diff --git a/example/bundle/assets/B3DMLoader-B2OeBq6-.js b/example/bundle/assets/B3DMLoader-B2OeBq6-.js new file mode 100644 index 00000000..b06141a9 --- /dev/null +++ b/example/bundle/assets/B3DMLoader-B2OeBq6-.js @@ -0,0 +1 @@ +import{r as B,F as m,B as y}from"./readMagicBytes-Da5ueiou.js";import{L}from"./LoaderBase-CVSPpjX2.js";import{j as w,bc as x}from"./three.module-DpclfMcJ.js";import{G as U}from"./GLTFLoader-DkJa3Jo5.js";class C extends L{parse(s){const t=new DataView(s),T=B(t);console.assert(T==="b3dm");const u=t.getUint32(4,!0);console.assert(u===1);const h=t.getUint32(8,!0);console.assert(h===s.byteLength);const o=t.getUint32(12,!0),a=t.getUint32(16,!0),n=t.getUint32(20,!0),r=t.getUint32(24,!0),b=28,e=s.slice(b,b+o+a),g=new m(e,0,o,a),c=b+o+a,i=s.slice(c,c+n+r),l=new y(i,g.getData("BATCH_LENGTH"),0,n,r),f=c+n+r,d=new Uint8Array(s,f,h-f);return{version:u,featureTable:g,batchTable:l,glbBytes:d}}}class j extends C{constructor(s=x){super(),this.manager=s,this.adjustmentTransform=new w}parse(s){const t=super.parse(s),T=t.glbBytes.slice().buffer;return new Promise((u,h)=>{const o=this.manager,a=this.fetchOptions,n=o.getHandler("path.gltf")||new U(o);a.credentials==="include"&&a.mode==="cors"&&n.setCrossOrigin("use-credentials"),"credentials"in a&&n.setWithCredentials(a.credentials==="include"),a.headers&&n.setRequestHeader(a.headers);let r=this.workingPath;!/[\\/]$/.test(r)&&r.length&&(r+="/");const b=this.adjustmentTransform;n.parse(T,r,e=>{const{batchTable:g,featureTable:c}=t,{scene:i}=e,l=c.getData("RTC_CENTER");l&&(i.position.x+=l[0],i.position.y+=l[1],i.position.z+=l[2]),e.scene.updateMatrix(),e.scene.matrix.multiply(b),e.scene.matrix.decompose(e.scene.position,e.scene.quaternion,e.scene.scale),e.batchTable=g,e.featureTable=c,i.batchTable=g,i.featureTable=c,u(e)},h)})}}export{j as B}; diff --git a/example/bundle/assets/CMPTLoader-nLXQ3OXQ.js b/example/bundle/assets/CMPTLoader-nLXQ3OXQ.js new file mode 100644 index 00000000..e0af2352 --- /dev/null +++ b/example/bundle/assets/CMPTLoader-nLXQ3OXQ.js @@ -0,0 +1 @@ +import{j as g,bc as w,G as L}from"./three.module-DpclfMcJ.js";import{L as P}from"./LoaderBase-CVSPpjX2.js";import{r as d}from"./readMagicBytes-Da5ueiou.js";import{B as T}from"./B3DMLoader-B2OeBq6-.js";import{P as b}from"./PNTSLoader-BMN5TswI.js";import{W as y,I as M}from"./I3DMLoader-BlebwdUJ.js";class k extends P{parse(s){const n=new DataView(s),h=d(n);console.assert(h==="cmpt",'CMPTLoader: The magic bytes equal "cmpt".');const p=n.getUint32(4,!0);console.assert(p===1,'CMPTLoader: The version listed in the header is "1".');const l=n.getUint32(8,!0);console.assert(l===s.byteLength,"CMPTLoader: The contents buffer length listed in the header matches the file.");const c=n.getUint32(12,!0),i=[];let o=16;for(let r=0;r{const o=new L;return i.forEach(r=>{o.add(r.scene)}),{tiles:i,scene:o}})}}export{V as C}; diff --git a/example/bundle/assets/CameraControls-DhgPIfmg.js b/example/bundle/assets/CameraControls-DhgPIfmg.js new file mode 100644 index 00000000..34cf78d3 --- /dev/null +++ b/example/bundle/assets/CameraControls-DhgPIfmg.js @@ -0,0 +1,192 @@ +import{R as u0,V as a0,k as zn,aN as of,aO as Vr,z as Ci,_ as Va,O as s0,a as ew,S as Ga,P as uf,aA as tw,aP as nw,ah as rw,aQ as lw,C as iw,W as c0,aR as ow,aS as uw,aT as aw,aU as sw,s as cw,aV as fw,g as Vd,aW as dw,b as Gd,aX as pw,p as vw,aY as f0,$ as Ln,a0 as Er,aZ as li,x as ur,a6 as hw,a_ as Gr,a$ as d0,aE as p0,b0 as Za,o as mw,a3 as Vf,b1 as gw,b2 as yw,b3 as ww,b4 as Sw,n as Ew,F as Na,t as _w,L as kw,b5 as Rh,a2 as xw,b6 as Cw,b7 as Pw,ab as Mw,b8 as Tw,b9 as Rw}from"./three.module-DpclfMcJ.js";import{E as Nw}from"./EnvironmentControls-C8X7oAWq.js";import{G as zw}from"./GlobeControls-BUn2ddB7.js";import{T as Iw}from"./TilesRenderer-DdUhzUiO.js";function Lw(e,t){for(var n=0;ni[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function gs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v0={exports:{}},ys={},h0={exports:{}},Le={};/** + * @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 qo=Symbol.for("react.element"),Ow=Symbol.for("react.portal"),Fw=Symbol.for("react.fragment"),Dw=Symbol.for("react.strict_mode"),Uw=Symbol.for("react.profiler"),Aw=Symbol.for("react.provider"),Bw=Symbol.for("react.context"),jw=Symbol.for("react.forward_ref"),Hw=Symbol.for("react.suspense"),Ww=Symbol.for("react.memo"),Qw=Symbol.for("react.lazy"),Nh=Symbol.iterator;function Vw(e){return e===null||typeof e!="object"?null:(e=Nh&&e[Nh]||e["@@iterator"],typeof e=="function"?e:null)}var m0={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g0=Object.assign,y0={};function Fi(e,t,n){this.props=e,this.context=t,this.refs=y0,this.updater=n||m0}Fi.prototype.isReactComponent={};Fi.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};Fi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function w0(){}w0.prototype=Fi.prototype;function Zd(e,t,n){this.props=e,this.context=t,this.refs=y0,this.updater=n||m0}var Xd=Zd.prototype=new w0;Xd.constructor=Zd;g0(Xd,Fi.prototype);Xd.isPureReactComponent=!0;var zh=Array.isArray,S0=Object.prototype.hasOwnProperty,Yd={current:null},E0={key:!0,ref:!0,__self:!0,__source:!0};function _0(e,t,n){var i,o={},a=null,c=null;if(t!=null)for(i in t.ref!==void 0&&(c=t.ref),t.key!==void 0&&(a=""+t.key),t)S0.call(t,i)&&!E0.hasOwnProperty(i)&&(o[i]=t[i]);var d=arguments.length-2;if(d===1)o.children=n;else if(1>>1,ie=D[le];if(0>>1;leo(ct,Q))Eeo(ft,ct)?(D[le]=ft,D[Ee]=Q,le=Ee):(D[le]=ct,D[Ue]=Q,le=Ue);else if(Eeo(ft,Q))D[le]=ft,D[Ee]=Q,le=Ee;else break e}}return X}function o(D,X){var Q=D.sortIndex-X.sortIndex;return Q!==0?Q:D.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var v=[],y=[],g=1,m=null,S=3,C=!1,P=!1,R=!1,I=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(D){for(var X=n(y);X!==null;){if(X.callback===null)i(y);else if(X.startTime<=D)i(y),X.sortIndex=X.expirationTime,t(v,X);else break;X=n(y)}}function N(D){if(R=!1,x(D),!P)if(n(v)!==null)P=!0,ye(L);else{var X=n(y);X!==null&&Ke(N,X.startTime-D)}}function L(D,X){P=!1,R&&(R=!1,w(O),O=-1),C=!0;var Q=S;try{for(x(X),m=n(v);m!==null&&(!(m.expirationTime>X)||D&&!K());){var le=m.callback;if(typeof le=="function"){m.callback=null,S=m.priorityLevel;var ie=le(m.expirationTime<=X);X=e.unstable_now(),typeof ie=="function"?m.callback=ie:m===n(v)&&i(v),x(X)}else i(v);m=n(v)}if(m!==null)var we=!0;else{var Ue=n(y);Ue!==null&&Ke(N,Ue.startTime-X),we=!1}return we}finally{m=null,S=Q,C=!1}}var A=!1,Z=null,O=-1,G=5,Y=-1;function K(){return!(e.unstable_now()-YD||125le?(D.sortIndex=Q,t(y,D),n(v)===null&&D===n(y)&&(R?(w(O),O=-1):R=!0,Ke(N,Q-le))):(D.sortIndex=ie,t(v,D),P||C||(P=!0,ye(L))),D},e.unstable_shouldYield=K,e.unstable_wrapCallback=function(D){var X=S;return function(){var Q=S;S=X;try{return D.apply(this,arguments)}finally{S=Q}}}})(M0);P0.exports=M0;var nS=P0.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var rS=V,gn=nS;function $(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gf=Object.prototype.hasOwnProperty,lS=/^[: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]*$/,Lh={},Oh={};function iS(e){return Gf.call(Oh,e)?!0:Gf.call(Lh,e)?!1:lS.test(e)?Oh[e]=!0:(Lh[e]=!0,!1)}function oS(e,t,n,i){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function uS(e,t,n,i){if(t===null||typeof t>"u"||oS(e,t,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function bt(e,t,n,i,o,a,c){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=i,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=c}var Ot={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ot[e]=new bt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ot[t]=new bt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ot[e]=new bt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ot[e]=new bt(e,2,!1,e,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(e){Ot[e]=new bt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ot[e]=new bt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ot[e]=new bt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ot[e]=new bt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ot[e]=new bt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jd=/[\-:]([a-z])/g;function $d(e){return e[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(e){var t=e.replace(Jd,$d);Ot[t]=new bt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Jd,$d);Ot[t]=new bt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Jd,$d);Ot[t]=new bt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ot[e]=new bt(e,1,!1,e.toLowerCase(),null,!1,!1)});Ot.xlinkHref=new bt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ot[e]=new bt(e,1,!1,e.toLowerCase(),null,!0,!0)});function qd(e,t,n,i){var o=Ot.hasOwnProperty(t)?Ot[t]:null;(o!==null?o.type!==0:i||!(2d||o[c]!==a[d]){var v=` +`+o[c].replace(" at new "," at ");return e.displayName&&v.includes("")&&(v=v.replace("",e.displayName)),v}while(1<=c&&0<=d);break}}}finally{cf=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?wo(e):""}function aS(e){switch(e.tag){case 5:return wo(e.type);case 16:return wo("Lazy");case 13:return wo("Suspense");case 19:return wo("SuspenseList");case 0:case 2:case 15:return e=ff(e.type,!1),e;case 11:return e=ff(e.type.render,!1),e;case 1:return e=ff(e.type,!0),e;default:return""}}function Kf(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case oi:return"Fragment";case ii:return"Portal";case Zf:return"Profiler";case bd:return"StrictMode";case Xf:return"Suspense";case Yf:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case N0:return(e.displayName||"Context")+".Consumer";case R0:return(e._context.displayName||"Context")+".Provider";case ep:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tp:return t=e.displayName||null,t!==null?t:Kf(e.type)||"Memo";case Br:t=e._payload,e=e._init;try{return Kf(e(t))}catch{}}return null}function sS(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Kf(t);case 8:return t===bd?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function rl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function I0(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function cS(e){var t=I0(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),i=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(c){i=""+c,a.call(this,c)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(c){i=""+c},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function fa(e){e._valueTracker||(e._valueTracker=cS(e))}function L0(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=I0(e)?e.checked?"true":"false":e.value),e=i,e!==n?(t.setValue(e),!0):!1}function Xa(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Jf(e,t){var n=t.checked;return st({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Dh(e,t){var n=t.defaultValue==null?"":t.defaultValue,i=t.checked!=null?t.checked:t.defaultChecked;n=rl(t.value!=null?t.value:n),e._wrapperState={initialChecked:i,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function O0(e,t){t=t.checked,t!=null&&qd(e,"checked",t,!1)}function $f(e,t){O0(e,t);var n=rl(t.value),i=t.type;if(n!=null)i==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(i==="submit"||i==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qf(e,t.type,n):t.hasOwnProperty("defaultValue")&&qf(e,t.type,rl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Uh(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var i=t.type;if(!(i!=="submit"&&i!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function qf(e,t,n){(t!=="number"||Xa(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var So=Array.isArray;function yi(e,t,n,i){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=da.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oo(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ko={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},fS=["Webkit","ms","Moz","O"];Object.keys(ko).forEach(function(e){fS.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ko[t]=ko[e]})});function A0(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ko.hasOwnProperty(e)&&ko[e]?(""+t).trim():t+"px"}function B0(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var i=n.indexOf("--")===0,o=A0(n,t[n],i);n==="float"&&(n="cssFloat"),i?e.setProperty(n,o):e[n]=o}}var dS=st({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 td(e,t){if(t){if(dS[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error($(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error($(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error($(61))}if(t.style!=null&&typeof t.style!="object")throw Error($(62))}}function nd(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 rd=null;function np(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ld=null,wi=null,Si=null;function jh(e){if(e=tu(e)){if(typeof ld!="function")throw Error($(280));var t=e.stateNode;t&&(t=ks(t),ld(e.stateNode,e.type,t))}}function j0(e){wi?Si?Si.push(e):Si=[e]:wi=e}function H0(){if(wi){var e=wi,t=Si;if(Si=wi=null,jh(e),t)for(e=0;e>>=0,e===0?32:31-(kS(e)/xS|0)|0}var pa=64,va=4194304;function Eo(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function $a(e,t){var n=e.pendingLanes;if(n===0)return 0;var i=0,o=e.suspendedLanes,a=e.pingedLanes,c=n&268435455;if(c!==0){var d=c&~o;d!==0?i=Eo(d):(a&=c,a!==0&&(i=Eo(a)))}else c=n&~o,c!==0?i=Eo(c):a!==0&&(i=Eo(a));if(i===0)return 0;if(t!==0&&t!==i&&!(t&o)&&(o=i&-i,a=t&-t,o>=a||o===16&&(a&4194240)!==0))return t;if(i&4&&(i|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=i;0n;n++)t.push(e);return t}function bo(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Xn(t),e[t]=n}function TS(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var i=e.eventTimes;for(e=e.expirationTimes;0=Co),Kh=" ",Jh=!1;function ug(e,t){switch(e){case"keyup":return nE.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ag(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ui=!1;function lE(e,t){switch(e){case"compositionend":return ag(t);case"keypress":return t.which!==32?null:(Jh=!0,Kh);case"textInput":return e=t.data,e===Kh&&Jh?null:e;default:return null}}function iE(e,t){if(ui)return e==="compositionend"||!cp&&ug(e,t)?(e=ig(),Oa=up=Zr=null,ui=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=em(n)}}function dg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?dg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pg(){for(var e=window,t=Xa();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xa(e.document)}return t}function fp(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function vE(e){var t=pg(),n=e.focusedElem,i=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&dg(n.ownerDocument.documentElement,n)){if(i!==null&&fp(n)){if(t=i.start,e=i.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,a=Math.min(i.start,o);i=i.end===void 0?a:Math.min(i.end,o),!e.extend&&a>i&&(o=i,i=a,a=o),o=tm(n,a);var c=tm(n,i);o&&c&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==c.node||e.focusOffset!==c.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),a>i?(e.addRange(t),e.extend(c.node,c.offset)):(t.setEnd(c.node,c.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ai=null,cd=null,Mo=null,fd=!1;function nm(e,t,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fd||ai==null||ai!==Xa(i)||(i=ai,"selectionStart"in i&&fp(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}),Mo&&jo(Mo,i)||(Mo=i,i=es(cd,"onSelect"),0fi||(e.current=gd[fi],gd[fi]=null,fi--)}function qe(e,t){fi++,gd[fi]=e.current,e.current=t}var ll={},Gt=ol(ll),un=ol(!1),zl=ll;function Mi(e,t){var n=e.type.contextTypes;if(!n)return ll;var i=e.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===t)return i.__reactInternalMemoizedMaskedChildContext;var o={},a;for(a in n)o[a]=t[a];return i&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function an(e){return e=e.childContextTypes,e!=null}function ns(){tt(un),tt(Gt)}function sm(e,t,n){if(Gt.current!==ll)throw Error($(168));qe(Gt,t),qe(un,n)}function _g(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var o in i)if(!(o in t))throw Error($(108,sS(e)||"Unknown",o));return st({},n,i)}function rs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ll,zl=Gt.current,qe(Gt,e),qe(un,un.current),!0}function cm(e,t,n){var i=e.stateNode;if(!i)throw Error($(169));n?(e=_g(e,t,zl),i.__reactInternalMemoizedMergedChildContext=e,tt(un),tt(Gt),qe(Gt,e)):tt(un),qe(un,n)}var yr=null,xs=!1,Cf=!1;function kg(e){yr===null?yr=[e]:yr.push(e)}function PE(e){xs=!0,kg(e)}function ul(){if(!Cf&&yr!==null){Cf=!0;var e=0,t=Ze;try{var n=yr;for(Ze=1;e>=c,o-=c,wr=1<<32-Xn(t)+o|n<O?(G=Z,Z=null):G=Z.sibling;var Y=S(w,Z,x[O],N);if(Y===null){Z===null&&(Z=G);break}e&&Z&&Y.alternate===null&&t(w,Z),E=a(Y,E,O),A===null?L=Y:A.sibling=Y,A=Y,Z=G}if(O===x.length)return n(w,Z),it&&kl(w,O),L;if(Z===null){for(;OO?(G=Z,Z=null):G=Z.sibling;var K=S(w,Z,Y.value,N);if(K===null){Z===null&&(Z=G);break}e&&Z&&K.alternate===null&&t(w,Z),E=a(K,E,O),A===null?L=K:A.sibling=K,A=K,Z=G}if(Y.done)return n(w,Z),it&&kl(w,O),L;if(Z===null){for(;!Y.done;O++,Y=x.next())Y=m(w,Y.value,N),Y!==null&&(E=a(Y,E,O),A===null?L=Y:A.sibling=Y,A=Y);return it&&kl(w,O),L}for(Z=i(w,Z);!Y.done;O++,Y=x.next())Y=C(Z,w,O,Y.value,N),Y!==null&&(e&&Y.alternate!==null&&Z.delete(Y.key===null?O:Y.key),E=a(Y,E,O),A===null?L=Y:A.sibling=Y,A=Y);return e&&Z.forEach(function(ae){return t(w,ae)}),it&&kl(w,O),L}function I(w,E,x,N){if(typeof x=="object"&&x!==null&&x.type===oi&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ca:e:{for(var L=x.key,A=E;A!==null;){if(A.key===L){if(L=x.type,L===oi){if(A.tag===7){n(w,A.sibling),E=o(A,x.props.children),E.return=w,w=E;break e}}else if(A.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===Br&&pm(L)===A.type){n(w,A.sibling),E=o(A,x.props),E.ref=fo(w,A,x),E.return=w,w=E;break e}n(w,A);break}else t(w,A);A=A.sibling}x.type===oi?(E=Nl(x.props.children,w.mode,N,x.key),E.return=w,w=E):(N=Wa(x.type,x.key,x.props,null,w.mode,N),N.ref=fo(w,E,x),N.return=w,w=N)}return c(w);case ii:e:{for(A=x.key;E!==null;){if(E.key===A)if(E.tag===4&&E.stateNode.containerInfo===x.containerInfo&&E.stateNode.implementation===x.implementation){n(w,E.sibling),E=o(E,x.children||[]),E.return=w,w=E;break e}else{n(w,E);break}else t(w,E);E=E.sibling}E=Lf(x,w.mode,N),E.return=w,w=E}return c(w);case Br:return A=x._init,I(w,E,A(x._payload),N)}if(So(x))return P(w,E,x,N);if(oo(x))return R(w,E,x,N);Ea(w,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,E!==null&&E.tag===6?(n(w,E.sibling),E=o(E,x),E.return=w,w=E):(n(w,E),E=If(x,w.mode,N),E.return=w,w=E),c(w)):n(w,E)}return I}var Ri=Mg(!0),Tg=Mg(!1),os=ol(null),us=null,vi=null,hp=null;function mp(){hp=vi=us=null}function gp(e){var t=os.current;tt(os),e._currentValue=t}function Sd(e,t,n){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function _i(e,t){us=e,hp=vi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(on=!0),e.firstContext=null)}function Dn(e){var t=e._currentValue;if(hp!==e)if(e={context:e,memoizedValue:t,next:null},vi===null){if(us===null)throw Error($(308));vi=e,us.dependencies={lanes:0,firstContext:e}}else vi=vi.next=e;return t}var Pl=null;function yp(e){Pl===null?Pl=[e]:Pl.push(e)}function Rg(e,t,n,i){var o=t.interleaved;return o===null?(n.next=n,yp(t)):(n.next=o.next,o.next=n),t.interleaved=n,Cr(e,i)}function Cr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var jr=!1;function wp(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ng(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function _r(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function br(e,t,n){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,Ae&2){var o=i.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),i.pending=t,Cr(e,n)}return o=i.interleaved,o===null?(t.next=t,yp(i)):(t.next=o.next,o.next=t),i.interleaved=t,Cr(e,n)}function Da(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,lp(e,n)}}function vm(e,t){var n=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var o=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var c={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?o=a=c:a=a.next=c,n=n.next}while(n!==null);a===null?o=a=t:a=a.next=t}else o=a=t;n={baseState:i.baseState,firstBaseUpdate:o,lastBaseUpdate:a,shared:i.shared,effects:i.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function as(e,t,n,i){var o=e.updateQueue;jr=!1;var a=o.firstBaseUpdate,c=o.lastBaseUpdate,d=o.shared.pending;if(d!==null){o.shared.pending=null;var v=d,y=v.next;v.next=null,c===null?a=y:c.next=y,c=v;var g=e.alternate;g!==null&&(g=g.updateQueue,d=g.lastBaseUpdate,d!==c&&(d===null?g.firstBaseUpdate=y:d.next=y,g.lastBaseUpdate=v))}if(a!==null){var m=o.baseState;c=0,g=y=v=null,d=a;do{var S=d.lane,C=d.eventTime;if((i&S)===S){g!==null&&(g=g.next={eventTime:C,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var P=e,R=d;switch(S=t,C=n,R.tag){case 1:if(P=R.payload,typeof P=="function"){m=P.call(C,m,S);break e}m=P;break e;case 3:P.flags=P.flags&-65537|128;case 0:if(P=R.payload,S=typeof P=="function"?P.call(C,m,S):P,S==null)break e;m=st({},m,S);break e;case 2:jr=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,S=o.effects,S===null?o.effects=[d]:S.push(d))}else C={eventTime:C,lane:S,tag:d.tag,payload:d.payload,callback:d.callback,next:null},g===null?(y=g=C,v=m):g=g.next=C,c|=S;if(d=d.next,d===null){if(d=o.shared.pending,d===null)break;S=d,d=S.next,S.next=null,o.lastBaseUpdate=S,o.shared.pending=null}}while(!0);if(g===null&&(v=m),o.baseState=v,o.firstBaseUpdate=y,o.lastBaseUpdate=g,t=o.shared.interleaved,t!==null){o=t;do c|=o.lane,o=o.next;while(o!==t)}else a===null&&(o.shared.lanes=0);Ol|=c,e.lanes=c,e.memoizedState=m}}function hm(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var i=Mf.transition;Mf.transition={};try{e(!1),t()}finally{Ze=n,Mf.transition=i}}function Xg(){return Un().memoizedState}function NE(e,t,n){var i=tl(e);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},Yg(e))Kg(t,n);else if(n=Rg(e,t,n,i),n!==null){var o=$t();Yn(n,e,i,o),Jg(n,t,i)}}function zE(e,t,n){var i=tl(e),o={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(Yg(e))Kg(t,o);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var c=t.lastRenderedState,d=a(c,n);if(o.hasEagerState=!0,o.eagerState=d,Kn(d,c)){var v=t.interleaved;v===null?(o.next=o,yp(t)):(o.next=v.next,v.next=o),t.interleaved=o;return}}catch{}finally{}n=Rg(e,t,o,i),n!==null&&(o=$t(),Yn(n,e,i,o),Jg(n,t,i))}}function Yg(e){var t=e.alternate;return e===at||t!==null&&t===at}function Kg(e,t){To=cs=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Jg(e,t,n){if(n&4194240){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,lp(e,n)}}var fs={readContext:Dn,useCallback:Wt,useContext:Wt,useEffect:Wt,useImperativeHandle:Wt,useInsertionEffect:Wt,useLayoutEffect:Wt,useMemo:Wt,useReducer:Wt,useRef:Wt,useState:Wt,useDebugValue:Wt,useDeferredValue:Wt,useTransition:Wt,useMutableSource:Wt,useSyncExternalStore:Wt,useId:Wt,unstable_isNewReconciler:!1},IE={readContext:Dn,useCallback:function(e,t){return ir().memoizedState=[e,t===void 0?null:t],e},useContext:Dn,useEffect:gm,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Aa(4194308,4,Wg.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Aa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Aa(4,2,e,t)},useMemo:function(e,t){var n=ir();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var i=ir();return t=n!==void 0?n(t):t,i.memoizedState=i.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},i.queue=e,e=e.dispatch=NE.bind(null,at,e),[i.memoizedState,e]},useRef:function(e){var t=ir();return e={current:e},t.memoizedState=e},useState:mm,useDebugValue:Mp,useDeferredValue:function(e){return ir().memoizedState=e},useTransition:function(){var e=mm(!1),t=e[0];return e=RE.bind(null,e[1]),ir().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=at,o=ir();if(it){if(n===void 0)throw Error($(407));n=n()}else{if(n=t(),Rt===null)throw Error($(349));Ll&30||Og(i,t,n)}o.memoizedState=n;var a={value:n,getSnapshot:t};return o.queue=a,gm(Dg.bind(null,i,a,e),[e]),i.flags|=2048,Yo(9,Fg.bind(null,i,a,n,t),void 0,null),n},useId:function(){var e=ir(),t=Rt.identifierPrefix;if(it){var n=Sr,i=wr;n=(i&~(1<<32-Xn(i)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zo++,0<\/script>",e=e.removeChild(e.firstChild)):typeof i.is=="string"?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n==="select"&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[or]=t,e[Qo]=i,o1(e,t,!1,!1),t.stateNode=e;e:{switch(c=nd(n,i),n){case"dialog":be("cancel",e),be("close",e),o=i;break;case"iframe":case"object":case"embed":be("load",e),o=i;break;case"video":case"audio":for(o=0;o<_o.length;o++)be(_o[o],e);o=i;break;case"source":be("error",e),o=i;break;case"img":case"image":case"link":be("error",e),be("load",e),o=i;break;case"details":be("toggle",e),o=i;break;case"input":Dh(e,i),o=Jf(e,i),be("invalid",e);break;case"option":o=i;break;case"select":e._wrapperState={wasMultiple:!!i.multiple},o=st({},i,{value:void 0}),be("invalid",e);break;case"textarea":Ah(e,i),o=bf(e,i),be("invalid",e);break;default:o=i}td(n,o),d=o;for(a in d)if(d.hasOwnProperty(a)){var v=d[a];a==="style"?B0(e,v):a==="dangerouslySetInnerHTML"?(v=v?v.__html:void 0,v!=null&&U0(e,v)):a==="children"?typeof v=="string"?(n!=="textarea"||v!=="")&&Oo(e,v):typeof v=="number"&&Oo(e,""+v):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(Lo.hasOwnProperty(a)?v!=null&&a==="onScroll"&&be("scroll",e):v!=null&&qd(e,a,v,c))}switch(n){case"input":fa(e),Uh(e,i,!1);break;case"textarea":fa(e),Bh(e);break;case"option":i.value!=null&&e.setAttribute("value",""+rl(i.value));break;case"select":e.multiple=!!i.multiple,a=i.value,a!=null?yi(e,!!i.multiple,a,!1):i.defaultValue!=null&&yi(e,!!i.multiple,i.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=ts)}switch(n){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Qt(t),null;case 6:if(e&&t.stateNode!=null)a1(e,t,e.memoizedProps,i);else{if(typeof i!="string"&&t.stateNode===null)throw Error($(166));if(n=Ml(Go.current),Ml(sr.current),Sa(t)){if(i=t.stateNode,n=t.memoizedProps,i[or]=t,(a=i.nodeValue!==n)&&(e=mn,e!==null))switch(e.tag){case 3:wa(i.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&wa(i.nodeValue,n,(e.mode&1)!==0)}a&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[or]=t,t.stateNode=i}return Qt(t),null;case 13:if(tt(ut),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(it&&hn!==null&&t.mode&1&&!(t.flags&128))Pg(),Ti(),t.flags|=98560,a=!1;else if(a=Sa(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error($(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error($(317));a[or]=t}else Ti(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Qt(t),a=!1}else Zn!==null&&(Dd(Zn),Zn=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||ut.current&1?kt===0&&(kt=3):Op())),t.updateQueue!==null&&(t.flags|=4),Qt(t),null);case 4:return Ni(),Td(e,t),e===null&&Ho(t.stateNode.containerInfo),Qt(t),null;case 10:return gp(t.type._context),Qt(t),null;case 17:return an(t.type)&&ns(),Qt(t),null;case 19:if(tt(ut),a=t.memoizedState,a===null)return Qt(t),null;if(i=(t.flags&128)!==0,c=a.rendering,c===null)if(i)po(a,!1);else{if(kt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=ss(e),c!==null){for(t.flags|=128,po(a,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)a=n,e=i,a.flags&=14680066,c=a.alternate,c===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=c.childLanes,a.lanes=c.lanes,a.child=c.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=c.memoizedProps,a.memoizedState=c.memoizedState,a.updateQueue=c.updateQueue,a.type=c.type,e=c.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return qe(ut,ut.current&1|2),t.child}e=e.sibling}a.tail!==null&&ht()>Ii&&(t.flags|=128,i=!0,po(a,!1),t.lanes=4194304)}else{if(!i)if(e=ss(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),po(a,!0),a.tail===null&&a.tailMode==="hidden"&&!c.alternate&&!it)return Qt(t),null}else 2*ht()-a.renderingStartTime>Ii&&n!==1073741824&&(t.flags|=128,i=!0,po(a,!1),t.lanes=4194304);a.isBackwards?(c.sibling=t.child,t.child=c):(n=a.last,n!==null?n.sibling=c:t.child=c,a.last=c)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ht(),t.sibling=null,n=ut.current,qe(ut,i?n&1|2:n&1),t):(Qt(t),null);case 22:case 23:return Lp(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?vn&1073741824&&(Qt(t),t.subtreeFlags&6&&(t.flags|=8192)):Qt(t),null;case 24:return null;case 25:return null}throw Error($(156,t.tag))}function jE(e,t){switch(pp(t),t.tag){case 1:return an(t.type)&&ns(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ni(),tt(un),tt(Gt),_p(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ep(t),null;case 13:if(tt(ut),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error($(340));Ti()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return tt(ut),null;case 4:return Ni(),null;case 10:return gp(t.type._context),null;case 22:case 23:return Lp(),null;case 24:return null;default:return null}}var ka=!1,Vt=!1,HE=typeof WeakSet=="function"?WeakSet:Set,ce=null;function hi(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){pt(e,t,i)}else n.current=null}function Rd(e,t,n){try{n()}catch(i){pt(e,t,i)}}var Tm=!1;function WE(e,t){if(dd=qa,e=pg(),fp(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var o=i.anchorOffset,a=i.focusNode;i=i.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var c=0,d=-1,v=-1,y=0,g=0,m=e,S=null;t:for(;;){for(var C;m!==n||o!==0&&m.nodeType!==3||(d=c+o),m!==a||i!==0&&m.nodeType!==3||(v=c+i),m.nodeType===3&&(c+=m.nodeValue.length),(C=m.firstChild)!==null;)S=m,m=C;for(;;){if(m===e)break t;if(S===n&&++y===o&&(d=c),S===a&&++g===i&&(v=c),(C=m.nextSibling)!==null)break;m=S,S=m.parentNode}m=C}n=d===-1||v===-1?null:{start:d,end:v}}else n=null}n=n||{start:0,end:0}}else n=null;for(pd={focusedElem:e,selectionRange:n},qa=!1,ce=t;ce!==null;)if(t=ce,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ce=e;else for(;ce!==null;){t=ce;try{var P=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(P!==null){var R=P.memoizedProps,I=P.memoizedState,w=t.stateNode,E=w.getSnapshotBeforeUpdate(t.elementType===t.type?R:Vn(t.type,R),I);w.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error($(163))}}catch(N){pt(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,ce=e;break}ce=t.return}return P=Tm,Tm=!1,P}function Ro(e,t,n){var i=t.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var o=i=i.next;do{if((o.tag&e)===e){var a=o.destroy;o.destroy=void 0,a!==void 0&&Rd(t,n,a)}o=o.next}while(o!==i)}}function Ms(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var i=n.create;n.destroy=i()}n=n.next}while(n!==t)}}function Nd(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function s1(e){var t=e.alternate;t!==null&&(e.alternate=null,s1(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[or],delete t[Qo],delete t[md],delete t[xE],delete t[CE])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function c1(e){return e.tag===5||e.tag===3||e.tag===4}function Rm(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||c1(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function zd(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ts));else if(i!==4&&(e=e.child,e!==null))for(zd(e,t,n),e=e.sibling;e!==null;)zd(e,t,n),e=e.sibling}function Id(e,t,n){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(i!==4&&(e=e.child,e!==null))for(Id(e,t,n),e=e.sibling;e!==null;)Id(e,t,n),e=e.sibling}var It=null,Gn=!1;function Ur(e,t,n){for(n=n.child;n!==null;)f1(e,t,n),n=n.sibling}function f1(e,t,n){if(ar&&typeof ar.onCommitFiberUnmount=="function")try{ar.onCommitFiberUnmount(ws,n)}catch{}switch(n.tag){case 5:Vt||hi(n,t);case 6:var i=It,o=Gn;It=null,Ur(e,t,n),It=i,Gn=o,It!==null&&(Gn?(e=It,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):It.removeChild(n.stateNode));break;case 18:It!==null&&(Gn?(e=It,n=n.stateNode,e.nodeType===8?xf(e.parentNode,n):e.nodeType===1&&xf(e,n),Ao(e)):xf(It,n.stateNode));break;case 4:i=It,o=Gn,It=n.stateNode.containerInfo,Gn=!0,Ur(e,t,n),It=i,Gn=o;break;case 0:case 11:case 14:case 15:if(!Vt&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){o=i=i.next;do{var a=o,c=a.destroy;a=a.tag,c!==void 0&&(a&2||a&4)&&Rd(n,t,c),o=o.next}while(o!==i)}Ur(e,t,n);break;case 1:if(!Vt&&(hi(n,t),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(d){pt(n,t,d)}Ur(e,t,n);break;case 21:Ur(e,t,n);break;case 22:n.mode&1?(Vt=(i=Vt)||n.memoizedState!==null,Ur(e,t,n),Vt=i):Ur(e,t,n);break;default:Ur(e,t,n)}}function Nm(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new HE),t.forEach(function(i){var o=$E.bind(null,e,i);n.has(i)||(n.add(i),i.then(o,o))})}}function Wn(e,t){var n=t.deletions;if(n!==null)for(var i=0;io&&(o=c),i&=~a}if(i=o,i=ht()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*VE(i/1960))-i,10e?16:e,Xr===null)var i=!1;else{if(e=Xr,Xr=null,vs=0,Ae&6)throw Error($(331));var o=Ae;for(Ae|=4,ce=e.current;ce!==null;){var a=ce,c=a.child;if(ce.flags&16){var d=a.deletions;if(d!==null){for(var v=0;vht()-zp?Rl(e,0):Np|=n),sn(e,t)}function w1(e,t){t===0&&(e.mode&1?(t=va,va<<=1,!(va&130023424)&&(va=4194304)):t=1);var n=$t();e=Cr(e,t),e!==null&&(bo(e,t,n),sn(e,n))}function JE(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),w1(e,n)}function $E(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:i=e.stateNode;break;default:throw Error($(314))}i!==null&&i.delete(t),w1(e,n)}var S1;S1=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||un.current)on=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return on=!1,AE(e,t,n);on=!!(e.flags&131072)}else on=!1,it&&t.flags&1048576&&xg(t,is,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;Ba(e,t),e=t.pendingProps;var o=Mi(t,Gt.current);_i(t,n),o=xp(null,t,i,e,o,n);var a=Cp();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,an(i)?(a=!0,rs(t)):a=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,wp(t),o.updater=Ps,t.stateNode=o,o._reactInternals=t,_d(t,i,e,n),t=Cd(null,t,i,!0,a,n)):(t.tag=0,it&&a&&dp(t),Jt(null,t,o,n),t=t.child),t;case 16:i=t.elementType;e:{switch(Ba(e,t),e=t.pendingProps,o=i._init,i=o(i._payload),t.type=i,o=t.tag=bE(i),e=Vn(i,e),o){case 0:t=xd(null,t,i,e,n);break e;case 1:t=Cm(null,t,i,e,n);break e;case 11:t=km(null,t,i,e,n);break e;case 14:t=xm(null,t,i,Vn(i.type,e),n);break e}throw Error($(306,i,""))}return t;case 0:return i=t.type,o=t.pendingProps,o=t.elementType===i?o:Vn(i,o),xd(e,t,i,o,n);case 1:return i=t.type,o=t.pendingProps,o=t.elementType===i?o:Vn(i,o),Cm(e,t,i,o,n);case 3:e:{if(r1(t),e===null)throw Error($(387));i=t.pendingProps,a=t.memoizedState,o=a.element,Ng(e,t),as(t,i,null,n);var c=t.memoizedState;if(i=c.element,a.isDehydrated)if(a={element:i,isDehydrated:!1,cache:c.cache,pendingSuspenseBoundaries:c.pendingSuspenseBoundaries,transitions:c.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){o=zi(Error($(423)),t),t=Pm(e,t,i,n,o);break e}else if(i!==o){o=zi(Error($(424)),t),t=Pm(e,t,i,n,o);break e}else for(hn=qr(t.stateNode.containerInfo.firstChild),mn=t,it=!0,Zn=null,n=Tg(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ti(),i===o){t=Pr(e,t,n);break e}Jt(e,t,i,n)}t=t.child}return t;case 5:return zg(t),e===null&&wd(t),i=t.type,o=t.pendingProps,a=e!==null?e.memoizedProps:null,c=o.children,vd(i,o)?c=null:a!==null&&vd(i,a)&&(t.flags|=32),n1(e,t),Jt(e,t,c,n),t.child;case 6:return e===null&&wd(t),null;case 13:return l1(e,t,n);case 4:return Sp(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ri(t,null,i,n):Jt(e,t,i,n),t.child;case 11:return i=t.type,o=t.pendingProps,o=t.elementType===i?o:Vn(i,o),km(e,t,i,o,n);case 7:return Jt(e,t,t.pendingProps,n),t.child;case 8:return Jt(e,t,t.pendingProps.children,n),t.child;case 12:return Jt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(i=t.type._context,o=t.pendingProps,a=t.memoizedProps,c=o.value,qe(os,i._currentValue),i._currentValue=c,a!==null)if(Kn(a.value,c)){if(a.children===o.children&&!un.current){t=Pr(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var d=a.dependencies;if(d!==null){c=a.child;for(var v=d.firstContext;v!==null;){if(v.context===i){if(a.tag===1){v=_r(-1,n&-n),v.tag=2;var y=a.updateQueue;if(y!==null){y=y.shared;var g=y.pending;g===null?v.next=v:(v.next=g.next,g.next=v),y.pending=v}}a.lanes|=n,v=a.alternate,v!==null&&(v.lanes|=n),Sd(a.return,n,t),d.lanes|=n;break}v=v.next}}else if(a.tag===10)c=a.type===t.type?null:a.child;else if(a.tag===18){if(c=a.return,c===null)throw Error($(341));c.lanes|=n,d=c.alternate,d!==null&&(d.lanes|=n),Sd(c,n,t),c=a.sibling}else c=a.child;if(c!==null)c.return=a;else for(c=a;c!==null;){if(c===t){c=null;break}if(a=c.sibling,a!==null){a.return=c.return,c=a;break}c=c.return}a=c}Jt(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,i=t.pendingProps.children,_i(t,n),o=Dn(o),i=i(o),t.flags|=1,Jt(e,t,i,n),t.child;case 14:return i=t.type,o=Vn(i,t.pendingProps),o=Vn(i.type,o),xm(e,t,i,o,n);case 15:return e1(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,o=t.pendingProps,o=t.elementType===i?o:Vn(i,o),Ba(e,t),t.tag=1,an(i)?(e=!0,rs(t)):e=!1,_i(t,n),$g(t,i,o),_d(t,i,o,n),Cd(null,t,i,!0,e,n);case 19:return i1(e,t,n);case 22:return t1(e,t,n)}throw Error($(156,t.tag))};function E1(e,t){return Y0(e,t)}function qE(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 On(e,t,n,i){return new qE(e,t,n,i)}function Fp(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bE(e){if(typeof e=="function")return Fp(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ep)return 11;if(e===tp)return 14}return 2}function nl(e,t){var n=e.alternate;return n===null?(n=On(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wa(e,t,n,i,o,a){var c=2;if(i=e,typeof e=="function")Fp(e)&&(c=1);else if(typeof e=="string")c=5;else e:switch(e){case oi:return Nl(n.children,o,a,t);case bd:c=8,o|=8;break;case Zf:return e=On(12,n,t,o|2),e.elementType=Zf,e.lanes=a,e;case Xf:return e=On(13,n,t,o),e.elementType=Xf,e.lanes=a,e;case Yf:return e=On(19,n,t,o),e.elementType=Yf,e.lanes=a,e;case z0:return Rs(n,o,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R0:c=10;break e;case N0:c=9;break e;case ep:c=11;break e;case tp:c=14;break e;case Br:c=16,i=null;break e}throw Error($(130,e==null?e:typeof e,""))}return t=On(c,n,t,o),t.elementType=e,t.type=i,t.lanes=a,t}function Nl(e,t,n,i){return e=On(7,e,i,t),e.lanes=n,e}function Rs(e,t,n,i){return e=On(22,e,i,t),e.elementType=z0,e.lanes=n,e.stateNode={isHidden:!1},e}function If(e,t,n){return e=On(6,e,null,t),e.lanes=n,e}function Lf(e,t,n){return t=On(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function e_(e,t,n,i,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pf(0),this.expirationTimes=pf(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pf(0),this.identifierPrefix=i,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Dp(e,t,n,i,o,a,c,d,v){return e=new e_(e,t,n,d,v),t===1?(t=1,a===!0&&(t|=8)):t=0,a=On(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},wp(a),e}function t_(e,t,n){var i=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(C1)}catch(e){console.error(e)}}C1(),C0.exports=yn;var P1=C0.exports;const V2=gs(P1);var o_,Am=P1;o_=Am.createRoot,Am.hydrateRoot;var M1={exports:{}},Al={};/** + * @license React + * react-reconciler-constants.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. + */Al.ConcurrentRoot=1;Al.ContinuousEventPriority=4;Al.DefaultEventPriority=16;Al.DiscreteEventPriority=1;Al.IdleEventPriority=536870912;Al.LegacyRoot=0;M1.exports=Al;var gi=M1.exports;function u_(e){let t;const n=new Set,i=(y,g)=>{const m=typeof y=="function"?y(t):y;if(m!==t){const S=t;t=g?m:Object.assign({},t,m),n.forEach(C=>C(t,S))}},o=()=>t,a=(y,g=o,m=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let S=g(t);function C(){const P=g(t);if(!m(S,P)){const R=S;y(S=P,R)}}return n.add(C),()=>n.delete(C)},v={setState:i,getState:o,subscribe:(y,g,m)=>g||m?a(y,g,m):(n.add(y),()=>n.delete(y)),destroy:()=>n.clear()};return t=e(i,o,v),v}const a_=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),Bm=a_?V.useEffect:V.useLayoutEffect;function T1(e){const t=typeof e=="function"?u_(e):e,n=(i=t.getState,o=Object.is)=>{const[,a]=V.useReducer(I=>I+1,0),c=t.getState(),d=V.useRef(c),v=V.useRef(i),y=V.useRef(o),g=V.useRef(!1),m=V.useRef();m.current===void 0&&(m.current=i(c));let S,C=!1;(d.current!==c||v.current!==i||y.current!==o||g.current)&&(S=i(c),C=!o(m.current,S)),Bm(()=>{C&&(m.current=S),d.current=c,v.current=i,y.current=o,g.current=!1});const P=V.useRef(c);Bm(()=>{const I=()=>{try{const E=t.getState(),x=v.current(E);y.current(m.current,x)||(d.current=E,m.current=x,a())}catch{g.current=!0,a()}},w=t.subscribe(I);return t.getState()!==P.current&&I(),w},[]);const R=C?S:m.current;return V.useDebugValue(R),R};return Object.assign(n,t),n[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[n,t];return{next(){const o=i.length<=0;return{value:i.shift(),done:o}}}},n}const s_=e=>typeof e=="object"&&typeof e.then=="function",Tl=[];function R1(e,t,n=(i,o)=>i===o){if(e===t)return!0;if(!e||!t)return!1;const i=e.length;if(t.length!==i)return!1;for(let o=0;o0&&(a.timeout&&clearTimeout(a.timeout),a.timeout=setTimeout(a.remove,i.lifespan)),a.response;if(!n)throw a.promise}const o={keys:t,equal:i.equal,remove:()=>{const a=Tl.indexOf(o);a!==-1&&Tl.splice(a,1)},promise:(s_(e)?e:e(...t)).then(a=>{o.response=a,i.lifespan&&i.lifespan>0&&(o.timeout=setTimeout(o.remove,i.lifespan))}).catch(a=>o.error=a)};if(Tl.push(o),!n)throw o.promise}const c_=(e,t,n)=>N1(e,t,!1,n),f_=(e,t,n)=>void N1(e,t,!0,n),d_=e=>{if(e===void 0||e.length===0)Tl.splice(0,Tl.length);else{const t=Tl.find(n=>R1(e,n.keys,n.equal));t&&t.remove()}};var z1={exports:{}},I1={exports:{}},L1={};/** + * @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(e){function t(D,X){var Q=D.length;D.push(X);e:for(;0>>1,ie=D[le];if(0>>1;leo(ct,Q))Eeo(ft,ct)?(D[le]=ft,D[Ee]=Q,le=Ee):(D[le]=ct,D[Ue]=Q,le=Ue);else if(Eeo(ft,Q))D[le]=ft,D[Ee]=Q,le=Ee;else break e}}return X}function o(D,X){var Q=D.sortIndex-X.sortIndex;return Q!==0?Q:D.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var v=[],y=[],g=1,m=null,S=3,C=!1,P=!1,R=!1,I=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(D){for(var X=n(y);X!==null;){if(X.callback===null)i(y);else if(X.startTime<=D)i(y),X.sortIndex=X.expirationTime,t(v,X);else break;X=n(y)}}function N(D){if(R=!1,x(D),!P)if(n(v)!==null)P=!0,ye(L);else{var X=n(y);X!==null&&Ke(N,X.startTime-D)}}function L(D,X){P=!1,R&&(R=!1,w(O),O=-1),C=!0;var Q=S;try{for(x(X),m=n(v);m!==null&&(!(m.expirationTime>X)||D&&!K());){var le=m.callback;if(typeof le=="function"){m.callback=null,S=m.priorityLevel;var ie=le(m.expirationTime<=X);X=e.unstable_now(),typeof ie=="function"?m.callback=ie:m===n(v)&&i(v),x(X)}else i(v);m=n(v)}if(m!==null)var we=!0;else{var Ue=n(y);Ue!==null&&Ke(N,Ue.startTime-X),we=!1}return we}finally{m=null,S=Q,C=!1}}var A=!1,Z=null,O=-1,G=5,Y=-1;function K(){return!(e.unstable_now()-YD||125le?(D.sortIndex=Q,t(y,D),n(v)===null&&D===n(y)&&(R?(w(O),O=-1):R=!0,Ke(N,Q-le))):(D.sortIndex=ie,t(v,D),P||C||(P=!0,ye(L))),D},e.unstable_shouldYield=K,e.unstable_wrapCallback=function(D){var X=S;return function(){var Q=S;S=X;try{return D.apply(this,arguments)}finally{S=Q}}}})(L1);I1.exports=L1;var Ud=I1.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 p_=function(t){var n={},i=V,o=Ud,a=Object.assign;function c(r){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+r,u=1;uT||f[k]!==p[T]){var W=` +`+f[k].replace(" at new "," at ");return r.displayName&&W.includes("")&&(W=W.replace("",r.displayName)),W}while(1<=k&&0<=T);break}}}finally{pe=!1,Error.prepareStackTrace=u}return(r=r?r.displayName||r.name:"")?Ve(r):""}var ke=Object.prototype.hasOwnProperty,Pe=[],De=-1;function Oe(r){return{current:r}}function _e(r){0>De||(r.current=Pe[De],Pe[De]=null,De--)}function Me(r,l){De++,Pe[De]=r.current,r.current=l}var Fe={},Xe=Oe(Fe),Te=Oe(!1),Je=Fe;function Ut(r,l){var u=r.type.contextTypes;if(!u)return Fe;var s=r.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===l)return s.__reactInternalMemoizedMaskedChildContext;var f={},p;for(p in u)f[p]=l[p];return s&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=l,r.__reactInternalMemoizedMaskedChildContext=f),f}function mt(r){return r=r.childContextTypes,r!=null}function Nt(){_e(Te),_e(Xe)}function Qe(r,l,u){if(Xe.current!==Fe)throw Error(c(168));Me(Xe,l),Me(Te,u)}function St(r,l,u){var s=r.stateNode;if(l=l.childContextTypes,typeof s.getChildContext!="function")return u;s=s.getChildContext();for(var f in s)if(!(f in l))throw Error(c(108,O(r)||"Unknown",f));return a({},u,s)}function Ge(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Fe,Je=Xe.current,Me(Xe,r),Me(Te,Te.current),!0}function Be(r,l,u){var s=r.stateNode;if(!s)throw Error(c(169));u?(r=St(r,l,Je),s.__reactInternalMemoizedMergedChildContext=r,_e(Te),_e(Xe),Me(Xe,r)):_e(Te),Me(Te,u)}var nt=Math.clz32?Math.clz32:Jn,cr=Math.log,Xt=Math.LN2;function Jn(r){return r>>>=0,r===0?32:31-(cr(r)/Xt|0)|0}var gu=64,yu=4194304;function Hi(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function wu(r,l){var u=r.pendingLanes;if(u===0)return 0;var s=0,f=r.suspendedLanes,p=r.pingedLanes,k=u&268435455;if(k!==0){var T=k&~f;T!==0?s=Hi(T):(p&=k,p!==0&&(s=Hi(p)))}else k=u&~f,k!==0?s=Hi(k):p!==0&&(s=Hi(p));if(s===0)return 0;if(l!==0&&l!==s&&!(l&f)&&(f=s&-s,p=l&-l,f>=p||f===16&&(p&4194240)!==0))return l;if(s&4&&(s|=u&16),l=r.entangledLanes,l!==0)for(r=r.entanglements,l&=s;0u;u++)l.push(r);return l}function Wi(r,l,u){r.pendingLanes|=l,l!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,l=31-nt(l),r[l]=u}function vy(r,l){var u=r.pendingLanes&~l;r.pendingLanes=l,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=l,r.mutableReadLanes&=l,r.entangledLanes&=l,l=r.entanglements;var s=r.eventTimes;for(r=r.expirationTimes;0>=k,f-=k,pr=1<<32-nt(l)+f|u<He?(Mt=Ce,Ce=null):Mt=Ce.sibling;var We=Se(F,Ce,B[He],ue);if(We===null){Ce===null&&(Ce=Mt);break}r&&Ce&&We.alternate===null&&l(F,Ce),z=p(We,z,He),Re===null?ve=We:Re.sibling=We,Re=We,Ce=Mt}if(He===B.length)return u(F,Ce),rt&&hl(F,He),ve;if(Ce===null){for(;HeHe?(Mt=Ce,Ce=null):Mt=Ce.sibling;var Dr=Se(F,Ce,We.value,ue);if(Dr===null){Ce===null&&(Ce=Mt);break}r&&Ce&&Dr.alternate===null&&l(F,Ce),z=p(Dr,z,He),Re===null?ve=Dr:Re.sibling=Dr,Re=Dr,Ce=Mt}if(We.done)return u(F,Ce),rt&&hl(F,He),ve;if(Ce===null){for(;!We.done;He++,We=B.next())We=xe(F,We.value,ue),We!==null&&(z=p(We,z,He),Re===null?ve=We:Re.sibling=We,Re=We);return rt&&hl(F,He),ve}for(Ce=s(F,Ce);!We.done;He++,We=B.next())We=Ye(Ce,F,He,We.value,ue),We!==null&&(r&&We.alternate!==null&&Ce.delete(We.key===null?He:We.key),z=p(We,z,He),Re===null?ve=We:Re.sibling=We,Re=We);return r&&Ce.forEach(function(by){return l(F,by)}),rt&&hl(F,He),ve}function Mn(F,z,B,ue){if(typeof B=="object"&&B!==null&&B.type===g&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case v:e:{for(var ve=B.key,Re=z;Re!==null;){if(Re.key===ve){if(ve=B.type,ve===g){if(Re.tag===7){u(F,Re.sibling),z=f(Re,B.props.children),z.return=F,F=z;break e}}else if(Re.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===x&&pv(ve)===Re.type){u(F,Re.sibling),z=f(Re,B.props),z.ref=Gi(F,Re,B),z.return=F,F=z;break e}u(F,Re);break}else l(F,Re);Re=Re.sibling}B.type===g?(z=_l(B.props.children,F.mode,ue,B.key),z.return=F,F=z):(ue=ua(B.type,B.key,B.props,null,F.mode,ue),ue.ref=Gi(F,z,B),ue.return=F,F=ue)}return k(F);case y:e:{for(Re=B.key;z!==null;){if(z.key===Re)if(z.tag===4&&z.stateNode.containerInfo===B.containerInfo&&z.stateNode.implementation===B.implementation){u(F,z.sibling),z=f(z,B.children||[]),z.return=F,F=z;break e}else{u(F,z);break}else l(F,z);z=z.sibling}z=rf(B,F.mode,ue),z.return=F,F=z}return k(F);case x:return Re=B._init,Mn(F,z,Re(B._payload),ue)}if(ze(B))return ge(F,z,B,ue);if(A(B))return Ht(F,z,B,ue);Nu(F,B)}return typeof B=="string"&&B!==""||typeof B=="number"?(B=""+B,z!==null&&z.tag===6?(u(F,z.sibling),z=f(z,B),z.return=F,F=z):(u(F,z),z=nf(B,F.mode,ue),z.return=F,F=z),k(F)):u(F,z)}return Mn}var Xl=vv(!0),hv=vv(!1),Zi={},kn=Oe(Zi),Xi=Oe(Zi),Yl=Oe(Zi);function tr(r){if(r===Zi)throw Error(c(174));return r}function Sc(r,l){Me(Yl,l),Me(Xi,r),Me(kn,Zi),r=Ke(l),_e(kn),Me(kn,r)}function Kl(){_e(kn),_e(Xi),_e(Yl)}function mv(r){var l=tr(Yl.current),u=tr(kn.current);l=D(u,r.type,l),u!==l&&(Me(Xi,r),Me(kn,l))}function Ec(r){Xi.current===r&&(_e(kn),_e(Xi))}var ot=Oe(0);function zu(r){for(var l=r;l!==null;){if(l.tag===13){var u=l.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||dl(u)||ji(u)))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if(l.flags&128)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var _c=[];function kc(){for(var r=0;r<_c.length;r++){var l=_c[r];Bl?l._workInProgressVersionPrimary=null:l._workInProgressVersionSecondary=null}_c.length=0}var Iu=d.ReactCurrentDispatcher,xn=d.ReactCurrentBatchConfig,Jl=0,dt=null,At=null,Pt=null,Lu=!1,Yi=!1,Ki=0,xy=0;function Bt(){throw Error(c(321))}function xc(r,l){if(l===null)return!1;for(var u=0;uu?u:4,r(!0);var s=xn.transition;xn.transition={};try{r(!1),l()}finally{je=u,xn.transition=s}}function Nv(){return nr().memoizedState}function Py(r,l,u){var s=Lr(r);u={lane:s,action:u,hasEagerState:!1,eagerState:null,next:null},zv(r)?Iv(l,u):(Lv(r,l,u),u=Kt(),r=Cn(r,s,u),r!==null&&Ov(r,l,s))}function My(r,l,u){var s=Lr(r),f={lane:s,action:u,hasEagerState:!1,eagerState:null,next:null};if(zv(r))Iv(l,f);else{Lv(r,l,f);var p=r.alternate;if(r.lanes===0&&(p===null||p.lanes===0)&&(p=l.lastRenderedReducer,p!==null))try{var k=l.lastRenderedState,T=p(k,u);if(f.hasEagerState=!0,f.eagerState=T,qn(T,k))return}catch{}finally{}u=Kt(),r=Cn(r,s,u),r!==null&&Ov(r,l,s)}}function zv(r){var l=r.alternate;return r===dt||l!==null&&l===dt}function Iv(r,l){Yi=Lu=!0;var u=r.pending;u===null?l.next=l:(l.next=u.next,u.next=l),r.pending=l}function Lv(r,l,u){gt!==null&&r.mode&1&&!(Ne&2)?(r=l.interleaved,r===null?(u.next=u,er===null?er=[l]:er.push(l)):(u.next=r.next,r.next=u),l.interleaved=u):(r=l.pending,r===null?u.next=u:(u.next=r.next,r.next=u),l.pending=u)}function Ov(r,l,u){if(u&4194240){var s=l.lanes;s&=r.pendingLanes,u|=s,l.lanes=u,rc(r,u)}}var Au={readContext:Sn,useCallback:Bt,useContext:Bt,useEffect:Bt,useImperativeHandle:Bt,useInsertionEffect:Bt,useLayoutEffect:Bt,useMemo:Bt,useReducer:Bt,useRef:Bt,useState:Bt,useDebugValue:Bt,useDeferredValue:Bt,useTransition:Bt,useMutableSource:Bt,useSyncExternalStore:Bt,useId:Bt,unstable_isNewReconciler:!1},Ty={readContext:Sn,useCallback:function(r,l){return hr().memoizedState=[r,l===void 0?null:l],r},useContext:Sn,useEffect:Tc,useImperativeHandle:function(r,l,u){return u=u!=null?u.concat([r]):null,Du(4194308,4,Pv.bind(null,l,r),u)},useLayoutEffect:function(r,l){return Du(4194308,4,r,l)},useInsertionEffect:function(r,l){return Du(4,2,r,l)},useMemo:function(r,l){var u=hr();return l=l===void 0?null:l,r=r(),u.memoizedState=[r,l],r},useReducer:function(r,l,u){var s=hr();return l=u!==void 0?u(l):l,s.memoizedState=s.baseState=l,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:l},s.queue=r,r=r.dispatch=Py.bind(null,dt,r),[s.memoizedState,r]},useRef:function(r){var l=hr();return r={current:r},l.memoizedState=r},useState:Mc,useDebugValue:Rc,useDeferredValue:function(r){var l=Mc(r),u=l[0],s=l[1];return Tc(function(){var f=xn.transition;xn.transition={};try{s(r)}finally{xn.transition=f}},[r]),u},useTransition:function(){var r=Mc(!1),l=r[0];return r=Cy.bind(null,r[1]),hr().memoizedState=r,[l,r]},useMutableSource:function(){},useSyncExternalStore:function(r,l,u){var s=dt,f=hr();if(rt){if(u===void 0)throw Error(c(407));u=u()}else{if(u=l(),gt===null)throw Error(c(349));Jl&30||wv(s,l,u)}f.memoizedState=u;var p={value:u,getSnapshot:l};return f.queue=p,Tc(Ev.bind(null,s,p,r),[r]),s.flags|=2048,Ji(9,Sv.bind(null,s,p,u,l),void 0,null),u},useId:function(){var r=hr(),l=gt.identifierPrefix;if(rt){var u=vr,s=pr;u=(s&~(1<<32-nt(s)-1)).toString(32)+u,l=":"+l+"R"+u,u=Ki++,0Yc&&(l.flags|=128,s=!0,eo(f,!1),l.lanes=4194304)}else{if(!s)if(r=zu(p),r!==null){if(l.flags|=128,s=!0,r=r.updateQueue,r!==null&&(l.updateQueue=r,l.flags|=4),eo(f,!0),f.tail===null&&f.tailMode==="hidden"&&!p.alternate&&!rt)return jt(l),null}else 2*Ct()-f.renderingStartTime>Yc&&u!==1073741824&&(l.flags|=128,s=!0,eo(f,!1),l.lanes=4194304);f.isBackwards?(p.sibling=l.child,l.child=p):(r=f.last,r!==null?r.sibling=p:l.child=p,f.last=p)}return f.tail!==null?(l=f.tail,f.rendering=l,f.tail=l.sibling,f.renderingStartTime=Ct(),l.sibling=null,r=ot.current,Me(ot,s?r&1|2:r&1),l):(jt(l),null);case 22:case 23:return bc(),s=l.memoizedState!==null,r!==null&&r.memoizedState!==null!==s&&(l.flags|=8192),s&&l.mode&1?pn&1073741824&&(jt(l),en&&l.subtreeFlags&6&&(l.flags|=8192)):jt(l),null;case 24:return null;case 25:return null}throw Error(c(156,l.tag))}var Ly=d.ReactCurrentOwner,dn=!1;function Yt(r,l,u,s){l.child=r===null?hv(l,null,u,s):Xl(l,r.child,u,s)}function Wv(r,l,u,s,f){u=u.render;var p=l.ref;return Ql(l,f),s=Cc(r,l,u,s,p,f),u=Pc(),r!==null&&!dn?(l.updateQueue=r.updateQueue,l.flags&=-2053,r.lanes&=~f,mr(r,l,f)):(rt&&u&&hc(l),l.flags|=1,Yt(r,l,s,f),l.child)}function Qv(r,l,u,s,f){if(r===null){var p=u.type;return typeof p=="function"&&!tf(p)&&p.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(l.tag=15,l.type=p,Vv(r,l,p,s,f)):(r=ua(u.type,null,s,l,l.mode,f),r.ref=l.ref,r.return=l,l.child=r)}if(p=r.child,!(r.lanes&f)){var k=p.memoizedProps;if(u=u.compare,u=u!==null?u:_u,u(k,s)&&r.ref===l.ref)return mr(r,l,f)}return l.flags|=1,r=Fr(p,s),r.ref=l.ref,r.return=l,l.child=r}function Vv(r,l,u,s,f){if(r!==null&&_u(r.memoizedProps,s)&&r.ref===l.ref)if(dn=!1,(r.lanes&f)!==0)r.flags&131072&&(dn=!0);else return l.lanes=r.lanes,mr(r,l,f);return Ic(r,l,u,s,f)}function Gv(r,l,u){var s=l.pendingProps,f=s.children,p=r!==null?r.memoizedState:null;if(s.mode==="hidden")if(!(l.mode&1))l.memoizedState={baseLanes:0,cachePool:null},Me($l,pn),pn|=u;else if(u&1073741824)l.memoizedState={baseLanes:0,cachePool:null},s=p!==null?p.baseLanes:u,Me($l,pn),pn|=s;else return r=p!==null?p.baseLanes|u:u,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:r,cachePool:null},l.updateQueue=null,Me($l,pn),pn|=r,null;else p!==null?(s=p.baseLanes|u,l.memoizedState=null):s=u,Me($l,pn),pn|=s;return Yt(r,l,f,u),l.child}function Zv(r,l){var u=l.ref;(r===null&&u!==null||r!==null&&r.ref!==u)&&(l.flags|=512,l.flags|=2097152)}function Ic(r,l,u,s,f){var p=mt(u)?Je:Xe.current;return p=Ut(l,p),Ql(l,f),u=Cc(r,l,u,s,p,f),s=Pc(),r!==null&&!dn?(l.updateQueue=r.updateQueue,l.flags&=-2053,r.lanes&=~f,mr(r,l,f)):(rt&&s&&hc(l),l.flags|=1,Yt(r,l,u,f),l.child)}function Xv(r,l,u,s,f){if(mt(u)){var p=!0;Ge(l)}else p=!1;if(Ql(l,f),l.stateNode===null)r!==null&&(r.alternate=null,l.alternate=null,l.flags|=2),uv(l,u,s),vc(l,u,s,f),s=!0;else if(r===null){var k=l.stateNode,T=l.memoizedProps;k.props=T;var W=k.context,b=u.contextType;typeof b=="object"&&b!==null?b=Sn(b):(b=mt(u)?Je:Xe.current,b=Ut(l,b));var fe=u.getDerivedStateFromProps,xe=typeof fe=="function"||typeof k.getSnapshotBeforeUpdate=="function";xe||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(T!==s||W!==b)&&av(l,k,s,b),Rr=!1;var Se=l.memoizedState;k.state=Se,Pu(l,s,k,f),W=l.memoizedState,T!==s||Se!==W||Te.current||Rr?(typeof fe=="function"&&(pc(l,u,fe,s),W=l.memoizedState),(T=Rr||ov(l,u,T,s,Se,W,b))?(xe||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(l.flags|=4194308)):(typeof k.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=s,l.memoizedState=W),k.props=s,k.state=W,k.context=b,s=T):(typeof k.componentDidMount=="function"&&(l.flags|=4194308),s=!1)}else{k=l.stateNode,nv(r,l),T=l.memoizedProps,b=l.type===l.elementType?T:jn(l.type,T),k.props=b,xe=l.pendingProps,Se=k.context,W=u.contextType,typeof W=="object"&&W!==null?W=Sn(W):(W=mt(u)?Je:Xe.current,W=Ut(l,W));var Ye=u.getDerivedStateFromProps;(fe=typeof Ye=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(T!==xe||Se!==W)&&av(l,k,s,W),Rr=!1,Se=l.memoizedState,k.state=Se,Pu(l,s,k,f);var ge=l.memoizedState;T!==xe||Se!==ge||Te.current||Rr?(typeof Ye=="function"&&(pc(l,u,Ye,s),ge=l.memoizedState),(b=Rr||ov(l,u,b,s,Se,ge,W)||!1)?(fe||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(s,ge,W),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(s,ge,W)),typeof k.componentDidUpdate=="function"&&(l.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof k.componentDidUpdate!="function"||T===r.memoizedProps&&Se===r.memoizedState||(l.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&Se===r.memoizedState||(l.flags|=1024),l.memoizedProps=s,l.memoizedState=ge),k.props=s,k.state=ge,k.context=W,s=b):(typeof k.componentDidUpdate!="function"||T===r.memoizedProps&&Se===r.memoizedState||(l.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&Se===r.memoizedState||(l.flags|=1024),s=!1)}return Lc(r,l,u,s,p,f)}function Lc(r,l,u,s,f,p){Zv(r,l);var k=(l.flags&128)!==0;if(!s&&!k)return f&&Be(l,u,!1),mr(r,l,p);s=l.stateNode,Ly.current=l;var T=k&&typeof u.getDerivedStateFromError!="function"?null:s.render();return l.flags|=1,r!==null&&k?(l.child=Xl(l,r.child,null,p),l.child=Xl(l,null,T,p)):Yt(r,l,T,p),l.memoizedState=s.state,f&&Be(l,u,!0),l.child}function Yv(r){var l=r.stateNode;l.pendingContext?Qe(r,l.pendingContext,l.pendingContext!==l.context):l.context&&Qe(r,l.context,!1),Sc(r,l.containerInfo)}function Kv(r,l,u,s,f){return Zl(),wc(f),l.flags|=256,Yt(r,l,u,s),l.child}var Hu={dehydrated:null,treeContext:null,retryLane:0};function Wu(r){return{baseLanes:r,cachePool:null}}function Jv(r,l,u){var s=l.pendingProps,f=ot.current,p=!1,k=(l.flags&128)!==0,T;if((T=k)||(T=r!==null&&r.memoizedState===null?!1:(f&2)!==0),T?(p=!0,l.flags&=-129):(r===null||r.memoizedState!==null)&&(f|=1),Me(ot,f&1),r===null)return yc(l),r=l.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?(l.mode&1?ji(r)?l.lanes=8:l.lanes=1073741824:l.lanes=1,null):(f=s.children,r=s.fallback,p?(s=l.mode,p=l.child,f={mode:"hidden",children:f},!(s&1)&&p!==null?(p.childLanes=0,p.pendingProps=f):p=aa(f,s,0,null),r=_l(r,s,u,null),p.return=l,r.return=l,p.sibling=r,l.child=p,l.child.memoizedState=Wu(u),l.memoizedState=Hu,r):Oc(l,f));if(f=r.memoizedState,f!==null){if(T=f.dehydrated,T!==null){if(k)return l.flags&256?(l.flags&=-257,Qu(r,l,u,Error(c(422)))):l.memoizedState!==null?(l.child=r.child,l.flags|=128,null):(p=s.fallback,f=l.mode,s=aa({mode:"visible",children:s.children},f,0,null),p=_l(p,f,u,null),p.flags|=2,s.return=l,p.return=l,s.sibling=p,l.child=s,l.mode&1&&Xl(l,r.child,null,u),l.child.memoizedState=Wu(u),l.memoizedState=Hu,p);if(!(l.mode&1))l=Qu(r,l,u,null);else if(ji(T))l=Qu(r,l,u,Error(c(419)));else if(s=(u&r.childLanes)!==0,dn||s){if(s=gt,s!==null){switch(u&-u){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}s=p&(s.suspendedLanes|u)?0:p,s!==0&&s!==f.retryLane&&(f.retryLane=s,Cn(r,s,-1))}ef(),l=Qu(r,l,u,Error(c(421)))}else dl(T)?(l.flags|=128,l.child=r.child,l=Zy.bind(null,r),pl(T,l),l=null):(u=f.treeContext,Ft&&(fn=ec(T),cn=l,rt=!0,Hn=null,Qi=!1,u!==null&&(En[_n++]=pr,En[_n++]=vr,En[_n++]=vl,pr=u.id,vr=u.overflow,vl=l)),l=Oc(l,l.pendingProps.children),l.flags|=4096);return l}return p?(s=qv(r,l,s.children,s.fallback,u),p=l.child,f=r.child.memoizedState,p.memoizedState=f===null?Wu(u):{baseLanes:f.baseLanes|u,cachePool:null},p.childLanes=r.childLanes&~u,l.memoizedState=Hu,s):(u=$v(r,l,s.children,u),l.memoizedState=null,u)}return p?(s=qv(r,l,s.children,s.fallback,u),p=l.child,f=r.child.memoizedState,p.memoizedState=f===null?Wu(u):{baseLanes:f.baseLanes|u,cachePool:null},p.childLanes=r.childLanes&~u,l.memoizedState=Hu,s):(u=$v(r,l,s.children,u),l.memoizedState=null,u)}function Oc(r,l){return l=aa({mode:"visible",children:l},r.mode,0,null),l.return=r,r.child=l}function $v(r,l,u,s){var f=r.child;return r=f.sibling,u=Fr(f,{mode:"visible",children:u}),!(l.mode&1)&&(u.lanes=s),u.return=l,u.sibling=null,r!==null&&(s=l.deletions,s===null?(l.deletions=[r],l.flags|=16):s.push(r)),l.child=u}function qv(r,l,u,s,f){var p=l.mode;r=r.child;var k=r.sibling,T={mode:"hidden",children:u};return!(p&1)&&l.child!==r?(u=l.child,u.childLanes=0,u.pendingProps=T,l.deletions=null):(u=Fr(r,T),u.subtreeFlags=r.subtreeFlags&14680064),k!==null?s=Fr(k,s):(s=_l(s,p,f,null),s.flags|=2),s.return=l,u.return=l,u.sibling=s,l.child=u,s}function Qu(r,l,u,s){return s!==null&&wc(s),Xl(l,r.child,null,u),r=Oc(l,l.pendingProps.children),r.flags|=2,l.memoizedState=null,r}function bv(r,l,u){r.lanes|=l;var s=r.alternate;s!==null&&(s.lanes|=l),fc(r.return,l,u)}function Fc(r,l,u,s,f){var p=r.memoizedState;p===null?r.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:s,tail:u,tailMode:f}:(p.isBackwards=l,p.rendering=null,p.renderingStartTime=0,p.last=s,p.tail=u,p.tailMode=f)}function eh(r,l,u){var s=l.pendingProps,f=s.revealOrder,p=s.tail;if(Yt(r,l,s.children,u),s=ot.current,s&2)s=s&1|2,l.flags|=128;else{if(r!==null&&r.flags&128)e:for(r=l.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&bv(r,u,l);else if(r.tag===19)bv(r,u,l);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===l)break e;for(;r.sibling===null;){if(r.return===null||r.return===l)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}s&=1}if(Me(ot,s),!(l.mode&1))l.memoizedState=null;else switch(f){case"forwards":for(u=l.child,f=null;u!==null;)r=u.alternate,r!==null&&zu(r)===null&&(f=u),u=u.sibling;u=f,u===null?(f=l.child,l.child=null):(f=u.sibling,u.sibling=null),Fc(l,!1,f,u,p);break;case"backwards":for(u=null,f=l.child,l.child=null;f!==null;){if(r=f.alternate,r!==null&&zu(r)===null){l.child=f;break}r=f.sibling,f.sibling=u,u=f,f=r}Fc(l,!0,u,null,p);break;case"together":Fc(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function mr(r,l,u){if(r!==null&&(l.dependencies=r.dependencies),ql|=l.lanes,!(u&l.childLanes))return null;if(r!==null&&l.child!==r.child)throw Error(c(153));if(l.child!==null){for(r=l.child,u=Fr(r,r.pendingProps),l.child=u,u.return=l;r.sibling!==null;)r=r.sibling,u=u.sibling=Fr(r,r.pendingProps),u.return=l;u.sibling=null}return l.child}function Oy(r,l,u){switch(l.tag){case 3:Yv(l),Zl();break;case 5:mv(l);break;case 1:mt(l.type)&&Ge(l);break;case 4:Sc(l,l.stateNode.containerInfo);break;case 10:tv(l,l.type._context,l.memoizedProps.value);break;case 13:var s=l.memoizedState;if(s!==null)return s.dehydrated!==null?(Me(ot,ot.current&1),l.flags|=128,null):u&l.child.childLanes?Jv(r,l,u):(Me(ot,ot.current&1),r=mr(r,l,u),r!==null?r.sibling:null);Me(ot,ot.current&1);break;case 19:if(s=(u&l.childLanes)!==0,r.flags&128){if(s)return eh(r,l,u);l.flags|=128}var f=l.memoizedState;if(f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(ot,ot.current),s)break;return null;case 22:case 23:return l.lanes=0,Gv(r,l,u)}return mr(r,l,u)}function Fy(r,l){switch(mc(l),l.tag){case 1:return mt(l.type)&&Nt(),r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 3:return Kl(),_e(Te),_e(Xe),kc(),r=l.flags,r&65536&&!(r&128)?(l.flags=r&-65537|128,l):null;case 5:return Ec(l),null;case 13:if(_e(ot),r=l.memoizedState,r!==null&&r.dehydrated!==null){if(l.alternate===null)throw Error(c(340));Zl()}return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 19:return _e(ot),null;case 4:return Kl(),null;case 10:return cc(l.type._context),null;case 22:case 23:return bc(),null;case 24:return null;default:return null}}var Vu=!1,gl=!1,Dy=typeof WeakSet=="function"?WeakSet:Set,oe=null;function Gu(r,l){var u=r.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(s){rn(r,l,s)}else u.current=null}function Dc(r,l,u){try{u()}catch(s){rn(r,l,s)}}var th=!1;function Uy(r,l){for(X(r.containerInfo),oe=l;oe!==null;)if(r=oe,l=r.child,(r.subtreeFlags&1028)!==0&&l!==null)l.return=r,oe=l;else for(;oe!==null;){r=oe;try{var u=r.alternate;if(r.flags&1024)switch(r.tag){case 0:case 11:case 15:break;case 1:if(u!==null){var s=u.memoizedProps,f=u.memoizedState,p=r.stateNode,k=p.getSnapshotBeforeUpdate(r.elementType===r.type?s:jn(r.type,s),f);p.__reactInternalSnapshotBeforeUpdate=k}break;case 3:en&&Ys(r.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(c(163))}}catch(T){rn(r,r.return,T)}if(l=r.sibling,l!==null){l.return=r.return,oe=l;break}oe=r.return}return u=th,th=!1,u}function yl(r,l,u){var s=l.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var f=s=s.next;do{if((f.tag&r)===r){var p=f.destroy;f.destroy=void 0,p!==void 0&&Dc(l,u,p)}f=f.next}while(f!==s)}}function to(r,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var u=l=l.next;do{if((u.tag&r)===r){var s=u.create;u.destroy=s()}u=u.next}while(u!==l)}}function Uc(r){var l=r.ref;if(l!==null){var u=r.stateNode;switch(r.tag){case 5:r=ye(u);break;default:r=u}typeof l=="function"?l(r):l.current=r}}function nh(r,l,u){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(Su,l)}catch{}switch(l.tag){case 0:case 11:case 14:case 15:if(r=l.updateQueue,r!==null&&(r=r.lastEffect,r!==null)){var s=r=r.next;do{var f=s,p=f.destroy;f=f.tag,p!==void 0&&(f&2||f&4)&&Dc(l,u,p),s=s.next}while(s!==r)}break;case 1:if(Gu(l,u),r=l.stateNode,typeof r.componentWillUnmount=="function")try{r.props=l.memoizedProps,r.state=l.memoizedState,r.componentWillUnmount()}catch(k){rn(l,u,k)}break;case 5:Gu(l,u);break;case 4:en?ah(r,l,u):jl&&jl&&(l=l.stateNode.containerInfo,u=fu(l),pu(l,u))}}function rh(r,l,u){for(var s=l;;)if(nh(r,s,u),s.child===null||en&&s.tag===4){if(s===l)break;for(;s.sibling===null;){if(s.return===null||s.return===l)return;s=s.return}s.sibling.return=s.return,s=s.sibling}else s.child.return=s,s=s.child}function lh(r){var l=r.alternate;l!==null&&(r.alternate=null,lh(l)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(l=r.stateNode,l!==null&&Us(l)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function ih(r){return r.tag===5||r.tag===3||r.tag===4}function oh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||ih(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function uh(r){if(en){e:{for(var l=r.return;l!==null;){if(ih(l))break e;l=l.return}throw Error(c(160))}var u=l;switch(u.tag){case 5:l=u.stateNode,u.flags&32&&(Zt(l),u.flags&=-33),u=oh(r),Bc(r,u,l);break;case 3:case 4:l=u.stateNode.containerInfo,u=oh(r),Ac(r,u,l);break;default:throw Error(c(161))}}}function Ac(r,l,u){var s=r.tag;if(s===5||s===6)r=r.stateNode,l?Dt(u,r,l):Hl(u,r);else if(s!==4&&(r=r.child,r!==null))for(Ac(r,l,u),r=r.sibling;r!==null;)Ac(r,l,u),r=r.sibling}function Bc(r,l,u){var s=r.tag;if(s===5||s===6)r=r.stateNode,l?cl(u,r,l):su(u,r);else if(s!==4&&(r=r.child,r!==null))for(Bc(r,l,u),r=r.sibling;r!==null;)Bc(r,l,u),r=r.sibling}function ah(r,l,u){for(var s=l,f=!1,p,k;;){if(!f){f=s.return;e:for(;;){if(f===null)throw Error(c(160));switch(p=f.stateNode,f.tag){case 5:k=!1;break e;case 3:p=p.containerInfo,k=!0;break e;case 4:p=p.containerInfo,k=!0;break e}f=f.return}f=!0}if(s.tag===5||s.tag===6)rh(r,s,u),k?Tr(p,s.stateNode):cu(p,s.stateNode);else if(s.tag===18)k?J(p,s.stateNode):q(p,s.stateNode);else if(s.tag===4){if(s.child!==null){p=s.stateNode.containerInfo,k=!0,s.child.return=s,s=s.child;continue}}else if(nh(r,s,u),s.child!==null){s.child.return=s,s=s.child;continue}if(s===l)break;for(;s.sibling===null;){if(s.return===null||s.return===l)return;s=s.return,s.tag===4&&(f=!1)}s.sibling.return=s.return,s=s.sibling}}function jc(r,l){if(en){switch(l.tag){case 0:case 11:case 14:case 15:yl(3,l,l.return),to(3,l),yl(5,l,l.return);return;case 1:return;case 5:var u=l.stateNode;if(u!=null){var s=l.memoizedProps;r=r!==null?r.memoizedProps:s;var f=l.type,p=l.updateQueue;l.updateQueue=null,p!==null&&Zs(u,p,f,r,s,l)}return;case 6:if(l.stateNode===null)throw Error(c(162));u=l.memoizedProps,Vs(l.stateNode,r!==null?r.memoizedProps:u,u);return;case 3:Ft&&r!==null&&r.memoizedState.isDehydrated&&j(l.stateNode.containerInfo);return;case 12:return;case 13:Zu(l);return;case 19:Zu(l);return;case 17:return}throw Error(c(163))}switch(l.tag){case 0:case 11:case 14:case 15:yl(3,l,l.return),to(3,l),yl(5,l,l.return);return;case 12:return;case 13:Zu(l);return;case 19:Zu(l);return;case 3:Ft&&r!==null&&r.memoizedState.isDehydrated&&j(l.stateNode.containerInfo);break;case 22:case 23:return}e:if(jl){switch(l.tag){case 1:case 5:case 6:break e;case 3:case 4:l=l.stateNode,pu(l.containerInfo,l.pendingChildren);break e}throw Error(c(163))}}function Zu(r){var l=r.updateQueue;if(l!==null){r.updateQueue=null;var u=r.stateNode;u===null&&(u=r.stateNode=new Dy),l.forEach(function(s){var f=Xy.bind(null,r,s);u.has(s)||(u.add(s),s.then(f,f))})}}function Ay(r,l){for(oe=l;oe!==null;){l=oe;var u=l.deletions;if(u!==null)for(var s=0;s";case Yu:return":has("+(Qc(r)||"")+")";case Ku:return'[role="'+r.value+'"]';case $u:return'"'+r.value+'"';case Ju:return'[data-testname="'+r.value+'"]';default:throw Error(c(365))}}function ph(r,l){var u=[];r=[r,0];for(var s=0;sf&&(f=k),s&=~p}if(s=f,s=Ct()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*jy(s/1960))-s,10r?16:r,Ir===null)var s=!1;else{if(r=Ir,Ir=null,na=0,Ne&6)throw Error(c(331));var f=Ne;for(Ne|=4,oe=r.current;oe!==null;){var p=oe,k=p.child;if(oe.flags&16){var T=p.deletions;if(T!==null){for(var W=0;WCt()-Xc?wl(r,0):Zc|=u),nn(r,l)}function _h(r,l){l===0&&(r.mode&1?(l=yu,yu<<=1,!(yu&130023424)&&(yu=4194304)):l=1);var u=Kt();r=ia(r,l),r!==null&&(Wi(r,l,u),nn(r,u))}function Zy(r){var l=r.memoizedState,u=0;l!==null&&(u=l.retryLane),_h(r,u)}function Xy(r,l){var u=0;switch(r.tag){case 13:var s=r.stateNode,f=r.memoizedState;f!==null&&(u=f.retryLane);break;case 19:s=r.stateNode;break;default:throw Error(c(314))}s!==null&&s.delete(l),_h(r,u)}var kh;kh=function(r,l,u){if(r!==null)if(r.memoizedProps!==l.pendingProps||Te.current)dn=!0;else{if(!(r.lanes&u)&&!(l.flags&128))return dn=!1,Oy(r,l,u);dn=!!(r.flags&131072)}else dn=!1,rt&&l.flags&1048576&&sv(l,Ru,l.index);switch(l.lanes=0,l.tag){case 2:var s=l.type;r!==null&&(r.alternate=null,l.alternate=null,l.flags|=2),r=l.pendingProps;var f=Ut(l,Xe.current);Ql(l,u),f=Cc(null,l,s,r,f,u);var p=Pc();return l.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,mt(s)?(p=!0,Ge(l)):p=!1,l.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,dc(l),f.updater=Mu,l.stateNode=f,f._reactInternals=l,vc(l,s,r,u),l=Lc(null,l,s,!0,p,u)):(l.tag=0,rt&&p&&hc(l),Yt(null,l,f,u),l=l.child),l;case 16:s=l.elementType;e:{switch(r!==null&&(r.alternate=null,l.alternate=null,l.flags|=2),r=l.pendingProps,f=s._init,s=f(s._payload),l.type=s,f=l.tag=Ky(s),r=jn(s,r),f){case 0:l=Ic(null,l,s,r,u);break e;case 1:l=Xv(null,l,s,r,u);break e;case 11:l=Wv(null,l,s,r,u);break e;case 14:l=Qv(null,l,s,jn(s.type,r),u);break e}throw Error(c(306,s,""))}return l;case 0:return s=l.type,f=l.pendingProps,f=l.elementType===s?f:jn(s,f),Ic(r,l,s,f,u);case 1:return s=l.type,f=l.pendingProps,f=l.elementType===s?f:jn(s,f),Xv(r,l,s,f,u);case 3:e:{if(Yv(l),r===null)throw Error(c(387));s=l.pendingProps,p=l.memoizedState,f=p.element,nv(r,l),Pu(l,s,null,u);var k=l.memoizedState;if(s=k.element,Ft&&p.isDehydrated)if(p={element:s,isDehydrated:!1,cache:k.cache,transitions:k.transitions},l.updateQueue.baseState=p,l.memoizedState=p,l.flags&256){f=Error(c(423)),l=Kv(r,l,s,u,f);break e}else if(s!==f){f=Error(c(424)),l=Kv(r,l,s,u,f);break e}else for(Ft&&(fn=mu(l.stateNode.containerInfo),cn=l,rt=!0,Hn=null,Qi=!1),u=hv(l,null,s,u),l.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Zl(),s===f){l=mr(r,l,u);break e}Yt(r,l,s,u)}l=l.child}return l;case 5:return mv(l),r===null&&yc(l),s=l.type,f=l.pendingProps,p=r!==null?r.memoizedProps:null,k=f.children,ct(s,f)?k=null:p!==null&&ct(s,p)&&(l.flags|=32),Zv(r,l),Yt(r,l,k,u),l.child;case 6:return r===null&&yc(l),null;case 13:return Jv(r,l,u);case 4:return Sc(l,l.stateNode.containerInfo),s=l.pendingProps,r===null?l.child=Xl(l,null,s,u):Yt(r,l,s,u),l.child;case 11:return s=l.type,f=l.pendingProps,f=l.elementType===s?f:jn(s,f),Wv(r,l,s,f,u);case 7:return Yt(r,l,l.pendingProps,u),l.child;case 8:return Yt(r,l,l.pendingProps.children,u),l.child;case 12:return Yt(r,l,l.pendingProps.children,u),l.child;case 10:e:{if(s=l.type._context,f=l.pendingProps,p=l.memoizedProps,k=f.value,tv(l,s,k),p!==null)if(qn(p.value,k)){if(p.children===f.children&&!Te.current){l=mr(r,l,u);break e}}else for(p=l.child,p!==null&&(p.return=l);p!==null;){var T=p.dependencies;if(T!==null){k=p.child;for(var W=T.firstContext;W!==null;){if(W.context===s){if(p.tag===1){W=dr(-1,u&-u),W.tag=2;var b=p.updateQueue;if(b!==null){b=b.shared;var fe=b.pending;fe===null?W.next=W:(W.next=fe.next,fe.next=W),b.pending=W}}p.lanes|=u,W=p.alternate,W!==null&&(W.lanes|=u),fc(p.return,u,l),T.lanes|=u;break}W=W.next}}else if(p.tag===10)k=p.type===l.type?null:p.child;else if(p.tag===18){if(k=p.return,k===null)throw Error(c(341));k.lanes|=u,T=k.alternate,T!==null&&(T.lanes|=u),fc(k,u,l),k=p.sibling}else k=p.child;if(k!==null)k.return=p;else for(k=p;k!==null;){if(k===l){k=null;break}if(p=k.sibling,p!==null){p.return=k.return,k=p;break}k=k.return}p=k}Yt(r,l,f.children,u),l=l.child}return l;case 9:return f=l.type,s=l.pendingProps.children,Ql(l,u),f=Sn(f),s=s(f),l.flags|=1,Yt(r,l,s,u),l.child;case 14:return s=l.type,f=jn(s,l.pendingProps),f=jn(s.type,f),Qv(r,l,s,f,u);case 15:return Vv(r,l,l.type,l.pendingProps,u);case 17:return s=l.type,f=l.pendingProps,f=l.elementType===s?f:jn(s,f),r!==null&&(r.alternate=null,l.alternate=null,l.flags|=2),l.tag=1,mt(s)?(r=!0,Ge(l)):r=!1,Ql(l,u),uv(l,s,f),vc(l,s,f,u),Lc(null,l,s,!0,r,u);case 19:return eh(r,l,u);case 22:return Gv(r,l,u)}throw Error(c(156,l.tag))};function xh(r,l){return lc(r,l)}function Yy(r,l,u,s){this.tag=r,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(r,l,u,s){return new Yy(r,l,u,s)}function tf(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Ky(r){if(typeof r=="function")return tf(r)?1:0;if(r!=null){if(r=r.$$typeof,r===R)return 11;if(r===E)return 14}return 2}function Fr(r,l){var u=r.alternate;return u===null?(u=Pn(r.tag,l,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=l,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&14680064,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,l=r.dependencies,u.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u}function ua(r,l,u,s,f,p){var k=2;if(s=r,typeof r=="function")tf(r)&&(k=1);else if(typeof r=="string")k=5;else e:switch(r){case g:return _l(u.children,f,p,l);case m:k=8,f|=8;break;case S:return r=Pn(12,u,l,f|2),r.elementType=S,r.lanes=p,r;case I:return r=Pn(13,u,l,f),r.elementType=I,r.lanes=p,r;case w:return r=Pn(19,u,l,f),r.elementType=w,r.lanes=p,r;case N:return aa(u,f,p,l);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case C:k=10;break e;case P:k=9;break e;case R:k=11;break e;case E:k=14;break e;case x:k=16,s=null;break e}throw Error(c(130,r==null?r:typeof r,""))}return l=Pn(k,u,l,f),l.elementType=r,l.type=s,l.lanes=p,l}function _l(r,l,u,s){return r=Pn(7,r,s,l),r.lanes=u,r}function aa(r,l,u,s){return r=Pn(22,r,s,l),r.elementType=N,r.lanes=u,r.stateNode={},r}function nf(r,l,u){return r=Pn(6,r,null,l),r.lanes=u,r}function rf(r,l,u){return l=Pn(4,r.children!==null?r.children:[],r.key,l),l.lanes=u,l.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},l}function Jy(r,l,u,s,f){this.tag=l,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Ai,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=nc(0),this.expirationTimes=nc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=nc(0),this.identifierPrefix=s,this.onRecoverableError=f,Ft&&(this.mutableSourceEagerHydrationData=null)}function Ch(r,l,u,s,f,p,k,T,W){return r=new Jy(r,l,u,T,W),l===1?(l=1,p===!0&&(l|=8)):l=0,p=Pn(3,null,null,l),r.current=p,p.stateNode=r,p.memoizedState={element:s,isDehydrated:u,cache:null,transitions:null},dc(p),r}function Ph(r){if(!r)return Fe;r=r._reactInternals;e:{if(G(r)!==r||r.tag!==1)throw Error(c(170));var l=r;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(mt(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(c(171))}if(r.tag===1){var u=r.type;if(mt(u))return St(r,u,l)}return l}function Mh(r){var l=r._reactInternals;if(l===void 0)throw typeof r.render=="function"?Error(c(188)):(r=Object.keys(r).join(","),Error(c(268,r)));return r=ae(l),r===null?null:r.stateNode}function Th(r,l){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u=b&&p>=xe&&f<=fe&&k<=Se){r.splice(l,1);break}else if(s!==b||u.width!==W.width||Sek){if(!(p!==xe||u.height!==W.height||fef)){b>s&&(W.width+=b-s,W.x=s),fep&&(W.height+=xe-p,W.y=p),Seu&&(u=k)),k ")+` + +No matching component was found for: + `)+r.join(" > ")}return null},n.getPublicRootInstance=function(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return ye(r.child.stateNode);default:return r.child.stateNode}},n.injectIntoDevTools=function(r){if(r={bundleType:r.bundleType,version:r.version,rendererPackageName:r.rendererPackageName,rendererConfig:r.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:d.ReactCurrentDispatcher,findHostInstanceByFiber:$y,findFiberByHostInstance:r.findFiberByHostInstance||qy,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")r=!1;else{var l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(l.isDisabled||!l.supportsFiber)r=!0;else{try{Su=l.inject(r),$n=l}catch{}r=!!l.checkDCE}}return r},n.isAlreadyRendering=function(){return!1},n.observeVisibleRects=function(r,l,u,s){if(!al)throw Error(c(363));r=Vc(r,l);var f=Qs(r,u,s).disconnect;return{disconnect:function(){f()}}},n.registerMutableSourceForHydration=function(r,l){var u=l._getVersion;u=u(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,u]:r.mutableSourceEagerHydrationData.push(l,u)},n.runWithPriority=function(r,l){var u=je;try{return je=r,l()}finally{je=u}},n.shouldError=function(){return null},n.shouldSuspend=function(){return!1},n.updateContainer=function(r,l,u,s){var f=l.current,p=Kt(),k=Lr(f);return u=Ph(u),l.context===null?l.context=u:l.pendingContext=u,l=dr(p,k),l.payload={element:r},s=s===void 0?null:s,s!==null&&(l.callback=s),Nr(f,l),r=Cn(f,k,p),r!==null&&Cu(r,f,k),k},n};z1.exports=p_;var v_=z1.exports;const h_=gs(v_),jp={},O1=e=>void Object.assign(jp,e);function m_(e,t){function n(g,{args:m=[],attach:S,...C},P){let R=`${g[0].toUpperCase()}${g.slice(1)}`,I;if(g==="primitive"){if(C.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const w=C.object;I=ni(w,{type:g,root:P,attach:S,primitive:!0})}else{const w=jp[R];if(!w)throw new Error(`R3F: ${R} 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(m))throw new Error("R3F: The args prop must be an array!");I=ni(new w(...m),{type:g,root:P,attach:S,memoizedProps:{args:m}})}return I.__r3f.attach===void 0&&(I instanceof rw?I.__r3f.attach="geometry":I instanceof lw&&(I.__r3f.attach="material")),R!=="inject"&&Df(I,C),I}function i(g,m){let S=!1;if(m){var C,P;(C=m.__r3f)!=null&&C.attach?Ff(g,m,m.__r3f.attach):m.isObject3D&&g.isObject3D&&(g.add(m),S=!0),S||(P=g.__r3f)==null||P.objects.push(m),m.__r3f||ni(m,{}),m.__r3f.parent=g,Bd(m),ri(m)}}function o(g,m,S){let C=!1;if(m){var P,R;if((P=m.__r3f)!=null&&P.attach)Ff(g,m,m.__r3f.attach);else if(m.isObject3D&&g.isObject3D){m.parent=g,m.dispatchEvent({type:"added"}),g.dispatchEvent({type:"childadded",child:m});const I=g.children.filter(E=>E!==m),w=I.indexOf(S);g.children=[...I.slice(0,w),m,...I.slice(w)],C=!0}C||(R=g.__r3f)==null||R.objects.push(m),m.__r3f||ni(m,{}),m.__r3f.parent=g,Bd(m),ri(m)}}function a(g,m,S=!1){g&&[...g].forEach(C=>c(m,C,S))}function c(g,m,S){if(m){var C,P,R;if(m.__r3f&&(m.__r3f.parent=null),(C=g.__r3f)!=null&&C.objects&&(g.__r3f.objects=g.__r3f.objects.filter(N=>N!==m)),(P=m.__r3f)!=null&&P.attach)Vm(g,m,m.__r3f.attach);else if(m.isObject3D&&g.isObject3D){var I;g.remove(m),(I=m.__r3f)!=null&&I.root&&x_(Qa(m),m)}const E=(R=m.__r3f)==null?void 0:R.primitive,x=!E&&(S===void 0?m.dispose!==null:S);if(!E){var w;a((w=m.__r3f)==null?void 0:w.objects,m,x),a(m.children,m,x)}if(delete m.__r3f,x&&m.dispose&&m.type!=="Scene"){const N=()=>{try{m.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?Ud.unstable_scheduleCallback(Ud.unstable_IdlePriority,N):N()}ri(g)}}function d(g,m,S,C){var P;const R=(P=g.__r3f)==null?void 0:P.parent;if(!R)return;const I=n(m,S,g.__r3f.root);if(g.children){for(const w of g.children)w.__r3f&&i(I,w);g.children=g.children.filter(w=>!w.__r3f)}g.__r3f.objects.forEach(w=>i(I,w)),g.__r3f.objects=[],g.__r3f.autoRemovedBeforeAppend||c(R,g),I.parent&&(I.__r3f.autoRemovedBeforeAppend=!0),i(R,I),I.raycast&&I.__r3f.eventCount&&Qa(I).getState().internal.interaction.push(I),[C,C.alternate].forEach(w=>{w!==null&&(w.stateNode=I,w.ref&&(typeof w.ref=="function"?w.ref(I):w.ref.current=I))})}const v=()=>{};return{reconciler:h_({createInstance:n,removeChild:c,appendChild:i,appendInitialChild:i,insertBefore:o,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(g,m)=>{if(!m)return;const S=g.getState().scene;S.__r3f&&(S.__r3f.root=g,i(S,m))},removeChildFromContainer:(g,m)=>{m&&c(g.getState().scene,m)},insertInContainerBefore:(g,m,S)=>{if(!m||!S)return;const C=g.getState().scene;C.__r3f&&o(C,m,S)},getRootHostContext:()=>null,getChildHostContext:g=>g,finalizeInitialChildren(g){var m;return!!((m=g==null?void 0:g.__r3f)!=null?m:{}).handlers},prepareUpdate(g,m,S,C){var P;if(((P=g==null?void 0:g.__r3f)!=null?P:{}).primitive&&C.object&&C.object!==g)return[!0];{const{args:I=[],children:w,...E}=C,{args:x=[],children:N,...L}=S;if(!Array.isArray(I))throw new Error("R3F: the args prop must be an array!");if(I.some((Z,O)=>Z!==x[O]))return[!0];const A=H1(g,E,L,!0);return A.changes.length?[!1,A]:null}},commitUpdate(g,[m,S],C,P,R,I){m?d(g,C,R,I):Df(g,S)},commitMount(g,m,S,C){var P;const R=(P=g.__r3f)!=null?P:{};g.raycast&&R.handlers&&R.eventCount&&Qa(g).getState().internal.interaction.push(g)},getPublicInstance:g=>g,prepareForCommit:()=>null,preparePortalMount:g=>ni(g.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(g){var m;const{attach:S,parent:C}=(m=g.__r3f)!=null?m:{};S&&C&&Vm(C,g,S),g.isObject3D&&(g.visible=!1),ri(g)},unhideInstance(g,m){var S;const{attach:C,parent:P}=(S=g.__r3f)!=null?S:{};C&&P&&Ff(P,g,C),(g.isObject3D&&m.visible==null||m.visible)&&(g.visible=!0),ri(g)},createTextInstance:v,hideTextInstance:v,unhideTextInstance:v,getCurrentEventPriority:()=>t?t():gi.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&$e.fun(performance.now)?performance.now:$e.fun(Date.now)?Date.now:()=>0,scheduleTimeout:$e.fun(setTimeout)?setTimeout:void 0,cancelTimeout:$e.fun(clearTimeout)?clearTimeout:void 0}),applyProps:Df}}var jm,Hm;const Of=e=>"colorSpace"in e||"outputColorSpace"in e,F1=()=>{var e;return(e=jp.ColorManagement)!=null?e:null},D1=e=>e&&e.isOrthographicCamera,g_=e=>e&&e.hasOwnProperty("current"),ru=typeof window<"u"&&((jm=window.document)!=null&&jm.createElement||((Hm=window.navigator)==null?void 0:Hm.product)==="ReactNative")?V.useLayoutEffect:V.useEffect;function U1(e){const t=V.useRef(e);return ru(()=>void(t.current=e),[e]),t}function y_({set:e}){return ru(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}class A1 extends V.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}}A1.getDerivedStateFromError=()=>({error:!0});const B1="__default",Wm=new Map,w_=e=>e&&!!e.memoized&&!!e.changes;function j1(e){var t;const n=typeof window<"u"?(t=window.devicePixelRatio)!=null?t:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],n),e[1]):e}const ho=e=>{var t;return(t=e.__r3f)==null?void 0:t.root.getState()};function Qa(e){let t=e.__r3f.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}const $e={obj:e=>e===Object(e)&&!$e.arr(e)&&typeof e!="function",fun:e=>typeof e=="function",str:e=>typeof e=="string",num:e=>typeof e=="number",boo:e=>typeof e=="boolean",und:e=>e===void 0,arr:e=>Array.isArray(e),equ(e,t,{arrays:n="shallow",objects:i="reference",strict:o=!0}={}){if(typeof e!=typeof t||!!e!=!!t)return!1;if($e.str(e)||$e.num(e)||$e.boo(e))return e===t;const a=$e.obj(e);if(a&&i==="reference")return e===t;const c=$e.arr(e);if(c&&n==="reference")return e===t;if((c||a)&&e===t)return!0;let d;for(d in e)if(!(d in t))return!1;if(a&&n==="shallow"&&i==="shallow"){for(d in o?t:e)if(!$e.equ(e[d],t[d],{strict:o,objects:"reference"}))return!1}else for(d in o?t:e)if(e[d]!==t[d])return!1;if($e.und(d)){if(c&&e.length===0&&t.length===0||a&&Object.keys(e).length===0&&Object.keys(t).length===0)return!0;if(e!==t)return!1}return!0}};function S_(e){const t={nodes:{},materials:{}};return e&&e.traverse(n=>{n.name&&(t.nodes[n.name]=n),n.material&&!t.materials[n.material.name]&&(t.materials[n.material.name]=n.material)}),t}function E_(e){e.dispose&&e.type!=="Scene"&&e.dispose();for(const t in e)t.dispose==null||t.dispose(),delete e[t]}function ni(e,t){const n=e;return n.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t},e}function Ad(e,t){let n=e;if(t.includes("-")){const i=t.split("-"),o=i.pop();return n=i.reduce((a,c)=>a[c],e),{target:n,key:o}}else return{target:n,key:t}}const Qm=/-\d+$/;function Ff(e,t,n){if($e.str(n)){if(Qm.test(n)){const a=n.replace(Qm,""),{target:c,key:d}=Ad(e,a);Array.isArray(c[d])||(c[d]=[])}const{target:i,key:o}=Ad(e,n);t.__r3f.previousAttach=i[o],i[o]=t}else t.__r3f.previousAttach=n(e,t)}function Vm(e,t,n){var i,o;if($e.str(n)){const{target:a,key:c}=Ad(e,n),d=t.__r3f.previousAttach;d===void 0?delete a[c]:a[c]=d}else(i=t.__r3f)==null||i.previousAttach==null||i.previousAttach(e,t);(o=t.__r3f)==null||delete o.previousAttach}function H1(e,{children:t,key:n,ref:i,...o},{children:a,key:c,ref:d,...v}={},y=!1){const g=e.__r3f,m=Object.entries(o),S=[];if(y){const P=Object.keys(v);for(let R=0;R{var I;if((I=e.__r3f)!=null&&I.primitive&&P==="object"||$e.equ(R,v[P]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(P))return S.push([P,R,!0,[]]);let w=[];P.includes("-")&&(w=P.split("-")),S.push([P,R,!1,w]);for(const E in o){const x=o[E];E.startsWith(`${P}-`)&&S.push([E,x,!1,E.split("-")])}});const C={...o};return g!=null&&g.memoizedProps&&g!=null&&g.memoizedProps.args&&(C.args=g.memoizedProps.args),g!=null&&g.memoizedProps&&g!=null&&g.memoizedProps.attach&&(C.attach=g.memoizedProps.attach),{memoized:C,changes:S}}const __=typeof process<"u"&&!1;function Df(e,t){var n;const i=e.__r3f,o=i==null?void 0:i.root,a=o==null||o.getState==null?void 0:o.getState(),{memoized:c,changes:d}=w_(t)?t:H1(e,t),v=i==null?void 0:i.eventCount;e.__r3f&&(e.__r3f.memoizedProps=c);for(let g=0;gw[E],e),!(I&&I.set))){const[w,...E]=P.reverse();R=E.reverse().reduce((x,N)=>x[N],e),m=w}if(S===B1+"remove")if(R.constructor){let w=Wm.get(R.constructor);w||(w=new R.constructor,Wm.set(R.constructor,w)),S=w[m]}else S=0;if(C&&i)S?i.handlers[m]=S:delete i.handlers[m],i.eventCount=Object.keys(i.handlers).length;else if(I&&I.set&&(I.copy||I instanceof of)){if(Array.isArray(S))I.fromArray?I.fromArray(S):I.set(...S);else if(I.copy&&S&&S.constructor&&(__?I.constructor.name===S.constructor.name:I.constructor===S.constructor))I.copy(S);else if(S!==void 0){const w=I instanceof iw;!w&&I.setScalar?I.setScalar(S):I instanceof of&&S instanceof of?I.mask=S.mask:I.set(S),!F1()&&a&&!a.linear&&w&&I.convertSRGBToLinear()}}else if(R[m]=S,R[m]instanceof Vr&&R[m].format===Ci&&R[m].type===Va&&a){const w=R[m];Of(w)&&Of(a.gl)?w.colorSpace=a.gl.outputColorSpace:w.encoding=a.gl.outputEncoding}ri(e)}if(i&&i.parent&&e.raycast&&v!==i.eventCount){const g=Qa(e).getState().internal,m=g.interaction.indexOf(e);m>-1&&g.interaction.splice(m,1),i.eventCount&&g.interaction.push(e)}return!(d.length===1&&d[0][0]==="onUpdate")&&d.length&&(n=e.__r3f)!=null&&n.parent&&Bd(e),e}function ri(e){var t,n;const i=(t=e.__r3f)==null||(n=t.root)==null||n.getState==null?void 0:n.getState();i&&i.internal.frames===0&&i.invalidate()}function Bd(e){e.onUpdate==null||e.onUpdate(e)}function W1(e,t){e.manual||(D1(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix(),e.updateMatrixWorld())}function Pa(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function k_(){var e;const t=typeof self<"u"&&self||typeof window<"u"&&window;if(!t)return gi.DefaultEventPriority;switch((e=t.event)==null?void 0:e.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return gi.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return gi.ContinuousEventPriority;default:return gi.DefaultEventPriority}}function Q1(e,t,n,i){const o=n.get(t);o&&(n.delete(t),n.size===0&&(e.delete(i),o.target.releasePointerCapture(i)))}function x_(e,t){const{internal:n}=e.getState();n.interaction=n.interaction.filter(i=>i!==t),n.initialHits=n.initialHits.filter(i=>i!==t),n.hovered.forEach((i,o)=>{(i.eventObject===t||i.object===t)&&n.hovered.delete(o)}),n.capturedMap.forEach((i,o)=>{Q1(n.capturedMap,t,i,o)})}function C_(e){function t(v){const{internal:y}=e.getState(),g=v.offsetX-y.initialClick[0],m=v.offsetY-y.initialClick[1];return Math.round(Math.sqrt(g*g+m*m))}function n(v){return v.filter(y=>["Move","Over","Enter","Out","Leave"].some(g=>{var m;return(m=y.__r3f)==null?void 0:m.handlers["onPointer"+g]}))}function i(v,y){const g=e.getState(),m=new Set,S=[],C=y?y(g.internal.interaction):g.internal.interaction;for(let w=0;w{const x=ho(w.object),N=ho(E.object);return!x||!N?w.distance-E.distance:N.events.priority-x.events.priority||w.distance-E.distance}).filter(w=>{const E=Pa(w);return m.has(E)?!1:(m.add(E),!0)});g.events.filter&&(R=g.events.filter(R,g));for(const w of R){let E=w.object;for(;E;){var I;(I=E.__r3f)!=null&&I.eventCount&&S.push({...w,eventObject:E}),E=E.parent}}if("pointerId"in v&&g.internal.capturedMap.has(v.pointerId))for(let w of g.internal.capturedMap.get(v.pointerId).values())m.has(Pa(w.intersection))||S.push(w.intersection);return S}function o(v,y,g,m){const S=e.getState();if(v.length){const C={stopped:!1};for(const P of v){const R=ho(P.object)||S,{raycaster:I,pointer:w,camera:E,internal:x}=R,N=new zn(w.x,w.y,0).unproject(E),L=Y=>{var K,ae;return(K=(ae=x.capturedMap.get(Y))==null?void 0:ae.has(P.eventObject))!=null?K:!1},A=Y=>{const K={intersection:P,target:y.target};x.capturedMap.has(Y)?x.capturedMap.get(Y).set(P.eventObject,K):x.capturedMap.set(Y,new Map([[P.eventObject,K]])),y.target.setPointerCapture(Y)},Z=Y=>{const K=x.capturedMap.get(Y);K&&Q1(x.capturedMap,P.eventObject,K,Y)};let O={};for(let Y in y){let K=y[Y];typeof K!="function"&&(O[Y]=K)}let G={...P,...O,pointer:w,intersections:v,stopped:C.stopped,delta:g,unprojectedPoint:N,ray:I.ray,camera:E,stopPropagation(){const Y="pointerId"in y&&x.capturedMap.get(y.pointerId);if((!Y||Y.has(P.eventObject))&&(G.stopped=C.stopped=!0,x.hovered.size&&Array.from(x.hovered.values()).find(K=>K.eventObject===P.eventObject))){const K=v.slice(0,v.indexOf(P));a([...K,P])}},target:{hasPointerCapture:L,setPointerCapture:A,releasePointerCapture:Z},currentTarget:{hasPointerCapture:L,setPointerCapture:A,releasePointerCapture:Z},nativeEvent:y};if(m(G),C.stopped===!0)break}}return v}function a(v){const{internal:y}=e.getState();for(const g of y.hovered.values())if(!v.length||!v.find(m=>m.object===g.object&&m.index===g.index&&m.instanceId===g.instanceId)){const S=g.eventObject.__r3f,C=S==null?void 0:S.handlers;if(y.hovered.delete(Pa(g)),S!=null&&S.eventCount){const P={...g,intersections:v};C.onPointerOut==null||C.onPointerOut(P),C.onPointerLeave==null||C.onPointerLeave(P)}}}function c(v,y){for(let g=0;ga([]);case"onLostPointerCapture":return y=>{const{internal:g}=e.getState();"pointerId"in y&&g.capturedMap.has(y.pointerId)&&requestAnimationFrame(()=>{g.capturedMap.has(y.pointerId)&&(g.capturedMap.delete(y.pointerId),a([]))})}}return function(g){const{onPointerMissed:m,internal:S}=e.getState();S.lastEvent.current=g;const C=v==="onPointerMove",P=v==="onClick"||v==="onContextMenu"||v==="onDoubleClick",I=i(g,C?n:void 0),w=P?t(g):0;v==="onPointerDown"&&(S.initialClick=[g.offsetX,g.offsetY],S.initialHits=I.map(x=>x.eventObject)),P&&!I.length&&w<=2&&(c(g,S.interaction),m&&m(g)),C&&a(I);function E(x){const N=x.eventObject,L=N.__r3f,A=L==null?void 0:L.handlers;if(L!=null&&L.eventCount)if(C){if(A.onPointerOver||A.onPointerEnter||A.onPointerOut||A.onPointerLeave){const Z=Pa(x),O=S.hovered.get(Z);O?O.stopped&&x.stopPropagation():(S.hovered.set(Z,x),A.onPointerOver==null||A.onPointerOver(x),A.onPointerEnter==null||A.onPointerEnter(x))}A.onPointerMove==null||A.onPointerMove(x)}else{const Z=A[v];Z?(!P||S.initialHits.includes(N))&&(c(g,S.interaction.filter(O=>!S.initialHits.includes(O))),Z(x)):P&&S.initialHits.includes(N)&&c(g,S.interaction.filter(O=>!S.initialHits.includes(O)))}}o(I,g,w,E)}}return{handlePointer:d}}const P_=["set","get","setSize","setFrameloop","setDpr","events","invalidate","advance","size","viewport"],V1=e=>!!(e!=null&&e.render),Hp=V.createContext(null),M_=(e,t)=>{const n=T1((d,v)=>{const y=new zn,g=new zn,m=new zn;function S(w=v().camera,E=g,x=v().size){const{width:N,height:L,top:A,left:Z}=x,O=N/L;E instanceof zn?m.copy(E):m.set(...E);const G=w.getWorldPosition(y).distanceTo(m);if(D1(w))return{width:N/w.zoom,height:L/w.zoom,top:A,left:Z,factor:1,distance:G,aspect:O};{const Y=w.fov*Math.PI/180,K=2*Math.tan(Y/2)*G,ae=K*(N/L);return{width:ae,height:K,top:A,left:Z,factor:N/ae,distance:G,aspect:O}}}let C;const P=w=>d(E=>({performance:{...E.performance,current:w}})),R=new a0;return{set:d,get:v,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(w=1)=>e(v(),w),advance:(w,E)=>t(w,E,v()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new cw,pointer:R,mouse:R,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const w=v();C&&clearTimeout(C),w.performance.current!==w.performance.min&&P(w.performance.min),C=setTimeout(()=>P(v().performance.max),w.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:S},setEvents:w=>d(E=>({...E,events:{...E.events,...w}})),setSize:(w,E,x,N,L)=>{const A=v().camera,Z={width:w,height:E,top:N||0,left:L||0,updateStyle:x};d(O=>({size:Z,viewport:{...O.viewport,...S(A,g,Z)}}))},setDpr:w=>d(E=>{const x=j1(w);return{viewport:{...E.viewport,dpr:x,initialDpr:E.viewport.initialDpr||x}}}),setFrameloop:(w="always")=>{const E=v().clock;E.stop(),E.elapsedTime=0,w!=="never"&&(E.start(),E.elapsedTime=0),d(()=>({frameloop:w}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:V.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(w,E,x)=>{const N=v().internal;return N.priority=N.priority+(E>0?1:0),N.subscribers.push({ref:w,priority:E,store:x}),N.subscribers=N.subscribers.sort((L,A)=>L.priority-A.priority),()=>{const L=v().internal;L!=null&&L.subscribers&&(L.priority=L.priority-(E>0?1:0),L.subscribers=L.subscribers.filter(A=>A.ref!==w))}}}}}),i=n.getState();let o=i.size,a=i.viewport.dpr,c=i.camera;return n.subscribe(()=>{const{camera:d,size:v,viewport:y,gl:g,set:m}=n.getState();if(v.width!==o.width||v.height!==o.height||y.dpr!==a){var S;o=v,a=y.dpr,W1(d,v),g.setPixelRatio(y.dpr);const C=(S=v.updateStyle)!=null?S:typeof HTMLCanvasElement<"u"&&g.domElement instanceof HTMLCanvasElement;g.setSize(v.width,v.height,C)}d!==c&&(c=d,m(C=>({viewport:{...C.viewport,...C.viewport.getCurrentViewport(d)}})))}),n.subscribe(d=>e(d)),n};let Ma,T_=new Set,R_=new Set,N_=new Set;function Uf(e,t){if(e.size)for(const{callback:n}of e.values())n(t)}function mo(e,t){switch(e){case"before":return Uf(T_,t);case"after":return Uf(R_,t);case"tail":return Uf(N_,t)}}let Af,Bf;function jf(e,t,n){let i=t.clock.getDelta();for(t.frameloop==="never"&&typeof e=="number"&&(i=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),Af=t.internal.subscribers,Ma=0;Ma0)&&!((g=a.gl.xr)!=null&&g.isPresenting)&&(i+=jf(y,a))}if(n=!1,mo("after",y),i===0)return mo("tail",y),t=!1,cancelAnimationFrame(o)}function d(y,g=1){var m;if(!y)return e.forEach(S=>d(S.store.getState(),g));(m=y.gl.xr)!=null&&m.isPresenting||!y.internal.active||y.frameloop==="never"||(g>1?y.internal.frames=Math.min(60,y.internal.frames+g):n?y.internal.frames=2:y.internal.frames=1,t||(t=!0,requestAnimationFrame(c)))}function v(y,g=!0,m,S){if(g&&mo("before",y),m)jf(y,m,S);else for(const C of e.values())jf(y,C.store.getState());g&&mo("after",y)}return{loop:c,invalidate:d,advance:v}}function Wp(){const e=V.useContext(Hp);if(!e)throw new Error("R3F: Hooks can only be used within the Canvas component!");return e}function Nn(e=n=>n,t){return Wp()(e,t)}function Qp(e,t=0){const n=Wp(),i=n.getState().internal.subscribe,o=U1(e);return ru(()=>i(o,t,n),[t,i,n]),null}const Gm=new WeakMap;function G1(e,t){return function(n,...i){let o=Gm.get(n);return o||(o=new n,Gm.set(n,o)),e&&e(o),Promise.all(i.map(a=>new Promise((c,d)=>o.load(a,v=>{v.scene&&Object.assign(v,S_(v.scene)),c(v)},t,v=>d(new Error(`Could not load ${a}: ${v==null?void 0:v.message}`))))))}}function Li(e,t,n,i){const o=Array.isArray(t)?t:[t],a=c_(G1(n,i),[e,...o],{equal:$e.equ});return Array.isArray(t)?a:a[0]}Li.preload=function(e,t,n){const i=Array.isArray(t)?t:[t];return f_(G1(n),[e,...i])};Li.clear=function(e,t){const n=Array.isArray(t)?t:[t];return d_([e,...n])};const Oi=new Map,{invalidate:Zm,advance:Xm}=z_(Oi),{reconciler:Jo,applyProps:Hr}=m_(Oi,k_),ti={objects:"shallow",strict:!1},I_=(e,t)=>{const n=typeof e=="function"?e(t):e;return V1(n)?n:new c0({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e})};function L_(e,t){const n=typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement;if(t){const{width:i,height:o,top:a,left:c,updateStyle:d=n}=t;return{width:i,height:o,top:a,left:c,updateStyle:d}}else if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&e.parentElement){const{width:i,height:o,top:a,left:c}=e.parentElement.getBoundingClientRect();return{width:i,height:o,top:a,left:c,updateStyle:n}}else if(typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height,top:0,left:0,updateStyle:n};return{width:0,height:0,top:0,left:0}}function O_(e){const t=Oi.get(e),n=t==null?void 0:t.fiber,i=t==null?void 0:t.store;t&&console.warn("R3F.createRoot should only be called once!");const o=typeof reportError=="function"?reportError:console.error,a=i||M_(Zm,Xm),c=n||Jo.createContainer(a,gi.ConcurrentRoot,null,!1,null,"",o,null);t||Oi.set(e,{fiber:c,store:a});let d,v=!1,y;return{configure(g={}){let{gl:m,size:S,scene:C,events:P,onCreated:R,shadows:I=!1,linear:w=!1,flat:E=!1,legacy:x=!1,orthographic:N=!1,frameloop:L="always",dpr:A=[1,2],performance:Z,raycaster:O,camera:G,onPointerMissed:Y}=g,K=a.getState(),ae=K.gl;K.gl||K.set({gl:ae=I_(m,e)});let he=K.raycaster;he||K.set({raycaster:he=new u0});const{params:de,...ze}=O||{};if($e.equ(ze,he,ti)||Hr(he,{...ze}),$e.equ(de,he.params,ti)||Hr(he,{params:{...he.params,...de}}),!K.camera||K.camera===y&&!$e.equ(y,G,ti)){y=G;const Q=G instanceof ow,le=Q?G:N?new s0(0,0,0,0,.1,1e3):new ew(75,0,.1,1e3);Q||(le.position.z=5,G&&(Hr(le,G),("aspect"in G||"left"in G||"right"in G||"bottom"in G||"top"in G)&&(le.manual=!0,le.updateProjectionMatrix())),!K.camera&&!(G!=null&&G.rotation)&&le.lookAt(0,0,0)),K.set({camera:le}),he.camera=le}if(!K.scene){let Q;C instanceof Ga?Q=C:(Q=new Ga,C&&Hr(Q,C)),K.set({scene:ni(Q)})}if(!K.xr){var ye;const Q=(we,Ue)=>{const ct=a.getState();ct.frameloop!=="never"&&Xm(we,!0,ct,Ue)},le=()=>{const we=a.getState();we.gl.xr.enabled=we.gl.xr.isPresenting,we.gl.xr.setAnimationLoop(we.gl.xr.isPresenting?Q:null),we.gl.xr.isPresenting||Zm(we)},ie={connect(){const we=a.getState().gl;we.xr.addEventListener("sessionstart",le),we.xr.addEventListener("sessionend",le)},disconnect(){const we=a.getState().gl;we.xr.removeEventListener("sessionstart",le),we.xr.removeEventListener("sessionend",le)}};typeof((ye=ae.xr)==null?void 0:ye.addEventListener)=="function"&&ie.connect(),K.set({xr:ie})}if(ae.shadowMap){const Q=ae.shadowMap.enabled,le=ae.shadowMap.type;if(ae.shadowMap.enabled=!!I,$e.boo(I))ae.shadowMap.type=uf;else if($e.str(I)){var Ke;const ie={basic:uw,percentage:aw,soft:uf,variance:sw};ae.shadowMap.type=(Ke=ie[I])!=null?Ke:uf}else $e.obj(I)&&Object.assign(ae.shadowMap,I);(Q!==ae.shadowMap.enabled||le!==ae.shadowMap.type)&&(ae.shadowMap.needsUpdate=!0)}const D=F1();D&&("enabled"in D?D.enabled=!x:"legacyMode"in D&&(D.legacyMode=x)),v||Hr(ae,{outputEncoding:w?3e3:3001,toneMapping:E?tw:nw}),K.legacy!==x&&K.set(()=>({legacy:x})),K.linear!==w&&K.set(()=>({linear:w})),K.flat!==E&&K.set(()=>({flat:E})),m&&!$e.fun(m)&&!V1(m)&&!$e.equ(m,ae,ti)&&Hr(ae,m),P&&!K.events.handlers&&K.set({events:P(a)});const X=L_(e,S);return $e.equ(X,K.size,ti)||K.setSize(X.width,X.height,X.updateStyle,X.top,X.left),A&&K.viewport.dpr!==j1(A)&&K.setDpr(A),K.frameloop!==L&&K.setFrameloop(L),K.onPointerMissed||K.set({onPointerMissed:Y}),Z&&!$e.equ(Z,K.performance,ti)&&K.set(Q=>({performance:{...Q.performance,...Z}})),d=R,v=!0,this},render(g){return v||this.configure(),Jo.updateContainer(lt.jsx(F_,{store:a,children:g,onCreated:d,rootElement:e}),c,null,()=>{}),a},unmount(){Z1(e)}}}function F_({store:e,children:t,onCreated:n,rootElement:i}){return ru(()=>{const o=e.getState();o.set(a=>({internal:{...a.internal,active:!0}})),n&&n(o),e.getState().events.connected||o.events.connect==null||o.events.connect(i)},[]),lt.jsx(Hp.Provider,{value:e,children:t})}function Z1(e,t){const n=Oi.get(e),i=n==null?void 0:n.fiber;if(i){const o=n==null?void 0:n.store.getState();o&&(o.internal.active=!1),Jo.updateContainer(null,i,null,()=>{o&&setTimeout(()=>{try{var a,c,d,v;o.events.disconnect==null||o.events.disconnect(),(a=o.gl)==null||(c=a.renderLists)==null||c.dispose==null||c.dispose(),(d=o.gl)==null||d.forceContextLoss==null||d.forceContextLoss(),(v=o.gl)!=null&&v.xr&&o.xr.disconnect(),E_(o),Oi.delete(e)}catch{}},500)})}}function D_(e,t,n){return lt.jsx(U_,{children:e,container:t,state:n},t.uuid)}function U_({state:e={},children:t,container:n}){const{events:i,size:o,...a}=e,c=Wp(),[d]=V.useState(()=>new u0),[v]=V.useState(()=>new a0),y=V.useCallback((m,S)=>{const C={...m};Object.keys(m).forEach(R=>{(P_.includes(R)||m[R]!==S[R]&&S[R])&&delete C[R]});let P;if(S&&o){const R=S.camera;P=m.viewport.getCurrentViewport(R,new zn,o),R!==m.camera&&W1(R,o)}return{...C,scene:n,raycaster:d,pointer:v,mouse:v,previousRoot:c,events:{...m.events,...S==null?void 0:S.events,...i},size:{...m.size,...o},viewport:{...m.viewport,...P},...a}},[e]),[g]=V.useState(()=>{const m=c.getState();return T1((C,P)=>({...m,scene:n,raycaster:d,pointer:v,mouse:v,previousRoot:c,events:{...m.events,...i},size:{...m.size,...o},...a,set:C,get:P,setEvents:R=>C(I=>({...I,events:{...I.events,...R}}))}))});return V.useEffect(()=>{const m=c.subscribe(S=>g.setState(C=>y(S,C)));return()=>{m()}},[y]),V.useEffect(()=>{g.setState(m=>y(c.getState(),m))},[y]),V.useEffect(()=>()=>{g.destroy()},[]),lt.jsx(lt.Fragment,{children:Jo.createPortal(lt.jsx(Hp.Provider,{value:g,children:t}),g,null)})}Jo.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:V.version});const Hf={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 A_(e){const{handlePointer:t}=C_(e);return{priority:1,enabled:!0,compute(n,i,o){i.pointer.set(n.offsetX/i.size.width*2-1,-(n.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(Hf).reduce((n,i)=>({...n,[i]:t(i)}),{}),update:()=>{var n;const{events:i,internal:o}=e.getState();(n=o.lastEvent)!=null&&n.current&&i.handlers&&i.handlers.onPointerMove(o.lastEvent.current)},connect:n=>{var i;const{set:o,events:a}=e.getState();a.disconnect==null||a.disconnect(),o(c=>({events:{...c.events,connected:n}})),Object.entries((i=a.handlers)!=null?i:[]).forEach(([c,d])=>{const[v,y]=Hf[c];n.addEventListener(v,d,{passive:y})})},disconnect:()=>{const{set:n,events:i}=e.getState();if(i.connected){var o;Object.entries((o=i.handlers)!=null?o:[]).forEach(([a,c])=>{if(i&&i.connected instanceof HTMLElement){const[d]=Hf[a];i.connected.removeEventListener(d,c)}}),n(a=>({events:{...a.events,connected:void 0}}))}}}}function jd(e,t,n){var i,o,a,c,d;t==null&&(t=100);function v(){var g=Date.now()-c;g=0?i=setTimeout(v,t-g):(i=null,n||(d=e.apply(a,o),a=o=null))}var y=function(){a=this,o=arguments,c=Date.now();var g=n&&!i;return i||(i=setTimeout(v,t)),g&&(d=e.apply(a,o),a=o=null),d};return y.clear=function(){i&&(clearTimeout(i),i=null)},y.flush=function(){i&&(d=e.apply(a,o),a=o=null,clearTimeout(i),i=null)},y}jd.debounce=jd;var B_=jd;const Ym=gs(B_);var j_=Object.defineProperty,H_=Object.defineProperties,W_=Object.getOwnPropertyDescriptors,Km=Object.getOwnPropertySymbols,Q_=Object.prototype.hasOwnProperty,V_=Object.prototype.propertyIsEnumerable,Jm=(e,t,n)=>t in e?j_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$m=(e,t)=>{for(var n in t||(t={}))Q_.call(t,n)&&Jm(e,n,t[n]);if(Km)for(var n of Km(t))V_.call(t,n)&&Jm(e,n,t[n]);return e},G_=(e,t)=>H_(e,W_(t)),qm,bm;typeof window<"u"&&((qm=window.document)!=null&&qm.createElement||((bm=window.navigator)==null?void 0:bm.product)==="ReactNative")?V.useLayoutEffect:V.useEffect;function X1(e,t,n){if(!e)return;if(n(e)===!0)return e;let i=e.child;for(;i;){const o=X1(i,t,n);if(o)return o;i=i.sibling}}function Y1(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}const e0=console.error;console.error=function(){const e=[...arguments].join("");if(e!=null&&e.startsWith("Warning:")&&e.includes("useContext")){console.error=e0;return}return e0.apply(this,arguments)};const Vp=Y1(V.createContext(null));class K1 extends V.Component{render(){return V.createElement(Vp.Provider,{value:this._reactInternals},this.props.children)}}function Z_(){const e=V.useContext(Vp);if(e===null)throw new Error("its-fine: useFiber must be called within a !");const t=V.useId();return V.useMemo(()=>{for(const i of[e,e==null?void 0:e.alternate]){if(!i)continue;const o=X1(i,!1,a=>{let c=a.memoizedState;for(;c;){if(c.memoizedState===t)return!0;c=c.next}});if(o)return o}},[e,t])}function X_(){const e=Z_(),[t]=V.useState(()=>new Map);t.clear();let n=e;for(;n;){if(n.type&&typeof n.type=="object"){const o=n.type._context===void 0&&n.type.Provider===n.type?n.type:n.type._context;o&&o!==Vp&&!t.has(o)&&t.set(o,V.useContext(Y1(o)))}n=n.return}return t}function Y_(){const e=X_();return V.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>i=>V.createElement(t,null,V.createElement(n.Provider,G_($m({},i),{value:e.get(n)}))),t=>V.createElement(K1,$m({},t))),[e])}function K_({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const o=n||typeof window<"u"&&window.ResizeObserver,[a,c]=V.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0});if(!o)return a.width=1280,a.height=800,[()=>{},a,()=>{}];const d=V.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),v=e?typeof e=="number"?e:e.scroll:null,y=e?typeof e=="number"?e:e.resize:null,g=V.useRef(!1);V.useEffect(()=>(g.current=!0,()=>void(g.current=!1)));const[m,S,C]=V.useMemo(()=>{const w=()=>{if(!d.current.element)return;const{left:E,top:x,width:N,height:L,bottom:A,right:Z,x:O,y:G}=d.current.element.getBoundingClientRect(),Y={left:E,top:x,width:N,height:L,bottom:A,right:Z,x:O,y:G};d.current.element instanceof HTMLElement&&i&&(Y.height=d.current.element.offsetHeight,Y.width=d.current.element.offsetWidth),Object.freeze(Y),g.current&&!b_(d.current.lastBounds,Y)&&c(d.current.lastBounds=Y)};return[w,y?Ym(w,y):w,v?Ym(w,v):w]},[c,i,v,y]);function P(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(w=>w.removeEventListener("scroll",C,!0)),d.current.scrollContainers=null),d.current.resizeObserver&&(d.current.resizeObserver.disconnect(),d.current.resizeObserver=null),d.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",d.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",d.current.orientationHandler))}function R(){var w;d.current.element&&(d.current.resizeObserver=new o(S),(w=d.current.resizeObserver)==null||w.observe(d.current.element),t&&d.current.scrollContainers&&d.current.scrollContainers.forEach(E=>E.addEventListener("scroll",C,{capture:!0,passive:!0})),d.current.orientationHandler=()=>{C()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",d.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",d.current.orientationHandler))}const I=w=>{!w||w===d.current.element||(P(),d.current.element=w,d.current.scrollContainers=J1(w),R())};return $_(C,!!t),J_(S),V.useEffect(()=>{P(),R()},[t,C,S]),V.useEffect(()=>P,[]),[I,a,m]}function J_(e){V.useEffect(()=>{const t=e;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[e])}function $_(e,t){V.useEffect(()=>{if(t){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",n,!0)}},[e,t])}function J1(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:i,overflowY:o}=window.getComputedStyle(e);return[n,i,o].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...J1(e.parentElement)]}const q_=["x","y","top","bottom","left","right","width","height"],b_=(e,t)=>q_.every(n=>e[n]===t[n]),e2=V.forwardRef(function({children:t,fallback:n,resize:i,style:o,gl:a,events:c=A_,eventSource:d,eventPrefix:v,shadows:y,linear:g,flat:m,legacy:S,orthographic:C,frameloop:P,dpr:R,performance:I,raycaster:w,camera:E,scene:x,onPointerMissed:N,onCreated:L,...A},Z){V.useMemo(()=>O1(fw),[]);const O=Y_(),[G,Y]=K_({scroll:!0,debounce:{scroll:50,resize:0},...i}),K=V.useRef(null),ae=V.useRef(null);V.useImperativeHandle(Z,()=>K.current);const he=U1(N),[de,ze]=V.useState(!1),[ye,Ke]=V.useState(!1);if(de)throw de;if(ye)throw ye;const D=V.useRef(null);ru(()=>{const Q=K.current;Y.width>0&&Y.height>0&&Q&&(D.current||(D.current=O_(Q)),D.current.configure({gl:a,events:c,shadows:y,linear:g,flat:m,legacy:S,orthographic:C,frameloop:P,dpr:R,performance:I,raycaster:w,camera:E,scene:x,size:Y,onPointerMissed:(...le)=>he.current==null?void 0:he.current(...le),onCreated:le=>{le.events.connect==null||le.events.connect(d?g_(d)?d.current:d:ae.current),v&&le.setEvents({compute:(ie,we)=>{const Ue=ie[v+"X"],ct=ie[v+"Y"];we.pointer.set(Ue/we.size.width*2-1,-(ct/we.size.height)*2+1),we.raycaster.setFromCamera(we.pointer,we.camera)}}),L==null||L(le)}}),D.current.render(lt.jsx(O,{children:lt.jsx(A1,{set:Ke,children:lt.jsx(V.Suspense,{fallback:lt.jsx(y_,{set:ze}),children:t})})})))}),V.useEffect(()=>{const Q=K.current;if(Q)return()=>Z1(Q)},[]);const X=d?"none":"auto";return lt.jsx("div",{ref:ae,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:X,...o},...A,children:lt.jsx("div",{ref:G,style:{width:"100%",height:"100%"},children:lt.jsx("canvas",{ref:K,style:{display:"block"},children:n})})})}),G2=V.forwardRef(function(t,n){return lt.jsx(K1,{children:lt.jsx(e2,{...t,ref:n})})});function Hd(){return Hd=Object.assign?Object.assign.bind():function(e){for(var t=1;t>>1|(et&21845)<<1;Ar=(Ar&52428)>>>2|(Ar&13107)<<2,Ar=(Ar&61680)>>>4|(Ar&3855)<<4,Qd[et]=((Ar&65280)>>>8|(Ar&255)<<8)>>>1}var Io=function(e,t,n){for(var i=e.length,o=0,a=new Yr(t);o>>v]=y}else for(d=new Yr(i),o=0;o>>15-e[o]);return d},lu=new In(288);for(var et=0;et<144;++et)lu[et]=8;for(var et=144;et<256;++et)lu[et]=9;for(var et=256;et<280;++et)lu[et]=7;for(var et=280;et<288;++et)lu[et]=8;var ny=new In(32);for(var et=0;et<32;++et)ny[et]=5;var i2=Io(lu,9,1),o2=Io(ny,5,1),Wf=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},Qn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Qf=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},u2=function(e){return(e/8|0)+(e&7&&1)},a2=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var i=new(e instanceof Yr?Yr:e instanceof Wd?Wd:In)(n-t);return i.set(e.subarray(t,n)),i},s2=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new In(0);var o=!t||n,a=!n||n.i;n||(n={}),t||(t=new In(i*3));var c=function(Ee){var ft=t.length;if(Ee>ft){var An=new In(Math.max(ft*2,Ee));An.set(t),t=An}},d=n.f||0,v=n.p||0,y=n.b||0,g=n.l,m=n.d,S=n.m,C=n.n,P=i*8;do{if(!g){n.f=d=Qn(e,v,1);var R=Qn(e,v+1,3);if(v+=3,R)if(R==1)g=i2,m=o2,S=9,C=5;else if(R==2){var x=Qn(e,v,31)+257,N=Qn(e,v+10,15)+4,L=x+Qn(e,v+5,31)+1;v+=14;for(var A=new In(L),Z=new In(19),O=0;O>>4;if(I<16)A[O++]=I;else{var he=0,de=0;for(I==16?(de=3+Qn(e,v,3),v+=2,he=A[O-1]):I==17?(de=3+Qn(e,v,7),v+=3):I==18&&(de=11+Qn(e,v,127),v+=7);de--;)A[O++]=he}}var ze=A.subarray(0,x),ye=A.subarray(x);S=Wf(ze),C=Wf(ye),g=Io(ze,S,1),m=Io(ye,C,1)}else throw"invalid block type";else{var I=u2(v)+4,w=e[I-4]|e[I-3]<<8,E=I+w;if(E>i){if(a)throw"unexpected EOF";break}o&&c(y+w),t.set(e.subarray(I,E),y),n.b=y+=w,n.p=v=E*8;continue}if(v>P){if(a)throw"unexpected EOF";break}}o&&c(y+131072);for(var Ke=(1<>>4;if(v+=he&15,v>P){if(a)throw"unexpected EOF";break}if(!he)throw"invalid length/literal";if(Q<256)t[y++]=Q;else if(Q==256){X=v,g=null;break}else{var le=Q-254;if(Q>264){var O=Q-257,ie=$1[O];le=Qn(e,v,(1<>>4;if(!we)throw"invalid distance";v+=we&15;var ye=l2[Ue];if(Ue>3){var ie=q1[Ue];ye+=Qf(e,v)&(1<P){if(a)throw"unexpected EOF";break}o&&c(y+131072);for(var ct=y+le;y>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(e[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Ta(e,t){return s2((f2(e),e.subarray(2,-4)),t)}var d2=typeof TextDecoder<"u"&&new TextDecoder,p2=0;try{d2.decode(c2,{stream:!0}),p2=1}catch{}const v2=e=>e&&e.isCubeTexture;class h2 extends Vd{constructor(t,n){var i,o;const a=v2(t),d=((o=a?(i=t.image[0])==null?void 0:i.width:t.image.width)!=null?o:1024)/4,v=Math.floor(Math.log2(d)),y=Math.pow(2,v),g=3*Math.max(y,16*7),m=4*y,S=[a?"#define ENVMAP_TYPE_CUBE":"",`#define CUBEUV_TEXEL_WIDTH ${1/g}`,`#define CUBEUV_TEXEL_HEIGHT ${1/m}`,`#define CUBEUV_MAX_MIP ${v}.0`],C=` + varying vec3 vWorldPosition; + void main() + { + vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) ); + vWorldPosition = worldPosition.xyz; + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + } + `,P=S.join(` +`)+` + #define ENVMAP_TYPE_CUBE_UV + varying vec3 vWorldPosition; + uniform float radius; + uniform float height; + uniform float angle; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube map; + #else + uniform sampler2D map; + #endif + // From: https://www.shadertoy.com/view/4tsBD7 + float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) + { + float d = dot ( rd, n ); + + if( d > 0.0 ) { return 1e6; } + + vec3 o = ro - c; + float t = - dot( n, o ) / d; + vec3 q = o + rd * t; + + return ( dot( q, q ) < r * r ) ? t : 1e6; + } + // From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm + float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) + { + vec3 oc = ro - ce; + float b = dot( oc, rd ); + float c = dot( oc, oc ) - ra * ra; + float h = b * b - c; + + if( h < 0.0 ) { return -1.0; } + + h = sqrt( h ); + + return - b + h; + } + vec3 project() + { + vec3 p = normalize( vWorldPosition ); + vec3 camPos = cameraPosition; + camPos.y -= height; + float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius ); + if( intersection > 0.0 ) { + + vec3 h = vec3( 0.0, - height, 0.0 ); + float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius ); + p = ( camPos + min( intersection, intersection2 ) * p ) / radius; + } else { + p = vec3( 0.0, 1.0, 0.0 ); + } + return p; + } + #include + #include + void main() + { + vec3 projectedWorldPosition = project(); + + #ifdef ENVMAP_TYPE_CUBE + vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb; + #else + vec3 direction = normalize( projectedWorldPosition ); + vec2 uv = equirectUv( direction ); + vec3 outcolor = texture2D( map, uv ).rgb; + #endif + gl_FragColor = vec4( outcolor, 1.0 ); + #include + #include <${parseInt(vw.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}> + } + `,R={map:{value:t},height:{value:(n==null?void 0:n.height)||15},radius:{value:(n==null?void 0:n.radius)||100}},I=new dw(1,16),w=new Gd({uniforms:R,fragmentShader:P,vertexShader:C,side:pw});super(I,w)}set radius(t){this.material.uniforms.radius.value=t}get radius(){return this.material.uniforms.radius.value}set height(t){this.material.uniforms.height.value=t}get height(){return this.material.uniforms.height.value}}class m2 extends f0{constructor(t){super(t),this.type=Ln}parse(t){const c=function(O,G){switch(O){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(G||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(G||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(G||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(G||""))}},g=` +`,m=function(O,G,Y){G=G||1024;let ae=O.pos,he=-1,de=0,ze="",ye=String.fromCharCode.apply(null,new Uint16Array(O.subarray(ae,ae+128)));for(;0>(he=ye.indexOf(g))&&de=O.byteLength||!(ze=m(O)))&&c(1,"no header found"),(ye=ze.match(G))||c(3,"bad initial token"),de.valid|=1,de.programtype=ye[1],de.string+=ze+` +`;ze=m(O),ze!==!1;){if(de.string+=ze+` +`,ze.charAt(0)==="#"){de.comments+=ze+` +`;continue}if((ye=ze.match(Y))&&(de.gamma=parseFloat(ye[1])),(ye=ze.match(K))&&(de.exposure=parseFloat(ye[1])),(ye=ze.match(ae))&&(de.valid|=2,de.format=ye[1]),(ye=ze.match(he))&&(de.valid|=4,de.height=parseInt(ye[1],10),de.width=parseInt(ye[2],10)),de.valid&2&&de.valid&4)break}return de.valid&2||c(3,"missing format specifier"),de.valid&4||c(3,"missing image size specifier"),de},C=function(O,G,Y){const K=G;if(K<8||K>32767||O[0]!==2||O[1]!==2||O[2]&128)return new Uint8Array(O);K!==(O[2]<<8|O[3])&&c(3,"wrong scanline width");const ae=new Uint8Array(4*G*Y);ae.length||c(4,"unable to allocate buffer space");let he=0,de=0;const ze=4*K,ye=new Uint8Array(4),Ke=new Uint8Array(ze);let D=Y;for(;D>0&&deO.byteLength&&c(1),ye[0]=O[de++],ye[1]=O[de++],ye[2]=O[de++],ye[3]=O[de++],(ye[0]!=2||ye[1]!=2||(ye[2]<<8|ye[3])!=K)&&c(3,"bad rgbe scanline format");let X=0,Q;for(;X128;if(ie&&(Q-=128),(Q===0||X+Q>ze)&&c(3,"bad scanline data"),ie){const we=O[de++];for(let Ue=0;Ue>3]&1<<(U&7))&&(_[M++]=U);for(var j=M-1;M<65536;)_[M++]=0;return j}function K(h){for(var _=0;_<16384;_++)h[_]={},h[_].len=0,h[_].lit=0,h[_].p=null}const ae={l:0,c:0,lc:0};function he(h,_,M,U,j){for(;M>M&(1<0;--_){var U=M+de[_]>>1;de[_]=M,M=U}for(var _=0;_<65537;++_){var j=h[_];j>0&&(h[_]=j|de[j]++<<6)}}function ye(h,_,M,U,j,H,q){for(var J=M,ne=0,te=0;j<=H;j++){if(J.value-M.value>U)return!1;he(6,ne,te,h,J);var re=ae.l;if(ne=ae.c,te=ae.lc,q[j]=re,re==63){if(J.value-M.value>U)throw"Something wrong with hufUnpackEncTable";he(8,ne,te,h,J);var ee=ae.l+6;if(ne=ae.c,te=ae.lc,j+ee>H+1)throw"Something wrong with hufUnpackEncTable";for(;ee--;)q[j++]=0;j--}else if(re>=59){var ee=re-59+2;if(j+ee>H+1)throw"Something wrong with hufUnpackEncTable";for(;ee--;)q[j++]=0;j--}}ze(q)}function Ke(h){return h&63}function D(h){return h>>6}function X(h,_,M,U){for(;_<=M;_++){var j=D(h[_]),H=Ke(h[_]);if(j>>H)throw"Invalid table entry";if(H>14){var q=U[j>>H-14];if(q.len)throw"Invalid table entry";if(q.lit++,q.p){var J=q.p;q.p=new Array(q.lit);for(var ne=0;ne0;ne--){var q=U[(j<<14-H)+te];if(q.len||q.p)throw"Invalid table entry";q.len=H,q.lit=_,te++}}return!0}const Q={c:0,lc:0};function le(h,_,M,U){h=h<<8|cu(M,U),_+=8,Q.c=h,Q.lc=_}const ie={c:0,lc:0};function we(h,_,M,U,j,H,q,J,ne,te){if(h==_){U<8&&(le(M,U,j,q),M=Q.c,U=Q.lc),U-=8;var re=M>>U,re=new Uint8Array([re])[0];if(ne.value+re>te)return!1;for(var ee=J[ne.value-1];re-- >0;)J[ne.value++]=ee}else if(ne.value32767?_-65536:_}const Ee={a:0,b:0};function ft(h,_){var M=ct(h),U=ct(_),j=U,H=M+(j&1)+(j>>1),q=H,J=H-j;Ee.a=q,Ee.b=J}function An(h,_){var M=Ue(h),U=Ue(_),j=M-(U>>1)&65535,H=U+j-32768&65535;Ee.a=H,Ee.b=j}function Ai(h,_,M,U,j,H,q){for(var J=q<16384,ne=M>j?j:M,te=1,re;te<=ne;)te<<=1;for(te>>=1,re=te,te>>=1;te>=1;){for(var ee=0,Ve=ee+H*(j-re),pe=H*te,me=H*re,ke=U*te,Pe=U*re,De,Oe,_e,Me;ee<=Ve;ee+=me){for(var Fe=ee,Xe=ee+U*(M-re);Fe<=Xe;Fe+=Pe){var Te=Fe+ke,Je=Fe+pe,Ut=Je+ke;J?(ft(h[Fe+_],h[Je+_]),De=Ee.a,_e=Ee.b,ft(h[Te+_],h[Ut+_]),Oe=Ee.a,Me=Ee.b,ft(De,Oe),h[Fe+_]=Ee.a,h[Te+_]=Ee.b,ft(_e,Me),h[Je+_]=Ee.a,h[Ut+_]=Ee.b):(An(h[Fe+_],h[Je+_]),De=Ee.a,_e=Ee.b,An(h[Te+_],h[Ut+_]),Oe=Ee.a,Me=Ee.b,An(De,Oe),h[Fe+_]=Ee.a,h[Te+_]=Ee.b,An(_e,Me),h[Je+_]=Ee.a,h[Ut+_]=Ee.b)}if(M&te){var Je=Fe+pe;J?ft(h[Fe+_],h[Je+_]):An(h[Fe+_],h[Je+_]),De=Ee.a,h[Je+_]=Ee.b,h[Fe+_]=De}}if(j&te)for(var Fe=ee,Xe=ee+U*(M-re);Fe<=Xe;Fe+=Pe){var Te=Fe+ke;J?ft(h[Fe+_],h[Te+_]):An(h[Fe+_],h[Te+_]),De=Ee.a,h[Te+_]=Ee.b,h[Fe+_]=De}re=te,te>>=1}return ee}function Bl(h,_,M,U,j,H,q,J,ne,te){for(var re=0,ee=0,Ve=J,pe=Math.trunc(j.value+(H+7)/8);j.value=14;){var me=re>>ee-14&16383,ke=_[me];if(ke.len)ee-=ke.len,we(ke.lit,q,re,ee,M,U,j,ne,te,Ve),re=ie.c,ee=ie.lc;else{if(!ke.p)throw"hufDecode issues";var Pe;for(Pe=0;Pe=De&&D(h[ke.p[Pe]])==(re>>ee-De&(1<>=Oe,ee-=Oe;ee>0;){var ke=_[re<<14-ee&16383];if(ke.len)ee-=ke.len,we(ke.lit,q,re,ee,M,U,j,ne,te,Ve),re=ie.c,ee=ie.lc;else throw"hufDecode issues"}return!0}function en(h,_,M,U,j,H){var q={value:0},J=M.value,ne=Dt(_,M),te=Dt(_,M);M.value+=4;var re=Dt(_,M);if(M.value+=4,ne<0||ne>=65537||te<0||te>=65537)throw"Something wrong with HUF_ENCSIZE";var ee=new Array(65537),Ve=new Array(16384);K(Ve);var pe=U-(M.value-J);if(ye(h,_,M,pe,ne,te,ee),re>8*(U-(M.value-J)))throw"Something wrong with hufUncompress";X(ee,ne,te,Ve),Bl(ee,Ve,h,_,M,re,te,H,j,q)}function jl(h,_,M){for(var U=0;UH||(_[j++]=h[M++],j>H));)_[j++]=h[U++]}function uu(h){for(var _=h.byteLength,M=new Array,U=0,j=new DataView(h);_>0;){var H=j.getInt8(U++);if(H<0){var q=-H;_-=q+1;for(var J=0;J>8==255?j+=U&255:(M[j]=U,j++),h.value++}function As(h,_){_[0]=se(h[0]),_[1]=se(h[1]),_[2]=se(h[5]),_[3]=se(h[6]),_[4]=se(h[14]),_[5]=se(h[15]),_[6]=se(h[27]),_[7]=se(h[28]),_[8]=se(h[2]),_[9]=se(h[4]),_[10]=se(h[7]),_[11]=se(h[13]),_[12]=se(h[16]),_[13]=se(h[26]),_[14]=se(h[29]),_[15]=se(h[42]),_[16]=se(h[3]),_[17]=se(h[8]),_[18]=se(h[12]),_[19]=se(h[17]),_[20]=se(h[25]),_[21]=se(h[30]),_[22]=se(h[41]),_[23]=se(h[43]),_[24]=se(h[9]),_[25]=se(h[11]),_[26]=se(h[18]),_[27]=se(h[24]),_[28]=se(h[31]),_[29]=se(h[40]),_[30]=se(h[44]),_[31]=se(h[53]),_[32]=se(h[10]),_[33]=se(h[19]),_[34]=se(h[23]),_[35]=se(h[32]),_[36]=se(h[39]),_[37]=se(h[45]),_[38]=se(h[52]),_[39]=se(h[54]),_[40]=se(h[20]),_[41]=se(h[22]),_[42]=se(h[33]),_[43]=se(h[38]),_[44]=se(h[46]),_[45]=se(h[51]),_[46]=se(h[55]),_[47]=se(h[60]),_[48]=se(h[21]),_[49]=se(h[34]),_[50]=se(h[37]),_[51]=se(h[47]),_[52]=se(h[50]),_[53]=se(h[56]),_[54]=se(h[59]),_[55]=se(h[61]),_[56]=se(h[35]),_[57]=se(h[36]),_[58]=se(h[48]),_[59]=se(h[49]),_[60]=se(h[57]),_[61]=se(h[58]),_[62]=se(h[62]),_[63]=se(h[63])}function Bs(h){const _=.5*Math.cos(.7853975),M=.5*Math.cos(3.14159/16),U=.5*Math.cos(3.14159/8),j=.5*Math.cos(3*3.14159/16),H=.5*Math.cos(5*3.14159/16),q=.5*Math.cos(3*3.14159/8),J=.5*Math.cos(7*3.14159/16);for(var ne=new Array(4),te=new Array(4),re=new Array(4),ee=new Array(4),Ve=0;Ve<8;++Ve){var pe=Ve*8;ne[0]=U*h[pe+2],ne[1]=q*h[pe+2],ne[2]=U*h[pe+6],ne[3]=q*h[pe+6],te[0]=M*h[pe+1]+j*h[pe+3]+H*h[pe+5]+J*h[pe+7],te[1]=j*h[pe+1]-J*h[pe+3]-M*h[pe+5]-H*h[pe+7],te[2]=H*h[pe+1]-M*h[pe+3]+J*h[pe+5]+j*h[pe+7],te[3]=J*h[pe+1]-H*h[pe+3]+j*h[pe+5]-M*h[pe+7],re[0]=_*(h[pe+0]+h[pe+4]),re[3]=_*(h[pe+0]-h[pe+4]),re[1]=ne[0]+ne[3],re[2]=ne[1]-ne[2],ee[0]=re[0]+re[1],ee[1]=re[3]+re[2],ee[2]=re[3]-re[2],ee[3]=re[0]-re[1],h[pe+0]=ee[0]+te[0],h[pe+1]=ee[1]+te[1],h[pe+2]=ee[2]+te[2],h[pe+3]=ee[3]+te[3],h[pe+4]=ee[3]-te[3],h[pe+5]=ee[2]-te[2],h[pe+6]=ee[1]-te[1],h[pe+7]=ee[0]-te[0]}for(var me=0;me<8;++me)ne[0]=U*h[16+me],ne[1]=q*h[16+me],ne[2]=U*h[48+me],ne[3]=q*h[48+me],te[0]=M*h[8+me]+j*h[24+me]+H*h[40+me]+J*h[56+me],te[1]=j*h[8+me]-J*h[24+me]-M*h[40+me]-H*h[56+me],te[2]=H*h[8+me]-M*h[24+me]+J*h[40+me]+j*h[56+me],te[3]=J*h[8+me]-H*h[24+me]+j*h[40+me]-M*h[56+me],re[0]=_*(h[me]+h[32+me]),re[3]=_*(h[me]-h[32+me]),re[1]=ne[0]+ne[3],re[2]=ne[1]-ne[2],ee[0]=re[0]+re[1],ee[1]=re[3]+re[2],ee[2]=re[3]-re[2],ee[3]=re[0]-re[1],h[0+me]=ee[0]+te[0],h[8+me]=ee[1]+te[1],h[16+me]=ee[2]+te[2],h[24+me]=ee[3]+te[3],h[32+me]=ee[3]-te[3],h[40+me]=ee[2]-te[2],h[48+me]=ee[1]-te[1],h[56+me]=ee[0]-te[0]}function al(h){for(var _=0;_<64;++_){var M=h[0][_],U=h[1][_],j=h[2][_];h[0][_]=M+1.5747*j,h[1][_]=M-.1873*U-.4682*j,h[2][_]=M+1.8556*U}}function js(h,_,M){for(var U=0;U<64;++U)_[M+U]=li.toHalfFloat(Hs(h[U]))}function Hs(h){return h<=1?Math.sign(h)*Math.pow(Math.abs(h),2.2):Math.sign(h)*Math.pow(G,Math.abs(h)-1)}function au(h){return new DataView(h.array.buffer,h.offset.value,h.size)}function sl(h){var _=h.viewer.buffer.slice(h.offset.value,h.offset.value+h.size),M=new Uint8Array(uu(_)),U=new Uint8Array(M.length);return Ft(M),ou(M,U),new DataView(U.buffer)}function Bi(h){var _=h.array.slice(h.offset.value,h.offset.value+h.size),M=Ta(_),U=new Uint8Array(M.length);return Ft(M),ou(M,U),new DataView(U.buffer)}function Ws(h){for(var _=h.viewer,M={value:h.offset.value},U=new Uint16Array(h.width*h.scanlineBlockSize*(h.channels*h.type)),j=new Uint8Array(8192),H=0,q=new Array(h.channels),J=0;J=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(ne<=te)for(var J=0;J0;){var J=Hl(_.buffer,M),ne=Tr(_,M),te=ne>>2&3,re=(ne>>4)-1,ee=new Int8Array([re])[0],Ve=Tr(_,M);H.push({name:J,index:ee,type:Ve,compression:te}),q-=J.length+3}for(var pe=Bn.channels,me=new Array(h.channels),ke=0;ke=0&&(Oe.idx[Me.index]=_e),Pe.offset=_e)}if(j.acCompressedSize>0)switch(j.acCompression){case 0:var Te=new Uint16Array(j.totalAcUncompressedCount);en(h.array,_,M,j.acCompressedSize,Te,j.totalAcUncompressedCount);break;case 1:var Fe=h.array.slice(M.value,M.value+j.totalAcUncompressedCount),Xe=Ta(Fe),Te=new Uint16Array(Xe.buffer);M.value+=j.totalAcUncompressedCount;break}if(j.dcCompressedSize>0){var Je={array:h.array,offset:M,size:j.dcCompressedSize},Ut=new Uint16Array(Bi(Je).buffer);M.value+=j.dcCompressedSize}if(j.rleRawSize>0){var Fe=h.array.slice(M.value,M.value+j.rleCompressedSize),Xe=Ta(Fe),mt=uu(Xe.buffer);M.value+=j.rleCompressedSize}for(var Nt=0,Qe=new Array(me.length),ke=0;ke>10,M=h&1023;return(h>>15?-1:1)*(_?_===31?M?NaN:1/0:Math.pow(2,_-15)*(1+M/1024):6103515625e-14*(M/1024))}function fl(h,_){var M=h.getUint16(_.value,!0);return _.value+=2,M}function Ys(h,_){return se(fl(h,_))}function Ks(h,_,M,U){for(var j=M.value,H=[];M.valueIe.height?Ie.height-_:Ie.scanlineBlockSize;const U=Ie.size=Ie.height)break;for(let q=0;q{let i;switch(e){case Va:i=new Uint8ClampedArray(t*n*4);break;case Ln:i=new Uint16Array(t*n*4);break;case Sw:i=new Uint32Array(t*n*4);break;case ww:i=new Int8Array(t*n*4);break;case yw:i=new Int16Array(t*n*4);break;case gw:i=new Int32Array(t*n*4);break;case Er:i=new Float32Array(t*n*4);break;default:throw new Error("Unsupported data type")}return i};let Ra;const S2=(e,t,n,i)=>{if(Ra!==void 0)return Ra;const o=new p0(1,1,i);t.setRenderTarget(o);const a=new Vd(new d0,new Ew({color:16777215}));t.render(a,n),t.setRenderTarget(null);const c=ry(e,o.width,o.height);return t.readRenderTargetPixels(o,0,0,o.width,o.height,c),o.dispose(),a.geometry.dispose(),a.material.dispose(),Ra=c[0]!==0,Ra};class Gp{constructor(t){var n,i,o,a,c,d,v,y,g,m,S,C,P,R,I,w;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(x){throw this._renderer.setRenderTarget(null),x}this._renderer.setRenderTarget(null)},this._width=t.width,this._height=t.height,this._type=t.type,this._colorSpace=t.colorSpace;const E={format:Ci,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:((n=t.renderTargetOptions)===null||n===void 0?void 0:n.anisotropy)!==void 0?(i=t.renderTargetOptions)===null||i===void 0?void 0:i.anisotropy:1,generateMipmaps:((o=t.renderTargetOptions)===null||o===void 0?void 0:o.generateMipmaps)!==void 0?(a=t.renderTargetOptions)===null||a===void 0?void 0:a.generateMipmaps:!1,magFilter:((c=t.renderTargetOptions)===null||c===void 0?void 0:c.magFilter)!==void 0?(d=t.renderTargetOptions)===null||d===void 0?void 0:d.magFilter:ur,minFilter:((v=t.renderTargetOptions)===null||v===void 0?void 0:v.minFilter)!==void 0?(y=t.renderTargetOptions)===null||y===void 0?void 0:y.minFilter:ur,samples:((g=t.renderTargetOptions)===null||g===void 0?void 0:g.samples)!==void 0?(m=t.renderTargetOptions)===null||m===void 0?void 0:m.samples:void 0,wrapS:((S=t.renderTargetOptions)===null||S===void 0?void 0:S.wrapS)!==void 0?(C=t.renderTargetOptions)===null||C===void 0?void 0:C.wrapS:Gr,wrapT:((P=t.renderTargetOptions)===null||P===void 0?void 0:P.wrapT)!==void 0?(R=t.renderTargetOptions)===null||R===void 0?void 0:R.wrapT:Gr};if(this._material=t.material,t.renderer?this._renderer=t.renderer:(this._renderer=Gp.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new Ga,this._camera=new s0,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!S2(this._type,this._renderer,this._camera,E)){let x;switch(this._type){case Ln:x=this._renderer.extensions.has("EXT_color_buffer_float")?Er:void 0;break}x!==void 0?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${Er}`),this._type=x):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new Vd(new d0,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new p0(this.width,this.height,E),this._renderTarget.texture.mapping=((I=t.renderTargetOptions)===null||I===void 0?void 0:I.mapping)!==void 0?(w=t.renderTargetOptions)===null||w===void 0?void 0:w.mapping:Za}static instantiateRenderer(){const t=new c0;return t.setSize(128,128),t}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const t=ry(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,t),t}toDataTexture(t){const n=new mw(this.toArray(),this.width,this.height,Ci,this._type,(t==null?void 0:t.mapping)||Za,(t==null?void 0:t.wrapS)||Gr,(t==null?void 0:t.wrapT)||Gr,(t==null?void 0:t.magFilter)||ur,(t==null?void 0:t.minFilter)||ur,(t==null?void 0:t.anisotropy)||1,Vf);return n.generateMipmaps=(t==null?void 0:t.generateMipmaps)!==void 0?t==null?void 0:t.generateMipmaps:!1,n}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(t){this.disposeOnDemandRenderer(),t&&this.renderTarget.dispose(),this.material instanceof Gd&&Object.values(this.material.uniforms).forEach(n=>{n.value instanceof Vr&&n.value.dispose()}),Object.values(this.material).forEach(n=>{n instanceof Vr&&n.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(t){this._width=t,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(t){this._height=t,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(t){this._renderTarget=t,this._width=t.width,this._height=t.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}const E2=` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} +`,_2=` +// min half float value +#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 ) +// max half float value +#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 ) + +uniform sampler2D sdr; +uniform sampler2D gainMap; +uniform vec3 gamma; +uniform vec3 offsetHdr; +uniform vec3 offsetSdr; +uniform vec3 gainMapMin; +uniform vec3 gainMapMax; +uniform float weightFactor; + +varying vec2 vUv; + +void main() { + vec3 rgb = texture2D( sdr, vUv ).rgb; + vec3 recovery = texture2D( gainMap, vUv ).rgb; + vec3 logRecovery = pow( recovery, gamma ); + vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery; + vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr; + vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor )); + gl_FragColor = vec4( clampedHdrColor , 1.0 ); +} +`;class k2 extends Gd{constructor({gamma:t,offsetHdr:n,offsetSdr:i,gainMapMin:o,gainMapMax:a,maxDisplayBoost:c,hdrCapacityMin:d,hdrCapacityMax:v,sdr:y,gainMap:g}){super({name:"GainMapDecoderMaterial",vertexShader:E2,fragmentShader:_2,uniforms:{sdr:{value:y},gainMap:{value:g},gamma:{value:new zn(1/t[0],1/t[1],1/t[2])},offsetHdr:{value:new zn().fromArray(n)},offsetSdr:{value:new zn().fromArray(i)},gainMapMin:{value:new zn().fromArray(o)},gainMapMax:{value:new zn().fromArray(a)},weightFactor:{value:(Math.log2(c)-d)/(v-d)}},blending:Cw,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=c,this._hdrCapacityMin=d,this._hdrCapacityMax=v,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(t){this.uniforms.sdr.value=t}get gainMap(){return this.uniforms.gainMap.value}set gainMap(t){this.uniforms.gainMap.value=t}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(t){this.uniforms.offsetHdr.value.fromArray(t)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(t){this.uniforms.offsetSdr.value.fromArray(t)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(t){this.uniforms.gainMapMin.value.fromArray(t)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(t){this.uniforms.gainMapMax.value.fromArray(t)}get gamma(){const t=this.uniforms.gamma.value;return[1/t.x,1/t.y,1/t.z]}set gamma(t){const n=this.uniforms.gamma.value;n.x=1/t[0],n.y=1/t[1],n.z=1/t[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(t){this._hdrCapacityMin=t,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(t){this._hdrCapacityMax=t,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(t){this._maxDisplayBoost=Math.max(1,Math.min(65504,t)),this.calculateWeight()}calculateWeight(){const t=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,t))}}class ly extends Error{}class iy extends Error{}const yo=(e,t,n)=>{var i;let o;const a=(i=e.attributes.getNamedItem(t))===null||i===void 0?void 0:i.nodeValue;if(a)o=a;else{const c=e.getElementsByTagName(t)[0];if(c){const d=c.getElementsByTagName("rdf:li");if(d.length===3)o=Array.from(d).map(v=>v.innerHTML);else throw new Error(`Gainmap metadata contains an array of items for ${t} but its length is not 3`)}else{if(n)return n;throw new Error(`Can't find ${t} in gainmap metadata`)}}return o},x2=e=>{var t,n;let i;typeof TextDecoder<"u"?i=new TextDecoder().decode(e):i=e.toString();let o=i.indexOf("",o);i.slice(o,c+10);const d=i.slice(o,c+10);try{const y=a.parseFromString(d,"text/xml").getElementsByTagName("rdf:Description")[0],g=yo(y,"hdrgm:GainMapMin","0"),m=yo(y,"hdrgm:GainMapMax"),S=yo(y,"hdrgm:Gamma","1"),C=yo(y,"hdrgm:OffsetSDR","0.015625"),P=yo(y,"hdrgm:OffsetHDR","0.015625");let R=(t=y.attributes.getNamedItem("hdrgm:HDRCapacityMin"))===null||t===void 0?void 0:t.nodeValue;R||(R="0");const I=(n=y.attributes.getNamedItem("hdrgm:HDRCapacityMax"))===null||n===void 0?void 0:n.nodeValue;if(!I)throw new Error("Incomplete gainmap metadata");return{gainMapMin:Array.isArray(g)?g.map(w=>parseFloat(w)):[parseFloat(g),parseFloat(g),parseFloat(g)],gainMapMax:Array.isArray(m)?m.map(w=>parseFloat(w)):[parseFloat(m),parseFloat(m),parseFloat(m)],gamma:Array.isArray(S)?S.map(w=>parseFloat(w)):[parseFloat(S),parseFloat(S),parseFloat(S)],offsetSdr:Array.isArray(C)?C.map(w=>parseFloat(w)):[parseFloat(C),parseFloat(C),parseFloat(C)],offsetHdr:Array.isArray(P)?P.map(w=>parseFloat(w)):[parseFloat(P),parseFloat(P),parseFloat(P)],hdrCapacityMin:parseFloat(R),hdrCapacityMax:parseFloat(I)}}catch{}o=i.indexOf("{const o=this.options.debug,a=new DataView(t.buffer);if(a.getUint16(0)!==65496){i(new Error("Not a valid jpeg"));return}const c=a.byteLength;let d=2,v=0,y;for(;d250){i(new Error(`Found no marker after ${v} loops 😵`));return}if(a.getUint8(d)!==255){i(new Error(`Not a valid marker at offset 0x${d.toString(16)}, found: 0x${a.getUint8(d).toString(16)}`));return}if(y=a.getUint8(d+1),o&&console.log(`Marker: ${y.toString(16)}`),y===226){o&&console.log("Found APP2 marker (0xffe2)");const g=d+4;if(a.getUint32(g)===1297106432){const m=g+4;let S;if(a.getUint16(m)===18761)S=!1;else if(a.getUint16(m)===19789)S=!0;else{i(new Error("No valid endianness marker found in TIFF header"));return}if(a.getUint16(m+2,!S)!==42){i(new Error("Not valid TIFF data! (no 0x002A marker)"));return}const C=a.getUint32(m+4,!S);if(C<8){i(new Error("Not valid TIFF data! (First offset less than 8)"));return}const P=m+C,R=a.getUint16(P,!S),I=P+2;let w=0;for(let L=I;L{const t=x2(e);if(!t)throw new iy("Gain map XMP metadata not found");const i=await new C2({extractFII:!0,extractNonFII:!0}).extract(e);if(i.length!==2)throw new ly("Gain map recovery image not found");return{sdr:new Uint8Array(await i[0].arrayBuffer()),gainMap:new Uint8Array(await i[1].arrayBuffer()),metadata:t}},t0=e=>new Promise((t,n)=>{const i=document.createElement("img");i.onload=()=>{t(i)},i.onerror=o=>{n(o)},i.src=URL.createObjectURL(e)});class oy extends _w{constructor(t,n){super(n),t&&(this._renderer=t),this._internalLoadingManager=new kw}setRenderer(t){return this._renderer=t,this}setRenderTargetOptions(t){return this._renderTargetOptions=t,this}prepareQuadRenderer(){this._renderer||console.warn("WARNING: An existing WebGL Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.");const t=new k2({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new Vr,sdr:new Vr});return new Gp({width:16,height:16,type:Ln,colorSpace:Vf,material:t,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(t,n,i,o){const a=o?new Blob([o],{type:"image/jpeg"}):void 0,c=new Blob([i],{type:"image/jpeg"});let d,v,y=!1;if(typeof createImageBitmap>"u"){const S=await Promise.all([a?t0(a):Promise.resolve(void 0),t0(c)]);v=S[0],d=S[1],y=!0}else{const S=await Promise.all([a?createImageBitmap(a,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(c,{imageOrientation:"flipY"})]);v=S[0],d=S[1]}const g=new Vr(v||new ImageData(2,2),Za,Gr,Gr,ur,Rh,Ci,Va,1,Vf);g.flipY=y,g.needsUpdate=!0;const m=new Vr(d,Za,Gr,Gr,ur,Rh,Ci,Va,1,xw);m.flipY=y,m.needsUpdate=!0,t.width=d.width,t.height=d.height,t.material.gainMap=g,t.material.sdr=m,t.material.gainMapMin=n.gainMapMin,t.material.gainMapMax=n.gainMapMax,t.material.offsetHdr=n.offsetHdr,t.material.offsetSdr=n.offsetSdr,t.material.gamma=n.gamma,t.material.hdrCapacityMin=n.hdrCapacityMin,t.material.hdrCapacityMax=n.hdrCapacityMax,t.material.maxDisplayBoost=Math.pow(2,n.hdrCapacityMax),t.material.needsUpdate=!0,t.render()}}class M2 extends oy{load([t,n,i],o,a,c){const d=this.prepareQuadRenderer();let v,y,g;const m=async()=>{if(v&&y&&g){try{await this.render(d,g,v,y)}catch(G){this.manager.itemError(t),this.manager.itemError(n),this.manager.itemError(i),typeof c=="function"&&c(G),d.disposeOnDemandRenderer();return}typeof o=="function"&&o(d),this.manager.itemEnd(t),this.manager.itemEnd(n),this.manager.itemEnd(i),d.disposeOnDemandRenderer()}};let S=!0,C=0,P=0,R=!0,I=0,w=0,E=!0,x=0,N=0;const L=()=>{if(typeof a=="function"){const G=C+I+x,Y=P+w+N,K=S&&R&&E;a(new ProgressEvent("progress",{lengthComputable:K,loaded:Y,total:G}))}};this.manager.itemStart(t),this.manager.itemStart(n),this.manager.itemStart(i);const A=new Na(this._internalLoadingManager);A.setResponseType("arraybuffer"),A.setRequestHeader(this.requestHeader),A.setPath(this.path),A.setWithCredentials(this.withCredentials),A.load(t,async G=>{if(typeof G=="string")throw new Error("Invalid sdr buffer");v=G,await m()},G=>{S=G.lengthComputable,P=G.loaded,C=G.total,L()},G=>{this.manager.itemError(t),typeof c=="function"&&c(G)});const Z=new Na(this._internalLoadingManager);Z.setResponseType("arraybuffer"),Z.setRequestHeader(this.requestHeader),Z.setPath(this.path),Z.setWithCredentials(this.withCredentials),Z.load(n,async G=>{if(typeof G=="string")throw new Error("Invalid gainmap buffer");y=G,await m()},G=>{R=G.lengthComputable,w=G.loaded,I=G.total,L()},G=>{this.manager.itemError(n),typeof c=="function"&&c(G)});const O=new Na(this._internalLoadingManager);return O.setRequestHeader(this.requestHeader),O.setPath(this.path),O.setWithCredentials(this.withCredentials),O.load(i,async G=>{if(typeof G!="string")throw new Error("Invalid metadata string");g=JSON.parse(G),await m()},G=>{E=G.lengthComputable,N=G.loaded,x=G.total,L()},G=>{this.manager.itemError(i),typeof c=="function"&&c(G)}),d}}class T2 extends oy{load(t,n,i,o){const a=this.prepareQuadRenderer(),c=new Na(this._internalLoadingManager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),this.manager.itemStart(t),c.load(t,async d=>{if(typeof d=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const v=new Uint8Array(d);let y,g,m;try{const S=await P2(v);y=S.sdr,g=S.gainMap,m=S.metadata}catch(S){if(S instanceof iy||S instanceof ly)console.warn(`Failure to reconstruct an HDR image from ${t}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),m={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},y=v;else throw S}try{await this.render(a,m,y,g)}catch(S){this.manager.itemError(t),typeof o=="function"&&o(S),a.disposeOnDemandRenderer();return}typeof n=="function"&&n(a),this.manager.itemEnd(t),a.disposeOnDemandRenderer()},i,d=>{this.manager.itemError(t),typeof o=="function"&&o(d)}),a}}const $o={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},uy="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",xi=e=>Array.isArray(e),Zp=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function Os({files:e=Zp,path:t="",preset:n=void 0,encoding:i=void 0,extensions:o}={}){let a=null,c=!1;n&&(Xp(n),e=$o[n],t=uy),c=xi(e);const{extension:d,isCubemap:v}=Yp(e);if(a=Kp(d),!a)throw new Error("useEnvironment: Unrecognized file extension: "+e);const y=Nn(C=>C.gl);V.useLayoutEffect(()=>{if(d!=="webp"&&d!=="jpg"&&d!=="jpeg")return;function C(){Li.clear(a,c?[e]:e)}y.domElement.addEventListener("webglcontextlost",C,{once:!0})},[e,y.domElement]);const g=Li(a,c?[e]:e,C=>{(d==="webp"||d==="jpg"||d==="jpeg")&&C.setRenderer(y),C.setPath==null||C.setPath(t),o&&o(C)});let m=c?g[0]:g;if(d==="jpg"||d==="jpeg"||d==="webp"){var S;m=(S=m.renderTarget)==null?void 0:S.texture}return m.mapping=v?Pw:Mw,"colorSpace"in m?m.colorSpace=i??v?"srgb":"srgb-linear":m.encoding=i??v?w2:y2,m}const R2={files:Zp,path:"",preset:void 0,extensions:void 0};Os.preload=e=>{const t={...R2,...e};let{files:n,path:i=""}=t;const{preset:o,extensions:a}=t;o&&(Xp(o),n=$o[o],i=uy);const{extension:c}=Yp(n);if(c==="webp"||c==="jpg"||c==="jpeg")throw new Error("useEnvironment: Preloading gainmaps is not supported");const d=Kp(c);if(!d)throw new Error("useEnvironment: Unrecognized file extension: "+n);Li.preload(d,xi(n)?[n]:n,v=>{v.setPath==null||v.setPath(i),a&&a(v)})};const N2={files:Zp,preset:void 0};Os.clear=e=>{const t={...N2,...e};let{files:n}=t;const{preset:i}=t;i&&(Xp(i),n=$o[i]);const{extension:o}=Yp(n),a=Kp(o);if(!a)throw new Error("useEnvironment: Unrecognized file extension: "+n);Li.clear(a,xi(n)?[n]:n)};function Xp(e){if(!(e in $o))throw new Error("Preset must be one of: "+Object.keys($o).join(", "))}function Yp(e){var t;const n=xi(e)&&e.length===6,i=xi(e)&&e.length===3&&e.some(c=>c.endsWith("json")),o=xi(e)?e[0]:e;return{extension:n?"cube":i?"webp":o.startsWith("data:application/exr")?"exr":o.startsWith("data:application/hdr")?"hdr":o.startsWith("data:image/jpeg")?"jpg":(t=o.split(".").pop())==null||(t=t.split("?"))==null||(t=t.shift())==null?void 0:t.toLowerCase(),isCubemap:n,isGainmap:i}}function Kp(e){return e==="cube"?Tw:e==="hdr"?m2:e==="exr"?g2:e==="jpg"||e==="jpeg"?T2:e==="webp"?M2:null}const z2=e=>e.current&&e.current.isScene,I2=e=>z2(e)?e.current:e;function Jp(e,t,n,i,o={}){var a,c,d,v,y;o={backgroundBlurriness:(a=o.blur)!==null&&a!==void 0?a:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...o};const g=I2(t||n),m=g.background,S=g.environment,C={backgroundBlurriness:g.backgroundBlurriness,backgroundIntensity:g.backgroundIntensity,backgroundRotation:(c=(d=g.backgroundRotation)==null||d.clone==null?void 0:d.clone())!==null&&c!==void 0?c:[0,0,0],environmentIntensity:g.environmentIntensity,environmentRotation:(v=(y=g.environmentRotation)==null||y.clone==null?void 0:y.clone())!==null&&v!==void 0?v:[0,0,0]};return e!=="only"&&(g.environment=i),e&&(g.background=i),Hr(g,o),()=>{e!=="only"&&(g.environment=S),e&&(g.background=m),Hr(g,C)}}function $p({scene:e,background:t=!1,map:n,...i}){const o=Nn(a=>a.scene);return V.useLayoutEffect(()=>{if(n)return Jp(t,e,o,n,i)}),null}function ay({background:e=!1,scene:t,blur:n,backgroundBlurriness:i,backgroundIntensity:o,backgroundRotation:a,environmentIntensity:c,environmentRotation:d,...v}){const y=Os(v),g=Nn(m=>m.scene);return V.useLayoutEffect(()=>Jp(e,t,g,y,{blur:n,backgroundBlurriness:i,backgroundIntensity:o,backgroundRotation:a,environmentIntensity:c,environmentRotation:d})),null}function L2({children:e,near:t=1,far:n=1e3,resolution:i=256,frames:o=1,map:a,background:c=!1,blur:d,backgroundBlurriness:v,backgroundIntensity:y,backgroundRotation:g,environmentIntensity:m,environmentRotation:S,scene:C,files:P,path:R,preset:I=void 0,extensions:w}){const E=Nn(O=>O.gl),x=Nn(O=>O.scene),N=V.useRef(null),[L]=V.useState(()=>new Ga),A=V.useMemo(()=>{const O=new Rw(i);return O.texture.type=Ln,O},[i]);V.useLayoutEffect(()=>(o===1&&N.current.update(E,L),Jp(c,C,x,A.texture,{blur:d,backgroundBlurriness:v,backgroundIntensity:y,backgroundRotation:g,environmentIntensity:m,environmentRotation:S})),[e,L,A.texture,C,x,c,o,E]);let Z=1;return Qp(()=>{(o===1/0||ZO1({GroundProjectedEnvImpl:h2}),[]);const d=V.useMemo(()=>[c],[c]),v=(t=e.ground)==null?void 0:t.height,y=(n=e.ground)==null?void 0:n.radius,g=(i=(o=e.ground)==null?void 0:o.scale)!==null&&i!==void 0?i:1e3;return V.createElement(V.Fragment,null,V.createElement($p,Hd({},e,{map:c})),V.createElement("groundProjectedEnvImpl",{args:d,scale:g,height:v,radius:y}))}function Z2(e){return e.ground?V.createElement(O2,e):e.map?V.createElement($p,e):e.children?V.createElement(L2,e):V.createElement(ay,e)}function F2(e,t){if(e===t)return!0;if(!e||!t)return e===t;for(const n in e)if(e[n]!==t[n])return!1;for(const n in t)if(e[n]!==t[n])return!1;return!0}function Fs(e){const t=V.useRef();return F2(t.current,e)||(t.current=e),t.current}function n0(e){return/^on/g.test(e)}function r0(e){return e.replace(/^on/,"").replace(/[a-z][A-Z]/g,t=>`${t[0]}-${t[1]}`).toLowerCase()}function l0(e){return e.split("-")}function sy(e,t){let n=e;const i=[...t];for(;i.length!==0;){const o=i.shift();n=n[o]}return n}function i0(e,t,n){const i=[...t],o=i.pop();sy(e,i)[o]=n}function D2(e,t){V.useEffect(()=>{if(e!==null){for(const n in t)if(n0(n))e.addEventListener(r0(n),t[n]);else{const i=l0(n);sy(e,i),i0(e,i,t[n])}return()=>{for(const n in t)n0(n)&&e.removeEventListener(r0(n),t[n]);for(const n in t){const i=l0(n);i0(e,i,t[n])}}}},[e,Fs(t)])}function cy(e,t){V.useEffect(()=>{if(e===null)return;const n={};for(const i in t)i in e&&(n[i]=e[i],e[i]=t[i]);return()=>{for(const i in n)e[i]=n[i]}},[e,Fs(t)])}function U2(){const[e,t]=V.useState(0);return[e,()=>t(e+1)]}const iu=V.createContext(null);function A2({children:e}){const t=V.useContext(iu),n=V.useRef();return V.useEffect(()=>{t&&(n.current.matrixWorld=t.group.matrixWorld)},[t]),lt.jsx("group",{ref:n,matrixWorldAutoUpdate:!1,matrixAutoUpdate:!1,children:e})}const o0=new zn;function X2(e){const{lat:t=0,lon:n=0,height:i=0,az:o=0,el:a=0,roll:c=0,children:d}=e,v=V.useRef(),y=V.useContext(iu),g=y&&y.ellipsoid||null;return V.useEffect(()=>{if(g===null)return;const m=v.current;m.matrix.identity(),g.getRotationMatrixFromAzElRoll(t,n,o,a,c,m.matrix),g.getCartographicToPosition(t,n,i,o0),m.matrix.setPosition(o0),m.matrix.decompose(m.position,m.quaternion,m.scale),m.updateMatrixWorld()},[g,t,n,i,o,a,c]),lt.jsx("group",{ref:v,children:d})}const Y2=V.forwardRef(function(t,n){const{plugin:i,args:o,...a}=t,c=V.useContext(iu),d=V.useMemo(()=>{if(c===null)return null;let v;return Array.isArray(o)?v=new i(...o):v=new i(o),v},[c,i,Fs(o)]);cy(d,a),V.useEffect(()=>{n&&(n instanceof Function?n(d):n.current=d)},[d,n]),V.useEffect(()=>{if(c!==null)return c.registerPlugin(d),()=>{c.unregisterPlugin(d)}},[d,c])}),K2=V.forwardRef(function(t,n){const{url:i,group:o={},children:a,...c}=t,[d,v]=V.useState(null),[y,g,m]=Nn(P=>[P.camera,P.gl,P.invalidate]),[S,C]=U2();return V.useEffect(()=>{const P=new Iw(i);return P.addEventListener("load-content",()=>m()),P.addEventListener("force-rerender",()=>m()),v(P),()=>{P.dispose()}},[i,m]),Qp(()=>{d!==null&&(y.updateMatrixWorld(),d.setResolutionFromRenderer(y,g),d.update())}),V.useEffect(()=>{if(d!==null)return d.setCamera(y),()=>{d.deleteCamera(y)}},[d,y]),V.useEffect(()=>{n&&(n instanceof Function?n(d):n.current=d)},[d,n]),D2(d,c),V.useEffect(()=>{C()},[d,Fs(c)]),lt.jsxs(lt.Fragment,{children:[d?lt.jsx("primitive",{object:d.group,...o}):null,lt.jsx(iu.Provider,{value:d,children:lt.jsx(A2,{children:a})},S)]})}),fy=V.forwardRef(function(t,n){const{controlsConstructor:i,domElement:o,scene:a,camera:c,tilesRenderer:d,...v}=t,[y]=Nn(L=>[L.camera]),[g]=Nn(L=>[L.gl]),[m]=Nn(L=>[L.scene]),[S]=Nn(L=>[L.invalidate]),[C]=Nn(L=>[L.get]),[P]=Nn(L=>[L.set]),R=V.useContext(iu),I=c||y||null,w=a||m||null,E=o||g.domElement||null,x=d||R||null,N=V.useMemo(()=>new i,[i]);V.useEffect(()=>{n&&(n instanceof Function?n(N):n.current=N)},[N,n]),V.useEffect(()=>{const L=()=>S();return N.addEventListener("change",L),N.addEventListener("start",L),N.addEventListener("end",L),()=>{N.removeEventListener("change",L),N.removeEventListener("start",L),N.removeEventListener("end",L)}},[N,S]),V.useEffect(()=>{N.setCamera(I)},[N,I]),V.useEffect(()=>{N.setScene(w)},[N,w]),V.useEffect(()=>{N.setTilesRenderer(x)},[N,x]),V.useEffect(()=>(N.attach(E),()=>{N.detach()}),[N,E]),V.useEffect(()=>{const L=C().controls;return P({controls:N}),()=>P({controls:L})},[N,C,P]),Qp(()=>{N.update()},-1),cy(N,v)});function J2(e){return lt.jsx(fy,{...e,controlsConstructor:Nw})}function $2(e){return lt.jsx(fy,{...e,controlsConstructor:zw})}export{G2 as C,J2 as E,$2 as G,Kw as R,K2 as T,Hd as _,Y2 as a,Z2 as b,o_ as c,Nn as d,O1 as e,iu as f,D_ as g,D2 as h,X2 as i,lt as j,gs as k,P1 as l,V2 as m,Q2 as n,T1 as o,V as r,Qp as u}; diff --git a/example/bundle/assets/CameraTransitionManager-Dx_3SZAI.js b/example/bundle/assets/CameraTransitionManager-Dx_3SZAI.js new file mode 100644 index 00000000..33919af8 --- /dev/null +++ b/example/bundle/assets/CameraTransitionManager-Dx_3SZAI.js @@ -0,0 +1 @@ +import{k as g,O as D,aD as M,a as v,s as x,i as h}from"./three.module-DpclfMcJ.js";const e=new g,s=new g,d=new D,P=new g;class T extends M{get animating(){return this._alpha!==0&&this._alpha!==1}get camera(){return this._alpha===0?this.perspectiveCamera:this._alpha===1?this.orthographicCamera:this.transitionCamera}get mode(){return this._target===0?"perspective":"orthographic"}set mode(o){if(o===this.mode)return;const a=this.camera;o==="perspective"?(this._target=0,this._alpha=0):(this._target=1,this._alpha=1),this.dispatchEvent({type:"camera-change",camera:this.camera,prevCamera:a})}constructor(o=new v,a=new D){super(),this.perspectiveCamera=o,this.orthographicCamera=a,this.transitionCamera=new v,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new g,this.duration=200,this.autoSync=!0,this._target=0,this._alpha=0,this._clock=new x}toggle(){this._target=this._target===1?0:1,this._clock.getDelta()}update(){this.autoSync&&this.syncCameras();const{perspectiveCamera:o,orthographicCamera:a,transitionCamera:t,camera:p}=this,m=this._clock.getDelta()*1e3;if(this._alpha!==this._target){const n=Math.sign(this._target-this._alpha)*m/this.duration;this._alpha=h.clamp(this._alpha+n,0,1),this.dispatchEvent({type:"change"})}const c=p;let i=null;this._alpha===0?i=o:this._alpha===1?i=a:(i=t,this._updateTransitionCamera()),c!==i&&(i===t&&this.dispatchEvent({type:"transition-start"}),this.dispatchEvent({type:"camera-change",camera:i,prevCamera:c}),c===t&&this.dispatchEvent({type:"transition-end"}))}syncCameras(){const o=this._getFromCamera(),{perspectiveCamera:a,orthographicCamera:t,transitionCamera:p,fixedPoint:r}=this;if(e.set(0,0,-1).transformDirection(o.matrixWorld).normalize(),o.isPerspectiveCamera){if(this.orthographicPositionalZoom)t.position.copy(a.position).addScaledVector(e,-this.orthographicOffset),t.rotation.copy(a.rotation),t.updateMatrixWorld();else{const l=s.subVectors(r,t.position).dot(e),n=s.subVectors(r,a.position).dot(e);s.copy(a.position).addScaledVector(e,n),t.rotation.copy(a.rotation),t.position.copy(s).addScaledVector(e,-l),t.updateMatrixWorld()}const m=Math.abs(s.subVectors(a.position,r).dot(e)),c=2*Math.tan(h.DEG2RAD*a.fov*.5)*m,i=t.top-t.bottom;t.zoom=i/c,t.updateProjectionMatrix()}else{const m=Math.abs(s.subVectors(t.position,r).dot(e)),i=(t.top-t.bottom)/t.zoom*.5/Math.tan(h.DEG2RAD*a.fov*.5);a.rotation.copy(t.rotation),a.position.copy(t.position).addScaledVector(e,m).addScaledVector(e,-i),a.updateMatrixWorld(),this.orthographicPositionalZoom&&(t.position.copy(a.position).addScaledVector(e,-this.orthographicOffset),t.updateMatrixWorld())}p.position.copy(a.position),p.rotation.copy(a.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const o=this._getTransitionDirection();return o===0?this._target===0?this.perspectiveCamera:this.orthographicCamera:o>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const o=this._getTransitionDirection();return o===0?this._target===0?this.perspectiveCamera:this.orthographicCamera:o>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:o,orthographicCamera:a,transitionCamera:t,fixedPoint:p}=this,r=this._alpha;e.set(0,0,-1).transformDirection(a.matrixWorld).normalize(),d.copy(a),d.position.addScaledVector(e,a.near),a.far-=a.near,a.near=0,e.set(0,0,-1).transformDirection(o.matrixWorld).normalize();const m=Math.abs(s.subVectors(o.position,p).dot(e)),c=2*Math.tan(h.DEG2RAD*o.fov*.5)*m,i=h.lerp(o.fov,1,r),l=c*.5/Math.tan(h.DEG2RAD*i*.5),n=P.lerpVectors(o.position,d.position,r);n.addScaledVector(e,Math.abs(s.subVectors(n,p).dot(e))-l);const C=s.subVectors(o.position,n).dot(e),f=s.subVectors(d.position,n).dot(e),_=h.lerp(C+o.near,f+d.near,r),u=h.lerp(C+o.far,f+d.far,r),y=Math.max(u,0)-Math.max(_,0);t.aspect=o.aspect,t.fov=i,t.near=Math.max(_,y*1e-5),t.far=u,t.position.copy(n),t.rotation.copy(o.rotation),t.updateProjectionMatrix(),t.updateMatrixWorld()}}export{T as C}; diff --git a/example/bundle/assets/CesiumIonAuthPlugin-DCN_lM0S.js b/example/bundle/assets/CesiumIonAuthPlugin-DCN_lM0S.js new file mode 100644 index 00000000..c73775f2 --- /dev/null +++ b/example/bundle/assets/CesiumIonAuthPlugin-DCN_lM0S.js @@ -0,0 +1 @@ +import{G as o}from"./GoogleCloudAuthPlugin-B9LFbpXw.js";class l{constructor({apiToken:e,assetId:i=null,autoRefreshToken:t=!1}){this.name="CESIUM_ION_AUTH_PLUGIN",this.apiToken=e,this.assetId=i,this.autoRefreshToken=t,this.tiles=null,this.endpointURL=null,this._bearerToken=null,this._tileSetVersion=-1,this._tokenRefreshPromise=null,this._attributions=[]}init(e){this.assetId!==null&&(e.rootURL=`https://api.cesium.com/v1/assets/${this.assetId}/endpoint`),this.tiles=e,this.endpointURL=e.rootURL,e.resetFailedTiles()}loadRootTileSet(){return this._refreshToken().then(()=>this.tiles.loadRootTileSet())}preprocessURL(e){return e=new URL(e),/^http/.test(e.protocol)&&this._tileSetVersion!=-1&&e.searchParams.append("v",this._tileSetVersion),e.toString()}fetchData(e,i){return this.tiles.getPluginByName("GOOGLE_CLOUD_AUTH_PLUGIN")!==null?null:Promise.resolve().then(async()=>{this._tokenRefreshPromise!==null&&(await this._tokenRefreshPromise,e=this.preprocessURL(e));const s=await fetch(e,i);return s.status>=400&&s.status<=499&&this.autoRefreshToken?(await this._refreshToken(i),fetch(this.preprocessURL(e),i)):s})}getAttributions(e){this.tiles.visibleTiles.size>0&&e.push(...this._attributions)}_refreshToken(e){if(this._tokenRefreshPromise===null){const i=new URL(this.endpointURL);i.searchParams.append("access_token",this.apiToken),this._tokenRefreshPromise=fetch(i,e).then(t=>{if(!t.ok)throw new Error(`CesiumIonAuthPlugin: Failed to load data with error code ${t.status}`);return t.json()}).then(t=>{const s=this.tiles;if("externalType"in t){const r=new URL(t.options.url);s.rootURL=t.options.url,s.registerPlugin(new o({apiToken:r.searchParams.get("key")}))}else{if(s.rootURL=t.url,s.fetchOptions.headers=s.fetchOptions.headers||{},s.fetchOptions.headers.Authorization=`Bearer ${t.accessToken}`,i.searchParams.has("v")&&this._tileSetVersion===-1){const r=new URL(t.url);this._tileSetVersion=r.searchParams.get("v")}this._bearerToken=t.accessToken,t.attributions&&(this._attributions=t.attributions.map(r=>({value:r.html,type:"html",collapsible:r.collapsible})))}return this._tokenRefreshPromise=null,t})}return this._tokenRefreshPromise}}export{l as C}; diff --git a/example/bundle/assets/DRACOLoader-DJWREZh5.js b/example/bundle/assets/DRACOLoader-DJWREZh5.js new file mode 100644 index 00000000..0778228b --- /dev/null +++ b/example/bundle/assets/DRACOLoader-DJWREZh5.js @@ -0,0 +1,2 @@ +import{t as C,F as L,a2 as _,a3 as P,ah as D,ai as T,C as R,aH as I}from"./three.module-DpclfMcJ.js";const w=new WeakMap;class x extends C{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,o,s,r){const n=new L(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,t=>{this.parse(t,o,r)},s,r)}parse(e,o,s=()=>{}){this.decodeDracoFile(e,o,null,null,_,s).catch(s)}decodeDracoFile(e,o,s,r,n=P,t=()=>{}){const i={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,i).then(o).catch(t)}decodeGeometry(e,o){const s=JSON.stringify(o);if(w.has(e)){const a=w.get(e);if(a.key===s)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const n=this.workerNextTaskID++,t=e.byteLength,i=this._getWorker(n,t).then(a=>(r=a,new Promise((h,d)=>{r._callbacks[n]={resolve:h,reject:d},r.postMessage({type:"decode",id:n,taskConfig:o,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return i.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),w.set(e,{key:s,promise:i}),i}_createGeometry(e){const o=new D;e.index&&o.setIndex(new T(e.index.array,1));for(let s=0;s{s.load(e,r,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",o=[];return e?o.push(this._loadLibrary("draco_decoder.js","text")):(o.push(this._loadLibrary("draco_wasm_wrapper.js","text")),o.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(o).then(s=>{const r=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const n=S.toString(),t=["/* draco decoder */",r,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([t]))}),this.decoderPending}_getWorker(e,o){return this._initDecoder().then(()=>{if(this.workerPool.lengthn._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=o,s._taskLoad+=o,s})}_releaseTask(e,o){e._taskLoad-=e._taskCosts[o],delete e._callbacks[o],delete e._taskCosts[o]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const u=d.draco,c=new u.Decoder;try{const l=o(u,c,new Int8Array(a),h),f=l.attributes.map(y=>y.array.buffer);l.index&&f.push(l.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:l},f)}catch(l){console.error(l),self.postMessage({type:"error",id:i.id,error:l.message})}finally{u.destroy(c)}});break}};function o(t,i,a,h){const d=h.attributeIDs,u=h.attributeTypes;let c,l;const f=i.GetEncodedGeometryType(a);if(f===t.TRIANGULAR_MESH)c=new t.Mesh,l=i.DecodeArrayToMesh(a,a.byteLength,c);else if(f===t.POINT_CLOUD)c=new t.PointCloud,l=i.DecodeArrayToPointCloud(a,a.byteLength,c);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!l.ok()||c.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const y={index:null,attributes:[]};for(const p in d){const m=self[u[p]];let g,b;if(h.useUniqueIDs)b=d[p],g=i.GetAttributeByUniqueId(c,b);else{if(b=i.GetAttributeId(c,t[d[p]]),b===-1)continue;g=i.GetAttribute(c,b)}const A=r(t,i,c,p,m,g);p==="color"&&(A.vertexColorSpace=h.vertexColorSpace),y.attributes.push(A)}return f===t.TRIANGULAR_MESH&&(y.index=s(t,i,c)),t.destroy(c),y}function s(t,i,a){const d=a.num_faces()*3,u=d*4,c=t._malloc(u);i.GetTrianglesUInt32Array(a,u,c);const l=new Uint32Array(t.HEAPF32.buffer,c,d).slice();return t._free(c),{array:l,itemSize:1}}function r(t,i,a,h,d,u){const c=u.num_components(),f=a.num_points()*c,y=f*d.BYTES_PER_ELEMENT,p=n(t,d),m=t._malloc(y);i.GetAttributeDataArrayForAllPoints(a,u,p,y,m);const g=new d(t.HEAPF32.buffer,m,f).slice();return t._free(m),{name:h,array:g,itemSize:c}}function n(t,i){switch(i){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}}export{x as D}; diff --git a/example/bundle/assets/DebugTilesPlugin-CbfV2ROf.js b/example/bundle/assets/DebugTilesPlugin-CbfV2ROf.js new file mode 100644 index 00000000..594c77e5 --- /dev/null +++ b/example/bundle/assets/DebugTilesPlugin-CbfV2ROf.js @@ -0,0 +1 @@ +import{G as b,af as H,M as S,f as A,d as O,C as I}from"./three.module-DpclfMcJ.js";import{S as N,a as k}from"./EllipsoidRegionHelper-OhHLW9vN.js";const x=Symbol("ORIGINAL_MATERIAL"),M=Symbol("HAS_RANDOM_COLOR"),C=Symbol("HAS_RANDOM_NODE_COLOR"),E=Symbol("LOAD_TIME"),T=new O,G=()=>{},R={};function v(p){if(!R[p]){const r=Math.random(),e=.5+Math.random()*.5,t=.375+Math.random()*.25;R[p]=new I().setHSL(r,e,t)}return R[p]}const _=0,w=1,P=2,U=3,W=4,F=5,V=6,L=7,B=8,z=9,y=10;class J{constructor(r){r={displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:_,maxDebugDepth:-1,maxDebugDistance:-1,maxDebugError:-1,customColorCallback:null,...r},this.name="DEBUG_TILES_PLUGIN",this.tiles=null,this.extremeDebugDepth=-1,this.extremeDebugError=-1,this.boxGroup=null,this.sphereGroup=null,this.regionGroup=null,this.displayBoxBounds=r.displayBoxBounds,this.displaySphereBounds=r.displaySphereBounds,this.displayRegionBounds=r.displayRegionBounds,this.colorMode=r.colorMode,this.maxDebugDepth=r.maxDebugDepth,this.maxDebugDistance=r.maxDebugDistance,this.maxDebugError=r.maxDebugError,this.customColorCallback=r.customColorCallback,this.getDebugColor=(e,t)=>{t.setRGB(e,e,e)}}init(r){this.tiles=r;const e=r.group;this.boxGroup=new b,this.boxGroup.name="DebugTilesRenderer.boxGroup",e.add(this.boxGroup),this.boxGroup.updateMatrixWorld(),this.sphereGroup=new b,this.sphereGroup.name="DebugTilesRenderer.sphereGroup",e.add(this.sphereGroup),this.sphereGroup.updateMatrixWorld(),this.regionGroup=new b,this.regionGroup.name="DebugTilesRenderer.regionGroup",e.add(this.regionGroup),this.regionGroup.updateMatrixWorld(),this._onLoadTileSetCB=()=>{this._initExtremes()},this._onLoadModelCB=({scene:t,tile:a})=>{this._onLoadModel(t,a)},this._onDisposeModelCB=({tile:t})=>{this._onDisposeModel(t)},this._onUpdateAfterCB=()=>{this._onUpdateAfter()},this._onTileVisibilityChangeCB=({scene:t,tile:a,visible:h})=>{this._onTileVisibilityChange(a,h)},r.addEventListener("load-tile-set",this._onLoadTileSetCB),r.addEventListener("load-model",this._onLoadModelCB),r.addEventListener("dispose-model",this._onDisposeModelCB),r.addEventListener("update-after",this._onUpdateAfterCB),r.addEventListener("tile-visibility-change",this._onTileVisibilityChangeCB),r.traverse(t=>{t.cached.scene&&this._onLoadModel(t.cached.scene,t)}),r.visibleTiles.forEach(t=>{this._onTileVisibilityChange(t,!0)})}getTileInformationFromActiveObject(r){let e=null;return this.tiles.activeTiles.forEach(a=>{if(e)return!0;const h=a.cached.scene;h&&h.traverse(n=>{n===r&&(e=a)})}),e?{distanceToCamera:e.__distanceFromCamera,geometricError:e.geometricError,screenSpaceError:e.__error,depth:e.__depth,isLeaf:e.__isLeaf}:null}_initExtremes(){let r=-1;this.tiles.traverse(t=>{r=Math.max(r,t.__depth)});let e=-1;this.tiles.traverse(t=>{e=Math.max(e,t.geometricError)}),this.extremeDebugDepth=r,this.extremeDebugError=e}_onUpdateAfter(){const r=this.tiles;if(!r.root)return;this.boxGroup.visible=this.displayBoxBounds,this.sphereGroup.visible=this.displaySphereBounds,this.regionGroup.visible=this.displayRegionBounds;let e=-1;this.maxDebugDepth===-1?e=this.extremeDebugDepth:e=this.maxDebugDepth;let t=-1;this.maxDebugError===-1?t=this.extremeDebugError:t=this.maxDebugError;let a=-1;this.maxDebugDistance===-1?(r.getBoundingSphere(T),a=T.radius):a=this.maxDebugDistance;const h=this.errorTarget,n=this.colorMode,d=r.visibleTiles;let o;n===y&&(o=Array.from(d).sort((s,D)=>s[E]-D[E])),d.forEach(s=>{const D=s.cached.scene;let u,c,m;n===L&&(u=Math.random(),c=.5+Math.random()*.5,m=.375+Math.random()*.25),D.traverse(i=>{n===B&&(u=Math.random(),c=.5+Math.random()*.5,m=.375+Math.random()*.25);const f=i.material;if(f){const g=i[x];if(n===_&&f!==g)i.material.dispose(),i.material=i[x];else if(n!==_&&f===g)if(i.isPoints){const l=new H;l.size=g.size,l.sizeAttenuation=g.sizeAttenuation,i.material=l}else i.material=new S,i.material.flatShading=!0;switch(n!==L&&delete i.material[M],n!==B&&delete i.material[C],n){case W:{const l=s.__depth/e;this.getDebugColor(l,i.material.color);break}case F:{const l=s.__depthFromRenderedParent/e;this.getDebugColor(l,i.material.color);break}case w:{const l=s.__error/h;l>1?i.material.color.setRGB(1,0,0):this.getDebugColor(l,i.material.color);break}case P:{const l=Math.min(s.geometricError/t,1);this.getDebugColor(l,i.material.color);break}case U:{const l=Math.min(s.__distanceFromCamera/a,1);this.getDebugColor(l,i.material.color);break}case V:{!s.children||s.children.length===0?this.getDebugColor(1,i.material.color):this.getDebugColor(0,i.material.color);break}case B:{i.material[C]||(i.material.color.setHSL(u,c,m),i.material[C]=!0);break}case L:{i.material[M]||(i.material.color.setHSL(u,c,m),i.material[M]=!0);break}case z:{this.customColorCallback?this.customColorCallback(s,i):console.warn("DebugTilesRenderer: customColorCallback not defined");break}case y:{const l=o.indexOf(s);this.getDebugColor(l/(o.length-1),i.material.color);break}}}})})}_onTileVisibilityChange(r,e){const t=r.cached,a=this.sphereGroup,h=this.boxGroup,n=this.regionGroup,d=t.boxHelperGroup,o=t.sphereHelper,s=t.regionHelper;e?(d&&(h.add(d),d.updateMatrixWorld(!0)),o&&(a.add(o),o.updateMatrixWorld(!0)),s&&(n.add(s),s.updateMatrixWorld(!0))):(d&&h.remove(d),o&&a.remove(o),s&&n.remove(s))}_onLoadModel(r,e){e[E]=performance.now();const t=this.tiles,a=e.cached,{sphere:h,obb:n,region:d}=a.boundingVolume;if(n){const o=new b;o.name="DebugTilesRenderer.boxHelperGroup",o.matrix.copy(n.transform),o.matrixAutoUpdate=!1;const s=new A(n.box,v(e.__depth));s.raycast=G,o.add(s),a.boxHelperGroup=o,t.visibleTiles.has(e)&&this.displayBoxBounds&&(this.boxGroup.add(o),o.updateMatrixWorld(!0))}if(h){const o=new N(h,v(e.__depth));o.raycast=G,a.sphereHelper=o,t.visibleTiles.has(e)&&this.displaySphereBounds&&(this.sphereGroup.add(o),o.updateMatrixWorld(!0))}if(d){const o=new k(d,v(e.__depth));o.raycast=G;const s=new O;d.getBoundingSphere(s),o.position.copy(s.center),s.center.multiplyScalar(-1),o.geometry.translate(...s.center),a.regionHelper=o,t.visibleTiles.has(e)&&this.displayRegionBounds&&(this.regionGroup.add(o),o.updateMatrixWorld(!0))}r.traverse(o=>{const s=o.material;s&&(o[x]=s)})}_onDisposeModel(r){const e=r.cached;e.boxHelperGroup&&(e.boxHelperGroup.children[0].geometry.dispose(),delete e.boxHelperGroup),e.sphereHelper&&(e.sphereHelper.geometry.dispose(),delete e.sphereHelper),e.regionHelper&&(e.regionHelper.geometry.dispose(),delete e.regionHelper)}dispose(){const r=this.tiles;r.removeEventListener("load-tile-set",this._onLoadTileSetCB),r.removeEventListener("load-model",this._onLoadModelCB),r.removeEventListener("dispose-model",this._onDisposeModelCB),r.removeEventListener("update-after",this._onUpdateAfterCB),this.colorMode=_,this._onUpdateAfter(),r.traverse(e=>{this._onDisposeModel(e)}),this.boxGroup.removeFromParent(),this.sphereGroup.removeFromParent(),this.regionGroup.removeFromParent()}}export{z as C,U as D,P as G,V as I,y as L,_ as N,F as R,w as S,W as a,L as b,B as c,J as d}; diff --git a/example/bundle/assets/Ellipsoid-Cnb0UTwk.js b/example/bundle/assets/Ellipsoid-Cnb0UTwk.js new file mode 100644 index 00000000..9bd21be3 --- /dev/null +++ b/example/bundle/assets/Ellipsoid-Cnb0UTwk.js @@ -0,0 +1 @@ +import{k as l,i as R,as as W,j,d as K,an as Q,bb as tt}from"./three.module-DpclfMcJ.js";const d=new W,U=new l,et={};function it(r){const{x:t,y:e,z:i}=r;r.x=i,r.y=t,r.z=e}function ot(r){return-(r-Math.PI/2)}function B(r){return-r+Math.PI/2}function st(r,t,e={}){return d.theta=t,d.phi=B(r),U.setFromSpherical(d),d.setFromVector3(U),e.lat=ot(d.phi),e.lon=d.theta,e}function b(r,t="E",e="W"){const i=r<0?e:t;r=Math.abs(r);const o=~~r,s=(r-o)*60,n=~~s,y=~~((s-n)*60);return`${o}° ${n}' ${y}" ${i}`}function lt(r,t,e=!1){const i=st(r,t,et);let o,s;return e?(o=`${(R.RAD2DEG*i.lat).toFixed(4)}°`,s=`${(R.RAD2DEG*i.lon).toFixed(4)}°`):(o=b(R.RAD2DEG*i.lat,"N","S"),s=b(R.RAD2DEG*i.lon,"E","W")),`${o} ${s}`}const X=new W,m=new l,c=new l,w=new l,nt=new l,p=new j,u=new j,A=new K,a=new tt,Y=new l,Z=new l,T=new l,D=new l,G=new Q,rt=1e-12,at=.1,V=0,L=1,O=2;class ut{constructor(t=1,e=1,i=1){this.radius=new l(t,e,i)}intersectRay(t,e){return p.makeScale(...this.radius).invert(),A.center.set(0,0,0),A.radius=1,G.copy(t).applyMatrix4(p),G.intersectSphere(A,e)?(p.makeScale(...this.radius),e.applyMatrix4(p),e):null}getEastNorthUpFrame(t,e,i){return this.getEastNorthUpAxes(t,e,Y,Z,T,D),i.makeBasis(Y,Z,T).setPosition(D)}getEastNorthUpAxes(t,e,i,o,s,n=D){this.getCartographicToPosition(t,e,0,n),this.getCartographicToNormal(t,e,s),i.set(-n.y,n.x,0).normalize(),o.crossVectors(s,i).normalize()}getNorthernTangent(t,e,i,o=nt){return console.log("Ellipsoid: getNorthernTangent has been deprecated. Use getEastNorthUpAxes instead."),this.getEastNorthUpAxes(t,e,o,i,T),o.multiplyScalar(-1),i}getAzElRollFromRotationMatrix(t,e,i,o,s=V){return s===L?(a.set(-Math.PI/2,0,0,"XYZ"),u.makeRotationFromEuler(a).premultiply(i)):s===O?(a.set(-Math.PI/2,0,Math.PI,"XYZ"),u.makeRotationFromEuler(a).premultiply(i)):u.copy(i),this.getEastNorthUpFrame(t,e,p).invert(),u.premultiply(p),a.setFromRotationMatrix(u,"ZXY"),o.azimuth=-a.z,o.elevation=a.x,o.roll=a.y,o}getRotationMatrixFromAzElRoll(t,e,i,o,s,n,h=V){return this.getEastNorthUpFrame(t,e,p),a.set(o,s,-i,"ZXY"),n.makeRotationFromEuler(a).premultiply(p).setPosition(0,0,0),h===L?(a.set(Math.PI/2,0,0,"XYZ"),u.makeRotationFromEuler(a),n.multiply(u)):h===O&&(a.set(-Math.PI/2,0,Math.PI,"XYZ"),u.makeRotationFromEuler(a),n.multiply(u)),n}getCartographicToPosition(t,e,i,o){this.getCartographicToNormal(t,e,m);const s=this.radius;c.copy(m),c.x*=s.x**2,c.y*=s.y**2,c.z*=s.z**2;const n=Math.sqrt(m.dot(c));return c.divideScalar(n),o.copy(c).addScaledVector(m,i)}getPositionToCartographic(t,e){this.getPositionToSurfacePoint(t,c),this.getPositionToNormal(t,m);const i=w.subVectors(t,c);return e.lon=Math.atan2(m.y,m.x),e.lat=Math.asin(m.z),e.height=Math.sign(i.dot(t))*i.length(),e}getCartographicToNormal(t,e,i){return X.set(1,B(t),e),i.setFromSpherical(X).normalize(),it(i),i}getPositionToNormal(t,e){const i=this.radius;return e.copy(t),e.x/=i.x**2,e.y/=i.y**2,e.z/=i.z**2,e.normalize(),e}getPositionToSurfacePoint(t,e){const i=this.radius,o=1/i.x**2,s=1/i.y**2,n=1/i.z**2,h=t.x*t.x*o,y=t.y*t.y*s,z=t.z*t.z*n,v=h+y+z,f=Math.sqrt(1/v),S=c.copy(t).multiplyScalar(f);if(vrt);return e.set(t.x*M,t.y*E,t.z*x)}calculateHorizonDistance(t,e){const i=this.calculateEffectiveRadius(t);return Math.sqrt(2*i*e+e**2)}calculateEffectiveRadius(t){const e=this.radius.x,o=1-this.radius.z**2/e**2,s=t*R.DEG2RAD,n=Math.sin(s)**2;return e/Math.sqrt(1-o*n)}getPositionElevation(t){this.getPositionToSurfacePoint(t,c);const e=w.subVectors(t,c);return Math.sign(e.dot(t))*e.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return new this.constructor().copy(this)}}export{L as C,ut as E,O,lt as t}; diff --git a/example/bundle/assets/EllipsoidRegion-D6hT1syi.js b/example/bundle/assets/EllipsoidRegion-D6hT1syi.js new file mode 100644 index 00000000..d90474e0 --- /dev/null +++ b/example/bundle/assets/EllipsoidRegion-D6hT1syi.js @@ -0,0 +1 @@ +import{k as f,j as R,i as p}from"./three.module-DpclfMcJ.js";import{E as C}from"./Ellipsoid-Cnb0UTwk.js";const l=Math.PI,u=l/2,m=new f,c=new f,h=new f,y=new R;let d=0;const w=[];function T(M=!1){return M?(w[d]||(w[d]=new f),d++,w[d-1]):new f}function I(){d=0}class A extends C{constructor(i,t,o,n=-u,e=u,g=0,E=2*l,a=0,s=0){super(i,t,o),this.latStart=n,this.latEnd=e,this.lonStart=g,this.lonEnd=E,this.heightStart=a,this.heightEnd=s}_getPoints(i=!1){const{latStart:t,latEnd:o,lonStart:n,lonEnd:e,heightStart:g,heightEnd:E}=this,a=p.mapLinear(.5,0,1,t,o),s=p.mapLinear(.5,0,1,n,e),r=Math.floor(n/u)*u,k=[[-l/2,0],[l/2,0],[0,r],[0,r+l/2],[0,r+l],[0,r+3*l/2],[t,e],[o,e],[t,n],[o,n],[0,n],[0,e],[a,s],[t,s],[o,s],[a,n],[a,e]],B=[],V=k.length;for(let P=0;P<=1;P++){const v=p.mapLinear(P,0,1,g,E);for(let L=0,F=V;L=t&&_<=o&&S>=n&&S<=e){const x=T(i);B.push(x),this.getCartographicToPosition(_,S,v,x)}}}return B}getBoundingBox(i,t){I();const{latStart:o,latEnd:n,lonStart:e,lonEnd:g}=this;if(n-o.1&&(l.z>0&&w.multiplyScalar(-1),f.setXYZ(r,...w))}return u}class T extends S{constructor(t=new I,e=16776960){super(),this.ellipsoidRegion=t,this.material.color.set(e),this.update()}update(){const t=L(this.ellipsoidRegion);this.geometry.dispose(),this.geometry=new z(t,80)}dispose(){this.geometry.dispose(),this.material.dispose()}}class k extends N{constructor(t=new I,e=16776960){super(),this.ellipsoidRegion=t,this.material.color.set(e),this.update()}update(){this.geometry.dispose();const t=L(this.ellipsoidRegion),{lonStart:e,lonEnd:a}=this;a-e>=2*Math.PI?(t.groups.splice(2,2),this.geometry=H(t)):this.geometry=t}dispose(){this.geometry.dispose(),this.material.dispose()}}export{k as E,F as S,T as a}; diff --git a/example/bundle/assets/EnvironmentControls-C8X7oAWq.js b/example/bundle/assets/EnvironmentControls-C8X7oAWq.js new file mode 100644 index 00000000..6c22b1c9 --- /dev/null +++ b/example/bundle/assets/EnvironmentControls-C8X7oAWq.js @@ -0,0 +1,45 @@ +import{g as at,a$ as ct,b as ht,V as S,j as ot,an as lt,k as P,ao as nt,aD as pt,R as dt,s as ut,Q as rt,i as mt}from"./three.module-DpclfMcJ.js";class ft extends at{constructor(){super(new ct(0,0),new Pt),this.renderOrder=1/0}onBeforeRender(t){const e=this.material.uniforms;t.getSize(e.resolution.value)}updateMatrixWorld(){this.matrixWorld.makeTranslation(this.position)}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pt extends ht{constructor(){super({depthWrite:!1,depthTest:!1,transparent:!0,uniforms:{resolution:{value:new S},size:{value:15},thickness:{value:2},opacity:{value:1}},vertexShader:` + + uniform float pixelRatio; + uniform float size; + uniform float thickness; + uniform vec2 resolution; + varying vec2 vUv; + + void main() { + + vUv = uv; + + float aspect = resolution.x / resolution.y; + vec2 offset = uv * 2.0 - vec2( 1.0 ); + offset.y *= aspect; + + vec4 screenPoint = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + screenPoint.xy += offset * ( size + thickness ) * screenPoint.w / resolution.x; + + gl_Position = screenPoint; + + } + `,fragmentShader:` + + uniform float size; + uniform float thickness; + uniform float opacity; + + varying vec2 vUv; + void main() { + + float ht = 0.5 * thickness; + float planeDim = size + thickness; + float offset = ( planeDim - ht - 2.0 ) / planeDim; + float texelThickness = ht / planeDim; + + vec2 vec = vUv * 2.0 - vec2( 1.0 ); + float dist = abs( length( vec ) - offset ); + float fw = fwidth( dist ) * 0.5; + float a = smoothstep( texelThickness - fw, texelThickness + fw, dist ); + + gl_FragColor = vec4( 1, 1, 1, opacity * ( 1.0 - a ) ); + + } + `})}}const Q=new S,Y=new S;class vt{constructor(){this.domElement=null,this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new S,this.hoverSet=!1}reset(){this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new S,this.hoverSet=!1}updateFrame(){const{previousPositions:t,pointerPositions:e}=this;for(const i in e)t[i].copy(e[i])}setHoverEvent(t){(t.pointerType==="mouse"||t.type==="wheel")&&(this.getAdjustedPointer(t,this.hoverPosition),this.hoverSet=!0)}getLatestPoint(t){return this.pointerType!==null?(this.getCenterPoint(t),t):this.hoverSet?(t.copy(this.hoverPosition),t):null}getAdjustedPointer(t,e){const s=(this.domElement?this.domElement:t.target).getBoundingClientRect(),n=t.clientX-s.left,a=t.clientY-s.top;e.set(n,a)}addPointer(t){const e=t.pointerId,i=new S;this.getAdjustedPointer(t,i),this.pointerOrder.push(e),this.pointerPositions[e]=i,this.previousPositions[e]=i.clone(),this.startPositions[e]=i.clone(),this.getPointerCount()===1&&(this.pointerType=t.pointerType,this.buttons=t.buttons)}updatePointer(t){const e=t.pointerId;return e in this.pointerPositions?(this.getAdjustedPointer(t,this.pointerPositions[e]),!0):!1}deletePointer(t){const e=t.pointerId,i=this.pointerOrder;i.splice(i.indexOf(e),1),delete this.pointerPositions[e],delete this.previousPositions[e],delete this.startPositions[e],this.getPointerCount.length===0&&(this.buttons=0,this.pointerType=null)}getPointerCount(){return this.pointerOrder.length}getCenterPoint(t,e=this.pointerPositions){const i=this.pointerOrder;if(this.getPointerCount()===1||this.getPointerType()==="mouse"){const s=i[0];return t.copy(e[s]),t}else if(this.getPointerCount()===2){const s=this.pointerOrder[0],n=this.pointerOrder[1],a=e[s],d=e[n];return t.addVectors(a,d).multiplyScalar(.5),t}return null}getPreviousCenterPoint(t){return this.getCenterPoint(t,this.previousPositions)}getStartCenterPoint(t){return this.getCenterPoint(t,this.startPositions)}getMoveDistance(){return this.getCenterPoint(Q),this.getPreviousCenterPoint(Y),Q.sub(Y).length()}getTouchPointerDistance(t=this.pointerPositions){if(this.getPointerCount()<=1||this.getPointerType()==="mouse")return 0;const{pointerOrder:e}=this,i=e[0],s=e[1],n=t[i],a=t[s];return n.distanceTo(a)}getPreviousTouchPointerDistance(){return this.getTouchPointerDistance(this.previousPositions)}getStartTouchPointerDistance(){return this.getTouchPointerDistance(this.startPositions)}getPointerType(){return this.pointerType}isPointerTouch(){return this.getPointerType()==="touch"}getPointerButtons(){return this.buttons}isLeftClicked(){return!!(this.buttons&1)}isRightClicked(){return!!(this.buttons&2)}}const x=new ot,$=new lt,q=new P;function A(p,t,e){return e.makeTranslation(-p.x,-p.y,-p.z),x.makeRotationFromQuaternion(t),e.premultiply(x),x.makeTranslation(p.x,p.y,p.z),e.premultiply(x),e}function R(p,t,e,i){i.x=(p-e.offsetLeft)/e.clientWidth*2-1,i.y=-((t-e.offsetTop)/e.clientHeight)*2+1,i.isVector3&&(i.z=0)}function Dt(p,t,e){return t.intersectRay(p,e)?e:(x.makeScale(...t.radius).invert(),$.copy(p).applyMatrix4(x),q.set(0,0,0),$.closestPointToPoint(q,e).normalize(),x.makeScale(...t.radius),e.applyMatrix4(x))}function Mt(p,t,e){const i=p.origin.length(),s=Math.acos(t/i);e.copy(p.origin).multiplyScalar(-1).normalize();const n=q.crossVectors(e,p.direction).normalize();e.multiplyScalar(-1).applyAxisAngle(n,-s).normalize().multiplyScalar(t)}function W(p,t,e){const{origin:i,direction:s}=p.ray;i.set(t.x,t.y,-1).unproject(e),s.set(t.x,t.y,1).unproject(e).sub(i),p.near=0,p.far=s.length(),p.camera=e,s.normalize()}const _=0,E=1,b=2,I=3,V=4,F=.05,Z=.025,gt=1e-4,yt=.01,D=new ot,U=new P,y=new P,j=new P,X=new P,z=new P,M=new rt,J=new nt,f=new P,H=new P,B=new P,St=new rt,L=new S,u=new S,K=new S,T=new S,N=new S,tt=new S,et={type:"change"},it={type:"start"},st={type:"end"};class xt extends pt{get enabled(){return this._enabled}set enabled(t){t!==this.enabled&&(this._enabled=t,this.resetState(),this.pointerTracker.reset(),this.enabled||(this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0)))}constructor(t=null,e=null,i=null,s=null){super(),this.isEnvironmentControls=!0,this.domElement=null,this.camera=null,this.scene=null,this.tilesRenderer=null,this._enabled=!0,this.cameraRadius=5,this.rotationSpeed=1,this.minAltitude=0,this.maxAltitude=.45*Math.PI,this.minDistance=10,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.zoomSpeed=1,this.adjustHeight=!0,this.enableDamping=!1,this.dampingFactor=.15,this.reorientOnDrag=!0,this.scaleZoomOrientationAtEdges=!1,this.state=_,this.pointerTracker=new vt,this.needsUpdate=!1,this.actionHeightOffset=0,this.pivotPoint=new P,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.zoomDirection=new P,this.zoomPoint=new P,this.zoomDelta=0,this.rotationInertia=new S,this.dragInertia=new P,this.pivotMesh=new ft,this.pivotMesh.raycast=()=>{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new dt,this.raycaster.firstHitOnly=!0,this.up=new P(0,1,0),this.clock=new ut,this.fallbackPlane=new nt(new P(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=_,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,i&&this.attach(i),e&&this.setCamera(e),t&&this.setScene(t),s&&this.setTilesRenderer(s)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=t,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,this.tilesRenderer!==null&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.scene===null&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const i=o=>{o.preventDefault()},s=o=>{o.key==="Shift"&&(e=!0)},n=o=>{o.key==="Shift"&&(e=!1)},a=o=>{o.preventDefault();const{camera:c,raycaster:l,domElement:C,up:k,pivotMesh:w,pointerTracker:g}=this;if(g.addPointer(o),this.needsUpdate=!0,g.isPointerTouch()){if(w.visible=!1,g.getPointerCount()===0)C.setPointerCapture(o.pointerId);else if(g.getPointerCount()>2){this.resetState();return}}g.getCenterPoint(u),R(u.x,u.y,C,u),W(l,u,c);const G=Math.abs(l.ray.direction.dot(k));if(G{o.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.state!==_&&(this.needsUpdate=!0);const{pointerTracker:c}=this;c.setHoverEvent(o),c.updatePointer(o)&&(c.isPointerTouch()&&c.getPointerCount()===2&&(d||(d=!0,queueMicrotask(()=>{d=!1,c.getCenterPoint(N);const l=c.getStartTouchPointerDistance(),C=c.getTouchPointerDistance(),k=C-l;if(this.state===_||this.state===V){c.getCenterPoint(N),c.getStartCenterPoint(tt);const w=2*window.devicePixelRatio,g=N.distanceTo(tt);(Math.abs(k)>w||g>w)&&(Math.abs(k)>g?(this.setState(I),this.zoomDirectionSet=!1):this.setState(b))}if(this.state===I){const w=c.getPreviousTouchPointerDistance();this.zoomDelta+=C-w}else this.state===b&&(this.pivotMesh.visible=this.enabled)}))),this.dispatchEvent(et))},h=o=>{const{pointerTracker:c}=this;c.deletePointer(o),c.getPointerType()==="touch"&&c.getPointerCount()===0&&t.releasePointerCapture(o.pointerId),this.resetState(),this.needsUpdate=!0},v=o=>{o.preventDefault();const{pointerTracker:c}=this;c.setHoverEvent(o),c.updatePointer(o),this.dispatchEvent(it);let l;switch(o.deltaMode){case 2:l=o.deltaY*100;break;case 1:l=o.deltaY*16;break;case 0:l=o.deltaY;break}const C=Math.sign(l),k=Math.log(Math.abs(l)+1);this.zoomDelta-=3*C*k,this.needsUpdate=!0,this._lastUsedState=I,this.dispatchEvent(st)},r=o=>{const{pointerTracker:c}=this;e=!1,o.buttons!==c.getPointerButtons()&&(c.deletePointer(o),this.resetState())};t.addEventListener("contextmenu",i),t.addEventListener("keydown",s),t.addEventListener("keyup",n),t.addEventListener("pointerdown",a),t.addEventListener("pointermove",m),t.addEventListener("pointerup",h),t.addEventListener("wheel",v,{passive:!1}),t.addEventListener("pointerenter",r),this._detachCallback=()=>{t.removeEventListener("contextmenu",i),t.removeEventListener("keydown",s),t.removeEventListener("keyup",n),t.removeEventListener("pointerdown",a),t.removeEventListener("pointermove",m),t.removeEventListener("pointerup",h),t.removeEventListener("wheel",v),t.removeEventListener("pointerenter",r)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){return this._lastUsedState===I?this._zoomPointWasSet?(t.copy(this.zoomPoint),t):null:this._lastUsedState===b||this._lastUsedState===E?(t.copy(this.pivotPoint),t):null}detach(){this.domElement=null,this._detachCallback&&(this._detachCallback(),this._detachCallback=null,this.pointerTracker.reset())}resetState(){this.state!==_&&this.dispatchEvent(st),this.state=_,this.pivotMesh.removeFromParent(),this.pivotMesh.visible=this.enabled,this.actionHeightOffset=0}setState(t=this.state,e=!0){this.state!==t&&(this.state===_&&e&&this.dispatchEvent(it),this.pivotMesh.visible=this.enabled,this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0),this.state=t,t!==_&&t!==V&&(this._lastUsedState=t))}update(t=Math.min(this.clock.getDelta(),64/1e3)){if(!this.enabled||!this.camera||t===0)return;const{camera:e,cameraRadius:i,pivotPoint:s,up:n,state:a,adjustHeight:d}=this;e.updateMatrixWorld(),this.getCameraUpDirection(f),this._upInitialized||(this._upInitialized=!0,this.up.copy(f));const m=this._inertiaNeedsUpdate();if(this.needsUpdate||m){const r=this.zoomDelta;(a===I||r!==0)&&(this._updateZoom(),this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0)),this._updatePosition(t),this._updateRotation(t),(a!==_||r!==0||m)&&this.dispatchEvent(et),this.needsUpdate=!1}m&&this._updateInertiaDamping(t);const h=e.isOrthographicCamera?null:d&&this._getPointBelowCamera()||null,v=e.isOrthographicCamera?s:h&&h.point||null;if(this.getCameraUpDirection(f),this._setFrame(f,v),(this.state===E||this.state===b)&&this.actionHeightOffset!==0){const{actionHeightOffset:r}=this;e.position.addScaledVector(n,-r),s.addScaledVector(n,-r),h&&(h.distance-=r)}if(this.actionHeightOffset=0,h){const r=h.distance;if(r0?1/Math.abs(c):c;l*=v,l>1?hi.zoom*l&&(l=1),i.zoom*=l,i.updateProjectionMatrix(),o&&(R(u.x,u.y,d,B),B.unproject(i),i.position.sub(B).add(H),i.updateMatrixWorld())}else{this._updateZoomDirection();const o=y.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const c=t.distanceTo(i.position);if(r<0){const l=Math.min(0,c-n);r=r*c*v*.0025,r=Math.max(r,l)}else{const l=Math.max(0,c-s);r=r*Math.max(c-s,0)*v*.0025,r=Math.min(r,l)}i.position.addScaledVector(e,r),i.updateMatrixWorld()}else{const c=this._getPointBelowCamera();if(c){const l=c.distance;o.set(0,0,-1).transformDirection(i.matrixWorld),i.position.addScaledVector(o,r*l*.01),i.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:i,zoomDirection:s,pointerTracker:n}=this;n.getLatestPoint(u),R(u.x,u.y,t,H),W(e,H,i),s.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:i,raycaster:s,zoomPoint:n,pointerTracker:a,domElement:d}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&a.getLatestPoint(L)?(R(L.x,L.y,d,L),W(s,L,t)):(s.ray.origin.copy(t.position),s.ray.direction.copy(i),s.near=0,s.far=1/0);const m=this._raycast(s);return m?(n.copy(m.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0):!1}_getPointBelowCamera(t=this.camera.position,e=this.up){const{raycaster:i}=this;i.ray.direction.copy(e).multiplyScalar(-1),i.ray.origin.copy(t).addScaledVector(e,1e5),i.near=0,i.far=1/0;const s=this._raycast(i);return s&&(s.distance-=1e5),s}_updatePosition(t){const{raycaster:e,camera:i,pivotPoint:s,up:n,pointerTracker:a,domElement:d,state:m,dragInertia:h,enableDamping:v}=this;if(m===E){if(a.getCenterPoint(u),R(u.x,u.y,d,u),J.setFromNormalAndCoplanarPoint(n,s),W(e,u,i),Math.abs(e.ray.direction.dot(n))0?(h=Math.min(r-n-.01,h),h=Math.max(0,h)):(h=Math.max(r-a,h),h=Math.min(0,h)),M.setFromAxisAngle(f,m),A(i,M,D),s.matrixWorld.premultiply(D),z.set(-1,0,0).transformDirection(s.matrixWorld),M.setFromAxisAngle(z,h),A(i,M,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y)}_setFrame(t,e){const{up:i,camera:s,state:n,zoomPoint:a,zoomDirectionSet:d,zoomPointSet:m,reorientOnDrag:h,scaleZoomOrientationAtEdges:v}=this;s.updateMatrixWorld(),M.setFromUnitVectors(i,t);const r=n;if(d&&(m||this._updateZoomPoint())){if(this.getUpDirection(a,y),v){let o=Math.max(y.dot(i)-.6,0)/.4;o=mt.mapLinear(o,0,.5,0,1),o=Math.min(o,1),s.isOrthographicCamera&&(o*=.1),M.slerp(St,1-o)}A(a,M,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y),this.zoomDirectionSet=!1,this._updateZoomDirection()}else r===E&&h&&e&&(A(e,M,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y));i.copy(t),s.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:i,fallbackPlane:s}=this,n=t.intersectObject(e)[0]||null;if(n)return n;if(i){const a=s;if(t.ray.intersectPlane(a,y))return{point:y.clone(),distance:t.ray.origin.distanceTo(y)}}return null}}export{E as D,xt as E,_ as N,R as a,Mt as b,Dt as c,A as m,W as s}; diff --git a/example/bundle/assets/GLTFExtensionLoader-TubLlshp.js b/example/bundle/assets/GLTFExtensionLoader-TubLlshp.js new file mode 100644 index 00000000..cc4e483d --- /dev/null +++ b/example/bundle/assets/GLTFExtensionLoader-TubLlshp.js @@ -0,0 +1 @@ +import{bc as l}from"./three.module-DpclfMcJ.js";import{G as d}from"./GLTFLoader-DkJa3Jo5.js";import{L as p}from"./LoaderBase-CVSPpjX2.js";let u=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){const{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}};class h extends u{constructor(...e){super(...e),console.warn('GLTFCesiumRTCExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}class T extends p{constructor(e=l){super(),this.manager=e}parse(e){return new Promise((t,a)=>{const o=this.manager,n=this.fetchOptions;let s=o.getHandler("path.gltf")||o.getHandler("path.glb");s||(s=new d(o),s.register(()=>new h)),n.credentials==="include"&&n.mode==="cors"&&s.setCrossOrigin("use-credentials"),"credentials"in n&&s.setWithCredentials(n.credentials==="include"),n.headers&&s.setRequestHeader(n.headers);let r=s.resourcePath||s.path||this.workingPath;!/[\\/]$/.test(r)&&r.length&&(r+="/"),s.parse(e,r,c=>{t(c)},a)})}}export{T as G,u as a}; diff --git a/example/bundle/assets/GLTFLoader-DkJa3Jo5.js b/example/bundle/assets/GLTFLoader-DkJa3Jo5.js new file mode 100644 index 00000000..a1b98187 --- /dev/null +++ b/example/bundle/assets/GLTFLoader-DkJa3Jo5.js @@ -0,0 +1 @@ +import{be as Re,bf as W,bg as ue,t as xe,bh as G,F as le,C,a3 as y,bi as _e,bj as Le,D as Se,n as H,a2 as B,aC as b,V as fe,k as F,bd as be,bk as Me,at as de,ad as ye,ac as we,ai as j,bl as Ne,x as Y,y as he,bm as Q,bn as pe,af as Ie,aQ as K,aj as Oe,M as me,aX as Ce,bo as Fe,ah as De,bp as Pe,g as ke,ag as He,ay as Ge,bq as Be,br as Ue,G as V,a as ve,i as je,O as Ke,bs as Ve,bt as Xe,bu as ze,bv as Ae,aH as $,j as U,Q as ge,bw as qe,bx as We,by as Ye,a_ as Qe,bz as Ze,bA as Je,az as $e,bB as et,aO as ee,bC as te,bD as ne,bE as se,B as tt,d as nt,bF as st}from"./three.module-DpclfMcJ.js";function Bt(f){let t=0;for(const i in f.attributes){const n=f.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}const e=f.getIndex();return t+=e?e.count*e.itemSize*e.array.BYTES_PER_ELEMENT:0,t}function re(f,t){if(t===Re)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(t===W||t===ue){let e=f.getIndex();if(e===null){const s=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o=2.0 are supported."));return}const c=new kt(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(i,n)}parseAsync(t,e){const i=this;return new Promise(function(n,r){i.parse(t,e,n,r)})}}function rt(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}const A={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class it{constructor(t){this.parser=t,this.name=A.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Et{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Rt{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class xt{constructor(t){this.name=A.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,d=new Uint8Array(a,o,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(l,u,d,n.mode,n.filter).then(function(h){return h.buffer}):s.ready.then(function(){const h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,n.mode,n.filter),h})})}else return null}}class _t{constructor(t){this.name=A.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=e.meshes[i.mesh];for(const c of n.primitives)if(c.mode!==_.TRIANGLES&&c.mode!==_.TRIANGLE_STRIP&&c.mode!==_.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const c in s)a.push(this.parser.getDependency("accessor",s[c]).then(l=>(o[c]=l,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(const m of u){const T=new U,p=new F,g=new ge,R=new F(1,1,1),x=new be(m.geometry,m.material,d);for(let E=0;E0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Pt=new U;class kt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new rt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,s=-1;if(typeof navigator<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=i&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||r&&s<98?this.textureLoader=new ye(this.options.manager):this.textureLoader=new we(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new le(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const a={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:i,userData:{}};return O(r,a,n),M(a,n),Promise.all(i._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let n=0,r=e.length;n{const o=this.associations.get(s);o!=null&&this.associations.set(a,o);for(const[c,l]of s.children.entries())r(l,a.children[c])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i=2&&p.setY(N,w[L*o+1]),o>=3&&p.setZ(N,w[L*o+2]),o>=4&&p.setW(N,w[L*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(t){const e=this.json,i=this.options,r=e.textures[t].source,s=e.images[r];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,i).then(function(l){l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const d=(r.samplers||{})[s.sampler]||{};return l.magFilter=oe[d.magFilter]||Y,l.minFilter=oe[d.minFilter]||he,l.wrapS=ae[d.wrapS]||Q,l.wrapT=ae[d.wrapT]||Q,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==pe&&l.minFilter!==Y,n.associations.set(l,{textures:t}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=i.getDependency("bufferView",s.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then(function(u){return new Promise(function(d,h){let m=d;e.isImageBitmapLoader===!0&&(m=function(T){const p=new ee(T);p.needsUpdate=!0,d(p)}),e.load(G.resolveURL(u,r.path),m,void 0,h)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),M(u,s),u.userData.mimeType=s.mimeType||Dt(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=l,l}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),r.extensions[A.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[A.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=r.associations.get(s);s=r.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}return n!==void 0&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new Ie,K.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,o.sizeAttenuation=!1,this.cache.add(a,o)),i=o}else if(t.isLine){const a="LineBasicMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new Oe,K.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,this.cache.add(a,o)),i=o}if(n||r||s){let a="ClonedMaterial:"+i.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=i.clone(),r&&(o.vertexColors=!0),s&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(i))),i=o}t.material=i}getMaterialType(){return me}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=r.extensions||{},c=[];if(o[A.KHR_MATERIALS_UNLIT]){const u=n[A.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,e))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new C(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],y),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,B)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=Ce);const l=r.alphaMode||z.OPAQUE;if(l===z.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===z.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==H&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new fe(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&s!==H&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==H){const u=r.emissiveFactor;a.emissive=new C().setRGB(u[0],u[1],u[2],y)}return r.emissiveTexture!==void 0&&s!==H&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,B)),Promise.all(c).then(function(){const u=new s(a);return r.name&&(u.name=r.name),M(u,r),e.associations.set(u,{materials:t}),r.extensions&&O(n,u,r),u})}createUniqueName(t){const e=Fe.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(a){return i[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return ce(o,a,e)})}const s=[];for(let a=0,o=t.length;a0&&Ct(g,r),g.name=e.createUniqueName(r.name||"mesh_"+t),M(g,r),p.extensions&&O(n,g,p),e.assignFinalMaterial(g),u.push(g)}for(let h=0,m=u.length;h1?l=new V:c.length===1?l=c[0]:l=new de,l!==c[0])for(let u=0,d=c.length;u{const u=new Map;for(const[d,h]of n.associations)(d instanceof K||d instanceof ee)&&u.set(d,h);return l.traverse(d=>{const h=n.associations.get(d);h!=null&&u.set(d,h)}),u};return n.associations=c(r),r})}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];I[r.path]===I.weights?t.traverse(function(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}):o.push(a);let c;switch(I[r.path]){case I.weights:c=ne;break;case I.rotation:c=se;break;case I.position:case I.scale:c=te;break;default:switch(i.itemSize){case 1:c=ne;break;case 2:case 3:default:c=te;break}break}const l=n.interpolation!==void 0?Nt[n.interpolation]:Ae,u=this._getArrayFromAccessor(i);for(let d=0,h=o.length;do.value===n);return r===null?"":r.name}}adjustValueScaleOffset(e){return re(this.type)?Oe(this,e):e}}class z{constructor(e,s={},t={},n=null){this.definition=e,this.class=s[e.class],this.className=e.class,this.enums=t,this.data=n,this.name="name"in e?e.name:null,this.properties=null}getPropertyNames(){return Object.keys(this.class.properties)}includesData(e){return!!this.definition.properties[e]}dispose(){}_initProperties(e=D){const s={};for(const t in this.class.properties)s[t]=new e(this.enums,this.class.properties[t],this.definition.properties[t]);this.properties=s}}class Ve extends D{constructor(e,s,t=null){super(e,s,t),this.attribute=t.attribute}}class Ce extends z{constructor(...e){super(...e),this.isPropertyAttributeAccessor=!0,this._initProperties(Ve)}getData(e,s,t={}){const n=this.properties;P(n,t);for(const r in n)t[r]=this.getPropertyValue(r,e,s,t[r]);return t}getPropertyValue(e,s,t,n=null){if(s>=this.count)throw new Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");const r=this.properties[e],o=r.type;if(r){if(!this.definition.properties[e])return r.resolveDefault(n)}else throw new Error("PropertyAttributeAccessor: Requested class property does not exist.");n=r.shapeToProperty(n);const a=t.getAttribute(r.attribute.toLowerCase());if(_(o)){const u=n.elements;for(let f=0,p=u.length;f>h&1)===1}return n}getPropertyValue(e,s,t=null){if(s>=this.count)throw new Error("PropertyTableAccessor: Requested index is outside the range of the table.");const n=this.properties[e];if(n){if(!this.definition.properties[e])return n.resolveDefault(t)}else throw new Error("PropertyTableAccessor: Requested property does not exist.");const r=n.array,o=this.data,a=n.getArrayLengthFromId(o,s);if(t=n.shapeToProperty(t,a),r)for(let u=0,f=t.length;u=165,Pe=parseInt(ne)>=166,O=new Te,X=new se,U=new T,E=new class{constructor(){this._renderer=new ye,this._target=new G(1,1),this._texTarget=new G,this._quad=new we(new pe({blending:de,blendDst:me,blendSrc:Ae,uniforms:{map:{value:null},pixel:{value:new T}},vertexShader:` + void main() { + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + `,fragmentShader:` + uniform sampler2D map; + uniform ivec2 pixel; + + void main() { + + gl_FragColor = texelFetch( map, pixel, 0 ); + + } + `}))}increaseSizeTo(i){this._target.setSize(Math.max(this._target.width,i),1)}readDataAsync(i){const{_renderer:e,_target:s}=this;return q?e.readRenderTargetPixelsAsync(s,0,0,i.length/4,1,i):Promise.resolve().then(()=>this.readData(i))}readData(i){const{_renderer:e,_target:s}=this;e.readRenderTargetPixels(s,0,0,i.length/4,1,i)}renderPixelToTarget(i,e,s){const{_quad:t,_renderer:n,_target:r,_texTarget:o}=this;if(Pe)O.min.copy(e),O.max.copy(e),O.max.x+=1,O.max.y+=1,n.initRenderTarget(r),n.copyTextureToTexture(i,r.texture,O,s,0);else{const a=n.autoClear,u=n.getRenderTarget(),f=n.getScissorTest();n.getScissor(X),o.setSize(i.image.width,i.image.height),n.setRenderTarget(o),U.set(0,0),q?n.copyTextureToTexture(i,o.texture,null,U):n.copyTextureToTexture(U,i,o.texture),t.material.uniforms.map.value=o.texture,t.material.uniforms.pixel.value.copy(e),n.setRenderTarget(r),n.setScissorTest(!0),n.setScissor(s.x,s.y,1,1),n.autoClear=!1,t.render(n),n.setScissorTest(f),n.setScissor(X),n.setRenderTarget(u),n.autoClear=a,o.dispose()}}},k=new T,$=new T,Q=new T;function Re(i,e){return e===0?i.getAttribute("uv"):i.getAttribute(`uv${e}`)}function oe(i,e,s=new Array(3)){let t=3*e,n=3*e+1,r=3*e+2;return i.index&&(t=i.index.getX(t),n=i.index.getX(n),r=i.index.getX(r)),s[0]=t,s[1]=n,s[2]=r,s}function ae(i,e,s,t,n){const[r,o,a]=t,u=Re(i,e);k.fromBufferAttribute(u,r),$.fromBufferAttribute(u,o),Q.fromBufferAttribute(u,a),n.set(0,0,0).addScaledVector(k,s.x).addScaledVector($,s.y).addScaledVector(Q,s.z)}function ue(i,e,s,t){const n=i.x-Math.floor(i.x),r=i.y-Math.floor(i.y),o=Math.floor(n*e%e),a=Math.floor(r*s%s);return t.set(o,a),t}const W=new T,H=new T,J=new T;class De extends D{constructor(e,s,t=null){super(e,s,t),this.channels=m(t,"channels",[0]),this.index=m(t,"index",null),this.texCoord=m(t,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(e,s,t=null){const n=this.type;if(n==="BOOLEAN"||n==="STRING")throw new Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return ie(e,s*this.valueLength,n,t)}}class ge extends z{constructor(...e){super(...e),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(De)}getData(e,s,t,n={}){const r=this.properties;P(r,n);const o=Object.keys(r),a=o.map(u=>n[u]);return this.getPropertyValuesAtTexel(o,e,s,t,a),o.forEach((u,f)=>n[u]=a[f]),n}async getDataAsync(e,s,t,n={}){const r=this.properties;P(r,n);const o=Object.keys(r),a=o.map(u=>n[u]);return await this.getPropertyValuesAtTexelAsync(o,e,s,t,a),o.forEach((u,f)=>n[u]=a[f]),n}getPropertyValuesAtTexelAsync(...e){this._asyncRead=!0;const s=this.getPropertyValuesAtTexel(...e);return this._asyncRead=!1,s}getPropertyValuesAtTexel(e,s,t,n,r=[]){for(;r.length(c.call(this),r));return E.readData(p),c.call(this),r;function c(){for(let l=0,y=e.length;lp[4*l+b]),w=h.componentType,g=V(w,A),F=new g(x);if(new Uint8Array(F.buffer).set(I),h.array){const b=r[l];for(let N=0,ce=b.length;N{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}}class K{constructor(e,s,t,n=null,r=null){const{schema:o,propertyTables:a=[],propertyTextures:u=[],propertyAttributes:f=[]}=e,{enums:p,classes:c}=o,l=a.map(h=>new Me(h,c,p,t));let y=[],d=[];n&&(n.propertyTextures&&(y=n.propertyTextures.map(h=>new ge(u[h],c,p,s))),n.propertyAttributes&&(d=n.propertyAttributes.map(h=>new Ce(f[h],c,p)))),this.schema=o,this.tableAccessors=l,this.textureAccessors=y,this.attributeAccessors=d,this.object=r,this.textures=s,this.nodeMetadata=n}getPropertyTableData(e,s,t=null){if(!Array.isArray(e)||!Array.isArray(s))t=t||{},t=this.tableAccessors[e].getData(s,t);else{t=t||[];const n=Math.min(e.length,s.length);t.length=n;for(let r=0;rt)),Array.isArray(e))return e.map(s=>{const t=this.tableAccessors[s];return{name:t.name,className:t.definition.class}});{const s=this.tableAccessors[e];return{name:s.name,className:s.definition.class}}}getPropertyTextureData(e,s,t=[]){const n=this.textureAccessors;t.length=n.length;for(let r=0;r{t[o]=f});r.push(u)}return await Promise.all(r),t}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(e,s=[]){const t=this.attributeAccessors;s.length=t.length;for(let n=0;n({name:e.name,className:e.definition.class}))}dispose(){this.textureAccessors.forEach(e=>e.dispose()),this.tableAccessors.forEach(e=>e.dispose()),this.attributeAccessors.forEach(e=>e.dispose())}}const S="EXT_structural_metadata";function Fe(i,e=[]){var n;const s=((n=i.json.textures)==null?void 0:n.length)||0,t=new Array(s).fill(null);return e.forEach(({properties:r})=>{for(const o in r){const{index:a}=r[o];t[a]===null&&(t[a]=i.loadTexture(a))}}),Promise.all(t)}function Ue(i,e=[]){var n;const s=((n=i.json.bufferViews)==null?void 0:n.length)||0,t=new Array(s).fill(null);return e.forEach(({properties:r})=>{for(const o in r){const{values:a,arrayOffsets:u,stringOffsets:f}=r[o];t[a]===null&&(t[a]=i.loadBufferView(a)),t[u]===null&&(t[u]=i.loadBufferView(u)),t[f]===null&&(t[f]=i.loadBufferView(f))}}),Promise.all(t)}class Ge{constructor(e){this.parser=e,this.name=S}async afterRoot({scene:e,parser:s}){const t=s.json.extensionsUsed;if(!t||!t.includes(S))return;let n=null,r=s.json.extensions[S];if(r.schemaUri){const{manager:f,path:p,requestHeader:c,crossOrigin:l}=s.options,y=new URL(r.schemaUri,p).toString(),d=new xe(f);d.setCrossOrigin(l),d.setResponseType("json"),d.setRequestHeader(c),n=d.loadAsync(y).then(h=>{r={...r,schema:h}})}const[o,a]=await Promise.all([Fe(s,r.propertyTextures),Ue(s,r.propertyTables),n]),u=new K(r,o,a);e.userData.structuralMetadata=u,e.traverse(f=>{if(s.associations.has(f)){const{meshes:p,primitives:c}=s.associations.get(f),l=s.json.meshes[p].primitives[c];if(l&&l.extensions&&l.extensions[S]){const y=l.extensions[S];f.userData.structuralMetadata=new K(r,o,a,y,f)}else f.userData.structuralMetadata=u}})}}const Z=new T,Y=new T,ee=new T;function Le(i){return i.x>i.y&&i.x>i.z?0:i.y>i.z?1:2}class Be{constructor(e,s,t){this.geometry=e,this.textures=s,this.data=t,this._asyncRead=!1,this.featureIds=t.featureIds.map(n=>{const{texture:r,...o}=n,a={label:null,propertyTable:null,nullFeatureId:null,...o};return r&&(a.texture={texCoord:0,channels:[0],...r}),a})}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...e){this._asyncRead=!0;const s=this.getFeatures(...e);return this._asyncRead=!1,s}getFeatures(e,s){const{geometry:t,textures:n,featureIds:r}=this,o=new Array(r.length).fill(null),a=r.length;E.increaseSizeTo(a);const u=oe(t,e),f=u[Le(s)];for(let l=0,y=r.length;l(c(),o));return E.readData(p),c(),o;function c(){const l=new Uint32Array(1);for(let y=0,d=r.length;yp[4*y+g]);new Uint8Array(l.buffer).set(I);const w=l[0];w!==A&&(o[y]=w)}}}}dispose(){this.textures.forEach(e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}}const R="EXT_mesh_features";function te(i,e,s){i.traverse(t=>{if(e.associations.has(t)){const{meshes:n,primitives:r}=e.associations.get(t),o=e.json.meshes[n].primitives[r];o&&o.extensions&&o.extensions[R]&&s(t,o.extensions[R])}})}class ve{constructor(e){this.parser=e,this.name=R}async afterRoot({scene:e,parser:s}){var a;const t=s.json.extensionsUsed;if(!t||!t.includes(R))return;const n=((a=s.json.textures)==null?void 0:a.length)||0,r=new Array(n).fill(null);te(e,s,(u,{featureIds:f})=>{f.forEach(p=>{if(p.texture&&r[p.texture.index]===null){const c=p.texture.index;r[c]=s.loadTexture(c)}})});const o=await Promise.all(r);te(e,s,(u,f)=>{u.userData.meshFeatures=new Be(u.geometry,o,f)})}}export{ve as G,Ge as a}; diff --git a/example/bundle/assets/GizmoViewport-BC-gHgu9.js b/example/bundle/assets/GizmoViewport-BC-gHgu9.js new file mode 100644 index 00000000..10895192 --- /dev/null +++ b/example/bundle/assets/GizmoViewport-BC-gHgu9.js @@ -0,0 +1 @@ +import{d as E,r as e,u as S,_ as C,g as Q}from"./CameraControls-DhgPIfmg.js";import{aE as X,x as O,$ as Y,aF as B,a0 as V,S as Z,k as P,at as J,Q as A,j as K,aG as N}from"./three.module-DpclfMcJ.js";function U(n,d,u){const o=E(l=>l.size),s=E(l=>l.viewport),f=typeof n=="number"?n:o.width*s.dpr,i=o.height*s.dpr,r=(typeof n=="number"?u:n)||{},{samples:c=0,depth:g,...p}=r,m=e.useMemo(()=>{const l=new X(f,i,{minFilter:O,magFilter:O,type:Y,...p});return g&&(l.depthTexture=new B(f,i,V)),l.samples=c,l},[]);return e.useLayoutEffect(()=>{m.setSize(f,i),c&&(m.samples=c)},[c,m,f,i]),e.useEffect(()=>()=>m.dispose(),[]),m}const $=n=>typeof n=="function",ee=e.forwardRef(({envMap:n,resolution:d=256,frames:u=1/0,children:o,makeDefault:s,...f},i)=>{const r=E(({set:t})=>t),c=E(({camera:t})=>t),g=E(({size:t})=>t),p=e.useRef(null);e.useImperativeHandle(i,()=>p.current,[]);const m=e.useRef(null),l=U(d);e.useLayoutEffect(()=>{f.manual||p.current.updateProjectionMatrix()},[g,f]),e.useLayoutEffect(()=>{p.current.updateProjectionMatrix()}),e.useLayoutEffect(()=>{if(s){const t=c;return r(()=>({camera:p.current})),()=>r(()=>({camera:t}))}},[p,s,r]);let h=0,y=null;const a=$(o);return S(t=>{a&&(u===1/0||h{i=o.autoClear,u===1&&(o.autoClear=!0,o.render(n,d)),o.autoClear=!1,o.clearDepth(),o.render(s,f),o.autoClear=i},u),e.createElement("group",{onPointerOver:()=>null})}function ne({children:n,renderPriority:d=1}){const{scene:u,camera:o}=E(),[s]=e.useState(()=>new Z);return e.createElement(e.Fragment,null,Q(e.createElement(e.Fragment,null,n,e.createElement(te,{defaultScene:u,defaultCamera:o,renderPriority:d})),s,{events:{priority:d+1}}))}const q=e.createContext({}),re=()=>e.useContext(q),oe=2*Math.PI,H=new J,I=new K,[v,R]=[new A,new A],G=new P,L=new P,ae=n=>"minPolarAngle"in n,k=n=>"getTarget"in n,ie=({alignment:n="bottom-right",margin:d=[80,80],renderPriority:u=1,onUpdate:o,onTarget:s,children:f})=>{const i=E(x=>x.size),r=E(x=>x.camera),c=E(x=>x.controls),g=E(x=>x.invalidate),p=e.useRef(null),m=e.useRef(null),l=e.useRef(!1),h=e.useRef(0),y=e.useRef(new P(0,0,0)),a=e.useRef(new P(0,0,0));e.useEffect(()=>{a.current.copy(r.up)},[r]);const t=e.useCallback(x=>{l.current=!0,(c||s)&&(y.current=(s==null?void 0:s())||(k(c)?c.getTarget(y.current):c==null?void 0:c.target)),h.current=r.position.distanceTo(G),v.copy(r.quaternion),L.copy(x).multiplyScalar(h.current).add(G),H.lookAt(L),R.copy(H.quaternion),g()},[c,r,s,g]);S((x,b)=>{if(m.current&&p.current){var z;if(l.current)if(v.angleTo(R)<.01)l.current=!1,ae(c)&&r.up.copy(a.current);else{const D=b*oe;v.rotateTowards(R,D),r.position.set(0,0,1).applyQuaternion(v).multiplyScalar(h.current).add(y.current),r.up.set(0,1,0).applyQuaternion(v).normalize(),r.quaternion.copy(v),k(c)&&c.setPosition(r.position.x,r.position.y,r.position.z),o?o():c&&c.update(b),g()}I.copy(r.matrix).invert(),(z=p.current)==null||z.quaternion.setFromRotationMatrix(I)}});const j=e.useMemo(()=>({tweenCamera:t}),[t]),[F,T]=d,W=n.endsWith("-center")?0:n.endsWith("-left")?-i.width/2+F:i.width/2-F,_=n.startsWith("center-")?0:n.startsWith("top-")?i.height/2-T:-i.height/2+T;return e.createElement(ne,{renderPriority:u},e.createElement(q.Provider,{value:j},e.createElement(ee,{makeDefault:!0,ref:m,position:[0,0,200]}),e.createElement("group",{ref:p,position:[W,_,0]},f)))};function M({scale:n=[.8,.05,.05],color:d,rotation:u}){return e.createElement("group",{rotation:u},e.createElement("mesh",{position:[.4,0,0]},e.createElement("boxGeometry",{args:n}),e.createElement("meshBasicMaterial",{color:d,toneMapped:!1})))}function w({onClick:n,font:d,disabled:u,arcStyle:o,label:s,labelColor:f,axisHeadScale:i=1,...r}){const c=E(a=>a.gl),g=e.useMemo(()=>{const a=document.createElement("canvas");a.width=64,a.height=64;const t=a.getContext("2d");return t.beginPath(),t.arc(32,32,16,0,2*Math.PI),t.closePath(),t.fillStyle=o,t.fill(),s&&(t.font=d,t.textAlign="center",t.fillStyle=f,t.fillText(s,32,41)),new N(a)},[o,s,f,d]),[p,m]=e.useState(!1),l=(s?1:.75)*(p?1.2:1)*i,h=a=>{a.stopPropagation(),m(!0)},y=a=>{a.stopPropagation(),m(!1)};return e.createElement("sprite",C({scale:l,onPointerOver:u?void 0:h,onPointerOut:u?void 0:n||y},r),e.createElement("spriteMaterial",{map:g,"map-anisotropy":c.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:s?1:.75,toneMapped:!1}))}const le=({hideNegativeAxes:n,hideAxisHeads:d,disabled:u,font:o="18px Inter var, Arial, sans-serif",axisColors:s=["#ff2060","#20df80","#2080ff"],axisHeadScale:f=1,axisScale:i,labels:r=["X","Y","Z"],labelColor:c="#000",onClick:g,...p})=>{const[m,l,h]=s,{tweenCamera:y}=re(),a={font:o,disabled:u,labelColor:c,onClick:g,axisHeadScale:f,onPointerDown:u?void 0:t=>{y(t.object.position),t.stopPropagation()}};return e.createElement("group",C({scale:40},p),e.createElement(M,{color:m,rotation:[0,0,0],scale:i}),e.createElement(M,{color:l,rotation:[0,0,Math.PI/2],scale:i}),e.createElement(M,{color:h,rotation:[0,-Math.PI/2,0],scale:i}),!d&&e.createElement(e.Fragment,null,e.createElement(w,C({arcStyle:m,position:[1,0,0],label:r[0]},a)),e.createElement(w,C({arcStyle:l,position:[0,1,0],label:r[1]},a)),e.createElement(w,C({arcStyle:h,position:[0,0,1],label:r[2]},a)),!n&&e.createElement(e.Fragment,null,e.createElement(w,C({arcStyle:m,position:[-1,0,0]},a)),e.createElement(w,C({arcStyle:l,position:[0,-1,0]},a)),e.createElement(w,C({arcStyle:h,position:[0,0,-1]},a)))))};export{ie as G,le as a,U as u}; diff --git a/example/bundle/assets/GlobeControls-BUn2ddB7.js b/example/bundle/assets/GlobeControls-BUn2ddB7.js new file mode 100644 index 00000000..2995fd1c --- /dev/null +++ b/example/bundle/assets/GlobeControls-BUn2ddB7.js @@ -0,0 +1 @@ +import{j as S,k as _,an as A,V as F,Q as G,i as l}from"./three.module-DpclfMcJ.js";import{E as N,c as z,N as Z,D as j,m as w,a as H,s as L,b as q}from"./EnvironmentControls-C8X7oAWq.js";import{E as k}from"./Ellipsoid-Cnb0UTwk.js";const p=new S,C=new S,f=new _,s=new _,y=new _,c=new _,R=new _,v=new _,V=new _,u=new G,b=new _,D=new _,E={},g=new A,T=new k,P=new F,Q=400;class X extends N{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,o=null,i=null,e=null){super(t,o,i),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.dragQuaternion=new G,this.setTilesRenderer(e)}setScene(t){t===null&&this.tilesRenderer!==null?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:o,tilesGroup:i,ellipsoid:e}=this;return c.set(0,0,-1).transformDirection(o.matrixWorld),p.copy(i.matrixWorld).invert(),g.origin.copy(o.position),g.direction.copy(c),g.applyMatrix4(p),z(g,e,s),s.applyMatrix4(i.matrixWorld),(super.getPivotPoint(t)===null||t.distanceTo(g.origin)>s.distanceTo(g.origin))&&t.copy(s),t}getVectorToCenter(t){const{tilesGroup:o,camera:i}=this;return t.setFromMatrixPosition(o.matrixWorld).sub(i.position)}getDistanceToCenter(){return this.getVectorToCenter(s).length()}getUpDirection(t,o){const{tilesGroup:i,ellipsoid:e}=this;p.copy(i.matrixWorld).invert(),s.copy(t).applyMatrix4(p),e.getPositionToNormal(s,o),o.transformDirection(i.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:o,ellipsoid:i,camera:e}=this;e.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(s),p.copy(o.matrixWorld).invert(),s.applyMatrix4(p),i.getPositionToNormal(s,t),t.transformDirection(o.matrixWorld)):this.getUpDirection(e.position,t)}update(t=Math.min(this.clock.getDelta(),64/1e3)){if(!this.enabled||!this.tilesGroup||!this.camera||t===0)return;const{camera:o,pivotMesh:i}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(this.state!==Z&&this._dragMode!==1&&this._rotationMode!==1&&(i.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),this.adjustCamera(o)}adjustCamera(t){super.adjustCamera(t);const{tilesGroup:o,ellipsoid:i}=this;if(t.isPerspectiveCamera){const e=s.setFromMatrixPosition(o.matrixWorld).sub(t.position).length(),r=Math.max(...i.radius),a=.25*r,n=l.clamp((e-r)/a,0,1),h=l.lerp(1,1e3,n);t.near=Math.max(h,e-r-a);const m=p.copy(o.matrixWorld).invert();f.copy(t.position).applyMatrix4(m),i.getPositionToCartographic(f,E);const d=Math.max(i.getPositionElevation(f),Q),x=i.calculateHorizonDistance(E.lat,d);t.far=x*2.5+.1,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),p.copy(t.matrixWorld).invert(),s.setFromMatrixPosition(o.matrixWorld).applyMatrix4(p);const e=-s.z;t.near=e-Math.max(...i.radius)*1.1,t.far=e+.1,t.position.addScaledVector(c,t.near),t.far-=t.near,t.near=0,t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(this.state!==j){const{enableDamping:o,tilesGroup:i,dragQuaternion:e,dragInertia:r,camera:a}=this;o&&(e.w===1&&(e.x!==0||e.y!==0||e.z!==0)&&(e.w=Math.min(e.w,1-1e-9)),y.setFromMatrixPosition(i.matrixWorld),u.identity().slerp(e,r.x*t),w(y,u,C),a.matrixWorld.premultiply(C),a.matrixWorld.decompose(a.position,a.quaternion,s))}else{this._dragMode===0&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:o,camera:i,pivotPoint:e,pointerTracker:r,domElement:a,tilesGroup:n}=this,h=f,m=v;r.getCenterPoint(P),H(P.x,P.y,a,P),L(o,P,i),p.copy(n.matrixWorld).invert(),o.ray.applyMatrix4(p);const d=s.copy(e).applyMatrix4(p).length();T.radius.setScalar(d),i.isPerspectiveCamera?T.intersectRay(o.ray,s)||q(o.ray,d,s):z(o.ray,T,s),s.applyMatrix4(n.matrixWorld),y.setFromMatrixPosition(n.matrixWorld),h.subVectors(e,y).normalize(),m.subVectors(s,y).normalize(),u.setFromUnitVectors(m,h),w(y,u,C),i.matrixWorld.premultiply(C),i.matrixWorld.decompose(i.position,i.quaternion,s);const{dragInertia:x,dragQuaternion:M}=this;r.getMoveDistance()/t<2*window.devicePixelRatio?(M.slerp(u,.5),x.set(1/t,0,0)):(M.copy(u),x.set(1/t,0,0))}this._alignCameraUp(this.up)}_updateRotation(...t){this._rotationMode===1||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:o,zoomSpeed:i,zoomPoint:e,camera:r,maxZoom:a}=this,n=l.clamp(l.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){c.set(0,0,-1).transformDirection(r.matrixWorld).normalize(),D.copy(this.up).multiplyScalar(-1),this.getUpDirection(e,b);const h=l.clamp(l.mapLinear(-b.dot(D),1,.95,0,1),0,1),m=1-c.dot(D),d=r.isOrthographicCamera?.05:1,x=l.clamp(n*3,0,1),M=Math.min(h*m*d*x,.1);D.lerpVectors(c,D,M).normalize(),u.setFromUnitVectors(c,D),w(e,u,C),r.matrixWorld.premultiply(C),r.matrixWorld.decompose(r.position,r.quaternion,D),this.zoomDirection.subVectors(e,r.position).normalize()}super._updateZoom()}else if(r.isPerspectiveCamera){const h=this._getPerspectiveTransitionDistance(),m=this._getMaxPerspectiveDistance(),d=l.mapLinear(this.getDistanceToCenter(),h,m,0,1);this._tiltTowardsCenter(l.lerp(0,.4,d*n)),this._alignCameraUpToNorth(l.lerp(0,.2,d*n));const x=this.getDistanceToCenter()-o.radius.x,M=t*x*i*.0025,W=Math.max(M,Math.min(this.getDistanceToCenter()-m,0));this.getVectorToCenter(s).normalize(),this.camera.position.addScaledVector(s,W),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const h=this._getOrthographicTransitionZoom(),m=this._getMinOrthographicZoom(),d=l.mapLinear(r.zoom,h,m,0,1);this._tiltTowardsCenter(l.lerp(0,.4,d*n)),this._alignCameraUpToNorth(l.lerp(0,.2,d*n));const x=this.zoomDelta,M=Math.pow(.95,Math.abs(x*.05)),W=x>0?1/Math.abs(M):M,O=m/r.zoom,U=Math.max(W*i,Math.min(O,1));r.zoom=Math.min(a,r.zoom*U),r.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:o}=this;V.set(0,0,1).transformDirection(o.matrixWorld),this._alignCameraUp(V,t)}_alignCameraUp(t,o=null){const{camera:i}=this;c.set(0,0,-1).transformDirection(i.matrixWorld),R.set(-1,0,0).transformDirection(i.matrixWorld),v.crossVectors(t,c),o===null&&(o=1-Math.abs(c.dot(t)),o=l.mapLinear(o,0,1,-.01,1),o=l.clamp(o,0,1)**2),v.lerp(R,1-o).normalize(),u.setFromUnitVectors(R,v),i.quaternion.premultiply(u),i.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:o,tilesGroup:i}=this;c.set(0,0,-1).transformDirection(o.matrixWorld).normalize(),s.setFromMatrixPosition(i.matrixWorld).sub(o.position).normalize(),s.lerp(c,1-t).normalize(),u.setFromUnitVectors(c,s),o.quaternion.premultiply(u),o.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:o}=this;if(!t.isPerspectiveCamera)throw new Error;const i=Math.max(...o.radius),e=2*Math.atan(Math.tan(l.DEG2RAD*t.fov*.5)*t.aspect),r=i/Math.tan(l.DEG2RAD*t.fov*.5),a=i/Math.tan(e*.5);return Math.max(r,a)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:o}=this;if(!t.isPerspectiveCamera)throw new Error;const i=Math.max(...o.radius),e=2*Math.atan(Math.tan(l.DEG2RAD*t.fov*.5)*t.aspect),r=i/Math.tan(l.DEG2RAD*t.fov*.5),a=i/Math.tan(e*.5);return 2*Math.max(r,a)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:o}=this;if(!t.isOrthographicCamera)throw new Error;const i=t.top-t.bottom,e=t.right-t.left,r=Math.max(i,e),n=2*Math.max(...o.radius);return 2*r/n}_getMinOrthographicZoom(){const{camera:t,ellipsoid:o}=this;if(!t.isOrthographicCamera)throw new Error;const i=t.top-t.bottom,e=t.right-t.left,r=Math.min(i,e),n=2*Math.max(...o.radius);return .7*r/n}_getVirtualOrthoCameraPosition(t,o=this.camera){const{tilesGroup:i,ellipsoid:e}=this;if(!o.isOrthographicCamera)throw new Error;p.copy(i.matrixWorld).invert(),g.origin.copy(o.position),g.direction.set(0,0,-1).transformDirection(o.matrixWorld),g.applyMatrix4(p),z(g,e,f),f.applyMatrix4(i.matrixWorld);const r=o.top-o.bottom,a=o.right-o.left,n=Math.max(r,a)/o.zoom;c.set(0,0,-1).transformDirection(o.matrixWorld);const h=f.sub(o.position).dot(c);t.copy(o.position).addScaledVector(c,h-n*4)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}export{X as G}; diff --git a/example/bundle/assets/GoogleCloudAuthPlugin-B9LFbpXw.js b/example/bundle/assets/GoogleCloudAuthPlugin-B9LFbpXw.js new file mode 100644 index 00000000..a22654e8 --- /dev/null +++ b/example/bundle/assets/GoogleCloudAuthPlugin-B9LFbpXw.js @@ -0,0 +1 @@ +import{t as h}from"./TilesRenderer-DdUhzUiO.js";class u{constructor(){this.creditsCount={}}_adjustAttributions(t,e){const s=this.creditsCount,i=t.split(/;/g);for(let n=0,l=i.length;n{const i=e[1];return s[1]-i}).map(e=>e[0]).join("; ")}}function a(r){let t=null;return h(r,e=>{if(e.content&&e.content.uri){const[,s]=e.content.uri.split("?");return t=new URLSearchParams(s).get("session"),!0}return!1}),t}class d{constructor({apiToken:t,autoRefreshToken:e=!1,logoUrl:s=null,useRecommendedSettings:i=!0}){this.name="GOOGLE_CLOUD_AUTH_PLUGIN",this.apiToken=t,this.autoRefreshToken=e,this.useRecommendedSettings=i,this.logoUrl=s,this.sessionToken=null,this.tiles=null,this._onLoadCallback=null,this._visibilityChangeCallback=null,this._tokenRefreshPromise=null,this._attributionsManager=new u,this._logoAttribution={value:"",type:"image",collapsible:!1},this._attribution={value:"",type:"string",collapsible:!0}}init(t){t!=null&&(t.resetFailedTiles(),t.rootURL==null&&(t.rootURL="https://tile.googleapis.com/v1/3dtiles/root.json"),this.useRecommendedSettings&&(t.parseQueue.maxJobs=10,t.downloadQueue.maxJobs=30,t.errorTarget=40),this.tiles=t,this._onLoadCallback=({tileSet:e})=>{this.sessionToken=a(e.root),t.removeEventListener("load-tile-set",this._onLoadCallback)},this._visibilityChangeCallback=({tile:e,visible:s})=>{const i=e.cached.metadata.asset.copyright||"";s?this._attributionsManager.addAttributions(i):this._attributionsManager.removeAttributions(i)},t.addEventListener("load-tile-set",this._onLoadCallback),t.addEventListener("tile-visibility-change",this._visibilityChangeCallback))}getAttributions(t){this.tiles.visibleTiles.size>0&&(this.logoUrl&&(this._logoAttribution.value=this.logoUrl,t.push(this._logoAttribution)),this._attribution.value=this._attributionsManager.toString(),t.push(this._attribution))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&(t.searchParams.append("key",this.apiToken),this.sessionToken!==null&&t.searchParams.append("session",this.sessionToken)),t.toString()}dispose(){const{tiles:t}=this;t.removeEventListener("load-tile-set",this._onLoadCallback),t.removeEventListener("tile-visibility-change",this._visibilityChangeCallback)}async fetchData(t,e){this._tokenRefreshPromise!==null&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const s=await fetch(t,e);return s.status>=400&&s.status<=499&&this.autoRefreshToken?(await this._refreshToken(e),fetch(this.preprocessURL(t),e)):s}_refreshToken(t){if(this._tokenRefreshPromise===null){const e=new URL(this.tiles.rootURL);e.searchParams.append("key",this.apiToken),this._tokenRefreshPromise=fetch(e,t).then(s=>s.json()).then(s=>{this.sessionToken=a(s.root),this._tokenRefreshPromise=null})}return this._tokenRefreshPromise}}export{d as G}; diff --git a/example/bundle/assets/I3DMLoader-BlebwdUJ.js b/example/bundle/assets/I3DMLoader-BlebwdUJ.js new file mode 100644 index 00000000..30fdc1c7 --- /dev/null +++ b/example/bundle/assets/I3DMLoader-BlebwdUJ.js @@ -0,0 +1 @@ +import{r as Z,F as J,B as q,a as K}from"./readMagicBytes-Da5ueiou.js";import{L as X}from"./LoaderBase-CVSPpjX2.js";import{j as y,bc as Y,k as g,bd as tt,Q}from"./three.module-DpclfMcJ.js";import{G as et}from"./GLTFLoader-DkJa3Jo5.js";import{E as j}from"./Ellipsoid-Cnb0UTwk.js";const Lt=-1,ht=0,ut=1,gt=2,ft=3,R=6378137,st=1/298.257223563,at=-(st*R-R),nt=1736*1e3,H=1738.1*1e3;class ot extends X{parse(o){const a=new DataView(o),s=Z(a);console.assert(s==="i3dm");const O=a.getUint32(4,!0);console.assert(O===1);const I=a.getUint32(8,!0);console.assert(I===o.byteLength);const S=a.getUint32(12,!0),U=a.getUint32(16,!0),i=a.getUint32(20,!0),f=a.getUint32(24,!0),m=a.getUint32(28,!0),L=32,M=o.slice(L,L+S+U),n=new J(M,0,S,U),e=L+S+U,T=o.slice(e,e+i+f),E=new q(T,n.getData("INSTANCES_LENGTH"),0,i,f),N=e+i+f,h=new Uint8Array(o,N,I-N);let d=null,p=null,b=null;if(m)d=h,p=Promise.resolve();else{const r=this.resolveExternalURL(K(h)),u=r.split(/[\\/]/g);u.pop(),b=u.join("/"),p=fetch(r,this.fetchOptions).then(c=>{if(!c.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${r}" with status ${c.status} : ${c.statusText}`);return c.arrayBuffer()}).then(c=>{d=new Uint8Array(c)})}return p.then(()=>({version:O,featureTable:n,batchTable:E,glbBytes:d,gltfWorkingPath:b}))}}const rt=new j(R,R,at),mt=new j(H,H,nt),W=new g,F=new g,P=new g,C=new g,x=new Q,_=new g,w=new y,V=new y,v=new g,k=new y,B=new Q,G={};class Et extends ot{constructor(o=Y){super(),this.manager=o,this.adjustmentTransform=new y,this.ellipsoid=rt.clone()}resolveExternalURL(o){return this.manager.resolveURL(super.resolveExternalURL(o))}parse(o){return super.parse(o).then(a=>{const{featureTable:s,batchTable:O}=a,I=a.glbBytes.slice().buffer;return new Promise((S,U)=>{const i=this.fetchOptions,f=this.manager,m=f.getHandler("path.gltf")||new et(f);i.credentials==="include"&&i.mode==="cors"&&m.setCrossOrigin("use-credentials"),"credentials"in i&&m.setWithCredentials(i.credentials==="include"),i.headers&&m.setRequestHeader(i.headers);let L=a.gltfWorkingPath??this.workingPath;/[\\/]$/.test(L)||(L+="/");const M=this.adjustmentTransform;m.parse(I,L,n=>{const e=s.getData("INSTANCES_LENGTH"),T=s.getData("POSITION",e,"FLOAT","VEC3"),E=s.getData("NORMAL_UP",e,"FLOAT","VEC3"),N=s.getData("NORMAL_RIGHT",e,"FLOAT","VEC3"),h=s.getData("SCALE_NON_UNIFORM",e,"FLOAT","VEC3"),d=s.getData("SCALE",e,"FLOAT","SCALAR"),p=s.getData("RTC_CENTER"),b=s.getData("EAST_NORTH_UP");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach(t=>{t in s.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)});const r=new g;for(let t=0;t{if(t.isMesh){c.push(t);const{geometry:A,material:D}=t,l=new tt(A,D,e);l.position.copy(r),p&&(l.position.x+=p[0],l.position.y+=p[1],l.position.z+=p[2]),u.push(l)}});for(let t=0;t{if(!r.ok)throw new Error(`Failed to load file "${t}" with status ${r.status} : ${r.statusText}`);return r.arrayBuffer()}).then(r=>(this.workingPath===""&&(this.workingPath=this.workingPathForURL(t)),this.parse(r)))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const r=t.split(/[\\/]/g);return r.pop(),r.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}export{n as L}; diff --git a/example/bundle/assets/OrbitControls-DEr5g9Mg.js b/example/bundle/assets/OrbitControls-DEr5g9Mg.js new file mode 100644 index 00000000..5b8089ea --- /dev/null +++ b/example/bundle/assets/OrbitControls-DEr5g9Mg.js @@ -0,0 +1 @@ +import{an as S,ao as w,k as p,ap as O,aq as u,ar as _,Q as E,as as P,V as c,i as j}from"./three.module-DpclfMcJ.js";const D={type:"change"},b={type:"start"},M={type:"end"},f=new S,T=new w,A=Math.cos(70*j.DEG2RAD),n=new p,r=2*Math.PI,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},y=1e-6;class X extends O{constructor(t,e=null){super(t,e),this.state=o.NONE,this.enabled=!0,this.target=new p,this.cursor=new p,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.ROTATE,MIDDLE:u.DOLLY,RIGHT:u.PAN},this.touches={ONE:_.ROTATE,TWO:_.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new p,this._lastQuaternion=new E,this._lastTargetPosition=new p,this._quat=new E().setFromUnitVectors(t.up,new p(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new P,this._sphericalDelta=new P,this._scale=1,this._panOffset=new p,this._rotateStart=new c,this._rotateEnd=new c,this._rotateDelta=new c,this._panStart=new c,this._panEnd=new c,this._panDelta=new c,this._dollyStart=new c,this._dollyEnd=new c,this._dollyDelta=new c,this._dollyDirection=new p,this._mouse=new c,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=L.bind(this),this._onPointerDown=R.bind(this),this._onPointerUp=x.bind(this),this._onContextMenu=Z.bind(this),this._onMouseWheel=N.bind(this),this._onKeyDown=Y.bind(this),this._onTouchStart=I.bind(this),this._onTouchMove=U.bind(this),this._onMouseDown=C.bind(this),this._onMouseMove=k.bind(this),this._interceptControlDown=z.bind(this),this._interceptControlUp=K.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(D),this.update(),this.state=o.NONE}update(t=null){const e=this.object.position;n.copy(e).sub(this.target),n.applyQuaternion(this._quat),this._spherical.setFromVector3(n),this.autoRotate&&this.state===o.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,a=this.maxAzimuthAngle;isFinite(s)&&isFinite(a)&&(s<-Math.PI?s+=r:s>Math.PI&&(s-=r),a<-Math.PI?a+=r:a>Math.PI&&(a-=r),s<=a?this._spherical.theta=Math.max(s,Math.min(a,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+a)/2?Math.max(s,this._spherical.theta):Math.min(a,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let h=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const l=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),h=l!=this._spherical.radius}if(n.setFromSpherical(this._spherical),n.applyQuaternion(this._quatInverse),e.copy(this.target).add(n),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let l=null;if(this.object.isPerspectiveCamera){const d=n.length();l=this._clampDistance(d*this._scale);const m=d-l;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),h=!!m}else if(this.object.isOrthographicCamera){const d=new p(this._mouse.x,this._mouse.y,0);d.unproject(this.object);const m=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),h=m!==this.object.zoom;const g=new p(this._mouse.x,this._mouse.y,0);g.unproject(this.object),this.object.position.sub(g).add(d),this.object.updateMatrixWorld(),l=n.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;l!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(l).add(this.object.position):(f.origin.copy(this.object.position),f.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(f.direction))y||8*(1-this._lastQuaternion.dot(this.object.quaternion))>y||this._lastTargetPosition.distanceToSquared(this.target)>y?(this.dispatchEvent(D),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?r/60*this.autoRotateSpeed*t:r/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){n.setFromMatrixColumn(e,0),n.multiplyScalar(-t),this._panOffset.add(n)}_panUp(t,e){this.screenSpacePanning===!0?n.setFromMatrixColumn(e,1):(n.setFromMatrixColumn(e,0),n.crossVectors(this.object.up,n)),n.multiplyScalar(t),this._panOffset.add(n)}_pan(t,e){const s=this.domElement;if(this.object.isPerspectiveCamera){const a=this.object.position;n.copy(a).sub(this.target);let h=n.length();h*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*h/s.clientHeight,this.object.matrix),this._panUp(2*e*h/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),a=t-s.left,h=e-s.top,l=s.width,d=s.height;this._mouse.x=a/l*2-1,this._mouse.y=-(h/d)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._rotateStart.set(s,a)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panStart.set(s,a)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyStart.set(0,h)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const s=this._getSecondPointerPosition(t),a=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this._rotateEnd.set(a,h)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panEnd.set(s,a)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyEnd.set(0,h),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const l=(t.pageX+e.x)*.5,d=(t.pageY+e.y)*.5;this._updateZoomParameters(l,d)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e>11,t=L>>5&63,o=L&31,g=Math.round(s/31*255),n=Math.round(t/63*255),c=Math.round(o/31*255);return[g,n,c]}const D={RGB:"color",POSITION:"position"};class Q extends x{constructor(s=w){super(),this.manager=s}parse(s){return super.parse(s).then(async t=>{const{featureTable:o,batchTable:g}=t,n=new G,c=o.header.extensions,l=new P;let a;if(c&&c["3DTILES_draco_point_compression"]){const{byteOffset:e,byteLength:u,properties:i}=c["3DTILES_draco_point_compression"],f=this.manager.getHandler("draco.drc");if(f==null)throw new Error("PNTSLoader: dracoLoader not available.");const b={};for(const p in i)if(p in D&&p in i){const S=D[p];b[S]=i[p]}const N={attributeIDs:b,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},B=o.getBuffer(e,u);a=await f.decodeGeometry(B,N),a.attributes.color&&(n.vertexColors=!0)}else{const e=o.getData("POINTS_LENGTH"),u=o.getData("POSITION",e,"FLOAT","VEC3"),i=o.getData("RGB",e,"UNSIGNED_BYTE","VEC3"),f=o.getData("RGBA",e,"UNSIGNED_BYTE","VEC4"),b=o.getData("RGB565",e,"UNSIGNED_SHORT","SCALAR"),N=o.getData("CONSTANT_RGBA",e,"UNSIGNED_BYTE","VEC4"),B=o.getData("POSITION_QUANTIZED",e,"UNSIGNED_SHORT","VEC3"),p=o.getData("QUANTIZED_VOLUME_SCALE",e,"FLOAT","VEC3"),S=o.getData("QUANTIZED_VOLUME_OFFSET",e,"FLOAT","VEC3");if(a=new R,B){const E=new Float32Array(e*3);for(let r=0;r{e in o.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)});const O=new V(a,n);O.position.copy(l),t.scene=O,t.scene.featureTable=o,t.scene.batchTable=g;const T=o.getData("RTC_CENTER");return T&&(t.scene.position.x+=T[0],t.scene.position.y+=T[1],t.scene.position.z+=T[2]),t})}}export{Q as P}; diff --git a/example/bundle/assets/Pass-inUSP30K.js b/example/bundle/assets/Pass-inUSP30K.js new file mode 100644 index 00000000..e702db7f --- /dev/null +++ b/example/bundle/assets/Pass-inUSP30K.js @@ -0,0 +1 @@ +import{O as r,g as a,ah as i,aw as t}from"./three.module-DpclfMcJ.js";const o=new r(-1,1,1,-1,0,1);class m extends i{constructor(){super(),this.setAttribute("position",new t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new t([0,2,0,0,2,0],2))}}const n=new m;class u{constructor(e){this._mesh=new a(n,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,o)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}export{u as F}; diff --git a/example/bundle/assets/TileCompressionPlugin-Bcbrk_fI.js b/example/bundle/assets/TileCompressionPlugin-Bcbrk_fI.js new file mode 100644 index 00000000..6edd999a --- /dev/null +++ b/example/bundle/assets/TileCompressionPlugin-Bcbrk_fI.js @@ -0,0 +1 @@ +import{k as M,x as w,ai as I,i as z}from"./three.module-DpclfMcJ.js";const S=new M;function A(t,o){if(t.isInterleavedBufferAttribute||t.array instanceof o)return t;const f=o===Int8Array||o===Int16Array||o===Int32Array?-1:0,s=new o(t.count*t.itemSize),y=new I(s,t.itemSize,!0),d=t.itemSize,v=t.count;for(let c=0;c{if(r.material&&s){const a=r.material;for(const n in a){const e=a[n];e&&e.isTexture&&e.generateMipmaps&&(e.generateMipmaps=!1,e.minFilter=w)}}if(r.geometry){const a=r.geometry,n=a.attributes;if(d){const{uv:e,uv1:m,uv2:l,uv3:p}=n;e&&(n.uv=A(e,i)),m&&(n.uv1=A(m,i)),l&&(n.uv2=A(l,i)),p&&(n.uv3=A(p,i))}if(f&&!n.normals&&a.computeVertexNormals(),v&&n.normals&&(n.normals=A(n.normals,u)),c&&B(r,x),y&&a.index){const e=n.position.count,m=a.index,l=e>65535?Uint32Array:e>255?Uint16Array:Uint8Array;if(!(m.array instanceof l)){const p=new l(a.index.count);p.set(m.array);const b=new I(p,1);a.setIndex(b)}}}})}}export{N as T}; diff --git a/example/bundle/assets/TilesFadePlugin-GTJOynw2.js b/example/bundle/assets/TilesFadePlugin-GTJOynw2.js new file mode 100644 index 00000000..15021fd3 --- /dev/null +++ b/example/bundle/assets/TilesFadePlugin-GTJOynw2.js @@ -0,0 +1,47 @@ +import{i as I,k as _,G as b,j as O,Q as D}from"./three.module-DpclfMcJ.js";const{clamp:p}=I;class L{constructor(){this.duration=250,this.fadeCount=0,this._lastTick=-1,this._fadeState=new Map,this._fadeParams=new WeakMap,this.onFadeComplete=null,this.onFadeStart=null,this.onFadeSetComplete=null,this.onFadeSetStart=null}prepareObject(e){e.traverse(a=>{a.material&&this.prepareMaterial(a.material)})}deleteObject(e){if(!e)return;this.completeFade(e);const a=this._fadeParams;e.traverse(i=>{const t=i.material;t&&(a.delete(t),t.onBeforeCompile=()=>{},t.needsUpdate=!0)})}prepareMaterial(e){const a=this._fadeParams;if(a.has(e))return;const i={fadeIn:{value:0},fadeOut:{value:0}};e.defines={FEATURE_FADE:0},e.onBeforeCompile=t=>{t.uniforms={...t.uniforms,...i},t.fragmentShader=t.fragmentShader.replace(/void main\(/,r=>` + #if FEATURE_FADE + + // adapted from https://www.shadertoy.com/view/Mlt3z8 + float bayerDither2x2( vec2 v ) { + + return mod( 3.0 * v.y + 2.0 * v.x, 4.0 ); + + } + + float bayerDither4x4( vec2 v ) { + + vec2 P1 = mod( v, 2.0 ); + vec2 P2 = floor( 0.5 * mod( v, 4.0 ) ); + return 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 ); + + } + + uniform float fadeIn; + uniform float fadeOut; + #endif + + ${r} + `).replace(/#include /,r=>` + + ${r} + + #if FEATURE_FADE + + float bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) ); + float bayerBins = 16.0; + float dither = ( 0.5 + bayerValue ) / bayerBins; + if ( dither >= fadeIn ) { + + discard; + + } + + if ( dither < fadeOut ) { + + discard; + + } + + #endif + + `)},a.set(e,i)}guaranteeState(e){const a=this._fadeState;if(a.has(e))return!1;const i={fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0};a.set(e,i);const t=this._fadeParams;return e.traverse(r=>{const o=r.material;if(o&&t.has(o)){const f=t.get(o);f.fadeIn.value=0,f.fadeOut.value=0}}),!0}completeFade(e){const a=this._fadeState;a.has(e)&&(a.delete(e),e.traverse(i=>{const t=i.material;t&&t.defines.FEATURE_FADE!==0&&(t.defines.FEATURE_FADE=0,t.needsUpdate=!0)}),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(e),this.fadeCount===0&&this.onFadeSetComplete&&this.onFadeSetComplete())}completeAllFades(){this._fadeState.forEach((e,a)=>{this.completeFade(a)})}forEachObject(e){this._fadeState.forEach((a,i)=>e(i))}fadeIn(e){const a=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeInTarget=1,i.fadeOutTarget=0,i.fadeOut=0,a&&(this.fadeCount++,this.fadeCount===1&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}fadeOut(e){const a=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeOutTarget=1,a&&(i.fadeInTarget=1,i.fadeIn=1,this.fadeCount++,this.fadeCount===1&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}update(){const e=window.performance.now();this._lastTick===-1&&(this._lastTick=e);const a=p((e-this._lastTick)/this.duration,0,1);this._lastTick=e;const i=this._fadeState,t=this._fadeParams;i.forEach((r,o)=>{const{fadeOutTarget:f,fadeInTarget:h}=r;let{fadeOut:d,fadeIn:n}=r;const c=Math.sign(h-n);n=p(n+c*a,0,1);const m=Math.sign(f-d);d=p(d+m*a,0,1),r.fadeIn=n,r.fadeOut=d;const u=+(d!==f||n!==h);o.traverse(P=>{const l=P.material;if(l&&t.has(l)){const T=t.get(l);T.fadeIn.value=n,T.fadeOut.value=d,u!==l.defines.FEATURE_FADE&&(l.defines.FEATURE_FADE=u,l.needsUpdate=!0)}}),((d===1||d===0)&&(n===1||n===0)||d>=n)&&this.completeFade(o)})}}const E=Symbol("HAS_POPPED_IN"),F=new _,M=new _,C=new D,S=new D,A=new _;function U(s,e,a){s.visible=!0,a?e.__depthFromRenderedParent===1?((e[E]||this.fadeRootTiles)&&this._fadeManager.fadeIn(s),e[E]=!0):this._fadeManager.fadeIn(s):(this._fadeGroup.add(s),this._fadeManager.fadeOut(s))}function y(s,e){this._fadeManager.prepareObject(s),this._tileMap.set(s,e)}function w(s){this._fadeManager.deleteObject(s),this._tileMap.delete(s)}function x(s){s.parent===this._fadeGroup&&this._fadeGroup.remove(s)}function R(s){this._prevCameraTransforms.set(s,new O)}function G(s){this._prevCameraTransforms.delete(s)}function B(){const s=this._fadeManager,e=this.tiles;this._fadingBefore=s.fadeCount,this._displayActiveTiles=e.displayActiveTiles,e.displayActiveTiles=!0}function k(){const s=this._fadeManager,e=this._fadeGroup,a=this._displayActiveTiles,i=this._fadingBefore,t=this.tiles,r=this._prevCameraTransforms,o=this._tileMap,f=t.lruCache,h=t.cameras;t.displayActiveTiles=a,s.update();const d=s.fadeCount;if(i!==0&&d!==0&&(t.dispatchEvent({type:"fade-change"}),t.dispatchEvent({type:"force-rerender"})),a||t.visibleTiles.forEach(n=>{n.cached.scene.visible=n.__inFrustum}),this.maximumFadeOutTiles{if(!r.has(c))return;const m=c.matrixWorld,u=r.get(c);m.decompose(M,S,A),u.decompose(F,C,A);const v=S.angleTo(C),g=M.distanceTo(F);n=n&&(v>.25||g>.1)}),n&&s.completeAllFades()}h.forEach(n=>{r.get(n).copy(n.matrixWorld)}),s.forEachObject(n=>{f.markUsed(o.get(n))})}class N{get fadeDuration(){return this._fadeManager.duration}set fadeDuration(e){this._fadeManager.duration=Number(e)}get fadingTiles(){return this._fadeManager.fadeCount}constructor(e){e={maximumFadeOutTiles:50,fadeRootTiles:!1,fadeDuration:250,...e},this.name="FADE_TILES_PLUGIN",this.tiles=null,this._fadeManager=new L,this._prevCameraTransforms=null,this._fadeGroup=null,this._tileMap=null,this.maximumFadeOutTiles=e.maximumFadeOutTiles,this.fadeRootTiles=e.fadeRootTiles,this.fadeDuration=e.fadeDuration}init(e){const a=new b;a.name="TilesFadeGroup",e.group.add(a);const i=this._fadeManager;i.onFadeSetStart=()=>{e.dispatchEvent({type:"fade-start"}),e.dispatchEvent({type:"force-rerender"})},i.onFadeSetComplete=()=>{e.dispatchEvent({type:"fade-end"}),e.dispatchEvent({type:"force-rerender"})},i.onFadeComplete=x.bind(this),this.tiles=e,this._fadeManager=i,this._fadeGroup=a,this._tileMap=new Map,this._prevCameraTransforms=new Map,e.cameras.forEach(t=>{this._prevCameraTransforms.set(t,new O)}),e.forEachLoadedModel((t,r)=>{y.call(this,t,r)}),this._onLoadModel=t=>y.call(this,t.scene,t.tile),this._onDisposeModel=t=>w.call(this,t.scene),this._onTileVisibilityChange=t=>U.call(this,t.scene,t.tile,t.visible),this._onAddCamera=t=>R.call(this,t.camera),this._onDeleteCamera=t=>G.call(this,t.camera),this._onUpdateBefore=()=>B.call(this),this._onUpdateAfter=()=>k.call(this),e.addEventListener("load-model",this._onLoadModel),e.addEventListener("dispose-model",this._onDisposeModel),e.addEventListener("tile-visibility-change",this._onTileVisibilityChange),e.addEventListener("add-camera",this._onAddCamera),e.addEventListener("delete-camera",this._onDeleteCamera),e.addEventListener("update-before",this._onUpdateBefore),e.addEventListener("update-after",this._onUpdateAfter)}dispose(){const e=this.tiles;e.removeEventListener("load-model",this._onLoadModel),e.removeEventListener("dispose-model",this._onDisposeModel),e.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),e.removeEventListener("add-camera",this._onAddCamera),e.removeEventListener("delete-camera",this._onDeleteCamera),e.removeEventListener("update-before",this._onUpdateBefore),e.removeEventListener("update-after",this._onUpdateAfter),e.forEachLoadedModel(a=>{this._fadeManager.deleteObject(a),this._tileMap.delete(a),a.visible=!0}),this._fadeGroup.removeFromParent()}}export{N as T}; diff --git a/example/bundle/assets/TilesRenderer-DdUhzUiO.js b/example/bundle/assets/TilesRenderer-DdUhzUiO.js new file mode 100644 index 00000000..ef9f38a3 --- /dev/null +++ b/example/bundle/assets/TilesRenderer-DdUhzUiO.js @@ -0,0 +1 @@ +import{F,a as V,U,b as B,P as $,W as Ae,I as Ie}from"./I3DMLoader-BlebwdUJ.js";import{B as Be}from"./B3DMLoader-B2OeBq6-.js";import{P as Ee}from"./PNTSLoader-BMN5TswI.js";import{C as Ve}from"./CMPTLoader-nLXQ3OXQ.js";import{G as De}from"./GLTFExtensionLoader-TubLlshp.js";import{j as w,G as Oe,an as me,k as y,p as _e,ao as Ne,B as ze,d as qe,aI as We,ba as je,aV as Je,V as ge,aD as O,bb as Ge,L as Qe}from"./three.module-DpclfMcJ.js";import{r as $e}from"./readMagicBytes-Da5ueiou.js";import{E as He}from"./EllipsoidRegion-D6hT1syi.js";import{e as Ye}from"./GLTFLoader-DkJa3Jo5.js";function ne(i){let e;try{e=new URL(i,"http://fakehost.com/")}catch{return null}const t=e.pathname.split("/").pop(),s=t.lastIndexOf(".");return s===-1||s===t.length-1?null:t.substring(s+1)}const ie=2**30;class Xe{get unloadPriorityCallback(){return this._unloadPriorityCallback}set unloadPriorityCallback(e){e.length===1?(console.warn('LRUCache: "unloadPriorityCallback" function has been changed to take two arguments.'),this._unloadPriorityCallback=(t,s)=>{const n=e(t),o=e(s);return no?1:0}):this._unloadPriorityCallback=e}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=.3*ie,this.maxBytesSize=.4*ie,this.unloadPercent=.05,this.autoMarkUnused=!0,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.markUnusedQueued=!1,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this.bytesMap.get(e)??null}add(e,t){this.markUnusedQueued&&this.markAllUnused();const s=this.itemSet;if(s.has(e)||this.isFull())return!1;const n=this.usedSet,o=this.itemList,r=this.callbacks,a=this.bytesMap;o.push(e),n.add(e),s.set(e,Date.now()),r.set(e,t);const l=this.computeMemoryUsageCallback(e);return this.cachedBytes+=l||0,a.set(e,l),!0}has(e){return this.itemSet.has(e)}remove(e){const t=this.usedSet,s=this.itemSet,n=this.itemList,o=this.bytesMap,r=this.callbacks,a=this.loadedSet;if(s.has(e)){this.cachedBytes-=o.get(e)||0,o.delete(e),r.get(e)(e);const l=n.indexOf(e);return n.splice(l,1),t.delete(e),s.delete(e),r.delete(e),a.delete(e),!0}return!1}setLoaded(e,t){const{itemSet:s,loadedSet:n}=this;s.has(e)&&(t===!0?n.add(e):n.delete(e))}updateMemoryUsage(e){const t=this.itemSet,s=this.bytesMap;if(!t.has(e))return;this.cachedBytes-=s.get(e)||0;const n=this.computeMemoryUsageCallback(e);s.set(e,n),this.cachedBytes+=n}markUsed(e){this.markUnusedQueued&&this.markAllUnused();const t=this.itemSet,s=this.usedSet;t.has(e)&&!s.has(e)&&(t.set(e,Date.now()),s.add(e))}markUnused(e){const t=this.usedSet;t.has(e)&&t.delete(e)}markAllUnused(){this.usedSet.clear(),this.markUnusedQueued=!1,this.unloadingHandle!==-1&&(cancelAnimationFrame(this.unloadingHandle),this.unloadingHandle=-1)}unloadUnusedContent(){const{unloadPercent:e,minSize:t,maxSize:s,itemList:n,itemSet:o,usedSet:r,loadedSet:a,callbacks:l,bytesMap:c,minBytesSize:h,maxBytesSize:p}=this,f=n.length-r.size,m=n.length-a.size,d=Math.max(Math.min(n.length-t,f),0),_=this.cachedBytes-h,S=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const A=d>0&&f>0||m&&n.length>s;if(f&&this.cachedBytes>h||m&&this.cachedBytes>p||A){n.sort((b,C)=>{const te=r.has(b),Le=r.has(C);if(te===Le){const se=a.has(b),Fe=a.has(C);return se===Fe?-S(b,C):se?1:-1}else return te?1:-1});const D=Math.max(t*e,d*e),I=Math.ceil(Math.min(D,f,d)),u=Math.max(e*_,e*h),L=Math.min(u,_);let x=0,T=0;for(;this.cachedBytes-T>p||n.length-x>s;){const b=n[x],C=c.get(b)||0;if(r.has(b)&&a.has(b)||this.cachedBytes-T-C=I)break;T+=C,x++}n.splice(0,x).forEach(b=>{this.cachedBytes-=c.get(b)||0,l.get(b)(b),c.delete(b),o.delete(b),l.delete(b),a.delete(b),r.delete(b)}),g=x0}g&&(this.unloadingHandle=requestAnimationFrame(()=>this.scheduleUnload()))}scheduleUnload(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.unloadUnusedContent(),this.autoMarkUnused&&(this.markUnusedQueued=!0)}))}}class oe{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise((s,n)=>{const o=(...l)=>t(...l).then(s).catch(n),r=this.items,a=this.callbacks;r.push(e),a.set(e,o),this.autoUpdate&&this.scheduleJobRun()})}remove(e){const t=this.items,s=this.callbacks,n=t.indexOf(e);n!==-1&&(t.splice(n,1),s.delete(e))}tryRunJobs(){this.sort();const e=this.items,t=this.callbacks,s=this.maxJobs;let n=this.currJobs;for(;s>n&&e.length>0;){n++;const o=e.pop(),r=t.get(o);t.delete(o),r(o).then(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}).catch(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})}this.currJobs=n}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}function K(i){return i===V||i===F}function k(i,e){return i.__lastFrameVisited===e&&i.__used}function ee(i,e){i.__lastFrameVisited!==e.frameCount&&(i.__lastFrameVisited=e.frameCount,i.__used=!1,i.__inFrustum=!1,i.__isLeaf=!1,i.__visible=!1,i.__active=!1,i.__error=1/0,i.__distanceFromCamera=1/0,i.__childrenWereVisible=!1,i.__allChildrenLoaded=!1,i.__inFrustum=e.tileInView(i),e.calculateError(i))}function be(i,e){if(e.ensureChildrenArePreprocessed(i),ee(i,e),Z(i,e),!i.__hasRenderableContent){const t=i.children;for(let s=0,n=t.length;s0&&i.__depth+1>=e.maxDepth)}function xe(i,e=null,t=null,s=null,n=0){if(e&&e(i,s,n)){t&&t(i,s,n);return}const o=i.children;for(let r=0,a=o.length;rr.setTileVisible&&r.setTileVisible(i,n))),i.__wasSetActive=s,i.__wasSetVisible=n,i.__usedLastFrame=t;const o=i.children;for(let r=0,a=o.length;ri.__depthFromRenderedParent!==e.__depthFromRenderedParent?i.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:i.__inFrustum!==e.__inFrustum?i.__inFrustum?1:-1:i.__used!==e.__used?i.__used?1:-1:i.__error!==e.__error?i.__error>e.__error?1:-1:i.__distanceFromCamera!==e.__distanceFromCamera?i.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,Ke=(i,e)=>i.__depthFromRenderedParent!==e.__depthFromRenderedParent?i.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:i.__loadingState!==e.__loadingState?i.__loadingState>e.__loadingState?-1:1:i.__lastFrameVisited!==e.__lastFrameVisited?i.__lastFrameVisited>e.__lastFrameVisited?-1:1:i.__hasUnrenderableContent!==e.__hasUnrenderableContent?i.__hasUnrenderableContent?-1:1:i.__error!==e.__error?i.__error>e.__error?-1:1:0;class et{get root(){const e=this.rootTileSet;return e?e.root:null}set loadSiblings(e){console.warn('TilesRenderer: "loadSiblings" option has been removed.')}set stopAtEmptyTiles(e){console.warn('TilesRenderer: "stopAtEmptyTiles" option has been removed.')}set preprocessURL(e){console.warn('TilesRendererBase: The "preprocessURL" callback has been deprecated. Use a plugin, instead.'),this._preprocessURL=e}get preprocessURL(){return this._preprocessURL}constructor(e=null){this.rootLoadingState=U,this.rootTileSet=null,this.rootURL=e,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this._preprocessURL=null;const t=new Xe;t.unloadPriorityCallback=Ke;const s=new oe;s.maxJobs=10,s.priorityCallback=ae;const n=new oe;n.maxJobs=1,n.priorityCallback=ae,this.lruCache=t,this.downloadQueue=s,this.parseQueue=n,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(e){if(e[re]===!0)throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");const t=this.plugins,s=e.priority||0;let n=0;for(let o=0;os));o++);t.splice(n,0,e),e[re]=!0,e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;if(typeof e=="string"&&(e=this.getPluginByName(name)),t.includes(e)){const s=t.indexOf(e);return t.splice(s,1),e.dispose&&e.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}traverse(e,t){this.root&&xe(this.root,(s,...n)=>(this.ensureChildrenArePreprocessed(s),e?e(s,...n):!1),t)}queueTileForDownload(e){this.queuedTiles.push(e)}update(){const e=this.stats,t=this.lruCache;if(this.rootLoadingState===U&&(this.rootLoadingState=B,this.invokeOnePlugin(o=>o.loadRootTileSet&&o.loadRootTileSet()).then(()=>this.rootLoadingState=V).catch(()=>this.rootLoadingState=F)),!this.root)return;const s=this.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,Se(s,this),ve(s,this),Te(s,this),we(s,this);const n=this.queuedTiles;n.sort(t.unloadPriorityCallback);for(let o=0,r=n.length;o{t.__loadingState===F&&(t.__loadingState=U)}),e.failed=0)}dispose(){this.invokeAllPlugins(s=>{s!==this&&s.dispose&&s.dispose()});const e=this.lruCache,t=[];this.traverse(s=>(t.push(s),!1));for(let s=0,n=t.length;st.setTileVisible&&t.setTileVisible(e,!1)),e.__visible=!1),e.__active&&(this.setTileActive(e,!1),e.__active=!1)}preprocessNode(e,t,s=null){var n;if(e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=s,e.children=e.children||[],(n=e.content)!=null&&n.uri){const o=ne(e.content.uri);e.__hasContent=!0,e.__hasUnrenderableContent=!!(o&&/json$/.test(o)),e.__hasRenderableContent=!e.__hasUnrenderableContent}else e.__hasContent=!1,e.__hasUnrenderableContent=!1,e.__hasRenderableContent=!1;e.__distanceFromCamera=1/0,e.__error=1/0,e.__inFrustum=!1,e.__isLeaf=!1,e.__usedLastFrame=!1,e.__used=!1,e.__wasSetVisible=!1,e.__visible=!1,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1,e.__wasSetActive=!1,e.__active=!1,e.__loadingState=U,e.__loadIndex=0,e.__loadAbort=null,s===null?(e.__depth=0,e.__depthFromRenderedParent=0,e.refine=e.refine||"REPLACE"):(e.__depth=s.__depth+1,e.__depthFromRenderedParent=s.__depthFromRenderedParent+(e.__hasRenderableContent?1:0),e.refine=e.refine||s.refine),e.__basePath=t,e.__lastFrameVisited=-1,this.invokeAllPlugins(o=>{o!==this&&o.preprocessNode&&o.preprocessNode(e,t,s)})}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}ensureChildrenArePreprocessed(e){const t=e.children;for(let s=0,n=t.length;sparseInt(l));console.assert(o<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),o===1&&r>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=t.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(e.root,a,s)}loadRootTileSet(){let e=this.rootURL;this.invokeAllPlugins(s=>e=s.preprocessURL?s.preprocessURL(e,null):e);const t=this.invokeOnePlugin(s=>s.fetchData&&s.fetchData(e,this.fetchOptions)).then(s=>{if(s.ok)return s.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${s.status} : ${s.statusText}`)}).then(s=>{this.preprocessTileSet(s,e),this.rootTileSet=s});return t.catch(s=>{console.error(s),this.rootTileSet=null}),t}requestTileContents(e){if(e.__loadingState!==U)return;let t=!1,s=new URL(e.content.uri,e.__basePath+"/").toString();this.invokeAllPlugins(d=>s=d.preprocessURL?d.preprocessURL(s,e):s);const n=this.stats,o=this.lruCache,r=this.downloadQueue,a=this.parseQueue,l=ne(s);if(!o.add(e,d=>{d.__loadingState===B?(d.__loadAbort.abort(),d.__loadAbort=null):t?d.children.length=0:this.invokeAllPlugins(_=>{_.disposeTile&&_.disposeTile(d)}),d.__loadingState===B?n.downloading--:d.__loadingState===$&&n.parsing--,d.__loadingState=U,d.__loadIndex++,a.remove(d),r.remove(d)}))return;e.__loadIndex++;const h=e.__loadIndex,p=new AbortController,f=p.signal;n.downloading++,e.__loadAbort=p,e.__loadingState=B;const m=d=>{e.__loadIndex===h&&(d.name!=="AbortError"?(a.remove(e),r.remove(e),e.__loadingState===$?n.parsing--:e.__loadingState===B&&n.downloading--,n.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(d),e.__loadingState=F,o.setLoaded(e,!0)):o.remove(e))};return r.add(e,d=>d.__loadIndex!==h?Promise.resolve():this.invokeOnePlugin(_=>_.fetchData&&_.fetchData(s,{...this.fetchOptions,signal:f}))).then(d=>{if(e.__loadIndex===h){if(d.ok)return l==="json"?d.json():d.arrayBuffer();throw new Error(`Failed to load model with error code ${d.status}`)}}).then(d=>{if(e.__loadIndex===h)return n.downloading--,n.parsing++,e.__loadAbort=null,e.__loadingState=$,a.add(e,_=>_.__loadIndex!==h?Promise.resolve():l==="json"&&d.root?(this.preprocessTileSet(d,s,e),e.children.push(d.root),t=!0,Promise.resolve()):this.invokeOnePlugin(S=>S.parseTile&&S.parseTile(d,_,l,s)))}).then(()=>{e.__loadIndex===h&&(n.parsing--,e.__loadingState=V,o.setLoaded(e,!0),o.getMemoryUsage(e)===null&&(o.isFull()&&o.computeMemoryUsageCallback(e)>0?o.remove(e):o.updateMemoryUsage(e)))}).catch(m)}getAttributions(e=[]){return this.invokeAllPlugins(t=>t!==this&&t.getAttributions&&t.getAttributions(e)),e}invokeOnePlugin(e){const t=[...this.plugins,this];for(let s=0;sNumber.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(N);const o=this.children;for(let r=0,a=o.length;r{Object.getPrototypeOf(o).raycast.call(o,e,s)}):t.invokeOnePlugin(r=>r.raycastTile&&r.raycastTile(i,n,e,s))||e.intersectObject(n,!0,s)}function nt(i,e,t){Re(i,e,t,z),z.sort(Pe);const s=z[0]||null;return z.length=0,s}function Me(i,e,t,s=null){const{group:n,activeTiles:o}=i;i.ensureChildrenArePreprocessed(e),s===null&&(s=Ce,G.copy(n.matrixWorld).invert(),s.copy(t.ray).applyMatrix4(G));const r=[],a=e.children;for(let h=0,p=a.length;hc)break;const _=Me(i,d,t,s);if(_){const S=_.distance*_.distance;Snew y),this.planes=new Array(6).fill().map(()=>new Ne)}clampPoint(e,t){return t.copy(e).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(e){return this.clampPoint(e,v).distanceTo(e)}containsPoint(e){return v.copy(e).applyMatrix4(this.inverseTransform),this.box.containsPoint(v)}intersectsRay(e){return j.copy(e).applyMatrix4(this.inverseTransform),j.intersectsBox(this.box)}intersectRay(e,t){return j.copy(e).applyMatrix4(this.inverseTransform),j.intersectBox(this.box,t)?(t.applyMatrix4(this.transform),t):null}update(){const{points:e,inverseTransform:t,transform:s,box:n}=this;t.copy(s).invert();const{min:o,max:r}=n;let a=0;for(let l=-1;l<=1;l+=2)for(let c=-1;c<=1;c+=2)for(let h=-1;h<=1;h+=2)e[a].set(l<0?o.x:r.x,c<0?o.y:r.y,h<0?o.z:r.z).applyMatrix4(s),a++;this.updatePlanes()}updatePlanes(){q.copy(this.box.min).applyMatrix4(this.transform),W.copy(this.box.max).applyMatrix4(this.transform),v.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(v,q),this.planes[1].setFromNormalAndCoplanarPoint(v,W).negate(),v.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(v,q),this.planes[3].setFromNormalAndCoplanarPoint(v,W).negate(),v.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(v,q),this.planes[5].setFromNormalAndCoplanarPoint(v,W).negate()}intersectsFrustum(e){const{points:t}=this,{planes:s}=e;for(let n=0;n<6;n++){const o=s[n];let r=-1/0;for(let a=0;a<8;a++){const l=t[a],c=o.distanceToPoint(l);r=ro?n:o}intersectsFrustum(e){const t=this.obb||this.regionObb,s=this.sphere;return s&&!e.intersectsSphere(s)||t&&!t.intersectsFrustum(e)?!1:!!(s||t)}getOBB(e,t){const s=this.obb||this.regionObb;s?(e.copy(s.box),t.copy(s.transform)):(this.getAABB(e),t.identity())}getAABB(e){if(this.sphere)this.sphere.getBoundingBox(e);else{const t=this.obb||this.regionObb;e.copy(t.box).applyMatrix4(t.transform)}}getSphere(e){if(this.sphere)e.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(e);else{const t=this.obb||this.regionObb;t.box.getBoundingSphere(e),e.applyMatrix4(t.transform)}}setObbData(e,t){const s=new le;P.set(e[3],e[4],e[5]),R.set(e[6],e[7],e[8]),M.set(e[9],e[10],e[11]);const n=P.length(),o=R.length(),r=M.length();P.normalize(),R.normalize(),M.normalize(),n===0&&P.crossVectors(R,M),o===0&&R.crossVectors(P,M),r===0&&M.crossVectors(P,R),s.transform.set(P.x,R.x,M.x,e[0],P.y,R.y,M.y,e[1],P.z,R.z,M.z,e[2],0,0,0,1).premultiply(t),s.box.min.set(-n,-o,-r),s.box.max.set(n,o,r),s.update(),this.obb=s}setSphereData(e,t,s,n,o){const r=new qe;r.center.set(e,t,s),r.radius=n,r.applyMatrix4(o),this.sphere=r}setRegionData(e,t,s,n,o,r,a){const l=new He(...e.radius,s,o,t,n,r,a),c=new le;l.getBoundingBox(c.box,c.transform),c.update(),this.region=l,this.regionObb=c}}const ot=new We;function rt(i,e,t,s){const n=ot.set(i.normal.x,i.normal.y,i.normal.z,e.normal.x,e.normal.y,e.normal.z,t.normal.x,t.normal.y,t.normal.z);return s.set(-i.constant,-e.constant,-t.constant),s.applyMatrix3(n.invert()),s}class at extends je{constructor(){super(),this.points=Array(8).fill().map(()=>new y)}setFromProjectionMatrix(e,t){super.setFromProjectionMatrix(e,t),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:e,points:t}=this;[[e[0],e[3],e[4]],[e[1],e[3],e[4]],[e[0],e[2],e[4]],[e[1],e[2],e[4]],[e[0],e[3],e[5]],[e[1],e[3],e[5]],[e[0],e[2],e[5]],[e[1],e[2],e[5]]].forEach((n,o)=>{rt(n[0],n[1],n[2],t[o])})}}function lt(i){const{TextureUtils:e}=Je;if(!e)return 0;const t=new Set;let s=0;return i.traverse(n=>{if(n.geometry&&!t.has(n.geometry)&&(s+=Ye(n.geometry),t.add(n.geometry)),n.material){const o=n.material;for(const r in o){const a=o[r];if(a&&a.isTexture&&!t.has(a)){const{format:l,type:c,image:h}=a,{width:p,height:f}=h,m=e.getByteLength(p,f,l,c);s+=a.generateMipmaps?m*4/3:m,t.add(a)}}}}),s}const de=new w,ue=new Ge,fe=parseInt(_e)<165,Ue=Symbol("INITIAL_FRUSTUM_CULLED"),J=new w,Y=new w,E=new y,X=new ge,ct=new y(1,0,0),ht=new y(0,1,0);function pe(i,e){i.traverse(t=>{t.frustumCulled=t[Ue]&&e})}class dt extends et{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel(t=>{pe(t,!e)}))}constructor(...e){super(...e),this.group=new tt(this),this.ellipsoid=Ae.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this.optimizeRaycast=!0,this._upRotationMatrix=new w,this.lruCache.computeMemoryUsageCallback=s=>s.cached.bytesUsed??null,this._autoDisableRendererCulling=!0,this._loadingTiles=!1;const t=new Qe;if(t.setURLModifier(s=>this.preprocessURL?this.preprocessURL(s):s),this.manager=t,this._listeners={},fe){const s=this;this._overridenRaycast=function(n,o){s.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,n,o)}}}addEventListener(...e){O.prototype.addEventListener.call(this,...e)}hasEventListener(...e){O.prototype.hasEventListener.call(this,...e)}removeEventListener(...e){O.prototype.removeEventListener.call(this,...e)}dispatchEvent(...e){O.prototype.dispatchEvent.call(this,...e)}getBounds(...e){return console.warn("TilesRenderer: getBounds has been renamed to getBoundingBox."),this.getBoundingBox(...e)}getOrientedBounds(...e){return console.warn("TilesRenderer: getOrientedBounds has been renamed to getOrientedBoundingBox."),this.getOrientedBoundingBox(...e)}getBoundingBox(e){if(!this.root)return!1;const t=this.root.cached.boundingVolume;return t?(t.getAABB(e),!0):!1}getOrientedBoundingBox(e,t){if(!this.root)return!1;const s=this.root.cached.boundingVolume;return s?(s.getOBB(e,t),!0):!1}getBoundingSphere(e){if(!this.root)return!1;const t=this.root.cached.boundingVolume;return t?(t.getSphere(e),!0):!1}forEachLoadedModel(e){this.traverse(t=>{const s=t.cached.scene;s&&e(s,t)})}raycast(e,t){if(this.root)if(e.firstHitOnly){const s=Me(this,this.root,e);s&&t.push(s)}else ke(this,this.root,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){const t=this.cameras,s=this.cameraMap;return s.has(e)?!1:(s.set(e,new ge),t.push(e),this.dispatchEvent({type:"add-camera",camera:e}),!0)}setResolution(e,t,s){const n=this.cameraMap;if(!n.has(e))return!1;const o=t.isVector2?t.x:t,r=t.isVector2?t.y:s,a=n.get(e);return(a.width!==o||a.height!==r)&&(a.set(o,r),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(e,t){return t.getSize(X).multiplyScalar(t.getPixelRatio()),this.setResolution(e,X.x,X.y)}deleteCamera(e){const t=this.cameras,s=this.cameraMap;if(s.has(e)){const n=t.indexOf(e);return t.splice(n,1),s.delete(e),this.dispatchEvent({type:"delete-camera",camera:e}),!0}return!1}preprocessTileSet(e,t,s){super.preprocessTileSet(e,t,s),queueMicrotask(()=>{this.dispatchEvent({type:"load-tile-set",tileSet:e,url:t})})}loadRootTileSet(...e){return super.loadRootTileSet(...e).then(()=>{switch((this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(ht,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(ct,Math.PI/2);break}this.dispatchEvent({type:"load-content"})})}update(){let e=null;if(this.invokeAllPlugins(r=>{if(r.doTilesNeedUpdate){const a=r.doTilesNeedUpdate();e=e===null?a:e||a}}),e===!1){this.dispatchEvent({type:"update-before"}),this.dispatchEvent({type:"update-after"});return}this.dispatchEvent({type:"update-before"});const t=this.group,s=this.cameras,n=this.cameraMap,o=this.cameraInfo;if(s.length===0){console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");return}for(;o.length>s.length;)o.pop();for(;o.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let r=0,a=o.length;rL.scene);break}case"gltf":case"glb":{const u=new De(c);u.workingPath=a,u.fetchOptions=l,p=u.parse(e);break}default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),p=Promise.resolve(null);break}const _=this.stats;this._loadingTiles===!1&&_.parsing+_.downloading>0&&(this.dispatchEvent({type:"tiles-load-start"}),this._loadingTiles=!0);const S=await p;let g,A;if(S.isObject3D?(g=S,A=null):(g=S.scene,A=S),await this.invokeAllPlugins(u=>u.processTileModel&&u.processTileModel(g,t)),o._loadIndex!==h)return;g.updateMatrix(),(d==="glb"||d==="gltf")&&g.matrix.multiply(m),g.matrix.premultiply(f),g.matrix.decompose(g.position,g.quaternion,g.scale),g.traverse(u=>{u[Ue]=u.frustumCulled}),pe(g,!this.autoDisableRendererCulling),fe&&g.traverse(u=>{u.raycast=this._overridenRaycast});const Q=[],D=[],I=[];g.traverse(u=>{if(u.geometry&&D.push(u.geometry),u.material){const L=u.material;Q.push(u.material);for(const x in L){const T=L[x];T&&T.isTexture&&I.push(T)}}}),o.materials=Q,o.geometry=D,o.textures=I,o.scene=g,o.metadata=A,o.bytesUsed=lt(g),this.dispatchEvent({type:"load-model",scene:g,tile:t}),this._loadingTiles===!0&&_.parsing+_.downloading===1&&(this.dispatchEvent({type:"tiles-load-end"}),this._loadingTiles=!1)}disposeTile(e){super.disposeTile(e);const t=e.cached;if(t.scene){const s=t.materials,n=t.geometry,o=t.textures,r=t.scene.parent;t.scene.traverse(a=>{a.userData.meshFeatures&&a.userData.meshFeatures.dispose(),a.userData.structuralMetadata&&a.userData.structuralMetadata.dispose()});for(let a=0,l=n.length;a{const t=Symbol(i);Object.defineProperty(dt.prototype,i,{get(){return this[t]||null},set(s){console.warn(`TilesRenderer: "${i}" has been deprecated in favor of the "${e}" event.`),this[t]&&this.removeEventListener(e,this[t]),this[t]=s,this.addEventListener(e,s)}})});export{oe as P,dt as T,xe as t}; diff --git a/example/bundle/assets/UpdateOnChangePlugin-BFotcVNs.js b/example/bundle/assets/UpdateOnChangePlugin-BFotcVNs.js new file mode 100644 index 00000000..7f20ee1a --- /dev/null +++ b/example/bundle/assets/UpdateOnChangePlugin-BFotcVNs.js @@ -0,0 +1 @@ +import{j as r}from"./three.module-DpclfMcJ.js";const a=new r;class l{constructor(){this.name="UPDATE_ON_CHANGE_PLUGIN",this.tiles=null,this.needsUpdate=!1,this.cameraMatrices=new Map}init(e){this.tiles=e,this._needsUpdateCallback=()=>{this.needsUpdate=!0},this._onCameraAdd=({camera:t})=>{this.needsUpdate=!0,this.cameraMatrices.set(t,new r)},this._onCameraDelete=({camera:t})=>{this.needsUpdate=!0,this.cameraMatrices.delete(t)},e.addEventListener("camera-resolution-change",this._needsUpdateCallback),e.addEventListener("load-content",this._needsUpdateCallback),e.addEventListener("add-camera",this._onCameraAdd),e.addEventListener("delete-camera",this._onCameraDelete),e.cameras.forEach(t=>{this._onCameraAdd({camera:t})})}doTilesNeedUpdate(){const e=this.tiles;let t=!1;this.cameraMatrices.forEach((s,n)=>{a.copy(e.group.matrixWorld).premultiply(n.matrixWorldInverse).premultiply(n.projectionMatrixInverse),t=t||!a.equals(s),s.copy(a)});const d=this.needsUpdate;return this.needsUpdate=!1,d||t}dispose(){const e=this.tiles;e.removeEventListener("camera-resolution-change",this._needsUpdateCallback),e.removeEventListener("content-load",this._needsUpdateCallback),e.removeEventListener("camera-add",this._onCameraAdd),e.removeEventListener("camera-delete",this._onCameraDelete)}}export{l as U}; diff --git a/example/bundle/assets/b3dmExample-7XiMw09T.js b/example/bundle/assets/b3dmExample-7XiMw09T.js new file mode 100644 index 00000000..48252ac9 --- /dev/null +++ b/example/bundle/assets/b3dmExample-7XiMw09T.js @@ -0,0 +1,20 @@ +import{S as M,W as D,P as L,a as T,D as P,A as R,G as F,b as _,C as A,U as E,B as H,c as I,R as W,V as j}from"./three.module-DpclfMcJ.js";import{O as G}from"./OrbitControls-DEr5g9Mg.js";import{B as z}from"./B3DMLoader-B2OeBq6-.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";let s,m,c,t,f,r,b,a,d,u;$();C();function O(i){const e={...i};return e.uniforms={highlightedBatchId:{value:-1},highlightColor:{value:new A(16761095).convertSRGBToLinear()},...E.clone(i.uniforms)},e.extensions={derivatives:!0},e.lights=!0,e.vertexShader=` + attribute float _batchid; + varying float batchid; + `+e.vertexShader.replace(/#include /,` + #include + batchid = _batchid; + `),e.fragmentShader=` + varying float batchid; + uniform float highlightedBatchId; + uniform vec3 highlightColor; + `+e.fragmentShader.replace(/vec4 diffuseColor = vec4\( diffuse, opacity \);/,` + vec4 diffuseColor = + abs( batchid - highlightedBatchId ) < 0.5 ? + vec4( highlightColor, opacity ) : + vec4( diffuse, opacity ); + `),e}function $(){u=document.getElementById("info"),c=new M,t=new D({antialias:!0}),t.setPixelRatio(window.devicePixelRatio),t.setSize(window.innerWidth,window.innerHeight),t.setClearColor(1383455),t.shadowMap.enabled=!0,t.shadowMap.type=L,document.body.appendChild(t.domElement),s=new T(60,window.innerWidth/window.innerHeight,1,4e3),s.position.set(400,400,400),m=new G(s,t.domElement),m.screenSpacePanning=!1,m.minDistance=1,m.maxDistance=2e3,r=new P(16777215,1.25),r.position.set(1,2,3).multiplyScalar(40),r.castShadow=!0,r.shadow.bias=-.01,r.shadow.mapSize.setScalar(2048);const i=r.shadow.camera;i.left=-200,i.bottom=-200,i.right=200,i.top=200,i.updateProjectionMatrix(),c.add(r);const e=new R(16777215,.05);c.add(e),f=new F,c.add(f),new z().loadAsync("https://raw.githubusercontent.com/CesiumGS/cesium/main/Apps/SampleData/Cesium3DTiles/Hierarchy/BatchTableHierarchy/tile.b3dm").then(h=>{console.log(h),d=h.scene,f.add(d);const n=new H;n.setFromObject(d),n.getCenter(f.position).multiplyScalar(-1),d.traverse(o=>{o.isMesh&&(o.material=new _(O(I.standard)))})}),b=new W,a=new j,y(),window.addEventListener("resize",y,!1),t.domElement.addEventListener("mousemove",U,!1)}function U(i){const e=this.getBoundingClientRect();a.x=i.clientX-e.x,a.y=i.clientY-e.y,a.x=a.x/e.width*2-1,a.y=-(a.y/e.height)*2+1,b.setFromCamera(a,s);const h=b.intersectObject(c,!0);let n=-1;if(h.length){const{face:o,object:p}=h[0],v=p.geometry.getAttribute("_batchid");if(v){let l=p;for(;!l.batchTable;)l=l.parent;const B=l.batchTable;n=v.getX(o.a);const w=B.getDataFromId(n);u.innerText=`_batchid : ${n} +Area : ${w.height.toFixed(3)} +Height : ${w.height.toFixed(3)} +`;const g=w["3DTILES_batch_table_hierarchy"];for(const x in g)for(const S in g[x])u.innerText+=`${S} : ${g[x][S]} +`}}else u.innerText="";d&&d.traverse(o=>{o.isMesh&&(o.material.uniforms.highlightedBatchId.value=n)})}function y(){s.aspect=window.innerWidth/window.innerHeight,t.setPixelRatio(window.devicePixelRatio),t.setSize(window.innerWidth,window.innerHeight),s.updateProjectionMatrix()}function C(){requestAnimationFrame(C),V()}function V(){t.render(c,s)} diff --git a/example/bundle/assets/basic-C9vnuZ4H.js b/example/bundle/assets/basic-C9vnuZ4H.js new file mode 100644 index 00000000..74b7fb39 --- /dev/null +++ b/example/bundle/assets/basic-C9vnuZ4H.js @@ -0,0 +1,217 @@ +import{i as j,b as k,U as I,az as E,aA as F,aB as B,aC as z,C as A}from"./three.module-DpclfMcJ.js";import{r as c,e as O,u as b,_ as U,c as P,j as n,C as N,T as G,a as L,E as V,b as $}from"./CameraControls-DhgPIfmg.js";import{T as H}from"./TilesFadePlugin-GTJOynw2.js";import{u as w,G as K,a as W}from"./GizmoViewport-BC-gHgu9.js";import"./EnvironmentControls-C8X7oAWq.js";import"./GlobeControls-BUn2ddB7.js";import"./Ellipsoid-Cnb0UTwk.js";import"./TilesRenderer-DdUhzUiO.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";function X(m,t,i,e){const s=class extends k{constructor(v={}){const f=Object.entries(m);super({uniforms:f.reduce((l,[u,x])=>{const d=I.clone({[u]:{value:x}});return{...l,...d}},{}),vertexShader:t,fragmentShader:i}),this.key="",f.forEach(([l])=>Object.defineProperty(this,l,{get:()=>this.uniforms[l].value,set:u=>this.uniforms[l].value=u})),Object.assign(this,v)}};return s.key=j.generateUUID(),s}const Y=X({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class q extends z{constructor(t=6,i=!1){super(),this.uniforms={chromaticAberration:{value:.05},transmission:{value:0},_transmission:{value:1},transmissionMap:{value:null},roughness:{value:0},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:1/0},attenuationColor:{value:new A("white")},anisotropicBlur:{value:.1},time:{value:0},distortion:{value:0},distortionScale:{value:.5},temporalDistortion:{value:0},buffer:{value:null}},this.onBeforeCompile=e=>{e.uniforms={...e.uniforms,...this.uniforms},this.anisotropy>0&&(e.defines.USE_ANISOTROPY=""),i?e.defines.USE_SAMPLER="":e.defines.USE_TRANSMISSION="",e.fragmentShader=` + uniform float chromaticAberration; + uniform float anisotropicBlur; + uniform float time; + uniform float distortion; + uniform float distortionScale; + uniform float temporalDistortion; + uniform sampler2D buffer; + + vec3 random3(vec3 c) { + float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); + vec3 r; + r.z = fract(512.0*j); + j *= .125; + r.x = fract(512.0*j); + j *= .125; + r.y = fract(512.0*j); + return r-0.5; + } + + uint hash( uint x ) { + x += ( x << 10u ); + x ^= ( x >> 6u ); + x += ( x << 3u ); + x ^= ( x >> 11u ); + x += ( x << 15u ); + return x; + } + + // Compound versions of the hashing algorithm I whipped together. + uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); } + uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); } + uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); } + + // Construct a float with half-open range [0:1] using low 23 bits. + // All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0. + float floatConstruct( uint m ) { + const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask + const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32 + m &= ieeeMantissa; // Keep only mantissa bits (fractional part) + m |= ieeeOne; // Add fractional part to 1.0 + float f = uintBitsToFloat( m ); // Range [1:2] + return f - 1.0; // Range [0:1] + } + + // Pseudo-random value in half-open range [0:1]. + float randomBase( float x ) { return floatConstruct(hash(floatBitsToUint(x))); } + float randomBase( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); } + float randomBase( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); } + float randomBase( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); } + float rand(float seed) { + float result = randomBase(vec3(gl_FragCoord.xy, seed)); + return result; + } + + const float F3 = 0.3333333; + const float G3 = 0.1666667; + + float snoise(vec3 p) { + vec3 s = floor(p + dot(p, vec3(F3))); + vec3 x = p - s + dot(s, vec3(G3)); + vec3 e = step(vec3(0.0), x - x.yzx); + vec3 i1 = e*(1.0 - e.zxy); + vec3 i2 = 1.0 - e.zxy*(1.0 - e); + vec3 x1 = x - i1 + G3; + vec3 x2 = x - i2 + 2.0*G3; + vec3 x3 = x - 1.0 + 3.0*G3; + vec4 w, d; + w.x = dot(x, x); + w.y = dot(x1, x1); + w.z = dot(x2, x2); + w.w = dot(x3, x3); + w = max(0.6 - w, 0.0); + d.x = dot(random3(s), x); + d.y = dot(random3(s + i1), x1); + d.z = dot(random3(s + i2), x2); + d.w = dot(random3(s + 1.0), x3); + w *= w; + w *= w; + d *= w; + return dot(d, vec4(52.0)); + } + + float snoiseFractal(vec3 m) { + return 0.5333333* snoise(m) + +0.2666667* snoise(2.0*m) + +0.1333333* snoise(4.0*m) + +0.0666667* snoise(8.0*m); + } +`+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include ",` + #ifdef USE_TRANSMISSION + // Transmission code is based on glTF-Sampler-Viewer + // https://github.com/KhronosGroup/glTF-Sample-Viewer + 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; + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + // Direction of refracted light. + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + // Compute rotation-independant scaling of the model matrix. + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + // The thickness is specified in local space. + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and + // an IOR of 1.5 results in the default amount of microfacet refraction. + 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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + #ifdef USE_SAMPLER + #ifdef texture2DLodEXT + return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod); + #else + return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod); + #endif + #else + return texture2D(buffer, fragCoord.xy); + #endif + } + vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + // Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all. + return radiance; + } else { + // Compute light attenuation using Beer's law. + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law + 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; + // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + // Sample framebuffer to get pixel the refracted ray hits. + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); + // Get the specular component. + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); + } + #endif +`),e.fragmentShader=e.fragmentShader.replace("#include ",` + // Improve the refraction to use the world pos + material.transmission = _transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vUv ).g; + #endif + + vec3 pos = vWorldPosition; + float runningSeed = 0.0; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec3 transmission = vec3(0.0); + float transmissionR, transmissionB, transmissionG; + float randomCoords = rand(runningSeed++); + float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur); + vec3 distortionNormal = vec3(0.0); + vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion; + if (distortion > 0.0) { + distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset))); + } + for (float i = 0.0; i < ${t}.0; i ++) { + vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5)) * pow(rand(runningSeed++), 0.33) + distortionNormal); + transmissionR = getIBLVolumeRefraction( + sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${t}), + material.attenuationColor, material.attenuationDistance + ).r; + transmissionG = getIBLVolumeRefraction( + sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${t})) , material.thickness + thickness_smear * (i + randomCoords) / float(${t}), + material.attenuationColor, material.attenuationDistance + ).g; + transmissionB = getIBLVolumeRefraction( + sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${t})), material.thickness + thickness_smear * (i + randomCoords) / float(${t}), + material.attenuationColor, material.attenuationDistance + ).b; + transmission.r += transmissionR; + transmission.g += transmissionG; + transmission.b += transmissionB; + } + transmission /= ${t}.0; + totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); +`)},Object.keys(this.uniforms).forEach(e=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:s=>this.uniforms[e].value=s}))}}const J=c.forwardRef(({buffer:m,transmissionSampler:t=!1,backside:i=!1,side:e=E,transmission:s=1,thickness:h=0,backsideThickness:v=0,backsideEnvMapIntensity:f=1,samples:l=10,resolution:u,backsideResolution:x,background:d,anisotropy:T,anisotropicBlur:g,...D},R)=>{O({MeshTransmissionMaterial:q});const r=c.useRef(null),[_]=c.useState(()=>new Y),M=w(x||u),p=w(u);let S,C,y,a;return b(o=>{r.current.time=o.clock.getElapsedTime(),r.current.buffer===p.texture&&!t&&(a=r.current.__r3f.parent,a&&(y=o.gl.toneMapping,S=o.scene.background,C=r.current.envMapIntensity,o.gl.toneMapping=F,d&&(o.scene.background=d),a.material=_,i&&(o.gl.setRenderTarget(M),o.gl.render(o.scene,o.camera),a.material=r.current,a.material.buffer=M.texture,a.material.thickness=v,a.material.side=B,a.material.envMapIntensity=f),o.gl.setRenderTarget(p),o.gl.render(o.scene,o.camera),a.material=r.current,a.material.thickness=h,a.material.side=e,a.material.buffer=p.texture,a.material.envMapIntensity=C,o.scene.background=S,o.gl.setRenderTarget(null),o.gl.toneMapping=y))}),c.useImperativeHandle(R,()=>r.current,[]),c.createElement("meshTransmissionMaterial",U({args:[l,t],ref:r},D,{buffer:m||p.texture,_transmission:s,anisotropicBlur:g??T,transmission:t?s:0,thickness:h,side:e}))}),Q="https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json";function Z(m){const t=c.useRef();return b(()=>{const i=t.current;i.rotation.x=Math.sin(window.performance.now()*5e-4)*2,i.rotation.y=Math.cos(window.performance.now()*.0015)}),n.jsxs("mesh",{...m,ref:t,children:[n.jsx("icosahedronGeometry",{}),n.jsx(J,{thickness:1.5,chromaticAberration:.25,color:8445674})]})}function ee(){return n.jsxs(N,{camera:{position:[12,7.5,12]},style:{width:"100%",height:"100%",position:"absolute",margin:0,left:0,top:0},children:[n.jsx("group",{"rotation-x":Math.PI/2,children:n.jsxs(G,{url:Q,children:[n.jsx(L,{plugin:H,fadeDuration:500}),n.jsx(Z,{position:[0,-4,-4],scale:2})]})}),n.jsx(V,{enableDamping:!0,maxDistance:50}),n.jsx($,{preset:"sunset",background:!0,backgroundBlurriness:.9,environmentIntensity:1}),n.jsx(K,{alignment:"bottom-right",children:n.jsx(W,{})})]})}P(document.getElementById("root")).render(n.jsx(c.StrictMode,{children:n.jsx(ee,{})})); diff --git a/example/bundle/assets/cmptExample-CwH8FrcN.js b/example/bundle/assets/cmptExample-CwH8FrcN.js new file mode 100644 index 00000000..24fd7db0 --- /dev/null +++ b/example/bundle/assets/cmptExample-CwH8FrcN.js @@ -0,0 +1 @@ +import{S as m,W as c,P as l,a as p,D as f,A as h}from"./three.module-DpclfMcJ.js";import{O as u}from"./OrbitControls-DEr5g9Mg.js";import{C as g}from"./CMPTLoader-nLXQ3OXQ.js";import"./LoaderBase-CVSPpjX2.js";import"./readMagicBytes-Da5ueiou.js";import"./B3DMLoader-B2OeBq6-.js";import"./GLTFLoader-DkJa3Jo5.js";import"./PNTSLoader-BMN5TswI.js";import"./I3DMLoader-BlebwdUJ.js";import"./Ellipsoid-Cnb0UTwk.js";let n,o,a,e,i;P();d();function P(){a=new m,e=new c({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=l,document.body.appendChild(e.domElement),n=new p(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(400,400,400),o=new u(n,e.domElement),o.screenSpacePanning=!1,o.minDistance=1,o.maxDistance=2e3,i=new f(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const t=i.shadow.camera;t.left=-200,t.bottom=-200,t.right=200,t.top=200,t.updateProjectionMatrix(),a.add(i);const s=new h(16777215,.05);a.add(s),new g().loadAsync("...").then(w=>{console.log(w)}),r(),window.addEventListener("resize",r,!1)}function r(){n.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix()}function d(){requestAnimationFrame(d),S()}function S(){e.render(a,n)} diff --git a/example/bundle/assets/customMaterial-DZXs5hhp.js b/example/bundle/assets/customMaterial-DZXs5hhp.js new file mode 100644 index 00000000..5d5b9b8d --- /dev/null +++ b/example/bundle/assets/customMaterial-DZXs5hhp.js @@ -0,0 +1,70 @@ +import{S as k,W as F,P as L,a as R,O as z,D as E,A as T,G as W,M as I,b as v,B as V,d as G}from"./three.module-DpclfMcJ.js";import{O as H}from"./OrbitControls-DEr5g9Mg.js";import{g as A}from"./lil-gui.module.min-Bc0DeA9g.js";import{S as D}from"./stats.module--VATS4Kh.js";import{T as N}from"./TilesRenderer-DdUhzUiO.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";let n,c,p,o,t,a,m,h,f,d,s,w;const g=0,x=1,y=2,S=3,l={material:g,orthographic:!1,rebuild:M},O={vertexShader:` + varying vec3 wPosition; + void main() { + + #include + #include + wPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz; + + } + `,fragmentShader:` + varying vec3 wPosition; + void main() { + + float minVal = - 30.0; + float maxVal = 30.0; + + float val = ( wPosition.y - minVal ) / ( maxVal - minVal ); + + vec4 color1 = vec4( 0.149, 0.196, 0.219, 1.0 ) * 0.5; + vec4 color2 = vec4( 1.0 ); + + gl_FragColor = mix( color1, color2, val ); + + } + `},_={extensions:{derivatives:!0},vertexShader:` + varying vec3 wPosition; + varying vec3 vViewPosition; + void main() { + + #include + #include + wPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz; + vViewPosition = - mvPosition.xyz; + + } + `,fragmentShader:` + varying vec3 wPosition; + varying vec3 vViewPosition; + void main() { + + // lighting + vec3 fdx = vec3( dFdx( wPosition.x ), dFdx( wPosition.y ), dFdx( wPosition.z ) ); + vec3 fdy = vec3( dFdy( wPosition.x ), dFdy( wPosition.y ), dFdy( wPosition.z ) ); + vec3 worldNormal = normalize( cross( fdx, fdy ) ); + + float lighting = + 0.4 + + clamp( dot( worldNormal, vec3( 1.0, 1.0, 1.0 ) ), 0.0, 1.0 ) * 0.5 + + clamp( dot( worldNormal, vec3( - 1.0, 1.0, - 1.0 ) ), 0.0, 1.0 ) * 0.3; + + // thickness scale + float upwardness = dot( worldNormal, vec3( 0.0, 1.0, 0.0 ) ); + float yInv = clamp( 1.0 - abs( upwardness ), 0.0, 1.0 ); + float thicknessScale = pow( yInv, 0.4 ); + thicknessScale *= 0.25 + 0.5 * ( vViewPosition.z + 1.0 ) / 2.0; + + // thickness + float thickness = 0.01 * thicknessScale; + float thickness2 = thickness / 2.0; + float m = mod( wPosition.y, 3.0 ); + + // soften edge + float center = thickness2; + float dist = clamp( abs( m - thickness2 ) / thickness2, 0.0, 1.0 ); + + vec4 topoColor = vec4( 0.149, 0.196, 0.219, 1.0 ) * 0.5; + gl_FragColor = mix( topoColor * lighting, vec4( lighting ), dist ); + + } + `};$();b();function P(i){const r=parseFloat(l.material);i.traverse(e=>{if(e.isMesh)switch(e.material.dispose(),r){case g:e.material=e.originalMaterial,e.material.side=2,e.receiveShadow=!1,e.castShadow=!1;break;case x:e.material=new v(O),e.material.side=2,e.receiveShadow=!1,e.castShadow=!1;break;case y:e.material=new v(_),e.material.side=2,e.material.flatShading=!0,e.receiveShadow=!1,e.castShadow=!1;break;case S:e.material=new I,e.material.side=2,e.receiveShadow=!0,e.castShadow=!0}})}function j({scene:i}){i.traverse(r=>{r.isMesh&&(r.originalMaterial=r.material)}),P(i)}function B({scene:i}){i.traverse(r=>{r.isMesh&&r.material.dispose()})}function M(){t&&(t.group.parent.remove(t.group),t.dispose());const i=window.location.hash.replace(/^#/,"")||"../data/tileset.json";t=new N(i),t.errorTarget=2,t.addEventListener("load-model",j),t.addEventListener("dispose-model",B),m.add(t.group)}function $(){p=new k,o=new F({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(1383455),o.shadowMap.enabled=!0,o.shadowMap.type=L,document.body.appendChild(o.domElement),n=new R(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(400,400,400),a=new z,c=new H(n,o.domElement),c.screenSpacePanning=!1,c.minDistance=1,c.maxDistance=2e3,d=new E(16777215,1.25),d.position.set(1,2,3).multiplyScalar(40),d.castShadow=!0,d.shadow.bias=-.01,d.shadow.mapSize.setScalar(2048);const i=d.shadow.camera;i.left=-200,i.bottom=-200,i.right=200,i.top=200,i.updateProjectionMatrix(),p.add(d);const r=new T(16777215,.05);p.add(r),h=new V,f=new G,m=new W,p.add(m),M(),u(),window.addEventListener("resize",u,!1);const e=new A;e.width=300,e.add(l,"orthographic"),e.add(l,"material",{DEFAULT:g,GRADIENT:x,TOPOGRAPHIC_LINES:y,LIGHTING:S}).onChange(()=>{t.forEachLoadedModel(P)}),e.add(l,"rebuild"),e.open(),w=new D,w.showPanel(0),document.body.appendChild(w.dom),s=document.createElement("div"),s.style.position="absolute",s.style.top=0,s.style.left=0,s.style.color="white",s.style.width="100%",s.style.textAlign="center",s.style.padding="5px",s.style.pointerEvents="none",s.style.lineHeight="1.5em",document.body.appendChild(s)}function u(){n.aspect=window.innerWidth/window.innerHeight,o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix(),C()}function C(){a.position.copy(n.position),a.rotation.copy(n.rotation);const i=n.position.distanceTo(c.target)/2,r=window.innerWidth/window.innerHeight;a.left=-r*i,a.right=r*i,a.bottom=-i,a.top=i,a.near=n.near,a.far=n.far,a.updateProjectionMatrix()}function b(){requestAnimationFrame(b),l.orthographic?(t.deleteCamera(n),t.setCamera(a),t.setResolutionFromRenderer(a,o)):(t.deleteCamera(a),t.setCamera(n),t.setResolutionFromRenderer(n,o)),m.rotation.set(0,0,0),l.up==="-Z"&&(m.rotation.x=Math.PI/2),m.updateMatrixWorld(!0),t.getBoundingBox(h)?(h.getCenter(t.group.position),t.group.position.multiplyScalar(-1)):t.getBoundingSphere(f)&&(t.group.position.copy(f.center),t.group.position.multiplyScalar(-1)),window.tiles=t,n.updateMatrixWorld(),a.updateMatrixWorld(),t.update(),q(),w.update()}function q(){C(),s.innerText=`Geometries: ${o.info.memory.geometries} Textures: ${o.info.memory.textures} Programs: ${o.info.programs.length} `,o.render(p,l.orthographic?a:n)} diff --git a/example/bundle/assets/ellipsoid-rcvdXV59.js b/example/bundle/assets/ellipsoid-rcvdXV59.js new file mode 100644 index 00000000..97ffd4f5 --- /dev/null +++ b/example/bundle/assets/ellipsoid-rcvdXV59.js @@ -0,0 +1 @@ +import{S as C,W as M,a as E,G as x,e as S,d as v,f as B,B as I,D as L,A as W,g as G,h as z}from"./three.module-DpclfMcJ.js";import{E as y,a as F,S as O}from"./EllipsoidRegionHelper-OhHLW9vN.js";import{O as A}from"./OrbitControls-DEr5g9Mg.js";import{g as D}from"./lil-gui.module.min-Bc0DeA9g.js";import"./EllipsoidRegion-D6hT1syi.js";import"./Ellipsoid-Cnb0UTwk.js";let l,w,p,o,r,P,c,u,e,g,f,a;const t=[];let m;const s={displaySphereHelper:!1,displayBoxHelper:!1,displayPoints:!1};q();b();function q(){p=new C,o=new M({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(1383455),o.shadowMap.enabled=!0,document.body.appendChild(o.domElement),l=new E(60,window.innerWidth/window.innerHeight,.1,100),l.position.set(3,1.5,1),r=new x,r.rotation.x=-Math.PI/2,p.add(r),m=new x,r.add(m),e=new y,e.material=new S({polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),e.ellipsoidRegion.radius.z=.95,e.ellipsoidRegion.heightStart=-.05,e.ellipsoidRegion.heightEnd=.05,e.ellipsoidRegion.latStart=0,e.ellipsoidRegion.latEnd=Math.PI/4,e.ellipsoidRegion.lonStart=0,e.ellipsoidRegion.lonEnd=Math.PI/4,g=new y,g.material=new S({opacity:.1,transparent:!0,depthWrite:!1}),f=new F(e.ellipsoidRegion),f.material.color.set(1383455).convertSRGBToLinear(),c=new O(new v),a=new x,u=new B(new I),a.add(u),r.add(e,g,f,c,a),n(),w=new A(l,o.domElement),w.screenSpacePanning=!1,w.minDistance=1,w.maxDistance=2e3,P=new L(16777215,1.25),P.position.set(1,2,3).multiplyScalar(40),p.add(P);const h=new W(16777215,.15);p.add(h);const i=new D;i.add(s,"displayBoxHelper"),i.add(s,"displaySphereHelper"),i.add(s,"displayPoints");const R=i.addFolder("radius");R.add(e.ellipsoidRegion.radius,"x",.1,2).onChange(n),R.add(e.ellipsoidRegion.radius,"y",.1,2).onChange(n),R.add(e.ellipsoidRegion.radius,"z",.1,2).onChange(n);const d=i.addFolder("region");d.add(e.ellipsoidRegion,"latStart",-Math.PI/2,Math.PI/2).onChange(n),d.add(e.ellipsoidRegion,"latEnd",-Math.PI/2,Math.PI/2).onChange(n),d.add(e.ellipsoidRegion,"lonStart",0,2*Math.PI).onChange(n),d.add(e.ellipsoidRegion,"lonEnd",0,2*Math.PI).onChange(n),d.add(e.ellipsoidRegion,"heightStart",-.25,.25).onChange(n),d.add(e.ellipsoidRegion,"heightEnd",-.25,.25).onChange(n),H(),window.addEventListener("resize",H,!1)}function n(){g.ellipsoidRegion.radius.copy(e.ellipsoidRegion.radius),e.update(),g.update(),f.update(),e.ellipsoidRegion.getBoundingSphere(c.sphere),e.ellipsoidRegion.getBoundingBox(u.box,a.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale);const h=e.ellipsoidRegion._getPoints();t.forEach(i=>i.visible=!1);for(let i=0;i{r.deleteCamera(u),e.deleteCamera(u),r.setCamera(m),e.setCamera(m),d.setCamera(m)}),d=new y(l,t.camera,s.domElement),d.minZoomDistance=2,d.cameraRadius=1,c=new S,c.rotation.set(Math.PI/2,0,0),l.add(c),w(),f(),window.addEventListener("resize",f,!1);const o=new D,n=o.addFolder("camera");n.add(a,"orthographic").onChange(m=>{t.fixedPoint.copy(d.pivotPoint),t.syncCameras(),d.adjustCamera(t.perspectiveCamera),d.adjustCamera(t.orthographicCamera),t.toggle()}),n.add(a,"transitionDuration",0,1.5);const i=o.addFolder("fade");i.add(a,"useFade"),i.add(a,"fadeRootTiles"),i.add(a,"errorTarget",0,1e3),i.add(a,"fadeDuration",0,5),i.add(a,"renderScale",.1,1,.05).onChange(m=>s.setPixelRatio(m*window.devicePixelRatio));const C=i.add(a,"fadingGroundTiles").listen().disable();C.domElement.style.opacity=1,o.add(a,"reinstantiateTiles"),o.open()}function w(){e&&(e.dispose(),e.group.removeFromParent(),r.dispose(),r.group.removeFromParent()),e=new p("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json"),e.fetchOptions.mode="cors",e.lruCache.minSize=900,e.lruCache.maxSize=1300,e.errorTarget=12,e.registerPlugin(new g),e.setCamera(t.camera),r=new p("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_sky/0528_0260184_to_s64o256_sky_tileset.json"),r.fetchOptions.mode="cors",r.lruCache=e.lruCache,r.registerPlugin(new g),r.setCamera(t.camera),c.add(e.group,r.group)}function f(){const{perspectiveCamera:o,orthographicCamera:n}=t,i=window.innerWidth/window.innerHeight;n.bottom=-40,n.top=40,n.left=-40*i,n.right=40*i,n.updateProjectionMatrix(),o.aspect=i,o.updateProjectionMatrix(),s.setSize(window.innerWidth,window.innerHeight)}function h(){requestAnimationFrame(h),d.enabled=!t.animating,d.update(),t.duration=1e3*a.transitionDuration,t.update();const o=t.camera;o.updateMatrixWorld();const n=e.getPluginByName("FADE_TILES_PLUGIN");n.fadeRootTiles=a.fadeRootTiles,n.fadeDuration=a.useFade?a.fadeDuration*1e3:0,e.errorTarget=a.errorTarget,e.setCamera(o),e.setResolutionFromRenderer(o,s),e.update();const i=r.getPluginByName("FADE_TILES_PLUGIN");i.fadeRootTiles=a.fadeRootTiles,i.fadeDuration=a.useFade?a.fadeDuration*1e3:0,r.setCamera(o),r.setResolutionFromRenderer(o,s),r.update(),s.render(l,o),a.fadingGroundTiles=n.fadingTiles+" tiles"} diff --git a/example/bundle/assets/globe-C-Ij2kUN.js b/example/bundle/assets/globe-C-Ij2kUN.js new file mode 100644 index 00000000..4f610de3 --- /dev/null +++ b/example/bundle/assets/globe-C-Ij2kUN.js @@ -0,0 +1 @@ +import{S as F,O as k,aB as W,k as E,j as L,an as I,i as b}from"./three.module-DpclfMcJ.js";import{d as S,r as n,f as O,u as w,g as _,j as t,h as B,c as U,C as q,T as V,a as v,G as N,i as X,b as Y}from"./CameraControls-DhgPIfmg.js";import{D as Z}from"./DRACOLoader-DJWREZh5.js";import{u as H,G as J,T as K}from"./leva.esm-BicpJr1E.js";import{G as Q}from"./GoogleCloudAuthPlugin-B9LFbpXw.js";import{T as $}from"./TileCompressionPlugin-Bcbrk_fI.js";import{U as ee}from"./UpdateOnChangePlugin-BFotcVNs.js";import{T as te}from"./TilesFadePlugin-GTJOynw2.js";import{c as re}from"./EnvironmentControls-C8X7oAWq.js";import{C as oe}from"./CameraTransitionManager-Dx_3SZAI.js";import"./GlobeControls-BUn2ddB7.js";import"./Ellipsoid-Cnb0UTwk.js";import"./TilesRenderer-DdUhzUiO.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./GLTFMeshFeaturesExtension-D473cUUw.js";import"./Pass-inUSP30K.js";const h=new E,C=new E,y=new E,j=new L,D=new L,T=new L,P=new I,R={};function ae(i,s,o,a){D.copy(o.matrixWorld).invert(),P.origin.copy(i.position),P.direction.set(0,0,-1).transformDirection(i.matrixWorld),P.applyMatrix4(D),re(P,s,y),y.applyMatrix4(o.matrixWorld),C.set(0,0,-1).transformDirection(i.matrixWorld);const m=y.sub(i.position).dot(C);return a.copy(i.position).addScaledVector(C,m),a}function ie(i){const{defaultScene:s,defaultCamera:o,overrideRenderLoop:a=!0,renderPriority:m=1}=i,c=n.useMemo(()=>new k,[]),[x,p,u,d]=S(l=>[l.set,l.size,l.gl,l.scene]);n.useEffect(()=>{x({camera:c})},[x,c]),n.useEffect(()=>{c.left=-p.width/2,c.right=p.width/2,c.top=p.height/2,c.bottom=-p.height/2,c.near=0,c.far=2e3,c.position.z=c.far/2,c.updateProjectionMatrix()},[c,p]),w(()=>{a&&u.render(s,o);const l=u.autoClear;u.autoClear=!1,u.clearDepth(),u.render(d,c),u.autoClear=l},m)}function z(){const i=n.useRef();return n.useEffect(()=>{const o=i.current.attributes.position;for(let a=0,m=o.count;a0&&(h.x=0,o.setXYZ(a,...h))}),t.jsx("boxGeometry",{ref:i})}function ne({northColor:i=15684432,southColor:s=16777215}){const[o,a]=n.useState(),m=n.useRef();return n.useEffect(()=>{a(m.current)},[]),t.jsxs("group",{scale:.5,ref:m,children:[t.jsx("ambientLight",{intensity:1}),t.jsx("directionalLight",{position:[0,2,3],intensity:3,target:o}),t.jsx("directionalLight",{position:[0,-2,-3],intensity:3,target:o}),t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{}),t.jsx("meshBasicMaterial",{color:0,opacity:.3,transparent:!0,side:W})]}),t.jsxs("group",{scale:[.5,1,.15],children:[t.jsxs("mesh",{"position-y":.5,children:[t.jsx(z,{}),t.jsx("meshStandardMaterial",{color:i})]}),t.jsxs("mesh",{"position-y":-.5,"rotation-x":Math.PI,children:[t.jsx(z,{}),t.jsx("meshStandardMaterial",{color:s})]})]})]})}function se({children:i,overrideRenderLoop:s,mode:o="3d",margin:a=10,scale:m=35,visible:c=!0,...x}){const[p,u,d]=S(r=>[r.camera,r.scene,r.size]),l=n.useContext(O),f=n.useRef(null),e=n.useMemo(()=>new F,[]);return w(()=>{if(l===null||f.current===null)return null;const{ellipsoid:r}=l,g=f.current;if(j.copy(l.group.matrixWorld).invert(),ae(p,r,l.group,y).applyMatrix4(j),r.getPositionToCartographic(y,R),r.getRotationMatrixFromAzElRoll(R.lat,R.lon,0,0,0,T).premultiply(l.group.matrixWorld),T.invert(),j.copy(p.matrixWorld).premultiply(T),o.toLowerCase()==="3d")g.quaternion.setFromRotationMatrix(j).invert();else if(h.set(0,1,0).transformDirection(j).normalize(),h.z=0,h.normalize(),h.length()===0)g.quaternion.identity();else{const M=C.set(0,1,0).angleTo(h);C.cross(h).normalize(),g.quaternion.setFromAxisAngle(C,-M)}}),i||(i=t.jsx(ne,{})),c?_(t.jsxs(t.Fragment,{children:[t.jsx("group",{ref:f,scale:m,position:[d.width/2-a-m/2,-d.height/2+a+m/2,0],...x,children:i}),t.jsx(ie,{defaultCamera:p,defaultScene:u,overrideRenderLoop:s,renderPriority:10})]}),e,{events:{priority:10}}):null}const ce=n.forwardRef(function(s,o){const{mode:a="perspective",perspectiveCamera:m,orthographicCamera:c,...x}=s,[p,u,d,l,f]=S(r=>[r.set,r.invalidate,r.controls,r.camera,r.size]),e=n.useMemo(()=>{const r=new oe;return r.autoSync=!1,l.isOrthographicCamera?(r.orthographicCamera.copy(l),r.mode="orthographic"):r.perspectiveCamera.copy(l),r.syncCameras(),r.mode=a,r},[]);n.useEffect(()=>{const{perspectiveCamera:r,orthographicCamera:g}=e,M=f.width/f.height;r.aspect=M,r.updateProjectionMatrix(),g.left=-g.top*M,g.right=-g.left,r.updateProjectionMatrix()},[e,f]),n.useEffect(()=>{o&&(o instanceof Function?o(e):o.current=e)},[e,o]),n.useEffect(()=>{const r=({camera:g})=>{p(()=>({camera:g}))};return p(()=>({camera:e.camera})),e.addEventListener("camera-change",r),()=>{e.removeEventListener("camera-change",r)}},[e,p]),n.useEffect(()=>{const r=e.perspectiveCamera,g=e.orthographicCamera;return e.perspectiveCamera=m||r,e.orthographicCamera=c||g,p(()=>({camera:e.camera})),()=>{e.perspectiveCamera=r,e.orthographicCamera=g}},[m,c,e,p]),n.useEffect(()=>{a!==e.mode&&(d&&d.isEnvironmentControls?(d.getPivotPoint(e.fixedPoint),e.syncCameras(),d.adjustCamera(e.perspectiveCamera),d.adjustCamera(e.orthographicCamera)):(e.fixedPoint.set(0,0,-1).transformDirection(e.camera.matrixWorld).multiplyScalar(50).add(e.camera.position),e.syncCameras()),e.toggle(),u())},[a,e,u,d]),n.useEffect(()=>{const r=()=>u();return e.addEventListener("transition-start",r),e.addEventListener("change",r),e.addEventListener("transition-end",r),()=>{e.removeEventListener("transition-start",r),e.removeEventListener("change",r),e.removeEventListener("transition-end",r)}},[e,u]),B(e,x),w(()=>{e.update(),d&&(d.enabled=!e.animating),e.animating&&u()},-1)}),me=new Z().setDecoderPath("https://www.gstatic.com/draco/v1/decoders/"),G=new E,A=new E;function le(){const i=n.useRef();return w(({camera:s})=>{const o=i.current;G.setFromMatrixPosition(s.matrixWorld),o.position.set(0,0,0),o.updateMatrixWorld(),A.setFromMatrixPosition(o.matrixWorld);let a;if(s.isPerspectiveCamera){const m=G.distanceTo(A);a=Math.max(.05*m*Math.atan(s.fov*b.DEG2RAD),25)}else a=Math.max((s.top-s.bottom)*.05/s.zoom,25);o.scale.setScalar(a),o.position.z=a*.5}),t.jsxs("mesh",{ref:i,"rotation-x":-Math.PI/2,raycast:()=>{},children:[t.jsx("coneGeometry",{args:[.3]}),t.jsx("meshStandardMaterial",{color:15483002,emissive:15483002,emissiveIntensity:.25})]})}function pe(){const i={apiToken:{value:localStorage.getItem("google-token")||"put-your-api-key-here",onChange:a=>localStorage.setItem("google-token",a),transient:!1},ortho:!1},{apiToken:s,ortho:o}=H(i);return t.jsxs(q,{frameloop:"demand",camera:{position:[0,.5*1e7,1.5*1e7]},style:{width:"100%",height:"100%",position:"absolute",margin:0,left:0,top:0},flat:!0,children:[t.jsx("color",{attach:"background",args:[1118481]}),t.jsxs(V,{group:{rotation:[-Math.PI/2,0,0]},children:[t.jsx(v,{plugin:Q,args:{apiToken:s}}),t.jsx(v,{plugin:J,dracoLoader:me}),t.jsx(v,{plugin:$}),t.jsx(v,{plugin:ee}),t.jsx(v,{plugin:te}),t.jsx(N,{enableDamping:!0}),t.jsx(K,{}),t.jsx(X,{lat:34.2013*b.DEG2RAD,lon:-118.1714*b.DEG2RAD,height:350,children:t.jsx(le,{})}),";",t.jsx(se,{})]}),t.jsx(Y,{preset:"sunset",backgroundBlurriness:.9,environmentIntensity:1}),t.jsx(ce,{mode:o?"orthographic":"perspective"})]})}U(document.getElementById("root")).render(t.jsx(n.StrictMode,{children:t.jsx(pe,{})})); diff --git a/example/bundle/assets/gltf-gx10b73O.js b/example/bundle/assets/gltf-gx10b73O.js new file mode 100644 index 00000000..7a637256 --- /dev/null +++ b/example/bundle/assets/gltf-gx10b73O.js @@ -0,0 +1 @@ +import{S as k,W as M,P as L,a as b,D as C,A as F,L as P}from"./three.module-DpclfMcJ.js";import{O as S}from"./OrbitControls-DEr5g9Mg.js";import{D as x}from"./DRACOLoader-DJWREZh5.js";import{G}from"./GLTFLoader-DkJa3Jo5.js";import{G as g}from"./GLTFExtensionLoader-TubLlshp.js";import"./LoaderBase-CVSPpjX2.js";let s,t,r,e,i;R();h();function R(){r=new k,e=new M({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=L,document.body.appendChild(e.domElement),s=new b(60,window.innerWidth/window.innerHeight,1,4e3),s.position.set(3,10,20),t=new S(s,e.domElement),t.screenSpacePanning=!1,t.minDistance=1,t.maxDistance=2e3,i=new C(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const d=i.shadow.camera;d.left=-200,d.bottom=-200,d.right=200,d.top=200,d.updateProjectionMatrix(),r.add(i);const p=new F(16777215,.05);r.add(p);let c=0;const f=["https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Binary/CesiumMilkTruck.glb","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Embedded/CesiumMilkTruck.gltf","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF/CesiumMilkTruck.gltf"];for(const o of f){const n=new g;n.workingPath=n.workingPathForURL(o),n.loadAsync(o).then(a=>{a.scene.position.set(c+=5,0,0),t.target.set(c/2,0,0),t.update(),console.log("default loader:",{gltf:a,url:o}),r.add(a.scene)})}const T=["https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Draco/CesiumMilkTruck.gltf","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Box/glTF-Binary/Box.glb"],l=new P,m=new G(l),w=new x(l);w.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/"),m.setDRACOLoader(w),l.addHandler(/\.gltf$/,m),l.addHandler(/\.glb$/,m);for(const o of T){const n=new g(l);n.workingPath=n.workingPathForURL(o),n.loadAsync(o).then(a=>{a.scene.position.set(c+=5,0,0),t.target.set(c/2,0,0),t.update(),console.log("custom loader:",{gltf:a,url:o}),r.add(a.scene)})}u(),window.addEventListener("resize",u,!1)}function u(){s.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),s.updateProjectionMatrix()}function h(){requestAnimationFrame(h),D()}function D(){e.render(r,s)} diff --git a/example/bundle/assets/googleMapsAerial-DSBsG7lA.js b/example/bundle/assets/googleMapsAerial-DSBsG7lA.js new file mode 100644 index 00000000..4fecffaa --- /dev/null +++ b/example/bundle/assets/googleMapsAerial-DSBsG7lA.js @@ -0,0 +1,2 @@ +import{S as f,W as h,a as R,i as l,R as P}from"./three.module-DpclfMcJ.js";import{G as y}from"./GLTFLoader-DkJa3Jo5.js";import{D}from"./DRACOLoader-DJWREZh5.js";import{g as L}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as A}from"./OrbitControls-DEr5g9Mg.js";import{T}from"./TilesRenderer-DdUhzUiO.js";import{G as x}from"./GoogleCloudAuthPlugin-B9LFbpXw.js";import{T as C}from"./TileCompressionPlugin-Bcbrk_fI.js";import{T as E}from"./TilesFadePlugin-GTJOynw2.js";import{W as G}from"./I3DMLoader-BlebwdUJ.js";import{t as S}from"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";let t,n,d,i,e;const W=new P;W.firstHitOnly=!0;const b=localStorage.getItem("googleApiKey")??"put-your-api-key-here",m={apiKey:b,reload:g};v();w();function g(){localStorage.setItem("googleApiKey",m.apiKey),e&&(d.remove(e.group),e.dispose(),e=null),e=new T,e.registerPlugin(new x({apiToken:m.apiKey})),e.registerPlugin(new C),e.registerPlugin(new E),e.setLatLonToYUp(35.6586*l.DEG2RAD,139.7454*l.DEG2RAD);const o=new D;o.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const r=new y(e.manager);r.setDRACOLoader(o),e.manager.addHandler(/\.gltf$/,r),d.add(e.group),e.setResolutionFromRenderer(t,i),e.setCamera(t)}function v(){d=new f,i=new h({antialias:!0}),i.setClearColor(1383455),document.body.appendChild(i.domElement),t=new R(60,window.innerWidth/window.innerHeight,100,16e5),t.position.set(1e3,1e3,1e3).multiplyScalar(.5),n=new A(t,i.domElement),n.minDistance=500,n.maxDistance=1e4*2,n.minPolarAngle=0,n.maxPolarAngle=3*Math.PI/8,n.enableDamping=!0,n.autoRotate=!0,n.autoRotateSpeed=.5,n.enablePan=!1,g(),c(),window.addEventListener("resize",c,!1),window.addEventListener("hashchange",u);const o=new L;o.width=300,o.add(m,"apiKey"),o.add(m,"reload"),o.open(),u()}function c(){t.aspect=window.innerWidth/window.innerHeight,i.setSize(window.innerWidth,window.innerHeight),t.updateProjectionMatrix(),i.setPixelRatio(window.devicePixelRatio)}function u(){const r=window.location.hash.replace(/^#/,"").split(/,/g).map(s=>parseFloat(s));if(r.length!==2||r.findIndex(s=>Number.isNaN(s))!==-1)return;const[p,a]=r;e.setLatLonToYUp(p*l.DEG2RAD,a*l.DEG2RAD)}function w(){requestAnimationFrame(w),e&&(n.update(),e.setResolutionFromRenderer(t,i),e.setCamera(t),t.updateMatrixWorld(),e.update(),F())}function F(){var o;if(i.render(d,t),e){const r=e.group.matrixWorld.clone().invert(),p=t.position.clone().applyMatrix4(r),a={};G.getPositionToCartographic(p,a);const s=((o=e.getAttributions()[0])==null?void 0:o.value)||"";document.getElementById("credits").innerText=S(a.lat,a.lon)+` +`+s}} diff --git a/example/bundle/assets/googleMapsExample-BU772Sr0.js b/example/bundle/assets/googleMapsExample-BU772Sr0.js new file mode 100644 index 00000000..95d75a0e --- /dev/null +++ b/example/bundle/assets/googleMapsExample-BU772Sr0.js @@ -0,0 +1,18 @@ +import{j as B,k as v,l as z,m as H,g as V,B as j,d as $,n as N,o as k,p as K,q as D,W as q,S as Q,a as X,O as Z,i as g}from"./three.module-DpclfMcJ.js";import{G as J}from"./GLTFLoader-DkJa3Jo5.js";import{D as Y}from"./DRACOLoader-DJWREZh5.js";import{g as ee}from"./lil-gui.module.min-Bc0DeA9g.js";import{S as te}from"./stats.module--VATS4Kh.js";import{F as ae}from"./Pass-inUSP30K.js";import{T as re}from"./TilesRenderer-DdUhzUiO.js";import{G as ne}from"./GoogleCloudAuthPlugin-B9LFbpXw.js";import{T as ie}from"./TileCompressionPlugin-Bcbrk_fI.js";import{U as se}from"./UpdateOnChangePlugin-BFotcVNs.js";import{T as oe}from"./TilesFadePlugin-GTJOynw2.js";import{C as ce}from"./CameraTransitionManager-Dx_3SZAI.js";import{G as de}from"./GlobeControls-BUn2ddB7.js";import{C as W,t as le}from"./Ellipsoid-Cnb0UTwk.js";import{W as I}from"./I3DMLoader-BlebwdUJ.js";import"./B3DMLoader-B2OeBq6-.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./EnvironmentControls-C8X7oAWq.js";const he=new B,E=new v,G=new v;class me extends z{constructor(...e){super(...e),this.resetDistance=1e4,this._matricesTextureHandle=null,this._lastCameraPos=new B,this._forceUpdate=!0}setMatrixAt(...e){super.setMatrixAt(...e),this._forceUpdate=!0}onBeforeRender(e,t,a,s,d,r){super.onBeforeRender(e,t,a,s,d,r),E.setFromMatrixPosition(a.matrixWorld),G.setFromMatrixPosition(this._lastCameraPos);const o=this._matricesTexture;let c=this._modelViewMatricesTexture;if((!c||c.image.width!==o.image.width||c.image.height!==o.image.height)&&(c&&c.dispose(),c=o.clone(),c.source=new H({...c.image,data:c.image.data.slice()}),this._modelViewMatricesTexture=c),this._forceUpdate||E.distanceTo(G)>this.resetDistance){const l=o.image.data,u=c.image.data;for(let h=0;h{const y=this.getGeometryRangeAt(u),{reservedIndexCount:x,reservedVertexCount:M}=y;if(x>=d&&M>=r){const w=d-x+(r-M);w{const h=this.unusedVertexCountthis.deleteGeometry(h)),r.length=0,this.optimize(),c())){const h=this.geometry.index,y=this.geometry.attributes.position;let x,M;if(h){const w=Math.ceil(d*h.count);x=Math.max(w,a,l.count)+h.count}else x=Math.max(this.unusedIndexCount,a);if(y){const w=Math.ceil(d*y.count);M=Math.max(w,t,u.count)+y.count}else M=Math.max(this.unusedVertexCount,t);this.setGeometrySize(M,x)}o=super.addGeometry(e,t,a)}return o}addInstance(e){if(this.maxInstanceCount===this.instanceCount){const t=Math.ceil(this.maxInstanceCount*(1+this.expandPercent));this.setInstanceCount(Math.min(t,this.maxInstanceExpansionSize))}return super.addInstance(e)}deleteInstance(e){const t=this.getGeometryIdAt(e);return t!==-1&&this._freeGeometryIds.push(t),super.deleteInstance(e)}raycastInstance(e,t,a){const s=this.geometry,d=this.getGeometryIdAt(e);C.material=this.material,C.geometry.index=s.index,C.geometry.attributes=s.attributes;const r=this.getGeometryRangeAt(d);C.geometry.setDrawRange(r.start,r.count),C.geometry.boundingBox===null&&(C.geometry.boundingBox=new j),C.geometry.boundingSphere===null&&(C.geometry.boundingSphere=new $),this.getMatrixAt(e,C.matrixWorld).premultiply(this.matrixWorld),this.getBoundingBoxAt(d,C.geometry.boundingBox),this.getBoundingSphereAt(d,C.geometry.boundingSphere),C.raycast(t,_);for(let o=0,c=_.length;o{e.vertexShader=e.vertexShader.replace("#include ",` + #include + varying float texture_index; + `).replace("#include ",` + #include + texture_index = getIndirectIndex( gl_DrawID ); + `),e.fragmentShader=e.fragmentShader.replace("#include ",` + #ifdef USE_MAP + precision highp sampler2DArray; + uniform sampler2DArray map; + varying float texture_index; + #endif + `).replace("#include ",` + #ifdef USE_MAP + diffuseColor *= texture( map, vec3( vMapUv, texture_index ) ); + #endif + `)}}const S=new ae(new N),L=new k(new Uint8Array([255,255,255,255]),1,1);L.needsUpdate=!0;class xe{constructor(e={}){if(parseInt(K)<170)throw new Error("BatchedTilesPlugin: Three.js revision 170 or higher required.");e={instanceCount:500,vertexCount:750,indexCount:2e3,expandPercent:.25,maxInstanceCount:1/0,discardOriginalContent:!0,material:null,renderer:null,...e},this.name="BATCHED_MESH_PLUGIN",this.priority=-1;const t=e.renderer.getContext();this.instanceCount=e.instanceCount,this.vertexCount=e.vertexCount,this.indexCount=e.indexCount,this.material=e.material?e.material.clone():null,this.expandPercent=e.expandPercent,this.maxInstanceCount=Math.min(e.maxInstanceCount,t.getParameter(t.MAX_3D_TEXTURE_SIZE)),this.renderer=e.renderer,this.discardOriginalContent=e.discardOriginalContent,this.batchedMesh=null,this.arrayTarget=null,this.tiles=null,this._onLoadModel=null,this._onDisposeModel=null,this._onVisibilityChange=null,this._tileToInstanceId=new Map}init(e){this._onDisposeModel=({scene:t,tile:a})=>{this.removeSceneFromBatchedMesh(t,a)},e.addEventListener("dispose-model",this._onDisposeModel),this.tiles=e}initBatchedMesh(e){if(this.batchedMesh!==null)return;const{instanceCount:t,vertexCount:a,indexCount:s,tiles:d,renderer:r}=this,o=this.material?this.material:new e.material.constructor,c=new ue(t,t*a,t*s,o);c.name="BatchTilesPlugin",c.frustumCulled=!1,d.group.add(c),c.updateMatrixWorld();const l=e.material.map,u={colorSpace:l.colorSpace,wrapS:l.wrapS,wrapT:l.wrapT,wrapR:l.wrapS,magFilter:l.magFilter},h=new D(l.image.width,l.image.height,t);Object.assign(h.texture,u),r.initRenderTarget(h),o.map=h.texture,ge(o),this.arrayTarget=h,this.batchedMesh=c}setTileVisible(e,t){const a=e.cached.scene;if(t&&this.addSceneToBatchedMesh(a,e),this._tileToInstanceId.has(e)){this._tileToInstanceId.get(e).forEach(r=>{this.batchedMesh.setVisibleAt(r,t)});const d=this.tiles;return t?d.visibleTiles.add(e):d.visibleTiles.delete(e),d.dispatchEvent({type:"tile-visibility-change",scene:a,tile:e,visible:t}),!0}return!1}unloadTileFromGPU(e,t){return!this.discardOriginalContent&&this._tileToInstanceId.has(t)?(this.removeSceneFromBatchedMesh(e,t),!0):!1}assignTextureToLayer(e,t){this.expandArrayTargetIfNeeded();const{renderer:a}=this,s=a.getRenderTarget();a.setRenderTarget(this.arrayTarget,t),S.material.map=e,S.render(a),a.setRenderTarget(s),S.material.map=null,e.dispose()}expandArrayTargetIfNeeded(){const{batchedMesh:e,arrayTarget:t,renderer:a}=this,s=Math.min(e.maxInstanceCount,this.maxInstanceCount);if(s>t.depth){const d={colorSpace:t.texture.colorSpace,wrapS:t.texture.wrapS,wrapT:t.texture.wrapT,generateMipmaps:t.texture.generateMipmaps,minFilter:t.texture.minFilter,magFilter:t.texture.magFilter},r=new D(t.width,t.height,s);Object.assign(r.texture,d),a.initRenderTarget(r),a.copyTextureToTexture(t.texture,r.texture),t.dispose(),e.material.map=r.texture,this.arrayTarget=r}}removeSceneFromBatchedMesh(e,t){if(this._tileToInstanceId.has(t)){const a=this._tileToInstanceId.get(t);this._tileToInstanceId.delete(t),a.forEach(s=>{this.batchedMesh.deleteInstance(s)})}}addSceneToBatchedMesh(e,t){if(this._tileToInstanceId.has(t))return;const a=[];e.traverse(r=>{r.isMesh&&a.push(r)});let s=!0;a.forEach(r=>{if(this.batchedMesh&&s){const o=r.geometry.attributes,c=this.batchedMesh.geometry.attributes;for(const l in c)if(!(l in o)){s=!1;return}}});const d=!this.batchedMesh||this.batchedMesh.instanceCount+a.length<=this.maxInstanceCount;if(s&&d){this.discardOriginalContent&&(t.cached.scene=null,t.cached.materials=[],t.cached.geometries=[],t.cached.textures=[]),e.updateMatrixWorld();const r=[];a.forEach(o=>{this.initBatchedMesh(o);const{geometry:c,material:l}=o,{batchedMesh:u,expandPercent:h}=this;u.expandPercent=h;const y=u.addGeometry(c,this.vertexCount,this.indexCount),x=u.addInstance(y);r.push(x),u.setMatrixAt(x,o.matrixWorld),u.setVisibleAt(x,!1),pe(l.color)||(l.color.setHSL(Math.random(),.5,.5),u.setColorAt(x,l.color));const M=l.map;M?this.assignTextureToLayer(M,x):this.assignTextureToLayer(L,x)}),this._tileToInstanceId.set(t,r)}}raycastTile(e,t,a,s){return this._tileToInstanceId.has(e)?(this._tileToInstanceId.get(e).forEach(r=>{this.batchedMesh.raycastInstance(r,a,s)}),!0):!1}dispose(){const{arrayTarget:e,tiles:t,batchedMesh:a}=this;e&&e.dispose(),a&&(a.material.dispose(),a.geometry.dispose(),a.dispose(),a.removeFromParent()),t.removeEventListener("dispose-model",this._onDisposeModel)}}let T,b,f,n,m,P,A;const fe=localStorage.getItem("googleApiKey")??"put-your-api-key-here",p={orthographic:!1,enableCacheDisplay:!1,enableRendererStats:!1,apiKey:fe,useBatchedMesh:!!new URLSearchParams(window.location.hash.replace(/^#/,"")).get("batched"),errorTarget:40,reload:U};Ce();O();function U(){n&&(b.remove(n.group),n.dispose(),n=null),localStorage.setItem("googleApiKey",p.apiKey),n=new re,n.registerPlugin(new ne({apiToken:p.apiKey,autoRefreshToken:!0})),n.registerPlugin(new ie),n.registerPlugin(new se),p.useBatchedMesh?n.registerPlugin(new xe({renderer:f})):n.registerPlugin(new oe),n.group.rotation.x=-Math.PI/2;const i=new Y;i.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const e=new J(n.manager);e.setDRACOLoader(i),n.manager.addHandler(/\.gltf$/,e),b.add(n.group),n.setResolutionFromRenderer(m.camera,f),n.setCamera(m.camera),T.setTilesRenderer(n)}function Ce(){f=new q({antialias:!0}),f.setClearColor(1383455),document.body.appendChild(f.domElement),b=new Q,m=new ce(new X(60,window.innerWidth/window.innerHeight,1,16e7),new Z(-1,1,1,-1,1,16e7)),m.perspectiveCamera.position.set(48e5,257e4,1472e4),m.perspectiveCamera.lookAt(0,0,0),m.autoSync=!1,m.addEventListener("camera-change",({camera:a,prevCamera:s})=>{n.deleteCamera(s),n.setCamera(a),T.setCamera(a)}),m.orthographicPositionalZoom=!1,T=new de(b,m.camera,f.domElement,null),T.enableDamping=!0,U(),R(),window.addEventListener("resize",R,!1),window.addEventListener("hashchange",F);const i=new ee;i.width=300,i.add(p,"orthographic").onChange(a=>{T.getPivotPoint(m.fixedPoint),m.syncCameras(),T.adjustCamera(m.perspectiveCamera),T.adjustCamera(m.orthographicCamera),m.toggle()});const e=i.addFolder("Google Photorealistic Tiles");e.add(p,"apiKey"),e.add(p,"useBatchedMesh").listen(),e.add(p,"reload");const t=i.addFolder("Example Options");t.add(p,"enableCacheDisplay"),t.add(p,"enableRendererStats"),t.add(p,"errorTarget",5,100,1).onChange(()=>{n.getPluginByName("UPDATE_ON_CHANGE_PLUGIN").needsUpdate=!0}),P=document.createElement("div"),document.getElementById("info").appendChild(P),A=new te,A.showPanel(0),document.body.appendChild(A.dom),F(),setInterval(ye,100)}function R(){const{perspectiveCamera:i,orthographicCamera:e}=m,t=window.innerWidth/window.innerHeight;i.aspect=t,i.updateProjectionMatrix(),e.left=-e.top*t,e.right=-e.left,e.updateProjectionMatrix(),f.setSize(window.innerWidth,window.innerHeight),f.setPixelRatio(window.devicePixelRatio)}function ye(){if(!n)return;const i=m.camera,e={},t={},a=n.group.matrixWorld.clone().invert(),s=i.position.clone().applyMatrix4(a),d=i.matrixWorld.clone().premultiply(a);I.getPositionToCartographic(s,e),I.getAzElRollFromRotationMatrix(e.lat,e.lon,d,t,W),t.azimuth*=g.RAD2DEG,t.elevation*=g.RAD2DEG,t.roll*=g.RAD2DEG,e.lat*=g.RAD2DEG,e.lon*=g.RAD2DEG;const r=new URLSearchParams;r.set("lat",e.lat.toFixed(4)),r.set("lon",e.lon.toFixed(4)),r.set("height",e.height.toFixed(2)),r.set("az",t.azimuth.toFixed(2)),r.set("el",t.elevation.toFixed(2)),r.set("roll",t.roll.toFixed(2)),p.useBatchedMesh&&r.set("batched",1),window.history.replaceState(void 0,void 0,`#${r}`)}function F(){const i=window.location.hash.replace(/^#/,""),e=new URLSearchParams(i);if(e.has("batched")&&(p.useBatchedMesh=!!e.get("batched")),!e.has("lat")&&!e.has("lon"))return;n.group.updateMatrixWorld();const t=m.camera,a=parseFloat(e.get("lat")),s=parseFloat(e.get("lon")),d=parseFloat(e.get("height"))||1e3;if(e.has("az")&&e.has("el")){const r=parseFloat(e.get("az")),o=parseFloat(e.get("el")),c=parseFloat(e.get("roll"))||0;I.getRotationMatrixFromAzElRoll(a*g.DEG2RAD,s*g.DEG2RAD,r*g.DEG2RAD,o*g.DEG2RAD,c*g.DEG2RAD,t.matrixWorld,W),t.matrixWorld.premultiply(n.group.matrixWorld),t.matrixWorld.decompose(t.position,t.quaternion,t.scale),I.getCartographicToPosition(a*g.DEG2RAD,s*g.DEG2RAD,d,t.position),t.position.applyMatrix4(n.group.matrixWorld)}else I.getCartographicToPosition(a*g.DEG2RAD,s*g.DEG2RAD,d,t.position),t.position.applyMatrix4(n.group.matrixWorld),t.lookAt(0,0,0)}function O(){if(requestAnimationFrame(O),!n)return;T.enabled=!m.animating,T.update(),m.update();const i=m.camera;n.setResolutionFromRenderer(i,f),n.setCamera(i),i.updateMatrixWorld(),n.errorTarget=p.errorTarget,n.update(),f.render(b,i),A.update(),Me()}function Me(){var d;let i="";if(p.enableCacheDisplay){const r=n.lruCache,o=r.cachedBytes/r.maxBytesSize;i+=`Downloading: ${n.stats.downloading} Parsing: ${n.stats.parsing} Visible: ${n.visibleTiles.size}
`,i+=`Cache: ${(100*o).toFixed(2)}% ~${(r.cachedBytes/1e3/1e3).toFixed(2)}mb
`}if(p.enableRendererStats){const r=f.info.memory,o=f.info.render,c=f.info.programs.length;i+=`Geometries: ${r.geometries} Textures: ${r.textures} Programs: ${c} Draw Calls: ${o.calls}`}P.innerHTML!==i&&(P.innerHTML=i);const e=n.group.matrixWorld.clone().invert(),t=m.camera.position.clone().applyMatrix4(e),a={};I.getPositionToCartographic(t,a);const s=((d=n.getAttributions()[0])==null?void 0:d.value)||"";document.getElementById("credits").innerText=le(a.lat,a.lon)+` +`+s} diff --git a/example/bundle/assets/i3dmExample-xU-8fPZ8.js b/example/bundle/assets/i3dmExample-xU-8fPZ8.js new file mode 100644 index 00000000..53607918 --- /dev/null +++ b/example/bundle/assets/i3dmExample-xU-8fPZ8.js @@ -0,0 +1 @@ +import{S,W as P,P as b,a as M,D as W,A as C,k as m,Q as v,j as L}from"./three.module-DpclfMcJ.js";import{O as y}from"./OrbitControls-DEr5g9Mg.js";import{I as R}from"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./Ellipsoid-Cnb0UTwk.js";let n,a,s,e,i;z();f();function z(){s=new S,e=new P({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=b,document.body.appendChild(e.domElement),n=new M(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(100,100,100),a=new y(n,e.domElement),a.screenSpacePanning=!1,a.minDistance=1,a.maxDistance=2e3,i=new W(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const o=i.shadow.camera;o.left=-200,o.bottom=-200,o.right=200,o.top=200,o.updateProjectionMatrix(),s.add(i);const h=new C(16777215,.05);s.add(h),new R().loadAsync("https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/1.0/TilesetWithTreeBillboards/tree.i3dm").then(d=>{let t=null;if(d.scene.traverse(r=>{!t&&r.isInstancedMesh&&(t=r)}),t){d.scene.updateMatrixWorld(!0);const r=new m,u=new v,g=new m,w=new L,c=new m;for(let l=0,x=t.count;l>Math.log2(g),S=I[h];if(!this.getBit(e._tileAvailability,r)){t.push(void 0);continue}const c=this.deriveChildTile(e,S,r,E);S.children.push(c),t.push(c)}I=t,t=[]}return I}deriveChildTile(A,e,I,t){const i=new VA(e,t);i.boundingVolume=this.getTileBoundingVolume(i),i.geometricError=this.getGeometricError(i);for(let g=0;A&&g=A.lengthBits)throw new Error("Bit index out of bounds.");if(A.constant!==void 0)return A.constant;const I=e>>3,t=e%8;return(new Uint8Array(A.bitstream)[I]>>t&1)===1}getTileBoundingVolume(A){const e={};if(this.rootTile.boundingVolume.region){const I=[...this.rootTile.boundingVolume.region],t=I[0],i=I[2],g=I[1],C=I[3],o=(i-t)/Math.pow(2,A.__level),E=(C-g)/Math.pow(2,A.__level);I[0]=t+o*A.__x,I[2]=t+o*(A.__x+1),I[1]=g+E*A.__y,I[3]=g+E*(A.__y+1);for(let r=0;r<4;r++){const h=I[r];h<-Math.PI?I[r]+=2*Math.PI:h>Math.PI&&(I[r]-=2*Math.PI)}if(FA(A)){const r=I[4],S=(I[5]-r)/Math.pow(2,A.__level);I[4]=r+S*A.__z,I[5]=r+S*(A.__z+1)}e.region=I}if(this.rootTile.boundingVolume.box){const I=[...this.rootTile.boundingVolume.box],t=2**A.__level-1,i=Math.pow(2,-A.__level),g=FA(A)?3:2;for(let C=0;C{this.enabled&&Object.defineProperty(w,"shiftKey",{get(){return!1}})};e.addEventListener("pointerdown",I),super(A,e),this.enableKeys=!1,this.enableFlight=!0,this.baseSpeed=1,this.fastSpeed=4,this.forwardKey="w",this.backKey="s",this.leftKey="a",this.rightKey="d",this.upKey="q",this.downKey="e",this.fastKey="shift";let t=!1,i=!1,g=!1,C=!1,o=!1,E=!1,r=!1,h=0,S=0,c=0,a=-1;const n=new Re,d=new ue,l=()=>{if(a!==-1){cancelAnimationFrame(a),a=-1,this.minDistance=S,this.maxDistance=c;const w=Math.min(h,A.position.distanceTo(n));N.set(0,0,-1,0).applyMatrix4(A.matrixWorld),this.target.copy(A.position).addScaledVector(N,w),this.dispatchEvent(UI)}},D=()=>{if(!this.enabled||!this.enableFlight)return;a=requestAnimationFrame(D),N.set(0,0,0,0),i&&(N.z-=1),g&&(N.z+=1),C&&(N.x-=1),o&&(N.x+=1),E&&(N.y+=1),r&&(N.y-=1),N.applyMatrix4(A.matrixWorld);const w=60*d.getDelta(),u=t?this.fastSpeed:this.baseSpeed;A.position.addScaledVector(N,u*w),this.target.addScaledVector(N,u*w),this.dispatchEvent(mI)},F=w=>{const u=w.key.toLowerCase();switch(a===-1&&(c=this.maxDistance,S=this.minDistance,h=A.position.distanceTo(this.target),n.copy(this.target)),u){case this.forwardKey:i=!0;break;case this.backKey:g=!0;break;case this.leftKey:C=!0;break;case this.rightKey:o=!0;break;case this.upKey:E=!0;break;case this.downKey:r=!0;break;case this.fastKey:t=!0;break}switch(u){case this.fastKey:case this.forwardKey:case this.backKey:case this.leftKey:case this.rightKey:case this.upKey:case this.downKey:w.stopPropagation(),w.preventDefault()}(i||g||C||o||E||r||t)&&(this.minDistance=.01,this.maxDistance=.01,N.set(0,0,-1,0).applyMatrix4(A.matrixWorld),this.target.copy(A.position).addScaledVector(N,.01),a===-1&&(this.dispatchEvent(uI),d.getDelta(),D()))},R=w=>{const u=w.key.toLowerCase();switch(u){case this.fastKey:case this.forwardKey:case this.backKey:case this.leftKey:case this.rightKey:case this.upKey:case this.downKey:w.stopPropagation(),w.preventDefault()}switch(u){case this.forwardKey:i=!1;break;case this.backKey:g=!1;break;case this.leftKey:C=!1;break;case this.rightKey:o=!1;break;case this.upKey:E=!1;break;case this.downKey:r=!1;break;case this.fastKey:t=!1;break}i||g||C||o||E||r||t||l()},M=()=>{l()};this.blurCallback=M,this.keyDownCallback=F,this.keyUpCallback=R,this.disableShiftKeyCallback=I,this.domElement.addEventListener("blur",M),this.domElement.addEventListener("keydown",F),this.domElement.addEventListener("keyup",R)}dispose(){super.dispose(),this.domElement.removeEventListener("blur",this.blurCallback),this.domElement.removeEventListener("keydown",this.keyDownCallback),this.domElement.removeEventListener("keyup",this.keyUpCallback),this.domElement.removeEventListener("pointerdown",this.disableShiftKeyCallback)}}class LI{constructor(A=4){this.pool=A,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(A){if(!this.workers[A]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,A)),this.workers[A]=e}}_getIdleWorker(){for(let A=0;A{const t=this._getIdleWorker();t!==-1?(this._initWorker(t),this.workerStatus|=1<A.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const kI=0,WA=2,NI=1,XA=2,MI=0,_I=1,xI=10,TI=0,ge=9,Be=15,Ce=16,oe=22,se=37,Qe=43,Ee=76,ae=83,ne=97,re=100,ce=103,he=109,le=165,de=166,YA=1000066e3;class qI{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class gA{constructor(A,e,I,t){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(A.buffer,A.byteOffset+e,I),this._littleEndian=t,this._offset=0}_nextUint8(){const A=this._dataView.getUint8(this._offset);return this._offset+=1,A}_nextUint16(){const A=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,A}_nextUint32(){const A=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,A}_nextUint64(){const A=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,A}_nextInt32(){const A=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,A}_nextUint8Array(A){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,A);return this._offset+=A,e}_skip(A){return this._offset+=A,this}_scan(A,e){e===void 0&&(e=0);const I=this._offset;let t=0;for(;this._dataView.getUint8(this._offset)!==e&&tA.arrayBuffer()).then(A=>WebAssembly.instantiate(A,NA)).then(this._init):WebAssembly.instantiate(Buffer.from(zA,"base64"),NA).then(this._init),kA)}_init(A){K=A.instance,NA.env.emscripten_notify_memory_growth(0)}decode(A,e=0){if(!K)throw new Error("ZSTDDecoder: Await .init() before decoding.");const I=A.byteLength,t=K.exports.malloc(I);HA.set(A,t),e=e||Number(K.exports.ZSTD_findDecompressedSize(t,I));const i=K.exports.malloc(e),g=K.exports.ZSTD_decompress(i,e,t,I),C=HA.slice(i,i+g);return K.exports.free(t),K.exports.free(i),C}}const zA="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",bI="display-p3",YI="display-p3-linear",MA=new WeakMap;let _A=0,xA;class H extends Ue{constructor(A){super(A),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new LI,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(A){return this.transcoderPath=A,this}setWorkerLimit(A){return this.workerPool.setWorkerLimit(A),this}async detectSupportAsync(A){return this.workerConfig={astcSupported:await A.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await A.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await A.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await A.hasFeatureAsync("texture-compression-bc"),bptcSupported:await A.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await A.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(A){return A.isWebGPURenderer===!0?this.workerConfig={astcSupported:A.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:A.hasFeature("texture-compression-etc1"),etc2Supported:A.hasFeature("texture-compression-etc2"),dxtSupported:A.hasFeature("texture-compression-bc"),bptcSupported:A.hasFeature("texture-compression-bptc"),pvrtcSupported:A.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:A.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:A.extensions.has("WEBGL_compressed_texture_astc")&&A.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:A.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:A.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:A.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:A.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:A.extensions.has("WEBGL_compressed_texture_pvrtc")||A.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const A=new GA(this.manager);A.setPath(this.transcoderPath),A.setWithCredentials(this.withCredentials);const e=A.loadAsync("basis_transcoder.js"),I=new GA(this.manager);I.setPath(this.transcoderPath),I.setResponseType("arraybuffer"),I.setWithCredentials(this.withCredentials);const t=I.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,t]).then(([i,g])=>{const C=H.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(H.EngineFormat),"let _EngineType = "+JSON.stringify(H.EngineType),"let _TranscoderFormat = "+JSON.stringify(H.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(H.BasisFormat),"/* basis_transcoder.js */",i,"/* worker */",C.substring(C.indexOf("{")+1,C.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=g,this.workerPool.setWorkerCreator(()=>{const E=new Worker(this.workerSourceURL),r=this.transcoderBinary.slice(0);return E.postMessage({type:"init",config:this.workerConfig,transcoderBinary:r},[r]),E})}),_A>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_A++}return this.transcoderPending}load(A,e,I,t){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const i=new GA(this.manager);i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials),i.load(A,g=>{this.parse(g,e,t)},I,t)}parse(A,e,I){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(MA.has(A))return MA.get(A).promise.then(e).catch(I);this._createTexture(A).then(t=>e?e(t):null).catch(I)}_createTextureFrom(A,e){const{type:I,error:t,data:{faces:i,width:g,height:C,format:o,type:E,dfdFlags:r}}=A;if(I==="error")return Promise.reject(t);let h;if(e.faceCount===6)h=new Le(i,o,E);else{const S=i[0].mipmaps;h=e.layerCount>1?new ke(S,g,C,e.layerCount,o,E):new te(S,g,C,o,E)}return h.minFilter=i[0].mipmaps.length===1?KA:Ne,h.magFilter=KA,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=we(e),h.premultiplyAlpha=!!(r&NI),h}async _createTexture(A,e={}){const I=HI(new Uint8Array(A)),t=I.vkFormat===YA&&I.dataFormatDescriptor[0].colorModel===167;if(!(I.vkFormat===TI||t&&!this.workerConfig.astcHDRSupported))return PI(I);const g=e,C=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:A,taskConfig:g},[A])).then(o=>this._createTextureFrom(o.data,I));return MA.set(A,{promise:C}),C}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),_A--,this}}H.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2};H.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25};H.EngineFormat={RGBAFormat:AA,RGBA_ASTC_4x4_Format:ie,RGB_BPTC_UNSIGNED_Format:Me,RGBA_BPTC_Format:_e,RGBA_ETC2_EAC_Format:xe,RGBA_PVRTC_4BPPV1_Format:Te,RGBA_S3TC_DXT5_Format:qe,RGB_ETC1_Format:He,RGB_ETC2_Format:Je,RGB_PVRTC_4BPPV1_Format:be,RGBA_S3TC_DXT1_Format:Ye};H.EngineType={UnsignedByteType:Y,HalfFloatType:eA,FloatType:sA};H.BasisWorker=function(){let B,A,e;const I=_EngineFormat,t=_EngineType,i=_TranscoderFormat,g=_BasisFormat;self.addEventListener("message",function(a){const n=a.data;switch(n.type){case"init":B=n.config,C(n.transcoderBinary);break;case"transcode":A.then(()=>{try{const{faces:d,buffers:l,width:D,height:F,hasAlpha:R,format:M,type:w,dfdFlags:u}=o(n.buffer);self.postMessage({type:"transcode",id:n.id,data:{faces:d,width:D,height:F,hasAlpha:R,format:M,type:w,dfdFlags:u}},l)}catch(d){console.error(d),self.postMessage({type:"error",id:n.id,error:d.message})}});break}});function C(a){A=new Promise(n=>{e={wasmBinary:a,onRuntimeInitialized:n},BASIS(e)}).then(()=>{e.initializeBasis(),e.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function o(a){const n=new e.KTX2File(new Uint8Array(a));function d(){n.close(),n.delete()}if(!n.isValid())throw d(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let l;if(n.isUASTC())l=g.UASTC;else if(n.isETC1S())l=g.ETC1S;else if(n.isHDR())l=g.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const D=n.getWidth(),F=n.getHeight(),R=n.getLayers()||1,M=n.getLevels(),w=n.getFaces(),u=n.getHasAlpha(),rA=n.getDFDFlags(),{transcoderFormat:IA,engineFormat:tA,engineType:Z}=h(l,D,F,u);if(!D||!F||!M)throw d(),new Error("THREE.KTX2Loader: Invalid texture");if(!n.startTranscoding())throw d(),new Error("THREE.KTX2Loader: .startTranscoding failed");const cA=[],hA=[];for(let W=0;W1?(_=j.origWidth,V=j.origHeight):(_=j.width,V=j.height);let $=new Uint8Array(n.getImageTranscodedSizeInBytes(O,z,0,IA));const Se=n.transcodeImage($,O,z,W,IA,0,-1,-1);if(Z===t.HalfFloatType&&($=new Uint16Array($.buffer,$.byteOffset,$.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!Se)throw d(),new Error("THREE.KTX2Loader: .transcodeImage failed.");U.push($)}const iA=c(U);lA.push({data:iA,width:_,height:V}),hA.push(iA.buffer)}cA.push({mipmaps:lA,width:D,height:F,format:tA,type:Z})}return d(),{faces:cA,buffers:hA,width:D,height:F,hasAlpha:u,dfdFlags:rA,format:tA,type:Z}}const E=[{if:"astcSupported",basisFormat:[g.UASTC],transcoderFormat:[i.ASTC_4x4,i.ASTC_4x4],engineFormat:[I.RGBA_ASTC_4x4_Format,I.RGBA_ASTC_4x4_Format],engineType:[t.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.BC7_M5,i.BC7_M5],engineFormat:[I.RGBA_BPTC_Format,I.RGBA_BPTC_Format],engineType:[t.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.BC1,i.BC3],engineFormat:[I.RGBA_S3TC_DXT1_Format,I.RGBA_S3TC_DXT5_Format],engineType:[t.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.ETC1,i.ETC2],engineFormat:[I.RGB_ETC2_Format,I.RGBA_ETC2_EAC_Format],engineType:[t.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.ETC1],engineFormat:[I.RGB_ETC1_Format],engineType:[t.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.PVRTC1_4_RGB,i.PVRTC1_4_RGBA],engineFormat:[I.RGB_PVRTC_4BPPV1_Format,I.RGBA_PVRTC_4BPPV1_Format],engineType:[t.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[g.UASTC_HDR],transcoderFormat:[i.BC6H],engineFormat:[I.RGB_BPTC_UNSIGNED_Format],engineType:[t.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[g.ETC1S,g.UASTC],transcoderFormat:[i.RGBA32,i.RGBA32],engineFormat:[I.RGBAFormat,I.RGBAFormat],engineType:[t.UnsignedByteType,t.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[g.UASTC_HDR],transcoderFormat:[i.RGBA_HALF],engineFormat:[I.RGBAFormat],engineType:[t.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],r={[g.ETC1S]:E.filter(a=>a.basisFormat.includes(g.ETC1S)).sort((a,n)=>a.priorityUASTC-n.priorityUASTC),[g.UASTC]:E.filter(a=>a.basisFormat.includes(g.UASTC)).sort((a,n)=>a.priorityUASTC-n.priorityUASTC),[g.UASTC_HDR]:E.filter(a=>a.basisFormat.includes(g.UASTC_HDR)).sort((a,n)=>a.priorityHDR-n.priorityHDR)};function h(a,n,d,l){const D=r[a];for(let F=0;F{const g=new JI;await g.init(),i(g)})),e=await xA);const I=[];for(let i=0;i>i),C=Math.max(1,B.pixelHeight>>i),o=B.pixelDepth?Math.max(1,B.pixelDepth>>i):0,E=B.levels[i];let r;if(B.supercompressionScheme===kI)r=E.levelData;else if(B.supercompressionScheme===WA)r=e.decode(E.levelData,E.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let h;qA[A]===sA?h=new Float32Array(r.buffer,r.byteOffset,r.byteLength/Float32Array.BYTES_PER_ELEMENT):qA[A]===eA?h=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/Uint16Array.BYTES_PER_ELEMENT):h=r,I.push({data:h,width:g,height:C,depth:o})}let t;if(KI.has(TA[A]))t=B.pixelDepth===0?new Ke(I[0].data,B.pixelWidth,B.pixelHeight):new Pe(I[0].data,B.pixelWidth,B.pixelHeight,B.pixelDepth);else{if(B.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");t=new te(I,B.pixelWidth,B.pixelHeight)}return t.mipmaps=I,t.type=qA[A],t.format=TA[A],t.colorSpace=we(B),t.needsUpdate=!0,Promise.resolve(t)}function we(B){const A=B.dataFormatDescriptor[0];return A.colorPrimaries===_I?A.transferFunction===XA?ve:Oe:A.colorPrimaries===xI?A.transferFunction===XA?bI:YI:A.colorPrimaries===MI?PA:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${A.colorPrimaries}"`),PA)}const vI=1,De=2,ye=window.location.hash.replace(/^#/,"");let p,oA,J,f,s,QA,P,T,dA,y,EA,wA,L,G,aA,yA,JA,v,b,m,nA,X,q,x,fA;const Q={enableUpdate:!0,raycast:pA,optimizeRaycast:!0,enableCacheDisplay:!1,enableRendererStats:!1,orthographic:!1,errorTarget:6,errorThreshold:60,maxDepth:15,displayActiveTiles:!1,resolutionScale:1,up:ye?"+Z":"+Y",displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:0,showThirdPerson:!1,showSecondView:!1,reload:fe};OI();Ge();function fe(){const B=ye||"../data/tileset.json";s&&(q.remove(s.group),s.dispose()),s=new DI(B),s.registerPlugin(new wI),s.registerPlugin(new RI);const A=new BI;A.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const e=new H;e.setTranscoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/basis/"),e.detectSupport(f);const I=new gI(s.manager);I.setDRACOLoader(A),I.setKTX2Loader(e),I.register(()=>new FI),s.fetchOptions.mode="cors",s.manager.addHandler(/\.gltf$/,I),q.add(s.group),s.customColorCallback=(t,i)=>{const C=t.__depth%2===0?16711680:16777215;i.traverse(o=>{o.isMesh&&o.material.color.set(C)})}}function OI(){J=new Ve,f=new SA({antialias:!0}),f.setPixelRatio(window.devicePixelRatio),f.setSize(window.innerWidth,window.innerHeight),f.setClearColor(1383455),document.body.appendChild(f.domElement),f.domElement.tabIndex=1,p=new RA(60,window.innerWidth/window.innerHeight,1,1e4),p.position.set(400,400,400),QA=new mA(p),J.add(QA),G=new We,aA=new mA(G),J.add(aA),L=new RA(60,window.innerWidth/window.innerHeight,1,4e3),L.position.set(400,400,-400),L.lookAt(0,0,0),y=new SA({antialias:!0}),y.setPixelRatio(window.devicePixelRatio),y.setSize(window.innerWidth,window.innerHeight),y.setClearColor(1383455),document.body.appendChild(y.domElement),y.domElement.style.position="absolute",y.domElement.style.right="0",y.domElement.style.top="0",y.domElement.style.outline="#0f1416 solid 2px",y.domElement.tabIndex=1,wA=new LA(L,y.domElement),wA.screenSpacePanning=!1,wA.minDistance=1,wA.maxDistance=5e3,EA=new mA(L),J.add(EA),P=new RA(60,window.innerWidth/window.innerHeight,1,4e3),P.position.set(50,40,40),P.lookAt(0,0,0),T=new SA({antialias:!0}),T.setPixelRatio(window.devicePixelRatio),T.setSize(window.innerWidth,window.innerHeight),T.setClearColor(988182),document.body.appendChild(T.domElement),T.domElement.style.position="fixed",T.domElement.style.left="5px",T.domElement.style.bottom="5px",T.domElement.tabIndex=1,dA=new LA(P,T.domElement),dA.screenSpacePanning=!1,dA.minDistance=1,dA.maxDistance=5e3,oA=new LA(p,f.domElement),oA.screenSpacePanning=!1,oA.minDistance=1,oA.maxDistance=5e3;const B=new Xe(16777215,4);B.position.set(1,2,3),J.add(B);const A=new Ze(16777215,.2);J.add(A),yA=new AI,JA=new eI,X=new uA,J.add(X),q=new uA,X.add(q),v=new II,b=new bA,m=new uA;const e=new ze({color:15277667}),I=new OA(new je(.25,.25,6),e);I.rotation.x=Math.PI/2,I.position.z+=3,m.add(I);const t=new OA(new $e(1.5,.2,16,100),e);m.add(t),J.add(m),m.visible=!1,fe(),DA(),window.addEventListener("resize",DA,!1),f.domElement.addEventListener("pointermove",$A,!1),f.domElement.addEventListener("pointerdown",ee,!1),f.domElement.addEventListener("pointerup",Ie,!1),f.domElement.addEventListener("pointerleave",jA,!1),y.domElement.addEventListener("pointermove",$A,!1),y.domElement.addEventListener("pointerdown",ee,!1),y.domElement.addEventListener("pointerup",Ie,!1),y.domElement.addEventListener("pointerleave",jA,!1);const i=new CI;i.width=300;const g=i.addFolder("Tiles Options");g.add(Q,"displayActiveTiles"),g.add(Q,"errorTarget").min(0).max(50),g.add(Q,"errorThreshold").min(0).max(1e3),g.add(Q,"maxDepth").min(1).max(100),g.add(Q,"up",["+Y","+Z","-Z"]),g.open();const C=i.addFolder("Debug Options");C.add(Q,"displayBoxBounds"),C.add(Q,"displaySphereBounds"),C.add(Q,"displayRegionBounds"),C.add(Q,"colorMode",{NONE:pA,SCREEN_ERROR:sI,GEOMETRIC_ERROR:QI,DISTANCE:EI,DEPTH:aI,RELATIVE_DEPTH:nI,IS_LEAF:rI,RANDOM_COLOR:cI,RANDOM_NODE_COLOR:hI,CUSTOM_COLOR:lI,LOAD_ORDER:dI}),C.open();const o=i.addFolder("Example Options");o.add(Q,"resolutionScale").min(.01).max(2).step(.01).onChange(DA),o.add(Q,"orthographic"),o.add(Q,"showThirdPerson"),o.add(Q,"showSecondView").onChange(DA),o.add(Q,"enableUpdate").onChange(E=>{s.parseQueue.autoUpdate=E,s.downloadQueue.autoUpdate=E,E&&(s.parseQueue.scheduleJobRun(),s.downloadQueue.scheduleJobRun())}),o.add(Q,"raycast",{NONE:pA,ALL_HITS:vI,FIRST_HIT_ONLY:De}),o.add(Q,"optimizeRaycast"),o.add(Q,"enableCacheDisplay"),o.add(Q,"enableRendererStats"),o.open(),i.add(Q,"reload"),i.open(),x=document.createElement("div"),x.style.position="absolute",x.style.top=0,x.style.left=0,x.style.color="white",x.style.width="100%",x.style.textAlign="center",x.style.padding="5px",x.style.pointerEvents="none",x.style.lineHeight="1.5em",document.body.appendChild(x),fA=new oI,fA.showPanel(0),document.body.appendChild(fA.dom)}function DA(){P.aspect=window.innerWidth/window.innerHeight,P.updateProjectionMatrix(),T.setSize(Math.floor(window.innerWidth/3),Math.floor(window.innerHeight/3)),Q.showSecondView?(p.aspect=.5*window.innerWidth/window.innerHeight,f.setSize(.5*window.innerWidth,window.innerHeight),L.aspect=.5*window.innerWidth/window.innerHeight,y.setSize(.5*window.innerWidth,window.innerHeight),y.domElement.style.display="block"):(p.aspect=window.innerWidth/window.innerHeight,f.setSize(window.innerWidth,window.innerHeight),y.domElement.style.display="none"),p.updateProjectionMatrix(),f.setPixelRatio(window.devicePixelRatio*Q.resolutionScale),L.updateProjectionMatrix(),y.setPixelRatio(window.devicePixelRatio),Fe()}function jA(B){nA=null}function $A(B){const A=this.getBoundingClientRect();b.x=B.clientX-A.x,b.y=B.clientY-A.y,b.x=b.x/A.width*2-1,b.y=-(b.y/A.height)*2+1,nA=this}const pe=new bA,Ae=new bA;function ee(B){const A=this.getBoundingClientRect();pe.set(B.clientX-A.x,B.clientY-A.y)}function Ie(B){const A=this.getBoundingClientRect();if(Ae.set(B.clientX-A.x,B.clientY-A.y),pe.distanceTo(Ae)>2)return;nA===y.domElement?v.setFromCamera(b,L):v.setFromCamera(b,Q.orthographic?G:p),v.firstHitOnly=!0;const e=v.intersectObject(s.group,!0);if(e.length){const I=e[0].object,t=s.getPluginByName("DEBUG_TILES_PLUGIN").getTileInformationFromActiveObject(I);let i="";for(const g in t){let C=t[g];typeof C=="number"&&(C=Math.floor(C*1e5)/1e5);let o=g;for(;o.length<20;)o+=" ";i+=`${o} : ${C} +`}console.log(i)}}function Fe(){G.position.copy(p.position),G.rotation.copy(p.rotation);const B=p.position.distanceTo(oA.target)/2;let A=window.innerWidth/window.innerHeight;Q.showSecondView&&(A*=.5),G.left=-A*B,G.right=A*B,G.bottom=-B,G.top=B,G.near=p.near,G.far=p.far,G.updateProjectionMatrix()}function Ge(){requestAnimationFrame(Ge),s.errorTarget=Q.errorTarget,s.errorThreshold=Q.errorThreshold,s.optimizeRaycast=Q.optimizeRaycast,s.displayActiveTiles=Q.displayActiveTiles,s.maxDepth=Q.maxDepth;const B=s.getPluginByName("DEBUG_TILES_PLUGIN");if(B.displayBoxBounds=Q.displayBoxBounds,B.displaySphereBounds=Q.displaySphereBounds,B.displayRegionBounds=Q.displayRegionBounds,B.colorMode=parseFloat(Q.colorMode),Q.orthographic?(s.deleteCamera(p),s.setCamera(G),s.setResolutionFromRenderer(G,f)):(s.deleteCamera(G),s.setCamera(p),s.setResolutionFromRenderer(p,f)),Q.showSecondView?(s.setCamera(L),s.setResolutionFromRenderer(L,y)):s.deleteCamera(L),s.root&&s.root.boundingVolume.region&&(s.getOrientedBoundingBox(yA,q.matrix),q.matrix.decompose(q.position,q.quaternion,q.scale),q.position.set(0,0,0),q.quaternion.invert(),q.scale.set(1,1,1)),X.rotation.set(0,0,0),Q.up==="-Z"?X.rotation.x=Math.PI/2:Q.up==="+Z"&&(X.rotation.x=-Math.PI/2),X.updateMatrixWorld(!1),s.getBoundingBox(yA)?(yA.getCenter(s.group.position),s.group.position.multiplyScalar(-1)):s.getBoundingSphere(JA)&&(s.group.position.copy(JA.center),s.group.position.multiplyScalar(-1)),parseFloat(Q.raycast)!==pA&&nA!==null){nA===f.domElement?v.setFromCamera(b,Q.orthographic?G:p):v.setFromCamera(b,L),v.firstHitOnly=parseFloat(Q.raycast)===De;const A=v.intersectObject(s.group,!0);if(A.length){const e=A[0],I=e.point;if(m.position.copy(I),e.face){const t=e.face.normal;t.transformDirection(e.object.matrixWorld),m.lookAt(I.x+t.x,I.y+t.y,I.z+t.z)}m.visible=!0}else m.visible=!1}else m.visible=!1;window.tiles=s,Q.enableUpdate&&(L.updateMatrixWorld(),p.updateMatrixWorld(),G.updateMatrixWorld(),s.update()),VI(),fA.update()}function VI(){if(Fe(),QA.visible=!1,aA.visible=!1,EA.visible=!1,Q.orthographic){const e=G.position.distanceTo(m.position);m.scale.setScalar(e/150)}else{const e=p.position.distanceTo(m.position);m.scale.setScalar(e*p.fov/6e3)}if(f.render(J,Q.orthographic?G:p),Q.showSecondView){const e=L.position.distanceTo(m.position);m.scale.setScalar(e*L.fov/6e3),y.render(J,L)}if(T.domElement.style.visibility=Q.showThirdPerson?"visible":"hidden",Q.showThirdPerson){QA.update(),QA.visible=!Q.orthographic,aA.update(),aA.visible=Q.orthographic,Q.showSecondView&&(EA.update(),EA.visible=!0);const e=P.position.distanceTo(m.position);m.scale.setScalar(e*P.fov/6e3),T.render(J,P)}const B=s.lruCache.itemList.length/s.lruCache.maxSize;let A=`Downloading: ${s.stats.downloading} Parsing: ${s.stats.parsing} Visible: ${s.visibleTiles.size}`;if(Q.enableCacheDisplay){const e=new Set;s.traverse(t=>{const i=t.cached.scene;i&&i.traverse(g=>{g.geometry&&e.add(g.geometry)})});let I=0;e.forEach(t=>{I+=iI(t)}),A+=`
Cache: ${(100*B).toFixed(2)}% ~${(I/1e3/1e3).toFixed(2)}mb`}if(Q.enableRendererStats){const e=f.info.memory,I=f.info.programs.length;A+=`
Geometries: ${e.geometries} Textures: ${e.textures} Programs: ${I}`}x.innerHTML!==A&&(x.innerHTML=A)} diff --git a/example/bundle/assets/ion-BQobsELj.js b/example/bundle/assets/ion-BQobsELj.js new file mode 100644 index 00000000..9b04599c --- /dev/null +++ b/example/bundle/assets/ion-BQobsELj.js @@ -0,0 +1 @@ +import{d as g,k as d}from"./three.module-DpclfMcJ.js";import{c as x,j as e,r as b,C as k,T as f,a as s,E as P,b as C}from"./CameraControls-DhgPIfmg.js";import{D as v}from"./DRACOLoader-DJWREZh5.js";import{u as j,G as y,T as E}from"./leva.esm-BicpJr1E.js";import{C as T}from"./CesiumIonAuthPlugin-DCN_lM0S.js";import{O as L}from"./Ellipsoid-Cnb0UTwk.js";import{U as M}from"./UpdateOnChangePlugin-BFotcVNs.js";import{G as I,a as w}from"./GizmoViewport-BC-gHgu9.js";import"./EnvironmentControls-C8X7oAWq.js";import"./GlobeControls-BUn2ddB7.js";import"./TilesRenderer-DdUhzUiO.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./GLTFMeshFeaturesExtension-D473cUUw.js";import"./Pass-inUSP30K.js";import"./GoogleCloudAuthPlugin-B9LFbpXw.js";const l=new g,m=new d;class z{constructor(t){t={up:"+z",recenter:!0,lat:null,lon:null,height:0,...t},this.tiles=null,this.up=t.up.toLowerCase().replace(/\s+/,""),this.lat=t.lat,this.lon=t.lon,this.height=t.height,this.recenter=t.recenter,this._callback=null}init(t){this.tiles=t,this._callback=()=>{const{up:i,lat:a,lon:r,height:n,recenter:u}=this;if(a!==null&&r!==null)this.transformLatLonHeightToOrigin(a,r,n);else{const{ellipsoid:p}=t,h=Math.min(...p.radius);if(t.getBoundingSphere(l),l.center.length()>h*.5){const o={};p.getPositionToCartographic(l.center,o),this.transformLatLonHeightToOrigin(o.lat,o.lon,o.height)}else{const o=t.group;switch(o.rotation.set(0,0,0),i){case"x":case"+x":o.rotation.z=Math.PI/2;break;case"-x":o.rotation.z=-Math.PI/2;break;case"y":case"+y":break;case"-y":o.rotation.z=Math.PI;break;case"z":case"+z":o.rotation.x=-Math.PI/2;break;case"-z":o.rotation.x=Math.PI/2;break}t.group.position.copy(l.center).applyEuler(o.rotation).multiplyScalar(-1)}}u||t.group.position.setScalar(0),t.removeEventListener("load-tile-set",this._callback)},t.addEventListener("load-tile-set",this._callback)}transformLatLonHeightToOrigin(t,i,a=0){const{group:r,ellipsoid:n}=this.tiles;n.getRotationMatrixFromAzElRoll(t,i,0,0,0,r.matrix,L),n.getCartographicToPosition(t,i,a,m),r.matrix.setPosition(m).invert().decompose(r.position,r.quaternion,r.scale),r.updateMatrixWorld()}dispose(){const{group:t}=this.tiles;t.position.setScalar(0),t.quaternion.identity(),t.scale.set(1,1,1),this.tiles.addEventListener("load-tile-set",this._callback)}}const R=new v().setDecoderPath("https://www.gstatic.com/draco/v1/decoders/");function S(){const c={apiToken:{value:localStorage.getItem("ion-token")||"put-your-api-key-here",onChange:a=>localStorage.setItem("ion-token",a),transient:!1},assetId:{value:"40866",options:{"Aerometrex - San Francisco":"1415196","Aerometrex - Denver":"354307","New York City 3D Buildings":"75343","Melbourne Photogrammetry":"69380","Cesium HQ":"40866","Melbourne Point Cloud":"43978","Montreal Point Cloud":"28945"}}},{apiToken:t,assetId:i}=j(c);return e.jsxs(k,{frameloop:"demand",camera:{position:[300,300,300],near:1,far:1e5},style:{width:"100%",height:"100%",position:"absolute",margin:0,left:0,top:0},children:[e.jsxs(f,{children:[e.jsx(s,{plugin:T,args:{apiToken:t,assetId:i}}),e.jsx(s,{plugin:y,dracoLoader:R}),e.jsx(s,{plugin:z}),e.jsx(s,{plugin:M}),e.jsx(E,{})]},i+t),e.jsx(P,{enableDamping:!0,maxDistance:5e3}),e.jsx(C,{preset:"sunset",background:!0,backgroundBlurriness:.9,environmentIntensity:1}),e.jsx(I,{alignment:"bottom-right",children:e.jsx(w,{})})]})}x(document.getElementById("root")).render(e.jsx(b.StrictMode,{children:e.jsx(S,{})})); diff --git a/example/bundle/assets/ionExample-1LyF3OmL.js b/example/bundle/assets/ionExample-1LyF3OmL.js new file mode 100644 index 00000000..92a5d36c --- /dev/null +++ b/example/bundle/assets/ionExample-1LyF3OmL.js @@ -0,0 +1 @@ +import{S as f,o as h,ab as A,W as x,a as T,d as y,k as l,Q as C}from"./three.module-DpclfMcJ.js";import{G as I}from"./GLTFLoader-DkJa3Jo5.js";import{D as R}from"./DRACOLoader-DJWREZh5.js";import{g as k}from"./lil-gui.module.min-Bc0DeA9g.js";import{E as z}from"./EnvironmentControls-C8X7oAWq.js";import{T as E}from"./TilesRenderer-DdUhzUiO.js";import{C as P}from"./CesiumIonAuthPlugin-DCN_lM0S.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./GoogleCloudAuthPlugin-B9LFbpXw.js";let i,c,a,r,e;const v=localStorage.getItem("ionApiKey")??"put-your-api-key-here",s={ionAssetId:"40866",ionAccessToken:v,reload:u};S();w();function D(o,t){const n=new C,d=new l().crossVectors(o,t);return n.x=d.x,n.y=d.y,n.z=d.z,n.w=1+o.clone().dot(t),n.normalize(),n}function L(){e.fetchOptions.mode="cors";const o=new R;o.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const t=new I(e.manager);t.setDRACOLoader(o),e.manager.addHandler(/\.gltf$/,t),a.add(e.group)}function u(){e&&(a.remove(e.group),e.dispose(),e=null),localStorage.setItem("ionApiKey",s.ionAccessToken),e=new E,e.registerPlugin(new P({apiToken:s.ionAccessToken,assetId:s.ionAssetId})),e.addEventListener("load-tile-set",()=>{const o=new y;e.getBoundingSphere(o);const t=o.center.clone(),n=t.length(),d=t.normalize(),g=new l(0,1,0),p=D(d,g);e.group.quaternion.x=p.x,e.group.quaternion.y=p.y,e.group.quaternion.z=p.z,e.group.quaternion.w=p.w,e.group.position.y=-n}),L()}function S(){a=new f;const o=new h(new Uint8Array(64*64*4).fill(255),64,64);o.mapping=A,o.needsUpdate=!0,a.environment=o,r=new x({antialias:!0}),r.setClearColor(1383455),document.body.appendChild(r.domElement),r.domElement.tabIndex=1,i=new T(60,window.innerWidth/window.innerHeight,1,1e5),i.position.set(100,100,-100),i.lookAt(0,0,0),c=new z(a,i,r.domElement),c.adjustHeight=!1,c.minDistance=1,c.maxAltitude=Math.PI,u(),m(),window.addEventListener("resize",m,!1);const t=new k;t.width=300;const n=t.addFolder("Ion");n.add(s,"ionAssetId"),n.add(s,"ionAccessToken"),n.add(s,"reload"),n.open()}function m(){i.aspect=window.innerWidth/window.innerHeight,i.updateProjectionMatrix(),r.setSize(window.innerWidth,window.innerHeight),r.setPixelRatio(window.devicePixelRatio)}function w(){requestAnimationFrame(w),e&&(c.update(),e.setCamera(i),e.setResolutionFromRenderer(i,r),i.updateMatrixWorld(),e.update(),r.render(a,i))} diff --git a/example/bundle/assets/ionLunar-DPf-S6o0.js b/example/bundle/assets/ionLunar-DPf-S6o0.js new file mode 100644 index 00000000..ba7d70d4 --- /dev/null +++ b/example/bundle/assets/ionLunar-DPf-S6o0.js @@ -0,0 +1 @@ +import{W as d,S as l,a as u}from"./three.module-DpclfMcJ.js";import{g as w}from"./lil-gui.module.min-Bc0DeA9g.js";import{G as g}from"./GlobeControls-BUn2ddB7.js";import{T as c}from"./TilesRenderer-DdUhzUiO.js";import{L as f}from"./I3DMLoader-BlebwdUJ.js";import{C as P}from"./CesiumIonAuthPlugin-DCN_lM0S.js";import{T as h}from"./TileCompressionPlugin-Bcbrk_fI.js";import{U as y}from"./UpdateOnChangePlugin-BFotcVNs.js";import{T}from"./TilesFadePlugin-GTJOynw2.js";import"./EnvironmentControls-C8X7oAWq.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./GoogleCloudAuthPlugin-B9LFbpXw.js";let n,o,i,r,e;const C=localStorage.getItem("ionApiKey")??"put-your-api-key-here",a={apiKey:C,reload:p};R();m();function p(){e&&(o.remove(e.group),e.dispose(),e=null),localStorage.setItem("ionApiKey",a.apiKey),e=new c,e.ellipsoid.copy(f),e.registerPlugin(new P({apiToken:a.apiKey,assetId:"2684829",autoRefreshToken:!0})),e.registerPlugin(new h),e.registerPlugin(new y),e.registerPlugin(new T),e.group.rotation.x=-Math.PI/2,e.errorTarget=20,o.add(e.group),e.setCamera(i),n.setTilesRenderer(e)}function R(){r=new d({antialias:!0}),r.setClearColor(1383455),document.body.appendChild(r.domElement),o=new l,i=new u(60,window.innerWidth/window.innerHeight,1,16e7),i.position.set(2620409,0,-6249816),i.lookAt(0,0,0),n=new g(o,i,r.domElement,null),n.enableDamping=!0,p(),s(),window.addEventListener("resize",s,!1);const t=new w;t.width=300,t.add(a,"apiKey"),t.add(a,"reload")}function s(){const t=window.innerWidth/window.innerHeight;i.aspect=t,i.updateProjectionMatrix(),r.setSize(window.innerWidth,window.innerHeight),r.setPixelRatio(window.devicePixelRatio)}function m(){requestAnimationFrame(m),e&&(n.update(),e.setResolutionFromRenderer(i,r),i.updateMatrixWorld(),e.update(),r.render(o,i))} diff --git a/example/bundle/assets/landformSiteOverlay-gh-eB817.js b/example/bundle/assets/landformSiteOverlay-gh-eB817.js new file mode 100644 index 00000000..4511c8d7 --- /dev/null +++ b/example/bundle/assets/landformSiteOverlay-gh-eB817.js @@ -0,0 +1,29 @@ +import{k as v,j as N,Q as P,C as k,ac as J,ad as S,S as U,W as j,a as q,G as I,a2 as Y,n as B}from"./three.module-DpclfMcJ.js";import{g as D}from"./lil-gui.module.min-Bc0DeA9g.js";import{P as Q,T as V}from"./TilesRenderer-DdUhzUiO.js";import{E as K}from"./EnvironmentControls-C8X7oAWq.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";const M=new v,w=new P,y=new v;function E(a,e){if(a.sceneMatrix)return;const{translation:t,rotation:r,scale:s}=a;if(M.set(t.x,t.y,t.z),w.set(r.x,r.y,r.z,r.w),y.set(s.x,s.y,s.z),a.matrix=new N().compose(M,w,y),a.sceneMatrix=new N().copy(a.matrix),a.parent_id!==""){const i=e.find(o=>o.id===a.parent_id);E(i,e),a.sceneMatrix.premultiply(i.sceneMatrix)}}class W{constructor(){this.fetchOptions={}}loadAsync(e){return fetch(e,this.fetchOptions).then(t=>t.json()).then(t=>this.parse(t))}parse(e){return e.frames.forEach(t=>E(t,e.frames)),e}}const z=a=>class extends a{constructor(...e){super(...e),this.textures=[],this.overlayColor=new k(8716287),this.displayAsOverlay=!1}onBeforeCompile(e){const t=this.textures,r=this;e.uniforms.textures={get value(){return r.textures}},e.uniforms.overlayColor={get value(){return r.overlayColor}},e.defines={DISPLAY_AS_OVERLAY:Number(this.displayAsOverlay)},t.length!==0&&(e.fragmentShader=e.fragmentShader.replace(/void main/,s=>` + uniform sampler2D textures[ ${t.length} ]; + uniform vec3 overlayColor; + ${s} + + `).replace(/#include /,s=>` + + ${s} + + vec4 col; + #pragma unroll_loop_start + for ( int i = 0; i < ${t.length}; i ++ ) { + + col = texture( textures[ i ], vMapUv ); + + #if DISPLAY_AS_OVERLAY + + diffuseColor = mix( diffuseColor, vec4( overlayColor, 1.0 ), col.r * 0.5 ); + + #else + + diffuseColor = mix( diffuseColor, col, col.a ); + + #endif + + } + #pragma unroll_loop_end + + `))}customProgramCacheKey(){return String(this.displayAsOverlay)+String(this.textures.length)+this.onBeforeCompile.toString()}};function G(){let a=!1,e=!1,t=-1;return typeof navigator<"u"&&(a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,e=navigator.userAgent.indexOf("Firefox")>-1,t=e?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),!(typeof createImageBitmap>"u"||a||e&&t<98)}class ${constructor(e,t){this.cache={},this.fetchOptions={},this.loadTextureCallback=e,this.queue=t}getTextureLoader(){const e=this.fetchOptions;let t;return G()?t=new J:t=new S,e.credentials==="include"&&e.mode==="cors"&&t.setCrossOrigin("use-credentials"),"credentials"in e&&t.setWithCredentials(e.credentials==="include"),e.headers&&t.setRequestHeader(e.headers),t}loadTexture(e){const t=this.cache;if(e in t)return t[e].promise;const r=new AbortController,s=this.queue.add(e,()=>this.loadTextureCallback(e)).then(i=>{if(r.signal.aborted)throw new Error("TextureCache: Texture load aborted.");return t[e].texture=i,i});return this.cache[e]={texture:null,abortController:r,promise:s},s}getTexture(e){const t=this.cache;return e in t?t[e].texture:null}deleteTexture(e){const t=this.cache;if(e in t){const r=t[e];r.refs--,r.refs===0&&(r.texture?r.texture.dispose():r.abortController&&(r.abortController.abort(),this.queue.remove(e)),delete this.cache[e])}}dispose(){const e=this.cache;for(const t in e){const r=e[t];r.texture?(r.texture.dispose(),r.texture.image instanceof ImageBitmap&&r.texture.image.close()):r.abortController&&r.abortController.abort()}}}class H{constructor(e={}){e={textureUpdateCallback:()=>{throw new Error('TextureOverlayPlugin: "textureUpdateCallback" required.')},waitForLoadCompletion:!0,...e},this.name="TEXTURE_OVERLAY_PLUGIN",this.caches=null,this.queue=null,this.tiles=null,this.textureUpdateCallback=e.textureUpdateCallback,this.waitForLoadCompletion=e.waitForLoadCompletion}init(e){this.tiles=e,this.caches={},this.queue=new Q,this.queue.priorityCallback=(t,r)=>e.downloadQueue.priorityCallback(t,r),this._disposeModelCallback=({tile:t})=>{const r=this.caches;for(const s in r)r[s].deleteTexture(this.getTileKey(t))},this._assignTexturesCallback=({tile:t,scene:r})=>{queueMicrotask(()=>this.textureUpdateCallback(r,t,this))},e.addEventListener("dispose-model",this._disposeModelCallback),e.addEventListener("load-model",this._assignTexturesCallback),e.addEventListener("layer-textures-change",this._assignTexturesCallback)}processTileModel(e,t){const r=this.caches,s=[];for(const i in r){const n=r[i].loadTexture(this.getTileKey(t)).catch(()=>{});s.push(n)}return Promise.all(s)}dispose(){const{caches:e,tiles:t}=this;Object.keys(e).forEach(r=>{this.unregisterLayer(r)}),t.removeEventListener("dispose-model",this._disposeModelCallback),t.removeEventListener("load-model",this._assignTexturesCallback),t.removeEventListener("layer-textures-change",this._assignTexturesCallback)}getTileKey(e){return new URL(e.content.uri,e.__basePath+"/").toString()}getTexturesForTile(e,t={}){const r=this.getTileKey(e),s=this.caches;for(const i in t)i in s||delete t[i];for(const i in s)t[i]=s[i].getTexture(r);return t}hasLayer(e){return e in this.caches}registerLayer(e,t){if(e in this.caches)throw new Error(`TextureOverlayPlugin: Texture overlay named ${e} already exists.`);const r=this.tiles,s=new $(t,this.queue);if(s.fetchOptions=r.fetchOptions,this.caches[e]=s,this.waitForLoadCompletion){const i=[];r.forEachLoadedModel((o,n)=>{const c=s.loadTexture(this.getTileKey(n)).then(()=>({scene:o,tile:n}));i.push(c)}),Promise.allSettled(i).then(o=>{e in this.caches&&o.forEach(n=>{n.status==="fulfilled"&&this.textureUpdateCallback(n.value.scene,n.value.tile,this)})})}else r.forEachLoadedModel((i,o)=>{s.loadTexture(this.getTileKey(o)).then(()=>this.textureUpdateCallback(i,o,this)).catch(()=>{})})}unregisterLayer(e){const t=this.tiles,r=this.caches;if(e in r){const s=r[e];delete r[e],t.forEachLoadedModel((i,o)=>{s.getTexture(this.getTileKey(o))&&this.textureUpdateCallback(i,o,this)}),s.dispose()}}}const X=["NLF_0477_0709296508M723RAS_N0261004NCAM00701_0A0085J02/NLF_0477_0709296508M723RAS_N0261004NCAM00701_0A0085J02_scene.json","NLF_0477_0709296508M723RAS_N0261004NCAM00708_0A00LLJ02/NLF_0477_0709296508M723RAS_N0261004NCAM00708_0A00LLJ02_scene.json","NLF_0477_0709297328M366RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297328M366RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297503M102RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297503M102RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297668M065RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297668M065RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297838M897RAS_N0261004NCAM02477_0A0195J02/NLF_0477_0709297838M897RAS_N0261004NCAM02477_0A0195J02_scene.json","NLF_0477_0709298005M099RAS_N0261004NCAM02477_0A0195J02/NLF_0477_0709298005M099RAS_N0261004NCAM02477_0A0195J02_scene.json","NLF_0477_0709298187M680RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298187M680RAS_N0261004NCAM13477_0A0195J02_scene.json","NLF_0477_0709298299M678RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298299M678RAS_N0261004NCAM13477_0A0195J02_scene.json","NLF_0477_0709298393M010RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298393M010RAS_N0261004NCAM13477_0A0195J02_scene.json"].map(a=>"https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/m20-drive-1004/tilesets/"+a),x=[];let d,f,A,u;const g={errorTarget:12,slopeDisplay:"NONE"};Z();R();function Z(){A=new U,u=new j({antialias:!0}),u.setPixelRatio(window.devicePixelRatio),u.setSize(window.innerWidth,window.innerHeight),u.setClearColor(14208704),document.body.appendChild(u.domElement),u.domElement.tabIndex=1,d=new q(60,window.innerWidth/window.innerHeight,.025,4e3),d.position.set(-20,10,20),d.lookAt(0,0,0),f=new K(A,d,u.domElement),f.adjustHeight=!1,f.minDistance=1,f.maxAltitude=Math.PI;const a=new I;a.rotation.set(Math.PI/2,0,0),A.add(a);let e=null,t=null,r=null;const s=async o=>{const n=o.replace("/tilesets/","/textures/SMG/").replace(/\.[0-9a-z]+$/i,".png");return new S().loadAsync(n).then(c=>(c.colorSpace=Y,c.flipY=!1,c))};X.forEach(async o=>{const n=await new W().loadAsync(o),c=o.split(/[\\/]/g);c.pop();const C=z(B);n.tilesets.forEach(p=>{const b=[...c,`${p.id}_tileset.json`].join("/"),l=new V(b),O=(m,L,_)=>{m.traverse(h=>{h.material&&(h.material.textures=Object.values(_.getTexturesForTile(L)),h.material.displayAsOverlay=g.slopeDisplay==="OVERLAY",h.material.needsUpdate=!0)})},F=new H({textureUpdateCallback:O});l.registerPlugin(F),l.addEventListener("load-model",({tile:m,scene:L})=>{L.traverse(_=>{if(_.material){const h=new C;h.copy(_.material),_.material=h}})}),r=r||l.lruCache,t=t||l.parseQueue,e=e||l.downloadQueue,l.lruCache=r,l.downloadQueue=e,l.parseQueue=t,l.setCamera(d),n.frames.find(m=>m.id===p.frame_id).sceneMatrix.decompose(l.group.position,l.group.quaternion,l.group.scale),a.add(l.group),x.push(l)})}),T(),window.addEventListener("resize",T,!1);const i=new D;i.add(g,"errorTarget",0,100),i.add(g,"slopeDisplay",["NONE","OVERLAY","SOLID"]).onChange(o=>{o!=="NONE"?x.forEach(n=>{const c=n.getPluginByName("TEXTURE_OVERLAY_PLUGIN");c.hasLayer("slopeLayer")||c.registerLayer("slopeLayer",s),n.forEachLoadedModel(C=>{C.traverse(p=>{p.material&&(p.material.displayAsOverlay=o==="OVERLAY",p.material.needsUpdate=!0)})})}):x.forEach(n=>{n.getPluginByName("TEXTURE_OVERLAY_PLUGIN").unregisterLayer("slopeLayer")})}),i.open()}function T(){d.aspect=window.innerWidth/window.innerHeight,d.updateProjectionMatrix(),u.setSize(window.innerWidth,window.innerHeight),u.setPixelRatio(window.devicePixelRatio)}function R(){requestAnimationFrame(R),f.update(),d.updateMatrixWorld(),x.forEach(a=>{a.errorTarget=g.errorTarget,a.setResolutionFromRenderer(d,u),a.update()}),u.render(A,d)} diff --git a/example/bundle/assets/leva.esm-BicpJr1E.js b/example/bundle/assets/leva.esm-BicpJr1E.js new file mode 100644 index 00000000..b6e5e4f0 --- /dev/null +++ b/example/bundle/assets/leva.esm-BicpJr1E.js @@ -0,0 +1,64 @@ +import{G as ba}from"./GLTFLoader-DkJa3Jo5.js";import{a as va,G as ya}from"./GLTFMeshFeaturesExtension-D473cUUw.js";import{a as wa}from"./GLTFExtensionLoader-TubLlshp.js";import{R as g,k as fi,d as xa,r as d,c as Ea,j as F,f as $a,l as di,m as pi,n as Sa,o as Ca}from"./CameraControls-DhgPIfmg.js";class $m{constructor(t){t={metadata:!0,rtc:!0,plugins:[],dracoLoader:null,ktxLoader:null,meshoptDecoder:null,autoDispose:!0,...t},this.tiles=null,this.metadata=t.metadata,this.rtc=t.rtc,this.plugins=t.plugins,this.dracoLoader=t.dracoLoader,this.ktxLoader=t.ktxLoader,this.meshoptDecoder=t.meshoptDecoder,this._gltfRegex=/\.(gltf|glb)$/g,this._dracoRegex=/\.drc$/g,this._loader=null}init(t){const n=new ba(t.manager);this.dracoLoader&&(n.setDRACOLoader(this.dracoLoader),t.manager.addHandler(this._dracoRegex,this.dracoLoader)),this.ktxLoader&&n.setKTX2Loader(this.ktxLoader),this.meshoptDecoder&&n.setMeshoptDecoder(this.meshoptDecoder),this.rtc&&n.register(()=>new wa),this.metadata&&(n.register(()=>new va),n.register(()=>new ya)),this.plugins.forEach(r=>n.register(r)),t.manager.addHandler(this._gltfRegex,n),this.tiles=t,this._loader=n}dispose(){this.tiles.manager.removeHandler(this._gltfRegex),this.tiles.manager.removeHandler(this._dracoRegex),this.autoDispose&&(this.ktxLoader.dispose(),this.dracoLoader.dispose())}}function Oa(e,t,n){return Math.max(t,Math.min(e,n))}const ee={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function Ur(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function Kr(e,t,n,r=.15){return r===0?Oa(e,t,n):en?+Ur(e-n,n-t,r)+n:e}function Ra(e,[t,n],[r,o]){const[[i,s],[a,c]]=e;return[Kr(t,i,s,r),Kr(n,a,c,o)]}function _a(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ta(e){var t=_a(e,"string");return typeof t=="symbol"?t:String(t)}function ae(e,t,n){return t=Ta(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function La(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function mi(e){return mn(e)?La(e)[0]:e}function Na(e){return Ma(e).map(t=>t.identifier)}function jn(e){const t=mi(e);return mn(e)?t.identifier:t.pointerId}function qr(e){const t=mi(e);return[t.clientX,t.clientY]}function Fa(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:o,ctrlKey:i}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:o,ctrlKey:i})}return t}function en(e,...t){return typeof e=="function"?e(...t):e}function za(){}function Ba(...e){return e.length===0?za:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function Xr(e,t){return Object.assign({},t,e||{})}const Wa=32;class Ha{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:o}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=o,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?en(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:o}=this;n.args=this.args;let i=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,o.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,o.locked=!!document.pointerLockElement,Object.assign(o,Fa(t)),o.down=o.pressed=o.buttons%2===1||o.touches>0,i=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const E=n._delta.map(Math.abs);ee.addTo(n._distance,E)}this.axisIntent&&this.axisIntent(t);const[s,a]=n._movement,[c,l]=r.threshold,{_step:u,values:f}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(s)>=c&&f[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&f[1])):(u[0]===!1&&(u[0]=Math.abs(s)>=c&&Math.sign(s)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[E,S]=f;p[0]=u[0]!==!1?E-u[0]:0,p[1]=u[1]!==!1?S-u[1]:0}else p[0]=u[0]!==!1?s-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(p);const h=n.offset,m=n._active&&!n._blocked||n.active;m&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=o[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=en(r.bounds,n)),this.setup&&this.setup()),n.movement=p,this.computeOffset()));const[b,y]=n.offset,[[v,w],[x,$]]=n._bounds;n.overflow=[bw?1:0,y$?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const C=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=Ra(n._bounds,n.offset,C),n.delta=ee.sub(n.offset,h),this.computeMovement(),m&&(!n.last||i>Wa)){n.delta=ee.sub(n.offset,h);const E=n.delta.map(Math.abs);ee.addTo(n.distance,E),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[E[0]/i,E[1]/i],n.timeDelta=i)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const o=this.handler(q(q(q({},n),t),{},{[this.aliasKey]:t.values}));o!==void 0&&(t.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Va([e,t],n){const r=Math.abs(e),o=Math.abs(t);if(r>o&&r>n)return"x";if(o>r&&o>n)return"y"}class Ua extends Ha{constructor(...t){super(...t),ae(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=ee.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=ee.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const o=typeof r.axisThreshold=="object"?r.axisThreshold[gi(t)]:r.axisThreshold;n.axis=Va(n._movement,o)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const Ka=e=>e,Jr=.15,bi={enabled(e=!0){return e},eventOptions(e,t,n){return q(q({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[Jr,Jr];case!1:return[0,0];default:return ee.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return ee.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||Ka},threshold(e){return ee.toVector(e,0)}},Ga=0,Dt=q(q({},bi),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=Ga){return e},bounds(e={}){if(typeof e=="function")return i=>Dt.bounds(e(i));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:o=1/0}=e;return[[t,n],[r,o]]}}),Zr={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class Ya extends Ua{constructor(...t){super(...t),ae(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),o={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=Dt.bounds(o)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const o=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(o&&o.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=jn(t),r._pointerActive=!0,this.computeValues(qr(t)),this.computeInitial(),n.preventScrollAxis&&gi(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive)return;const o=jn(t);if(n._pointerId!==void 0&&o!==n._pointerId)return;const i=qr(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=ee.sub(i,n._values),this.computeValues(i)),ee.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const o=jn(t);if(n._pointerId!==void 0&&o!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,s]=n._distance;if(n.tap=i<=r.tapsThreshold&&s<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[a,c]=n._delta,[l,u]=n._movement,[f,p]=r.swipe.velocity,[h,m]=r.swipe.distance,b=r.swipe.duration;if(n.elapsedTimef&&Math.abs(l)>h&&(n.swipe[0]=Math.sign(a)),v>p&&Math.abs(u)>m&&(n.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,qa(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=Zr[t.key];if(n){const r=this.state,o=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(this.config.keyboardDisplacement,o),r._keyboardActive=!0,ee.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Zr&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function qa(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const It=typeof window<"u"&&window.document&&window.document.createElement;function vi(){return It&&"ontouchstart"in window}function Xa(){return vi()||It&&window.navigator.maxTouchPoints>1}function Ja(){return It&&"onpointerdown"in window}function Za(){return It&&"exitPointerLock"in window.document}function Qa(){try{return"constructor"in GestureEvent}catch{return!1}}const de={isBrowser:It,gesture:Qa(),touch:vi(),touchscreen:Xa(),pointer:Ja(),pointerLock:Za()},ec=250,tc=180,nc=.5,rc=50,oc=250,ic=10,Qr={mouse:0,touch:0,pen:8},sc=q(q({},Dt),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:o=!1}={}}){return this.pointerLock=r&&de.pointerLock,de.touch&&n?"touch":this.pointerLock?"mouse":de.pointer&&!o?"pointer":de.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?ec:void 0,!(!de.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:o=!0}={}}){return this.pointerButtons=r,this.keys=o,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:o=void 0}){const i=ee.toVector(e,n?r:o?1:0);return this.filterTaps=n,this.tapsThreshold=r,i},swipe({velocity:e=nc,distance:t=rc,duration:n=oc}={}){return{velocity:this.transform(ee.toVector(e)),distance:this.transform(ee.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return tc;case!1:return 0;default:return e}},axisThreshold(e){return e?q(q({},Qr),e):Qr},keyboardDisplacement(e=ic){return e}});q(q({},bi),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!de.touch&&de.gesture)return"gesture";if(de.touch&&r)return"touch";if(de.touchscreen){if(de.pointer)return"pointer";if(de.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const o=s=>{const a=Xr(en(n,s),{min:-1/0,max:1/0});return[a.min,a.max]},i=s=>{const a=Xr(en(r,s),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[o(),i()]:s=>[o(s),i(s)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",ee.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});q(q({},Dt),{},{mouseOnly:(e=!0)=>e});q(q({},Dt),{},{mouseOnly:(e=!0)=>e});const yi=new Map,Gn=new Map;function ac(e){yi.set(e.key,e.engine),Gn.set(e.key,e.resolver)}const cc={key:"drag",engine:Ya,resolver:sc};function lc(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i=0)&&(n[o]=e[o]);return n}function uc(e,t){if(e==null)return{};var n=lc(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const fc={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=de.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},dc=["target","eventOptions","window","enabled","transform"];function Zt(e={},t){const n={};for(const[r,o]of Object.entries(t))switch(typeof o){case"function":n[r]=o.call(n,e[r],r,e);break;case"object":n[r]=Zt(e[r],o);break;case"boolean":o&&(n[r]=e[r]);break}return n}function pc(e,t,n={}){const r=e,{target:o,eventOptions:i,window:s,enabled:a,transform:c}=r,l=uc(r,dc);if(n.shared=Zt({target:o,eventOptions:i,window:s,enabled:a,transform:c},fc),t){const u=Gn.get(t);n[t]=Zt(q({shared:n.shared},l),u)}else for(const u in l){const f=Gn.get(u);f&&(n[u]=Zt(q({shared:n.shared},l[u]),f))}return n}class wi{constructor(t,n){ae(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,o,i){const s=this._listeners,a=ja(n,r),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=q(q({},c),i);t.addEventListener(a,o,l);const u=()=>{t.removeEventListener(a,o,l),s.delete(u)};return s.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class hc{constructor(){ae(this,"_timeouts",new Map)}add(t,n,r=140,...o){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...o))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class gc{constructor(t){ae(this,"gestures",new Set),ae(this,"_targetEventStore",new wi(this)),ae(this,"gestureEventStores",{}),ae(this,"gestureTimeoutStores",{}),ae(this,"handlers",{}),ae(this,"config",{}),ae(this,"pointerIds",new Set),ae(this,"touchIds",new Set),ae(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),mc(this,t)}setEventIds(t){if(mn(t))return this.touchIds=new Set(Na(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=pc(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let o;if(!(n.target&&(o=n.target(),!o))){if(n.enabled){for(const s of this.gestures){const a=this.config[s],c=eo(r,a.eventOptions,!!o);if(a.enabled){const l=yi.get(s);new l(this,t,s).bind(c)}}const i=eo(r,n.eventOptions,!!o);for(const s in this.nativeHandlers)i(s,"",a=>this.nativeHandlers[s](q(q({},this.state.shared),{},{event:a,args:t})),void 0,!0)}for(const i in r)r[i]=Ba(...r[i]);if(!o)return r;for(const i in r){const{device:s,capture:a,passive:c}=Ia(i);this._targetEventStore.add(o,s,"",r[i],{capture:a,passive:c})}}}}function tt(e,t){e.gestures.add(t),e.gestureEventStores[t]=new wi(e,t),e.gestureTimeoutStores[t]=new hc}function mc(e,t){t.drag&&tt(e,"drag"),t.wheel&&tt(e,"wheel"),t.scroll&&tt(e,"scroll"),t.move&&tt(e,"move"),t.pinch&&tt(e,"pinch"),t.hover&&tt(e,"hover")}const eo=(e,t,n)=>(r,o,i,s={},a=!1)=>{var c,l;const u=(c=s.capture)!==null&&c!==void 0?c:t.capture,f=(l=s.passive)!==null&&l!==void 0?l:t.passive;let p=a?r:Aa(r,o,u);n&&f&&(p+="Passive"),e[p]=e[p]||[],e[p].push(i)};function bc(e,t={},n,r){const o=g.useMemo(()=>new gc(e),[]);if(o.applyHandlers(e,r),o.applyConfig(t,n),g.useEffect(o.effect.bind(o)),g.useEffect(()=>o.clean.bind(o),[]),t.target===void 0)return o.bind.bind(o)}function vc(e,t){return ac(cc),bc({drag:e},t||{},"drag")}const yc=e=>(t,n,r)=>{const o=r.subscribe;return r.subscribe=(s,a,c)=>{let l=s;if(a){const u=(c==null?void 0:c.equalityFn)||Object.is;let f=s(r.getState());l=p=>{const h=s(p);if(!u(f,h)){const m=f;a(f=h,m)}},c!=null&&c.fireImmediately&&a(f,f)}return o(l)},e(t,n,r)};function bn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r[s.gl]),r=d.useMemo(()=>document.createElement("div"),[]),o=d.useMemo(()=>Ea(r),[r]),i=d.useMemo(()=>{const s=new ResizeObserver(([{contentRect:a}])=>{r.style.top=`${a.top}px`,r.style.left=`${a.left}px`,r.style.width=`${a.width}px`,r.style.height=`${a.height}px`});return s.observe(n.domElement),s},[n,r]);d.useEffect(()=>(r.style.pointerEvents="none",r.style.position="absolute",document.body.appendChild(r),()=>{r.remove(),i.disconnect()}),[i,r]),o.render(F.jsx(d.StrictMode,{children:F.jsx("div",{...t,children:e})}))}function Sm({children:e,style:t,...n}){const r=d.useContext($a),[o,i]=d.useState([]);d.useEffect(()=>{if(!r)return;let l=!1;const u=()=>{l||(l=!0,queueMicrotask(()=>{i(r.getAttributions()),l=!1}))};return r.addEventListener("tile-visibility-change",u),r.addEventListener("load-tile-set",u),()=>{r.removeEventListener("tile-visibility-change",u),r.removeEventListener("load-tile-set",u)}},[r]);const s=[];o.forEach((l,u)=>{let f=null;l.type==="string"?f=F.jsx("div",{children:l.value},u):l.type==="html"?f=F.jsx("div",{dangerouslySetInnerHTML:{__html:l.value},style:{pointerEvents:"all"}},u):l.type==="image"&&(f=F.jsx("div",{children:F.jsx("img",{src:l.value})},u)),f&&s.push(f)});const a=d.useMemo(()=>"class_"+window.crypto.randomUUID(),[]),c=d.useMemo(()=>` + #${a} a { + color: white; + } + + #${a} img { + max-width: 125px; + display: block; + margin: 5px 0; + } + `,[a]);return F.jsxs(Cc,{id:a,style:{position:"absolute",bottom:0,left:0,padding:"10px",color:"rgba( 255, 255, 255, 0.75 )",fontSize:"10px",...t},...n,children:[F.jsx("style",{children:c}),e,s]})}function Oc(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Si(...e){return t=>e.forEach(n=>Oc(n,t))}function Ye(...e){return d.useCallback(Si(...e),e)}var Ci=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),i=o.find(Rc);if(i){const s=i.props.children,a=o.map(c=>c===i?d.Children.count(s)>1?d.Children.only(null):d.isValidElement(s)?s.props.children:null:c);return F.jsx(Yn,{...r,ref:t,children:d.isValidElement(s)?d.cloneElement(s,void 0,a):null})}return F.jsx(Yn,{...r,ref:t,children:n})});Ci.displayName="Slot";var Yn=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=Tc(n);return d.cloneElement(n,{..._c(r,n.props),ref:t?Si(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});Yn.displayName="SlotClone";var Oi=({children:e})=>F.jsx(F.Fragment,{children:e});function Rc(e){return d.isValidElement(e)&&e.type===Oi}function _c(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Tc(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Pc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ze=Pc.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?Ci:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),F.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function kc(e,t){e&&di.flushSync(()=>e.dispatchEvent(t))}var Ue=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},Ac="Portal",Ri=d.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=d.useState(!1);Ue(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?pi.createPortal(F.jsx(ze.div,{...r,ref:t}),s):null});Ri.displayName=Ac;var Dc=Ri,to=Object.prototype.hasOwnProperty;function Tt(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&Tt(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(to.call(e,n)&&++r&&!to.call(t,n)||!(n in t)||!Tt(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var vn=function(t,n,r,o){this.name=t,this.fn=n,this.args=r,this.modifiers=o};vn.prototype._test=function(t){var n=this.fn;try{it(this.modifiers.slice(),n,this)(t)}catch{n=function(){return!1}}try{return it(this.modifiers.slice(),n,this)(t)}catch{return!1}};vn.prototype._check=function(t){try{it(this.modifiers.slice(),this.fn,this)(t)}catch{if(it(this.modifiers.slice(),function(r){return r},this)(!1))return}if(!it(this.modifiers.slice(),this.fn,this)(t))throw null};vn.prototype._testAsync=function(t){var n=this;return new Promise(function(r,o){Ti(n.modifiers.slice(),n.fn,n)(t).then(function(i){i?r(t):o(null)}).catch(function(i){return o(i)})})};function _i(e,t){return t===void 0&&(t="simple"),typeof e=="object"?e[t]:e}function it(e,t,n){if(e.length){var r=e.shift(),o=it(e,t,n);return r.perform(o,n)}else return _i(t)}function Ti(e,t,n){if(e.length){var r=e.shift(),o=Ti(e,t,n);return r.performAsync(o,n)}else return function(i){return Promise.resolve(_i(t,"async")(i))}}var Ic=function(t,n,r){this.name=t,this.perform=n,this.performAsync=r},wr=function(e){function t(n,r,o,i){for(var s=[],a=arguments.length-4;a-- >0;)s[a]=arguments[a+4];e.call(this,s),e.captureStackTrace&&e.captureStackTrace(this,t),this.rule=n,this.value=r,this.cause=o,this.target=i}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),Ee=function(t,n){t===void 0&&(t=[]),n===void 0&&(n=[]),this.chain=t,this.nextRuleModifiers=n};Ee.prototype._applyRule=function(t,n){var r=this;return function(){for(var o=[],i=arguments.length;i--;)o[i]=arguments[i];return r.chain.push(new vn(n,t.apply(r,o),o,r.nextRuleModifiers)),r.nextRuleModifiers=[],r}};Ee.prototype._applyModifier=function(t,n){return this.nextRuleModifiers.push(new Ic(n,t.simple,t.async)),this};Ee.prototype._clone=function(){return new Ee(this.chain.slice(),this.nextRuleModifiers.slice())};Ee.prototype.test=function(t){return this.chain.every(function(n){return n._test(t)})};Ee.prototype.testAll=function(t){var n=[];return this.chain.forEach(function(r){try{r._check(t)}catch(o){n.push(new wr(r,t,o))}}),n};Ee.prototype.check=function(t){this.chain.forEach(function(n){try{n._check(t)}catch(r){throw new wr(n,t,r)}})};Ee.prototype.testAsync=function(t){var n=this;return new Promise(function(r,o){Pi(t,n.chain.slice(),r,o)})};function Pi(e,t,n,r){if(t.length){var o=t.shift();o._testAsync(e).then(function(){Pi(e,t,n,r)},function(i){r(new wr(o,e,i))})}else n(e)}var no=function(e,t){return t&&typeof e=="string"&&e.trim().length===0?!0:e==null};function jc(e,t){return t===void 0&&(t=!1),{simple:function(n){return no(n,t)||e.check(n)===void 0},async:function(n){return no(n,t)||e.testAsync(n)}}}function ce(){return typeof Proxy<"u"?ki(new Ee):qn(new Ee)}var Pt={};ce.extend=function(e){Object.assign(Pt,e)};ce.clearCustomRules=function(){Pt={}};function ki(e){return new Proxy(e,{get:function(n,r){if(r in n)return n[r];var o=ki(e._clone());if(r in tn)return o._applyModifier(tn[r],r);if(r in Pt)return o._applyRule(Pt[r],r);if(r in Xn)return o._applyRule(Xn[r],r)}})}function qn(e){var t=function(o,i){return Object.keys(o).forEach(function(s){i[s]=function(){for(var a=[],c=arguments.length;c--;)a[c]=arguments[c];var l=qn(i._clone()),u=l._applyRule(o[s],s).apply(void 0,a);return u}}),i},n=t(Xn,e),r=t(Pt,n);return Object.keys(tn).forEach(function(o){Object.defineProperty(r,o,{get:function(){var i=qn(r._clone());return i._applyModifier(tn[o],o)}})}),r}var tn={not:{simple:function(e){return function(t){return!e(t)}},async:function(e){return function(t){return Promise.resolve(e(t)).then(function(n){return!n}).catch(function(){return!0})}}},some:{simple:function(e){return function(t){return Ut(t).some(function(n){try{return e(n)}catch{return!1}})}},async:function(e){return function(t){return Promise.all(Ut(t).map(function(n){try{return e(n).catch(function(){return!1})}catch{return!1}})).then(function(n){return n.some(Boolean)})}}},every:{simple:function(e){return function(t){return t!==!1&&Ut(t).every(e)}},async:function(e){return function(t){return Promise.all(Ut(t).map(e)).then(function(n){return n.every(Boolean)})}}},strict:{simple:function(e,t){return function(n){return ro(t)&&n&&typeof n=="object"?Object.keys(t.args[0]).length===Object.keys(n).length&&e(n):e(n)}},async:function(e,t){return function(n){return Promise.resolve(e(n)).then(function(r){return ro(t)&&n&&typeof n=="object"?Object.keys(t.args[0]).length===Object.keys(n).length&&r:r}).catch(function(){return!1})}}}};function ro(e){return e&&e.name==="schema"&&e.args.length>0&&typeof e.args[0]=="object"}function Ut(e){return typeof e=="string"?e.split(""):e}var Xn={equal:function(e){return function(t){return t==e}},exact:function(e){return function(t){return t===e}},number:function(e){return e===void 0&&(e=!0),function(t){return typeof t=="number"&&(e||isFinite(t))}},integer:function(){return function(e){var t=Number.isInteger||Mc;return t(e)}},numeric:function(){return function(e){return!isNaN(parseFloat(e))&&isFinite(e)}},string:function(){return nt("string")},boolean:function(){return nt("boolean")},undefined:function(){return nt("undefined")},null:function(){return nt("null")},array:function(){return nt("array")},object:function(){return nt("object")},instanceOf:function(e){return function(t){return t instanceof e}},pattern:function(e){return function(t){return e.test(t)}},lowercase:function(){return function(e){return typeof e=="boolean"||e===e.toLowerCase()&&e.trim()!==""}},uppercase:function(){return function(e){return e===e.toUpperCase()&&e.trim()!==""}},vowel:function(){return function(e){return/^[aeiou]+$/i.test(e)}},consonant:function(){return function(e){return/^(?=[^aeiou])([a-z]+)$/i.test(e)}},first:function(e){return function(t){return t[0]==e}},last:function(e){return function(t){return t[t.length-1]==e}},empty:function(){return function(e){return e.length===0}},length:function(e,t){return function(n){return n.length>=e&&n.length<=(t||e)}},minLength:function(e){return function(t){return t.length>=e}},maxLength:function(e){return function(t){return t.length<=e}},negative:function(){return function(e){return e<0}},positive:function(){return function(e){return e>=0}},between:function(e,t){return function(n){return n>=e&&n<=t}},range:function(e,t){return function(n){return n>=e&&n<=t}},lessThan:function(e){return function(t){return te}},greaterThanOrEqual:function(e){return function(t){return t>=e}},even:function(){return function(e){return e%2===0}},odd:function(){return function(e){return e%2!==0}},includes:function(e){return function(t){return~t.indexOf(e)}},schema:function(e){return Lc(e)},passesAnyOf:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return function(n){return e.some(function(r){return r.test(n)})}},optional:jc};function nt(e){return function(t){return Array.isArray(t)&&e==="array"||t===null&&e==="null"||typeof t===e}}function Mc(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}function Lc(e){return{simple:function(t){var n=[];if(Object.keys(e).forEach(function(r){var o=e[r];try{o.check((t||{})[r])}catch(i){i.target=r,n.push(i)}}),n.length>0)throw n;return!0},async:function(t){var n=[],r=Object.keys(e).map(function(o){var i=e[o];return i.testAsync((t||{})[o]).catch(function(s){s.target=o,n.push(s)})});return Promise.all(r).then(function(){if(n.length>0)throw n;return!0})}}}var V="colors",ne="sizes",_="space",Nc={gap:_,gridGap:_,columnGap:_,gridColumnGap:_,rowGap:_,gridRowGap:_,inset:_,insetBlock:_,insetBlockEnd:_,insetBlockStart:_,insetInline:_,insetInlineEnd:_,insetInlineStart:_,margin:_,marginTop:_,marginRight:_,marginBottom:_,marginLeft:_,marginBlock:_,marginBlockEnd:_,marginBlockStart:_,marginInline:_,marginInlineEnd:_,marginInlineStart:_,padding:_,paddingTop:_,paddingRight:_,paddingBottom:_,paddingLeft:_,paddingBlock:_,paddingBlockEnd:_,paddingBlockStart:_,paddingInline:_,paddingInlineEnd:_,paddingInlineStart:_,top:_,right:_,bottom:_,left:_,scrollMargin:_,scrollMarginTop:_,scrollMarginRight:_,scrollMarginBottom:_,scrollMarginLeft:_,scrollMarginX:_,scrollMarginY:_,scrollMarginBlock:_,scrollMarginBlockEnd:_,scrollMarginBlockStart:_,scrollMarginInline:_,scrollMarginInlineEnd:_,scrollMarginInlineStart:_,scrollPadding:_,scrollPaddingTop:_,scrollPaddingRight:_,scrollPaddingBottom:_,scrollPaddingLeft:_,scrollPaddingX:_,scrollPaddingY:_,scrollPaddingBlock:_,scrollPaddingBlockEnd:_,scrollPaddingBlockStart:_,scrollPaddingInline:_,scrollPaddingInlineEnd:_,scrollPaddingInlineStart:_,fontSize:"fontSizes",background:V,backgroundColor:V,backgroundImage:V,borderImage:V,border:V,borderBlock:V,borderBlockEnd:V,borderBlockStart:V,borderBottom:V,borderBottomColor:V,borderColor:V,borderInline:V,borderInlineEnd:V,borderInlineStart:V,borderLeft:V,borderLeftColor:V,borderRight:V,borderRightColor:V,borderTop:V,borderTopColor:V,caretColor:V,color:V,columnRuleColor:V,fill:V,outline:V,outlineColor:V,stroke:V,textDecorationColor:V,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:ne,minBlockSize:ne,maxBlockSize:ne,inlineSize:ne,minInlineSize:ne,maxInlineSize:ne,width:ne,minWidth:ne,maxWidth:ne,height:ne,minHeight:ne,maxHeight:ne,flexBasis:ne,gridTemplateColumns:ne,gridTemplateRows:ne,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},Fc=(e,t)=>typeof t=="function"?{"()":Function.prototype.toString.call(t)}:t,ut=()=>{const e=Object.create(null);return(t,n,...r)=>{const o=(i=>JSON.stringify(i,Fc))(t);return o in e?e[o]:e[o]=n(t,...r)}},He=Symbol.for("sxs.internal"),xr=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),oo=e=>{for(const t in e)return!0;return!1},{hasOwnProperty:zc}=Object.prototype,Jn=e=>e.includes("-")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),Bc=/\s+(?![^()]*\))/,rt=e=>t=>e(...typeof t=="string"?String(t).split(Bc):[t]),io={appearance:e=>({WebkitAppearance:e,appearance:e}),backfaceVisibility:e=>({WebkitBackfaceVisibility:e,backfaceVisibility:e}),backdropFilter:e=>({WebkitBackdropFilter:e,backdropFilter:e}),backgroundClip:e=>({WebkitBackgroundClip:e,backgroundClip:e}),boxDecorationBreak:e=>({WebkitBoxDecorationBreak:e,boxDecorationBreak:e}),clipPath:e=>({WebkitClipPath:e,clipPath:e}),content:e=>({content:e.includes('"')||e.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(e)?e:`"${e}"`}),hyphens:e=>({WebkitHyphens:e,hyphens:e}),maskImage:e=>({WebkitMaskImage:e,maskImage:e}),maskSize:e=>({WebkitMaskSize:e,maskSize:e}),tabSize:e=>({MozTabSize:e,tabSize:e}),textSizeAdjust:e=>({WebkitTextSizeAdjust:e,textSizeAdjust:e}),userSelect:e=>({WebkitUserSelect:e,userSelect:e}),marginBlock:rt((e,t)=>({marginBlockStart:e,marginBlockEnd:t||e})),marginInline:rt((e,t)=>({marginInlineStart:e,marginInlineEnd:t||e})),maxSize:rt((e,t)=>({maxBlockSize:e,maxInlineSize:t||e})),minSize:rt((e,t)=>({minBlockSize:e,minInlineSize:t||e})),paddingBlock:rt((e,t)=>({paddingBlockStart:e,paddingBlockEnd:t||e})),paddingInline:rt((e,t)=>({paddingInlineStart:e,paddingInlineEnd:t||e}))},Mn=/([\d.]+)([^]*)/,Wc=(e,t)=>e.length?e.reduce((n,r)=>(n.push(...t.map(o=>o.includes("&")?o.replace(/&/g,/[ +>|~]/.test(r)&&/&.*&/.test(o)?`:is(${r})`:r):r+" "+o)),n),[]):t,Hc=(e,t)=>e in Vc&&typeof t=="string"?t.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,(n,r,o,i)=>r+(o==="stretch"?`-moz-available${i};${Jn(e)}:${r}-webkit-fill-available`:`-moz-fit-content${i};${Jn(e)}:${r}fit-content`)+i):String(t),Vc={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},Pe=e=>e?e+"-":"",Ai=(e,t,n)=>e.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,(r,o,i,s,a)=>s=="$"==!!i?r:(o||s=="--"?"calc(":"")+"var(--"+(s==="$"?Pe(t)+(a.includes("$")?"":Pe(n))+a.replace(/\$/g,"-"):a)+")"+(o||s=="--"?"*"+(o||"")+(i||"1")+")":"")),Uc=/\s*,\s*(?![^()]*\))/,Kc=Object.prototype.toString,ot=(e,t,n,r,o)=>{let i,s,a;const c=(l,u,f)=>{let p,h;const m=b=>{for(p in b){const w=p.charCodeAt(0)===64,x=w&&Array.isArray(b[p])?b[p]:[b[p]];for(h of x){const $=/[A-Z]/.test(v=p)?v:v.replace(/-[^]/g,E=>E[1].toUpperCase()),C=typeof h=="object"&&h&&h.toString===Kc&&(!r.utils[$]||!u.length);if($ in r.utils&&!C){const E=r.utils[$];if(E!==s){s=E,m(E(h)),s=null;continue}}else if($ in io){const E=io[$];if(E!==a){a=E,m(E(h)),a=null;continue}}if(w&&(y=p.slice(1)in r.media?"@media "+r.media[p.slice(1)]:p,p=y.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,(E,S,k,z,R,T)=>{const P=Mn.test(S),I=.0625*(P?-1:1),[j,L]=P?[z,S]:[S,z];return"("+(k[0]==="="?"":k[0]===">"===P?"max-":"min-")+j+":"+(k[0]!=="="&&k.length===1?L.replace(Mn,(B,W,M)=>Number(W)+I*(k===">"?1:-1)+M):L)+(R?") and ("+(R[0]===">"?"min-":"max-")+j+":"+(R.length===1?T.replace(Mn,(B,W,M)=>Number(W)+I*(R===">"?-1:1)+M):T):"")+")"})),C){const E=w?f.concat(p):[...f],S=w?[...u]:Wc(u,p.split(Uc));i!==void 0&&o(so(...i)),i=void 0,c(h,S,E)}else i===void 0&&(i=[[],u,f]),p=w||p.charCodeAt(0)!==36?p:`--${Pe(r.prefix)}${p.slice(1).replace(/\$/g,"-")}`,h=C?h:typeof h=="number"?h&&$ in Gc?String(h)+"px":String(h):Ai(Hc($,h??""),r.prefix,r.themeMap[$]),i[0].push(`${w?`${p} `:`${Jn(p)}:`}${h}`)}}var y,v};m(l),i!==void 0&&o(so(...i)),i=void 0};c(e,t,n)},so=(e,t,n)=>`${n.map(r=>`${r}{`).join("")}${t.length?`${t.join(",")}{`:""}${e.join(";")}${t.length?"}":""}${Array(n.length?n.length+1:0).join("}")}`,Gc={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},ao=e=>String.fromCharCode(e+(e>25?39:97)),Ve=e=>(t=>{let n,r="";for(n=Math.abs(t);n>52;n=n/52|0)r=ao(n%52)+r;return ao(n%52)+r})(((t,n)=>{let r=n.length;for(;r;)t=33*t^n.charCodeAt(--r);return t})(5381,JSON.stringify(e))>>>0),Ct=["themed","global","styled","onevar","resonevar","allvar","inline"],Yc=e=>{if(e.href&&!e.href.startsWith(location.origin))return!1;try{return!!e.cssRules}catch{return!1}},qc=e=>{let t;const n=()=>{const{cssRules:o}=t.sheet;return[].map.call(o,(i,s)=>{const{cssText:a}=i;let c="";if(a.startsWith("--sxs"))return"";if(o[s-1]&&(c=o[s-1].cssText).startsWith("--sxs")){if(!i.cssRules.length)return"";for(const l in t.rules)if(t.rules[l].group===i)return`--sxs{--sxs:${[...t.rules[l].cache].join(" ")}}${a}`;return i.cssRules.length?`${c}${a}`:""}return a}).join("")},r=()=>{if(t){const{rules:a,sheet:c}=t;if(!c.deleteRule){for(;Object(Object(c.cssRules)[0]).type===3;)c.cssRules.splice(0,1);c.cssRules=[]}for(const l in a)delete a[l]}const o=Object(e).styleSheets||[];for(const a of o)if(Yc(a)){for(let c=0,l=a.cssRules;l[c];++c){const u=Object(l[c]);if(u.type!==1)continue;const f=Object(l[c+1]);if(f.type!==4)continue;++c;const{cssText:p}=u;if(!p.startsWith("--sxs"))continue;const h=p.slice(14,-3).trim().split(/\s+/),m=Ct[h[0]];m&&(t||(t={sheet:a,reset:r,rules:{},toString:n}),t.rules[m]={group:f,index:c,cache:new Set(h)})}if(t)break}if(!t){const a=(c,l)=>({type:l,cssRules:[],insertRule(u,f){this.cssRules.splice(f,0,a(u,{import:3,undefined:1}[(u.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return c==="@media{}"?`@media{${[].map.call(this.cssRules,u=>u.cssText).join("")}}`:c}});t={sheet:e?(e.head||e).appendChild(document.createElement("style")).sheet:a("","text/css"),rules:{},reset:r,toString:n}}const{sheet:i,rules:s}=t;for(let a=Ct.length-1;a>=0;--a){const c=Ct[a];if(!s[c]){const l=Ct[a+1],u=s[l]?s[l].index:i.cssRules.length;i.insertRule("@media{}",u),i.insertRule(`--sxs{--sxs:${a}}`,u),s[c]={group:i.cssRules[u+1],index:u,cache:new Set([a])}}Xc(s[c])}};return r(),t},Xc=e=>{const t=e.group;let n=t.cssRules.length;e.apply=r=>{try{t.insertRule(r,n),++n}catch{}}},Et=Symbol(),Jc=ut(),co=(e,t)=>Jc(e,()=>(...n)=>{let r={type:null,composers:new Set};for(const o of n)if(o!=null)if(o[He]){r.type==null&&(r.type=o[He].type);for(const i of o[He].composers)r.composers.add(i)}else o.constructor!==Object||o.$$typeof?r.type==null&&(r.type=o):r.composers.add(Zc(o,e));return r.type==null&&(r.type="span"),r.composers.size||r.composers.add(["PJLV",{},[],[],{},[]]),Qc(e,r,t)}),Zc=({variants:e,compoundVariants:t,defaultVariants:n,...r},o)=>{const i=`${Pe(o.prefix)}c-${Ve(r)}`,s=[],a=[],c=Object.create(null),l=[];for(const p in n)c[p]=String(n[p]);if(typeof e=="object"&&e)for(const p in e){u=c,f=p,zc.call(u,f)||(c[p]="undefined");const h=e[p];for(const m in h){const b={[p]:String(m)};String(m)==="undefined"&&l.push(p);const y=h[m],v=[b,y,!oo(y)];s.push(v)}}var u,f;if(typeof t=="object"&&t)for(const p of t){let{css:h,...m}=p;h=typeof h=="object"&&h||{};for(const y in m)m[y]=String(m[y]);const b=[m,h,!oo(h)];a.push(b)}return[i,r,s,a,c,l]},Qc=(e,t,n)=>{const[r,o,i,s]=el(t.composers),a=typeof t.type=="function"||t.type.$$typeof?(f=>{function p(){for(let h=0;hp.rules[h]={apply:m=>p[Et].push([h,m])}),p})(n):null,c=(a||n).rules,l=`.${r}${o.length>1?`:where(.${o.slice(1).join(".")})`:""}`,u=f=>{f=typeof f=="object"&&f||tl;const{css:p,...h}=f,m={};for(const v in i)if(delete h[v],v in f){let w=f[v];typeof w=="object"&&w?m[v]={"@initial":i[v],...w}:(w=String(w),m[v]=w!=="undefined"||s.has(v)?w:i[v])}else m[v]=i[v];const b=new Set([...o]);for(const[v,w,x,$]of t.composers){n.rules.styled.cache.has(v)||(n.rules.styled.cache.add(v),ot(w,[`.${v}`],[],e,S=>{c.styled.apply(S)}));const C=lo(x,m,e.media),E=lo($,m,e.media,!0);for(const S of C)if(S!==void 0)for(const[k,z,R]of S){const T=`${v}-${Ve(z)}-${k}`;b.add(T);const P=(R?n.rules.resonevar:n.rules.onevar).cache,I=R?c.resonevar:c.onevar;P.has(T)||(P.add(T),ot(z,[`.${T}`],[],e,j=>{I.apply(j)}))}for(const S of E)if(S!==void 0)for(const[k,z]of S){const R=`${v}-${Ve(z)}-${k}`;b.add(R),n.rules.allvar.cache.has(R)||(n.rules.allvar.cache.add(R),ot(z,[`.${R}`],[],e,T=>{c.allvar.apply(T)}))}}if(typeof p=="object"&&p){const v=`${r}-i${Ve(p)}-css`;b.add(v),n.rules.inline.cache.has(v)||(n.rules.inline.cache.add(v),ot(p,[`.${v}`],[],e,w=>{c.inline.apply(w)}))}for(const v of String(f.className||"").trim().split(/\s+/))v&&b.add(v);const y=h.className=[...b].join(" ");return{type:t.type,className:y,selector:l,props:h,toString:()=>y,deferredInjector:a}};return xr(u,{className:r,selector:l,[He]:t,toString:()=>(n.rules.styled.cache.has(r)||u(),r)})},el=e=>{let t="";const n=[],r={},o=[];for(const[i,,,,s,a]of e){t===""&&(t=i),n.push(i),o.push(...a);for(const c in s){const l=s[c];(r[c]===void 0||l!=="undefined"||a.includes(l))&&(r[c]=l)}}return[t,n,r,new Set(o)]},lo=(e,t,n,r)=>{const o=[];e:for(let[i,s,a]of e){if(a)continue;let c,l=0,u=!1;for(c in i){const f=i[c];let p=t[c];if(p!==f){if(typeof p!="object"||!p)continue e;{let h,m,b=0;for(const y in p){if(f===String(p[y])){if(y!=="@initial"){const v=y.slice(1);(m=m||[]).push(v in n?n[v]:y.replace(/^@media ?/,"")),u=!0}l+=b,h=!0}++b}if(m&&m.length&&(s={["@media "+m.join(", ")]:s}),!h)continue e}}}(o[l]=o[l]||[]).push([r?"cv":`${c}-${i[c]}`,s,u])}return o},tl={},nl=ut(),rl=(e,t)=>nl(e,()=>(...n)=>{const r=()=>{for(let o of n){o=typeof o=="object"&&o||{};let i=Ve(o);if(!t.rules.global.cache.has(i)){if(t.rules.global.cache.add(i),"@import"in o){let s=[].indexOf.call(t.sheet.cssRules,t.rules.themed.group)-1;for(let a of[].concat(o["@import"]))a=a.includes('"')||a.includes("'")?a:`"${a}"`,t.sheet.insertRule(`@import ${a};`,s++);delete o["@import"]}ot(o,[],[],e,s=>{t.rules.global.apply(s)})}}return""};return xr(r,{toString:r})}),ol=ut(),il=(e,t)=>ol(e,()=>n=>{const r=`${Pe(e.prefix)}k-${Ve(n)}`,o=()=>{if(!t.rules.global.cache.has(r)){t.rules.global.cache.add(r);const i=[];ot(n,[],[],e,a=>i.push(a));const s=`@keyframes ${r}{${i.join("")}}`;t.rules.global.apply(s)}return r};return xr(o,{get name(){return o()},toString:o})}),sl=class{constructor(e,t,n,r){this.token=e==null?"":String(e),this.value=t==null?"":String(t),this.scale=n==null?"":String(n),this.prefix=r==null?"":String(r)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+Pe(this.prefix)+Pe(this.scale)+this.token}toString(){return this.computedValue}},al=ut(),cl=(e,t)=>al(e,()=>(n,r)=>{r=typeof n=="object"&&n||Object(r);const o=`.${n=(n=typeof n=="string"?n:"")||`${Pe(e.prefix)}t-${Ve(r)}`}`,i={},s=[];for(const c in r){i[c]={};for(const l in r[c]){const u=`--${Pe(e.prefix)}${c}-${l}`,f=Ai(String(r[c][l]),e.prefix,c);i[c][l]=new sl(l,f,c,e.prefix),s.push(`${u}:${f}`)}}const a=()=>{if(s.length&&!t.rules.themed.cache.has(n)){t.rules.themed.cache.add(n);const c=`${r===e.theme?":root,":""}.${n}{${s.join(";")}}`;t.rules.themed.apply(c)}return n};return{...i,get className(){return a()},selector:o,toString:a}}),ll=ut(),ul=ut(),fl=e=>{const t=(n=>{let r=!1;const o=ll(n,i=>{r=!0;const s="prefix"in(i=typeof i=="object"&&i||{})?String(i.prefix):"",a=typeof i.media=="object"&&i.media||{},c=typeof i.root=="object"?i.root||null:globalThis.document||null,l=typeof i.theme=="object"&&i.theme||{},u={prefix:s,media:a,theme:l,themeMap:typeof i.themeMap=="object"&&i.themeMap||{...Nc},utils:typeof i.utils=="object"&&i.utils||{}},f=qc(c),p={css:co(u,f),globalCss:rl(u,f),keyframes:il(u,f),createTheme:cl(u,f),reset(){f.reset(),p.theme.toString()},theme:{},sheet:f,config:u,prefix:s,getCssText:f.toString,toString:f.toString};return String(p.theme=p.createTheme(l)),p});return r||o.reset(),o})(e);return t.styled=(({config:n,sheet:r})=>ul(n,()=>{const o=co(n,r);return(...i)=>{const s=o(...i),a=s[He].type,c=g.forwardRef((l,u)=>{const f=l&&l.as||a,{props:p,deferredInjector:h}=s(l);return delete p.as,p.ref=u,h?g.createElement(g.Fragment,null,g.createElement(f,p),g.createElement(h,null)):g.createElement(f,p)});return c.className=s.className,c.displayName=`Styled.${a.displayName||a.name||a}`,c.selector=s.selector,c.toString=()=>s.selector,c[He]=s[He],c}}))(t),t};function Re(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function dl(e,t=[]){let n=[];function r(i,s){const a=d.createContext(s),c=n.length;n=[...n,s];const l=f=>{var v;const{scope:p,children:h,...m}=f,b=((v=p==null?void 0:p[e])==null?void 0:v[c])||a,y=d.useMemo(()=>m,Object.values(m));return F.jsx(b.Provider,{value:y,children:h})};l.displayName=i+"Provider";function u(f,p){var b;const h=((b=p==null?void 0:p[e])==null?void 0:b[c])||a,m=d.useContext(h);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[l,u]}const o=()=>{const i=n.map(s=>d.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,pl(o,...t)]}function pl(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const f=c(i)[`__scope${l}`];return{...a,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function ft(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function hl(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e);d.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var gl="DismissableLayer",Zn="dismissableLayer.update",ml="dismissableLayer.pointerDownOutside",bl="dismissableLayer.focusOutside",uo,Di=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ii=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...c}=e,l=d.useContext(Di),[u,f]=d.useState(null),p=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=d.useState({}),m=Ye(t,S=>f(S)),b=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=b.indexOf(y),w=u?b.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,$=w>=v,C=wl(S=>{const k=S.target,z=[...l.branches].some(R=>R.contains(k));!$||z||(o==null||o(S),s==null||s(S),S.defaultPrevented||a==null||a())},p),E=xl(S=>{const k=S.target;[...l.branches].some(R=>R.contains(k))||(i==null||i(S),s==null||s(S),S.defaultPrevented||a==null||a())},p);return hl(S=>{w===l.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&a&&(S.preventDefault(),a()))},p),d.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(uo=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),fo(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=uo)}},[u,p,n,l]),d.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),fo())},[u,l]),d.useEffect(()=>{const S=()=>h({});return document.addEventListener(Zn,S),()=>document.removeEventListener(Zn,S)},[]),F.jsx(ze.div,{...c,ref:m,style:{pointerEvents:x?$?"auto":"none":void 0,...e.style},onFocusCapture:Re(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Re(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Re(e.onPointerDownCapture,C.onPointerDownCapture)})});Ii.displayName=gl;var vl="DismissableLayerBranch",yl=d.forwardRef((e,t)=>{const n=d.useContext(Di),r=d.useRef(null),o=Ye(t,r);return d.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),F.jsx(ze.div,{...e,ref:o})});yl.displayName=vl;function wl(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let c=function(){ji(ml,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function xl(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=d.useRef(!1);return d.useEffect(()=>{const o=i=>{i.target&&!r.current&&ji(bl,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function fo(){const e=new CustomEvent(Zn);document.dispatchEvent(e)}function ji(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?kc(o,i):o.dispatchEvent(i)}var El=Sa.useId||(()=>{}),$l=0;function Sl(e){const[t,n]=d.useState(El());return Ue(()=>{n(r=>r??String($l++))},[e]),t?`radix-${t}`:""}const Cl=["top","right","bottom","left"],je=Math.min,le=Math.max,nn=Math.round,Kt=Math.floor,Me=e=>({x:e,y:e}),Ol={left:"right",right:"left",bottom:"top",top:"bottom"},Rl={start:"end",end:"start"};function Qn(e,t,n){return le(e,je(t,n))}function ke(e,t){return typeof e=="function"?e(t):e}function Ae(e){return e.split("-")[0]}function dt(e){return e.split("-")[1]}function Er(e){return e==="x"?"y":"x"}function $r(e){return e==="y"?"height":"width"}function Le(e){return["top","bottom"].includes(Ae(e))?"y":"x"}function Sr(e){return Er(Le(e))}function _l(e,t,n){n===void 0&&(n=!1);const r=dt(e),o=Sr(e),i=$r(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=rn(s)),[s,rn(s)]}function Tl(e){const t=rn(e);return[er(e),t,er(t)]}function er(e){return e.replace(/start|end/g,t=>Rl[t])}function Pl(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function kl(e,t,n,r){const o=dt(e);let i=Pl(Ae(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(er)))),i}function rn(e){return e.replace(/left|right|bottom|top/g,t=>Ol[t])}function Al(e){return{top:0,right:0,bottom:0,left:0,...e}}function Mi(e){return typeof e!="number"?Al(e):{top:e,right:e,bottom:e,left:e}}function on(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function po(e,t,n){let{reference:r,floating:o}=e;const i=Le(t),s=Sr(t),a=$r(s),c=Ae(t),l=i==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let h;switch(c){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(dt(t)){case"start":h[s]-=p*(n&&l?-1:1);break;case"end":h[s]+=p*(n&&l?-1:1);break}return h}const Dl=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=po(l,r,c),p=r,h={},m=0;for(let b=0;b({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:l,padding:u=0}=ke(e,t)||{};if(l==null)return{};const f=Mi(u),p={x:n,y:r},h=Sr(o),m=$r(h),b=await s.getDimensions(l),y=h==="y",v=y?"top":"left",w=y?"bottom":"right",x=y?"clientHeight":"clientWidth",$=i.reference[m]+i.reference[h]-p[h]-i.floating[m],C=p[h]-i.reference[h],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let S=E?E[x]:0;(!S||!await(s.isElement==null?void 0:s.isElement(E)))&&(S=a.floating[x]||i.floating[m]);const k=$/2-C/2,z=S/2-b[m]/2-1,R=je(f[v],z),T=je(f[w],z),P=R,I=S-b[m]-T,j=S/2-b[m]/2+k,L=Qn(P,j,I),B=!c.arrow&&dt(o)!=null&&j!==L&&i.reference[m]/2-(jj<=0)){var T,P;const j=(((T=i.flip)==null?void 0:T.index)||0)+1,L=S[j];if(L)return{data:{index:j,overflows:R},reset:{placement:L}};let B=(P=R.filter(W=>W.overflows[0]<=0).sort((W,M)=>W.overflows[1]-M.overflows[1])[0])==null?void 0:P.placement;if(!B)switch(h){case"bestFit":{var I;const W=(I=R.filter(M=>{if(E){const H=Le(M.placement);return H===w||H==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(H=>H>0).reduce((H,J)=>H+J,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:I[0];W&&(B=W);break}case"initialPlacement":B=a;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function ho(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function go(e){return Cl.some(t=>e[t]>=0)}const Ml=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ke(e,t);switch(r){case"referenceHidden":{const i=await kt(t,{...o,elementContext:"reference"}),s=ho(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:go(s)}}}case"escaped":{const i=await kt(t,{...o,altBoundary:!0}),s=ho(i,n.floating);return{data:{escapedOffsets:s,escaped:go(s)}}}default:return{}}}}};async function Ll(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ae(n),a=dt(n),c=Le(n)==="y",l=["left","top"].includes(s)?-1:1,u=i&&c?-1:1,f=ke(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(h=a==="end"?m*-1:m),c?{x:h*u,y:p*l}:{x:p*l,y:h*u}}const Nl=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,c=await Ll(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},Fl=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:y=>{let{x:v,y:w}=y;return{x:v,y:w}}},...c}=ke(e,t),l={x:n,y:r},u=await kt(t,c),f=Le(Ae(o)),p=Er(f);let h=l[p],m=l[f];if(i){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",w=h+u[y],x=h-u[v];h=Qn(w,h,x)}if(s){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",w=m+u[y],x=m-u[v];m=Qn(w,m,x)}const b=a.fn({...t,[p]:h,[f]:m});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:i,[f]:s}}}}}},zl=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=ke(e,t),u={x:n,y:r},f=Le(o),p=Er(f);let h=u[p],m=u[f];const b=ke(a,t),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const x=p==="y"?"height":"width",$=i.reference[p]-i.floating[x]+y.mainAxis,C=i.reference[p]+i.reference[x]-y.mainAxis;h<$?h=$:h>C&&(h=C)}if(l){var v,w;const x=p==="y"?"width":"height",$=["top","left"].includes(Ae(o)),C=i.reference[f]-i.floating[x]+($&&((v=s.offset)==null?void 0:v[f])||0)+($?0:y.crossAxis),E=i.reference[f]+i.reference[x]+($?0:((w=s.offset)==null?void 0:w[f])||0)-($?y.crossAxis:0);mE&&(m=E)}return{[p]:h,[f]:m}}}},Bl=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:c=()=>{},...l}=ke(e,t),u=await kt(t,l),f=Ae(o),p=dt(o),h=Le(o)==="y",{width:m,height:b}=i.floating;let y,v;f==="top"||f==="bottom"?(y=f,v=p===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,y=p==="end"?"top":"bottom");const w=b-u.top-u.bottom,x=m-u.left-u.right,$=je(b-u[y],w),C=je(m-u[v],x),E=!t.middlewareData.shift;let S=$,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=w),E&&!p){const R=le(u.left,0),T=le(u.right,0),P=le(u.top,0),I=le(u.bottom,0);h?k=m-2*(R!==0||T!==0?R+T:le(u.left,u.right)):S=b-2*(P!==0||I!==0?P+I:le(u.top,u.bottom))}await c({...t,availableWidth:k,availableHeight:S});const z=await s.getDimensions(a.floating);return m!==z.width||b!==z.height?{reset:{rects:!0}}:{}}}};function yn(){return typeof window<"u"}function pt(e){return Li(e)?(e.nodeName||"").toLowerCase():"#document"}function ue(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Se(e){var t;return(t=(Li(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Li(e){return yn()?e instanceof Node||e instanceof ue(e).Node:!1}function be(e){return yn()?e instanceof Element||e instanceof ue(e).Element:!1}function $e(e){return yn()?e instanceof HTMLElement||e instanceof ue(e).HTMLElement:!1}function mo(e){return!yn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ue(e).ShadowRoot}function jt(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ve(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Wl(e){return["table","td","th"].includes(pt(e))}function wn(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Cr(e){const t=Or(),n=be(e)?ve(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Hl(e){let t=Ne(e);for(;$e(t)&&!at(t);){if(Cr(t))return t;if(wn(t))return null;t=Ne(t)}return null}function Or(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function at(e){return["html","body","#document"].includes(pt(e))}function ve(e){return ue(e).getComputedStyle(e)}function xn(e){return be(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ne(e){if(pt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||mo(e)&&e.host||Se(e);return mo(t)?t.host:t}function Ni(e){const t=Ne(e);return at(t)?e.ownerDocument?e.ownerDocument.body:e.body:$e(t)&&jt(t)?t:Ni(t)}function At(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ni(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=ue(o);if(i){const a=tr(s);return t.concat(s,s.visualViewport||[],jt(o)?o:[],a&&n?At(a):[])}return t.concat(o,At(o,[],n))}function tr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fi(e){const t=ve(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=$e(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=nn(n)!==i||nn(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Rr(e){return be(e)?e:e.contextElement}function st(e){const t=Rr(e);if(!$e(t))return Me(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Fi(t);let s=(i?nn(n.width):n.width)/r,a=(i?nn(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Vl=Me(0);function zi(e){const t=ue(e);return!Or()||!t.visualViewport?Vl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ul(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}function Ke(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Rr(e);let s=Me(1);t&&(r?be(r)&&(s=st(r)):s=st(e));const a=Ul(i,n,r)?zi(i):Me(0);let c=(o.left+a.x)/s.x,l=(o.top+a.y)/s.y,u=o.width/s.x,f=o.height/s.y;if(i){const p=ue(i),h=r&&be(r)?ue(r):r;let m=p,b=tr(m);for(;b&&r&&h!==m;){const y=st(b),v=b.getBoundingClientRect(),w=ve(b),x=v.left+(b.clientLeft+parseFloat(w.paddingLeft))*y.x,$=v.top+(b.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,l*=y.y,u*=y.x,f*=y.y,c+=x,l+=$,m=ue(b),b=tr(m)}}return on({width:u,height:f,x:c,y:l})}function Kl(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Se(r),a=t?wn(t.floating):!1;if(r===s||a&&i)return n;let c={scrollLeft:0,scrollTop:0},l=Me(1);const u=Me(0),f=$e(r);if((f||!f&&!i)&&((pt(r)!=="body"||jt(s))&&(c=xn(r)),$e(r))){const p=Ke(r);l=st(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x,y:n.y*l.y-c.scrollTop*l.y+u.y}}function Gl(e){return Array.from(e.getClientRects())}function nr(e,t){const n=xn(e).scrollLeft;return t?t.left+n:Ke(Se(e)).left+n}function Yl(e){const t=Se(e),n=xn(e),r=e.ownerDocument.body,o=le(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=le(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+nr(e);const a=-n.scrollTop;return ve(r).direction==="rtl"&&(s+=le(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function ql(e,t){const n=ue(e),r=Se(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const l=Or();(!l||l&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:i,height:s,x:a,y:c}}function Xl(e,t){const n=Ke(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=$e(e)?st(e):Me(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,l=r*i.y;return{width:s,height:a,x:c,y:l}}function bo(e,t,n){let r;if(t==="viewport")r=ql(e,n);else if(t==="document")r=Yl(Se(e));else if(be(t))r=Xl(t,n);else{const o=zi(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return on(r)}function Bi(e,t){const n=Ne(e);return n===t||!be(n)||at(n)?!1:ve(n).position==="fixed"||Bi(n,t)}function Jl(e,t){const n=t.get(e);if(n)return n;let r=At(e,[],!1).filter(a=>be(a)&&pt(a)!=="body"),o=null;const i=ve(e).position==="fixed";let s=i?Ne(e):e;for(;be(s)&&!at(s);){const a=ve(s),c=Cr(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||jt(s)&&!c&&Bi(e,s))?r=r.filter(u=>u!==s):o=a,s=Ne(s)}return t.set(e,r),r}function Zl(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?wn(t)?[]:Jl(t,this._c):[].concat(n),r],a=s[0],c=s.reduce((l,u)=>{const f=bo(t,u,o);return l.top=le(f.top,l.top),l.right=je(f.right,l.right),l.bottom=je(f.bottom,l.bottom),l.left=le(f.left,l.left),l},bo(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Ql(e){const{width:t,height:n}=Fi(e);return{width:t,height:n}}function eu(e,t,n){const r=$e(t),o=Se(t),i=n==="fixed",s=Ke(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=Me(0);if(r||!r&&!i)if((pt(t)!=="body"||jt(o))&&(a=xn(t)),r){const h=Ke(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&(c.x=nr(o));let l=0,u=0;if(o&&!r&&!i){const h=o.getBoundingClientRect();u=h.top+a.scrollTop,l=h.left+a.scrollLeft-nr(o,h)}const f=s.left+a.scrollLeft-c.x-l,p=s.top+a.scrollTop-c.y-u;return{x:f,y:p,width:s.width,height:s.height}}function Ln(e){return ve(e).position==="static"}function vo(e,t){if(!$e(e)||ve(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Se(e)===n&&(n=n.ownerDocument.body),n}function Wi(e,t){const n=ue(e);if(wn(e))return n;if(!$e(e)){let o=Ne(e);for(;o&&!at(o);){if(be(o)&&!Ln(o))return o;o=Ne(o)}return n}let r=vo(e,t);for(;r&&Wl(r)&&Ln(r);)r=vo(r,t);return r&&at(r)&&Ln(r)&&!Cr(r)?n:r||Hl(e)||n}const tu=async function(e){const t=this.getOffsetParent||Wi,n=this.getDimensions,r=await n(e.floating);return{reference:eu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nu(e){return ve(e).direction==="rtl"}const ru={convertOffsetParentRelativeRectToViewportRelativeRect:Kl,getDocumentElement:Se,getClippingRect:Zl,getOffsetParent:Wi,getElementRects:tu,getClientRects:Gl,getDimensions:Ql,getScale:st,isElement:be,isRTL:nu};function ou(e,t){let n=null,r;const o=Se(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const{left:l,top:u,width:f,height:p}=e.getBoundingClientRect();if(a||t(),!f||!p)return;const h=Kt(u),m=Kt(o.clientWidth-(l+f)),b=Kt(o.clientHeight-(u+p)),y=Kt(l),w={rootMargin:-h+"px "+-m+"px "+-b+"px "+-y+"px",threshold:le(0,je(1,c))||1};let x=!0;function $(C){const E=C[0].intersectionRatio;if(E!==c){if(!x)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver($,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver($,w)}n.observe(e)}return s(!0),i}function iu(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=Rr(e),u=o||i?[...l?At(l):[],...At(t)]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),i&&v.addEventListener("resize",n)});const f=l&&a?ou(l,n):null;let p=-1,h=null;s&&(h=new ResizeObserver(v=>{let[w]=v;w&&w.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),l&&!c&&h.observe(l),h.observe(t));let m,b=c?Ke(e):null;c&&y();function y(){const v=Ke(e);b&&(v.x!==b.x||v.y!==b.y||v.width!==b.width||v.height!==b.height)&&n(),b=v,m=requestAnimationFrame(y)}return n(),()=>{var v;u.forEach(w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f==null||f(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const su=Nl,au=Fl,cu=jl,lu=Bl,uu=Ml,yo=Il,fu=zl,du=(e,t,n)=>{const r=new Map,o={platform:ru,...n},i={...o.platform,_c:r};return Dl(e,t,{...o,platform:i})};var Qt=typeof document<"u"?d.useLayoutEffect:d.useEffect;function sn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!sn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!sn(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Hi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wo(e,t){const n=Hi(e);return Math.round(t*n)/n}function Nn(e){const t=d.useRef(e);return Qt(()=>{t.current=e}),t}function pu(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:c,open:l}=e,[u,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=d.useState(r);sn(p,r)||h(r);const[m,b]=d.useState(null),[y,v]=d.useState(null),w=d.useCallback(M=>{M!==E.current&&(E.current=M,b(M))},[]),x=d.useCallback(M=>{M!==S.current&&(S.current=M,v(M))},[]),$=i||m,C=s||y,E=d.useRef(null),S=d.useRef(null),k=d.useRef(u),z=c!=null,R=Nn(c),T=Nn(o),P=Nn(l),I=d.useCallback(()=>{if(!E.current||!S.current)return;const M={placement:t,strategy:n,middleware:p};T.current&&(M.platform=T.current),du(E.current,S.current,M).then(H=>{const J={...H,isPositioned:P.current!==!1};j.current&&!sn(k.current,J)&&(k.current=J,di.flushSync(()=>{f(J)}))})},[p,t,n,T,P]);Qt(()=>{l===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[l]);const j=d.useRef(!1);Qt(()=>(j.current=!0,()=>{j.current=!1}),[]),Qt(()=>{if($&&(E.current=$),C&&(S.current=C),$&&C){if(R.current)return R.current($,C,I);I()}},[$,C,I,R,z]);const L=d.useMemo(()=>({reference:E,floating:S,setReference:w,setFloating:x}),[w,x]),B=d.useMemo(()=>({reference:$,floating:C}),[$,C]),W=d.useMemo(()=>{const M={position:n,left:0,top:0};if(!B.floating)return M;const H=wo(B.floating,u.x),J=wo(B.floating,u.y);return a?{...M,transform:"translate("+H+"px, "+J+"px)",...Hi(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:J}},[n,a,B.floating,u.x,u.y]);return d.useMemo(()=>({...u,update:I,refs:L,elements:B,floatingStyles:W}),[u,I,L,B,W])}const hu=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?yo({element:r.current,padding:o}).fn(n):{}:r?yo({element:r,padding:o}).fn(n):{}}}},gu=(e,t)=>({...su(e),options:[e,t]}),mu=(e,t)=>({...au(e),options:[e,t]}),bu=(e,t)=>({...fu(e),options:[e,t]}),vu=(e,t)=>({...cu(e),options:[e,t]}),yu=(e,t)=>({...lu(e),options:[e,t]}),wu=(e,t)=>({...uu(e),options:[e,t]}),xu=(e,t)=>({...hu(e),options:[e,t]});var Eu="Arrow",Vi=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return F.jsx(ze.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:F.jsx("polygon",{points:"0,0 30,0 15,10"})})});Vi.displayName=Eu;var $u=Vi;function Su(e,t=[]){let n=[];function r(i,s){const a=d.createContext(s),c=n.length;n=[...n,s];function l(f){const{scope:p,children:h,...m}=f,b=(p==null?void 0:p[e][c])||a,y=d.useMemo(()=>m,Object.values(m));return F.jsx(b.Provider,{value:y,children:h})}function u(f,p){const h=(p==null?void 0:p[e][c])||a,m=d.useContext(h);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return l.displayName=i+"Provider",[l,u]}const o=()=>{const i=n.map(s=>d.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Cu(o,...t)]}function Cu(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const f=c(i)[`__scope${l}`];return{...a,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Ou(e){const[t,n]=d.useState(void 0);return Ue(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var _r="Popper",[Ui,Ki]=Su(_r),[Ru,Gi]=Ui(_r),Yi=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return F.jsx(Ru,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yi.displayName=_r;var qi="PopperAnchor",Xi=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Gi(qi,n),s=d.useRef(null),a=Ye(t,s);return d.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:F.jsx(ze.div,{...o,ref:a})});Xi.displayName=qi;var Tr="PopperContent",[_u,Tu]=Ui(Tr),Ji=d.forwardRef((e,t)=>{var Be,Ce,bt,vt,yt,wt;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:m,...b}=e,y=Gi(Tr,n),[v,w]=d.useState(null),x=Ye(t,fe=>w(fe)),[$,C]=d.useState(null),E=Ou($),S=(E==null?void 0:E.width)??0,k=(E==null?void 0:E.height)??0,z=r+(i!=="center"?"-"+i:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},T=Array.isArray(l)?l:[l],P=T.length>0,I={padding:R,boundary:T.filter(ku),altBoundary:P},{refs:j,floatingStyles:L,placement:B,isPositioned:W,middlewareData:M}=pu({strategy:"fixed",placement:z,whileElementsMounted:(...fe)=>iu(...fe,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[gu({mainAxis:o+k,alignmentAxis:s}),c&&mu({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?bu():void 0,...I}),c&&vu({...I}),yu({...I,apply:({elements:fe,rects:Xe,availableWidth:Je,availableHeight:Ze})=>{const{width:On,height:Rn}=Xe.reference,Qe=fe.floating.style;Qe.setProperty("--radix-popper-available-width",`${Je}px`),Qe.setProperty("--radix-popper-available-height",`${Ze}px`),Qe.setProperty("--radix-popper-anchor-width",`${On}px`),Qe.setProperty("--radix-popper-anchor-height",`${Rn}px`)}}),$&&xu({element:$,padding:a}),Au({arrowWidth:S,arrowHeight:k}),p&&wu({strategy:"referenceHidden",...I})]}),[H,J]=es(B),ie=ft(m);Ue(()=>{W&&(ie==null||ie())},[W,ie]);const zt=(Be=M.arrow)==null?void 0:Be.x,Bt=(Ce=M.arrow)==null?void 0:Ce.y,Wt=((bt=M.arrow)==null?void 0:bt.centerOffset)!==0,[Ht,qe]=d.useState();return Ue(()=>{v&&qe(window.getComputedStyle(v).zIndex)},[v]),F.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:W?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ht,"--radix-popper-transform-origin":[(vt=M.transformOrigin)==null?void 0:vt.x,(yt=M.transformOrigin)==null?void 0:yt.y].join(" "),...((wt=M.hide)==null?void 0:wt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:F.jsx(_u,{scope:n,placedSide:H,onArrowChange:C,arrowX:zt,arrowY:Bt,shouldHideArrow:Wt,children:F.jsx(ze.div,{"data-side":H,"data-align":J,...b,ref:x,style:{...b.style,animation:W?void 0:"none"}})})})});Ji.displayName=Tr;var Zi="PopperArrow",Pu={top:"bottom",right:"left",bottom:"top",left:"right"},Qi=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Tu(Zi,r),s=Pu[i.placedSide];return F.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:F.jsx($u,{...o,ref:n,style:{...o.style,display:"block"}})})});Qi.displayName=Zi;function ku(e){return e!==null}var Au=e=>({name:"transformOrigin",options:e,fn(t){var y,v,w;const{placement:n,rects:r,middlewareData:o}=t,s=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[l,u]=es(n),f={start:"0%",center:"50%",end:"100%"}[u],p=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,h=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let m="",b="";return l==="bottom"?(m=s?f:`${p}px`,b=`${-c}px`):l==="top"?(m=s?f:`${p}px`,b=`${r.floating.height+c}px`):l==="right"?(m=`${-c}px`,b=s?f:`${h}px`):l==="left"&&(m=`${r.floating.width+c}px`,b=s?f:`${h}px`),{data:{x:m,y:b}}}});function es(e){const[t,n="center"]=e.split("-");return[t,n]}var Du=Yi,Iu=Xi,ju=Ji,Mu=Qi;function Lu(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var ts=e=>{const{present:t,children:n}=e,r=Nu(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),i=Ye(r.ref,Fu(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:i}):null};ts.displayName="Presence";function Nu(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),i=d.useRef("none"),s=e?"mounted":"unmounted",[a,c]=Lu(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=Gt(r.current);i.current=a==="mounted"?l:"none"},[a]),Ue(()=>{const l=r.current,u=o.current;if(u!==e){const p=i.current,h=Gt(l);e?c("MOUNT"):h==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&p!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Ue(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,f=h=>{const b=Gt(r.current).includes(h.animationName);if(h.target===t&&b&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=h=>{h.target===t&&(i.current=Gt(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function Gt(e){return(e==null?void 0:e.animationName)||"none"}function Fu(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function zu({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=Bu({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=ft(n),c=d.useCallback(l=>{if(i){const f=typeof l=="function"?l(e):l;f!==e&&a(f)}else o(l)},[i,e,o,a]);return[s,c]}function Bu({defaultProp:e,onChange:t}){const n=d.useState(e),[r]=n,o=d.useRef(r),i=ft(t);return d.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}var Wu="VisuallyHidden",ns=d.forwardRef((e,t)=>F.jsx(ze.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));ns.displayName=Wu;var Hu=ns,[En,Cm]=dl("Tooltip",[Ki]),$n=Ki(),Vu="TooltipProvider",rr="tooltip.open",[Om,Pr]=En(Vu),Sn="Tooltip",[Uu,Cn]=En(Sn),rs=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,c=Pr(Sn,e.__scopeTooltip),l=$n(t),[u,f]=d.useState(null),p=Sl(),h=d.useRef(0),m=s??c.disableHoverableContent,b=a??c.delayDuration,y=d.useRef(!1),[v=!1,w]=zu({prop:r,defaultProp:o,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(rr))):c.onClose(),i==null||i(S)}}),x=d.useMemo(()=>v?y.current?"delayed-open":"instant-open":"closed",[v]),$=d.useCallback(()=>{window.clearTimeout(h.current),y.current=!1,w(!0)},[w]),C=d.useCallback(()=>{window.clearTimeout(h.current),w(!1)},[w]),E=d.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,w(!0)},b)},[b,w]);return d.useEffect(()=>()=>window.clearTimeout(h.current),[]),F.jsx(Du,{...l,children:F.jsx(Uu,{scope:t,contentId:p,open:v,stateAttribute:x,trigger:u,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayed?E():$()},[c.isOpenDelayed,E,$]),onTriggerLeave:d.useCallback(()=>{m?C():window.clearTimeout(h.current)},[C,m]),onOpen:$,onClose:C,disableHoverableContent:m,children:n})})};rs.displayName=Sn;var or="TooltipTrigger",os=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Cn(or,n),i=Pr(or,n),s=$n(n),a=d.useRef(null),c=Ye(t,a,o.onTriggerChange),l=d.useRef(!1),u=d.useRef(!1),f=d.useCallback(()=>l.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),F.jsx(Iu,{asChild:!0,...s,children:F.jsx(ze.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:Re(e.onPointerMove,p=>{p.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Re(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:Re(e.onBlur,o.onClose),onClick:Re(e.onClick,o.onClose)})})});os.displayName=or;var Ku="TooltipPortal",[Rm,Gu]=En(Ku,{forceMount:void 0}),ct="TooltipContent",is=d.forwardRef((e,t)=>{const n=Gu(ct,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=Cn(ct,e.__scopeTooltip);return F.jsx(ts,{present:r||s.open,children:s.disableHoverableContent?F.jsx(ss,{side:o,...i,ref:t}):F.jsx(Yu,{side:o,...i,ref:t})})}),Yu=d.forwardRef((e,t)=>{const n=Cn(ct,e.__scopeTooltip),r=Pr(ct,e.__scopeTooltip),o=d.useRef(null),i=Ye(t,o),[s,a]=d.useState(null),{trigger:c,onClose:l}=n,u=o.current,{onPointerInTransitChange:f}=r,p=d.useCallback(()=>{a(null),f(!1)},[f]),h=d.useCallback((m,b)=>{const y=m.currentTarget,v={x:m.clientX,y:m.clientY},w=Ju(v,y.getBoundingClientRect()),x=Zu(v,w),$=Qu(b.getBoundingClientRect()),C=tf([...x,...$]);a(C),f(!0)},[f]);return d.useEffect(()=>()=>p(),[p]),d.useEffect(()=>{if(c&&u){const m=y=>h(y,u),b=y=>h(y,c);return c.addEventListener("pointerleave",m),u.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",b)}}},[c,u,h,p]),d.useEffect(()=>{if(s){const m=b=>{const y=b.target,v={x:b.clientX,y:b.clientY},w=(c==null?void 0:c.contains(y))||(u==null?void 0:u.contains(y)),x=!ef(v,s);w?p():x&&(p(),l())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,u,s,l,p]),F.jsx(ss,{...e,ref:i})}),[qu,Xu]=En(Sn,{isInside:!1}),ss=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...a}=e,c=Cn(ct,n),l=$n(n),{onClose:u}=c;return d.useEffect(()=>(document.addEventListener(rr,u),()=>document.removeEventListener(rr,u)),[u]),d.useEffect(()=>{if(c.trigger){const f=p=>{const h=p.target;h!=null&&h.contains(c.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,u]),F.jsx(Ii,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:f=>f.preventDefault(),onDismiss:u,children:F.jsxs(ju,{"data-state":c.stateAttribute,...l,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[F.jsx(Oi,{children:r}),F.jsx(qu,{scope:n,isInside:!0,children:F.jsx(Hu,{id:c.contentId,role:"tooltip",children:o||r})})]})})});is.displayName=ct;var as="TooltipArrow",cs=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=$n(n);return Xu(as,n).isInside?null:F.jsx(Mu,{...o,...r,ref:t})});cs.displayName=as;function Ju(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Zu(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Qu(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function ef(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;ir!=u>r&&n<(l-a)*(r-c)/(u-c)+a&&(o=!o)}return o}function tf(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),nf(t)}function nf(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var rf=rs,of=os,sf=is,af=cs;function cf(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i=0)&&(n[o]=e[o]);return n}function U(e,t){if(e==null)return{};var n=cf(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}let Y;(function(e){e[e.UNSUPPORTED_INPUT=0]="UNSUPPORTED_INPUT",e[e.NO_COMPONENT_FOR_TYPE=1]="NO_COMPONENT_FOR_TYPE",e[e.UNKNOWN_INPUT=2]="UNKNOWN_INPUT",e[e.DUPLICATE_KEYS=3]="DUPLICATE_KEYS",e[e.ALREADY_REGISTERED_TYPE=4]="ALREADY_REGISTERED_TYPE",e[e.CLIPBOARD_ERROR=5]="CLIPBOARD_ERROR",e[e.THEME_ERROR=6]="THEME_ERROR",e[e.PATH_DOESNT_EXIST=7]="PATH_DOESNT_EXIST",e[e.INPUT_TYPE_OVERRIDE=8]="INPUT_TYPE_OVERRIDE",e[e.EMPTY_KEY=9]="EMPTY_KEY"})(Y||(Y={}));const lf={[Y.UNSUPPORTED_INPUT]:(e,t)=>[`An input with type \`${e}\` input was found at path \`${t}\` but it's not supported yet.`],[Y.NO_COMPONENT_FOR_TYPE]:(e,t)=>[`Type \`${e}\` found at path \`${t}\` can't be displayed in panel because no component supports it yet.`],[Y.UNKNOWN_INPUT]:(e,t)=>[`input at path \`${e}\` is not recognized.`,t],[Y.DUPLICATE_KEYS]:(e,t,n)=>[`Key \`${e}\` of path \`${t}\` already exists at path \`${n}\`. Even nested keys need to be unique. Rename one of the keys.`],[Y.ALREADY_REGISTERED_TYPE]:e=>[`Type ${e} has already been registered. You can't register a component with the same type.`],[Y.CLIPBOARD_ERROR]:e=>["Error copying the value",e],[Y.THEME_ERROR]:(e,t)=>[`Error accessing the theme \`${e}.${t}\` value.`],[Y.PATH_DOESNT_EXIST]:e=>[`Error getting the value at path \`${e}\`. There is probably an error in your \`render\` function.`],[Y.PATH_DOESNT_EXIST]:e=>[`Error accessing the value at path \`${e}\``],[Y.INPUT_TYPE_OVERRIDE]:(e,t,n)=>[`Input at path \`${e}\` already exists with type: \`${t}\`. Its type cannot be overridden with type \`${n}\`.`],[Y.EMPTY_KEY]:()=>["Keys can not be empty, if you want to hide a label use whitespace."]};function ls(e,t,...n){const[r,...o]=lf[t](...n);console[e]("LEVA: "+r,...o)}const _e=ls.bind(null,"warn"),uf=ls.bind(null,"log"),ff=["value"],df=["schema"],pf=["value"],us=[],Ge={};function xo(e){let{value:t}=e,n=U(e,ff);for(let r of us){const o=r(t,n);if(o)return o}}function De(e,t){let{schema:n}=t,r=U(t,df);if(e in Ge){_e(Y.ALREADY_REGISTERED_TYPE,e);return}us.push((o,i)=>n(o,i)&&e),Ge[e]=r}function Fn(e,t,n,r){const{normalize:o}=Ge[e];if(o)return o(t,n,r);if(typeof t!="object"||!("value"in t))return{value:t};const{value:i}=t,s=U(t,pf);return{value:i,settings:s}}function hf(e,t,n,r,o,i){const{sanitize:s}=Ge[e];return s?s(t,n,r,o,i):t}function Eo(e,t,n){const{format:r}=Ge[e];return r?r(t,n):t}function gf(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function D(e){for(var t=1;te>n?n:e{if(e===""||typeof e=="number")return e;try{const t=Ie(e);if(!isNaN(t))return t}catch{}return parseFloat(e)},bf=Math.log(10);function So(e){let t=Math.abs(+String(e).replace(".",""));if(t===0)return .01;for(;t!==0&&t%10===0;)t/=10;const n=Math.floor(Math.log(t)/bf)+1,r=Math.floor(Math.log10(Math.abs(e))),o=Math.pow(10,r-n);return Math.max(o,.001)}const an=(e,t,n)=>n===t?0:(Fe(e,t,n)-t)/(n-t),cn=(e,t,n)=>e*(n-t)+t,vf=()=>"_"+Math.random().toString(36).substr(2,9),Co=/\(([0-9+\-*/^ .]+)\)/,Oo=/(\d+(?:\.\d+)?) ?\^ ?(\d+(?:\.\d+)?)/,Ro=/(\d+(?:\.\d+)?) ?\* ?(\d+(?:\.\d+)?)/,_o=/(\d+(?:\.\d+)?) ?\/ ?(\d+(?:\.\d+)?)/,To=/(\d+(?:\.\d+)?) ?\+ ?(\d+(?:\.\d+)?)/,Po=/(\d+(?:\.\d+)?) ?- ?(\d+(?:\.\d+)?)/;function Ie(e){if(isNaN(Number(e)))if(Co.test(e)){const t=e.replace(Co,(n,r)=>String(Ie(r)));return Ie(t)}else if(Oo.test(e)){const t=e.replace(Oo,(n,r,o)=>String(Math.pow(Number(r),Number(o))));return Ie(t)}else if(Ro.test(e)){const t=e.replace(Ro,(n,r,o)=>String(Number(r)*Number(o)));return Ie(t)}else if(_o.test(e)){const t=e.replace(_o,(n,r,o)=>{if(o!=0)return String(Number(r)/Number(o));throw new Error("Division by zero")});return Ie(t)}else if(To.test(e)){const t=e.replace(To,(n,r,o)=>String(Number(r)+Number(o)));return Ie(t)}else if(Po.test(e)){const t=e.replace(Po,(n,r,o)=>String(Number(r)-Number(o)));return Ie(t)}else return Number(e);return Number(e)}function yf(e,t){return t.reduce((n,r)=>(e&&e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}function wf(e,t){const n=D({},e);return t.forEach(r=>r in e&&delete n[r]),n}function xf(e,t){return e.reduce((n,r,o)=>Object.assign(n,{[t[o]]:r}),{})}function fs(e){return Object.prototype.toString.call(e)==="[object Object]"}const Ef=e=>fs(e)&&Object.keys(e).length===0;let me;(function(e){e.BUTTON="BUTTON",e.BUTTON_GROUP="BUTTON_GROUP",e.MONITOR="MONITOR",e.FOLDER="FOLDER"})(me||(me={}));let ye;(function(e){e.SELECT="SELECT",e.IMAGE="IMAGE",e.NUMBER="NUMBER",e.COLOR="COLOR",e.STRING="STRING",e.BOOLEAN="BOOLEAN",e.INTERVAL="INTERVAL",e.VECTOR3D="VECTOR3D",e.VECTOR2D="VECTOR2D"})(ye||(ye={}));const $f=["type","__customInput"],Sf=["render","label","optional","order","disabled","hint","onChange","onEditStart","onEditEnd","transient"],Cf=["type"];function ds(e,t,n={},r){var o,i;if(typeof e!="object"||Array.isArray(e))return{type:r,input:e,options:D({key:t,label:t,optional:!1,disabled:!1,order:0},n)};if("__customInput"in e){const{type:C,__customInput:E}=e,S=U(e,$f);return ds(E,t,S,C)}const{render:s,label:a,optional:c,order:l=0,disabled:u,hint:f,onChange:p,onEditStart:h,onEditEnd:m,transient:b}=e,y=U(e,Sf),v=D({render:s,key:t,label:a??t,hint:f,transient:b??!!p,onEditStart:h,onEditEnd:m,disabled:u,optional:c,order:l},n);let{type:w}=y,x=U(y,Cf);if(w=r??w,w in me)return{type:w,input:x,options:v};let $;return r&&fs(x)&&"value"in x?$=x.value:$=Ef(x)?void 0:x,{type:w,input:$,options:D(D({},v),{},{onChange:p,optional:(o=v.optional)!==null&&o!==void 0?o:!1,disabled:(i=v.disabled)!==null&&i!==void 0?i:!1})}}function Of(e,t,n,r){const o=ds(e,t),{type:i,input:s,options:a}=o;if(i)return i in me?o:{type:i,input:Fn(i,s,n,r),options:a};let c=xo(s);return c?{type:c,input:Fn(c,s,n,r),options:a}:(c=xo({value:s}),c?{type:c,input:Fn(c,{value:s},n,r),options:a}:!1)}function ko(e,t,n,r,o){const{value:i,type:s,settings:a}=e;e.value=ps({type:s,value:i,settings:a},t,n,r),e.fromPanel=o}const Rf=function(t,n,r){this.type="LEVA_ERROR",this.message="LEVA: "+t,this.previousValue=n,this.error=r};function ps({type:e,value:t,settings:n},r,o,i){const s=e!=="SELECT"&&typeof r=="function"?r(t):r;let a;try{a=hf(e,s,n,t,o,i)}catch(c){throw new Rf(`The value \`${r}\` did not result in a correct value.`,t,c)}return Tt(a,t)?t:a}const hs=(e,t,n=!1)=>{let r=0;return function(){const o=arguments,i=n&&!r,s=()=>e.apply(this,o);window.clearTimeout(r),r=window.setTimeout(s,t),i&&s()}},gs=e=>e.shiftKey?5:e.altKey?1/5:1;function _f(e,t){const n=console.error;console.error=()=>{},pi.render(e,t),console.error=n}const Tf=["value"],Pf=["min","max"],kf=e=>{if(typeof e=="number")return!0;if(typeof e=="string"){const t=parseFloat(e);return isNaN(t)?!1:e.substring((""+t).length).trim().length<4}return!1},ms=(e,{min:t=-1/0,max:n=1/0,suffix:r})=>{const o=parseFloat(e);if(e===""||isNaN(o))throw Error("Invalid number");const i=Fe(o,t,n);return r?i+r:i},Af=(e,{pad:t=0,suffix:n})=>{const r=parseFloat(e).toFixed(t);return n?r+n:r},bs=e=>{let{value:t}=e,n=U(e,Tf);const{min:r=-1/0,max:o=1/0}=n,i=U(n,Pf);let s=parseFloat(t);const a=typeof t=="string"?t.substring((""+s).length):void 0;s=Fe(s,r,o);let c=n.step;c||(Number.isFinite(r)?Number.isFinite(o)?c=+(Math.abs(o-r)/100).toPrecision(1):c=+(Math.abs(s-r)/100).toPrecision(1):Number.isFinite(o)&&(c=+(Math.abs(o-s)/100).toPrecision(1)));const l=c?So(c)*10:So(s);c=c||l/10;const u=Math.round(Fe(Math.log10(1/l),0,2));return{value:a?s+a:s,settings:D({initialValue:s,step:c,pad:u,min:r,max:o,suffix:a},i)}},vs=(e,{step:t,initialValue:n})=>{const r=Math.round((e-n)/t);return n+r*t};var ys=Object.freeze({__proto__:null,schema:kf,sanitize:ms,format:Af,normalize:bs,sanitizeStep:vs});function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t({colors:{elevation1:"#292d39",elevation2:"#181c20",elevation3:"#373c4b",accent1:"#0066dc",accent2:"#007bff",accent3:"#3c93ff",highlight1:"#535760",highlight2:"#8c92a4",highlight3:"#fefefe",vivid1:"#ffcc00",folderWidgetColor:"$highlight2",folderTextColor:"$highlight3",toolTipBackground:"$highlight3",toolTipText:"$elevation2"},radii:{xs:"2px",sm:"3px",lg:"10px"},space:{xs:"3px",sm:"6px",md:"10px",rowGap:"7px",colGap:"7px"},fonts:{mono:"ui-monospace, SFMono-Regular, Menlo, 'Roboto Mono', monospace",sans:"system-ui, sans-serif"},fontSizes:{root:"11px",toolTip:"$root"},sizes:{rootWidth:"280px",controlWidth:"160px",numberInputMinWidth:"38px",scrubberWidth:"8px",scrubberHeight:"16px",rowHeight:"24px",folderTitleHeight:"20px",checkboxSize:"16px",joystickWidth:"100px",joystickHeight:"100px",colorPickerWidth:"$controlWidth",colorPickerHeight:"100px",imagePreviewWidth:"$controlWidth",imagePreviewHeight:"100px",monitorHeight:"60px",titleBarHeight:"39px"},shadows:{level1:"0 0 9px 0 #00000088",level2:"0 4px 14px #00000033"},borderWidths:{root:"0px",input:"1px",focus:"1px",hover:"1px",active:"1px",folder:"1px"},fontWeights:{label:"normal",folder:"normal",button:"normal"}});function Yt(e,t){const[n,r]=e.split(" "),o={};return n!=="none"&&(o.boxShadow=`${t.inset?"inset ":""}0 0 0 $borderWidths${[t.key]} $colors${n!=="default"&&n||t.borderColor}`),r&&(o.backgroundColor=r),o}const $t={$inputStyle:()=>e=>Yt(e,{key:"$input",borderColor:"$highlight1",inset:!0}),$focusStyle:()=>e=>Yt(e,{key:"$focus",borderColor:"$accent2"}),$hoverStyle:()=>e=>Yt(e,{key:"$hover",borderColor:"$accent1",inset:!0}),$activeStyle:()=>e=>Yt(e,{key:"$active",borderColor:"$accent1",inset:!0})},{styled:A,css:_m,createTheme:If,globalCss:jf,keyframes:Tm}=fl({prefix:"leva",theme:$s(),utils:D(D({},$t),{},{$flex:()=>({display:"flex",alignItems:"center"}),$flexCenter:()=>({display:"flex",alignItems:"center",justifyContent:"center"}),$reset:()=>({outline:"none",fontSize:"inherit",fontWeight:"inherit",color:"inherit",fontFamily:"inherit",border:"none",backgroundColor:"transparent",appearance:"none"}),$draggable:()=>({touchAction:"none",WebkitUserDrag:"none",userSelect:"none"}),$focus:e=>({"&:focus":$t.$focusStyle()(e)}),$focusWithin:e=>({"&:focus-within":$t.$focusStyle()(e)}),$hover:e=>({"&:hover":$t.$hoverStyle()(e)}),$active:e=>({"&:active":$t.$activeStyle()(e)})})}),Mf=jf({".leva__panel__dragged":{WebkitUserDrag:"none",userSelect:"none",input:{userSelect:"none"},"*":{cursor:"ew-resize !important"}}});function Lf(e){const t=$s();if(!e)return{theme:t,className:""};Object.keys(e).forEach(r=>{Object.assign(t[r],e[r])});const n=If(t);return{theme:t,className:n.className}}function Te(e,t){const{theme:n}=d.useContext(kr);if(!(e in n)||!(t in n[e]))return _e(Y.THEME_ERROR,e,t),"";let r=t;for(;;){let o=n[e][r];if(typeof o=="string"&&o.charAt(0)==="$")r=o.substr(1);else return o}}const Ss=A("input",{$reset:"",padding:"0 $sm",width:0,minWidth:0,flex:1,height:"100%",variants:{levaType:{number:{textAlign:"right"}},as:{textarea:{padding:"$sm"}}}}),Cs=A("div",{$draggable:"",height:"100%",$flexCenter:"",position:"relative",padding:"0 $xs",fontSize:"0.8em",opacity:.8,cursor:"default",touchAction:"none",[`& + ${Ss}`]:{paddingLeft:0}}),Nf=A(Cs,{cursor:"ew-resize",marginRight:"-$xs",textTransform:"uppercase",opacity:.3,"&:hover":{opacity:1},variants:{dragging:{true:{backgroundColor:"$accent2",opacity:1}}}}),Ff=A("div",{$flex:"",position:"relative",borderRadius:"$sm",overflow:"hidden",color:"inherit",height:"$rowHeight",backgroundColor:"$elevation3",$inputStyle:"$elevation1",$hover:"",$focusWithin:"",variants:{textArea:{true:{height:"auto"}}}}),zf=["innerLabel","value","onUpdate","onChange","onKeyDown","type","id","inputType","rows"],Bf=["onUpdate"];function Ar(e){let{innerLabel:t,value:n,onUpdate:r,onChange:o,onKeyDown:i,type:s,id:a,inputType:c="text",rows:l=0}=e,u=U(e,zf);const{id:f,emitOnEditStart:p,emitOnEditEnd:h,disabled:m}=te(),b=a||f,y=d.useRef(null),v=l>0,w=v?"textarea":"input",x=d.useCallback(E=>S=>{const k=S.currentTarget.value;E(k)},[]);g.useEffect(()=>{const E=y.current,S=x(k=>{r(k),h()});return E==null||E.addEventListener("blur",S),()=>E==null?void 0:E.removeEventListener("blur",S)},[x,r,h]);const $=d.useCallback(E=>{E.key==="Enter"&&x(r)(E)},[x,r]),C=Object.assign({as:w},v?{rows:l}:{},u);return g.createElement(Ff,{textArea:v},t&&typeof t=="string"?g.createElement(Cs,null,t):t,g.createElement(Ss,X({levaType:s,ref:y,id:b,type:c,autoComplete:"off",spellCheck:"false",value:n,onChange:x(o),onFocus:()=>p(),onKeyPress:$,onKeyDown:i,disabled:m},C)))}function Wf(e){let{onUpdate:t}=e,n=U(e,Bf);const r=d.useCallback(i=>t(mf(i)),[t]),o=d.useCallback(i=>{const s=i.key==="ArrowUp"?1:i.key==="ArrowDown"?-1:0;if(s){i.preventDefault();const a=i.altKey?.1:i.shiftKey?10:1;t(c=>parseFloat(c)+s*a)}},[t]);return g.createElement(Ar,X({},n,{onUpdate:r,onKeyDown:o,type:"number"}))}const ln=A("div",{}),ir=A("div",{position:"relative",background:"$elevation2",transition:"height 300ms ease",variants:{fill:{true:{},false:{}},flat:{false:{},true:{}},isRoot:{true:{},false:{paddingLeft:"$md","&::after":{content:'""',position:"absolute",left:0,top:0,width:"$borderWidths$folder",height:"100%",backgroundColor:"$folderWidgetColor",opacity:.4,transform:"translateX(-50%)"}}}},compoundVariants:[{isRoot:!0,fill:!1,css:{overflowY:"auto",maxHeight:"calc(100vh - 20px - $$titleBarHeight)"}},{isRoot:!0,flat:!1,css:{borderRadius:"$lg"}}]}),Hf=A("div",{$flex:"",color:"$folderTextColor",userSelect:"none",cursor:"pointer",height:"$folderTitleHeight",fontWeight:"$folder","> svg":{marginLeft:-4,marginRight:4,cursor:"pointer",fill:"$folderWidgetColor",opacity:.6},"&:hover > svg":{fill:"$folderWidgetColor"},[`&:hover + ${ir}::after`]:{opacity:.6},[`${ln}:hover > & + ${ir}::after`]:{opacity:.6},[`${ln}:hover > & > svg`]:{opacity:1}}),Os=A("div",{position:"relative",display:"grid",gridTemplateColumns:"100%",rowGap:"$rowGap",transition:"opacity 250ms ease",variants:{toggled:{true:{opacity:1,transitionDelay:"250ms"},false:{opacity:0,transitionDelay:"0ms",pointerEvents:"none"}},isRoot:{true:{"& > div":{paddingLeft:"$md",paddingRight:"$md"},"& > div:first-of-type":{paddingTop:"$sm"},"& > div:last-of-type":{paddingBottom:"$sm"},[`> ${ln}:not(:first-of-type)`]:{paddingTop:"$sm",marginTop:"$md",borderTop:"$borderWidths$folder solid $colors$elevation1"}}}}}),Rs=A("div",{position:"relative",zIndex:100,display:"grid",rowGap:"$rowGap",gridTemplateRows:"minmax($sizes$rowHeight, max-content)",alignItems:"center",color:"$highlight2",[`${Os} > &`]:{"&:first-of-type":{marginTop:"$rowGap"},"&:last-of-type":{marginBottom:"$rowGap"}},variants:{disabled:{true:{pointerEvents:"none"},false:{"&:hover,&:focus-within":{color:"$highlight3"}}}}}),_s=A(Rs,{gridTemplateColumns:"auto $sizes$controlWidth",columnGap:"$colGap"}),Vf=A("div",{$flex:"",height:"100%",position:"relative",overflow:"hidden","& > div":{marginLeft:"$colGap",padding:"0 $xs",opacity:.4},"& > div:hover":{opacity:.8},"& > div > svg":{display:"none",cursor:"pointer",width:13,minWidth:13,height:13,backgroundColor:"$elevation2"},"&:hover > div > svg":{display:"block"},variants:{align:{top:{height:"100%",alignItems:"flex-start",paddingTop:"$sm"}}}}),Uf=A("input",{$reset:"",height:0,width:0,opacity:0,margin:0,"& + label":{position:"relative",$flexCenter:"",height:"100%",userSelect:"none",cursor:"pointer",paddingLeft:2,paddingRight:"$sm",pointerEvents:"auto"},"& + label:after":{content:'""',width:6,height:6,backgroundColor:"$elevation3",borderRadius:"50%",$activeStyle:""},"&:focus + label:after":{$focusStyle:""},"& + label:active:after":{backgroundColor:"$accent1",$focusStyle:""},"&:checked + label:after":{backgroundColor:"$accent1"}}),sr=A("label",{fontWeight:"$label",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","& > svg":{display:"block"}}),Kf=A("div",{opacity:1,variants:{disabled:{true:{opacity:.6,pointerEvents:"none",[`& ${sr}`]:{pointerEvents:"auto"}}}}}),Ts=A("div",{position:"fixed",top:0,bottom:0,right:0,left:0,zIndex:1e3,userSelect:"none"}),Gf=A("div",{background:"$toolTipBackground",fontFamily:"$sans",fontSize:"$toolTip",padding:"$xs $sm",color:"$toolTipText",borderRadius:"$xs",boxShadow:"$level2",maxWidth:260}),Yf=A(af,{fill:"$toolTipBackground"});function Dr({children:e}){const{className:t}=d.useContext(kr);return g.createElement(Dc,{className:t},e)}const qf=["align"];function Xf(){const{id:e,disable:t,disabled:n}=te();return g.createElement(g.Fragment,null,g.createElement(Uf,{id:e+"__disable",type:"checkbox",checked:!n,onChange:()=>t(!n)}),g.createElement("label",{htmlFor:e+"__disable"}))}function Jf(e){const{id:t,optional:n,hint:r}=te(),o=e.htmlFor||(t?{htmlFor:t}:null),i=!r&&typeof e.children=="string"?{title:e.children}:null;return g.createElement(g.Fragment,null,n&&g.createElement(Xf,null),r!==void 0?g.createElement(rf,null,g.createElement(of,{asChild:!0},g.createElement(sr,X({},o,e))),g.createElement(sf,{side:"top",sideOffset:2},g.createElement(Gf,null,r,g.createElement(Yf,null)))):g.createElement(sr,X({},o,i,e)))}function we(e){let{align:t}=e,n=U(e,qf);const{value:r,label:o,key:i,disabled:s}=te(),{hideCopyButton:a}=Df(),c=!a&&i!==void 0,[l,u]=d.useState(!1),f=async()=>{try{await navigator.clipboard.writeText(JSON.stringify({[i]:r??""})),u(!0)}catch{_e(Y.CLIPBOARD_ERROR,{[i]:r})}};return g.createElement(Vf,{align:t,onPointerLeave:()=>u(!1)},g.createElement(Jf,n),c&&!s&&g.createElement("div",{title:`Click to copy ${typeof o=="string"?o:i} value`},l?g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},g.createElement("path",{d:"M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"}),g.createElement("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm9.707 5.707a1 1 0 00-1.414-1.414L9 12.586l-1.293-1.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})):g.createElement("svg",{onClick:f,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},g.createElement("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),g.createElement("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"}))))}const Zf=["toggled"],Qf=A("svg",{fill:"currentColor",transition:"transform 350ms ease, fill 250ms ease"});function Ir(e){let{toggled:t}=e,n=U(e,Zf);return g.createElement(Qf,X({width:"9",height:"5",viewBox:"0 0 9 5",xmlns:"http://www.w3.org/2000/svg",style:{transform:`rotate(${t?0:-90}deg)`}},n),g.createElement("path",{d:"M3.8 4.4c.4.3 1 .3 1.4 0L8 1.7A1 1 0 007.4 0H1.6a1 1 0 00-.7 1.7l3 2.7z"}))}const ed=["input"];function he(e){let{input:t}=e,n=U(e,ed);return t?g.createElement(_s,n):g.createElement(Rs,n)}function Ps({value:e,type:t,settings:n,setValue:r}){const[o,i]=d.useState(Eo(t,e,n)),s=d.useRef(e),a=d.useRef(n);a.current=n;const c=d.useCallback(u=>i(Eo(t,u,a.current)),[t]),l=d.useCallback(u=>{try{r(u)}catch(f){const{type:p,previousValue:h}=f;if(p!=="LEVA_ERROR")throw f;c(h)}},[c,r]);return d.useEffect(()=>{Tt(e,s.current)||c(e),s.current=e},[e,c]),{displayValue:o,onChange:i,onUpdate:l}}function Lt(e,t){const{emitOnEditStart:n,emitOnEditEnd:r}=te();return vc(o=>{o.first&&(document.body.classList.add("leva__panel__dragged"),n==null||n());const i=e(o);return o.last&&(document.body.classList.remove("leva__panel__dragged"),r==null||r()),i},t)}function td(e){const t=d.useRef(null),n=d.useRef(null),r=d.useRef(!1);return d.useEffect(()=>{const o=hs(()=>{t.current.width=t.current.offsetWidth*window.devicePixelRatio,t.current.height=t.current.offsetHeight*window.devicePixelRatio,e(t.current,n.current)},250);return window.addEventListener("resize",o),r.current||(o(),r.current=!0),()=>window.removeEventListener("resize",o)},[e]),d.useEffect(()=>{n.current=t.current.getContext("2d")},[]),[t,n]}function ks(){const e=d.useRef(null),t=d.useRef({x:0,y:0}),n=d.useCallback(r=>{Object.assign(t.current,r),e.current&&(e.current.style.transform=`translate3d(${t.current.x}px, ${t.current.y}px, 0)`)},[]);return[e,n]}const nd=["__refCount"],zn=(e,t)=>{if(!e[t])return null;const n=e[t];return U(n,nd)};function rd(e){const t=Mt(),[n,r]=d.useState(zn(t.getData(),e)),o=d.useCallback(l=>t.setValueAtPath(e,l,!0),[e,t]),i=d.useCallback(l=>t.setSettingsAtPath(e,l),[e,t]),s=d.useCallback(l=>t.disableInputAtPath(e,l),[e,t]),a=d.useCallback(()=>t.emitOnEditStart(e),[e,t]),c=d.useCallback(()=>t.emitOnEditEnd(e),[e,t]);return d.useEffect(()=>{r(zn(t.getData(),e));const l=t.useStore.subscribe(u=>zn(u.data,e),r,{equalityFn:bn});return()=>l()},[t,e]),[n,{set:o,setSettings:i,disable:s,storeId:t.storeId,emitOnEditStart:a,emitOnEditEnd:c}]}const od=A("div",{variants:{hasRange:{true:{position:"relative",display:"grid",gridTemplateColumns:"auto $sizes$numberInputMinWidth",columnGap:"$colGap",alignItems:"center"}}}}),As=A("div",{position:"relative",width:"100%",height:2,borderRadius:"$xs",backgroundColor:"$elevation1"}),ar=A("div",{position:"absolute",width:"$scrubberWidth",height:"$scrubberHeight",borderRadius:"$xs",boxShadow:"0 0 0 2px $colors$elevation2",backgroundColor:"$accent2",cursor:"pointer",$active:"none $accent1",$hover:"none $accent3",variants:{position:{left:{borderTopRightRadius:0,borderBottomRightRadius:0,transform:"translateX(calc(-0.5 * ($sizes$scrubberWidth + 4px)))"},right:{borderTopLeftRadius:0,borderBottomLeftRadius:0,transform:"translateX(calc(0.5 * ($sizes$scrubberWidth + 4px)))"}}}}),Ds=A("div",{position:"relative",$flex:"",height:"100%",cursor:"pointer",touchAction:"none"}),Is=A("div",{position:"absolute",height:"100%",backgroundColor:"$accent2"});function id({value:e,min:t,max:n,onDrag:r,step:o,initialValue:i}){const s=d.useRef(null),a=d.useRef(null),c=d.useRef(0),l=Te("sizes","scrubberWidth"),u=Lt(({event:p,first:h,xy:[m],movement:[b],memo:y})=>{if(h){const{width:w,left:x}=s.current.getBoundingClientRect();c.current=w-parseFloat(l),y=(p==null?void 0:p.target)===a.current?e:cn((m-x)/w,t,n)}const v=y+cn(b/c.current,0,n-t);return r(vs(v,{step:o,initialValue:i})),y}),f=an(e,t,n);return g.createElement(Ds,X({ref:s},u()),g.createElement(As,null,g.createElement(Is,{style:{left:0,right:`${(1-f)*100}%`}})),g.createElement(ar,{ref:a,style:{left:`calc(${f} * (100% - ${l}))`}}))}const sd=g.memo(({label:e,onUpdate:t,step:n,innerLabelTrim:r})=>{const[o,i]=d.useState(!1),s=Lt(({active:a,delta:[c],event:l,memo:u=0})=>(i(a),u+=c/2,Math.abs(u)>=1&&(t(f=>parseFloat(f)+Math.floor(u)*n*gs(l)),u=0),u));return g.createElement(Nf,X({dragging:o,title:e.length>1?e:""},s()),e.slice(0,r))});function js({label:e,id:t,displayValue:n,onUpdate:r,onChange:o,settings:i,innerLabelTrim:s=1}){const a=s>0&&g.createElement(sd,{label:e,step:i.step,onUpdate:r,innerLabelTrim:s});return g.createElement(Wf,{id:t,value:String(n),onUpdate:r,onChange:o,innerLabel:a})}function ad(){const e=te(),{label:t,value:n,onUpdate:r,settings:o,id:i}=e,{min:s,max:a}=o,c=a!==1/0&&s!==-1/0;return g.createElement(he,{input:!0},g.createElement(we,null,t),g.createElement(od,{hasRange:c},c&&g.createElement(id,X({value:parseFloat(n),onDrag:r},o)),g.createElement(js,X({},e,{id:i,label:"value",innerLabelTrim:c?0:1}))))}const{sanitizeStep:cd}=ys,ld=U(ys,["sanitizeStep"]);var ud=D({component:ad},ld);const fd=(e,t)=>ce().schema({options:ce().passesAnyOf(ce().object(),ce().array())}).test(t),dd=(e,{values:t})=>{if(t.indexOf(e)<0)throw Error("Selected value doesn't match Select options");return e},pd=(e,{values:t})=>t.indexOf(e),hd=e=>{let{value:t,options:n}=e,r,o;return Array.isArray(n)?(o=n,r=n.map(i=>String(i))):(o=Object.values(n),r=Object.keys(n)),"value"in e?o.includes(t)||(r.unshift(String(t)),o.unshift(t)):t=o[0],Object.values(n).includes(t)||(n[String(t)]=t),{value:t,settings:{keys:r,values:o}}};var gd=Object.freeze({__proto__:null,schema:fd,sanitize:dd,format:pd,normalize:hd});const md=A("div",{$flexCenter:"",position:"relative","> svg":{pointerEvents:"none",position:"absolute",right:"$md"}}),cr=A("select",{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0}),bd=A("div",{display:"flex",alignItems:"center",width:"100%",height:"$rowHeight",backgroundColor:"$elevation3",borderRadius:"$sm",padding:"0 $sm",cursor:"pointer",[`${cr}:focus + &`]:{$focusStyle:""},[`${cr}:hover + &`]:{$hoverStyle:""}});function vd({displayValue:e,value:t,onUpdate:n,id:r,settings:o,disabled:i}){const{keys:s,values:a}=o,c=d.useRef();return t===a[e]&&(c.current=s[e]),g.createElement(md,null,g.createElement(cr,{id:r,value:e,onChange:l=>n(a[Number(l.currentTarget.value)]),disabled:i},s.map((l,u)=>g.createElement("option",{key:l,value:u},l))),g.createElement(bd,null,c.current),g.createElement(Ir,{toggled:!0}))}function yd(){const{label:e,value:t,displayValue:n,onUpdate:r,id:o,disabled:i,settings:s}=te();return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(vd,{id:o,value:t,displayValue:n,onUpdate:r,settings:s,disabled:i}))}var wd=D({component:yd},gd);const xd=e=>ce().string().test(e),Ed=e=>{if(typeof e!="string")throw Error("Invalid string");return e},$d=({value:e,editable:t=!0,rows:n=!1})=>({value:e,settings:{editable:t,rows:typeof n=="number"?n:n?5:0}});var Sd=Object.freeze({__proto__:null,schema:xd,sanitize:Ed,normalize:$d});const Cd=["displayValue","onUpdate","onChange","editable"],Od=A("div",{whiteSpace:"pre-wrap"});function Rd(e){let{displayValue:t,onUpdate:n,onChange:r,editable:o=!0}=e,i=U(e,Cd);return o?g.createElement(Ar,X({value:t,onUpdate:n,onChange:r},i)):g.createElement(Od,null,t)}function _d(){const{label:e,settings:t,displayValue:n,onUpdate:r,onChange:o}=te();return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(Rd,X({displayValue:n,onUpdate:r,onChange:o},t)))}var Td=D({component:_d},Sd);const Pd=e=>ce().boolean().test(e),kd=e=>{if(typeof e!="boolean")throw Error("Invalid boolean");return e};var Ad=Object.freeze({__proto__:null,schema:Pd,sanitize:kd});const Dd=A("div",{position:"relative",$flex:"",height:"$rowHeight",input:{$reset:"",height:0,width:0,opacity:0,margin:0},label:{position:"relative",$flexCenter:"",userSelect:"none",cursor:"pointer",height:"$checkboxSize",width:"$checkboxSize",backgroundColor:"$elevation3",borderRadius:"$sm",$hover:""},"input:focus + label":{$focusStyle:""},"input:focus:checked + label, input:checked + label:hover":{$hoverStyle:"$accent3"},"input + label:active":{backgroundColor:"$accent1"},"input:checked + label:active":{backgroundColor:"$accent1"},"label > svg":{display:"none",width:"90%",height:"90%",stroke:"$highlight3"},"input:checked + label":{backgroundColor:"$accent2"},"input:checked + label > svg":{display:"block"}});function Id({value:e,onUpdate:t,id:n,disabled:r}){return g.createElement(Dd,null,g.createElement("input",{id:n,type:"checkbox",checked:e,onChange:o=>t(o.currentTarget.checked),disabled:r}),g.createElement("label",{htmlFor:n},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},g.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))))}function jd(){const{label:e,value:t,onUpdate:n,disabled:r,id:o}=te();return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(Id,{value:t,onUpdate:n,id:o,disabled:r}))}var Md=D({component:jd},Ad);const Ld=["locked"];function Nd({value:e,id:t,valueKey:n,settings:r,onUpdate:o,innerLabelTrim:i}){const s=d.useRef(e[n]);s.current=e[n];const a=d.useCallback(l=>o({[n]:ps({type:"NUMBER",value:s.current,settings:r},l)}),[o,r,n]),c=Ps({type:"NUMBER",value:e[n],settings:r,setValue:a});return g.createElement(js,{id:t,label:n,value:e[n],displayValue:c.displayValue,onUpdate:c.onUpdate,onChange:c.onChange,settings:r,innerLabelTrim:i})}const Fd=A("div",{display:"grid",columnGap:"$colGap",gridAutoFlow:"column dense",alignItems:"center",variants:{withLock:{true:{gridTemplateColumns:"10px auto","> svg":{cursor:"pointer"}}}}});function zd(e){let{locked:t}=e,n=U(e,Ld);return g.createElement("svg",X({width:"10",height:"10",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),t?g.createElement("path",{d:"M5 4.63601C5 3.76031 5.24219 3.1054 5.64323 2.67357C6.03934 2.24705 6.64582 1.9783 7.5014 1.9783C8.35745 1.9783 8.96306 2.24652 9.35823 2.67208C9.75838 3.10299 10 3.75708 10 4.63325V5.99999H5V4.63601ZM4 5.99999V4.63601C4 3.58148 4.29339 2.65754 4.91049 1.99307C5.53252 1.32329 6.42675 0.978302 7.5014 0.978302C8.57583 0.978302 9.46952 1.32233 10.091 1.99162C10.7076 2.65557 11 3.57896 11 4.63325V5.99999H12C12.5523 5.99999 13 6.44771 13 6.99999V13C13 13.5523 12.5523 14 12 14H3C2.44772 14 2 13.5523 2 13V6.99999C2 6.44771 2.44772 5.99999 3 5.99999H4ZM3 6.99999H12V13H3V6.99999Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}):g.createElement("path",{d:"M9 3.63601C9 2.76044 9.24207 2.11211 9.64154 1.68623C10.0366 1.26502 10.6432 1 11.5014 1C12.4485 1 13.0839 1.30552 13.4722 1.80636C13.8031 2.23312 14 2.84313 14 3.63325H15C15 2.68242 14.7626 1.83856 14.2625 1.19361C13.6389 0.38943 12.6743 0 11.5014 0C10.4294 0 9.53523 0.337871 8.91218 1.0021C8.29351 1.66167 8 2.58135 8 3.63601V6H1C0.447715 6 0 6.44772 0 7V13C0 13.5523 0.447715 14 1 14H10C10.5523 14 11 13.5523 11 13V7C11 6.44772 10.5523 6 10 6H9V3.63601ZM1 7H10V13H1V7Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}function jr({value:e,onUpdate:t,settings:n,innerLabelTrim:r}){const{id:o,setSettings:i}=te(),{lock:s,locked:a}=n;return g.createElement(Fd,{withLock:s},s&&g.createElement(zd,{locked:a,onClick:()=>i({locked:!a})}),Object.keys(e).map((c,l)=>g.createElement(Nd,{id:l===0?o:`${o}.${c}`,key:c,valueKey:c,value:e,settings:n[c],onUpdate:t,innerLabelTrim:r})))}const Ms=(e,t)=>{const n={};let r=0,o=1/0;Object.entries(e).forEach(([i,s])=>{n[i]=bs(D({value:s},t[i])).settings,r=Math.max(r,n[i].step),o=Math.min(o,n[i].pad)});for(let i in n){const{step:s,min:a,max:c}=t[i]||{};!isFinite(s)&&(!isFinite(a)||!isFinite(c))&&(n[i].step=r,n[i].pad=o)}return n},Bd=["lock"],Wd=["value"];function Hd(e){const t=ce().array().length(e).every.number(),n=r=>{if(!r||typeof r!="object")return!1;const o=Object.values(r);return o.length===e&&o.every(i=>isFinite(i))};return r=>t.test(r)||n(r)}function Vd(e){return Array.isArray(e)?"array":"object"}function Ot(e,t,n){return Vd(e)===t?e:t==="array"?Object.values(e):xf(e,n)}const Ud=(e,t,n)=>{const r=Ot(e,"object",t.keys);for(let s in r)r[s]=ms(r[s],t[s]);const o=Object.keys(r);let i={};if(o.length===t.keys.length)i=r;else{const s=Ot(n,"object",t.keys);if(o.length===1&&t.locked){const a=o[0],c=r[a],l=s[a],u=l!==0?c/l:1;for(let f in s)f===a?i[a]=c:i[f]=s[f]*u}else i=D(D({},s),r)}return Ot(i,t.format,t.keys)},Kd=(e,t)=>Ot(e,"object",t.keys),Gd=e=>!!e&&("step"in e||"min"in e||"max"in e);function Yd(e,t,n=[]){const{lock:r=!1}=t,o=U(t,Bd),i=Array.isArray(e)?"array":"object",s=i==="object"?Object.keys(e):n,a=Ot(e,"object",s),c=Gd(o)?s.reduce((u,f)=>Object.assign(u,{[f]:o}),{}):o,l=Ms(a,c);return{value:i==="array"?e:a,settings:D(D({},l),{},{format:i,keys:s,lock:r,locked:!1})}}function Ls(e){return{schema:Hd(e.length),normalize:t=>{let{value:n}=t,r=U(t,Wd);return Yd(n,r,e)},format:(t,n)=>Kd(t,n),sanitize:(t,n,r)=>Ud(t,n,r)}}var qd={grad:.9,turn:360,rad:360/(2*Math.PI)},Oe=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},Z=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},pe=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Ns=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},Ao=function(e){return{r:pe(e.r,0,255),g:pe(e.g,0,255),b:pe(e.b,0,255),a:pe(e.a)}},Bn=function(e){return{r:Z(e.r),g:Z(e.g),b:Z(e.b),a:Z(e.a,3)}},Xd=/^#([0-9a-f]{3,8})$/i,qt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Fs=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,i=Math.max(t,n,r),s=i-Math.min(t,n,r),a=s?i===t?(n-r)/s:i===n?2+(r-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:i?s/i*100:0,v:i/255*100,a:o}},zs=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;t=t/360*6,n/=100,r/=100;var i=Math.floor(t),s=r*(1-n),a=r*(1-(t-i)*n),c=r*(1-(1-t+i)*n),l=i%6;return{r:255*[r,a,s,s,c,r][l],g:255*[c,r,r,a,s,s][l],b:255*[s,s,c,r,r,a][l],a:o}},Do=function(e){return{h:Ns(e.h),s:pe(e.s,0,100),l:pe(e.l,0,100),a:pe(e.a)}},Io=function(e){return{h:Z(e.h),s:Z(e.s),l:Z(e.l),a:Z(e.a,3)}},jo=function(e){return zs((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},Rt=function(e){return{h:(t=Fs(e)).h,s:(o=(200-(n=t.s))*(r=t.v)/100)>0&&o<200?n*r/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,n,r,o},Jd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zd=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qd=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ep=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lr={string:[[function(e){var t=Xd.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Z(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?Z(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Qd.exec(e)||ep.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:Ao({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=Jd.exec(e)||Zd.exec(e);if(!t)return null;var n,r,o=Do({h:(n=t[1],r=t[2],r===void 0&&(r="deg"),Number(n)*(qd[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return jo(o)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,r=e.b,o=e.a,i=o===void 0?1:o;return Oe(t)&&Oe(n)&&Oe(r)?Ao({r:Number(t),g:Number(n),b:Number(r),a:Number(i)}):null},"rgb"],[function(e){var t=e.h,n=e.s,r=e.l,o=e.a,i=o===void 0?1:o;if(!Oe(t)||!Oe(n)||!Oe(r))return null;var s=Do({h:Number(t),s:Number(n),l:Number(r),a:Number(i)});return jo(s)},"hsl"],[function(e){var t=e.h,n=e.s,r=e.v,o=e.a,i=o===void 0?1:o;if(!Oe(t)||!Oe(n)||!Oe(r))return null;var s=function(a){return{h:Ns(a.h),s:pe(a.s,0,100),v:pe(a.v,0,100),a:pe(a.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(i)});return zs(s)},"hsv"]]},Mo=function(e,t){for(var n=0;n=.5},e.prototype.toHex=function(){return t=Bn(this.rgba),n=t.r,r=t.g,o=t.b,s=(i=t.a)<1?qt(Z(255*i)):"","#"+qt(n)+qt(r)+qt(o)+s;var t,n,r,o,i,s},e.prototype.toRgb=function(){return Bn(this.rgba)},e.prototype.toRgbString=function(){return t=Bn(this.rgba),n=t.r,r=t.g,o=t.b,(i=t.a)<1?"rgba("+n+", "+r+", "+o+", "+i+")":"rgb("+n+", "+r+", "+o+")";var t,n,r,o,i},e.prototype.toHsl=function(){return Io(Rt(this.rgba))},e.prototype.toHslString=function(){return t=Io(Rt(this.rgba)),n=t.h,r=t.s,o=t.l,(i=t.a)<1?"hsla("+n+", "+r+"%, "+o+"%, "+i+")":"hsl("+n+", "+r+"%, "+o+"%)";var t,n,r,o,i},e.prototype.toHsv=function(){return t=Fs(this.rgba),{h:Z(t.h),s:Z(t.s),v:Z(t.v),a:Z(t.a,3)};var t},e.prototype.invert=function(){return re({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),re(Wn(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),re(Wn(this.rgba,-t))},e.prototype.grayscale=function(){return re(Wn(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),re(Lo(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),re(Lo(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?re({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):Z(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=Rt(this.rgba);return typeof t=="number"?re({h:t,s:n.s,l:n.l,a:n.a}):Z(n.h)},e.prototype.isEqual=function(t){return this.toHex()===re(t).toHex()},e}(),re=function(e){return e instanceof ur?e:new ur(e)},No=[],np=function(e){e.forEach(function(t){No.indexOf(t)<0&&(t(ur,lr),No.push(t))})};function rp(e,t){var n={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var o in n)r[n[o]]=o;var i={};e.prototype.toName=function(s){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,c,l=r[this.toHex()];if(l)return l;if(s!=null&&s.closest){var u=this.toRgb(),f=1/0,p="black";if(!i.length)for(var h in n)i[h]=new e(n[h]).toRgb();for(var m in n){var b=(a=u,c=i[m],Math.pow(a.r-c.r,2)+Math.pow(a.g-c.g,2)+Math.pow(a.b-c.b,2));b=0||(o[n]=e[n]);return o}function fr(e){var t=d.useRef(e),n=d.useRef(function(r){t.current&&t.current(r)});return t.current=e,n.current}var lt=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e0:y.buttons>0)&&o.current?i(Fo(o.current,y,a.current)):b(!1)},m=function(){return b(!1)};function b(y){var v=c.current,w=dr(o.current),x=y?w.addEventListener:w.removeEventListener;x(v?"touchmove":"mousemove",h),x(v?"touchend":"mouseup",m)}return[function(y){var v=y.nativeEvent,w=o.current;if(w&&(zo(v),!function($,C){return C&&!_t($)}(v,c.current)&&w)){if(_t(v)){c.current=!0;var x=v.changedTouches||[];x.length&&(a.current=x[0].identifier)}w.focus(),i(Fo(w,v,a.current)),b(!0)}},function(y){var v=y.which||y.keyCode;v<37||v>40||(y.preventDefault(),s({left:v===39?.05:v===37?-.05:0,top:v===40?.05:v===38?-.05:0}))},b]},[s,i]),u=l[0],f=l[1],p=l[2];return d.useEffect(function(){return p},[p]),g.createElement("div",ht({},r,{onTouchStart:u,onMouseDown:u,className:"react-colorful__interactive",ref:o,onKeyDown:f,tabIndex:0,role:"slider"}))}),Nt=function(e){return e.filter(Boolean).join(" ")},Nr=function(e){var t=e.color,n=e.left,r=e.top,o=r===void 0?.5:r,i=Nt(["react-colorful__pointer",e.className]);return g.createElement("div",{className:i,style:{top:100*o+"%",left:100*n+"%"}},g.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},oe=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n},Ws=function(e){var t=e.s,n=e.v,r=e.a,o=(200-t)*n/100;return{h:oe(e.h),s:oe(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:oe(o/2),a:oe(r,2)}},pr=function(e){var t=Ws(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},Vn=function(e){var t=Ws(e);return"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},Hs=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;t=t/360*6,n/=100,r/=100;var i=Math.floor(t),s=r*(1-n),a=r*(1-(t-i)*n),c=r*(1-(1-t+i)*n),l=i%6;return{r:oe(255*[r,a,s,s,c,r][l]),g:oe(255*[c,r,r,a,s,s][l]),b:oe(255*[s,s,c,r,r,a][l]),a:oe(o,2)}},Vs=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,i=Math.max(t,n,r),s=i-Math.min(t,n,r),a=s?i===t?(n-r)/s:i===n?2+(r-t)/s:4+(t-n)/s:0;return{h:oe(60*(a<0?a+6:a)),s:oe(i?s/i*100:0),v:oe(i/255*100),a:o}},Us=g.memo(function(e){var t=e.hue,n=e.onChange,r=Nt(["react-colorful__hue",e.className]);return g.createElement("div",{className:r},g.createElement(Lr,{onMove:function(o){n({h:360*o.left})},onKey:function(o){n({h:lt(t+360*o.left,0,360)})},"aria-label":"Hue","aria-valuenow":oe(t),"aria-valuemax":"360","aria-valuemin":"0"},g.createElement(Nr,{className:"react-colorful__hue-pointer",left:t/360,color:pr({h:t,s:100,v:100,a:1})})))}),Ks=g.memo(function(e){var t=e.hsva,n=e.onChange,r={backgroundColor:pr({h:t.h,s:100,v:100,a:1})};return g.createElement("div",{className:"react-colorful__saturation",style:r},g.createElement(Lr,{onMove:function(o){n({s:100*o.left,v:100-100*o.top})},onKey:function(o){n({s:lt(t.s+100*o.left,0,100),v:lt(t.v-100*o.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+oe(t.s)+"%, Brightness "+oe(t.v)+"%"},g.createElement(Nr,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:pr(t)})))}),Fr=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0};function Gs(e,t,n){var r=fr(n),o=d.useState(function(){return e.toHsva(t)}),i=o[0],s=o[1],a=d.useRef({color:t,hsva:i});d.useEffect(function(){if(!e.equal(t,a.current.color)){var l=e.toHsva(t);a.current={hsva:l,color:t},s(l)}},[t,e]),d.useEffect(function(){var l;Fr(i,a.current.hsva)||e.equal(l=e.fromHsva(i),a.current.color)||(a.current={hsva:i,color:l},r(l))},[i,e,r]);var c=d.useCallback(function(l){s(function(u){return Object.assign({},u,l)})},[]);return[i,c]}var op=typeof window<"u"?d.useLayoutEffect:d.useEffect,ip=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},Bo=new Map,Ys=function(e){op(function(){var t=e.current?e.current.ownerDocument:document;if(t!==void 0&&!Bo.has(t)){var n=t.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,Bo.set(t,n);var r=ip();r&&n.setAttribute("nonce",r),t.head.appendChild(n)}},[])},sp=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,i=e.onChange,s=Mr(e,["className","colorModel","color","onChange"]),a=d.useRef(null);Ys(a);var c=Gs(n,o,i),l=c[0],u=c[1],f=Nt(["react-colorful",t]);return g.createElement("div",ht({},s,{ref:a,className:f}),g.createElement(Ks,{hsva:l,onChange:u}),g.createElement(Us,{hue:l.h,onChange:u,className:"react-colorful__last-control"}))},ap=function(e){var t=e.className,n=e.hsva,r=e.onChange,o={backgroundImage:"linear-gradient(90deg, "+Vn(Object.assign({},n,{a:0}))+", "+Vn(Object.assign({},n,{a:1}))+")"},i=Nt(["react-colorful__alpha",t]),s=oe(100*n.a);return g.createElement("div",{className:i},g.createElement("div",{className:"react-colorful__alpha-gradient",style:o}),g.createElement(Lr,{onMove:function(a){r({a:a.left})},onKey:function(a){r({a:lt(n.a+a.left)})},"aria-label":"Alpha","aria-valuetext":s+"%","aria-valuenow":s,"aria-valuemin":"0","aria-valuemax":"100"},g.createElement(Nr,{className:"react-colorful__alpha-pointer",left:n.a,color:Vn(n)})))},cp=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,i=e.onChange,s=Mr(e,["className","colorModel","color","onChange"]),a=d.useRef(null);Ys(a);var c=Gs(n,o,i),l=c[0],u=c[1],f=Nt(["react-colorful",t]);return g.createElement("div",ht({},s,{ref:a,className:f}),g.createElement(Ks,{hsva:l,onChange:u}),g.createElement(Us,{hue:l.h,onChange:u}),g.createElement(ap,{hsva:l,onChange:u,className:"react-colorful__last-control"}))},lp={defaultColor:{r:0,g:0,b:0,a:1},toHsva:Vs,fromHsva:Hs,equal:Fr},up=function(e){return g.createElement(cp,ht({},e,{colorModel:lp}))},fp={defaultColor:{r:0,g:0,b:0},toHsva:function(e){return Vs({r:e.r,g:e.g,b:e.b,a:1})},fromHsva:function(e){return{r:(t=Hs(e)).r,g:t.g,b:t.b};var t},equal:Fr},dp=function(e){return g.createElement(sp,ht({},e,{colorModel:fp}))};function gt(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(u){try{l(r.next(u))}catch(f){s(f)}}function c(u){try{l(r.throw(u))}catch(f){s(f)}}function l(u){u.done?i(u.value):o(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})}function mt(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(n=0)),n;)try{if(r=1,o&&(i=l[0]&2?o.return:l[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,l[1])).done)return i;switch(o=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,o=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function hp(){for(var e=[],t=0;t0?r:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function mp(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var r=t.split(".").pop().toLowerCase(),o=gp.get(r);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var bp=[".DS_Store","Thumbs.db"];function vp(e){return gt(this,void 0,void 0,function(){return mt(this,function(t){return un(e)&&yp(e)?[2,$p(e.dataTransfer,e.type)]:wp(e)?[2,xp(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,Ep(e)]:[2,[]]})})}function yp(e){return un(e.dataTransfer)}function wp(e){return un(e)&&un(e.target)}function un(e){return typeof e=="object"&&e!==null}function xp(e){return hr(e.target.files).map(function(t){return Ft(t)})}function Ep(e){return gt(this,void 0,void 0,function(){var t;return mt(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(r){return r.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(r){return Ft(r)})]}})})}function $p(e,t){return gt(this,void 0,void 0,function(){var n,r;return mt(this,function(o){switch(o.label){case 0:return e===null?[2,[]]:e.items?(n=hr(e.items).filter(function(i){return i.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(Sp))]):[3,2];case 1:return r=o.sent(),[2,Wo(qs(r))];case 2:return[2,Wo(hr(e.files).map(function(i){return Ft(i)}))]}})})}function Wo(e){return e.filter(function(t){return bp.indexOf(t.name)===-1})}function hr(e){if(e===null)return[];for(var t=[],n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);nn)return[!1,Yo(n)];if(e.sizen)return[!1,Yo(n)]}return[!0,null]}function St(e){return e!=null}function Np(e){var t=e.files,n=e.accept,r=e.minSize,o=e.maxSize,i=e.multiple,s=e.maxFiles;return!i&&t.length>1||i&&s>=1&&t.length>s?!1:t.every(function(a){var c=Zs(a,n),l=Ko(c,1),u=l[0],f=Qs(a,r,o),p=Ko(f,1),h=p[0];return u&&h})}function fn(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Xt(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Xo(e){e.preventDefault()}function Fp(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function zp(e){return e.indexOf("Edge/")!==-1}function Bp(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Fp(e)||zp(e)}function xe(){for(var e=arguments.length,t=new Array(e),n=0;n1?o-1:0),s=1;se.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function rh(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i=0)&&(n[o]=e[o]);return n}var zr=d.forwardRef(function(e,t){var n=e.children,r=dn(e,Kp),o=na(r),i=o.open,s=dn(o,Gp);return d.useImperativeHandle(t,function(){return{open:i}},[i]),g.createElement(d.Fragment,null,n(G(G({},s),{},{open:i})))});zr.displayName="Dropzone";var ta={disabled:!1,getFilesFromEvent:vp,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0};zr.defaultProps=ta;zr.propTypes={children:K.func,accept:K.oneOfType([K.string,K.arrayOf(K.string)]),multiple:K.bool,preventDropOnDocument:K.bool,noClick:K.bool,noKeyboard:K.bool,noDrag:K.bool,noDragEventsBubbling:K.bool,minSize:K.number,maxSize:K.number,maxFiles:K.number,disabled:K.bool,getFilesFromEvent:K.func,onFileDialogCancel:K.func,onFileDialogOpen:K.func,useFsAccessApi:K.bool,onDragEnter:K.func,onDragLeave:K.func,onDragOver:K.func,onDrop:K.func,onDropAccepted:K.func,onDropRejected:K.func,validator:K.func};var br={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,draggedFiles:[],acceptedFiles:[],fileRejections:[]};function na(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=G(G({},ta),e),n=t.accept,r=t.disabled,o=t.getFilesFromEvent,i=t.maxSize,s=t.minSize,a=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,f=t.onDragOver,p=t.onDrop,h=t.onDropAccepted,m=t.onDropRejected,b=t.onFileDialogCancel,y=t.onFileDialogOpen,v=t.useFsAccessApi,w=t.preventDropOnDocument,x=t.noClick,$=t.noKeyboard,C=t.noDrag,E=t.noDragEventsBubbling,S=t.validator,k=d.useMemo(function(){return typeof y=="function"?y:Zo},[y]),z=d.useMemo(function(){return typeof b=="function"?b:Zo},[b]),R=d.useRef(null),T=d.useRef(null),P=d.useReducer(oh,br),I=Un(P,2),j=I[0],L=I[1],B=j.isFocused,W=j.isFileDialogActive,M=j.draggedFiles,H=d.useRef(typeof window<"u"&&window.isSecureContext&&v&&Wp()),J=function(){!H.current&&W&&setTimeout(function(){if(T.current){var N=T.current.files;N.length||(L({type:"closeDialog"}),z())}},300)};d.useEffect(function(){return window.addEventListener("focus",J,!1),function(){window.removeEventListener("focus",J,!1)}},[T,W,z,H]);var ie=d.useRef([]),zt=function(N){R.current&&R.current.contains(N.target)||(N.preventDefault(),ie.current=[])};d.useEffect(function(){return w&&(document.addEventListener("dragover",Xo,!1),document.addEventListener("drop",zt,!1)),function(){w&&(document.removeEventListener("dragover",Xo),document.removeEventListener("drop",zt))}},[R,w]);var Bt=d.useCallback(function(O){O.preventDefault(),O.persist(),Ze(O),ie.current=[].concat(Xp(ie.current),[O.target]),Xt(O)&&Promise.resolve(o(O)).then(function(N){fn(O)&&!E||(L({draggedFiles:N,isDragActive:!0,type:"setDraggedFiles"}),l&&l(O))})},[o,l,E]),Wt=d.useCallback(function(O){O.preventDefault(),O.persist(),Ze(O);var N=Xt(O);if(N&&O.dataTransfer)try{O.dataTransfer.dropEffect="copy"}catch{}return N&&f&&f(O),!1},[f,E]),Ht=d.useCallback(function(O){O.preventDefault(),O.persist(),Ze(O);var N=ie.current.filter(function(se){return R.current&&R.current.contains(se)}),Q=N.indexOf(O.target);Q!==-1&&N.splice(Q,1),ie.current=N,!(N.length>0)&&(L({isDragActive:!1,type:"setDraggedFiles",draggedFiles:[]}),Xt(O)&&u&&u(O))},[R,u,E]),qe=d.useCallback(function(O,N){var Q=[],se=[];O.forEach(function(ge){var xt=Zs(ge,n),et=Un(xt,2),_n=et[0],Tn=et[1],Pn=Qs(ge,s,i),Vt=Un(Pn,2),kn=Vt[0],An=Vt[1],Dn=S?S(ge):null;if(_n&&kn&&!Dn)Q.push(ge);else{var In=[Tn,An];Dn&&(In=In.concat(Dn)),se.push({file:ge,errors:In.filter(function(ma){return ma})})}}),(!a&&Q.length>1||a&&c>=1&&Q.length>c)&&(Q.forEach(function(ge){se.push({file:ge,errors:[Lp]})}),Q.splice(0)),L({acceptedFiles:Q,fileRejections:se,type:"setFiles"}),p&&p(Q,se,N),se.length>0&&m&&m(se,N),Q.length>0&&h&&h(Q,N)},[L,a,n,s,i,c,p,h,m,S]),Be=d.useCallback(function(O){O.preventDefault(),O.persist(),Ze(O),ie.current=[],Xt(O)&&Promise.resolve(o(O)).then(function(N){fn(O)&&!E||qe(N,O)}),L({type:"reset"})},[o,qe,E]),Ce=d.useCallback(function(){if(H.current){L({type:"openDialog"}),k();var O={multiple:a,types:Hp(n)};window.showOpenFilePicker(O).then(function(N){return o(N)}).then(function(N){qe(N,null),L({type:"closeDialog"})}).catch(function(N){Vp(N)?(z(N),L({type:"closeDialog"})):Up(N)&&(H.current=!1,T.current&&(T.current.value=null,T.current.click()))});return}T.current&&(L({type:"openDialog"}),k(),T.current.value=null,T.current.click())},[L,k,z,v,qe,n,a]),bt=d.useCallback(function(O){!R.current||!R.current.isEqualNode(O.target)||(O.key===" "||O.key==="Enter"||O.keyCode===32||O.keyCode===13)&&(O.preventDefault(),Ce())},[R,Ce]),vt=d.useCallback(function(){L({type:"focus"})},[]),yt=d.useCallback(function(){L({type:"blur"})},[]),wt=d.useCallback(function(){x||(Bp()?setTimeout(Ce,0):Ce())},[x,Ce]),fe=function(N){return r?null:N},Xe=function(N){return $?null:fe(N)},Je=function(N){return C?null:fe(N)},Ze=function(N){E&&N.stopPropagation()},On=d.useMemo(function(){return function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},N=O.refKey,Q=N===void 0?"ref":N,se=O.role,ge=O.onKeyDown,xt=O.onFocus,et=O.onBlur,_n=O.onClick,Tn=O.onDragEnter,Pn=O.onDragOver,Vt=O.onDragLeave,kn=O.onDrop,An=dn(O,Yp);return G(G(mr({onKeyDown:Xe(xe(ge,bt)),onFocus:Xe(xe(xt,vt)),onBlur:Xe(xe(et,yt)),onClick:fe(xe(_n,wt)),onDragEnter:Je(xe(Tn,Bt)),onDragOver:Je(xe(Pn,Wt)),onDragLeave:Je(xe(Vt,Ht)),onDrop:Je(xe(kn,Be)),role:typeof se=="string"&&se!==""?se:"button"},Q,R),!r&&!$?{tabIndex:0}:{}),An)}},[R,bt,vt,yt,wt,Bt,Wt,Ht,Be,$,C,r]),Rn=d.useCallback(function(O){O.stopPropagation()},[]),Qe=d.useMemo(function(){return function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},N=O.refKey,Q=N===void 0?"ref":N,se=O.onChange,ge=O.onClick,xt=dn(O,qp),et=mr({accept:n,multiple:a,type:"file",style:{display:"none"},onChange:fe(xe(se,Be)),onClick:fe(xe(ge,Rn)),tabIndex:-1},Q,T);return G(G({},et),xt)}},[T,n,a,Be,r]),Hr=M.length,Vr=Hr>0&&Np({files:M,accept:n,minSize:s,maxSize:i,multiple:a,maxFiles:c}),ga=Hr>0&&!Vr;return G(G({},j),{},{isDragAccept:Vr,isDragReject:ga,isFocused:B&&!r,getRootProps:On,getInputProps:Qe,rootRef:R,inputRef:T,open:fe(Ce)})}function oh(e,t){switch(t.type){case"focus":return G(G({},e),{},{isFocused:!0});case"blur":return G(G({},e),{},{isFocused:!1});case"openDialog":return G(G({},br),{},{isFileDialogActive:!0});case"closeDialog":return G(G({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":var n=t.isDragActive,r=t.draggedFiles;return G(G({},e),{},{draggedFiles:r,isDragActive:n});case"setFiles":return G(G({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return G({},br);default:return e}}function Zo(){}/*! + * isobject + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */var ih=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1};/*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */var sh=ih;function Qo(e){return sh(e)===!0&&Object.prototype.toString.call(e)==="[object Object]"}var ra=function(t){var n,r;return!(Qo(t)===!1||(n=t.constructor,typeof n!="function")||(r=n.prototype,Qo(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)};/*! + * is-extendable + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */var ah=ra,Br=function(t){return ah(t)||typeof t=="function"||Array.isArray(t)};/*! + * for-in + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */var ch=function(t,n,r){for(var o in t)if(n.call(r,t[o],o,t)===!1)break},lh=Br,uh=ch;function oa(e,t){for(var n=arguments.length,r=0;++r + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */var hh=function(e,t,n,r,o){if(!gh(e)||!t)return e;if(t=Jt(t),n&&(t+="."+Jt(n)),r&&(t+="."+Jt(r)),o&&(t+="."+Jt(o)),t in e)return e[t];for(var i=t.split("."),s=i.length,a=-1;e&&++a + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */var mh=function(e,t){if(e===null||typeof e>"u")throw new TypeError("expected first argument to be an object.");if(typeof t>"u"||typeof Symbol>"u"||typeof Object.getOwnPropertySymbols!="function")return e;for(var n=Object.prototype.propertyIsEnumerable,r=Object(e),o=arguments.length,i=0;++i"u")throw new TypeError("Cannot convert undefined or null to object");ei(e)||(e={});for(var t=1;t + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */var Sh=yh,Ch=function(e,t,n){if(typeof e!="string")throw new TypeError("expected a string");typeof t=="function"&&(n=t,t=null),typeof t=="string"&&(t={sep:t});var r=Sh({sep:"."},t),o=r.quotes||['"',"'","`"],i;r.brackets===!0?i={"<":">","(":")","[":"]","{":"}"}:r.brackets&&(i=r.brackets);var s=[],a=[],c=[""],l=r.sep,u=e.length,f=-1,p;function h(){if(i&&a.length)return i[a[a.length-1]]}for(;++f + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */var _h=function(t){return typeof t<"u"&&t!==null&&(typeof t=="object"||typeof t=="function")},ti=_h,Th=function(t){ti(t)||(t={});for(var n=arguments.length,r=1;r + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */var Ah=function(t){return typeof t<"u"&&t!==null&&(typeof t=="object"||typeof t=="function")};/*! + * set-value + * + * Copyright (c) 2014-2015, 2017, Jon Schlinkert. + * Released under the MIT License. + */var Dh=Ch,Ih=Th,ni=ra,ri=Ah,jh=function(e,t,n){if(!ri(e)||(Array.isArray(t)&&(t=[].concat.apply([],t).join(".")),typeof t!="string"))return e;for(var r=Dh(t,{sep:".",brackets:!0}).filter(Mh),o=r.length,i=-1,s=e;++ie.filter(Boolean).join(".");function zh(e){const t=e.split(".");return[t.pop(),t.join(".")||void 0]}function Bh(e,t){return Object.entries(yf(e,t)).reduce((n,[,{value:r,disabled:o,key:i}])=>(n[i]=o?void 0:r,n),{})}function Wh(e,t){const n=d.useRef();return Tt(e,n.current)||(n.current=e),n.current}function ia(e,t){return d.useMemo(e,Wh(t))}function Hh(e){const t=d.useRef(null),n=d.useRef(null),r=d.useRef(!0);return d.useLayoutEffect(()=>{e||(t.current.style.height="0px",t.current.style.overflow="hidden")},[]),d.useEffect(()=>{if(r.current){r.current=!1;return}let o;const i=t.current,s=()=>{e&&(i.style.removeProperty("height"),i.style.removeProperty("overflow"),n.current.scrollIntoView({behavior:"smooth",block:"nearest"}))};i.addEventListener("transitionend",s,{once:!0});const{height:a}=n.current.getBoundingClientRect();return i.style.height=a+"px",e||(i.style.overflow="hidden",o=window.setTimeout(()=>i.style.height="0px",50)),()=>{i.removeEventListener("transitionend",s),clearTimeout(o)}},[e]),{wrapperRef:t,contentRef:n}}const Vh=e=>{const[t,n]=d.useState(e.getVisiblePaths());return d.useEffect(()=>{n(e.getVisiblePaths());const r=e.useStore.subscribe(e.getVisiblePaths,n,{equalityFn:bn});return()=>r()},[e]),t};function Uh(e,t,n){return e.useStore(o=>{const i=D(D({},n),o.data);return Bh(i,t)},bn)}function sa(e=3){const t=d.useRef(null),n=d.useRef(null),[r,o]=d.useState(!1),i=d.useCallback(()=>o(!0),[]),s=d.useCallback(()=>o(!1),[]);return d.useLayoutEffect(()=>{if(r){const{bottom:a,top:c,left:l}=t.current.getBoundingClientRect(),{height:u}=n.current.getBoundingClientRect(),f=a+u>window.innerHeight-40?"up":"down";n.current.style.position="fixed",n.current.style.zIndex="10000",n.current.style.left=l+"px",f==="down"?n.current.style.top=a+e+"px":n.current.style.bottom=window.innerHeight-c+e+"px"}},[e,r]),{popinRef:t,wrapperRef:n,shown:r,show:i,hide:s}}np([rp]);const Kh={rgb:"toRgb",hsl:"toHsl",hsv:"toHsv",hex:"toHex"};ce.extend({color:()=>e=>re(e).isValid()});const Gh=e=>ce().color().test(e);function aa(e,{format:t,hasAlpha:n,isString:r}){const o=Kh[t]+(r&&t!=="hex"?"String":""),i=e[o]();return typeof i=="object"&&!n?wf(i,["a"]):i}const ca=(e,t)=>{const n=re(e);if(!n.isValid())throw Error("Invalid color");return aa(n,t)},Yh=(e,t)=>aa(re(e),D(D({},t),{},{isString:!0,format:"hex"})),qh=({value:e})=>{const t=tp(e),n=t==="name"?"hex":t,r=typeof e=="object"?"a"in e:t==="hex"&&e.length===8||/^(rgba)|(hsla)|(hsva)/.test(e),o={format:n,hasAlpha:r,isString:typeof e=="string"};return{value:ca(e,o),settings:o}};var Xh=Object.freeze({__proto__:null,schema:Gh,sanitize:ca,format:Yh,normalize:qh});const Jh=A("div",{position:"relative",boxSizing:"border-box",borderRadius:"$sm",overflow:"hidden",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",backgroundColor:"#fff",backgroundImage:`url('data:image/svg+xml;charset=utf-8,')`,$inputStyle:"",$hover:"",zIndex:1,variants:{active:{true:{$inputStyle:"$accent1"}}},"&::before":{content:'""',position:"absolute",top:0,bottom:0,right:0,left:0,backgroundColor:"currentColor",zIndex:1}}),Zh=A("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto",columnGap:"$colGap",alignItems:"center"}),Qh=A("div",{width:"$colorPickerWidth",height:"$colorPickerHeight",".react-colorful":{width:"100%",height:"100%",boxShadow:"$level2",cursor:"crosshair"},".react-colorful__saturation":{borderRadius:"$sm $sm 0 0"},".react-colorful__alpha, .react-colorful__hue":{height:10},".react-colorful__last-control":{borderRadius:"0 0 $sm $sm"},".react-colorful__pointer":{height:12,width:12}});function si(e,t){return t!=="rgb"?re(e).toRgb():e}function eg({value:e,displayValue:t,settings:n,onUpdate:r}){const{emitOnEditStart:o,emitOnEditEnd:i}=te(),{format:s,hasAlpha:a}=n,{popinRef:c,wrapperRef:l,shown:u,show:f,hide:p}=sa(),h=d.useRef(0),[m,b]=d.useState(()=>si(e,s)),y=a?up:dp,v=()=>{b(si(e,s)),f(),o()},w=()=>{p(),i(),window.clearTimeout(h.current)},x=()=>{h.current=window.setTimeout(w,500)};return d.useEffect(()=>()=>window.clearTimeout(h.current),[]),g.createElement(g.Fragment,null,g.createElement(Jh,{ref:c,active:u,onClick:()=>v(),style:{color:t}}),u&&g.createElement(Dr,null,g.createElement(Ts,{onPointerUp:w}),g.createElement(Qh,{ref:l,onMouseEnter:()=>window.clearTimeout(h.current),onMouseLeave:$=>$.buttons===0&&x()},g.createElement(y,{color:m,onChange:r}))))}function tg(){const{value:e,displayValue:t,label:n,onChange:r,onUpdate:o,settings:i}=te();return g.createElement(he,{input:!0},g.createElement(we,null,n),g.createElement(Zh,null,g.createElement(eg,{value:e,displayValue:t,onChange:r,onUpdate:o,settings:i}),g.createElement(Ar,{value:t,onChange:r,onUpdate:o})))}var ng=D({component:tg},Xh);function rg(){const{label:e,displayValue:t,onUpdate:n,settings:r}=te();return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(jr,{value:t,settings:r,onUpdate:n}))}var og=D({component:rg},Ls(["x","y","z"]));const ig=A("div",{$flexCenter:"",position:"relative",backgroundColor:"$elevation3",borderRadius:"$sm",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",touchAction:"none",$draggable:"",$hover:"","&:active":{cursor:"none"},"&::after":{content:'""',backgroundColor:"$accent2",height:4,width:4,borderRadius:2}}),sg=A("div",{$flexCenter:"",width:"$joystickWidth",height:"$joystickHeight",borderRadius:"$sm",boxShadow:"$level2",position:"fixed",zIndex:1e4,overflow:"hidden",$draggable:"",transform:"translate(-50%, -50%)",variants:{isOutOfBounds:{true:{backgroundColor:"$elevation1"},false:{backgroundColor:"$elevation3"}}},"> div":{position:"absolute",$flexCenter:"",borderStyle:"solid",borderWidth:1,borderColor:"$highlight1",backgroundColor:"$elevation3",width:"80%",height:"80%","&::after,&::before":{content:'""',position:"absolute",zindex:10,backgroundColor:"$highlight1"},"&::before":{width:"100%",height:1},"&::after":{height:"100%",width:1}},"> span":{position:"relative",zindex:100,width:10,height:10,backgroundColor:"$accent2",borderRadius:"50%"}});function ag({value:e,settings:t,onUpdate:n}){const r=d.useRef(),o=d.useRef(0),i=d.useRef(0),s=d.useRef(1),[a,c]=d.useState(!1),[l,u]=d.useState(!1),[f,p]=ks(),h=d.useRef(null),m=d.useRef(null);d.useLayoutEffect(()=>{if(a){const{top:P,left:I,width:j,height:L}=h.current.getBoundingClientRect();m.current.style.left=I+j/2+"px",m.current.style.top=P+L/2+"px"}},[a]);const{keys:[b,y],joystick:v}=t,w=v==="invertY"?1:-1,{[b]:{step:x},[y]:{step:$}}=t,C=Te("sizes","joystickWidth"),E=Te("sizes","joystickHeight"),S=parseFloat(C)*.8/2,k=parseFloat(E)*.8/2,z=d.useCallback(()=>{r.current||(u(!0),o.current&&p({x:o.current*S}),i.current&&p({y:i.current*-k}),r.current=window.setInterval(()=>{n(P=>{const I=x*o.current*s.current,j=w*$*i.current*s.current;return Array.isArray(P)?{[b]:P[0]+I,[y]:P[1]+j}:{[b]:P[b]+I,[y]:P[y]+j}})},16))},[S,k,n,p,x,$,b,y,w]),R=d.useCallback(()=>{window.clearTimeout(r.current),r.current=void 0,u(!1)},[]);d.useEffect(()=>{function P(I){s.current=gs(I)}return window.addEventListener("keydown",P),window.addEventListener("keyup",P),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",P),window.removeEventListener("keyup",P)}},[]);const T=Lt(({first:P,active:I,delta:[j,L],movement:[B,W]})=>{P&&c(!0);const M=Fe(B,-S,S),H=Fe(W,-k,k);o.current=Math.abs(B)>Math.abs(M)?Math.sign(B-M):0,i.current=Math.abs(W)>Math.abs(H)?Math.sign(H-W):0;let J=e[b],ie=e[y];I?(o.current||(J+=j*x*s.current,p({x:M})),i.current||(ie-=w*L*$*s.current,p({y:H})),o.current||i.current?z():R(),n({[b]:J,[y]:ie})):(c(!1),o.current=0,i.current=0,p({x:0,y:0}),R())});return g.createElement(ig,X({ref:h},T()),a&&g.createElement(Dr,null,g.createElement(sg,{ref:m,isOutOfBounds:l},g.createElement("div",null),g.createElement("span",{ref:f}))))}const cg=A("div",{display:"grid",columnGap:"$colGap",variants:{withJoystick:{true:{gridTemplateColumns:"$sizes$rowHeight auto"},false:{gridTemplateColumns:"auto"}}}});function lg(){const{label:e,displayValue:t,onUpdate:n,settings:r}=te();return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(cg,{withJoystick:!!r.joystick},r.joystick&&g.createElement(ag,{value:t,settings:r,onUpdate:n}),g.createElement(jr,{value:t,settings:r,onUpdate:n})))}const ug=["joystick"],la=Ls(["x","y"]),fg=e=>{let{joystick:t=!0}=e,n=U(e,ug);const{value:r,settings:o}=la.normalize(n);return{value:r,settings:D(D({},o),{},{joystick:t})}};var dg=D(D({component:lg},la),{},{normalize:fg});const pg=e=>{if(e!==void 0){if(e instanceof File)try{return URL.createObjectURL(e)}catch{return}if(typeof e=="string"&&e.indexOf("blob:")===0)return e;throw Error("Invalid image format [undefined | blob | File].")}},hg=(e,t)=>typeof t=="object"&&"image"in t,gg=({image:e})=>({value:e});var mg=Object.freeze({__proto__:null,sanitize:pg,schema:hg,normalize:gg});const bg=A("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto 20px",columnGap:"$colGap",alignItems:"center"}),vg=A("div",{$flexCenter:"",overflow:"hidden",height:"$rowHeight",background:"$elevation3",textAlign:"center",color:"inherit",borderRadius:"$sm",outline:"none",userSelect:"none",cursor:"pointer",$inputStyle:"",$hover:"",$focusWithin:"",$active:"$accent1 $elevation1",variants:{isDragAccept:{true:{$inputStyle:"$accent1",backgroundColor:"$elevation1"}}}}),yg=A("div",{boxSizing:"border-box",borderRadius:"$sm",height:"$rowHeight",width:"$rowHeight",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center",variants:{hasImage:{true:{cursor:"pointer",$hover:"",$active:""}}}}),wg=A("div",{$flexCenter:"",width:"$imagePreviewWidth",height:"$imagePreviewHeight",borderRadius:"$sm",boxShadow:"$level2",pointerEvents:"none",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center"}),xg=A("div",{fontSize:"0.8em",height:"100%",padding:"$rowGap $md"}),Eg=A("div",{$flexCenter:"",top:"0",right:"0",marginRight:"$sm",height:"100%",cursor:"pointer",variants:{disabled:{true:{color:"$elevation3",cursor:"default"}}},"&::after,&::before":{content:'""',position:"absolute",height:2,width:10,borderRadius:1,backgroundColor:"currentColor"},"&::after":{transform:"rotate(45deg)"},"&::before":{transform:"rotate(-45deg)"}});function $g(){const{label:e,value:t,onUpdate:n,disabled:r}=te(),{popinRef:o,wrapperRef:i,shown:s,show:a,hide:c}=sa(),l=d.useCallback(m=>{m.length&&n(m[0])},[n]),u=d.useCallback(m=>{m.stopPropagation(),n(void 0)},[n]),{getRootProps:f,getInputProps:p,isDragAccept:h}=na({maxFiles:1,accept:"image/*",onDrop:l,disabled:r});return g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(bg,null,g.createElement(yg,{ref:o,hasImage:!!t,onPointerDown:()=>!!t&&a(),onPointerUp:c,style:{backgroundImage:t?`url(${t})`:"none"}}),s&&!!t&&g.createElement(Dr,null,g.createElement(Ts,{onPointerUp:c,style:{cursor:"pointer"}}),g.createElement(wg,{ref:i,style:{backgroundImage:`url(${t})`}})),g.createElement(vg,f({isDragAccept:h}),g.createElement("input",p()),g.createElement(xg,null,h?"drop image":"click or drop")),g.createElement(Eg,{onClick:u,disabled:!t})))}var Sg=D({component:$g},mg);const ai=ce().number(),Cg=(e,t)=>ce().array().length(2).every.number().test(e)&&ce().schema({min:ai,max:ai}).test(t),pn=e=>({min:e[0],max:e[1]}),ua=(e,{bounds:[t,n]},r)=>{const o=Array.isArray(e)?pn(e):e,i={min:r[0],max:r[1]},{min:s,max:a}=D(D({},i),o);return[Fe(Number(s),t,Math.max(t,a)),Fe(Number(a),Math.min(n,s),n)]},Og=({value:e,min:t,max:n})=>{const r={min:t,max:n},o=Ms(pn(e),{min:r,max:r}),i=[t,n],s=D(D({},o),{},{bounds:i});return{value:ua(pn(e),s,e),settings:s}};var Rg=Object.freeze({__proto__:null,schema:Cg,format:pn,sanitize:ua,normalize:Og});const _g=["value","bounds","onDrag"],Tg=["bounds"],Pg=A("div",{display:"grid",columnGap:"$colGap",gridTemplateColumns:"auto calc($sizes$numberInputMinWidth * 2 + $space$rowGap)"});function kg(e){let{value:t,bounds:[n,r],onDrag:o}=e,i=U(e,_g);const s=d.useRef(null),a=d.useRef(null),c=d.useRef(null),l=d.useRef(0),u=Te("sizes","scrubberWidth"),f=Lt(({event:m,first:b,xy:[y],movement:[v],memo:w={}})=>{if(b){const{width:$,left:C}=s.current.getBoundingClientRect();l.current=$-parseFloat(u);const E=(m==null?void 0:m.target)===a.current||(m==null?void 0:m.target)===c.current;w.pos=cn((y-C)/$,n,r);const S=Math.abs(w.pos-t.min)-Math.abs(w.pos-t.max);w.key=S<0||S===0&&w.pos<=t.min?"min":"max",E&&(w.pos=t[w.key])}const x=w.pos+cn(v/l.current,0,r-n);return o({[w.key]:cd(x,i[w.key])}),w}),p=`calc(${an(t.min,n,r)} * (100% - ${u} - 8px) + 4px)`,h=`calc(${1-an(t.max,n,r)} * (100% - ${u} - 8px) + 4px)`;return g.createElement(Ds,X({ref:s},f()),g.createElement(As,null,g.createElement(Is,{style:{left:p,right:h}})),g.createElement(ar,{position:"left",ref:a,style:{left:p}}),g.createElement(ar,{position:"right",ref:c,style:{right:h}}))}function Ag(){const{label:e,displayValue:t,onUpdate:n,settings:r}=te(),o=U(r,Tg);return g.createElement(g.Fragment,null,g.createElement(he,{input:!0},g.createElement(we,null,e),g.createElement(Pg,null,g.createElement(kg,X({value:t},r,{onDrag:n})),g.createElement(jr,{value:t,settings:o,onUpdate:n,innerLabelTrim:0}))))}var Dg=D({component:Ag},Rg);const Ig=()=>{const e=new Map;return{on:(t,n)=>{let r=e.get(t);r===void 0&&(r=new Set,e.set(t,r)),r.add(n)},off:(t,n)=>{const r=e.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.delete(t))},emit:(t,...n)=>{const r=e.get(t);if(r!==void 0)for(const o of r)o(...n)}}},jg=["type","value"],Mg=["onChange","transient","onEditStart","onEditEnd"],Lg=function(){const t=Ca(yc(()=>({data:{}}))),n=Ig();this.storeId=vf(),this.useStore=t;const r={},o=new Set;this.getVisiblePaths=()=>{const s=this.getData(),a=Object.keys(s),c=[];Object.entries(r).forEach(([u,f])=>{f.render&&a.some(p=>p.indexOf(u)===0)&&!f.render(this.get)&&c.push(u+".")});const l=[];return o.forEach(u=>{u in s&&s[u].__refCount>0&&c.every(f=>u.indexOf(f)===-1)&&(!s[u].render||s[u].render(this.get))&&l.push(u)}),l},this.setOrderedPaths=s=>{s.forEach(a=>o.add(a))},this.orderPaths=s=>(this.setOrderedPaths(s),s),this.disposePaths=s=>{t.setState(a=>{const c=a.data;return s.forEach(l=>{if(l in c){const u=c[l];u.__refCount--,u.__refCount===0&&u.type in me&&delete c[l]}}),{data:c}})},this.dispose=()=>{t.setState(()=>({data:{}}))},this.getFolderSettings=s=>r[s]||{},this.getData=()=>t.getState().data,this.addData=(s,a)=>{t.setState(c=>{const l=c.data;return Object.entries(s).forEach(([u,f])=>{let p=l[u];if(p){const{type:h,value:m}=f,b=U(f,jg);h!==p.type?_e(Y.INPUT_TYPE_OVERRIDE,h):((p.__refCount===0||a)&&Object.assign(p,b),p.__refCount++)}else l[u]=D(D({},f),{},{__refCount:1})}),{data:l}})},this.setValueAtPath=(s,a,c)=>{t.setState(l=>{const u=l.data;return ko(u[s],a,s,this,c),{data:u}})},this.setSettingsAtPath=(s,a)=>{t.setState(c=>{const l=c.data;return l[s].settings=D(D({},l[s].settings),a),{data:l}})},this.disableInputAtPath=(s,a)=>{t.setState(c=>{const l=c.data;return l[s].disabled=a,{data:l}})},this.set=(s,a)=>{t.setState(c=>{const l=c.data;return Object.entries(s).forEach(([u,f])=>{try{ko(l[u],f,void 0,void 0,a)}catch{}}),{data:l}})},this.getInput=s=>{try{return this.getData()[s]}catch{_e(Y.PATH_DOESNT_EXIST,s)}},this.get=s=>{var a;return(a=this.getInput(s))===null||a===void 0?void 0:a.value},this.emitOnEditStart=s=>{n.emit(`onEditStart:${s}`,this.get(s),s,D(D({},this.getInput(s)),{},{get:this.get}))},this.emitOnEditEnd=s=>{n.emit(`onEditEnd:${s}`,this.get(s),s,D(D({},this.getInput(s)),{},{get:this.get}))},this.subscribeToEditStart=(s,a)=>{const c=`onEditStart:${s}`;return n.on(c,a),()=>n.off(c,a)},this.subscribeToEditEnd=(s,a)=>{const c=`onEditEnd:${s}`;return n.on(c,a),()=>n.off(c,a)};const i=(s,a,c)=>{const l={};return Object.entries(s).forEach(([u,f])=>{if(u==="")return _e(Y.EMPTY_KEY);let p=Wr(a,u);if(f.type===me.FOLDER){const h=i(f.schema,p,c);Object.assign(l,h),p in r||(r[p]=f.settings)}else if(u in c)_e(Y.DUPLICATE_KEYS,u,p,c[u].path);else{const h=Of(f,u,p,l);if(h){const{type:m,options:b,input:y}=h,{onChange:v,transient:w,onEditStart:x,onEditEnd:$}=b,C=U(b,Mg);l[p]=D(D(D({type:m},C),y),{},{fromPanel:!0}),c[u]={path:p,onChange:v,transient:w,onEditStart:x,onEditEnd:$}}else _e(Y.UNKNOWN_INPUT,p,f)}}),l};this.getDataFromSchema=s=>{const a={};return[i(s,"",a),a]}},fa=new Lg,Ng={collapsed:!1};function Fg(e,t){return{type:me.FOLDER,schema:e,settings:D(D({},Ng),t)}}const ci=e=>"__levaInput"in e,zg=(e,t)=>{const n={},r=t?t.toLowerCase():null;return e.forEach(o=>{const[i,s]=zh(o);(!r||i.toLowerCase().indexOf(r)>-1)&&Fh(n,s,{[i]:{__levaInput:!0,path:o}})}),n},Bg=["type","label","path","valueKey","value","settings","setValue","disabled"];function Wg(e){let{type:t,label:n,path:r,valueKey:o,value:i,settings:s,setValue:a,disabled:c}=e,l=U(e,Bg);const{displayValue:u,onChange:f,onUpdate:p}=Ps({type:t,value:i,settings:s,setValue:a}),h=Ge[t].component;return h?g.createElement(ws.Provider,{value:D({key:o,path:r,id:""+r,label:n,displayValue:u,value:i,onChange:f,onUpdate:p,settings:s,setValue:a,disabled:c},l)},g.createElement(Kf,{disabled:c},g.createElement(h,null))):(_e(Y.NO_COMPONENT_FOR_TYPE,t,r),null)}const Hg=A("button",{display:"block",$reset:"",fontWeight:"$button",height:"$rowHeight",borderStyle:"none",borderRadius:"$sm",backgroundColor:"$elevation1",color:"$highlight1","&:not(:disabled)":{color:"$highlight3",backgroundColor:"$accent2",cursor:"pointer",$hover:"$accent3",$active:"$accent3 $accent1",$focus:""}});function Vg({onClick:e,settings:t,label:n}){const r=Mt();return g.createElement(he,null,g.createElement(Hg,{disabled:t.disabled,onClick:()=>e(r.get)},n))}const Ug=A("div",{$flex:"",justifyContent:"flex-end",gap:"$colGap"}),Kg=A("button",{$reset:"",cursor:"pointer",borderRadius:"$xs","&:hover":{backgroundColor:"$elevation3"}}),Gg=({label:e,opts:t})=>{let n=typeof e=="string"&&e.trim()===""?null:e,r=t;return typeof t.opts=="object"&&(r.label!==void 0&&(n=t.label),r=t.opts),{label:n,opts:r}};function Yg(e){const{label:t,opts:n}=Gg(e),r=Mt();return g.createElement(he,{input:!!t},t&&g.createElement(we,null,t),g.createElement(Ug,null,Object.entries(n).map(([o,i])=>g.createElement(Kg,{key:o,onClick:()=>i(r.get)},o))))}const qg=A("canvas",{height:"$monitorHeight",width:"100%",display:"block",borderRadius:"$sm"}),da=100;function Xg(e,t){e.push(t),e.length>da&&e.shift()}const Jg=d.forwardRef(function({initialValue:e},t){const n=Te("colors","highlight3"),r=Te("colors","elevation2"),o=Te("colors","highlight1"),[i,s]=d.useMemo(()=>[re(o).alpha(.4).toRgbString(),re(o).alpha(.1).toRgbString()],[o]),a=d.useRef([e]),c=d.useRef(e),l=d.useRef(e),u=d.useRef(),f=d.useCallback((m,b)=>{if(!m)return;const{width:y,height:v}=m,w=new Path2D,x=y/da,$=v*.05;for(let S=0;S({frame:m=>{(c.current===void 0||ml.current)&&(l.current=m),Xg(a.current,m),u.current=requestAnimationFrame(()=>f(p.current,h.current))}}),[p,h,f]),d.useEffect(()=>()=>cancelAnimationFrame(u.current),[]),g.createElement(qg,{ref:p})}),li=e=>Number.isFinite(e)?e.toPrecision(2):e.toString(),Zg=d.forwardRef(function({initialValue:e},t){const[n,r]=d.useState(li(e));return d.useImperativeHandle(t,()=>({frame:o=>r(li(o))}),[]),g.createElement("div",null,n)});function ui(e){return typeof e=="function"?e():e.current}function Qg({label:e,objectOrFn:t,settings:n}){const r=d.useRef(),o=d.useRef(ui(t));return d.useEffect(()=>{const i=window.setInterval(()=>{var s;document.hidden||(s=r.current)===null||s===void 0||s.frame(ui(t))},n.interval);return()=>window.clearInterval(i)},[t,n.interval]),g.createElement(he,{input:!0},g.createElement(we,{align:"top"},e),n.graph?g.createElement(Jg,{ref:r,initialValue:o.current}):g.createElement(Zg,{ref:r,initialValue:o.current}))}const em=["type","label","key"],tm={[me.BUTTON]:Vg,[me.BUTTON_GROUP]:Yg,[me.MONITOR]:Qg},nm=g.memo(({path:e})=>{const[t,{set:n,setSettings:r,disable:o,storeId:i,emitOnEditStart:s,emitOnEditEnd:a}]=rd(e);if(!t)return null;const{type:c,label:l,key:u}=t,f=U(t,em);if(c in me){const p=tm[c];return g.createElement(p,X({label:l,path:e},f))}return c in Ge?g.createElement(Wg,X({key:i+e,type:c,label:l,storeId:i,path:e,valueKey:u,setValue:n,setSettings:r,disable:o,emitOnEditStart:s,emitOnEditEnd:a},f)):(uf(Y.UNSUPPORTED_INPUT,c,e),null)});function rm({toggle:e,toggled:t,name:n}){return g.createElement(Hf,{onClick:()=>e()},g.createElement(Ir,{toggled:t}),g.createElement("div",null,n))}const om=({name:e,path:t,tree:n})=>{const r=Mt(),o=Wr(t,e),{collapsed:i,color:s}=r.getFolderSettings(o),[a,c]=d.useState(!i),l=d.useRef(null),u=Te("colors","folderWidgetColor"),f=Te("colors","folderTextColor");return d.useLayoutEffect(()=>{l.current.style.setProperty("--leva-colors-folderWidgetColor",s||u),l.current.style.setProperty("--leva-colors-folderTextColor",s||f)},[s,u,f]),g.createElement(ln,{ref:l},g.createElement(rm,{name:e,toggled:a,toggle:()=>c(p=>!p)}),g.createElement(pa,{parent:o,tree:n,toggled:a}))},pa=g.memo(({isRoot:e=!1,fill:t=!1,flat:n=!1,parent:r,tree:o,toggled:i})=>{const{wrapperRef:s,contentRef:a}=Hh(i),c=Mt(),l=([f,p])=>{var h;return(ci(p)?(h=c.getInput(p.path))===null||h===void 0?void 0:h.order:c.getFolderSettings(Wr(r,f)).order)||0},u=Object.entries(o).sort((f,p)=>l(f)-l(p));return g.createElement(ir,{ref:s,isRoot:e,fill:t,flat:n},g.createElement(Os,{ref:a,isRoot:e,toggled:i},u.map(([f,p])=>ci(p)?g.createElement(nm,{key:p.path,valueKey:p.valueKey,path:p.path}):g.createElement(om,{key:f,name:f,path:r,tree:p}))))}),im=A("div",{position:"relative",fontFamily:"$mono",fontSize:"$root",color:"$rootText",backgroundColor:"$elevation1",variants:{fill:{false:{position:"fixed",top:"10px",right:"10px",zIndex:1e3,width:"$rootWidth"},true:{position:"relative",width:"100%"}},flat:{false:{borderRadius:"$lg",boxShadow:"$level1"}},oneLineLabels:{true:{[`${_s}`]:{gridTemplateColumns:"auto",gridAutoColumns:"minmax(max-content, 1fr)",gridAutoRows:"minmax($sizes$rowHeight), auto)",rowGap:0,columnGap:0,marginTop:"$rowGap"}}},hideTitleBar:{true:{$$titleBarHeight:"0px"},false:{$$titleBarHeight:"$sizes$titleBarHeight"}}},"&,*,*:after,*:before":{boxSizing:"border-box"},"*::selection":{backgroundColor:"$accent2"}}),ha=40,hn=A("i",{$flexCenter:"",width:ha,userSelect:"none",cursor:"pointer","> svg":{fill:"$highlight1",transition:"transform 350ms ease, fill 250ms ease"},"&:hover > svg":{fill:"$highlight3"},variants:{active:{true:{"> svg":{fill:"$highlight2"}}}}}),sm=A("div",{display:"flex",alignItems:"stretch",justifyContent:"space-between",height:"$titleBarHeight",variants:{mode:{drag:{cursor:"grab"}}}}),am=A("div",{$flex:"",position:"relative",width:"100%",overflow:"hidden",transition:"height 250ms ease",color:"$highlight3",paddingLeft:"$md",[`> ${hn}`]:{height:30},variants:{toggled:{true:{height:30},false:{height:0}}}}),cm=A("input",{$reset:"",flex:1,position:"relative",height:30,width:"100%",backgroundColor:"transparent",fontSize:"10px",borderRadius:"$root","&:focus":{},"&::placeholder":{color:"$highlight2"}}),lm=A("div",{touchAction:"none",$flexCenter:"",flex:1,"> svg":{fill:"$highlight1"},color:"$highlight1",variants:{drag:{true:{$draggable:"","> svg":{transition:"fill 250ms ease"},"&:hover":{color:"$highlight3"},"&:hover > svg":{fill:"$highlight3"}}},filterEnabled:{false:{paddingRight:ha}}}}),um=g.forwardRef(({setFilter:e,toggle:t},n)=>{const[r,o]=d.useState(""),i=d.useMemo(()=>hs(e,250),[e]),s=()=>{e(""),o("")},a=c=>{const l=c.currentTarget.value;t(!0),o(l)};return d.useEffect(()=>{i(r)},[r,i]),g.createElement(g.Fragment,null,g.createElement(cm,{ref:n,value:r,placeholder:"[Open filter with CMD+SHIFT+L]",onPointerDown:c=>c.stopPropagation(),onChange:a}),g.createElement(hn,{onClick:()=>s(),style:{visibility:r?"visible":"hidden"}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"14",width:"14",viewBox:"0 0 20 20",fill:"currentColor"},g.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"}))))});function fm({setFilter:e,onDrag:t,onDragStart:n,onDragEnd:r,toggle:o,toggled:i,title:s,drag:a,filterEnabled:c,from:l}){const[u,f]=d.useState(!1),p=d.useRef(null);d.useEffect(()=>{var m,b;u?(m=p.current)===null||m===void 0||m.focus():(b=p.current)===null||b===void 0||b.blur()},[u]);const h=Lt(({offset:[m,b],first:y,last:v})=>{t({x:m,y:b}),y&&n({x:m,y:b}),v&&r({x:m,y:b})},{filterTaps:!0,from:({offset:[m,b]})=>[(l==null?void 0:l.x)||m,(l==null?void 0:l.y)||b]});return d.useEffect(()=>{const m=b=>{b.key==="L"&&b.shiftKey&&b.metaKey&&f(y=>!y)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]),g.createElement(g.Fragment,null,g.createElement(sm,{mode:a?"drag":void 0},g.createElement(hn,{active:!i,onClick:()=>o()},g.createElement(Ir,{toggled:i,width:12,height:8})),g.createElement(lm,X({},a?h():{},{drag:a,filterEnabled:c}),s===void 0&&a?g.createElement("svg",{width:"20",height:"10",viewBox:"0 0 28 14",xmlns:"http://www.w3.org/2000/svg"},g.createElement("circle",{cx:"2",cy:"2",r:"2"}),g.createElement("circle",{cx:"14",cy:"2",r:"2"}),g.createElement("circle",{cx:"26",cy:"2",r:"2"}),g.createElement("circle",{cx:"2",cy:"12",r:"2"}),g.createElement("circle",{cx:"14",cy:"12",r:"2"}),g.createElement("circle",{cx:"26",cy:"12",r:"2"})):s),c&&g.createElement(hn,{active:u,onClick:()=>f(m=>!m)},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20",viewBox:"0 0 20 20"},g.createElement("path",{d:"M9 9a2 2 0 114 0 2 2 0 01-4 0z"}),g.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-13a4 4 0 00-3.446 6.032l-2.261 2.26a1 1 0 101.414 1.415l2.261-2.261A4 4 0 1011 5z",clipRule:"evenodd"})))),g.createElement(am,{toggled:u},g.createElement(um,{ref:p,setFilter:e,toggle:o})))}const dm=["store","hidden","theme","collapsed"];function pm(e){let{store:t,hidden:n=!1,theme:r,collapsed:o=!1}=e,i=U(e,dm);const s=ia(()=>Lf(r),[r]),[a,c]=d.useState(!o),l=typeof o=="object"?!o.collapsed:a,u=d.useMemo(()=>typeof o=="object"?f=>{typeof f=="function"?o.onChange(!f(!o.collapsed)):o.onChange(!f)}:c,[o]);return!t||n?null:g.createElement(kr.Provider,{value:s},g.createElement(hm,X({store:t},i,{toggled:l,setToggle:u,rootClass:s.className})))}const hm=g.memo(({store:e,rootClass:t,fill:n=!1,flat:r=!1,neverHide:o=!1,oneLineLabels:i=!1,titleBar:s={title:void 0,drag:!0,filter:!0,position:void 0,onDrag:void 0,onDragStart:void 0,onDragEnd:void 0},hideCopyButton:a=!1,toggled:c,setToggle:l})=>{var u,f;const p=Vh(e),[h,m]=d.useState(""),b=d.useMemo(()=>zg(p,h),[p,h]),[y,v]=ks(),w=o||p.length>0,x=typeof s=="object"&&s.title||void 0,$=typeof s=="object"&&(u=s.drag)!==null&&u!==void 0?u:!0,C=typeof s=="object"&&(f=s.filter)!==null&&f!==void 0?f:!0,E=typeof s=="object"&&s.position||void 0,S=typeof s=="object"&&s.onDrag||void 0,k=typeof s=="object"&&s.onDragStart||void 0,z=typeof s=="object"&&s.onDragEnd||void 0;return g.useEffect(()=>{v({x:E==null?void 0:E.x,y:E==null?void 0:E.y})},[E,v]),Mf(),g.createElement(Es.Provider,{value:{hideCopyButton:a}},g.createElement(im,{ref:y,className:t,fill:n,flat:r,oneLineLabels:i,hideTitleBar:!s,style:{display:w?"block":"none"}},s&&g.createElement(fm,{onDrag:R=>{v(R),S==null||S(R)},onDragStart:R=>k==null?void 0:k(R),onDragEnd:R=>z==null?void 0:z(R),setFilter:m,toggle:R=>l(T=>R??!T),toggled:c,title:x,drag:$,filterEnabled:C,from:E}),w&&g.createElement(xs.Provider,{value:e},g.createElement(pa,{isRoot:!0,fill:n,flat:r,tree:b,toggled:c}))))}),gm=["isRoot"];let gn=!1,We=null;function mm(e){let{isRoot:t=!1}=e,n=U(e,gm);return d.useEffect(()=>(gn=!0,!t&&We&&(We.remove(),We=null),()=>{t||(gn=!1)}),[t]),g.createElement(pm,X({store:fa},n))}function bm(e){d.useEffect(()=>{e&&!gn&&(We||(We=document.getElementById("leva__root")||Object.assign(document.createElement("div"),{id:"leva__root"}),document.body&&(document.body.appendChild(We),_f(g.createElement(mm,{isRoot:!0}),We))),gn=!0)},[e])}function vm(e,t,n,r,o){let i,s,a,c,l;return typeof e=="string"?(s=e,i=t,Array.isArray(n)&&(l=n)):(i=e,Array.isArray(t)?l=t:(c=t,l=n)),{schema:i,folderName:s,folderSettings:a,hookSettings:c,deps:l||[]}}function Pm(e,t,n,r,o){const{folderName:i,schema:s,folderSettings:a,hookSettings:c,deps:l}=vm(e,t,n),u=typeof s=="function",f=d.useRef(!1),p=d.useRef(!0),h=ia(()=>{f.current=!0;const T=typeof s=="function"?s():s;return i?{[i]:Fg(T,a)}:T},l),m=!(c!=null&&c.store);bm(m);const[b]=d.useState(()=>(c==null?void 0:c.store)||fa),[y,v]=d.useMemo(()=>b.getDataFromSchema(h),[b,h]),[w,x,$,C,E]=d.useMemo(()=>{const T=[],P=[],I={},j={},L={};return Object.values(v).forEach(({path:B,onChange:W,onEditStart:M,onEditEnd:H,transient:J})=>{T.push(B),W?(I[B]=W,J||P.push(B)):P.push(B),M&&(j[B]=M),H&&(L[B]=H)}),[T,P,I,j,L]},[v]),S=d.useMemo(()=>b.orderPaths(w),[w,b]),k=Uh(b,x,y),z=d.useCallback(T=>{const P=Object.entries(T).reduce((I,[j,L])=>Object.assign(I,{[v[j].path]:L}),{});b.set(P,!1)},[b,v]),R=d.useCallback(T=>b.get(v[T].path),[b,v]);return d.useEffect(()=>{const T=!p.current&&f.current;return b.addData(y,T),p.current=!1,f.current=!1,()=>b.disposePaths(S)},[b,S,y]),d.useEffect(()=>{const T=[];return Object.entries($).forEach(([P,I])=>{I(b.get(P),P,D({initial:!0,get:b.get},b.getInput(P)));const j=b.useStore.subscribe(L=>{const B=L.data[P];return[B.disabled?void 0:B.value,B]},([L,B])=>I(L,P,D({initial:!1,get:b.get},B)),{equalityFn:bn});T.push(j)}),()=>T.forEach(P=>P())},[b,$]),d.useEffect(()=>{const T=[];return Object.entries(C).forEach(([P,I])=>T.push(b.subscribeToEditStart(P,I))),Object.entries(E).forEach(([P,I])=>T.push(b.subscribeToEditEnd(P,I))),()=>T.forEach(P=>P())},[C,E,b]),u?[k,z,R]:k}De(ye.SELECT,wd);De(ye.IMAGE,Sg);De(ye.NUMBER,ud);De(ye.COLOR,ng);De(ye.STRING,Td);De(ye.BOOLEAN,Md);De(ye.INTERVAL,Dg);De(ye.VECTOR3D,og);De(ye.VECTOR2D,dg);export{$m as G,Sm as T,Pm as u}; diff --git a/example/bundle/assets/lil-gui.module.min-Bc0DeA9g.js b/example/bundle/assets/lil-gui.module.min-Bc0DeA9g.js new file mode 100644 index 00000000..428c5fdf --- /dev/null +++ b/example/bundle/assets/lil-gui.module.min-Bc0DeA9g.js @@ -0,0 +1,10 @@ +/** + * lil-gui + * https://lil-gui.georgealways.com + * @version 0.17.0 + * @author George Michael Brower + * @license MIT + */class u{constructor(t,i,e,n,a="div"){this.parent=t,this.object=i,this.property=e,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),u.nextNameID=u.nextNameID||0,this.$name.id="lil-gui-name-"+ ++u.nextNameID,this.$widget=document.createElement(a),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(e)}name(t){return this._name=t,this.$name.innerHTML=t,this}onChange(t){return this._onChange=t,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(t=!0){return this.disable(!t)}disable(t=!0){return t===this._disabled||(this._disabled=t,this.domElement.classList.toggle("disabled",t),this.$disable.toggleAttribute("disabled",t)),this}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(t){const i=this.parent.add(this.object,this.property,t);return i.name(this._name),this.destroy(),i}min(t){return this}max(t){return this}step(t){return this}decimals(t){return this}listen(t=!0){return this._listening=t,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const t=this.save();t!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=t}getValue(){return this.object[this.property]}setValue(t){return this.object[this.property]=t,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(t){return this.setValue(t),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class C extends u{constructor(t,i,e){super(t,i,e,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function w(l){let t,i;return(t=l.match(/(#|0x)?([a-f0-9]{6})/i))?i=t[2]:(t=l.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?i=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=l.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(i=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),!!i&&"#"+i}const k={isPrimitive:!0,match:l=>typeof l=="string",fromHexString:w,toHexString:w},m={isPrimitive:!0,match:l=>typeof l=="number",fromHexString:l=>parseInt(l.substring(1),16),toHexString:l=>"#"+l.toString(16).padStart(6,0)},L={isPrimitive:!1,match:Array.isArray,fromHexString(l,t,i=1){const e=m.fromHexString(l);t[0]=(e>>16&255)/255*i,t[1]=(e>>8&255)/255*i,t[2]=(255&e)/255*i},toHexString:([l,t,i],e=1)=>m.toHexString(l*(e=255/e)<<16^t*e<<8^i*e<<0)},S={isPrimitive:!1,match:l=>Object(l)===l,fromHexString(l,t,i=1){const e=m.fromHexString(l);t.r=(e>>16&255)/255*i,t.g=(e>>8&255)/255*i,t.b=(255&e)/255*i},toHexString:({r:l,g:t,b:i},e=1)=>m.toHexString(l*(e=255/e)<<16^t*e<<8^i*e<<0)},D=[k,m,L,S];class F extends u{constructor(t,i,e,n){var a;super(t,i,e,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(a=this.initialValue,D.find(r=>r.match(a))),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const r=w(this.$text.value);r&&this._setValueFromHexString(r)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){const i=this._format.fromHexString(t);this.setValue(i)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class f extends u{constructor(t,i,e){super(t,i,e,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",n=>{n.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class V extends u{constructor(t,i,e,n,a,r){super(t,i,e,"number"),this._initInput(),this.min(n),this.max(a);const d=r!==void 0;this.step(d?r:this._getImplicitStep(),d),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,i=!0){return this._step=t,this._stepExplicit=i,this}updateDisplay(){const t=this.getValue();if(this._hasSlider){let i=(t-this._min)/(this._max-this._min);i=Math.max(0,Math.min(i,1)),this.$fill.style.width=100*i+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=s=>{const p=parseFloat(this.$input.value);isNaN(p)||(this._snapClampSetValue(p+s),this.$input.value=this.getValue())};let i,e,n,a,r,d=!1;const h=s=>{if(d){const p=s.clientX-i,o=s.clientY-e;Math.abs(o)>5?(s.preventDefault(),this.$input.blur(),d=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(p)>5&&c()}if(!d){const p=s.clientY-n;r-=p*this._step*this._arrowKeyMultiplier(s),a+r>this._max?r=this._max-a:a+r{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",c)};this.$input.addEventListener("input",()=>{let s=parseFloat(this.$input.value);isNaN(s)||(this._stepExplicit&&(s=this._snap(s)),this.setValue(this._clamp(s)))}),this.$input.addEventListener("keydown",s=>{s.code==="Enter"&&this.$input.blur(),s.code==="ArrowUp"&&(s.preventDefault(),t(this._step*this._arrowKeyMultiplier(s))),s.code==="ArrowDown"&&(s.preventDefault(),t(this._step*this._arrowKeyMultiplier(s)*-1))}),this.$input.addEventListener("wheel",s=>{this._inputFocused&&(s.preventDefault(),t(this._step*this._normalizeMouseWheel(s)))},{passive:!1}),this.$input.addEventListener("mousedown",s=>{i=s.clientX,e=n=s.clientY,d=!0,a=this.getValue(),r=0,window.addEventListener("mousemove",h),window.addEventListener("mouseup",c)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const t=o=>{const g=this.$slider.getBoundingClientRect();let b=(x=o,v=g.left,y=g.right,A=this._min,_=this._max,(x-v)/(y-v)*(_-A)+A);var x,v,y,A,_;this._snapClampSetValue(b)},i=o=>{t(o.clientX)},e=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",e)};let n,a,r=!1;const d=o=>{o.preventDefault(),this._setDraggingStyle(!0),t(o.touches[0].clientX),r=!1},h=o=>{if(r){const g=o.touches[0].clientX-n,b=o.touches[0].clientY-a;Math.abs(g)>Math.abs(b)?d(o):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c))}else o.preventDefault(),t(o.touches[0].clientX)},c=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c)},s=this._callOnFinishChange.bind(this);let p;this.$slider.addEventListener("mousedown",o=>{this._setDraggingStyle(!0),t(o.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",e)}),this.$slider.addEventListener("touchstart",o=>{o.touches.length>1||(this._hasScrollBar?(n=o.touches[0].clientX,a=o.touches[0].clientY,r=!0):d(o),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",c))},{passive:!1}),this.$slider.addEventListener("wheel",o=>{if(Math.abs(o.deltaX)this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){const t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class M extends u{constructor(t,i,e,n){super(t,i,e,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(n)?n:Object.values(n),this._names=Array.isArray(n)?n:Object.keys(n),this._names.forEach(a=>{const r=document.createElement("option");r.innerHTML=a,this.$select.appendChild(r)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const t=this.getValue(),i=this._values.indexOf(t);return this.$select.selectedIndex=i,this.$display.innerHTML=i===-1?t:this._names[i],this}}class H extends u{constructor(t,i,e){super(t,i,e,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",n=>{n.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let $=!1;class E{constructor({parent:t,autoPlace:i=t===void 0,container:e,width:n,title:a="Controls",injectStyles:r=!0,touchStyles:d=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",h=>{h.code!=="Enter"&&h.code!=="Space"||(h.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),d&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!$&&r&&(function(h){const c=document.createElement("style");c.innerHTML=h;const s=document.querySelector("head link[rel=stylesheet], head style");s?document.head.insertBefore(c,s):document.head.appendChild(c)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),$=!0),e?e.appendChild(this.domElement):i&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),n&&this.domElement.style.setProperty("--width",n+"px"),this.domElement.addEventListener("keydown",h=>h.stopPropagation()),this.domElement.addEventListener("keyup",h=>h.stopPropagation())}add(t,i,e,n,a){if(Object(e)===e)return new M(this,t,i,e);const r=t[i];switch(typeof r){case"number":return new V(this,t,i,e,n,a);case"boolean":return new C(this,t,i);case"string":return new H(this,t,i);case"function":return new f(this,t,i)}console.error(`gui.add failed + property:`,i,` + object:`,t,` + value:`,r)}addColor(t,i,e=1){return new F(this,t,i,e)}addFolder(t){return new E({parent:this,title:t})}load(t,i=!0){return t.controllers&&this.controllers.forEach(e=>{e instanceof f||e._name in t.controllers&&e.load(t.controllers[e._name])}),i&&t.folders&&this.folders.forEach(e=>{e._title in t.folders&&e.load(t.folders[e._title])}),this}save(t=!0){const i={controllers:{},folders:{}};return this.controllers.forEach(e=>{if(!(e instanceof f)){if(e._name in i.controllers)throw new Error(`Cannot save GUI with duplicate property "${e._name}"`);i.controllers[e._name]=e.save()}}),t&&this.folders.forEach(e=>{if(e._title in i.folders)throw new Error(`Cannot save GUI with duplicate folder "${e._title}"`);i.folders[e._title]=e.save()}),i}open(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const i=this.$children.clientHeight;this.$children.style.height=i+"px",this.domElement.classList.add("transition");const e=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",e))};this.$children.addEventListener("transitionend",e);const n=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=n+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(i=>{t=t.concat(i.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(i=>{t=t.concat(i.foldersRecursive())}),t}}export{E as g}; diff --git a/example/bundle/assets/mars-eOYGbpoc.js b/example/bundle/assets/mars-eOYGbpoc.js new file mode 100644 index 00000000..492f9a8e --- /dev/null +++ b/example/bundle/assets/mars-eOYGbpoc.js @@ -0,0 +1 @@ +import{ae as f,S as h,W as x,a as B,D as P,A as S,G as T}from"./three.module-DpclfMcJ.js";import{g as y}from"./lil-gui.module.min-Bc0DeA9g.js";import{E as C}from"./EnvironmentControls-C8X7oAWq.js";import{T as m}from"./TilesRenderer-DdUhzUiO.js";import{d as p}from"./DebugTilesPlugin-CbfV2ROf.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./EllipsoidRegionHelper-OhHLW9vN.js";let t,a,n,o,e,i;const r={errorTarget:12,displayBoxBounds:!1,fog:!1};R();g();function R(){const u=new f(14208704,.0075,250);n=new h,o=new x({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(14208704),document.body.appendChild(o.domElement),o.domElement.tabIndex=1,t=new B(60,window.innerWidth/window.innerHeight,1,4e3),t.position.set(20,10,20),t.lookAt(0,0,0),a=new C(n,t,o.domElement),a.minZoomDistance=2,a.cameraRadius=1;const l=new P(16777215);l.position.set(1,2,3),n.add(l);const w=new S(16777215,.2);n.add(w);const d=new T;d.rotation.set(Math.PI/2,0,0),n.add(d),e=new m("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json"),e.registerPlugin(new p),e.fetchOptions.mode="cors",e.lruCache.minSize=900,e.lruCache.maxSize=1300,e.errorTarget=12,i=new m("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_sky/0528_0260184_to_s64o256_sky_tileset.json"),i.registerPlugin(new p),i.fetchOptions.mode="cors",i.lruCache=e.lruCache,d.add(e.group,i.group),c(),window.addEventListener("resize",c,!1);const s=new y;s.add(r,"fog").onChange(_=>{n.fog=_?u:null}),s.add(r,"displayBoxBounds"),s.add(r,"errorTarget",0,100),s.open()}function c(){t.aspect=window.innerWidth/window.innerHeight,t.updateProjectionMatrix(),o.setSize(window.innerWidth,window.innerHeight),o.setPixelRatio(window.devicePixelRatio)}function g(){requestAnimationFrame(g),a.update(),t.updateMatrixWorld(),e.errorTarget=r.errorTarget,e.getPluginByName("DEBUG_TILES_PLUGIN").displayBoxBounds=r.displayBoxBounds,i.getPluginByName("DEBUG_TILES_PLUGIN").displayBoxBounds=r.displayBoxBounds,e.setCamera(t),e.setResolutionFromRenderer(t,o),e.update(),i.setCamera(t),i.setResolutionFromRenderer(t,o),i.update(),o.render(n,t)} diff --git a/example/bundle/assets/metadata-D6CoxxfG.js b/example/bundle/assets/metadata-D6CoxxfG.js new file mode 100644 index 00000000..f3758b34 --- /dev/null +++ b/example/bundle/assets/metadata-D6CoxxfG.js @@ -0,0 +1,172 @@ +import{W as Y,S as G,a as $,D as j,A as V,G as N,V as W,R as k,k as C,am as X,d as z}from"./three.module-DpclfMcJ.js";import{G as O}from"./GLTFLoader-DkJa3Jo5.js";import{g as B}from"./lil-gui.module.min-Bc0DeA9g.js";import{E as K}from"./EnvironmentControls-C8X7oAWq.js";import{T as q}from"./TilesRenderer-DdUhzUiO.js";import{C as Z}from"./CesiumIonAuthPlugin-DCN_lM0S.js";import{G as J,a as Q}from"./GLTFMeshFeaturesExtension-D473cUUw.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";import"./GoogleCloudAuthPlugin-B9LFbpXw.js";import"./Pass-inUSP30K.js";const ee=i=>class extends i{get featureTexture(){return this.uniforms.featureTexture.value}set featureTexture(e){const t=this.uniforms.featureTexture.value;t!==e&&t&&t.dispose(),this.uniforms.featureTexture.value=e}get nullFeatureId(){return this.uniforms.nullFeatureId.value}set nullFeatureId(e){e<0||e===null||e===void 0?(this.uniforms.nullFeatureId.value=null,this.setDefine("USE_NULL_FEATURE",0)):(this.uniforms.nullFeatureId.value=e,this.setDefine("USE_NULL_FEATURE",1))}get highlightFeatureId(){return this.uniforms.highlightFeatureId.value}set highlightFeatureId(e){e==null?(this.uniforms.highlightFeatureId.value=null,this.setDefine("USE_HIGHLIGHT_FEATURE",0)):(this.uniforms.highlightFeatureId.value=e,this.setDefine("USE_HIGHLIGHT_FEATURE",1))}constructor(...e){super(...e),this.isMeshFeaturesMaterial=!0,this.uniforms={featureChannelsLength:{value:0},featureChannels:{value:new Array(4).fill(0)},featureTexture:{value:null},nullFeatureId:{value:null},highlightFeatureId:{value:-1}},Object.assign(this.defines,{FEATURE_TYPE:0,USE_HIGHLIGHT_FEATURE:0,USE_NULL_FEATURE:0,FEATURE_ATTR:"",FEATURE_TEXTURE_ATTR:"uv"}),this.addEventListener("dispose",()=>{this.featureTexture&&this.featureTexture.dispose()})}copy(e){const t=this.defines;if(super.copy(e),e.defines&&Object.assign(this.defines,t,e.defines),e.uniforms)for(const r in this.uniforms){const n=e.uniforms[r].value;Array.isArray(n)?this.uniforms[r].value=n.slice():this.uniforms[r].value=n}this.needsUpdate=!0}setDefine(e,t){const r=this.defines;r[e]!==t&&(this.needsUpdate=!0),t===null?delete r[e]:r[e]=t}setFromMeshFeatures(e,t){let r=null;typeof t=="number"?r=e.getFeatureInfo()[t]||null:typeof t=="string"&&(r=e.getFeatureInfo().find(n=>n.label===t)||null),r===null?(this.setDefine("FEATURE_TYPE",0),this.featureTexture=null):"attribute"in r?this._setAttributeFeature(r.attribute):"texture"in r?this._setTextureFeature(e.textures[r.texture.index],r.texture.texCoord,r.texture.channels):this._setAttributeFeature(null),r!==null&&(this.nullFeatureId=r.nullFeatureId==null?null:r.nullFeatureId)}disableFeatureDisplay(){this.setDefine("FEATURE_TYPE",0),this.featureTexture=null}_setTextureFeature(e,t,r){const n=this.uniforms;this.setDefine("FEATURE_TYPE",3),t===0?(this.setDefine("FEATURE_TEXTURE_ATTR","uv"),this.setDefine("USE_UV","")):(this.setDefine("FEATURE_TEXTURE_ATTR",`uv${t}`),this.setDefine(`USE_UV${t}`,"")),t!==0&&this.setDefine("USE_UV",null),t!==1&&this.setDefine("USE_UV1",null),t!==2&&this.setDefine("USE_UV2",null),t!==3&&this.setDefine("USE_UV3",null),n.featureChannelsLength.value=r.length,n.featureChannels.value=[...r],this.featureTexture=e}_setAttributeFeature(e=null){e===null?this.setDefine("FEATURE_TYPE",1):(this.setDefine("FEATURE_TYPE",2),this.setDefine("FEATURE_ATTR",`_feature_id_${e}`)),this.featureTexture=null}customProgramCacheKey(){const e=this.defines;return`${e.FEATURE_TYPE}|${e.USE_HIGHLIGHT_FEATURE}|${e.USE_NULL_FEATURE}|${e.FEATURE_ATTR}|${e.FEATURE_TEXTURE_ATTR}`}onBeforeCompile(e){e.uniforms={...e.uniforms,...this.uniforms},e.defines=this.defines,e.vertexShader=e.vertexShader.replace(/^/,t=>` + // texture + #if FEATURE_TYPE == 3 + + varying vec2 _feature_uv; + + // attribute + #elif FEATURE_TYPE == 2 + + attribute float FEATURE_ATTR; + flat varying uint _feature_attr; + + // implicit + #elif FEATURE_TYPE == 1 + + flat varying uint _feature_attr; + + #endif + + ${t} + `).replace(/void main\(\) {/,t=>` + ${t} + + // texture + #if FEATURE_TYPE == 3 + + _feature_uv = FEATURE_TEXTURE_ATTR; + + // attribute + #elif FEATURE_TYPE == 2 + + _feature_attr = uint( FEATURE_ATTR ); + + // none + #elif FEATURE_TYPE == 1 + + _feature_attr = uint( gl_VertexID ); + + #endif + `),e.fragmentShader=e.fragmentShader.replace(/^/,t=>` + + #if USE_HIGHLIGHT_FEATURE + + uniform uint highlightFeatureId; + + #endif + + #if USE_NULL_FEATURE + + uniform uint nullFeatureId; + + #endif + + // texture + #if FEATURE_TYPE == 3 + + uniform sampler2D featureTexture; + uniform int featureChannelsLength; + uniform uint featureChannels[ 4 ]; + varying vec2 _feature_uv; + + // attribute + #elif FEATURE_TYPE == 2 + + flat varying uint _feature_attr; + + // none + #elif FEATURE_TYPE == 1 + + flat varying uint _feature_attr; + + #endif + + // https://www.shadertoy.com/view/XljGzV + vec3 hsl2rgb( in vec3 c ) { + + vec3 rgb = clamp( abs( mod( c.x * 6.0 + vec3( 0.0, 4.0, 2.0 ), 6.0 ) - 3.0 ) - 1.0, 0.0, 1.0 ); + return c.z + c.y * ( rgb - 0.5 ) * ( 1.0 - abs( 2.0 * c.z - 1.0 ) ); + + } + + // https://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl + float rand( float v ) { + + return fract( sin( dot( vec2( v, v ), vec2( 12.9898, 78.233 ) ) ) * 43758.5453 ); + + } + + vec3 randFeatureColor( uint feature ) { + + vec3 hsl; + hsl.r = rand( float( feature ) / 5500.0 ); + hsl.g = 0.75; + hsl.b = 0.5; + return hsl2rgb( hsl ); + + } + + ${t} + `).replace(/#include /,t=>` + ${t} + + // disabled + #if FEATURE_TYPE != 0 + + uint featureId = 0u; + + // texture + #if FEATURE_TYPE == 3 + + // TODO: support anti aliasing here at the pixel edges + uvec4 fields = uvec4( texture( featureTexture, _feature_uv ) * float( 0xff ) ); + for ( int i = 0; i < min( featureChannelsLength, 4 ); i ++ ) { + + uint offset = 8u * featureChannels[ i ]; + featureId = featureId | ( fields[ i ] << offset ); + + } + + // attribute + #elif FEATURE_TYPE == 2 + + featureId = _feature_attr; + + // implicit + #elif FEATURE_TYPE == 1 + + featureId = _feature_attr; + + #endif + + #if USE_HIGHLIGHT_FEATURE + + if ( highlightFeatureId != featureId ) { + + diffuseColor.rgb *= 0.25; + + } + + #else + + vec3 featureColor = randFeatureColor( featureId ); + diffuseColor.rgb = mix( diffuseColor.rgb * featureColor, featureColor, 0.05 ); + + #endif + + #if USE_NULL_FEATURE + + if ( nullFeatureId == featureId ) { + + diffuseColor.rgb *= vec3( 0.0 ); + + } + + #endif + + #endif + + `)}};let h,p,_,T,I,l,A,g,R,U,w=!1,c=null,v=!1;const b=new W(-1,-1),y=new k;y.firstHitOnly=!0;y.params.Points.threshold=.05;const te=localStorage.getItem("ionApiKey")??"put-your-api-key-here",o={accessToken:te,assetId:2333904,reload:()=>{P()},featureIndex:0,propertyTexture:0,highlightAllFeatures:!1};re();H();function re(){g=document.getElementById("meshFeatures"),R=document.getElementById("structuralMetadata"),T=new Y({antialias:!0}),T.setPixelRatio(window.devicePixelRatio),T.setSize(window.innerWidth,window.innerHeight),T.setClearColor(1383455),document.body.appendChild(T.domElement),_=new G,h=new $(60,window.innerWidth/window.innerHeight,.1,5e3),h.position.set(-4,2,0).multiplyScalar(30),h.lookAt(0,0,0),p=new K(_,h,T.domElement),p.minDistance=.1,p.cameraRadius=.1,p.minAltitude=0,p.maxAltitude=Math.PI,p.adjustHeight=!1,p.addEventListener("start",()=>w=!0),p.addEventListener("end",()=>w=!1),I=new j(16777215,3.3),I.position.set(1,2,3).multiplyScalar(40),_.add(I),_.add(new V(16777215,1)),A=new N,A.position.y=40,_.add(A),P(),S(),window.addEventListener("resize",S,!1),window.addEventListener("pointermove",i=>{b.x=i.clientX/window.innerWidth*2-1,b.y=-(i.clientY/window.innerHeight)*2+1})}function ie(){U&&U.destroy(),U=new B;const i=U.addFolder("ion");i.add(o,"accessToken"),i.add(o,"assetId",[2333904,2342602]).onChange(P),i.add(o,"reload");const e=U.addFolder("features");o.assetId===2333904?(e.add(o,"featureIndex",[0,1]),e.add(o,"highlightAllFeatures")):e.add(o,"propertyTexture",{NONE:0,HORIZ_UNCERTAINTY:1,VERT_UNCERTAINTY:2})}function P(){l&&(l.dispose(),l.group.removeFromParent()),localStorage.setItem("ionApiKey",o.accessToken),l=new q,l.registerPlugin(new Z({apiToken:o.accessToken,assetId:o.assetId})),l.setCamera(h),A.add(l.group);const i=new O(l.manager);i.register(()=>new J),i.register(()=>new Q),l.manager.addHandler(/(gltf|glb)$/g,i),l.addEventListener("load-model",({scene:e})=>{e.traverse(t=>{if(t.material&&t.userData.meshFeatures){const r=ee(t.material.constructor),n=new r;n.copy(t.material),n.metalness=0,t.material=n}t.material&&t.userData.structuralMetadata&&(t.material.originalMap=t.material.map)})}),ie()}function S(){h.aspect=window.innerWidth/window.innerHeight,T.setPixelRatio(window.devicePixelRatio),T.setSize(window.innerWidth,window.innerHeight),h.updateProjectionMatrix()}function L(i,e,t,r=null,n=null,d=null){if(R.innerText=`STRUCTURAL_METADATA +`,n!==null){const u=i.getPropertyTableData(n,d);a(u,i.getPropertyTableInfo(n))}r!==null&&a(i.getPropertyAttributeData(r),i.getPropertyAttributeInfo()),a(i.getPropertyTextureData(e,t),i.getPropertyTextureInfo());function a(u,s){const f=Math.max(...Object.values(u).flatMap(m=>Object.keys(m)).map(m=>m.length));for(const m in u){R.innerText+=` +${s[m].name||s[m].className} +`;const F=u[m];for(const D in F){let E=F[D];E&&E.toArray&&(E=E.toArray()),E&&E.join&&(E=` +`+E.map(x=>x.toFixed?parseFloat(x.toFixed(6)):x).map((x,M)=>` [${M}] ${x}`).join(` +`)),typeof E=="number"&&(E=parseFloat(E.toFixed(6))),R.innerText+=` ${D.padEnd(f+1)} : ${E} +`}}}}function ne(){if(v||w)return;y.setFromCamera(b,h);const i=y.intersectObject(_)[0];if(i){const{object:e,face:t,point:r,index:n,faceIndex:d}=i,a=new C;if(t){const s=new X;s.setFromAttributeAndIndices(e.geometry.attributes.position,t.a,t.b,t.c),s.a.applyMatrix4(e.matrixWorld),s.b.applyMatrix4(e.matrixWorld),s.c.applyMatrix4(e.matrixWorld),s.getBarycoord(r,a)}else a.set(0,0,0);const{meshFeatures:u}=i.object.userData;u?(v=!0,u.getFeaturesAsync(d,a).then(s=>{v=!1,c={index:n,features:s,faceIndex:d,barycoord:a,object:e}})):c={index:n,features:null,faceIndex:d,barycoord:a,object:e}}else c=null}function ae(){const{featureIndex:i}=o;let e=null,t=null,r=null;if(c&&(e=c.object.userData.meshFeatures,t=c.object.userData.structuralMetadata,r=c.features),e!==null&&r!==null){const{index:n,faceIndex:d,barycoord:a}=c;if(g.innerText=`EXT_MESH_FEATURES + +`,g.innerText+=`feature : ${r.map(u=>u+"").join(", ")} +`,g.innerText+=`texture memory : ${T.info.memory.textures} +`,t!==null){const s=e.getFeatureInfo().map(f=>f.propertyTable);L(t,d,a,n,s,r)}}else if(g.innerText=`EXT_MESH_FEATURES + +`,g.innerText+=`feature : - +`,g.innerText+=`texture memory : ${T.info.memory.textures}`,t!==null){const{index:n,faceIndex:d,barycoord:a}=c;L(t,d,a,n)}else R.innerText="";l.forEachLoadedModel(n=>n.traverse(d=>{const a=d.material,{meshFeatures:u,structuralMetadata:s}=d.userData;if(a&&u)if(o.highlightAllFeatures)a.setFromMeshFeatures(u,i),a.highlightFeatureId=null;else if(c===null)a.disableFeatureDisplay();else{const f=r[i];a.setFromMeshFeatures(u,i),a.highlightFeatureId=f===null?-1:f}if(a&&s&&s.textureAccessors.length>0){let f=null;if(o.propertyTexture===0)f=a.originalMap;else if(o.propertyTexture===1){const F=s.getPropertyTextureInfo()[0].properties.r3dm_uncertainty_ce90sum;f=s.textures[F.index],f.channel=F.texCoord}else if(o.propertyTexture===2){const F=s.getPropertyTextureInfo()[1].properties.r3dm_uncertainty_le90sum;f=s.textures[F.index],f.channel=F.texCoord}a.map!==f&&(a.map=f,a.needsUpdate=!0)}}))}function H(){requestAnimationFrame(H),p.update(),h.updateMatrixWorld(),ae(),ne();const i=new z,e=new C(0,1,0);l.getBoundingSphere(i),l.group.position.copy(i.center).multiplyScalar(-1),A.quaternion.setFromUnitVectors(i.center.normalize(),e),l.setResolutionFromRenderer(h,T),l.update(),T.render(_,h)} diff --git a/example/bundle/assets/offscreenShadows-DZwmC_J0.js b/example/bundle/assets/offscreenShadows-DZwmC_J0.js new file mode 100644 index 00000000..ba9fa551 --- /dev/null +++ b/example/bundle/assets/offscreenShadows-DZwmC_J0.js @@ -0,0 +1 @@ +import{S as b,W as R,P,a as y,O as v,D as T,A as W,G as A,M as L,B as D,d as E}from"./three.module-DpclfMcJ.js";import{O}from"./OrbitControls-DEr5g9Mg.js";import{g as z}from"./lil-gui.module.min-Bc0DeA9g.js";import{S as B}from"./stats.module--VATS4Kh.js";import{T as H}from"./TilesRenderer-DdUhzUiO.js";import"./I3DMLoader-BlebwdUJ.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-DkJa3Jo5.js";import"./Ellipsoid-Cnb0UTwk.js";import"./B3DMLoader-B2OeBq6-.js";import"./PNTSLoader-BMN5TswI.js";import"./CMPTLoader-nLXQ3OXQ.js";import"./GLTFExtensionLoader-TubLlshp.js";import"./EllipsoidRegion-D6hT1syi.js";let a,p,m,i,e,t,d,c,h,r,w;const u=0,g=1,S=2,s={errorTarget:2,shadowStrategy:u,orthographic:!1};I();x();function F({scene:o}){o.traverse(n=>{n.isMesh&&(n.material=new L,n.castShadow=!0,n.receiveShadow=!0)})}function j(o){o.traverse(n=>{n.isMesh&&n.material.dispose()})}function I(){m=new b,i=new R({antialias:!0}),i.setPixelRatio(window.devicePixelRatio),i.setSize(window.innerWidth,window.innerHeight),i.setClearColor(1383455),i.shadowMap.enabled=!0,i.shadowMap.type=P,document.body.appendChild(i.domElement),a=new y(60,window.innerWidth/window.innerHeight,1,4e3),a.position.set(-56,232,260),t=new v,p=new O(a,i.domElement),p.screenSpacePanning=!1,p.minDistance=1,p.maxDistance=2e3,r=new T(16777215,1.25),r.position.set(-100,40,10),r.castShadow=!0,r.shadow.bias=-1e-4,r.shadow.normalBias=.2,r.shadow.mapSize.setScalar(2048);const o=r.shadow.camera;o.left=-120,o.bottom=-120,o.right=120,o.top=120,o.updateProjectionMatrix(),m.add(r);const n=new W(16777215,.05);m.add(n),c=new D,h=new E,d=new A,m.add(d);const M=window.location.hash.replace(/^#/,"")||"../data/tileset.json";e=new H(M),e.addEventListener("load-model",F),e.addEventListener("dispose-model",j),d.add(e.group),f(),window.addEventListener("resize",f,!1);const l=new z;l.width=300,l.add(s,"orthographic"),l.add(s,"errorTarget").min(0).max(25).step(1),l.add(s,"shadowStrategy",{NONE:u,DISPLAY_ACTIVE_TILES:g,USE_SHADOW_CAMERA:S}),l.open(),w=new B,w.showPanel(0),document.body.appendChild(w.dom)}function f(){a.aspect=window.innerWidth/window.innerHeight,i.setPixelRatio(window.devicePixelRatio),i.setSize(window.innerWidth,window.innerHeight),a.updateProjectionMatrix(),C()}function C(){t.position.copy(a.position),t.rotation.copy(a.rotation);const o=a.position.distanceTo(p.target)/2,n=window.innerWidth/window.innerHeight;t.left=-n*o,t.right=n*o,t.bottom=-o,t.top=o,t.near=a.near,t.far=a.far,t.updateProjectionMatrix()}function x(){switch(requestAnimationFrame(x),e.errorTarget=s.errorTarget,parseFloat(s.shadowStrategy)){case u:e.displayActiveTiles=!1,e.autoDisableRendererCulling=!0,e.deleteCamera(r.shadow.camera);break;case g:e.displayActiveTiles=!0,e.autoDisableRendererCulling=!1,e.deleteCamera(r.shadow.camera);break;case S:e.displayActiveTiles=!1,e.autoDisableRendererCulling=!1,e.setCamera(r.shadow.camera),e.setResolution(r.shadow.camera,r.shadow.mapSize);break}s.orthographic?(e.deleteCamera(a),e.setCamera(t),e.setResolutionFromRenderer(t,i)):(e.deleteCamera(t),e.setCamera(a),e.setResolutionFromRenderer(a,i)),d.rotation.set(0,0,0),s.up==="-Z"&&(d.rotation.x=Math.PI/2),d.updateMatrixWorld(!0),e.getBoundingBox(c)?(c.getCenter(e.group.position),e.group.position.multiplyScalar(-1)):e.getBoundingSphere(h)&&(e.group.position.copy(h.center),e.group.position.multiplyScalar(-1)),window.tiles=e,a.updateMatrixWorld(),t.updateMatrixWorld(),e.update(),_(),w.update()}function _(){C(),i.render(m,s.orthographic?t:a)} diff --git a/example/bundle/assets/pntsExample-PK1MBqfS.js b/example/bundle/assets/pntsExample-PK1MBqfS.js new file mode 100644 index 00000000..034e22ec --- /dev/null +++ b/example/bundle/assets/pntsExample-PK1MBqfS.js @@ -0,0 +1 @@ +import{S as c,W as m,P as l,a as h,D as p,A as f}from"./three.module-DpclfMcJ.js";import{O as u}from"./OrbitControls-DEr5g9Mg.js";import{P as S}from"./PNTSLoader-BMN5TswI.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";let n,a,o,e,i;g();d();function g(){o=new c,e=new m({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=l,document.body.appendChild(e.domElement),n=new h(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(2,2,2),a=new u(n,e.domElement),a.screenSpacePanning=!1,a.minDistance=1,a.maxDistance=2e3,i=new p(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const t=i.shadow.camera;t.left=-200,t.bottom=-200,t.right=200,t.top=200,t.updateProjectionMatrix(),o.add(i);const w=new f(16777215,.05);o.add(w),new S().loadAsync("https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/1.0/TilesetWithRequestVolume/points.pnts").then(s=>{console.log(s),o.add(s.scene)}),r(),window.addEventListener("resize",r,!1)}function r(){n.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix()}function d(){requestAnimationFrame(d),P()}function P(){e.render(o,n)} diff --git a/example/bundle/assets/readMagicBytes-Da5ueiou.js b/example/bundle/assets/readMagicBytes-Da5ueiou.js new file mode 100644 index 00000000..09bab973 --- /dev/null +++ b/example/bundle/assets/readMagicBytes-Da5ueiou.js @@ -0,0 +1 @@ +const y=new TextDecoder;function I(i){return y.decode(i)}function f(i,e,t,s,a,r){let n;switch(s){case"SCALAR":n=1;break;case"VEC2":n=2;break;case"VEC3":n=3;break;case"VEC4":n=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${r}".`)}let c;const o=t*n;switch(a){case"BYTE":c=new Int8Array(i,e,o);break;case"UNSIGNED_BYTE":c=new Uint8Array(i,e,o);break;case"SHORT":c=new Int16Array(i,e,o);break;case"UNSIGNED_SHORT":c=new Uint16Array(i,e,o);break;case"INT":c=new Int32Array(i,e,o);break;case"UNSIGNED_INT":c=new Uint32Array(i,e,o);break;case"FLOAT":c=new Float32Array(i,e,o);break;case"DOUBLE":c=new Float64Array(i,e,o);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${r}".`)}return c}class T{constructor(e,t,s,a){this.buffer=e,this.binOffset=t+s,this.binLength=a;let r=null;if(s!==0){const n=new Uint8Array(e,t,s);r=JSON.parse(I(n))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,s=null,a=null){const r=this.header;if(!(e in r))return null;const n=r[e];if(n instanceof Object){if(Array.isArray(n))return n;{const{buffer:c,binOffset:o,binLength:h}=this,l=n.byteOffset||0,p=n.type||a,b=n.componentType||s;if("type"in n&&a&&n.type!==a)throw new Error("FeatureTable: Specified type does not match expected type.");const u=o+l,d=f(c,u,t,p,b,e);if(u+d.byteLength>o+h)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}else return n}getBuffer(e,t){const{buffer:s,binOffset:a}=this;return s.slice(a+e,a+e+t)}}class g{constructor(e){this.batchTable=e;const t=e.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=t.classes;for(const a of this.classes){const r=a.instances;for(const n in r)a.instances[n]=this._parseProperty(r[n],a.length,n)}if(this.instancesLength=t.instancesLength,this.classIds=this._parseProperty(t.classIds,this.instancesLength,"classIds"),t.parentCounts?this.parentCounts=this._parseProperty(t.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),t.parentIds){const a=this.parentCounts.reduce((r,n)=>r+n,0);this.parentIds=this._parseProperty(t.parentIds,a,"parentIds")}else this.parentIds=null;this.instancesIds=[];const s={};for(const a of this.classIds)s[a]=s[a]??0,this.instancesIds.push(s[a]),s[a]++}_parseProperty(e,t,s){if(Array.isArray(e))return e;{const{buffer:a,binOffset:r}=this.batchTable,n=e.byteOffset,c=e.componentType||"UNSIGNED_SHORT",o=r+n;return f(a,o,t,"SCALAR",c,s)}}getDataFromId(e,t={}){const s=this.parentCounts[e];if(this.parentIds&&s>0){let o=0;for(let h=0;h=this.count)throw new Error(`BatchTable: id value "${e}" out of bounds for "${this.count}" features number.`);for(const s of this.getKeys())s!=="extensions"&&(t[s]=super.getData(s,this.count)[e]);for(const s in this.extensions){const a=this.extensions[s];a.getDataFromId instanceof Function&&(t[s]=t[s]||{},a.getDataFromId(e,t[s]))}return t}getPropertyArray(e){return super.getData(e,this.count)}}function A(i){let e;if(i instanceof DataView?e=i:e=new DataView(i),String.fromCharCode(e.getUint8(0))==="{")return null;let t="";for(let s=0;s<4;s++)t+=String.fromCharCode(e.getUint8(s));return t}export{D as B,T as F,I as a,A as r}; diff --git a/example/bundle/assets/stats.module--VATS4Kh.js b/example/bundle/assets/stats.module--VATS4Kh.js new file mode 100644 index 00000000..74b251dc --- /dev/null +++ b/example/bundle/assets/stats.module--VATS4Kh.js @@ -0,0 +1 @@ +var P=function(){var m=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(n){n.preventDefault(),o(++m%a.children.length)},!1);function i(n){return a.appendChild(n.dom),n}function o(n){for(var l=0;l=r+1e3&&(u.update(e*1e3/(n-r),100),r=n,e=0,h)){var l=performance.memory;h.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){f=this.end()},domElement:a,setMode:o}};P.Panel=function(m,a,i){var o=1/0,f=0,r=Math.round,e=r(window.devicePixelRatio||1),u=80*e,v=48*e,h=3*e,n=2*e,l=3*e,c=15*e,d=74*e,s=30*e,p=document.createElement("canvas");p.width=u,p.height=v,p.style.cssText="width:80px;height:48px";var t=p.getContext("2d");return t.font="bold "+9*e+"px Helvetica,Arial,sans-serif",t.textBaseline="top",t.fillStyle=i,t.fillRect(0,0,u,v),t.fillStyle=a,t.fillText(m,h,n),t.fillRect(l,c,d,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l,c,d,s),{dom:p,update:function(x,S){o=Math.min(o,x),f=Math.max(f,x),t.fillStyle=i,t.globalAlpha=1,t.fillRect(0,0,u,c),t.fillStyle=a,t.fillText(r(x)+" "+m+" ("+r(o)+"-"+r(f)+")",h,n),t.drawImage(p,l+e,c,d-e,s,l,c,d-e,s),t.fillRect(l+d-e,c,e,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l+d-e,c,e,r((1-x/S)*s))}}};export{P as S}; diff --git a/example/bundle/assets/three.module-DpclfMcJ.js b/example/bundle/assets/three.module-DpclfMcJ.js new file mode 100644 index 00000000..646e4153 --- /dev/null +++ b/example/bundle/assets/three.module-DpclfMcJ.js @@ -0,0 +1,3828 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ja="170",mf={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},gf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},hu=0,vl=1,uu=2,_f=3,xf=0,Nl=1,du=2,un=3,Un=0,Ue=1,dn=2,Pn=0,Si=1,yl=2,Ml=3,Sl=4,fu=5,Zn=100,pu=101,mu=102,gu=103,_u=104,xu=200,vu=201,yu=202,Mu=203,ha=204,ua=205,Su=206,bu=207,Eu=208,Tu=209,Au=210,wu=211,Cu=212,Ru=213,Iu=214,da=0,fa=1,pa=2,Ai=3,ma=4,ga=5,_a=6,xa=7,rr=0,Pu=1,Lu=2,Ln=0,Du=1,Uu=2,Nu=3,Fu=4,Ou=5,Bu=6,zu=7,bl="attached",ku="detached",$a=300,Nn=301,Jn=302,Hs=303,Gs=304,hs=306,Ws=1e3,Qe=1001,Xs=1002,be=1003,Fl=1004,vf=1004,ts=1005,yf=1005,xe=1006,Ds=1007,Mf=1007,fn=1008,Sf=1008,_n=1009,Ol=1010,Bl=1011,as=1012,Ka=1013,Fn=1014,He=1015,us=1016,Qa=1017,ja=1018,wi=1020,zl=35902,kl=1021,Vl=1022,De=1023,Hl=1024,Gl=1025,bi=1026,Ci=1027,to=1028,ar=1029,Wl=1030,eo=1031,bf=1032,no=1033,Us=33776,Ns=33777,Fs=33778,Os=33779,va=35840,ya=35841,Ma=35842,Sa=35843,ba=36196,Ea=37492,Ta=37496,Aa=37808,wa=37809,Ca=37810,Ra=37811,Ia=37812,Pa=37813,La=37814,Da=37815,Ua=37816,Na=37817,Fa=37818,Oa=37819,Ba=37820,za=37821,Bs=36492,ka=36494,Va=36495,Xl=36283,Ha=36284,Ga=36285,Wa=36286,Vu=2200,Hu=2201,Gu=2202,qs=2300,Xa=2301,la=2302,xi=2400,vi=2401,Ys=2402,io=2500,ql=2501,Ef=0,Tf=1,Af=2,Wu=3200,Xu=3201,wf=3202,Cf=3203,Kn=0,qu=1,Cn="",ke="srgb",Pi="srgb-linear",or="linear",se="srgb",Rf=0,mi=7680,If=7681,Pf=7682,Lf=7683,Df=34055,Uf=34056,Nf=5386,Ff=512,Of=513,Bf=514,zf=515,kf=516,Vf=517,Hf=518,El=519,Yu=512,Zu=513,Ju=514,Yl=515,$u=516,Ku=517,Qu=518,ju=519,Zs=35044,Gf=35048,Wf=35040,Xf=35045,qf=35049,Yf=35041,Zf=35046,Jf=35050,$f=35042,Kf="100",Tl="300 es",pn=2e3,Js=2001;class xn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,a=i.length;s>8&255]+Te[r>>16&255]+Te[r>>24&255]+"-"+Te[t&255]+Te[t>>8&255]+"-"+Te[t>>16&15|64]+Te[t>>24&255]+"-"+Te[e&63|128]+Te[e>>8&255]+"-"+Te[e>>16&255]+Te[e>>24&255]+Te[n&255]+Te[n>>8&255]+Te[n>>16&255]+Te[n>>24&255]).toLowerCase()}function fe(r,t,e){return Math.max(t,Math.min(e,r))}function Zl(r,t){return(r%t+t)%t}function Qf(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function jf(r,t,e){return r!==t?(e-r)/(t-r):0}function zs(r,t,e){return(1-e)*r+e*t}function tp(r,t,e,n){return zs(r,t,1-Math.exp(-e*n))}function ep(r,t=1){return t-Math.abs(Zl(r,t*2)-t)}function np(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function ip(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function sp(r,t){return r+Math.floor(Math.random()*(t-r+1))}function rp(r,t){return r+Math.random()*(t-r)}function ap(r){return r*(.5-Math.random())}function op(r){r!==void 0&&(Ic=r);let t=Ic+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function lp(r){return r*Ei}function cp(r){return r*os}function hp(r){return(r&r-1)===0&&r!==0}function up(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function dp(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function fp(r,t,e,n,i){const s=Math.cos,a=Math.sin,o=s(e/2),l=a(e/2),c=s((t+n)/2),h=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),f=s((n-t)/2),m=a((n-t)/2);switch(i){case"XYX":r.set(o*h,l*u,l*d,o*c);break;case"YZY":r.set(l*d,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*d,o*h,o*c);break;case"XZX":r.set(o*h,l*m,l*f,o*c);break;case"YXY":r.set(l*f,o*h,l*m,o*c);break;case"ZYZ":r.set(l*m,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Le(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function kt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const pp={DEG2RAD:Ei,RAD2DEG:os,generateUUID:Ze,clamp:fe,euclideanModulo:Zl,mapLinear:Qf,inverseLerp:jf,lerp:zs,damp:tp,pingpong:ep,smoothstep:np,smootherstep:ip,randInt:sp,randFloat:rp,randFloatSpread:ap,seededRandom:op,degToRad:lp,radToDeg:cp,isPowerOfTwo:hp,ceilPowerOfTwo:up,floorPowerOfTwo:dp,setQuaternionFromProperEuler:fp,normalize:kt,denormalize:Le};class ${constructor(t=0,e=0){$.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*i+t.x,this.y=s*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,n,i,s,a,o,l,c){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c)}set(t,e,n,i,s,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],_=i[0],g=i[3],p=i[6],y=i[1],v=i[4],x=i[7],P=i[2],T=i[5],C=i[8];return s[0]=a*_+o*y+l*P,s[3]=a*g+o*v+l*T,s[6]=a*p+o*x+l*C,s[1]=c*_+h*y+u*P,s[4]=c*g+h*v+u*T,s[7]=c*p+h*x+u*C,s[2]=d*_+f*y+m*P,s[5]=d*g+f*v+m*T,s[8]=d*p+f*x+m*C,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*s,f=c*s-a*l,m=e*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/m;return t[0]=u*_,t[1]=(i*c-h*n)*_,t[2]=(o*n-i*a)*_,t[3]=d*_,t[4]=(h*e-i*l)*_,t[5]=(i*s-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*s)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-i*c,i*l,-i*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Po.makeScale(t,e)),this}rotate(t){return this.premultiply(Po.makeRotation(-t)),this}translate(t,e){return this.premultiply(Po.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Po=new Bt;function td(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}const mp={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function es(r,t){return new mp[r](t)}function $s(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function ed(){const r=$s("canvas");return r.style.display="block",r}const Pc={};function Is(r){r in Pc||(Pc[r]=!0,console.warn(r))}function gp(r,t,e){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}function _p(r){const t=r.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function xp(r){const t=r.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const Yt={enabled:!0,workingColorSpace:Pi,spaces:{},convert:function(r,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===se&&(r.r=Dn(r.r),r.g=Dn(r.g),r.b=Dn(r.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(r.applyMatrix3(this.spaces[t].toXYZ),r.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===se&&(r.r=rs(r.r),r.g=rs(r.g),r.b=rs(r.b))),r},fromWorkingColorSpace:function(r,t){return this.convert(r,this.workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Cn?or:this.spaces[r].transfer},getLuminanceCoefficients:function(r,t=this.workingColorSpace){return r.fromArray(this.spaces[t].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,t,e){return r.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}};function Dn(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function rs(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const Lc=[.64,.33,.3,.6,.15,.06],Dc=[.2126,.7152,.0722],Uc=[.3127,.329],Nc=new Bt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Fc=new Bt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);Yt.define({[Pi]:{primaries:Lc,whitePoint:Uc,transfer:or,toXYZ:Nc,fromXYZ:Fc,luminanceCoefficients:Dc,workingColorSpaceConfig:{unpackColorSpace:ke},outputColorSpaceConfig:{drawingBufferColorSpace:ke}},[ke]:{primaries:Lc,whitePoint:Uc,transfer:se,toXYZ:Nc,fromXYZ:Fc,luminanceCoefficients:Dc,outputColorSpaceConfig:{drawingBufferColorSpace:ke}}});let Fi;class nd{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Fi===void 0&&(Fi=$s("canvas")),Fi.width=t.width,Fi.height=t.height;const n=Fi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Fi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=$s("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==$a)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ws:t.x=t.x-Math.floor(t.x);break;case Qe:t.x=t.x<0?0:1;break;case Xs:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Ws:t.y=t.y-Math.floor(t.y);break;case Qe:t.y=t.y<0?0:1;break;case Xs:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}pe.DEFAULT_IMAGE=null;pe.DEFAULT_MAPPING=$a;pe.DEFAULT_ANISOTROPY=1;class Kt{constructor(t=0,e=0,n=0,i=1){Kt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],_=l[2],g=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(c+1)/2,x=(f+1)/2,P=(p+1)/2,T=(h+d)/4,C=(u+_)/4,R=(m+g)/4;return v>x&&v>P?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=C/n):x>P?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=T/i,s=R/i):P<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(P),n=C/s,i=R/s),this.set(n,i,s,e),this}let y=Math.sqrt((g-m)*(g-m)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class id extends xn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Kt(0,0,t,e),this.scissorTest=!1,this.viewport=new Kt(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:xe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new pe(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o=0?1:-1,v=1-p*p;if(v>Number.EPSILON){const P=Math.sqrt(v),T=Math.atan2(P,p*y);g=Math.sin(g*T)/P,o=Math.sin(o*T)/P}const x=o*y;if(l=l*g+d*x,c=c*g+f*x,h=h*g+m*x,u=u*g+_*x,g===1-o){const P=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=P,c*=P,h*=P,u*=P}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],d=s[a+1],f=s[a+2],m=s[a+3];return t[e]=o*m+h*u+l*f-c*d,t[e+1]=l*m+h*d+c*u-o*f,t[e+2]=c*m+h*f+o*d-l*u,t[e+3]=h*m-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,s=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(s-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(fe(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,s=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*t._w+n*t._x+i*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*i+e*this._y,this._z=f*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class w{constructor(t=0,e=0,n=0){w.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Oc.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Oc.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*i-o*n),h=2*(o*e-s*i),u=2*(s*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=i+l*u+s*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Do.copy(this).projectOnVector(t),this.sub(Do)}reflect(t){return this.sub(Do.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Do=new w,Oc=new Ge;class Ne{constructor(t=new w(1/0,1/0,1/0),e=new w(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,en),en.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(xs),xr.subVectors(this.max,xs),Oi.subVectors(t.a,xs),Bi.subVectors(t.b,xs),zi.subVectors(t.c,xs),kn.subVectors(Bi,Oi),Vn.subVectors(zi,Bi),ni.subVectors(Oi,zi);let e=[0,-kn.z,kn.y,0,-Vn.z,Vn.y,0,-ni.z,ni.y,kn.z,0,-kn.x,Vn.z,0,-Vn.x,ni.z,0,-ni.x,-kn.y,kn.x,0,-Vn.y,Vn.x,0,-ni.y,ni.x,0];return!Uo(e,Oi,Bi,zi,xr)||(e=[1,0,0,0,1,0,0,0,1],!Uo(e,Oi,Bi,zi,xr))?!1:(vr.crossVectors(kn,Vn),e=[vr.x,vr.y,vr.z],Uo(e,Oi,Bi,zi,xr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,en).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(en).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Sn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Sn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Sn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Sn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Sn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Sn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Sn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Sn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Sn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Sn=[new w,new w,new w,new w,new w,new w,new w,new w],en=new w,_r=new Ne,Oi=new w,Bi=new w,zi=new w,kn=new w,Vn=new w,ni=new w,xs=new w,xr=new w,vr=new w,ii=new w;function Uo(r,t,e,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){ii.fromArray(r,s);const o=i.x*Math.abs(ii.x)+i.y*Math.abs(ii.y)+i.z*Math.abs(ii.z),l=t.dot(ii),c=e.dot(ii),h=n.dot(ii);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const bp=new Ne,vs=new w,No=new w;class Ce{constructor(t=new w,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):bp.setFromPoints(t).getCenter(n);let i=0;for(let s=0,a=t.length;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;vs.subVectors(t,this.center);const e=vs.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(vs,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(No.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(vs.copy(t.center).add(No)),this.expandByPoint(vs.copy(t.center).sub(No))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bn=new w,Fo=new w,yr=new w,Hn=new w,Oo=new w,Mr=new w,Bo=new w;class ds{constructor(t=new w,e=new w(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,bn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=bn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(bn.copy(this.origin).addScaledVector(this.direction,e),bn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Fo.copy(t).add(e).multiplyScalar(.5),yr.copy(e).sub(t).normalize(),Hn.copy(this.origin).sub(Fo);const s=t.distanceTo(e)*.5,a=-this.direction.dot(yr),o=Hn.dot(this.direction),l=-Hn.dot(yr),c=Hn.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=s*h,u>=0)if(d>=-m)if(d<=m){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Fo).addScaledVector(yr,d),f}intersectSphere(t,e){bn.subVectors(t.center,this.origin);const n=bn.dot(this.direction),i=bn.dot(bn)-n*n,s=t.radius*t.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,bn)!==null}intersectTriangle(t,e,n,i,s){Oo.subVectors(e,t),Mr.subVectors(n,t),Bo.crossVectors(Oo,Mr);let a=this.direction.dot(Bo),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Hn.subVectors(this.origin,t);const l=o*this.direction.dot(Mr.crossVectors(Hn,Mr));if(l<0)return null;const c=o*this.direction.dot(Oo.cross(Hn));if(c<0||l+c>a)return null;const h=-o*Hn.dot(Bo);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Dt{constructor(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){Dt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g)}set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=s,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=_,p[15]=g,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 Dt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/ki.setFromMatrixColumn(t,0).length(),s=1/ki.setFromMatrixColumn(t,1).length(),a=1/ki.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+m*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=m+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d+_*o,e[4]=m*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=m*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-m,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+m,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ep,t,Tp)}lookAt(t,e,n){const i=this.elements;return qe.subVectors(t,e),qe.lengthSq()===0&&(qe.z=1),qe.normalize(),Gn.crossVectors(n,qe),Gn.lengthSq()===0&&(Math.abs(n.z)===1?qe.x+=1e-4:qe.z+=1e-4,qe.normalize(),Gn.crossVectors(n,qe)),Gn.normalize(),Sr.crossVectors(qe,Gn),i[0]=Gn.x,i[4]=Sr.x,i[8]=qe.x,i[1]=Gn.y,i[5]=Sr.y,i[9]=qe.y,i[2]=Gn.z,i[6]=Sr.z,i[10]=qe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],_=n[6],g=n[10],p=n[14],y=n[3],v=n[7],x=n[11],P=n[15],T=i[0],C=i[4],R=i[8],b=i[12],M=i[1],L=i[5],k=i[9],O=i[13],V=i[2],Z=i[6],H=i[10],et=i[14],G=i[3],ot=i[7],mt=i[11],Mt=i[15];return s[0]=a*T+o*M+l*V+c*G,s[4]=a*C+o*L+l*Z+c*ot,s[8]=a*R+o*k+l*H+c*mt,s[12]=a*b+o*O+l*et+c*Mt,s[1]=h*T+u*M+d*V+f*G,s[5]=h*C+u*L+d*Z+f*ot,s[9]=h*R+u*k+d*H+f*mt,s[13]=h*b+u*O+d*et+f*Mt,s[2]=m*T+_*M+g*V+p*G,s[6]=m*C+_*L+g*Z+p*ot,s[10]=m*R+_*k+g*H+p*mt,s[14]=m*b+_*O+g*et+p*Mt,s[3]=y*T+v*M+x*V+P*G,s[7]=y*C+v*L+x*Z+P*ot,s[11]=y*R+v*k+x*H+P*mt,s[15]=y*b+v*O+x*et+P*Mt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],_=t[7],g=t[11],p=t[15];return m*(+s*l*u-i*c*u-s*o*d+n*c*d+i*o*f-n*l*f)+_*(+e*l*f-e*c*d+s*a*d-i*a*f+i*c*h-s*l*h)+g*(+e*c*u-e*o*f-s*a*u+n*a*f+s*o*h-n*c*h)+p*(-i*o*h-e*l*u+e*o*d+i*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],p=t[15],y=u*g*c-_*d*c+_*l*f-o*g*f-u*l*p+o*d*p,v=m*d*c-h*g*c-m*l*f+a*g*f+h*l*p-a*d*p,x=h*_*c-m*u*c+m*o*f-a*_*f-h*o*p+a*u*p,P=m*u*l-h*_*l-m*o*d+a*_*d+h*o*g-a*u*g,T=e*y+n*v+i*x+s*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/T;return t[0]=y*C,t[1]=(_*d*s-u*g*s-_*i*f+n*g*f+u*i*p-n*d*p)*C,t[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*p+n*l*p)*C,t[3]=(u*l*s-o*d*s-u*i*c+n*d*c+o*i*f-n*l*f)*C,t[4]=v*C,t[5]=(h*g*s-m*d*s+m*i*f-e*g*f-h*i*p+e*d*p)*C,t[6]=(m*l*s-a*g*s-m*i*c+e*g*c+a*i*p-e*l*p)*C,t[7]=(a*d*s-h*l*s+h*i*c-e*d*c-a*i*f+e*l*f)*C,t[8]=x*C,t[9]=(m*u*s-h*_*s-m*n*f+e*_*f+h*n*p-e*u*p)*C,t[10]=(a*_*s-m*o*s+m*n*c-e*_*c-a*n*p+e*o*p)*C,t[11]=(h*o*s-a*u*s-h*n*c+e*u*c+a*n*f-e*o*f)*C,t[12]=P*C,t[13]=(h*_*i-m*u*i+m*n*d-e*_*d-h*n*g+e*u*g)*C,t[14]=(m*o*i-a*_*i-m*n*l+e*_*l+a*n*g-e*o*g)*C,t[15]=(a*u*i-h*o*i+h*n*l-e*u*l-a*n*d+e*o*d)*C,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,a=t.x,o=t.y,l=t.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,a){return this.set(1,n,s,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,a=e._y,o=e._z,l=e._w,c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,m=s*u,_=a*h,g=a*u,p=o*u,y=l*c,v=l*h,x=l*u,P=n.x,T=n.y,C=n.z;return i[0]=(1-(_+p))*P,i[1]=(f+x)*P,i[2]=(m-v)*P,i[3]=0,i[4]=(f-x)*T,i[5]=(1-(d+p))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(m+v)*C,i[9]=(g-y)*C,i[10]=(1-(d+_))*C,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let s=ki.set(i[0],i[1],i[2]).length();const a=ki.set(i[4],i[5],i[6]).length(),o=ki.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],nn.copy(this);const c=1/s,h=1/a,u=1/o;return nn.elements[0]*=c,nn.elements[1]*=c,nn.elements[2]*=c,nn.elements[4]*=h,nn.elements[5]*=h,nn.elements[6]*=h,nn.elements[8]*=u,nn.elements[9]*=u,nn.elements[10]*=u,e.setFromRotationMatrix(nn),n.x=s,n.y=a,n.z=o,this}makePerspective(t,e,n,i,s,a,o=pn){const l=this.elements,c=2*s/(e-t),h=2*s/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let f,m;if(o===pn)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Js)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,a,o=pn){const l=this.elements,c=1/(e-t),h=1/(n-i),u=1/(a-s),d=(e+t)*c,f=(n+i)*h;let m,_;if(o===pn)m=(a+s)*u,_=-2*u;else if(o===Js)m=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ki=new w,nn=new Dt,Ep=new w(0,0,0),Tp=new w(1,1,1),Gn=new w,Sr=new w,qe=new w,Bc=new Dt,zc=new Ge;class Je{constructor(t=0,e=0,n=0,i=Je.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Bc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Bc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return zc.setFromEuler(this),this.setFromQuaternion(zc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Je.DEFAULT_ORDER="XYZ";class ro{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){sn.subVectors(i,e),Tn.subVectors(n,e),ko.subVectors(t,e);const a=sn.dot(sn),o=sn.dot(Tn),l=sn.dot(ko),c=Tn.dot(Tn),h=Tn.dot(ko),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,m=(a*h-o*l)*d;return s.set(1-f-m,m,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,An)===null?!1:An.x>=0&&An.y>=0&&An.x+An.y<=1}static getInterpolation(t,e,n,i,s,a,o,l){return this.getBarycoord(t,e,n,i,An)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,An.x),l.addScaledVector(a,An.y),l.addScaledVector(o,An.z),l)}static getInterpolatedAttribute(t,e,n,i,s,a){return Wo.setScalar(0),Xo.setScalar(0),qo.setScalar(0),Wo.fromBufferAttribute(t,e),Xo.fromBufferAttribute(t,n),qo.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Wo,s.x),a.addScaledVector(Xo,s.y),a.addScaledVector(qo,s.z),a}static isFrontFacing(t,e,n,i){return sn.subVectors(n,e),Tn.subVectors(t,e),sn.cross(Tn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return sn.subVectors(this.c,this.b),Tn.subVectors(this.a,this.b),sn.cross(Tn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return Ve.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let a,o;Gi.subVectors(i,n),Wi.subVectors(s,n),Vo.subVectors(t,n);const l=Gi.dot(Vo),c=Wi.dot(Vo);if(l<=0&&c<=0)return e.copy(n);Ho.subVectors(t,i);const h=Gi.dot(Ho),u=Wi.dot(Ho);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Gi,a);Go.subVectors(t,s);const f=Gi.dot(Go),m=Wi.dot(Go);if(m>=0&&f<=m)return e.copy(s);const _=f*c-l*m;if(_<=0&&c>=0&&m<=0)return o=c/(c-m),e.copy(n).addScaledVector(Wi,o);const g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return Xc.subVectors(s,i),o=(u-h)/(u-h+(f-m)),e.copy(i).addScaledVector(Xc,o);const p=1/(g+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector(Gi,a).addScaledVector(Wi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const sd={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},Wn={h:0,s:0,l:0},Er={h:0,s:0,l:0};function Yo(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class pt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ke){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Yt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Yt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Yt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Yt.workingColorSpace){if(t=Zl(t,1),e=fe(e,0,1),n=fe(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=Yo(a,s,t+1/3),this.g=Yo(a,s,t),this.b=Yo(a,s,t-1/3)}return Yt.toWorkingColorSpace(this,i),this}setStyle(t,e=ke){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ke){const n=sd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Dn(t.r),this.g=Dn(t.g),this.b=Dn(t.b),this}copyLinearToSRGB(t){return this.r=rs(t.r),this.g=rs(t.g),this.b=rs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ke){return Yt.fromWorkingColorSpace(Ae.copy(this),t),Math.round(fe(Ae.r*255,0,255))*65536+Math.round(fe(Ae.g*255,0,255))*256+Math.round(fe(Ae.b*255,0,255))}getHexString(t=ke){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Yt.workingColorSpace){Yt.fromWorkingColorSpace(Ae.copy(this),e);const n=Ae.r,i=Ae.g,s=Ae.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-s)/u+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Si&&(n.blending=this.blending),this.side!==Un&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ha&&(n.blendSrc=this.blendSrc),this.blendDst!==ua&&(n.blendDst=this.blendDst),this.blendEquation!==Zn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ai&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==El&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==mi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==mi&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(e){const s=i(t.textures),a=i(t.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Qn extends Re{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=rr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Rn=Pp();function Pp(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;!(c&8388608);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function ze(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=fe(r,-65504,65504),Rn.floatView[0]=r;const t=Rn.uint32View[0],e=t>>23&511;return Rn.baseTable[e]+((t&8388607)>>Rn.shiftTable[e])}function Ps(r){const t=r>>10;return Rn.uint32View[0]=Rn.mantissaTable[Rn.offsetTable[t]+(r&1023)]+Rn.exponentTable[t],Rn.floatView[0]}const Lp={toHalfFloat:ze,fromHalfFloat:Ps},ge=new w,Tr=new $;class re{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Zs,this.updateRanges=[],this.gpuType=He,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ne);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s(t.far-t.near)**2))&&(qc.copy(s).invert(),si.copy(t.ray).applyMatrix4(qc),!(n.boundingBox!==null&&si.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,si)))}_computeIntersections(t,e,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,_=d.length;m<_;m++){const g=d[m],p=a[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let x=y,P=v;xe.far?null:{distance:c,point:Pr.clone(),object:r}}function Lr(r,t,e,n,i,s,a,o,l,c){r.getVertexPosition(o,wr),r.getVertexPosition(l,Cr),r.getVertexPosition(c,Rr);const h=kp(r,t,e,n,wr,Cr,Rr,Zc);if(h){const u=new w;Ve.getBarycoord(Zc,wr,Cr,Rr,u),i&&(h.uv=Ve.getInterpolatedAttribute(i,o,l,c,u,new $)),s&&(h.uv1=Ve.getInterpolatedAttribute(s,o,l,c,u,new $)),a&&(h.normal=Ve.getInterpolatedAttribute(a,o,l,c,u,new w),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new w,materialIndex:0};Ve.getNormal(wr,Cr,Rr,d.normal),h.face=d,h.barycoord=u}return h}class Li extends Wt{constructor(t=1,e=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,s,0),m("z","y","x",1,-1,n,e,-t,a,s,1),m("x","z","y",1,1,t,n,e,i,a,2),m("x","z","y",1,-1,t,n,-e,i,a,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new St(c,3)),this.setAttribute("normal",new St(h,3)),this.setAttribute("uv",new St(u,2));function m(_,g,p,y,v,x,P,T,C,R,b){const M=x/C,L=P/R,k=x/2,O=P/2,V=T/2,Z=C+1,H=R+1;let et=0,G=0;const ot=new w;for(let mt=0;mt0?1:-1,h.push(ot.x,ot.y,ot.z),u.push(zt/C),u.push(1-mt/R),et+=1}}for(let mt=0;mt0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class ao extends Qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Dt,this.projectionMatrix=new Dt,this.projectionMatrixInverse=new Dt,this.coordinateSystem=pn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Xn=new w,Jc=new $,$c=new $;class Se extends ao{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=os*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Ei*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return os*2*Math.atan(Math.tan(Ei*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Xn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Xn.x,Xn.y).multiplyScalar(-t/Xn.z),Xn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Xn.x,Xn.y).multiplyScalar(-t/Xn.z)}getViewSize(t,e){return this.getViewBounds(t,Jc,$c),e.subVectors($c,Jc)}setViewOffset(t,e,n,i,s,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Ei*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,e-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const qi=-90,Yi=1;class od extends Qt{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Se(qi,Yi,t,e);i.layers=this.layers,this.add(i);const s=new Se(qi,Yi,t,e);s.layers=this.layers,this.add(s);const a=new Se(qi,Yi,t,e);a.layers=this.layers,this.add(a);const o=new Se(qi,Yi,t,e);o.layers=this.layers,this.add(o);const l=new Se(qi,Yi,t,e);l.layers=this.layers,this.add(l);const c=new Se(qi,Yi,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,a,o,l]=e;for(const c of e)this.remove(c);if(t===pn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Js)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,s),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,l),t.setRenderTarget(n,4,i),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class lr extends pe{constructor(t,e,n,i,s,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:Nn,super(t,e,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ld extends an{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new lr(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:xe}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + 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 ); + + } + `},i=new Li(5,5,5),s=new on({name:"CubemapFromEquirect",uniforms:ls(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ue,blending:Pn});s.uniforms.tEquirect.value=e;const a=new _e(i,s),o=e.minFilter;return e.minFilter===fn&&(e.minFilter=xe),new od(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(s)}}const $o=new w,Wp=new w,Xp=new Bt;class Yn{constructor(t=new w(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=$o.subVectors(n,e).cross(Wp.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta($o),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Xp.getNormalMatrix(t),i=this.coplanarPoint($o).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ri=new Ce,Dr=new w;class cr{constructor(t=new Yn,e=new Yn,n=new Yn,i=new Yn,s=new Yn,a=new Yn){this.planes=[t,e,n,i,s,a]}set(t,e,n,i,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=pn){const n=this.planes,i=t.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],f=i[8],m=i[9],_=i[10],g=i[11],p=i[12],y=i[13],v=i[14],x=i[15];if(n[0].setComponents(l-s,d-c,g-f,x-p).normalize(),n[1].setComponents(l+s,d+c,g+f,x+p).normalize(),n[2].setComponents(l+a,d+h,g+m,x+y).normalize(),n[3].setComponents(l-a,d-h,g-m,x-y).normalize(),n[4].setComponents(l-o,d-u,g-_,x-v).normalize(),e===pn)n[5].setComponents(l+o,d+u,g+_,x+v).normalize();else if(e===Js)n[5].setComponents(o,u,_,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ri.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ri.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ri)}intersectsSprite(t){return ri.center.set(0,0,0),ri.radius=.7071067811865476,ri.applyMatrix4(t.matrixWorld),this.intersectsSphere(ri)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)0?t.max.x:t.min.x,Dr.y=i.normal.y>0?t.max.y:t.min.y,Dr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Dr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function cd(){let r=null,t=!1,e=null,n=null;function i(s,a){e(s,a),n=r.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=r.requestAnimationFrame(i),t=!0)},stop:function(){r.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){r=s}}}function qp(r){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=r.createBuffer();r.bindBuffer(l,d),r.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=r.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=r.HALF_FLOAT:f=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=r.SHORT;else if(c instanceof Uint32Array)f=r.UNSIGNED_INT;else if(c instanceof Int32Array)f=r.INT;else if(c instanceof Int8Array)f=r.BYTE;else if(c instanceof Uint8Array)f=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(r.bindBuffer(c,o),u.length===0)r.bufferSubData(c,0,h);else{u.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #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 +#endif`,cm=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,hm=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,um=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,dm=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,fm=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,pm=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,mm=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,gm=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +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`,_m=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,xm=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,vm=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,ym=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Mm=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Sm=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,bm="gl_FragColor = linearToOutputTexel( gl_FragColor );",Em=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,Tm=`#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, envMapRotation * 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`,Am=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,wm=`#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`,Cm=`#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`,Rm=`#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`,Im=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Pm=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Lm=`#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`,Dm=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Um=`#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 +}`,Nm=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Fm=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Om=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Bm=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,zm=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,km=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Vm=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Hm=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Gm=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Wm=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,Xm=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,qm=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Ym=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,Zm=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,Jm=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,$m=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Km=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Qm=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,jm=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,tg=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,eg=`#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`,ng=`#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`,ig=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,sg=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,rg=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,ag=`#if defined( USE_MORPHCOLORS ) + 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`,og=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,lg=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + 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 ); + } +#endif`,cg=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,hg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,ug=`#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`,dg=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,fg=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,pg=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,mg=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,gg=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,_g=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,xg=`#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`,vg=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,yg=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Mg=`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 float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in 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( const in 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 ); +}`,Sg=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,bg=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Eg=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Tg=`#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`,Ag=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,wg=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,Cg=`#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 shadowIntensity; + 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 shadowIntensity; + 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 shadowIntensity; + 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 shadowIntensity, 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 mix( 1.0, shadow, shadowIntensity ); + } + 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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + 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 + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,Rg=`#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 shadowIntensity; + 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 shadowIntensity; + 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 shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Ig=`#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`,Pg=`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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Lg=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,Dg=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Ug=`#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`,Ng=`#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`,Fg=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Og=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Bg=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,zg=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,kg=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Vg=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], 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 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + + #else + + 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; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Hg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Gg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Wg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,Xg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const qg=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,Yg=`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 +}`,Zg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Jg=`#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; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,$g=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Kg=`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 +}`,Qg=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,jg=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,t_=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,e_=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,n_=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,i_=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,s_=`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 + #include +}`,r_=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,a_=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,o_=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,l_=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,c_=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,h_=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,u_=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,d_=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,f_=`#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() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,p_=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,m_=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,g_=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,__=`#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_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,x_=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,v_=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + 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 +}`,y_=`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 + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,M_=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,S_=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,b_=`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 +}`,E_=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #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 +}`,T_=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Gt={alphahash_fragment:Yp,alphahash_pars_fragment:Zp,alphamap_fragment:Jp,alphamap_pars_fragment:$p,alphatest_fragment:Kp,alphatest_pars_fragment:Qp,aomap_fragment:jp,aomap_pars_fragment:tm,batching_pars_vertex:em,batching_vertex:nm,begin_vertex:im,beginnormal_vertex:sm,bsdfs:rm,iridescence_fragment:am,bumpmap_pars_fragment:om,clipping_planes_fragment:lm,clipping_planes_pars_fragment:cm,clipping_planes_pars_vertex:hm,clipping_planes_vertex:um,color_fragment:dm,color_pars_fragment:fm,color_pars_vertex:pm,color_vertex:mm,common:gm,cube_uv_reflection_fragment:_m,defaultnormal_vertex:xm,displacementmap_pars_vertex:vm,displacementmap_vertex:ym,emissivemap_fragment:Mm,emissivemap_pars_fragment:Sm,colorspace_fragment:bm,colorspace_pars_fragment:Em,envmap_fragment:Tm,envmap_common_pars_fragment:Am,envmap_pars_fragment:wm,envmap_pars_vertex:Cm,envmap_physical_pars_fragment:zm,envmap_vertex:Rm,fog_vertex:Im,fog_pars_vertex:Pm,fog_fragment:Lm,fog_pars_fragment:Dm,gradientmap_pars_fragment:Um,lightmap_pars_fragment:Nm,lights_lambert_fragment:Fm,lights_lambert_pars_fragment:Om,lights_pars_begin:Bm,lights_toon_fragment:km,lights_toon_pars_fragment:Vm,lights_phong_fragment:Hm,lights_phong_pars_fragment:Gm,lights_physical_fragment:Wm,lights_physical_pars_fragment:Xm,lights_fragment_begin:qm,lights_fragment_maps:Ym,lights_fragment_end:Zm,logdepthbuf_fragment:Jm,logdepthbuf_pars_fragment:$m,logdepthbuf_pars_vertex:Km,logdepthbuf_vertex:Qm,map_fragment:jm,map_pars_fragment:tg,map_particle_fragment:eg,map_particle_pars_fragment:ng,metalnessmap_fragment:ig,metalnessmap_pars_fragment:sg,morphinstance_vertex:rg,morphcolor_vertex:ag,morphnormal_vertex:og,morphtarget_pars_vertex:lg,morphtarget_vertex:cg,normal_fragment_begin:hg,normal_fragment_maps:ug,normal_pars_fragment:dg,normal_pars_vertex:fg,normal_vertex:pg,normalmap_pars_fragment:mg,clearcoat_normal_fragment_begin:gg,clearcoat_normal_fragment_maps:_g,clearcoat_pars_fragment:xg,iridescence_pars_fragment:vg,opaque_fragment:yg,packing:Mg,premultiplied_alpha_fragment:Sg,project_vertex:bg,dithering_fragment:Eg,dithering_pars_fragment:Tg,roughnessmap_fragment:Ag,roughnessmap_pars_fragment:wg,shadowmap_pars_fragment:Cg,shadowmap_pars_vertex:Rg,shadowmap_vertex:Ig,shadowmask_pars_fragment:Pg,skinbase_vertex:Lg,skinning_pars_vertex:Dg,skinning_vertex:Ug,skinnormal_vertex:Ng,specularmap_fragment:Fg,specularmap_pars_fragment:Og,tonemapping_fragment:Bg,tonemapping_pars_fragment:zg,transmission_fragment:kg,transmission_pars_fragment:Vg,uv_pars_fragment:Hg,uv_pars_vertex:Gg,uv_vertex:Wg,worldpos_vertex:Xg,background_vert:qg,background_frag:Yg,backgroundCube_vert:Zg,backgroundCube_frag:Jg,cube_vert:$g,cube_frag:Kg,depth_vert:Qg,depth_frag:jg,distanceRGBA_vert:t_,distanceRGBA_frag:e_,equirect_vert:n_,equirect_frag:i_,linedashed_vert:s_,linedashed_frag:r_,meshbasic_vert:a_,meshbasic_frag:o_,meshlambert_vert:l_,meshlambert_frag:c_,meshmatcap_vert:h_,meshmatcap_frag:u_,meshnormal_vert:d_,meshnormal_frag:f_,meshphong_vert:p_,meshphong_frag:m_,meshphysical_vert:g_,meshphysical_frag:__,meshtoon_vert:x_,meshtoon_frag:v_,points_vert:y_,points_frag:M_,shadow_vert:S_,shadow_frag:b_,sprite_vert:E_,sprite_frag:T_},lt={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new $(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new $(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},rn={basic:{uniforms:Pe([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.fog]),vertexShader:Gt.meshbasic_vert,fragmentShader:Gt.meshbasic_frag},lambert:{uniforms:Pe([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new pt(0)}}]),vertexShader:Gt.meshlambert_vert,fragmentShader:Gt.meshlambert_frag},phong:{uniforms:Pe([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30}}]),vertexShader:Gt.meshphong_vert,fragmentShader:Gt.meshphong_frag},standard:{uniforms:Pe([lt.common,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.roughnessmap,lt.metalnessmap,lt.fog,lt.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag},toon:{uniforms:Pe([lt.common,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.gradientmap,lt.fog,lt.lights,{emissive:{value:new pt(0)}}]),vertexShader:Gt.meshtoon_vert,fragmentShader:Gt.meshtoon_frag},matcap:{uniforms:Pe([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,{matcap:{value:null}}]),vertexShader:Gt.meshmatcap_vert,fragmentShader:Gt.meshmatcap_frag},points:{uniforms:Pe([lt.points,lt.fog]),vertexShader:Gt.points_vert,fragmentShader:Gt.points_frag},dashed:{uniforms:Pe([lt.common,lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Gt.linedashed_vert,fragmentShader:Gt.linedashed_frag},depth:{uniforms:Pe([lt.common,lt.displacementmap]),vertexShader:Gt.depth_vert,fragmentShader:Gt.depth_frag},normal:{uniforms:Pe([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,{opacity:{value:1}}]),vertexShader:Gt.meshnormal_vert,fragmentShader:Gt.meshnormal_frag},sprite:{uniforms:Pe([lt.sprite,lt.fog]),vertexShader:Gt.sprite_vert,fragmentShader:Gt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Gt.background_vert,fragmentShader:Gt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Bt}},vertexShader:Gt.backgroundCube_vert,fragmentShader:Gt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Gt.cube_vert,fragmentShader:Gt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Gt.equirect_vert,fragmentShader:Gt.equirect_frag},distanceRGBA:{uniforms:Pe([lt.common,lt.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Gt.distanceRGBA_vert,fragmentShader:Gt.distanceRGBA_frag},shadow:{uniforms:Pe([lt.lights,lt.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:Gt.shadow_vert,fragmentShader:Gt.shadow_frag}};rn.physical={uniforms:Pe([rn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new $(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new $},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new $},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag};const Ur={r:0,b:0,g:0},ai=new Je,A_=new Dt;function w_(r,t,e,n,i,s,a){const o=new pt(0);let l=s===!0?0:1,c,h,u=null,d=0,f=null;function m(y){let v=y.isScene===!0?y.background:null;return v&&v.isTexture&&(v=(y.backgroundBlurriness>0?e:t).get(v)),v}function _(y){let v=!1;const x=m(y);x===null?p(o,l):x&&x.isColor&&(p(x,1),v=!0);const P=r.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function g(y,v){const x=m(v);x&&(x.isCubeTexture||x.mapping===hs)?(h===void 0&&(h=new _e(new Li(1,1,1),new on({name:"BackgroundCubeMaterial",uniforms:ls(rn.backgroundCube.uniforms),vertexShader:rn.backgroundCube.vertexShader,fragmentShader:rn.backgroundCube.fragmentShader,side:Ue,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,T,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),ai.copy(v.backgroundRotation),ai.x*=-1,ai.y*=-1,ai.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(ai.y*=-1,ai.z*=-1),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(A_.makeRotationFromEuler(ai)),h.material.toneMapped=Yt.getTransfer(x.colorSpace)!==se,(u!==x||d!==x.version||f!==r.toneMapping)&&(h.material.needsUpdate=!0,u=x,d=x.version,f=r.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new _e(new fs(2,2),new on({name:"BackgroundMaterial",uniforms:ls(rn.background.uniforms),vertexShader:rn.background.vertexShader,fragmentShader:rn.background.fragmentShader,side:Un,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=Yt.getTransfer(x.colorSpace)!==se,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||d!==x.version||f!==r.toneMapping)&&(c.material.needsUpdate=!0,u=x,d=x.version,f=r.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function p(y,v){y.getRGB(Ur,rd(r)),n.buffers.color.setClear(Ur.r,Ur.g,Ur.b,v,a)}return{getClearColor:function(){return o},setClearColor:function(y,v=1){o.set(y),l=v,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,p(o,l)},render:_,addToRenderList:g}}function C_(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=d(null);let s=i,a=!1;function o(M,L,k,O,V){let Z=!1;const H=u(O,k,L);s!==H&&(s=H,c(s.object)),Z=f(M,O,k,V),Z&&m(M,O,k,V),V!==null&&t.update(V,r.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,x(M,L,k,O),V!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function l(){return r.createVertexArray()}function c(M){return r.bindVertexArray(M)}function h(M){return r.deleteVertexArray(M)}function u(M,L,k){const O=k.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let Z=V[L.id];Z===void 0&&(Z={},V[L.id]=Z);let H=Z[O];return H===void 0&&(H=d(l()),Z[O]=H),H}function d(M){const L=[],k=[],O=[];for(let V=0;V=0){const mt=V[G];let Mt=Z[G];if(Mt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(Mt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(Mt=M.instanceColor)),mt===void 0||mt.attribute!==Mt||Mt&&mt.data!==Mt.data)return!0;H++}return s.attributesNum!==H||s.index!==O}function m(M,L,k,O){const V={},Z=L.attributes;let H=0;const et=k.getAttributes();for(const G in et)if(et[G].location>=0){let mt=Z[G];mt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(mt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(mt=M.instanceColor));const Mt={};Mt.attribute=mt,mt&&mt.data&&(Mt.data=mt.data),V[G]=Mt,H++}s.attributes=V,s.attributesNum=H,s.index=O}function _(){const M=s.newAttributes;for(let L=0,k=M.length;L=0){let ot=V[et];if(ot===void 0&&(et==="instanceMatrix"&&M.instanceMatrix&&(ot=M.instanceMatrix),et==="instanceColor"&&M.instanceColor&&(ot=M.instanceColor)),ot!==void 0){const mt=ot.normalized,Mt=ot.itemSize,zt=t.get(ot);if(zt===void 0)continue;const te=zt.buffer,Y=zt.type,it=zt.bytesPerElement,bt=Y===r.INT||Y===r.UNSIGNED_INT||ot.gpuType===Ka;if(ot.isInterleavedBufferAttribute){const rt=ot.data,It=rt.stride,Ft=ot.offset;if(rt.isInstancedInterleavedBuffer){for(let Ut=0;Ut0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),p=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),P=m>0,T=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:P,maxSamples:T}}function P_(r){const t=this;let e=null,n=0,i=!1,s=!1;const a=new Yn,o=new Bt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,p=r.get(u);if(!i||m===null||m.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,v=y*4;let x=p.clippingState||null;l.value=x,x=h(m,d,v,f);for(let P=0;P!==v;++P)x[P]=e[P];p.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,m!==!0||g===null){const p=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){const c=new ld(l.height);return c.fromEquirectangularTexture(r,a),t.set(a,c),a.addEventListener("dispose",i),e(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}class oo extends ao{constructor(t=-1,e=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const ns=4,Kc=[.125,.215,.35,.446,.526,.582],_i=20,Ko=new oo,Qc=new pt;let Qo=null,jo=0,tl=0,el=!1;const gi=(1+Math.sqrt(5))/2,Zi=1/gi,jc=[new w(-gi,Zi,0),new w(gi,Zi,0),new w(-Zi,0,gi),new w(Zi,0,gi),new w(0,gi,-Zi),new w(0,gi,Zi),new w(-1,1,-1),new w(1,1,-1),new w(-1,1,1),new w(1,1,1)];class Al{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){Qo=this._renderer.getRenderTarget(),jo=this._renderer.getActiveCubeFace(),tl=this._renderer.getActiveMipmapLevel(),el=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=eh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?v:0,v,v),h.setRenderTarget(i),_&&h.render(m,o),h.render(t,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=g}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Nn||t.mapping===Jn;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=nh()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=eh());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new _e(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=t;const l=this._cubeSize;Nr(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Ko)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s_i&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${_i}`);const p=[];let y=0;for(let C=0;C<_i;++C){const R=C/_,b=Math.exp(-R*R/2);p.push(b),C===0?y+=b:Cv-ns?i-v+ns:0),T=4*(this._cubeSize-x);Nr(e,P,T,3*x,2*x),l.setRenderTarget(e),l.render(u,Ko)}}function D_(r){const t=[],e=[],n=[];let i=r;const s=r-ns+1+Kc.length;for(let a=0;ar-ns?l=Kc[a-r+ns-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,_=3,g=2,p=1,y=new Float32Array(_*m*f),v=new Float32Array(g*m*f),x=new Float32Array(p*m*f);for(let T=0;T2?0:-1,b=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];y.set(b,_*m*T),v.set(d,g*m*T);const M=[T,T,T,T,T,T];x.set(M,p*m*T)}const P=new Wt;P.setAttribute("position",new re(y,_)),P.setAttribute("uv",new re(v,g)),P.setAttribute("faceIndex",new re(x,p)),t.push(P),i>ns&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function th(r,t,e){const n=new an(r,t,e);return n.texture.mapping=hs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Nr(r,t,e,n,i){r.viewport.set(t,e,n,i),r.scissor.set(t,e,n,i)}function U_(r,t,e){const n=new Float32Array(_i),i=new w(0,1,0);return new on({name:"SphericalGaussianBlur",defines:{n:_i,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ql(),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:Pn,depthTest:!1,depthWrite:!1})}function eh(){return new on({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ql(),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:Pn,depthTest:!1,depthWrite:!1})}function nh(){return new on({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ql(),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:Pn,depthTest:!1,depthWrite:!1})}function Ql(){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 N_(r){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Hs||l===Gs,h=l===Nn||l===Jn;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new Al(r)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&i(f)?(e===null&&(e=new Al(r)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function i(o){let l=0;const c=6;for(let h=0;ht.maxTextureSize&&(P=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const T=new Float32Array(x*P*4*u),C=new so(T,x,P,u);C.type=He,C.needsUpdate=!0;const R=v*4;for(let M=0;M0)return r;const i=t*e;let s=sh[i];if(s===void 0&&(s=new Float32Array(i),sh[i]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,r[a].toArray(s,o)}return s}function ve(r,t){if(r.length!==t.length)return!1;for(let e=0,n=r.length;e":" "} ${o}: ${e[a]}`)}return n.join(` +`)}const uh=new Bt;function N0(r){Yt._getMatrix(uh,Yt.workingColorSpace,r);const t=`mat3( ${uh.elements.map(e=>e.toFixed(4))} )`;switch(Yt.getTransfer(r)){case or:return[t,"LinearTransferOETF"];case se:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",r),[t,"LinearTransferOETF"]}}function dh(r,t,e){const n=r.getShaderParameter(t,r.COMPILE_STATUS),i=r.getShaderInfoLog(t).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return e.toUpperCase()+` + +`+i+` + +`+U0(r.getShaderSource(t),a)}else return i}function F0(r,t){const e=N0(t);return[`vec4 ${r}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` +`)}function O0(r,t){let e;switch(t){case Du:e="Linear";break;case Uu:e="Reinhard";break;case Nu:e="Cineon";break;case Fu:e="ACESFilmic";break;case Bu:e="AgX";break;case zu:e="Neutral";break;case Ou:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Fr=new w;function B0(){Yt.getLuminanceCoefficients(Fr);const r=Fr.x.toFixed(4),t=Fr.y.toFixed(4),e=Fr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` +`)}function z0(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ls).join(` +`)}function k0(r){const t=[];for(const e in r){const n=r[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` +`)}function V0(r,t){const e={},n=r.getProgramParameter(t,r.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function wl(r){return r.replace(H0,W0)}const G0=new Map;function W0(r,t){let e=Gt[t];if(e===void 0){const n=G0.get(t);if(n!==void 0)e=Gt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return wl(e)}const X0=/#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 mh(r){return r.replace(X0,q0)}function q0(r,t,e,n){let i="";for(let s=parseInt(t);s0&&(g+=` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Ls).join(` +`),p.length>0&&(p+=` +`)):(g=[gh(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Ls).join(` +`),p=[gh(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Ln?"#define TONE_MAPPING":"",e.toneMapping!==Ln?Gt.tonemapping_pars_fragment:"",e.toneMapping!==Ln?O0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Gt.colorspace_pars_fragment,F0("linearToOutputTexel",e.outputColorSpace),B0(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Ls).join(` +`)),a=wl(a),a=fh(a,e),a=ph(a,e),o=wl(o),o=fh(o,e),o=ph(o,e),a=mh(a),o=mh(o),e.isRawShaderMaterial!==!0&&(y=`#version 300 es +`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,p=["#define varying in",e.glslVersion===Tl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Tl?"":"#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(` +`)+` +`+p);const v=y+g+a,x=y+p+o,P=hh(i,i.VERTEX_SHADER,v),T=hh(i,i.FRAGMENT_SHADER,x);i.attachShader(_,P),i.attachShader(_,T),e.index0AttributeName!==void 0?i.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function C(L){if(r.debug.checkShaderErrors){const k=i.getProgramInfoLog(_).trim(),O=i.getShaderInfoLog(P).trim(),V=i.getShaderInfoLog(T).trim();let Z=!0,H=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(Z=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,P,T);else{const et=dh(i,P,"vertex"),G=dh(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+k+` +`+et+` +`+G)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||V==="")&&(H=!1);H&&(L.diagnostics={runnable:Z,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:V,prefix:p}})}i.deleteShader(P),i.deleteShader(T),R=new ca(i,_),b=V0(i,_)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let b;this.getAttributes=function(){return b===void 0&&C(this),b};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(_,L0)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=D0++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=P,this.fragmentShader=T,this}let j0=0;class tx{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new ex(t),e.set(t,n)),n}}class ex{constructor(t){this.id=j0++,this.code=t,this.usedTimes=0}}function nx(r,t,e,n,i,s,a){const o=new ro,l=new tx,c=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(b){return c.add(b),b===0?"uv":`uv${b}`}function g(b,M,L,k,O){const V=k.fog,Z=O.geometry,H=b.isMeshStandardMaterial?k.environment:null,et=(b.isMeshStandardMaterial?e:t).get(b.envMap||H),G=et&&et.mapping===hs?et.image.height:null,ot=m[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));const mt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,Mt=mt!==void 0?mt.length:0;let zt=0;Z.morphAttributes.position!==void 0&&(zt=1),Z.morphAttributes.normal!==void 0&&(zt=2),Z.morphAttributes.color!==void 0&&(zt=3);let te,Y,it,bt;if(ot){const ie=rn[ot];te=ie.vertexShader,Y=ie.fragmentShader}else te=b.vertexShader,Y=b.fragmentShader,l.update(b),it=l.getVertexShaderID(b),bt=l.getFragmentShaderID(b);const rt=r.getRenderTarget(),It=r.state.buffers.depth.getReversed(),Ft=O.isInstancedMesh===!0,Ut=O.isBatchedMesh===!0,Jt=!!b.map,K=!!b.matcap,nt=!!et,I=!!b.aoMap,Ct=!!b.lightMap,j=!!b.bumpMap,xt=!!b.normalMap,at=!!b.displacementMap,Pt=!!b.emissiveMap,gt=!!b.metalnessMap,A=!!b.roughnessMap,S=b.anisotropy>0,F=b.clearcoat>0,X=b.dispersion>0,Q=b.iridescence>0,q=b.sheen>0,Et=b.transmission>0,ct=S&&!!b.anisotropyMap,_t=F&&!!b.clearcoatMap,qt=F&&!!b.clearcoatNormalMap,tt=F&&!!b.clearcoatRoughnessMap,vt=Q&&!!b.iridescenceMap,Lt=Q&&!!b.iridescenceThicknessMap,Nt=q&&!!b.sheenColorMap,yt=q&&!!b.sheenRoughnessMap,Zt=!!b.specularMap,Xt=!!b.specularColorMap,ae=!!b.specularIntensityMap,D=Et&&!!b.transmissionMap,ht=Et&&!!b.thicknessMap,W=!!b.gradientMap,J=!!b.alphaMap,ft=b.alphaTest>0,ut=!!b.alphaHash,Vt=!!b.extensions;let ue=Ln;b.toneMapped&&(rt===null||rt.isXRRenderTarget===!0)&&(ue=r.toneMapping);const Ee={shaderID:ot,shaderType:b.type,shaderName:b.name,vertexShader:te,fragmentShader:Y,defines:b.defines,customVertexShaderID:it,customFragmentShaderID:bt,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:Ut,batchingColor:Ut&&O._colorsTexture!==null,instancing:Ft,instancingColor:Ft&&O.instanceColor!==null,instancingMorph:Ft&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:rt===null?r.outputColorSpace:rt.isXRRenderTarget===!0?rt.texture.colorSpace:Pi,alphaToCoverage:!!b.alphaToCoverage,map:Jt,matcap:K,envMap:nt,envMapMode:nt&&et.mapping,envMapCubeUVHeight:G,aoMap:I,lightMap:Ct,bumpMap:j,normalMap:xt,displacementMap:d&&at,emissiveMap:Pt,normalMapObjectSpace:xt&&b.normalMapType===qu,normalMapTangentSpace:xt&&b.normalMapType===Kn,metalnessMap:gt,roughnessMap:A,anisotropy:S,anisotropyMap:ct,clearcoat:F,clearcoatMap:_t,clearcoatNormalMap:qt,clearcoatRoughnessMap:tt,dispersion:X,iridescence:Q,iridescenceMap:vt,iridescenceThicknessMap:Lt,sheen:q,sheenColorMap:Nt,sheenRoughnessMap:yt,specularMap:Zt,specularColorMap:Xt,specularIntensityMap:ae,transmission:Et,transmissionMap:D,thicknessMap:ht,gradientMap:W,opaque:b.transparent===!1&&b.blending===Si&&b.alphaToCoverage===!1,alphaMap:J,alphaTest:ft,alphaHash:ut,combine:b.combine,mapUv:Jt&&_(b.map.channel),aoMapUv:I&&_(b.aoMap.channel),lightMapUv:Ct&&_(b.lightMap.channel),bumpMapUv:j&&_(b.bumpMap.channel),normalMapUv:xt&&_(b.normalMap.channel),displacementMapUv:at&&_(b.displacementMap.channel),emissiveMapUv:Pt&&_(b.emissiveMap.channel),metalnessMapUv:gt&&_(b.metalnessMap.channel),roughnessMapUv:A&&_(b.roughnessMap.channel),anisotropyMapUv:ct&&_(b.anisotropyMap.channel),clearcoatMapUv:_t&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:qt&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:vt&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:Lt&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:yt&&_(b.sheenRoughnessMap.channel),specularMapUv:Zt&&_(b.specularMap.channel),specularColorMapUv:Xt&&_(b.specularColorMap.channel),specularIntensityMapUv:ae&&_(b.specularIntensityMap.channel),transmissionMapUv:D&&_(b.transmissionMap.channel),thicknessMapUv:ht&&_(b.thicknessMap.channel),alphaMapUv:J&&_(b.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(xt||S),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!Z.attributes.uv&&(Jt||J),fog:!!V,useFog:b.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:It,skinning:O.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:Mt,morphTextureStride:zt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:ue,decodeVideoTexture:Jt&&b.map.isVideoTexture===!0&&Yt.getTransfer(b.map.colorSpace)===se,decodeVideoTextureEmissive:Pt&&b.emissiveMap.isVideoTexture===!0&&Yt.getTransfer(b.emissiveMap.colorSpace)===se,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===dn,flipSided:b.side===Ue,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Vt&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Vt&&b.extensions.multiDraw===!0||Ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return Ee.vertexUv1s=c.has(1),Ee.vertexUv2s=c.has(2),Ee.vertexUv3s=c.has(3),c.clear(),Ee}function p(b){const M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(const L in b.defines)M.push(L),M.push(b.defines[L]);return b.isRawShaderMaterial===!1&&(y(M,b),v(M,b),M.push(r.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function y(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function v(b,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),b.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reverseDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),b.push(o.mask)}function x(b){const M=m[b.type];let L;if(M){const k=rn[M];L=ad.clone(k.uniforms)}else L=b.uniforms;return L}function P(b,M){let L;for(let k=0,O=h.length;k0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function l(u,d,f,m,_,g){const p=a(u,d,f,m,_,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||sx),n.length>1&&n.sort(d||_h),i.length>1&&i.sort(d||_h)}function h(){for(let u=t,d=r.length;u=s.length?(a=new xh,s.push(a)):a=s[i],a}function e(){r=new WeakMap}return{get:t,dispose:e}}function ax(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new w,color:new pt};break;case"SpotLight":e={position:new w,direction:new w,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new w,color:new pt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new w,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":e={color:new pt,position:new w,halfWidth:new w,halfHeight:new w};break}return r[t.id]=e,e}}}function ox(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let lx=0;function cx(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function hx(r){const t=new ax,e=ox(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new w);const i=new w,s=new Dt,a=new Dt;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,y=0,v=0,x=0,P=0,T=0,C=0;c.sort(cx);for(let b=0,M=c.length;b0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=lt.LTC_FLOAT_1,n.rectAreaLTC2=lt.LTC_FLOAT_2):(n.rectAreaLTC1=lt.LTC_HALF_1,n.rectAreaLTC2=lt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const R=n.hash;(R.directionalLength!==f||R.pointLength!==m||R.spotLength!==_||R.rectAreaLength!==g||R.hemiLength!==p||R.numDirectionalShadows!==y||R.numPointShadows!==v||R.numSpotShadows!==x||R.numSpotMaps!==P||R.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=x+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=C,R.directionalLength=f,R.pointLength=m,R.spotLength=_,R.rectAreaLength=g,R.hemiLength=p,R.numDirectionalShadows=y,R.numPointShadows=v,R.numSpotShadows=x,R.numSpotMaps=P,R.numLightProbes=C,n.version=lx++)}function l(c,h){let u=0,d=0,f=0,m=0,_=0;const g=h.matrixWorldInverse;for(let p=0,y=c.length;p=a.length?(o=new vh(r),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class tc extends Re{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=Wu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class ec extends Re{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const dx=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,fx=`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 px(r,t,e){let n=new cr;const i=new $,s=new $,a=new Kt,o=new tc({depthPacking:Xu}),l=new ec,c={},h=e.maxTextureSize,u={[Un]:Ue,[Ue]:Un,[dn]:dn},d=new on({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $},radius:{value:4}},vertexShader:dx,fragmentShader:fx}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Wt;m.setAttribute("position",new re(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new _e(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nl;let p=this.type;this.render=function(T,C,R){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;const b=r.getRenderTarget(),M=r.getActiveCubeFace(),L=r.getActiveMipmapLevel(),k=r.state;k.setBlending(Pn),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const O=p!==un&&this.type===un,V=p===un&&this.type!==un;for(let Z=0,H=T.length;Zh||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/ot.x),i.x=s.x*ot.x,G.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/ot.y),i.y=s.y*ot.y,G.mapSize.y=s.y)),G.map===null||O===!0||V===!0){const Mt=this.type!==un?{minFilter:be,magFilter:be}:{};G.map!==null&&G.map.dispose(),G.map=new an(i.x,i.y,Mt),G.map.texture.name=et.name+".shadowMap",G.camera.updateProjectionMatrix()}r.setRenderTarget(G.map),r.clear();const mt=G.getViewportCount();for(let Mt=0;Mt0||C.map&&C.alphaTest>0){const k=M.uuid,O=C.uuid;let V=c[k];V===void 0&&(V={},c[k]=V);let Z=V[O];Z===void 0&&(Z=M.clone(),V[O]=Z,C.addEventListener("dispose",P)),M=Z}if(M.visible=C.visible,M.wireframe=C.wireframe,b===un?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,R.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=r.properties.get(M);k.light=R}return M}function x(T,C,R,b,M){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===un)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,T.matrixWorld);const O=t.update(T),V=T.material;if(Array.isArray(V)){const Z=O.groups;for(let H=0,et=Z.length;H=1):G.indexOf("OpenGL ES")!==-1&&(et=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=et>=2);let ot=null,mt={};const Mt=r.getParameter(r.SCISSOR_BOX),zt=r.getParameter(r.VIEWPORT),te=new Kt().fromArray(Mt),Y=new Kt().fromArray(zt);function it(D,ht,W,J){const ft=new Uint8Array(4),ut=r.createTexture();r.bindTexture(D,ut),r.texParameteri(D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(D,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Vt=0;Vtt?(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function xx(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function vx(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Cl(r,t,e,n){const i=yx(n);switch(e){case kl:return r*t;case Hl:return r*t;case Gl:return r*t*2;case to:return r*t/i.components*i.byteLength;case ar:return r*t/i.components*i.byteLength;case Wl:return r*t*2/i.components*i.byteLength;case eo:return r*t*2/i.components*i.byteLength;case Vl:return r*t*3/i.components*i.byteLength;case De:return r*t*4/i.components*i.byteLength;case no:return r*t*4/i.components*i.byteLength;case Us:case Ns:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Fs:case Os:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case ya:case Sa:return Math.max(r,16)*Math.max(t,8)/4;case va:case Ma:return Math.max(r,8)*Math.max(t,8)/2;case ba:case Ea:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Ta:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case Aa:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case wa:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case Ca:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case Ra:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case Ia:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case Pa:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case La:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case Da:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Ua:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case Na:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case Fa:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case Oa:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case Ba:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case za:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case Bs:case ka:case Va:return Math.ceil(r/4)*Math.ceil(t/4)*16;case Xl:case Ha:return Math.ceil(r/4)*Math.ceil(t/4)*8;case Ga:case Wa:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function yx(r){switch(r){case _n:case Ol:return{byteLength:1,components:1};case as:case Bl:case us:return{byteLength:2,components:1};case Qa:case ja:return{byteLength:2,components:4};case Fn:case Ka:case He:return{byteLength:4,components:1};case zl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}const Mx={contain:_x,cover:xx,fill:vx,getByteLength:Cl};function Sx(r,t,e,n,i,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new $,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(A,S){return f?new OffscreenCanvas(A,S):$s("canvas")}function _(A,S,F){let X=1;const Q=gt(A);if((Q.width>F||Q.height>F)&&(X=F/Math.max(Q.width,Q.height)),X<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const q=Math.floor(X*Q.width),Et=Math.floor(X*Q.height);u===void 0&&(u=m(q,Et));const ct=S?m(q,Et):u;return ct.width=q,ct.height=Et,ct.getContext("2d").drawImage(A,0,0,q,Et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+q+"x"+Et+")."),ct}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),A;return A}function g(A){return A.generateMipmaps}function p(A){r.generateMipmap(A)}function y(A){return A.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?r.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function v(A,S,F,X,Q=!1){if(A!==null){if(r[A]!==void 0)return r[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let q=S;if(S===r.RED&&(F===r.FLOAT&&(q=r.R32F),F===r.HALF_FLOAT&&(q=r.R16F),F===r.UNSIGNED_BYTE&&(q=r.R8)),S===r.RED_INTEGER&&(F===r.UNSIGNED_BYTE&&(q=r.R8UI),F===r.UNSIGNED_SHORT&&(q=r.R16UI),F===r.UNSIGNED_INT&&(q=r.R32UI),F===r.BYTE&&(q=r.R8I),F===r.SHORT&&(q=r.R16I),F===r.INT&&(q=r.R32I)),S===r.RG&&(F===r.FLOAT&&(q=r.RG32F),F===r.HALF_FLOAT&&(q=r.RG16F),F===r.UNSIGNED_BYTE&&(q=r.RG8)),S===r.RG_INTEGER&&(F===r.UNSIGNED_BYTE&&(q=r.RG8UI),F===r.UNSIGNED_SHORT&&(q=r.RG16UI),F===r.UNSIGNED_INT&&(q=r.RG32UI),F===r.BYTE&&(q=r.RG8I),F===r.SHORT&&(q=r.RG16I),F===r.INT&&(q=r.RG32I)),S===r.RGB_INTEGER&&(F===r.UNSIGNED_BYTE&&(q=r.RGB8UI),F===r.UNSIGNED_SHORT&&(q=r.RGB16UI),F===r.UNSIGNED_INT&&(q=r.RGB32UI),F===r.BYTE&&(q=r.RGB8I),F===r.SHORT&&(q=r.RGB16I),F===r.INT&&(q=r.RGB32I)),S===r.RGBA_INTEGER&&(F===r.UNSIGNED_BYTE&&(q=r.RGBA8UI),F===r.UNSIGNED_SHORT&&(q=r.RGBA16UI),F===r.UNSIGNED_INT&&(q=r.RGBA32UI),F===r.BYTE&&(q=r.RGBA8I),F===r.SHORT&&(q=r.RGBA16I),F===r.INT&&(q=r.RGBA32I)),S===r.RGB&&F===r.UNSIGNED_INT_5_9_9_9_REV&&(q=r.RGB9_E5),S===r.RGBA){const Et=Q?or:Yt.getTransfer(X);F===r.FLOAT&&(q=r.RGBA32F),F===r.HALF_FLOAT&&(q=r.RGBA16F),F===r.UNSIGNED_BYTE&&(q=Et===se?r.SRGB8_ALPHA8:r.RGBA8),F===r.UNSIGNED_SHORT_4_4_4_4&&(q=r.RGBA4),F===r.UNSIGNED_SHORT_5_5_5_1&&(q=r.RGB5_A1)}return(q===r.R16F||q===r.R32F||q===r.RG16F||q===r.RG32F||q===r.RGBA16F||q===r.RGBA32F)&&t.get("EXT_color_buffer_float"),q}function x(A,S){let F;return A?S===null||S===Fn||S===wi?F=r.DEPTH24_STENCIL8:S===He?F=r.DEPTH32F_STENCIL8:S===as&&(F=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Fn||S===wi?F=r.DEPTH_COMPONENT24:S===He?F=r.DEPTH_COMPONENT32F:S===as&&(F=r.DEPTH_COMPONENT16),F}function P(A,S){return g(A)===!0||A.isFramebufferTexture&&A.minFilter!==be&&A.minFilter!==xe?Math.log2(Math.max(S.width,S.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?S.mipmaps.length:1}function T(A){const S=A.target;S.removeEventListener("dispose",T),R(S),S.isVideoTexture&&h.delete(S)}function C(A){const S=A.target;S.removeEventListener("dispose",C),M(S)}function R(A){const S=n.get(A);if(S.__webglInit===void 0)return;const F=A.source,X=d.get(F);if(X){const Q=X[S.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&b(A),Object.keys(X).length===0&&d.delete(F)}n.remove(A)}function b(A){const S=n.get(A);r.deleteTexture(S.__webglTexture);const F=A.source,X=d.get(F);delete X[S.__cacheKey],a.memory.textures--}function M(A){const S=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(S.__webglFramebuffer[X]))for(let Q=0;Q=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+i.maxTextures),L+=1,A}function V(A){const S=[];return S.push(A.wrapS),S.push(A.wrapT),S.push(A.wrapR||0),S.push(A.magFilter),S.push(A.minFilter),S.push(A.anisotropy),S.push(A.internalFormat),S.push(A.format),S.push(A.type),S.push(A.generateMipmaps),S.push(A.premultiplyAlpha),S.push(A.flipY),S.push(A.unpackAlignment),S.push(A.colorSpace),S.join()}function Z(A,S){const F=n.get(A);if(A.isVideoTexture&&at(A),A.isRenderTargetTexture===!1&&A.version>0&&F.__version!==A.version){const X=A.image;if(X===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(F,A,S);return}}e.bindTexture(r.TEXTURE_2D,F.__webglTexture,r.TEXTURE0+S)}function H(A,S){const F=n.get(A);if(A.version>0&&F.__version!==A.version){Y(F,A,S);return}e.bindTexture(r.TEXTURE_2D_ARRAY,F.__webglTexture,r.TEXTURE0+S)}function et(A,S){const F=n.get(A);if(A.version>0&&F.__version!==A.version){Y(F,A,S);return}e.bindTexture(r.TEXTURE_3D,F.__webglTexture,r.TEXTURE0+S)}function G(A,S){const F=n.get(A);if(A.version>0&&F.__version!==A.version){it(F,A,S);return}e.bindTexture(r.TEXTURE_CUBE_MAP,F.__webglTexture,r.TEXTURE0+S)}const ot={[Ws]:r.REPEAT,[Qe]:r.CLAMP_TO_EDGE,[Xs]:r.MIRRORED_REPEAT},mt={[be]:r.NEAREST,[Fl]:r.NEAREST_MIPMAP_NEAREST,[ts]:r.NEAREST_MIPMAP_LINEAR,[xe]:r.LINEAR,[Ds]:r.LINEAR_MIPMAP_NEAREST,[fn]:r.LINEAR_MIPMAP_LINEAR},Mt={[Yu]:r.NEVER,[ju]:r.ALWAYS,[Zu]:r.LESS,[Yl]:r.LEQUAL,[Ju]:r.EQUAL,[Qu]:r.GEQUAL,[$u]:r.GREATER,[Ku]:r.NOTEQUAL};function zt(A,S){if(S.type===He&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===xe||S.magFilter===Ds||S.magFilter===ts||S.magFilter===fn||S.minFilter===xe||S.minFilter===Ds||S.minFilter===ts||S.minFilter===fn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(A,r.TEXTURE_WRAP_S,ot[S.wrapS]),r.texParameteri(A,r.TEXTURE_WRAP_T,ot[S.wrapT]),(A===r.TEXTURE_3D||A===r.TEXTURE_2D_ARRAY)&&r.texParameteri(A,r.TEXTURE_WRAP_R,ot[S.wrapR]),r.texParameteri(A,r.TEXTURE_MAG_FILTER,mt[S.magFilter]),r.texParameteri(A,r.TEXTURE_MIN_FILTER,mt[S.minFilter]),S.compareFunction&&(r.texParameteri(A,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(A,r.TEXTURE_COMPARE_FUNC,Mt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===be||S.minFilter!==ts&&S.minFilter!==fn||S.type===He&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");r.texParameterf(A,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function te(A,S){let F=!1;A.__webglInit===void 0&&(A.__webglInit=!0,S.addEventListener("dispose",T));const X=S.source;let Q=d.get(X);Q===void 0&&(Q={},d.set(X,Q));const q=V(S);if(q!==A.__cacheKey){Q[q]===void 0&&(Q[q]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,F=!0),Q[q].usedTimes++;const Et=Q[A.__cacheKey];Et!==void 0&&(Q[A.__cacheKey].usedTimes--,Et.usedTimes===0&&b(S)),A.__cacheKey=q,A.__webglTexture=Q[q].texture}return F}function Y(A,S,F){let X=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(X=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(X=r.TEXTURE_3D);const Q=te(A,S),q=S.source;e.bindTexture(X,A.__webglTexture,r.TEXTURE0+F);const Et=n.get(q);if(q.version!==Et.__version||Q===!0){e.activeTexture(r.TEXTURE0+F);const ct=Yt.getPrimaries(Yt.workingColorSpace),_t=S.colorSpace===Cn?null:Yt.getPrimaries(S.colorSpace),qt=S.colorSpace===Cn||ct===_t?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,qt);let tt=_(S.image,!1,i.maxTextureSize);tt=Pt(S,tt);const vt=s.convert(S.format,S.colorSpace),Lt=s.convert(S.type);let Nt=v(S.internalFormat,vt,Lt,S.colorSpace,S.isVideoTexture);zt(X,S);let yt;const Zt=S.mipmaps,Xt=S.isVideoTexture!==!0,ae=Et.__version===void 0||Q===!0,D=q.dataReady,ht=P(S,tt);if(S.isDepthTexture)Nt=x(S.format===Ci,S.type),ae&&(Xt?e.texStorage2D(r.TEXTURE_2D,1,Nt,tt.width,tt.height):e.texImage2D(r.TEXTURE_2D,0,Nt,tt.width,tt.height,0,vt,Lt,null));else if(S.isDataTexture)if(Zt.length>0){Xt&&ae&&e.texStorage2D(r.TEXTURE_2D,ht,Nt,Zt[0].width,Zt[0].height);for(let W=0,J=Zt.length;W0){const ft=Cl(yt.width,yt.height,S.format,S.type);for(const ut of S.layerUpdates){const Vt=yt.data.subarray(ut*ft/yt.data.BYTES_PER_ELEMENT,(ut+1)*ft/yt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,W,0,0,ut,yt.width,yt.height,1,vt,Vt)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,W,0,0,0,yt.width,yt.height,tt.depth,vt,yt.data)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,W,Nt,yt.width,yt.height,tt.depth,0,yt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Xt?D&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,W,0,0,0,yt.width,yt.height,tt.depth,vt,Lt,yt.data):e.texImage3D(r.TEXTURE_2D_ARRAY,W,Nt,yt.width,yt.height,tt.depth,0,vt,Lt,yt.data)}else{Xt&&ae&&e.texStorage2D(r.TEXTURE_2D,ht,Nt,Zt[0].width,Zt[0].height);for(let W=0,J=Zt.length;W0){const W=Cl(tt.width,tt.height,S.format,S.type);for(const J of S.layerUpdates){const ft=tt.data.subarray(J*W/tt.data.BYTES_PER_ELEMENT,(J+1)*W/tt.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,J,tt.width,tt.height,1,vt,Lt,ft)}S.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,tt.width,tt.height,tt.depth,vt,Lt,tt.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,Nt,tt.width,tt.height,tt.depth,0,vt,Lt,tt.data);else if(S.isData3DTexture)Xt?(ae&&e.texStorage3D(r.TEXTURE_3D,ht,Nt,tt.width,tt.height,tt.depth),D&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,tt.width,tt.height,tt.depth,vt,Lt,tt.data)):e.texImage3D(r.TEXTURE_3D,0,Nt,tt.width,tt.height,tt.depth,0,vt,Lt,tt.data);else if(S.isFramebufferTexture){if(ae)if(Xt)e.texStorage2D(r.TEXTURE_2D,ht,Nt,tt.width,tt.height);else{let W=tt.width,J=tt.height;for(let ft=0;ft>=1,J>>=1}}else if(Zt.length>0){if(Xt&&ae){const W=gt(Zt[0]);e.texStorage2D(r.TEXTURE_2D,ht,Nt,W.width,W.height)}for(let W=0,J=Zt.length;W0&&ht++;const J=gt(vt[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,ht,Zt,J.width,J.height)}for(let J=0;J<6;J++)if(tt){Xt?D&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,vt[J].width,vt[J].height,Nt,yt,vt[J].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Zt,vt[J].width,vt[J].height,0,Nt,yt,vt[J].data);for(let ft=0;ft>q),Lt=Math.max(1,S.height>>q);Q===r.TEXTURE_3D||Q===r.TEXTURE_2D_ARRAY?e.texImage3D(Q,q,_t,vt,Lt,S.depth,0,Et,ct,null):e.texImage2D(Q,q,_t,vt,Lt,0,Et,ct,null)}e.bindFramebuffer(r.FRAMEBUFFER,A),xt(S)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,X,Q,tt.__webglTexture,0,j(S)):(Q===r.TEXTURE_2D||Q>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,X,Q,tt.__webglTexture,q),e.bindFramebuffer(r.FRAMEBUFFER,null)}function rt(A,S,F){if(r.bindRenderbuffer(r.RENDERBUFFER,A),S.depthBuffer){const X=S.depthTexture,Q=X&&X.isDepthTexture?X.type:null,q=x(S.stencilBuffer,Q),Et=S.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ct=j(S);xt(S)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ct,q,S.width,S.height):F?r.renderbufferStorageMultisample(r.RENDERBUFFER,ct,q,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,q,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Et,r.RENDERBUFFER,A)}else{const X=S.textures;for(let Q=0;Q{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,X.removeEventListener("dispose",Q)};X.addEventListener("dispose",Q),S.__depthDisposeCallback=Q}S.__boundDepthTexture=X}if(A.depthTexture&&!S.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");It(S.__webglFramebuffer,A)}else if(F){S.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[X]),S.__webglDepthbuffer[X]===void 0)S.__webglDepthbuffer[X]=r.createRenderbuffer(),rt(S.__webglDepthbuffer[X],A,!1);else{const Q=A.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,q=S.__webglDepthbuffer[X];r.bindRenderbuffer(r.RENDERBUFFER,q),r.framebufferRenderbuffer(r.FRAMEBUFFER,Q,r.RENDERBUFFER,q)}}else if(e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=r.createRenderbuffer(),rt(S.__webglDepthbuffer,A,!1);else{const X=A.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Q=S.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,Q),r.framebufferRenderbuffer(r.FRAMEBUFFER,X,r.RENDERBUFFER,Q)}e.bindFramebuffer(r.FRAMEBUFFER,null)}function Ut(A,S,F){const X=n.get(A);S!==void 0&&bt(X.__webglFramebuffer,A,A.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),F!==void 0&&Ft(A)}function Jt(A){const S=A.texture,F=n.get(A),X=n.get(S);A.addEventListener("dispose",C);const Q=A.textures,q=A.isWebGLCubeRenderTarget===!0,Et=Q.length>1;if(Et||(X.__webglTexture===void 0&&(X.__webglTexture=r.createTexture()),X.__version=S.version,a.memory.textures++),q){F.__webglFramebuffer=[];for(let ct=0;ct<6;ct++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[ct]=[];for(let _t=0;_t0){F.__webglFramebuffer=[];for(let ct=0;ct0&&xt(A)===!1){F.__webglMultisampledFramebuffer=r.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ct=0;ct0)for(let _t=0;_t0)for(let _t=0;_t0){if(xt(A)===!1){const S=A.textures,F=A.width,X=A.height;let Q=r.COLOR_BUFFER_BIT;const q=A.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Et=n.get(A),ct=S.length>1;if(ct)for(let _t=0;_t0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function at(A){const S=a.render.frame;h.get(A)!==S&&(h.set(A,S),A.update())}function Pt(A,S){const F=A.colorSpace,X=A.format,Q=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||F!==Pi&&F!==Cn&&(Yt.getTransfer(F)===se?(X!==De||Q!==_n)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),S}function gt(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=O,this.resetTextureUnits=k,this.setTexture2D=Z,this.setTexture2DArray=H,this.setTexture3D=et,this.setTextureCube=G,this.rebindTextures=Ut,this.setupRenderTarget=Jt,this.updateRenderTargetMipmap=K,this.updateMultisampleRenderTarget=Ct,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=bt,this.useMultisampledRTT=xt}function pd(r,t){function e(n,i=Cn){let s;const a=Yt.getTransfer(i);if(n===_n)return r.UNSIGNED_BYTE;if(n===Qa)return r.UNSIGNED_SHORT_4_4_4_4;if(n===ja)return r.UNSIGNED_SHORT_5_5_5_1;if(n===zl)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===Ol)return r.BYTE;if(n===Bl)return r.SHORT;if(n===as)return r.UNSIGNED_SHORT;if(n===Ka)return r.INT;if(n===Fn)return r.UNSIGNED_INT;if(n===He)return r.FLOAT;if(n===us)return r.HALF_FLOAT;if(n===kl)return r.ALPHA;if(n===Vl)return r.RGB;if(n===De)return r.RGBA;if(n===Hl)return r.LUMINANCE;if(n===Gl)return r.LUMINANCE_ALPHA;if(n===bi)return r.DEPTH_COMPONENT;if(n===Ci)return r.DEPTH_STENCIL;if(n===to)return r.RED;if(n===ar)return r.RED_INTEGER;if(n===Wl)return r.RG;if(n===eo)return r.RG_INTEGER;if(n===no)return r.RGBA_INTEGER;if(n===Us||n===Ns||n===Fs||n===Os)if(a===se)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Us)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ns)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Fs)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Os)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Us)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ns)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Fs)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Os)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===va||n===ya||n===Ma||n===Sa)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===va)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ya)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ma)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sa)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ba||n===Ea||n===Ta)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ba||n===Ea)return a===se?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Ta)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Aa||n===wa||n===Ca||n===Ra||n===Ia||n===Pa||n===La||n===Da||n===Ua||n===Na||n===Fa||n===Oa||n===Ba||n===za)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Aa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===wa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ca)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ra)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ia)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Pa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===La)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Da)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ua)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Na)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Fa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Oa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ba)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===za)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Bs||n===ka||n===Va)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Bs)return a===se?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ka)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Va)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Xl||n===Ha||n===Ga||n===Wa)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Bs)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ha)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ga)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Wa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===wi?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:e}}class md extends Se{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class is extends Qt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const bx={type:"move"};class il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new is,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 is,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new is,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const g=e.getJointPose(_,n),p=this._getHandJoint(c,_);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(bx)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new is;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Ex=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Tx=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class Ax{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const i=new pe,s=t.properties.get(i);s.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new on({vertexShader:Ex,fragmentShader:Tx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new _e(new fs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class wx extends xn{constructor(t,e){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,m=null;const _=new Ax,g=e.getContextAttributes();let p=null,y=null;const v=[],x=[],P=new $;let T=null;const C=new Se;C.viewport=new Kt;const R=new Se;R.viewport=new Kt;const b=[C,R],M=new md;let L=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let it=v[Y];return it===void 0&&(it=new il,v[Y]=it),it.getTargetRaySpace()},this.getControllerGrip=function(Y){let it=v[Y];return it===void 0&&(it=new il,v[Y]=it),it.getGripSpace()},this.getHand=function(Y){let it=v[Y];return it===void 0&&(it=new il,v[Y]=it),it.getHandSpace()};function O(Y){const it=x.indexOf(Y.inputSource);if(it===-1)return;const bt=v[it];bt!==void 0&&(bt.update(Y.inputSource,Y.frame,c||a),bt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",Z);for(let Y=0;Y=0&&(x[rt]=null,v[rt].disconnect(bt))}for(let it=0;it=x.length){x.push(bt),rt=Ft;break}else if(x[Ft]===null){x[Ft]=bt,rt=Ft;break}if(rt===-1)break}const It=v[rt];It&&It.connect(bt)}}const H=new w,et=new w;function G(Y,it,bt){H.setFromMatrixPosition(it.matrixWorld),et.setFromMatrixPosition(bt.matrixWorld);const rt=H.distanceTo(et),It=it.projectionMatrix.elements,Ft=bt.projectionMatrix.elements,Ut=It[14]/(It[10]-1),Jt=It[14]/(It[10]+1),K=(It[9]+1)/It[5],nt=(It[9]-1)/It[5],I=(It[8]-1)/It[0],Ct=(Ft[8]+1)/Ft[0],j=Ut*I,xt=Ut*Ct,at=rt/(-I+Ct),Pt=at*-I;if(it.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Pt),Y.translateZ(at),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),It[10]===-1)Y.projectionMatrix.copy(it.projectionMatrix),Y.projectionMatrixInverse.copy(it.projectionMatrixInverse);else{const gt=Ut+at,A=Jt+at,S=j-Pt,F=xt+(rt-Pt),X=K*Jt/A*gt,Q=nt*Jt/A*gt;Y.projectionMatrix.makePerspective(S,F,X,Q,gt,A),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ot(Y,it){it===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(it.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let it=Y.near,bt=Y.far;_.texture!==null&&(_.depthNear>0&&(it=_.depthNear),_.depthFar>0&&(bt=_.depthFar)),M.near=R.near=C.near=it,M.far=R.far=C.far=bt,(L!==M.near||k!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,k=M.far),C.layers.mask=Y.layers.mask|2,R.layers.mask=Y.layers.mask|4,M.layers.mask=C.layers.mask|R.layers.mask;const rt=Y.parent,It=M.cameras;ot(M,rt);for(let Ft=0;Ft0&&(g.alphaTest.value=p.alphaTest);const y=t.get(p),v=y.envMap,x=y.envMapRotation;v&&(g.envMap.value=v,oi.copy(x),oi.x*=-1,oi.y*=-1,oi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(oi.y*=-1,oi.z*=-1),g.envMapRotation.value.setFromMatrix4(Cx.makeRotationFromEuler(oi)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,y,v){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=v*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,y){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ue&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){const y=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Ix(r,t,e,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const x=v.program;n.uniformBlockBinding(y,x)}function c(y,v){let x=i[y.id];x===void 0&&(m(y),x=h(y),i[y.id]=x,y.addEventListener("dispose",g));const P=v.program;n.updateUBOMapping(y,P);const T=t.render.frame;s[y.id]!==T&&(d(y),s[y.id]=T)}function h(y){const v=u();y.__bindingPointIndex=v;const x=r.createBuffer(),P=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,P,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,x),x}function u(){for(let y=0;y0&&(x+=P-T),y.__size=x,y.__cache={},this}function _(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),v}function g(y){const v=y.target;v.removeEventListener("dispose",g);const x=a.indexOf(v.__bindingPointIndex);a.splice(x,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function p(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:p}}class Px{constructor(t={}){const{canvas:e=ed(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Uint32Array(4),_=new Int32Array(4);let g=null,p=null;const y=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ke,this.toneMapping=Ln,this.toneMappingExposure=1;const x=this;let P=!1,T=0,C=0,R=null,b=-1,M=null;const L=new Kt,k=new Kt;let O=null;const V=new pt(0);let Z=0,H=e.width,et=e.height,G=1,ot=null,mt=null;const Mt=new Kt(0,0,H,et),zt=new Kt(0,0,H,et);let te=!1;const Y=new cr;let it=!1,bt=!1;const rt=new Dt,It=new Dt,Ft=new w,Ut=new Kt,Jt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let K=!1;function nt(){return R===null?G:1}let I=n;function Ct(E,U){return e.getContext(E,U)}try{const E={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ja}`),e.addEventListener("webglcontextlost",J,!1),e.addEventListener("webglcontextrestored",ft,!1),e.addEventListener("webglcontextcreationerror",ut,!1),I===null){const U="webgl2";if(I=Ct(U,E),I===null)throw Ct(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let j,xt,at,Pt,gt,A,S,F,X,Q,q,Et,ct,_t,qt,tt,vt,Lt,Nt,yt,Zt,Xt,ae,D;function ht(){j=new F_(I),j.init(),Xt=new pd(I,j),xt=new I_(I,j,t,Xt),at=new gx(I,j),xt.reverseDepthBuffer&&d&&at.buffers.depth.setReversed(!0),Pt=new z_(I),gt=new ix,A=new Sx(I,j,at,gt,xt,Xt,Pt),S=new L_(x),F=new N_(x),X=new qp(I),ae=new C_(I,X),Q=new O_(I,X,Pt,ae),q=new V_(I,Q,X,Pt),Nt=new k_(I,xt,A),tt=new P_(gt),Et=new nx(x,S,F,j,xt,ae,tt),ct=new Rx(x,gt),_t=new rx,qt=new ux(j),Lt=new w_(x,S,F,at,q,f,l),vt=new px(x,q,xt),D=new Ix(I,Pt,xt,at),yt=new R_(I,j,Pt),Zt=new B_(I,j,Pt),Pt.programs=Et.programs,x.capabilities=xt,x.extensions=j,x.properties=gt,x.renderLists=_t,x.shadowMap=vt,x.state=at,x.info=Pt}ht();const W=new wx(x,I);this.xr=W,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const E=j.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=j.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(E){E!==void 0&&(G=E,this.setSize(H,et,!1))},this.getSize=function(E){return E.set(H,et)},this.setSize=function(E,U,B=!0){if(W.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=E,et=U,e.width=Math.floor(E*G),e.height=Math.floor(U*G),B===!0&&(e.style.width=E+"px",e.style.height=U+"px"),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(H*G,et*G).floor()},this.setDrawingBufferSize=function(E,U,B){H=E,et=U,G=B,e.width=Math.floor(E*B),e.height=Math.floor(U*B),this.setViewport(0,0,E,U)},this.getCurrentViewport=function(E){return E.copy(L)},this.getViewport=function(E){return E.copy(Mt)},this.setViewport=function(E,U,B,z){E.isVector4?Mt.set(E.x,E.y,E.z,E.w):Mt.set(E,U,B,z),at.viewport(L.copy(Mt).multiplyScalar(G).round())},this.getScissor=function(E){return E.copy(zt)},this.setScissor=function(E,U,B,z){E.isVector4?zt.set(E.x,E.y,E.z,E.w):zt.set(E,U,B,z),at.scissor(k.copy(zt).multiplyScalar(G).round())},this.getScissorTest=function(){return te},this.setScissorTest=function(E){at.setScissorTest(te=E)},this.setOpaqueSort=function(E){ot=E},this.setTransparentSort=function(E){mt=E},this.getClearColor=function(E){return E.copy(Lt.getClearColor())},this.setClearColor=function(){Lt.setClearColor.apply(Lt,arguments)},this.getClearAlpha=function(){return Lt.getClearAlpha()},this.setClearAlpha=function(){Lt.setClearAlpha.apply(Lt,arguments)},this.clear=function(E=!0,U=!0,B=!0){let z=0;if(E){let N=!1;if(R!==null){const st=R.texture.format;N=st===no||st===eo||st===ar}if(N){const st=R.texture.type,dt=st===_n||st===Fn||st===as||st===wi||st===Qa||st===ja,Tt=Lt.getClearColor(),At=Lt.getClearAlpha(),Ot=Tt.r,Ht=Tt.g,wt=Tt.b;dt?(m[0]=Ot,m[1]=Ht,m[2]=wt,m[3]=At,I.clearBufferuiv(I.COLOR,0,m)):(_[0]=Ot,_[1]=Ht,_[2]=wt,_[3]=At,I.clearBufferiv(I.COLOR,0,_))}else z|=I.COLOR_BUFFER_BIT}U&&(z|=I.DEPTH_BUFFER_BIT),B&&(z|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",J,!1),e.removeEventListener("webglcontextrestored",ft,!1),e.removeEventListener("webglcontextcreationerror",ut,!1),_t.dispose(),qt.dispose(),gt.dispose(),S.dispose(),F.dispose(),q.dispose(),ae.dispose(),D.dispose(),Et.dispose(),W.dispose(),W.removeEventListener("sessionstart",Sc),W.removeEventListener("sessionend",bc),ei.stop()};function J(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function ft(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;const E=Pt.autoReset,U=vt.enabled,B=vt.autoUpdate,z=vt.needsUpdate,N=vt.type;ht(),Pt.autoReset=E,vt.enabled=U,vt.autoUpdate=B,vt.needsUpdate=z,vt.type=N}function ut(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Vt(E){const U=E.target;U.removeEventListener("dispose",Vt),ue(U)}function ue(E){Ee(E),gt.remove(E)}function Ee(E){const U=gt.get(E).programs;U!==void 0&&(U.forEach(function(B){Et.releaseProgram(B)}),E.isShaderMaterial&&Et.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,B,z,N,st){U===null&&(U=Jt);const dt=N.isMesh&&N.matrixWorld.determinant()<0,Tt=df(E,U,B,z,N);at.setMaterial(z,dt);let At=B.index,Ot=1;if(z.wireframe===!0){if(At=Q.getWireframeAttribute(B),At===void 0)return;Ot=2}const Ht=B.drawRange,wt=B.attributes.position;let jt=Ht.start*Ot,oe=(Ht.start+Ht.count)*Ot;st!==null&&(jt=Math.max(jt,st.start*Ot),oe=Math.min(oe,(st.start+st.count)*Ot)),At!==null?(jt=Math.max(jt,0),oe=Math.min(oe,At.count)):wt!=null&&(jt=Math.max(jt,0),oe=Math.min(oe,wt.count));const le=oe-jt;if(le<0||le===1/0)return;ae.setup(N,z,Tt,B,At);let Oe,ee=yt;if(At!==null&&(Oe=X.get(At),ee=Zt,ee.setIndex(Oe)),N.isMesh)z.wireframe===!0?(at.setLineWidth(z.wireframeLinewidth*nt()),ee.setMode(I.LINES)):ee.setMode(I.TRIANGLES);else if(N.isLine){let Rt=z.linewidth;Rt===void 0&&(Rt=1),at.setLineWidth(Rt*nt()),N.isLineSegments?ee.setMode(I.LINES):N.isLineLoop?ee.setMode(I.LINE_LOOP):ee.setMode(I.LINE_STRIP)}else N.isPoints?ee.setMode(I.POINTS):N.isSprite&&ee.setMode(I.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)ee.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(j.get("WEBGL_multi_draw"))ee.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Rt=N._multiDrawStarts,Mn=N._multiDrawCounts,ne=N._multiDrawCount,tn=At?X.get(At).bytesPerElement:1,Ni=gt.get(z).currentProgram.getUniforms();for(let Xe=0;Xe{function st(){if(z.forEach(function(dt){gt.get(dt).currentProgram.isReady()&&z.delete(dt)}),z.size===0){N(E);return}setTimeout(st,10)}j.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let je=null;function yn(E){je&&je(E)}function Sc(){ei.stop()}function bc(){ei.start()}const ei=new cd;ei.setAnimationLoop(yn),typeof self<"u"&&ei.setContext(self),this.setAnimationLoop=function(E){je=E,W.setAnimationLoop(E),E===null?ei.stop():ei.start()},W.addEventListener("sessionstart",Sc),W.addEventListener("sessionend",bc),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),W.enabled===!0&&W.isPresenting===!0&&(W.cameraAutoUpdate===!0&&W.updateCamera(U),U=W.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,U,R),p=qt.get(E,v.length),p.init(U),v.push(p),It.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Y.setFromProjectionMatrix(It),bt=this.localClippingEnabled,it=tt.init(this.clippingPlanes,bt),g=_t.get(E,y.length),g.init(),y.push(g),W.enabled===!0&&W.isPresenting===!0){const st=x.xr.getDepthSensingMesh();st!==null&&Io(st,U,-1/0,x.sortObjects)}Io(E,U,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(ot,mt),K=W.enabled===!1||W.isPresenting===!1||W.hasDepthSensing()===!1,K&&Lt.addToRenderList(g,E),this.info.render.frame++,it===!0&&tt.beginShadows();const B=p.state.shadowsArray;vt.render(B,E,U),it===!0&&tt.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=g.opaque,N=g.transmissive;if(p.setupLights(),U.isArrayCamera){const st=U.cameras;if(N.length>0)for(let dt=0,Tt=st.length;dt0&&Tc(z,N,E,U),K&&Lt.render(E),Ec(g,E,U);R!==null&&(A.updateMultisampleRenderTarget(R),A.updateRenderTargetMipmap(R)),E.isScene===!0&&E.onAfterRender(x,E,U),ae.resetDefaultState(),b=-1,M=null,v.pop(),v.length>0?(p=v[v.length-1],it===!0&&tt.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,y.pop(),y.length>0?g=y[y.length-1]:g=null};function Io(E,U,B,z){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)B=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Y.intersectsSprite(E)){z&&Ut.setFromMatrixPosition(E.matrixWorld).applyMatrix4(It);const dt=q.update(E),Tt=E.material;Tt.visible&&g.push(E,dt,Tt,B,Ut.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Y.intersectsObject(E))){const dt=q.update(E),Tt=E.material;if(z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ut.copy(E.boundingSphere.center)):(dt.boundingSphere===null&&dt.computeBoundingSphere(),Ut.copy(dt.boundingSphere.center)),Ut.applyMatrix4(E.matrixWorld).applyMatrix4(It)),Array.isArray(Tt)){const At=dt.groups;for(let Ot=0,Ht=At.length;Ot0&&mr(N,U,B),st.length>0&&mr(st,U,B),dt.length>0&&mr(dt,U,B),at.buffers.depth.setTest(!0),at.buffers.depth.setMask(!0),at.buffers.color.setMask(!0),at.setPolygonOffset(!1)}function Tc(E,U,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new an(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")||j.has("EXT_color_buffer_float")?us:_n,minFilter:fn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Yt.workingColorSpace}));const st=p.state.transmissionRenderTarget[z.id],dt=z.viewport||L;st.setSize(dt.z,dt.w);const Tt=x.getRenderTarget();x.setRenderTarget(st),x.getClearColor(V),Z=x.getClearAlpha(),Z<1&&x.setClearColor(16777215,.5),x.clear(),K&&Lt.render(B);const At=x.toneMapping;x.toneMapping=Ln;const Ot=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),it===!0&&tt.setGlobalState(x.clippingPlanes,z),mr(E,B,z),A.updateMultisampleRenderTarget(st),A.updateRenderTargetMipmap(st),j.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let wt=0,jt=U.length;wt0),wt=!!B.morphAttributes.position,jt=!!B.morphAttributes.normal,oe=!!B.morphAttributes.color;let le=Ln;z.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(le=x.toneMapping);const Oe=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ee=Oe!==void 0?Oe.length:0,Rt=gt.get(z),Mn=p.state.lights;if(it===!0&&(bt===!0||E!==M)){const $e=E===M&&z.id===b;tt.setState(z,E,$e)}let ne=!1;z.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==Mn.state.version||Rt.outputColorSpace!==Tt||N.isBatchedMesh&&Rt.batching===!1||!N.isBatchedMesh&&Rt.batching===!0||N.isBatchedMesh&&Rt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Rt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Rt.instancing===!1||!N.isInstancedMesh&&Rt.instancing===!0||N.isSkinnedMesh&&Rt.skinning===!1||!N.isSkinnedMesh&&Rt.skinning===!0||N.isInstancedMesh&&Rt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Rt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Rt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Rt.instancingMorph===!1&&N.morphTexture!==null||Rt.envMap!==At||z.fog===!0&&Rt.fog!==st||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==tt.numPlanes||Rt.numIntersection!==tt.numIntersection)||Rt.vertexAlphas!==Ot||Rt.vertexTangents!==Ht||Rt.morphTargets!==wt||Rt.morphNormals!==jt||Rt.morphColors!==oe||Rt.toneMapping!==le||Rt.morphTargetsCount!==ee)&&(ne=!0):(ne=!0,Rt.__version=z.version);let tn=Rt.currentProgram;ne===!0&&(tn=gr(z,U,N));let Ni=!1,Xe=!1,gs=!1;const ce=tn.getUniforms(),hn=Rt.uniforms;if(at.useProgram(tn.program)&&(Ni=!0,Xe=!0,gs=!0),z.id!==b&&(b=z.id,Xe=!0),Ni||M!==E){at.buffers.depth.getReversed()?(rt.copy(E.projectionMatrix),_p(rt),xp(rt),ce.setValue(I,"projectionMatrix",rt)):ce.setValue(I,"projectionMatrix",E.projectionMatrix),ce.setValue(I,"viewMatrix",E.matrixWorldInverse);const Bn=ce.map.cameraPosition;Bn!==void 0&&Bn.setValue(I,Ft.setFromMatrixPosition(E.matrixWorld)),xt.logarithmicDepthBuffer&&ce.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&ce.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),M!==E&&(M=E,Xe=!0,gs=!0)}if(N.isSkinnedMesh){ce.setOptional(I,N,"bindMatrix"),ce.setOptional(I,N,"bindMatrixInverse");const $e=N.skeleton;$e&&($e.boneTexture===null&&$e.computeBoneTexture(),ce.setValue(I,"boneTexture",$e.boneTexture,A))}N.isBatchedMesh&&(ce.setOptional(I,N,"batchingTexture"),ce.setValue(I,"batchingTexture",N._matricesTexture,A),ce.setOptional(I,N,"batchingIdTexture"),ce.setValue(I,"batchingIdTexture",N._indirectTexture,A),ce.setOptional(I,N,"batchingColorTexture"),N._colorsTexture!==null&&ce.setValue(I,"batchingColorTexture",N._colorsTexture,A));const _s=B.morphAttributes;if((_s.position!==void 0||_s.normal!==void 0||_s.color!==void 0)&&Nt.update(N,B,tn),(Xe||Rt.receiveShadow!==N.receiveShadow)&&(Rt.receiveShadow=N.receiveShadow,ce.setValue(I,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(hn.envMap.value=At,hn.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&U.environment!==null&&(hn.envMapIntensity.value=U.environmentIntensity),Xe&&(ce.setValue(I,"toneMappingExposure",x.toneMappingExposure),Rt.needsLights&&ff(hn,gs),st&&z.fog===!0&&ct.refreshFogUniforms(hn,st),ct.refreshMaterialUniforms(hn,z,G,et,p.state.transmissionRenderTarget[E.id]),ca.upload(I,wc(Rt),hn,A)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(ca.upload(I,wc(Rt),hn,A),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&ce.setValue(I,"center",N.center),ce.setValue(I,"modelViewMatrix",N.modelViewMatrix),ce.setValue(I,"normalMatrix",N.normalMatrix),ce.setValue(I,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const $e=z.uniformsGroups;for(let Bn=0,zn=$e.length;Bn0&&A.useMultisampledRTT(E)===!1?N=gt.get(E).__webglMultisampledFramebuffer:Array.isArray(Ht)?N=Ht[B]:N=Ht,L.copy(E.viewport),k.copy(E.scissor),O=E.scissorTest}else L.copy(Mt).multiplyScalar(G).floor(),k.copy(zt).multiplyScalar(G).floor(),O=te;if(at.bindFramebuffer(I.FRAMEBUFFER,N)&&z&&at.drawBuffers(E,N),at.viewport(L),at.scissor(k),at.setScissorTest(O),st){const At=gt.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+U,At.__webglTexture,B)}else if(dt){const At=gt.get(E.texture),Ot=U||0;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,At.__webglTexture,B||0,Ot)}b=-1},this.readRenderTargetPixels=function(E,U,B,z,N,st,dt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=gt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&dt!==void 0&&(Tt=Tt[dt]),Tt){at.bindFramebuffer(I.FRAMEBUFFER,Tt);try{const At=E.texture,Ot=At.format,Ht=At.type;if(!xt.textureFormatReadable(Ot)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!xt.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-z&&B>=0&&B<=E.height-N&&I.readPixels(U,B,z,N,Xt.convert(Ot),Xt.convert(Ht),st)}finally{const At=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(I.FRAMEBUFFER,At)}}},this.readRenderTargetPixelsAsync=async function(E,U,B,z,N,st,dt){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=gt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&dt!==void 0&&(Tt=Tt[dt]),Tt){const At=E.texture,Ot=At.format,Ht=At.type;if(!xt.textureFormatReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!xt.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(U>=0&&U<=E.width-z&&B>=0&&B<=E.height-N){at.bindFramebuffer(I.FRAMEBUFFER,Tt);const wt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,wt),I.bufferData(I.PIXEL_PACK_BUFFER,st.byteLength,I.STREAM_READ),I.readPixels(U,B,z,N,Xt.convert(Ot),Xt.convert(Ht),0);const jt=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(I.FRAMEBUFFER,jt);const oe=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await gp(I,oe,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,wt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,st),I.deleteBuffer(wt),I.deleteSync(oe),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,U=null,B=0){E.isTexture!==!0&&(Is("WebGLRenderer: copyFramebufferToTexture function signature has changed."),U=arguments[0]||null,E=arguments[1]);const z=Math.pow(2,-B),N=Math.floor(E.image.width*z),st=Math.floor(E.image.height*z),dt=U!==null?U.x:0,Tt=U!==null?U.y:0;A.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,B,0,0,dt,Tt,N,st),at.unbindTexture()},this.copyTextureToTexture=function(E,U,B=null,z=null,N=0){E.isTexture!==!0&&(Is("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,E=arguments[1],U=arguments[2],N=arguments[3]||0,B=null);let st,dt,Tt,At,Ot,Ht,wt,jt,oe;const le=E.isCompressedTexture?E.mipmaps[N]:E.image;B!==null?(st=B.max.x-B.min.x,dt=B.max.y-B.min.y,Tt=B.isBox3?B.max.z-B.min.z:1,At=B.min.x,Ot=B.min.y,Ht=B.isBox3?B.min.z:0):(st=le.width,dt=le.height,Tt=le.depth||1,At=0,Ot=0,Ht=0),z!==null?(wt=z.x,jt=z.y,oe=z.z):(wt=0,jt=0,oe=0);const Oe=Xt.convert(U.format),ee=Xt.convert(U.type);let Rt;U.isData3DTexture?(A.setTexture3D(U,0),Rt=I.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(A.setTexture2DArray(U,0),Rt=I.TEXTURE_2D_ARRAY):(A.setTexture2D(U,0),Rt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,U.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,U.unpackAlignment);const Mn=I.getParameter(I.UNPACK_ROW_LENGTH),ne=I.getParameter(I.UNPACK_IMAGE_HEIGHT),tn=I.getParameter(I.UNPACK_SKIP_PIXELS),Ni=I.getParameter(I.UNPACK_SKIP_ROWS),Xe=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,le.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,le.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,At),I.pixelStorei(I.UNPACK_SKIP_ROWS,Ot),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Ht);const gs=E.isDataArrayTexture||E.isData3DTexture,ce=U.isDataArrayTexture||U.isData3DTexture;if(E.isRenderTargetTexture||E.isDepthTexture){const hn=gt.get(E),_s=gt.get(U),$e=gt.get(hn.__renderTarget),Bn=gt.get(_s.__renderTarget);at.bindFramebuffer(I.READ_FRAMEBUFFER,$e.__webglFramebuffer),at.bindFramebuffer(I.DRAW_FRAMEBUFFER,Bn.__webglFramebuffer);for(let zn=0;zn0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class uo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Zs,this.updateRanges=[],this.version=0,this.uuid=Ze()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;it.far||e.push({distance:l,point:Ss.clone(),uv:Ve.getInterpolation(Ss,Or,Es,Br,yh,sl,Mh,new $),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function zr(r,t,e,n,i,s){Qi.subVectors(r,e).addScalar(.5).multiply(n),i!==void 0?(bs.x=s*Qi.x-i*Qi.y,bs.y=i*Qi.x+s*Qi.y):bs.copy(Qi),r.copy(t),r.x+=bs.x,r.y+=bs.y,r.applyMatrix4(_d)}const kr=new w,Sh=new w;class vd extends Qt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n0){let n,i;for(n=1,i=e.length;n0){kr.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(kr);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){kr.setFromMatrixPosition(t.matrixWorld),Sh.setFromMatrixPosition(this.matrixWorld);const n=kr.distanceTo(Sh)/t.zoom;e[0].object.visible=!0;let i,s;for(i=1,s=e.length;i=a)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=t,o.count=e,o.z=n,o.index=i}reset(){this.list.length=0,this.index=0}}const Be=new Dt,Bx=new pt(1,1,1),ll=new cr,Gr=new Ne,li=new Ce,ws=new w,Ph=new w,zx=new w,cl=new Ox,we=new _e,Wr=[];function kx(r,t,e=0){const n=t.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==t.array.constructor){const i=r.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new re(s,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ne);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ol),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;Be.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(Bx.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;const a=t.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?a.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ol),l=this._availableGeometryIds.shift(),s[l]=i):(l=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(l,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),a=e.getIndex(),o=this._geometryInfo[t];if(i&&a.count>o.reservedIndexCount||e.attributes.position.count>o.reservedVertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=e.getAttribute("position").count;for(const h in n.attributes){const u=e.getAttribute(h),d=n.getAttribute(h);kx(u,d,l);const f=u.itemSize;for(let m=u.count,_=c;m<_;m++){const g=l+m;for(let p=0;p=e.length||e[t].active===!1)return this;const n=this._instanceInfo;for(let i=0,s=n.length;i=e.length||e[t].active===!1?this:(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this)}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),s=this.geometry;for(let a=0,o=n.length;a=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){const s=new Ne,a=n.index,o=n.attributes.position;for(let l=i.start,c=i.start+i.count;l=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){const s=new Ce;this.getBoundingBoxAt(t,Gr),Gr.getCenter(s.center);const a=n.index,o=n.attributes.position;let l=0;for(let c=i.start,h=i.start+i.count;c=n.length||n[t].active===!1?this:(e.toArray(s,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){const n=this._instanceInfo,i=this._matricesTexture.image.data;return t>=n.length||n[t].active===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,s=this._instanceInfo;return t>=s.length||s[t].active===!1?this:(e.toArray(i,t*4),n.needsUpdate=!0,this)}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._instanceInfo;return t>=i.length||i[t].active===!1?null:e.fromArray(n,t*4)}setVisibleAt(t,e){const n=this._instanceInfo;return t>=n.length||n[t].active===!1||n[t].visible===e?this:(n[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){const e=this._instanceInfo;return t>=e.length||e[t].active===!1?!1:e[t].visible}setGeometryIdAt(t,e){const n=this._instanceInfo,i=this._geometryInfo;return t>=n.length||n[t].active===!1||e>=i.length||i[e].active===!1?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){const e=this._instanceInfo;return t>=e.length||e[t].active===!1?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(ol);e[e.length-1]===n.length;)n.pop(),e.pop();if(to.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Wt,this._initializeGeometry(s));const a=this.geometry;s.index&&ci(s.index.array,a.index.array);for(const o in s.attributes)ci(s.attributes[o].array,a.attributes[o].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,a=this.geometry;we.material=this.material,we.geometry.index=a.index,we.geometry.attributes=a.attributes,we.geometry.boundingBox===null&&(we.geometry.boundingBox=new Ne),we.geometry.boundingSphere===null&&(we.geometry.boundingSphere=new Ce);for(let o=0,l=n.length;o({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data;d&&(Be.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ll.setFromProjectionMatrix(Be,t.coordinateSystem));let _=0;if(this.sortObjects){Be.copy(this.matrixWorld).invert(),ws.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Be),Ph.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Be);for(let y=0,v=l.length;y0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;sn)return;hl.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(hl);if(!(lt.far))return{distance:l,point:Dh.clone().applyMatrix4(r.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:r}}const Uh=new w,Nh=new w;class vn extends $n{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,s=e.count;i0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Vx extends pe{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:xe,this.magFilter=s!==void 0?s:xe,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Hx extends pe{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=be,this.minFilter=be,this.generateMipmaps=!1,this.needsUpdate=!0}}class po extends pe{constructor(t,e,n,i,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,i,s,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class Gx extends po{constructor(t,e,n,i,s,a){super(t,e,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Qe,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wx extends po{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Nn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Xx extends pe{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ln{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const s=n.length;let a;e?a=e:a=t*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=e||(a.isVector2?new $:new w);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new w,i=[],s=[],a=[],o=new w,l=new Dt;for(let f=0;f<=t;f++){const m=f/t;i[f]=this.getTangentAt(m,new w)}s[0]=new w,a[0]=new w;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(fe(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(fe(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(o.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class mo extends ln{constructor(t=0,e=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new $){const n=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(Jr.subVectors(i[0],i[1]).add(i[0]),c=Jr);const u=i[o%s],d=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Bh(o,l.x,c.x,h.x,u.x),Bh(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class hr extends Wt{constructor(t=[new $(0,-.5),new $(.5,0),new $(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=fe(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/e,u=new w,d=new $,f=new w,m=new w,_=new w;let g=0,p=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-g,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:g=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(m)}for(let y=0;y<=e;y++){const v=n+y*h*i,x=Math.sin(v),P=Math.cos(v);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*x,u.y=t[T].y,u.z=t[T].x*P,a.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);const C=l[3*T+0]*x,R=l[3*T+1],b=l[3*T+0]*P;c.push(C,R,b)}}for(let y=0;y0&&v(!0),e>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new St(u,3)),this.setAttribute("normal",new St(d,3)),this.setAttribute("uv",new St(f,2));function y(){const x=new w,P=new w;let T=0;const C=(e-t)/n;for(let R=0;R<=s;R++){const b=[],M=R/s,L=M*(e-t)+t;for(let k=0;k<=i;k++){const O=k/i,V=O*l+o,Z=Math.sin(V),H=Math.cos(V);P.x=L*Z,P.y=-M*n+g,P.z=L*H,u.push(P.x,P.y,P.z),x.set(Z,C,H).normalize(),d.push(x.x,x.y,x.z),f.push(O,1-M),b.push(m++)}_.push(b)}for(let R=0;R0||b!==0)&&(h.push(M,L,O),T+=3),(e>0||b!==s-1)&&(h.push(L,k,O),T+=3)}c.addGroup(p,T,0),p+=T}function v(x){const P=m,T=new $,C=new w;let R=0;const b=x===!0?t:e,M=x===!0?1:-1;for(let k=1;k<=i;k++)u.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),m++;const L=m;for(let k=0;k<=i;k++){const V=k/i*l+o,Z=Math.cos(V),H=Math.sin(V);C.x=b*H,C.y=g*M,C.z=b*Z,u.push(C.x,C.y,C.z),d.push(0,M,0),T.x=Z*.5+.5,T.y=H*.5*M+.5,f.push(T.x,T.y),m++}for(let k=0;k.9&&C<.1&&(v<.2&&(a[y+0]+=1),x<.2&&(a[y+2]+=1),P<.2&&(a[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,v){const x=y*3;v.x=t[x+0],v.y=t[x+1],v.z=t[x+2]}function m(){const y=new w,v=new w,x=new w,P=new w,T=new $,C=new $,R=new $;for(let b=0,M=0;b80*e){o=c=r[0],l=h=r[1];for(let m=e;mc&&(c=u),d>h&&(h=d);f=Math.max(c-o,h-l),f=f!==0?32767/f:0}return Qs(s,a,e,o,l,f,0),a}};function Pd(r,t,e,n,i){let s,a;if(i===mv(r,t,e,n)>0)for(s=t;s=t;s-=n)a=zh(s,r[s],r[s+1],a);return a&&yo(a,a.next)&&(tr(a),a=a.next),a}function Ii(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(yo(e,e.next)||he(e.prev,e,e.next)===0)){if(tr(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Qs(r,t,e,n,i,s,a){if(!r)return;!a&&s&&cv(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?ev(r,n,i,s):tv(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(c.i/e|0),tr(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=nv(Ii(r),t,e),Qs(r,t,e,n,i,s,2)):a===2&&iv(r,t,e,n,i,s):Qs(Ii(r),t,e,n,i,s,1);break}}}function tv(r){const t=r.prev,e=r,n=r.next;if(he(t,e,n)>=0)return!1;const i=t.x,s=e.x,a=n.x,o=t.y,l=e.y,c=n.y,h=is?i>a?i:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&ss(i,o,s,l,a,c,m.x,m.y)&&he(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function ev(r,t,e,n){const i=r.prev,s=r,a=r.next;if(he(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,d=a.y,f=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,p=Il(f,m,t,e,n),y=Il(_,g,t,e,n);let v=r.prevZ,x=r.nextZ;for(;v&&v.z>=p&&x&&x.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==i&&v!==a&&ss(o,h,l,u,c,d,v.x,v.y)&&he(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ss(o,h,l,u,c,d,x.x,x.y)&&he(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=p;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==i&&v!==a&&ss(o,h,l,u,c,d,v.x,v.y)&&he(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ss(o,h,l,u,c,d,x.x,x.y)&&he(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function nv(r,t,e){let n=r;do{const i=n.prev,s=n.next.next;!yo(i,s)&&Ld(i,n,n.next,s)&&js(i,s)&&js(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),tr(n),tr(n.next),n=r=s),n=n.next}while(n!==r);return Ii(n)}function iv(r,t,e,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&dv(a,o)){let l=Dd(a,o);a=Ii(a,a.next),l=Ii(l,l.next),Qs(a,t,e,n,i,s,0),Qs(l,t,e,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function sv(r,t,e,n){const i=[];let s,a,o,l,c;for(s=0,a=t.length;s=e.next.y&&e.next.y!==e.y){const d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>n&&(n=d,i=e.x=e.x&&e.x>=l&&s!==e.x&&ss(ai.x||e.x===i.x&&lv(i,e)))&&(i=e,h=u)),e=e.next;while(e!==o);return i}function lv(r,t){return he(r.prev,r,t.prev)<0&&he(t.next,r,r.next)<0}function cv(r,t,e,n){let i=r;do i.z===0&&(i.z=Il(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,hv(i)}function hv(r){let t,e,n,i,s,a,o,l,c=1;do{for(e=r,r=null,s=null,a=0;e;){for(a++,n=e,o=0,t=0;t0||l>0&&n;)o!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,c*=2}while(a>1);return r}function Il(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function uv(r){let t=r,e=r;do(t.x=(r-a)*(s-o)&&(r-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(i-a)*(n-o)}function dv(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!fv(r,t)&&(js(r,t)&&js(t,r)&&pv(r,t)&&(he(r.prev,r,t.prev)||he(r,t.prev,t))||yo(r,t)&&he(r.prev,r,r.next)>0&&he(t.prev,t,t.next)>0)}function he(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function yo(r,t){return r.x===t.x&&r.y===t.y}function Ld(r,t,e,n){const i=ta(he(r,t,e)),s=ta(he(r,t,n)),a=ta(he(e,n,r)),o=ta(he(e,n,t));return!!(i!==s&&a!==o||i===0&&jr(r,e,t)||s===0&&jr(r,n,t)||a===0&&jr(e,r,n)||o===0&&jr(e,t,n))}function jr(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ta(r){return r>0?1:r<0?-1:0}function fv(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Ld(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function js(r,t){return he(r.prev,r,r.next)<0?he(r,t,r.next)>=0&&he(r,r.prev,t)>=0:he(r,t,r.prev)<0||he(r,r.next,t)<0}function pv(r,t){let e=r,n=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Dd(r,t){const e=new Pl(r.i,r.x,r.y),n=new Pl(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function zh(r,t,e,n){const i=new Pl(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function tr(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Pl(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function mv(r,t,e,n){let i=0;for(let s=t,a=e-n;s2&&r[t-1].equals(r[0])&&r.pop()}function Vh(r,t){for(let e=0;eNumber.EPSILON){const X=Math.sqrt(S),Q=Math.sqrt(gt*gt+A*A),q=nt.x-Pt/X,Et=nt.y+at/X,ct=I.x-A/Q,_t=I.y+gt/Q,qt=((ct-q)*A-(_t-Et)*gt)/(at*A-Pt*gt);Ct=q+at*qt-K.x,j=Et+Pt*qt-K.y;const tt=Ct*Ct+j*j;if(tt<=2)return new $(Ct,j);xt=Math.sqrt(tt/2)}else{let X=!1;at>Number.EPSILON?gt>Number.EPSILON&&(X=!0):at<-Number.EPSILON?gt<-Number.EPSILON&&(X=!0):Math.sign(Pt)===Math.sign(A)&&(X=!0),X?(Ct=-Pt,j=at,xt=Math.sqrt(S)):(Ct=at,j=Pt,xt=Math.sqrt(S/2))}return new $(Ct/xt,j/xt)}const ot=[];for(let K=0,nt=V.length,I=nt-1,Ct=K+1;K=0;K--){const nt=K/g,I=f*Math.cos(nt*Math.PI/2),Ct=m*Math.sin(nt*Math.PI/2)+_;for(let j=0,xt=V.length;j=0;){const Ct=I;let j=I-1;j<0&&(j=K.length-1);for(let xt=0,at=h+g*2;xt0)&&f.push(v,x,T),(p!==n-1||l0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Bd extends Re{static get type(){return"MeshPhongMaterial"}constructor(t){super(),this.isMeshPhongMaterial=!0,this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kn,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=rr,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class zd extends Re{static get type(){return"MeshToonMaterial"}constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kn,this.normalScale=new $(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class kd extends Re{static get type(){return"MeshNormalMaterial"}constructor(t){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kn,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Vd extends Re{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kn,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=rr,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Hd extends Re{static get type(){return"MeshMatcapMaterial"}constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kn,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Gd extends Fe{static get type(){return"LineDashedMaterial"}constructor(t){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Mi(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function Wd(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Xd(r){function t(i,s){return r[i]-r[s]}const e=r.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function Ll(r,t,e){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=e[s]*t;for(let l=0;l!==t;++l)i[a++]=r[o+l]}return i}function dc(r,t,e,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(t.push(s.time),e.push.apply(e,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(t.push(s.time),e.push(a)),s=r[i++];while(s!==void 0)}function vv(r,t,e,n,i=30){const s=r.clone();s.name=t;const a=[];for(let l=0;l=n)){u.push(c.times[f]);for(let _=0;_s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[m]){const p=m*u+h,y=p+u-h;_=o.values.slice(p,y)}else{const p=o.createInterpolant(),y=h,v=u-h;p.evaluate(s),_=p.resultBuffer.slice(y,v)}l==="quaternion"&&new Ge().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let p=0;p=s)){const o=e[1];t=s)break e}a=n,n=0;break n}break t}for(;n>>1;te;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(i!==void 0&&Wd(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===la,s=t.length-1;let a=1;for(let o=1;o0){t[a]=t[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}cn.prototype.TimeBufferType=Float32Array;cn.prototype.ValueBufferType=Float32Array;cn.prototype.DefaultInterpolation=Xa;class Di extends cn{constructor(t,e,n){super(t,e,n)}}Di.prototype.ValueTypeName="bool";Di.prototype.ValueBufferType=Array;Di.prototype.DefaultInterpolation=qs;Di.prototype.InterpolantFactoryMethodLinear=void 0;Di.prototype.InterpolantFactoryMethodSmooth=void 0;class pc extends cn{}pc.prototype.ValueTypeName="color";class er extends cn{}er.prototype.ValueTypeName="number";class Zd extends fr{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(i-e);let c=t*o;for(let h=c+o;c!==h;c+=4)Ge.slerpFlat(s,0,a,c-o,a,c,l);return s}}class pr extends cn{InterpolantFactoryMethodLinear(t){return new Zd(this.times,this.values,this.getValueSize(),t)}}pr.prototype.ValueTypeName="quaternion";pr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ui extends cn{constructor(t,e,n){super(t,e,n)}}Ui.prototype.ValueTypeName="string";Ui.prototype.ValueBufferType=Array;Ui.prototype.DefaultInterpolation=qs;Ui.prototype.InterpolantFactoryMethodLinear=void 0;Ui.prototype.InterpolantFactoryMethodSmooth=void 0;class nr extends cn{}nr.prototype.ValueTypeName="vector";class ir{constructor(t="",e=-1,n=[],i=io){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Ze(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(bv(n[a]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,a=n.length;s!==a;++s)e.push(cn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,a=[];for(let o=0;o1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,m,_){if(f.length!==0){const g=[],p=[];dc(f,g,p,m),g.length!==0&&_.push(new u(d,g,p))}},i=[],s=t.name||"default",a=t.fps||30,o=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u{e&&e(s),this.manager.itemEnd(t)},0),s;if(wn[t]!==void 0){wn[t].push({onLoad:e,onProgress:n,onError:i});return}wn[t]=[],wn[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=wn[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let _=0;const g=new ReadableStream({start(p){y();function y(){u.read().then(({done:v,value:x})=>{if(v)p.close();else{_+=x.byteLength;const P=new ProgressEvent("progress",{lengthComputable:m,loaded:_,total:f});for(let T=0,C=h.length;T{p.error(v)})}}});return new Response(g)}else throw new Ev(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{In.add(t,c);const h=wn[t];delete wn[t];for(let u=0,d=h.length;u{const h=wn[t];if(h===void 0)throw this.manager.itemError(t),c;delete wn[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Tv extends We{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new On(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){try{e(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const s in t.uniforms){const a=t.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new pt().setHex(a.value);break;case"v2":i.uniforms[s].value=new $().fromArray(a.value);break;case"v3":i.uniforms[s].value=new w().fromArray(a.value);break;case"v4":i.uniforms[s].value=new Kt().fromArray(a.value);break;case"m3":i.uniforms[s].value=new Bt().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Dt().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(const s in t.extensions)i.extensions[s]=t.extensions[s];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let s=t.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new $().fromArray(s)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new $().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Ro.createMaterialFromType(t)}static createMaterialFromType(t){const e={ShadowMaterial:Nd,SpriteMaterial:nc,RawShaderMaterial:Fd,ShaderMaterial:on,PointsMaterial:sc,MeshPhysicalMaterial:Od,MeshStandardMaterial:uc,MeshPhongMaterial:Bd,MeshToonMaterial:zd,MeshNormalMaterial:kd,MeshLambertMaterial:Vd,MeshDepthMaterial:tc,MeshDistanceMaterial:ec,MeshBasicMaterial:Qn,MeshMatcapMaterial:Hd,LineDashedMaterial:Gd,LineBasicMaterial:Fe,Material:Re};return new e[t]}}class Dl{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n0){const l=new mc(e);s=new sr(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c0){i=new sr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=t.length;a{const g=new Ne;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);const p=new Ce;return p.radius=_.sphereRadius,p.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:p}}),a._maxInstanceCount=t.maxInstanceCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._geometryCount=t.geometryCount,a._matricesTexture=c(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(a._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":a=new vd;break;case"Line":a=new $n(o(t.geometry),l(t.material));break;case"LineLoop":a=new bd(o(t.geometry),l(t.material));break;case"LineSegments":a=new vn(o(t.geometry),l(t.material));break;case"PointCloud":case"Points":a=new Ed(o(t.geometry),l(t.material));break;case"Sprite":a=new xd(l(t.material));break;case"Group":a=new is;break;case"Bone":a=new ic;break;default:a=new Qt}if(a.uuid=t.uuid,t.name!==void 0&&(a.name=t.name),t.matrix!==void 0?(a.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(t.position!==void 0&&a.position.fromArray(t.position),t.rotation!==void 0&&a.rotation.fromArray(t.rotation),t.quaternion!==void 0&&a.quaternion.fromArray(t.quaternion),t.scale!==void 0&&a.scale.fromArray(t.scale)),t.up!==void 0&&a.up.fromArray(t.up),t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(a.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(a.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(a.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(a.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(a.visible=t.visible),t.frustumCulled!==void 0&&(a.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(a.renderOrder=t.renderOrder),t.userData!==void 0&&(a.userData=t.userData),t.layers!==void 0&&(a.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=In.get(t);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(c=>{e&&e(c),s.manager.itemEnd(t)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return In.add(t,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){i&&i(c),In.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});In.add(t,l),s.manager.itemStart(t)}}let ea;class _c{static getContext(){return ea===void 0&&(ea=new(window.AudioContext||window.webkitAudioContext)),ea}static setContext(t){ea=t}}class Fv extends We{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new On(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){try{const c=l.slice(0);_c.getContext().decodeAudioData(c,function(u){e(u)}).catch(o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(t)}}}const Jh=new Dt,$h=new Dt,hi=new Dt;class Ov{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Se,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Se,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(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,hi.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,a=e.near*Math.tan(Ei*e.fov*.5)/e.zoom;let o,l;$h.elements[12]=-i,Jh.elements[12]=i,o=-a*e.aspect+s,l=a*e.aspect+s,hi.elements[0]=2*e.near/(l-o),hi.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(hi),o=-a*e.aspect-s,l=a*e.aspect-s,hi.elements[0]=2*e.near/(l-o),hi.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(hi)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply($h),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Jh)}}class of{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Kh(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Kh();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Kh(){return performance.now()}const ui=new w,Qh=new Ge,Bv=new w,di=new w;class zv extends Qt{constructor(){super(),this.type="AudioListener",this.context=_c.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new of}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(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ui,Qh,Bv),di.set(0,0,-1).applyQuaternion(Qh),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ui.x,i),e.positionY.linearRampToValueAtTime(ui.y,i),e.positionZ.linearRampToValueAtTime(ui.z,i),e.forwardX.linearRampToValueAtTime(di.x,i),e.forwardY.linearRampToValueAtTime(di.y,i),e.forwardZ.linearRampToValueAtTime(di.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(ui.x,ui.y,ui.z),e.setOrientation(di.x,di.y,di.z,n.x,n.y,n.z)}}class lf extends Qt{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=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+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,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(t=0){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.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){o.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let s=n,a=i;s!==a;++s)e[s]=e[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let a=0;a!==s;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){Ge.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const a=this._workIndex*s;Ge.multiplyQuaternionsFlat(t,a,t,e,t,n),Ge.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=e+o;t[l]=t[l]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,s){for(let a=0;a!==s;++a){const o=e+a;t[o]=t[o]+t[n+a]*i}}}const xc="\\[\\]\\.:\\/",Gv=new RegExp("["+xc+"]","g"),vc="[^"+xc+"]",Wv="[^"+xc.replace("\\.","")+"]",Xv=/((?:WC+[\/:])*)/.source.replace("WC",vc),qv=/(WCOD+)?/.source.replace("WCOD",Wv),Yv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vc),Zv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vc),Jv=new RegExp("^"+Xv+qv+Yv+Zv+"$"),$v=["material","materials","bones","map"];class Kv{constructor(t,e,n){const i=n||$t.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class $t{constructor(t,e,n){this.path=e,this.parsedPath=n||$t.parseTrackName(e),this.node=$t.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new $t.Composite(t,e,n):new $t(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Gv,"")}static parseTrackName(t){const e=Jv.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);$v.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s){for(let a=0;a=s){const u=s++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,m=i;f!==m;++f){const _=n[f],g=_[u],p=_[h];_[h]=g,_[u]=p}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=t.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,_=i;m!==_;++m){const g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[t]=i,a.push(t),o.push(e),s.push(u);for(let d=h,f=l.length;d!==f;++d){const m=l[d];u[d]=new $t(m,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=t[o];e[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class hf{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,a=s.length,o=new Array(a),l={endingStart:xi,endingEnd:xi};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Hu,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const i=this._clip.duration,s=t._clip.duration,a=s/i,o=i/s;t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=t/a,c[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case ql:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case io:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const a=n===Gu;if(t===0)return s===-1?i:a&&(s&1)===1?e-i:i;if(n===Vu){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){const o=Math.floor(i/e);i-=e*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=vi,i.endingEnd=vi):(t?i.endingStart=this.zeroSlopeAtStart?vi:xi:i.endingStart=Ys,e?i.endingEnd=this.zeroSlopeAtEnd?vi:xi:i.endingEnd=Ys)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=e,o[1]=s+t,l[1]=n,this}}const jv=new Float32Array(1);class ty extends xn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,a=t._propertyBindings,o=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}const _=e&&e._propertyBindings[u].binding.parsedPath;m=new cf($t.create(n,f,_),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(t){this.time=0;for(let e=0;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,nu).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const iu=new w,na=new w;class cy{constructor(t=new w,e=new w){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){iu.subVectors(t,this.start),na.subVectors(this.end,this.start);const n=na.dot(na);let s=na.dot(iu)/n;return e&&(s=fe(s,0,1)),s}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const su=new w;class hy extends Qt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Wt,i=[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 a=0,o=1,l=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{cu.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(cu,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class by extends vn{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Wt;i.setAttribute("position",new St(e,3)),i.setAttribute("color",new St(n,3));const s=new Fe({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){const i=new pt,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ey{constructor(){this.type="ShapePath",this.color=new pt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Ks,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,a){return this.currentPath.bezierCurveTo(t,e,n,i,s,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){const y=[];for(let v=0,x=p.length;vNumber.EPSILON){if(M<0&&(C=y[T],b=-b,R=y[P],M=-M),p.yR.y)continue;if(p.y===C.y){if(p.x===C.x)return!0}else{const L=M*(p.x-C.x)-b*(p.y-C.y);if(L===0)return!0;if(L<0)continue;x=!x}}else{if(p.y!==C.y)continue;if(R.x<=p.x&&p.x<=C.x||C.x<=p.x&&p.x<=R.x)return!0}}return x}const i=gn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new Ti,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=t?!h:h;const u=[],d=[];let f=[],m=0,_;d[m]=void 0,f[m]=[];for(let p=0,y=s.length;p1){let p=!1,y=0;for(let v=0,x=d.length;v0&&p===!1&&(f=u)}let g;for(let p=0,y=d.length;p{console.warn(y)}))},navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",T).then(b).catch(y=>{console.warn(y)})}function a(){s.style.display="",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function i(){a(),s.textContent="VR NOT SUPPORTED"}function h(n){a(),console.warn("Exception when trying to call xr.isSessionSupported",n),s.textContent="VR NOT ALLOWED"}function l(n){n.style.position="absolute",n.style.bottom="20px",n.style.padding="12px 6px",n.style.border="1px solid #fff",n.style.borderRadius="4px",n.style.background="rgba(0,0,0,0.1)",n.style.color="#fff",n.style.font="normal 13px sans-serif",n.style.textAlign="center",n.style.opacity="0.5",n.style.outline="none",n.style.zIndex="999"}if("xr"in navigator)return s.id="VRButton",s.style.display="none",l(s),navigator.xr.isSessionSupported("immersive-vr").then(function(n){n?r():i(),n&&g.xrSessionIsGranted&&s.click()}).catch(h),s;{const n=document.createElement("a");return window.isSecureContext===!1?(n.href=document.location.href.replace(/^http:/,"https:"),n.innerHTML="WEBXR NEEDS HTTPS"):(n.href="https://immersiveweb.dev/",n.innerHTML="WEBXR NOT AVAILABLE"),n.style.left="calc(50% - 90px)",n.style.width="180px",n.style.textDecoration="none",l(n),n}}static registerSessionGrantedListener(){if(typeof navigator<"u"&&"xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{g.xrSessionIsGranted=!0})}}}g.xrSessionIsGranted=!1;g.registerSessionGrantedListener();const u={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function U(o){const e=await fetch(o);if(e.ok)return e.json();throw new Error(e.statusText)}async function re(o){if(!o)throw new Error("No basePath supplied");return await U(`${o}/profilesList.json`)}async function le(o,e,t=null,s=!0){if(!o)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const r=await re(e);let a;if(o.profiles.some(l=>{const n=r[l];return n&&(a={profileId:l,profilePath:`${e}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!t)throw new Error("No matching profile name found");const l=r[t];if(!l)throw new Error(`No matching profile name found and default profile "${t}" missing.`);a={profileId:t,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}}const i=await U(a.profilePath);let h;if(s){let l;if(o.handedness==="any"?l=i.layouts[Object.keys(i.layouts)[0]]:l=i.layouts[o.handedness],!l)throw new Error(`No matching handedness, ${o.handedness}, in profile ${a.profileId}`);l.assetPath&&(h=a.profilePath.replace("profile.json",l.assetPath))}return{profile:i,assetPath:h}}const de={xAxis:0,yAxis:0,button:0,state:u.ComponentState.DEFAULT};function ue(o=0,e=0){let t=o,s=e;if(Math.sqrt(o*o+e*e)>1){const i=Math.atan2(e,o);t=Math.cos(i),s=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:s*.5+.5}}class ce{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===u.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(de)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:r}){const{normalizedXAxis:a,normalizedYAxis:i}=ue(e,t);switch(this.componentProperty){case u.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?a:.5;break;case u.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?i:.5;break;case u.ComponentProperty.BUTTON:this.value=this.states.includes(r)?s:0;break;case u.ComponentProperty.STATE:this.valueNodeProperty===u.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class he{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(s=>{const r=new ce(t.visualResponses[s]);this.visualResponses[s]=r}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:u.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=u.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=u.ComponentState.PRESSED:(t.touched||this.values.button>u.ButtonTouchThreshold)&&(this.values.state=u.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===u.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>u.AxisTouchThreshold&&(this.values.state=u.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===u.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>u.AxisTouchThreshold&&(this.values.state=u.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class pe{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(r=>{const a=this.layoutDescription.components[r];this.components[r]=new he(r,a)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const fe="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",me="generic-trigger";class xe extends z{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(t=>{t.isMesh&&(t.material.envMap=this.envMap,t.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(t=>{Object.values(t.visualResponses).forEach(s=>{const{valueNode:r,minNode:a,maxNode:i,value:h,valueNodeProperty:l}=s;r&&(l===u.VisualResponseProperty.VISIBILITY?r.visible=h:l===u.VisualResponseProperty.TRANSFORM&&(r.quaternion.slerpQuaternions(a.quaternion,i.quaternion,h),r.position.lerpVectors(a.position,i.position,h)))})}))}}function ye(o,e){Object.values(o.components).forEach(t=>{const{type:s,touchPointNodeName:r,visualResponses:a}=t;if(s===u.ComponentType.TOUCHPAD)if(t.touchPointNode=e.getObjectByName(r),t.touchPointNode){const i=new H(.001),h=new R({color:255}),l=new O(i,h);t.touchPointNode.add(l)}else console.warn(`Could not find touch dot, ${t.touchPointNodeName}, in touchpad component ${t.id}`);Object.values(a).forEach(i=>{const{valueNodeName:h,minNodeName:l,maxNodeName:n,valueNodeProperty:b}=i;if(b===u.VisualResponseProperty.TRANSFORM){if(i.minNode=e.getObjectByName(l),i.maxNode=e.getObjectByName(n),!i.minNode){console.warn(`Could not find ${l} in the model`);return}if(!i.maxNode){console.warn(`Could not find ${n} in the model`);return}}i.valueNode=e.getObjectByName(h),i.valueNode||console.warn(`Could not find ${h} in the model`)})})}function j(o,e){ye(o.motionController,e),o.envMap&&e.traverse(t=>{t.isMesh&&(t.material.envMap=o.envMap,t.material.needsUpdate=!0)}),o.add(e)}class ve{constructor(e=null,t=null){this.gltfLoader=e,this.path=fe,this._assetCache={},this.onLoad=t,this.gltfLoader||(this.gltfLoader=new ie)}setPath(e){return this.path=e,this}createControllerModel(e){const t=new xe;let s=null;return e.addEventListener("connected",r=>{const a=r.data;a.targetRayMode!=="tracked-pointer"||!a.gamepad||a.hand||le(a,this.path,me).then(({profile:i,assetPath:h})=>{t.motionController=new pe(a,i,h);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),j(t,s),this.onLoad&&this.onLoad(s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,n=>{this._assetCache[t.motionController.assetUrl]=n,s=n.scene.clone(),j(t,s),this.onLoad&&this.onLoad(s)},null,()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)})}}).catch(i=>{console.warn(i)})}),e.addEventListener("disconnected",()=>{t.motionController=null,t.remove(s),s=null}),t}}let p,v,c,d,m,L,P,w,N,V,f,A,x,C,E=null;const S=[],we=new G(0,1,0),k={displayGrid:!0};ge();function ge(){v=new W,c=new D({antialias:!0}),c.setPixelRatio(window.devicePixelRatio),c.setSize(window.innerWidth,window.innerHeight),c.setClearColor(12303291),c.xr.enabled=!0,document.body.appendChild(c.domElement),c.domElement.tabIndex=1,c.setAnimationLoop(Ee),m=new M,v.add(m),w=new $(10,10,16777215,16777215),w.material.transparent=!0,w.material.opacity=.5,w.material.depthWrite=!1,m.add(w),p=new X(60,window.innerWidth/window.innerHeight,.1,4e3),p.position.set(0,1,0),m.add(p);const o=new _(16777215);o.position.set(1,2,3),v.add(o);const e=new q(16777215,.2);v.add(e),L=new te,P=new se,A=new M,A.rotation.x=Math.PI/2,A.position.y=32,v.add(A),d=new ae("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/scene-tileset.json"),A.add(d.group),d.setCamera(p),d.setResolutionFromRenderer(p,c);const t=i=>{S.push(i)};d.downloadQueue.schedulingCallback=t,d.parseQueue.schedulingCallback=t,d.lruCache.maxSize=1200,d.lruCache.minSize=900,N=new oe,V=new G(0,0,1);const s=new R({color:11722715});f=new O(new Y(1.5,.2,16,100),s),f.visible=!1,v.add(f),document.body.appendChild(g.createButton(c)),x=c.xr.getController(0),x.addEventListener("selectstart",()=>{f.visible&&m.position.copy(f.position)}),x.addEventListener("connected",function(i){this.controllerActive=!0,this.add(be(i.data))}),x.addEventListener("disconnected",function(){this.controllerActive=!1,this.remove(this.children[0])}),m.add(x);const r=new ve;C=c.xr.getControllerGrip(0),C.add(r.createControllerModel(C)),m.add(C),B(),window.addEventListener("resize",B,!1);const a=new ne;a.width=300,a.add(k,"displayGrid"),a.open()}function be(o){let e,t;switch(o.targetRayMode){case"tracked-pointer":return e=new J,e.setAttribute("position",new F([0,0,0,0,0,-1],3)),e.setAttribute("color",new F([.5,.5,.5,0,0,0],3)),t=new K({vertexColors:!0,blending:Z,depthWrite:!1,transparent:!0}),new ee(e,t);case"gaze":return e=new Q(.02,.04,32).translate(0,0,-1),t=new R({opacity:.5,transparent:!0}),new O(e,t)}}function B(){p.updateProjectionMatrix(),c.setPixelRatio(window.devicePixelRatio),c.setSize(window.innerWidth,window.innerHeight),p.aspect=window.innerWidth/window.innerHeight,p.updateProjectionMatrix()}function Ae(){if(c.xr.isPresenting){if(E===null){const o=c.xr.getCamera(p);d.cameras.forEach(t=>d.deleteCamera(t)),d.setCamera(o);const e=o.cameras[0];e&&d.setResolution(o,e.viewport.z,e.viewport.w),E=c.xr.getSession()}}else E!==null&&(d.cameras.forEach(o=>d.deleteCamera(o)),d.setCamera(p),d.setResolutionFromRenderer(p,c),p.position.set(0,1,0),E=null)}function Ce(){for(let o=0,e=S.length;o + + + + + + 3D Tiles Renderer Batch Example + + + + + + + + + + + +
+ + diff --git a/example/bundle/cmptExample.html b/example/bundle/cmptExample.html new file mode 100644 index 00000000..9e3fb04e --- /dev/null +++ b/example/bundle/cmptExample.html @@ -0,0 +1,40 @@ + + + + + + + 3D Tiles Renderer Composite Format Example + + + + + + + + + + + + + + + + + diff --git a/example/bundle/customMaterial.html b/example/bundle/customMaterial.html new file mode 100644 index 00000000..e3d42a36 --- /dev/null +++ b/example/bundle/customMaterial.html @@ -0,0 +1,45 @@ + + + + + + + 3D Tiles Renderer Material Example + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/ellipsoid.html b/example/bundle/ellipsoid.html new file mode 100644 index 00000000..f8066d74 --- /dev/null +++ b/example/bundle/ellipsoid.html @@ -0,0 +1,46 @@ + + + + + + + 3D Tiles Renderer Batch Example + + + + + + + + + + + +
+ + diff --git a/example/bundle/fadingTiles.html b/example/bundle/fadingTiles.html new file mode 100644 index 00000000..74ce2537 --- /dev/null +++ b/example/bundle/fadingTiles.html @@ -0,0 +1,68 @@ + + + + + + + Dither Fade Tiles + + + + + + + + + + + + + + + + + + + + + +
+ Demonstration of tiles using a dither fade to change, smoothing out the transition. +
+ + diff --git a/example/bundle/gltf.html b/example/bundle/gltf.html new file mode 100644 index 00000000..26976b32 --- /dev/null +++ b/example/bundle/gltf.html @@ -0,0 +1,36 @@ + + + + + + + 3D Tiles Renderer 3DTILES_content_gltf Example + + + + + + + + + + + + + diff --git a/example/bundle/googleMapsAerial.html b/example/bundle/googleMapsAerial.html new file mode 100644 index 00000000..91b931c6 --- /dev/null +++ b/example/bundle/googleMapsAerial.html @@ -0,0 +1,85 @@ + + + + + + + Google 3D Tiles Example + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Example using Googles Photorealistic 3D Tiles - Tokyo Tower +
+ Google Cloud Tiles API key required +
+
+
+
+ + diff --git a/example/bundle/googleMapsExample.html b/example/bundle/googleMapsExample.html new file mode 100644 index 00000000..0b699f8d --- /dev/null +++ b/example/bundle/googleMapsExample.html @@ -0,0 +1,90 @@ + + + + + + + Google 3D Tiles Example + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Example using Googles Photorealistic 3D Tiles - Globe +
+ Google Cloud Tiles API key required +
+
+
+
+ + diff --git a/example/bundle/i3dmExample.html b/example/bundle/i3dmExample.html new file mode 100644 index 00000000..1c549a74 --- /dev/null +++ b/example/bundle/i3dmExample.html @@ -0,0 +1,37 @@ + + + + + + + 3D Tiles Renderer Instanced Example + + + + + + + + + + + + + + diff --git a/example/bundle/index.html b/example/bundle/index.html new file mode 100644 index 00000000..db34be1b --- /dev/null +++ b/example/bundle/index.html @@ -0,0 +1,48 @@ + + + + + + + 3D Tiles Renderer Options Example + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/ionExample.html b/example/bundle/ionExample.html new file mode 100644 index 00000000..51f5c6f3 --- /dev/null +++ b/example/bundle/ionExample.html @@ -0,0 +1,70 @@ + + + + + + + 3D Tiles Renderer Cesium Ion Integration Example + + + + + + + + + + + + + + + + + + + + + + +
+
+ Paste the evaluation Cesium Ion token from the Cesium repository or your own token and asset id
into the fields and press "reload" to see the demo. See cesium.com for more information. +
+
+
+ + diff --git a/example/bundle/ionLunar.html b/example/bundle/ionLunar.html new file mode 100644 index 00000000..dca35212 --- /dev/null +++ b/example/bundle/ionLunar.html @@ -0,0 +1,73 @@ + + + + + + + Cesium Ion Lunar Data Set + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Paste the evaluation Cesium Ion token from the Cesium repository or your own token and asset id
into the fields and press "reload" to see the demo. See cesium.com for more information. +
+
+
+ + diff --git a/example/bundle/landformSiteOverlay.html b/example/bundle/landformSiteOverlay.html new file mode 100644 index 00000000..6edccc80 --- /dev/null +++ b/example/bundle/landformSiteOverlay.html @@ -0,0 +1,68 @@ + + + + + + + Landform Drive 1004 Drive Tile Sets + + + + + + + + + + + + + + + + + + + +
+ Set of tiles from M20 Drive 1004 generated using NASA JPL's Landform with generated slope magnitude overlay. +
+ See information on this tile sets generation here. +
+ + diff --git a/example/bundle/mars.html b/example/bundle/mars.html new file mode 100644 index 00000000..257130f3 --- /dev/null +++ b/example/bundle/mars.html @@ -0,0 +1,70 @@ + + + + + + + Dingo Gap Tile Set + + + + + + + + + + + + + + + + + + + + + +
+ Dingo Gap site reconstructed from multiple sols of Curiosity Rover and Mars Reconnaissance Orbiter images. +
+ See more information here. +
+ + diff --git a/example/bundle/metadata.html b/example/bundle/metadata.html new file mode 100644 index 00000000..a4b5096f --- /dev/null +++ b/example/bundle/metadata.html @@ -0,0 +1,100 @@ + + + + + + + 3D Tiles Renderer Metadata Example + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Demonstration of displaying glTF Mesh Features and +
+ Structural Metadata properties on mouse-over. +
+ See Cesium repo for demo API key.
+
+
+
+ + diff --git a/example/bundle/offscreenShadows.html b/example/bundle/offscreenShadows.html new file mode 100644 index 00000000..075cd3e0 --- /dev/null +++ b/example/bundle/offscreenShadows.html @@ -0,0 +1,45 @@ + + + + + + + 3D Tiles Renderer Material Example + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/pntsExample.html b/example/bundle/pntsExample.html new file mode 100644 index 00000000..1af895db --- /dev/null +++ b/example/bundle/pntsExample.html @@ -0,0 +1,35 @@ + + + + + + + 3D Tiles Renderer Points Example + + + + + + + + + + + + diff --git a/example/bundle/r3f/basic.html b/example/bundle/r3f/basic.html new file mode 100644 index 00000000..f02e11f4 --- /dev/null +++ b/example/bundle/r3f/basic.html @@ -0,0 +1,55 @@ + + + + + + @react-three/fiber 3D Tiles Renderer + + + + + + + + + + + + + + + + + + + + + +
Demonstration using @react-three/fiber and @react-three/drei
+
+ + diff --git a/example/bundle/r3f/globe.html b/example/bundle/r3f/globe.html new file mode 100644 index 00000000..4b4d2a90 --- /dev/null +++ b/example/bundle/r3f/globe.html @@ -0,0 +1,66 @@ + + + + + + @react-three/fiber Cesium Ion + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Example using Google Photorealistic Tiles & @react-three/fiber. +
+ Google Cloud API Token required. +
+
+ + diff --git a/example/bundle/r3f/ion.html b/example/bundle/r3f/ion.html new file mode 100644 index 00000000..beafcfae --- /dev/null +++ b/example/bundle/r3f/ion.html @@ -0,0 +1,65 @@ + + + + + + @react-three/fiber Cesium Ion + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Example using Cesium Ion & @react-three/fiber. +
+ Paste the evaluation token from the Cesium repository or your own. +
+
+ + diff --git a/example/bundle/vr.html b/example/bundle/vr.html new file mode 100644 index 00000000..fa685ce5 --- /dev/null +++ b/example/bundle/vr.html @@ -0,0 +1,42 @@ + + + + + + + 3D Tiles Renderer VR Example + + + + + + + + + + + + + + + + + + + +