var Px=Object.defineProperty;var Ui=(n,t)=>{for(var e in t)Px(n,e,{get:t[e],enumerable:!0})};var Nt={};Ui(Nt,{AsyncFunction:()=>Dx,PI:()=>js,RESTapi:()=>W0,addCssLink:()=>H0,addCssStyle:()=>mp,arrayExtent:()=>_0,arrayLast:()=>b0,arrayMax:()=>cp,arrayMin:()=>lp,arrayToMatrix:()=>M0,arraysDiff:()=>w0,arraysEqual:()=>uh,arraysToString:()=>fh,blobToData:()=>Ox,blobsEqual:()=>Bx,checkArg:()=>kx,checkArgs:()=>Gx,clamp:()=>Dn,classHasStartup:()=>a0,clearCtx:()=>$s,cloneCanvas:()=>pp,concatArrays:()=>dh,convertArrayType:()=>Or,createCanvas:()=>Fr,createCtx:()=>ue,cssTrace:()=>Xx,ctxImageColors:()=>Mh,ctxImageData:()=>ji,ctxImagePixels:()=>N0,degToHeading:()=>Jx,degToRad:()=>tp,degreesEqual:()=>ep,degreesTowardXY:()=>s0,difference:()=>x0,distance:()=>Gi,distance3:()=>Hi,downloadBlob:()=>vh,downloadCanvas:()=>za,downloadJson:()=>D0,downloadJsonModule:()=>O0,drawText:()=>wh,dump:()=>G0,fetchCssStyle:()=>V0,fetchData:()=>La,fetchImage:()=>F0,fetchImageBitmap:()=>z0,fetchJson:()=>Fx,fetchText:()=>zx,fillCtxWithImage:()=>li,floatRamp:()=>Da,forLoop:()=>zt,fps:()=>Vx,getEventXY:()=>X0,getQueryString:()=>gp,grep:()=>u0,hasCanvas:()=>Ix,headingAngleToRad:()=>e0,headingToDeg:()=>$x,headingToRad:()=>Kx,headingTowardXY:()=>r0,headingsEq:()=>i0,identityFcn:()=>hh,imagePromise:()=>Wi,imageToCanvas:()=>B0,imageToCtx:()=>Br,inCone:()=>lh,inDeno:()=>Ca,inMain:()=>Aa,inNode:()=>Rx,inWorker:()=>ih,integerRamp:()=>Js,intersection:()=>y0,isArray:()=>Oa,isArrayLike:()=>fp,isBetween:()=>Rn,isCanvas:()=>Fa,isColorLikeArray:()=>R0,isDataSet:()=>dp,isFloatArray:()=>P0,isFunction:()=>Ir,isImage:()=>A0,isImageable:()=>ci,isIntArray:()=>L0,isInteger:()=>up,isLittleEndian:()=>I0,isNumber:()=>ai,isObject:()=>oi,isOneOfTypes:()=>xh,isOofA:()=>mn,isPowerOf2:()=>Cr,isString:()=>Le,isType:()=>Rr,isTypedArray:()=>Dr,isUintArray:()=>C0,lerp:()=>qs,lerpScale:()=>sh,logAll:()=>jx,logOnce:()=>Qd,matrixToArray:()=>S0,mod:()=>ri,mod180180:()=>Qx,mod2pi:()=>Xs,mod360:()=>pn,nestedProperty:()=>v0,nextPowerOf2:()=>Zx,noopFcn:()=>l0,objectLength:()=>d0,objectToString:()=>f0,objectsEqual:()=>p0,oneKeyOf:()=>ap,oneOf:()=>Vi,oneValOf:()=>mh,oofaBuffers:()=>T0,oofaObject:()=>hp,otherOneOf:()=>ph,parseQueryString:()=>yp,pause:()=>$d,pps:()=>Wx,precision:()=>Ra,printToPage:()=>j0,propFcn:()=>Zs,radToDeg:()=>Pr,radToHeading:()=>Ia,radToHeadingAngle:()=>t0,radiansTowardXY:()=>si,radsEqual:()=>n0,randomCentered:()=>qx,randomFloat:()=>rh,randomFloat2:()=>ii,randomInt:()=>In,randomInt2:()=>ni,randomNormal:()=>Yx,randomSeed:()=>Kd,range:()=>h0,removeArrayItem:()=>On,repeat:()=>Qe,resizeCtx:()=>bh,runModel:()=>o0,sampleModel:()=>c0,setCanvasSize:()=>Na,setCtxImage:()=>U0,setIdentity:()=>zr,setTextProperties:()=>Nr,shuffle:()=>yh,sortNums:()=>m0,sortObjs:()=>gh,sqDistance:()=>Ys,sqDistance3:()=>rp,step:()=>op,stringMetrics:()=>_h,subtractDegrees:()=>ip,subtractHeadings:()=>ch,subtractRadians:()=>np,timeit:()=>Hx,timeoutLoop:()=>Pa,toAofO:()=>gn,toDataURL:()=>Nx,toDeg:()=>oh,toJSON:()=>sp,toOofA:()=>E0,toRad:()=>ah,toWindow:()=>k0,typeOf:()=>Ce,union:()=>g0,waitUntilDone:()=>Ux,warn:()=>ki,wrap:()=>Lr});function Aa(){return globalThis.document!==void 0}function ih(){return globalThis.WorkerGlobalScope!==void 0}function Rx(){return typeof globalThis.require<"u"}function Ca(){return typeof globalThis.Deno<"u"}function Ix(){return globalThis.canvas!=="undefined"}function Dx(n,t){let e=Object.getPrototypeOf(async function(){}).constructor;return new e(...n,t)}function Ox(n,t="dataURL"){t=t[0].toUpperCase()+t.slice(1);let e=["Text","ArrayBuffer","DataURL"];if(!e.includes(t))throw Error("blobToData: data must be one of "+e.toString());let i=new FileReader;return new Promise((r,s)=>{i.addEventListener("load",()=>r(i.result)),i.addEventListener("error",o=>s(o)),i["readAs"+t](n)})}async function La(n,t="blob"){let e=["arrayBuffer","blob","json","text"];if(!e.includes(t))throw Error("fetchData: data must be one of "+e.toString());return fetch(n).then(i=>i[t]())}async function Fx(n){return La(n,"json")}async function zx(n){return La(n,"text")}function Nx(n,t=void 0){return n.toDataURL?n.toDataURL(t,t):(t||(t="text/plain;charset=US-ASCII"),`data:${t};base64,${btoa(n)}}`)}async function Bx(n,t){let e=await n.text(),i=await t.text();return e===i}function $d(n=1e3){return new Promise(t=>{setTimeout(t,n)})}async function Pa(n,t=-1,e=0){let i=0;for(;i++!==t;)n(i-1),await $d(e)}function Ux(n,t=10){return new Promise(e=>{function i(){if(n())return e();setTimeout(i,t)}i()})}function kx(n,t="number",e="Function"){}function Gx(n,t="number",e="Function"){}var Jd=new Set;function Qd(n,t=!1){Jd.has(n)||(t?console.warn(n):console.log(n),Jd.add(n))}function ki(n){Qd(n,!0)}function Hx(n,t=1e5,e="test"){e=e+"-"+t,console.time(e);for(let i=0;i<t;i++)n(i);console.timeEnd(e)}function Vx(){let n=typeof performance>"u"?Date:performance,t=n.now(),e=0;function i(){e++;let r=n.now()-t,s=parseFloat((e/(r/1e3)).toFixed(2));Object.assign(i,{fps:s,ms:r,start:t,steps:e})}return i.steps=0,i}function Wx(n,t=""){t&&console.log(t);let e=1,i="";for(;n;){if(typeof n=="function")i=n.constructor.toString();else{let r=Object.keys(n);i=r.length>0?`[${r.join(", ")}]`:`[${n.constructor.name}]`}console.log(`[${e++}]: ${i}`),n=Object.getPrototypeOf(n)}}function jx(n){Object.keys(n).forEach(t=>console.log("  ",t,n[t]))}function Xx(n,t=["position","cursor","display","width","height"]){let e=document.querySelector(n);for(;e;){let i=window.getComputedStyle(e);console.log("element:",e),console.log("tag:",e.tagName),t.forEach(r=>console.log(r+":",i[r])),console.log("------------------------"),e=e.parentElement}}var js=Math.PI;function In(n){return Math.floor(Math.random()*n)}function ni(n,t){return n+Math.floor(Math.random()*(t-n))}function rh(n){return Math.random()*n}function ii(n,t){return n+Math.random()*(t-n)}function qx(n){return ii(-n/2,n/2)}function Yx(n=0,t=1){let[e,i]=[1-Math.random(),Math.random()];return Math.sqrt(-2*Math.log(e))*Math.cos(2*js*i)*t+n}function Kd(n=123456){n=n%2147483647,Math.random=()=>(n=n*16807%2147483647,(n-1)/2147483646)}function Ra(n,t=4){if(Math.abs(n)===0)return 0;if(Array.isArray(n))return n.map(i=>Ra(i,t));let e=10**t;return Math.round(n*e)/e}var Cr=n=>(n&n-1)===0,Zx=n=>Math.pow(2,Math.ceil(Math.log2(n)));function ri(n,t){return(n%t+t)%t}var Lr=(n,t,e)=>t+ri(n-t,e-t);function Dn(n,t,e){return n<t?t:n>e?e:n}var Rn=(n,t,e)=>t<=n&&n<=e,qs=(n,t,e)=>n<=t?n+(t-n)*e:n-(n-t)*e;function sh(n,t,e){if(t===e)throw Error("lerpScale: lo === hi");return n=Dn(n,t,e),(n-t)/(e-t)}var oh=180/Math.PI,ah=Math.PI/180;function tp(n){return Xs(n*ah)}function Pr(n){return pn(n*oh)}var Jx=n=>pn(90-n),$x=n=>pn(90-n);function pn(n){return ri(n,360)}function Xs(n){return ri(n,2*js)}function Qx(n){let t=pn(n);return t>180&&(t-=360),t}function Ia(n){let t=n*oh;return pn(90-t)}function Kx(n){return pn(90-n)*ah}function t0(n){return-Pr(n)}function e0(n){return-tp(n)}function ep(n,t){return pn(n)===pn(t)}function n0(n,t){return Xs(n)===Xs(t)}var i0=ep;function np(n,t){let e=Xs(n-t);return e>js&&(e=e-2*js),e}function ip(n,t){let e=pn(n-t);return e>180&&(e=e-360),e}function ch(n,t){return-ip(n,t)}function si(n,t,e,i){return Math.atan2(i-t,e-n)}function r0(n,t,e,i){return Ia(si(n,t,e,i))}function s0(n,t,e,i){return Pr(si(n,t,e,i))}function lh(n,t,e,i,r,s,o){if(Ys(s,o,n,t)>e*e)return!1;let a=si(s,o,n,t);return i/2>=Math.abs(np(r,a))}var Ys=(n,t,e,i)=>(n-e)**2+(t-i)**2,Gi=(n,t,e,i)=>Math.sqrt(Ys(n,t,e,i)),rp=(n,t,e,i,r,s)=>(n-i)**2+(t-r)**2+(e-s)**2,Hi=(n,t,e,i,r,s)=>Math.sqrt(rp(n,t,e,i,r,s));async function o0(n,t=500,e=!0){if(console.log("runModel: model",n),e&&Kd(),Le(n)&&(n=(await import(n)).default),Ir(n)&&(n=new n),await n.startup(),n.setup(),Aa())await Pa(()=>{n.step()},t);else for(let i=0;i<t;i++)n.step();return n}function a0(n){console.log("classHasStartup?",n);let e=n.toString().split(`
`);return e=e.filter(i=>!/^ *\/\//.test(i)),e=e.filter(i=>/startup\(\)/.test(i)),e.length>0}function sp(n,t=0,e=!0){let i=e,r=["rectCache"];return JSON.stringify(n,(o,a)=>r.includes(o)?void 0:Array.isArray(a)&&a.length>0&&Number.isInteger(a[0].id)&&!i?a.map(l=>l.id):(i=!1,a),t)}function c0(n){let t={ticks:n.ticks,model:Object.keys(n),patches:n.patches.length,patch:n.patches.oneOf(),turtles:n.turtles.length,turtle:n.turtles.oneOf(),links:n.links.length,link:n.links.oneOf()},e=sp(t);return JSON.parse(e)}var hh=n=>n,l0=()=>{},Zs=n=>t=>t[n];function uh(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}function On(n,t){let e=n.indexOf(t);if(e!==-1)n.splice(e,1);else throw Error(`removeArrayItem: ${t} not in array`);return n}var fh=n=>n.map(t=>`${t}`).join(",");function zt(n,t){if(n.slice)for(let e=0,i=n.length;e<i;e++)t(n[e],e,n);else Object.keys(n).forEach(e=>t(n[e],e,n))}function Qe(n,t,e=[]){for(let i=0;i<n;i++)t(i,e);return e}function op(n,t,e){for(let i=0;i<n;i+=t)e(i)}function h0(n){return Qe(n,(t,e)=>{e[t]=t})}function u0(n,t){return n.reduce((e,i)=>(t.test(i)&&e.push(i),e),[])}function dh(n,t){let e=n.constructor;if(e===Array)return n.concat(Or(t,Array));let i=new e(n.length+t.length);return i.set(n),i.set(t,n.length),i}function f0(n,t=2,e=!0){let i=JSON.stringify(n,null,t);return e&&(i=i.replace(/"([^"]+)":/gm,"$1:")),i}function d0(n){return Object.keys(n).length}var p0=(n,t)=>JSON.stringify(n)===JSON.stringify(t);function Vi(n){return n[In(n.length)]}function ph(n,t){if(n.length<2)throw Error("otherOneOf: array.length < 2");let e;do e=Vi(n);while(t===e);return e}var ap=n=>Vi(Object.keys(n)),mh=n=>n[ap(n)];function m0(n,t=!0){return n.sort((e,i)=>t?e-i:i-e)}function gh(n,t,e=!0){typeof t=="string"&&(t=Zs(t));let i=(r,s)=>t(r)-t(s);return n.sort((r,s)=>e?i(r,s):-i(r,s))}function yh(n){for(let t=n.length-1;t>0;t--){let e=In(t);[n[e],n[t]]=[n[t],n[e]]}return n}function g0(n,t){return Array.from(new Set(n.concat(t)))}function y0(n,t){let e=new Set(t);return n.filter(i=>e.has(i))}function x0(n,t){let e=new Set(t);return n.filter(i=>!e.has(i))}function Da(n,t,e){if(e<=1)throw Error("floatRamp: numItems must be > 1");let i=[];for(let r=0;r<e;r++)i.push(n+(t-n)*(r/(e-1)));return i}function Js(n,t,e=t-n+1){return Da(n,t,e).map(i=>Math.round(i))}function v0(n,t){switch(typeof t=="string"&&(t=t.split(".")),t.length){case 1:return n[t[0]];case 2:return n[t[0]][t[1]];case 3:return n[t[0]][t[1]][t[2]];case 4:return n[t[0]][t[1]][t[2]][t[3]];default:return t.reduce((e,i)=>e[i],n)}}var b0=n=>n[n.length-1],cp=n=>n.reduce((t,e)=>Math.max(t,e)),lp=n=>n.reduce((t,e)=>Math.min(t,e)),_0=n=>[lp(n),cp(n)],w0=(n,t,e=i=>i)=>{if(n.length!==t.length)return console.log("lengths differ",n.length,t.length);let i=[];for(let r=0;r<n.length;r++)n[r]!==t[r]&&i.push([e(r),n[r],t[r]]);return i};function M0(n,t,e){if(n.length!==t*e)throw Error("arrayToMatrix: length !== width * height");let i=[];for(let r=0;r<e;r++){let s=n.slice(r*t,(r+1)*t);i.push(s)}return i}var S0=n=>n.flat();function mn(n){return oi(n)?Object.values(n).every(t=>Dr(t)):!1}function E0(n,t){let e=n.length,i=Object.keys(t),r={};return i.forEach(s=>{r[s]=new t[s](e)}),zt(n,(s,o)=>{i.forEach(a=>r[a][o]=s[a])}),r}function hp(n,t,e){let i={};return e.forEach(r=>{i[r]=n[r][t]}),i}function gn(n,t=Object.keys(n)){let e=n[t[0]].length,i=new Array(e);return zt(i,(r,s)=>{i[s]=hp(n,s,t)}),i}function T0(n){let t=[];return zt(n,e=>zt(e,i=>t.push(i.buffer))),t}var Ce=n=>({}).toString.call(n).match(/\s(\w+)/)[1].toLowerCase(),Rr=(n,t)=>Ce(n)===t,xh=(n,t)=>t.includes(Ce(n)),Le=n=>Rr(n,"string"),oi=n=>Rr(n,"object"),Oa=n=>Array.isArray(n),ai=n=>Rr(n,"number"),up=n=>Number.isInteger(n),Ir=n=>Rr(n,"function"),A0=n=>Rr(n,"image"),Fa=n=>xh(n,["htmlcanvaselement","offscreencanvas"]),ci=n=>xh(n,["image","htmlimageelement","htmlcanvaselement","offscreencanvas","imagebitmap"]),Dr=n=>Ce(n.buffer)==="arraybuffer",C0=n=>/^uint.*array$/.test(Ce(n)),L0=n=>/^int.*array$/.test(Ce(n)),P0=n=>/^float.*array$/.test(Ce(n)),fp=n=>Oa(n)||Dr(n),R0=n=>fp(n)&&[3,4].includes(n.length)&&n.every(t=>up(t)&&Rn(t,0,255)||ai(t)&&Rn(t,0,1));function I0(){let n=new Uint32Array([16909060]);return new Uint8ClampedArray(n.buffer)[0]===4}function Or(n,t){return n.constructor===t?n:t.from(n)}function dp(n){return Ce(n)==="object"&&n.width&&n.height&&n.data}function za(n,t="download.png",e=null){t.endsWith(".png")||t.endsWith(".jpeg")||(t=t+".png");let i=t.endsWith(".png")?"image/png":"image/jpeg",r=Ce(n)==="string"?n:n.toDataURL(i,e),s=document.createElement("a");s.download=t,s.href=r,s.click()}function vh(n,t="download",e=!0){dp(n)&&!Array.isArray(n.data)&&(n.data=Array.from(n.data)),Dr(n)&&(n=Array.from(n)),(oi(n)||Array.isArray(n))&&(n=e?JSON.stringify(n,null,2):JSON.stringify(n));let i=Ce(n)==="blob"?n:new Blob([n]),r=URL.createObjectURL(i),s=document.createElement("a");s.download=t,s.href=r,s.click(),URL.revokeObjectURL(r)}function D0(n,t="download.json"){vh(n,t)}function O0(n,t="json.js"){let i=`const json = ${JSON.stringify(n,null,2)}
export default json`;vh(i,t)}async function Wi(n,t=!0){if(Aa()&&t||Ca())return new Promise((e,i)=>{let r=new Image;r.crossOrigin="Anonymous",r.onload=()=>e(r),r.onerror=()=>i(`Could not load image ${n}`),r.src=n});if(ih()||!t){let e=await fetch(n).then(i=>i.blob());return createImageBitmap(e)}}async function F0(n){return new Promise((t,e)=>{let i=new Image;i.crossOrigin="Anonymous",i.onload=()=>t(i),i.onerror=()=>e(`Could not load image ${n}`),i.src=n})}async function z0(n){let t=await La(n,"blob");return createImageBitmap(t)}function Fr(n,t,e=!0){if(Aa()&&e){let i=document.createElement("canvas");return i.width=n,i.height=t,i}else{if(Ca())return globalThis.createCanvas(n,t);if(ih()||!e)return new OffscreenCanvas(n,t)}}function ue(n,t,e=!0,i={}){let r=Fr(n,t,e),s=r.getContext("2d",i);if(Ca()){let o={canvas:r};return Object.setPrototypeOf(o,s),o}else return s}function pp(n,t=!0){let e=ue(n.width,n.height,t);return e.drawImage(n,0,0),e.canvas}function bh(n,t,e){let i=pp(n.canvas);n.canvas.width=t,n.canvas.height=e,n.drawImage(i,0,0)}function Na(n,t,e){(n.width!==t||n.height!=e)&&(n.width=t,n.height=e)}function zr(n){n.save(),n.resetTransform()}function Nr(n,t,e="center",i="middle"){Object.assign(n,{font:t,textAlign:e,textBaseline:i})}var Ta;function _h(n,t,e="center",i="middle"){Ta||(Ta=ue(0,0)),Nr(Ta,t,e,i);let r=Ta.measureText(n);return r.height=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,r}function wh(n,t,e,i,r,s=!0){s&&zr(n),n.fillStyle=r.css||r,n.fillText(t,e,i),s&&n.restore()}function ji(n){return n.getImageData(0,0,n.canvas.width,n.canvas.height)}function Mh(n){let t=ji(n).data,e=[];return op(t.length,4,i=>e.push(t.subarray(i,i+4))),e}function N0(n){let t=ji(n);return new Uint32Array(t.data.buffer)}function $s(n,t=void 0){let{width:e,height:i}=n.canvas;zr(n),!t||t==="transparent"?n.clearRect(0,0,e,i):(t=t.css||t,n.fillStyle=t,n.fillRect(0,0,e,i)),n.restore()}function Br(n){let{width:t,height:e}=n,i=ue(t,e);return li(i,n),i}function B0(n){return Br(n).canvas}function li(n,t){zr(n),n.drawImage(t,0,0,n.canvas.width,n.canvas.height),n.restore()}function U0(n,t){Na(n.canvas,t.width,t.height),li(n,t)}function k0(n){Object.assign(window,n),console.log("toWindow:",Object.keys(n).join(", "))}function G0(n=window.model){let{patches:t,turtles:e,links:i}=n;Object.assign(window,{ps:t,ts:e,ls:i}),window.p=t.length>0?t.oneOf():{},window.t=e.length>0?e.oneOf():{},window.l=i.length>0?i.oneOf():{},console.log("debug: ps, ts, ls, p, t, l dumped to window")}function H0(n){let t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",n),document.head.appendChild(t)}async function V0(n){n.startsWith("/")&&(console.log("fetchCssStyle relative url",n),n=import.meta.resolve(n),console.log("        absolute url",n));let t=await fetch(n);if(!t.ok)throw Error(`fetchCssStyle: Not found: ${n}`);let e=await t.text();return mp(e),e}function mp(n){let t=document.createElement("style");t.innerHTML=n,document.head.appendChild(t)}function gp(){return window.location.search.substr(1)}function yp(n=gp()){let t={},e=new URLSearchParams(n);for(let i of e.entries()){let[r,s]=i;(s.match(/^[0-9.]+$/)||s.match(/^[0-9.]+e[0-9]+$/))&&(s=Number(s)),["true","t",""].includes(s)&&(s=!0),["false","f"].includes(s)&&(s=!1),t[r]=s}return t}function W0(n){return Object.assign(n,yp())}function j0(n,t=document.body){typeof n=="object"&&(n=JSON.stringify(n,null,2)),n="<pre>"+n+"</pre>",typeof t=="string"&&(t=document.getElementById(t)),t.style.fontFamily="monospace",t.innerHTML+=n}function X0(n,t){let e=n.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}var vp={};Ui(vp,{decode:()=>$0,encode:()=>J0,stegMsgSize:()=>Sh});async function xp(n){let t=Ce(n);switch(t){case"string":n=await Wi(n);case"htmlimageelement":return Br(n);case"htmlcanvaselement":case"offscreencanvas":return n.getContext("2d");case"canvasrenderingcontext2d":return n;default:throw Error("toContext: bad img type: "+t)}}function q0(n){let t=Ce(n);switch(t){case"number":n=String.fromCharCode(n);case"string":return new TextEncoder().encode(n);case"uint8array":case"uint8clampedarray":return n;default:throw Error("toUint8Array: bad msg type: "+t)}}function Y0(n){return[n>>Pe[0].shift,n>>Pe[1].shift&Pe[1].msgMask,n&Pe[2].msgMask]}var Pe=[{shift:5,msgMask:7,dataMask:248},{shift:3,msgMask:3,dataMask:252},{shift:0,msgMask:7,dataMask:248}];function Z0(n,t,e){let i=t*e;if(i<n.length)throw Error(`encode: image size < msg.length: ${i} ${n.length}`)}function Sh(n){for(let t=3;t<n.length;t=t+4)if(n[t]===254)return(t-3)/4;throw Error(`decode: no message terminator in image data, length = ${n.length}`)}async function J0(n,t){let e=await xp(n),{width:i,height:r}=e.canvas;Z0(t,i,r);let s=q0(t);console.log("msg buffer",s);let o=e.getImageData(0,0,i,r),a=o.data;console.log("imgageData.data",a);let c;return s.forEach((l,u)=>{let[h,d,f]=Y0(l);c=u*4,a[c]=(a[c++]&Pe[0].dataMask)+h,a[c]=(a[c++]&Pe[1].dataMask)+d,a[c]=(a[c++]&Pe[2].dataMask)+f,a[c]=255}),a[c+4]=254,console.log("encoded imgageData.data",a),e.putImageData(o,0,0),console.log("msg length",t.length),console.log("encode: embedded msg size",Sh(a)),e}async function $0(n,t=!1){let e=await xp(n),{width:i,height:r}=e.canvas,s=e.getImageData(0,0,i,r).data,o=Sh(s);console.log("decode: embedded msg size",o);let a=new Uint8Array(o);return a.forEach((c,l)=>{let u=l*4,h=(Pe[0].msgMask&s[u++])<<Pe[0].shift,d=(Pe[1].msgMask&s[u++])<<Pe[1].shift,f=(Pe[2].msgMask&s[u++])<<Pe[2].shift;a[l]=h+d+f}),console.log("decode msgArray",a),t?a:new TextDecoder().decode(a)}var Fp={};Ui(Fp,{bbox:()=>Qs,bboxPolygon:()=>xv,bearingToAzimuth:()=>rv,booleanPointInPolygon:()=>Sv,collectionOf:()=>wv,containsNumber:()=>Dp,convertArea:()=>av,convertLength:()=>ov,coordAll:()=>uv,coordEach:()=>Ur,coordReduce:()=>cv,feature:()=>yn,featureCollection:()=>ka,featureEach:()=>Lp,featureOf:()=>_v,featureReduce:()=>hv,findPoint:()=>yv,findSegment:()=>gv,flattenEach:()=>Ga,flattenReduce:()=>dv,geojsonType:()=>bv,geomEach:()=>Th,geomReduce:()=>fv,geometry:()=>Q0,geometryCollection:()=>nv,getCoord:()=>Ip,getCoords:()=>vv,getGeom:()=>Op,getType:()=>Mv,lengthToDegrees:()=>iv,lengthToRadians:()=>Eh,lineEach:()=>Rp,lineReduce:()=>mv,lineString:()=>zn,lineStrings:()=>ev,multiLineString:()=>Mp,multiPoint:()=>Sp,multiPolygon:()=>Ep,point:()=>Fn,points:()=>K0,polygon:()=>Ua,polygons:()=>tv,propEach:()=>Cp,propReduce:()=>lv,radiansToLength:()=>Tp,segmentEach:()=>Pp,segmentReduce:()=>pv});var Te=63710088e-1,wp={centimeters:Te*100,centimetres:Te*100,degrees:Te/111325,feet:Te*3.28084,inches:Te*39.37,kilometers:Te/1e3,kilometres:Te/1e3,meters:Te,metres:Te,miles:Te/1609.344,millimeters:Te*1e3,millimetres:Te*1e3,nauticalmiles:Te/1852,radians:1,yards:Te*1.0936},bp={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function yn(n,t,e){e===void 0&&(e={});var i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=n,i}function Q0(n,t,e){switch(n){case"Point":return Fn(t).geometry;case"LineString":return zn(t).geometry;case"Polygon":return Ua(t).geometry;case"MultiPoint":return Sp(t).geometry;case"MultiLineString":return Mp(t).geometry;case"MultiPolygon":return Ep(t).geometry;default:throw new Error(n+" is invalid")}}function Fn(n,t,e){if(e===void 0&&(e={}),!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ba(n[0])||!Ba(n[1]))throw new Error("coordinates must contain numbers");var i={type:"Point",coordinates:n};return yn(i,t,e)}function K0(n,t,e){return e===void 0&&(e={}),ka(n.map(function(i){return Fn(i,t)}),e)}function Ua(n,t,e){e===void 0&&(e={});for(var i=0,r=n;i<r.length;i++){var s=r[i];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<s[s.length-1].length;o++)if(s[s.length-1][o]!==s[0][o])throw new Error("First and last Position are not equivalent.")}var a={type:"Polygon",coordinates:n};return yn(a,t,e)}function tv(n,t,e){return e===void 0&&(e={}),ka(n.map(function(i){return Ua(i,t)}),e)}function zn(n,t,e){if(e===void 0&&(e={}),n.length<2)throw new Error("coordinates must be an array of two or more positions");var i={type:"LineString",coordinates:n};return yn(i,t,e)}function ev(n,t,e){return e===void 0&&(e={}),ka(n.map(function(i){return zn(i,t)}),e)}function ka(n,t){t===void 0&&(t={});var e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function Mp(n,t,e){e===void 0&&(e={});var i={type:"MultiLineString",coordinates:n};return yn(i,t,e)}function Sp(n,t,e){e===void 0&&(e={});var i={type:"MultiPoint",coordinates:n};return yn(i,t,e)}function Ep(n,t,e){e===void 0&&(e={});var i={type:"MultiPolygon",coordinates:n};return yn(i,t,e)}function nv(n,t,e){e===void 0&&(e={});var i={type:"GeometryCollection",geometries:n};return yn(i,t,e)}function Tp(n,t){t===void 0&&(t="kilometers");var e=wp[t];if(!e)throw new Error(t+" units is invalid");return n*e}function Eh(n,t){t===void 0&&(t="kilometers");var e=wp[t];if(!e)throw new Error(t+" units is invalid");return n/e}function iv(n,t){return sv(Eh(n,t))}function rv(n){var t=n%360;return t<0&&(t+=360),t}function sv(n){var t=n%(2*Math.PI);return t*180/Math.PI}function ov(n,t,e){if(t===void 0&&(t="kilometers"),e===void 0&&(e="kilometers"),!(n>=0))throw new Error("length must be a positive number");return Tp(Eh(n,t),e)}function av(n,t,e){if(t===void 0&&(t="meters"),e===void 0&&(e="kilometers"),!(n>=0))throw new Error("area must be a positive number");var i=bp[t];if(!i)throw new Error("invalid original units");var r=bp[e];if(!r)throw new Error("invalid final units");return n/i*r}function Ba(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Ap(n){return!!n&&n.constructor===Object}function Ur(n,t,e){if(n!==null)for(var i,r,s,o,a,c,l,u=0,h=0,d,f=n.type,p=f==="FeatureCollection",y=f==="Feature",x=p?n.features.length:1,g=0;g<x;g++){l=p?n.features[g].geometry:y?n.geometry:n,d=l?l.type==="GeometryCollection":!1,a=d?l.geometries.length:1;for(var m=0;m<a;m++){var b=0,v=0;if(o=d?l.geometries[m]:l,o!==null){c=o.coordinates;var w=o.type;switch(u=e&&(w==="Polygon"||w==="MultiPolygon")?1:0,w){case null:break;case"Point":if(t(c,h,g,b,v)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(t(c[i],h,g,b,v)===!1)return!1;h++,w==="MultiPoint"&&b++}w==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(r=0;r<c[i].length-u;r++){if(t(c[i][r],h,g,b,v)===!1)return!1;h++}w==="MultiLineString"&&b++,w==="Polygon"&&v++}w==="Polygon"&&b++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(v=0,r=0;r<c[i].length;r++){for(s=0;s<c[i][r].length-u;s++){if(t(c[i][r][s],h,g,b,v)===!1)return!1;h++}v++}b++}break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(Ur(o.geometries[i],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cv(n,t,e,i){var r=e;return Ur(n,function(s,o,a,c,l){o===0&&e===void 0?r=s:r=t(r,s,o,a,c,l)},i),r}function Cp(n,t){var e;switch(n.type){case"FeatureCollection":for(e=0;e<n.features.length&&t(n.features[e].properties,e)!==!1;e++);break;case"Feature":t(n.properties,0);break}}function lv(n,t,e){var i=e;return Cp(n,function(r,s){s===0&&e===void 0?i=r:i=t(i,r,s)}),i}function Lp(n,t){if(n.type==="Feature")t(n,0);else if(n.type==="FeatureCollection")for(var e=0;e<n.features.length&&t(n.features[e],e)!==!1;e++);}function hv(n,t,e){var i=e;return Lp(n,function(r,s){s===0&&e===void 0?i=r:i=t(i,r,s)}),i}function uv(n){var t=[];return Ur(n,function(e){t.push(e)}),t}function Th(n,t){var e,i,r,s,o,a,c,l,u,h,d=0,f=n.type==="FeatureCollection",p=n.type==="Feature",y=f?n.features.length:1;for(e=0;e<y;e++){for(a=f?n.features[e].geometry:p?n.geometry:n,l=f?n.features[e].properties:p?n.properties:{},u=f?n.features[e].bbox:p?n.bbox:void 0,h=f?n.features[e].id:p?n.id:void 0,c=a?a.type==="GeometryCollection":!1,o=c?a.geometries.length:1,r=0;r<o;r++){if(s=c?a.geometries[r]:a,s===null){if(t(null,d,l,u,h)===!1)return!1;continue}switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(s,d,l,u,h)===!1)return!1;break}case"GeometryCollection":{for(i=0;i<s.geometries.length;i++)if(t(s.geometries[i],d,l,u,h)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}d++}}function fv(n,t,e){var i=e;return Th(n,function(r,s,o,a,c){s===0&&e===void 0?i=r:i=t(i,r,s,o,a,c)}),i}function Ga(n,t){Th(n,function(e,i,r,s,o){var a=e===null?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return t(yn(e,r,{bbox:s,id:o}),i,0)===!1?!1:void 0}var c;switch(a){case"MultiPoint":c="Point";break;case"MultiLineString":c="LineString";break;case"MultiPolygon":c="Polygon";break}for(var l=0;l<e.coordinates.length;l++){var u=e.coordinates[l],h={type:c,coordinates:u};if(t(yn(h,r),i,l)===!1)return!1}})}function dv(n,t,e){var i=e;return Ga(n,function(r,s,o){s===0&&o===0&&e===void 0?i=r:i=t(i,r,s,o)}),i}function Pp(n,t){Ga(n,function(e,i,r){var s=0;if(e.geometry){var o=e.geometry.type;if(!(o==="Point"||o==="MultiPoint")){var a,c=0,l=0,u=0;if(Ur(e,function(h,d,f,p,y){if(a===void 0||i>c||p>l||y>u){a=h,c=i,l=p,u=y,s=0;return}var x=zn([a,h],e.properties);if(t(x,i,r,y,s)===!1)return!1;s++,a=h})===!1)return!1}}})}function pv(n,t,e){var i=e,r=!1;return Pp(n,function(s,o,a,c,l){r===!1&&e===void 0?i=s:i=t(i,s,o,a,c,l),r=!0}),i}function Rp(n,t){if(!n)throw new Error("geojson is required");Ga(n,function(e,i,r){if(e.geometry!==null){var s=e.geometry.type,o=e.geometry.coordinates;switch(s){case"LineString":if(t(e,i,r,0,0)===!1)return!1;break;case"Polygon":for(var a=0;a<o.length;a++)if(t(zn(o[a],e.properties),i,r,a)===!1)return!1;break}}})}function mv(n,t,e){var i=e;return Rp(n,function(r,s,o,a){s===0&&e===void 0?i=r:i=t(i,r,s,o,a)}),i}function gv(n,t){if(t=t||{},!Ap(t))throw new Error("options is invalid");var e=t.featureIndex||0,i=t.multiFeatureIndex||0,r=t.geometryIndex||0,s=t.segmentIndex||0,o=t.properties,a;switch(n.type){case"FeatureCollection":e<0&&(e=n.features.length+e),o=o||n.features[e].properties,a=n.features[e].geometry;break;case"Feature":o=o||n.properties,a=n.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=n;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var c=a.coordinates;switch(a.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),zn([c[s],c[s+1]],o,t);case"Polygon":return r<0&&(r=c.length+r),s<0&&(s=c[r].length+s-1),zn([c[r][s],c[r][s+1]],o,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),zn([c[i][s],c[i][s+1]],o,t);case"MultiPolygon":return i<0&&(i=c.length+i),r<0&&(r=c[i].length+r),s<0&&(s=c[i][r].length-s-1),zn([c[i][r][s],c[i][r][s+1]],o,t)}throw new Error("geojson is invalid")}function yv(n,t){if(t=t||{},!Ap(t))throw new Error("options is invalid");var e=t.featureIndex||0,i=t.multiFeatureIndex||0,r=t.geometryIndex||0,s=t.coordIndex||0,o=t.properties,a;switch(n.type){case"FeatureCollection":e<0&&(e=n.features.length+e),o=o||n.features[e].properties,a=n.features[e].geometry;break;case"Feature":o=o||n.properties,a=n.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=n;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var c=a.coordinates;switch(a.type){case"Point":return Fn(c,o,t);case"MultiPoint":return i<0&&(i=c.length+i),Fn(c[i],o,t);case"LineString":return s<0&&(s=c.length+s),Fn(c[s],o,t);case"Polygon":return r<0&&(r=c.length+r),s<0&&(s=c[r].length+s),Fn(c[r][s],o,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),Fn(c[i][s],o,t);case"MultiPolygon":return i<0&&(i=c.length+i),r<0&&(r=c[i].length+r),s<0&&(s=c[i][r].length-s),Fn(c[i][r][s],o,t)}throw new Error("geojson is invalid")}function Qs(n){var t=[1/0,1/0,-1/0,-1/0];return Ur(n,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}Qs.default=Qs;function xv(n,t){t===void 0&&(t={});var e=Number(n[0]),i=Number(n[1]),r=Number(n[2]),s=Number(n[3]);if(n.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var o=[e,i],a=[e,s],c=[r,s],l=[r,i];return Ua([[o,l,c,a,o]],t.properties,{bbox:n,id:t.id})}function Ip(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return n.geometry.coordinates;if(n.type==="Point")return n.coordinates}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return n;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function vv(n){if(Array.isArray(n))return n;if(n.type==="Feature"){if(n.geometry!==null)return n.geometry.coordinates}else if(n.coordinates)return n.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Dp(n){if(n.length>1&&Ba(n[0])&&Ba(n[1]))return!0;if(Array.isArray(n[0])&&n[0].length)return Dp(n[0]);throw new Error("coordinates must only contain numbers")}function bv(n,t,e){if(!t||!e)throw new Error("type and name required");if(!n||n.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+n.type)}function _v(n,t,e){if(!n)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!n||n.type!=="Feature"||!n.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!n.geometry||n.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+n.geometry.type)}function wv(n,t,e){if(!n)throw new Error("No featureCollection passed");if(!e)throw new Error(".collectionOf() requires a name");if(!n||n.type!=="FeatureCollection")throw new Error("Invalid input to "+e+", FeatureCollection required");for(var i=0,r=n.features;i<r.length;i++){var s=r[i];if(!s||s.type!=="Feature"||!s.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!s.geometry||s.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+s.geometry.type)}}function Op(n){return n.type==="Feature"?n.geometry:n}function Mv(n,t){return n.type==="FeatureCollection"?"FeatureCollection":n.type==="GeometryCollection"?"GeometryCollection":n.type==="Feature"&&n.geometry!==null?n.geometry.type:n.type}function Sv(n,t,e){if(e===void 0&&(e={}),!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");var i=Ip(n),r=Op(t),s=r.type,o=t.bbox,a=r.coordinates;if(o&&Ev(i,o)===!1)return!1;s==="Polygon"&&(a=[a]);for(var c=!1,l=0;l<a.length&&!c;l++)if(_p(i,a[l][0],e.ignoreBoundary)){for(var u=!1,h=1;h<a[l].length&&!u;)_p(i,a[l][h],!e.ignoreBoundary)&&(u=!0),h++;u||(c=!0)}return c}function _p(n,t,e){var i=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var r=0,s=t.length-1;r<t.length;s=r++){var o=t[r][0],a=t[r][1],c=t[s][0],l=t[s][1],u=n[1]*(o-c)+a*(c-n[0])+l*(n[0]-o)===0&&(o-n[0])*(c-n[0])<=0&&(a-n[1])*(l-n[1])<=0;if(u)return!e;var h=a>n[1]!=l>n[1]&&n[0]<(c-o)*(n[1]-a)/(l-a)+o;h&&(i=!i)}return i}function Ev(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}var Ah=class n extends Array{static get[Symbol.species](){return n}static fromArray(t){return Object.setPrototypeOf(t,n.prototype)}constructor(...t){super(...t)}toArray(){return Object.setPrototypeOf(this,Array.prototype),this}isEmpty(){return this.length===0}first(){return this[0]}last(){return this[this.length-1]}atIndex(t){if(this.length===0)return;let e=ri(t,this.length);return this[e]}all(t){return this.every(t)}props(t,e=n){let i=new e(this.length);for(let r=0;r<this.length;r++)i[r]=this[r][t];return i}typedSample(t){let e={};return zt(t,(i,r)=>{e[r]=this.props(r,i)}),e}uniq(){return n.from(new Set(this))}forLoop(t){for(let e=0,i=this.length;e<i;e++)t(this[e],e,this);return this}ask(t){let e=this.length;for(let i=0;i<Math.min(e,this.length);i++)t(this[i],i,this);if(e!=this.length){let i=this.name||this.constructor.name,r=this.length<e?"decreasing":"increasing";ki(`AgentArray.ask array mutation: ${i}: ${r}`)}}with(t){return this.filter(t)}other(t){return this.filter(e=>e!==t)}getValues(t){let e=new n;return Le(t)?this.forLoop(i=>e.push(i[t])):this.forLoop(i=>e.push(t(i))),e}count(t){return this.reduce((e,i)=>e+(t(i)?1:0),0)}sum(t){return this.reduce((e,i)=>e+(t?i[t]:i),0)}avg(t){return this.sum(t)/this.length}min(t){return this.reduce((e,i)=>Math.min(e,t?i[t]:i),1/0)}max(t){return this.reduce((e,i)=>Math.max(e,t?i[t]:i),-1/0)}extent(t){return[this.min(t),this.max(t)]}histogram(t,e=10,i=this.min(t),r=this.max(t)){let s=(r-i)/e,o=new n(e);return o.fill(0),this.ask(a=>{let c=t?a[t]:a;if(c<i||c>r)ki(`histogram bounds error: ${c}: ${i}-${r}`);else{let l=Math.floor((c-i)/s);l===e&&l--,o[l]++}}),o.parameters={key:t,bins:e,min:i,max:r,binSize:s,arraySize:this.length},o}clone(){return this.slice(0)}shuffle(){return yh(this)}sortBy(t,e=!0){return gh(this,t,e),this}remove(t,e){let i=this.agentIndex(t,e);return i!==-1?this.splice(i,1):console.log(`remove: ${t.id} not in AgentArray`),this}insert(t,e){let i=this.sortedIndex(t,e);if(this[i]===t){console.log(`insert: item ${t.id} already in AgentArray`);return}this.splice(i,0,t)}sortedIndex(t,e=hh){Le(e)&&(e=Zs(e));let i=e(t),r=0,s=this.length;for(;r<s;){let o=r+s>>>1;e(this[o])<i?r=o+1:s=o}return r}agentIndex(t,e){if(!e)return this.indexOf(t);let i=this.sortedIndex(t,e);return this[i]===t?i:-1}contains(t,e){return this.agentIndex(t,e)>=0}oneOf(){return Vi(this)}otherOneOf(t){return ph(this,t)}otherNOf(t,e){if(this.length<t)throw Error("AgentArray: otherNOf: length < N");return this.clone().remove(e).shuffle().slice(0,t)}minOrMaxOf(t,e,i=!1){if(this.isEmpty())throw Error("min/max OneOf: empty array");typeof e=="string"&&(e=Zs(e));let r=null,s=t?1/0:-1/0;for(let o=0;o<this.length;o++){let a=this[o],c=e(a);(t&&c<s||!t&&c>s)&&([r,s]=[a,c])}return i?[r,s]:r}minOneOf(t){return this.minOrMaxOf(!0,t)}maxOneOf(t){return this.minOrMaxOf(!1,t)}minValOf(t){return this.minOrMaxOf(!0,t,!0)}maxValOf(t){return this.minOrMaxOf(!1,t,!0)}nOf(t){if(t>this.length)throw Error(`nOf: n larger than AgentArray: ${t} ${this.length}`);if(t===this.length)return this;let e=new n;for(;e.length<t;){let i=this.oneOf();i in e||e.push(i)}return e}minOrMaxNOf(t,e,i){if(e>this.length)throw Error("min/max nOf: n larger than AgentArray");let r=this.clone().sortBy(i);return t?r.slice(0,e):r.slice(r.length-e)}minNOf(t,e){return this.minOrMaxNOf(!0,t,e)}maxNOf(t,e){return this.minOrMaxNOf(!1,t,e)}},xn=Ah;var Ch=class n extends xn{constructor(t,...e){if(!t)throw Error("AgentList requires model");super(...e),this.model=t}inRect(t,e,i=e,r=!1){let s=new n(this.model),o=t.x-e,a=t.x+e,c=t.y-i,l=t.y+i;return this.ask(u=>{o<=u.x&&u.x<=a&&c<=u.y&&u.y<=l&&(r||t!==u)&&s.push(u)}),s}inRadius(t,e,i=!1){let r=new n(this.model),s=e*e,o=Ys;return this.ask(a=>{o(t.x,t.y,a.x,a.y)<=s&&(i||t!==a)&&r.push(a)}),r}inCone(t,e,i,r,s=!1){r=this.model.toRads(r),i=this.model.toAngleRads(i);let o=new n(this.model);return this.ask(a=>{lh(a.x,a.y,e,i,r,t.x,t.y)&&(s||t!==a)&&o.push(a)}),o}},Ke=Ch;var Lh=class n extends xn{model;name;baseSet;AgentClass;static get[Symbol.species](){return xn}constructor(t,e,i,r=null){if(i.length===0)debugger;super(),r=r||this,Object.assign(this,{model:t,name:i,baseSet:r,AgentClass:e}),this.isBaseSet()?(this.breeds={},this.ID=0):(Object.setPrototypeOf(this,Object.getPrototypeOf(r)),this.baseSet.breeds[i]=this),this.protoMixin(e)}protoMixin(t){this.agentProto=new t;let e=this.agentProto;Object.assign(e,{agentSet:this,model:this.model}),e[this.baseSet.name]=this.baseSet,e.setBreed?console.log("protoMixin: agentClass.proto already set",t):(Object.assign(e,{setBreed(i){i.setBreed(this)},getBreed(){return this.agentSet},isBreed(i){return this.agentSet===i}}),Object.defineProperty(e,"breed",{get:function(){return this.agentSet}}))}addAgent(t=void 0){return t=t||this.agentProto.newInstance(this.agentProto),this.isBreedSet()?this.baseSet.addAgent(t):t.id=this.ID++,this.push(t),t}removeAgent(t){return t.id!=-1&&(this.isBreedSet()&&this.baseSet.remove(t,"id"),this.remove(t,"id")),this}setBreed(t){if(t.breed.name!==this.name)return t.agentSet.isBreedSet()&&t.agentSet.remove(t,"id"),this.isBreedSet()&&this.insert(t,"id"),Object.setPrototypeOf(t,this.agentProto)}setDefault(t,e){return this.agentProto[t]=e,this}getDefault(t){return this.agentProto[t]}newBreed(t){return new n(this.model,this.AgentClass,t,this)}isBreedSet(){return this.baseSet!==this}isBaseSet(){return this.baseSet===this}withBreed(t){return this.filter(e=>e.agentSet===t)}create(){console.log(`AgentSet: Abstract method called: ${this}`)}clear(){for(;!this.isEmpty();)this.last().die()}ask(t){if(this.length===0)return;let e=this.last().id;for(let i=0;i<this.length&&this[i].id<=e;i++)t(this[i],i,this)}},Xi=Lh;var Ph=class n{width;height;data;static emptyDataSet(t,e,i=Array){return new n(t,e,new i(t*e))}constructor(t,e,i){if(i.length!==t*e)throw Error(`new DataSet length: ${i.length} !== ${t} * ${e}`);Object.assign(this,{width:t,height:e,data:i})}checkXY(t,e){if(!this.inBounds(t,e))throw Error(`DataSet: x,y out of range: ${t}, ${e}`)}inBounds(t,e){return Rn(t,0,this.width-1)&&Rn(e,0,this.height-1)}dataType(){return this.data.constructor}type(){return this.constructor}toIndex(t,e){return t+e*this.width}toXY(t){return[t%this.width,Math.floor(t/this.width)]}getXY(t,e){return this.data[this.toIndex(t,e)]}setXY(t,e,i){this.data[this.toIndex(t,e)]=i}sample(t,e,i=!0){return this.checkXY(t,e),i?this.nearest(t,e):this.bilinear(t,e)}nearest(t,e){return this.getXY(Math.round(t),Math.round(e))}bilinear(t,e){let i=Math.floor(t),r=Math.floor(e),s=this.toIndex(i,r),o=this.width,a=t-i,c=e-r,l=1-a,u=1-c,h=this.data[s],d=this.data[s+1]||0,f=this.data[s+o]||0,p=this.data[s+1+o]||0;return h*l*u+d*a*u+f*l*c+p*a*c}clone(){return new n(this.width,this.height,this.data.slice(0))}emptyDataSet(t,e,i=this.dataType()){return n.emptyDataSet(t,e,i)}emptyArray(t){let e=this.type();return new e(t)}resample(t,e,i=!0,r=Array){if(t===this.width&&e===this.height)return this.clone();let s=n.emptyDataSet(t,e,r);for(let o=0;o<e;o++)for(let a=0;a<t;a++)s.setXY(a,o,this.sample(a*(this.width-1)/(t-1),o*(this.height-1)/(e-1),i));return s}scale(t,e){let i=this.min(),s=this.max()-i,a=(e-t)/s,c=t-a*i;return this.map(l=>a*l+c)}subset(t,e,i,r){if(t+i>this.width||e+r>this.height)throw console.log("subset: x+width",t+i,"this.width",this.width),console.log("subset: y+height",e+r,"this.height",this.height),Error("DataSet.subSet: params out of range");let s=this.emptyDataSet(i,r);for(let o=0;o<i;o++)for(let a=0;a<r;a++)s.setXY(o,a,this.getXY(o+t,a+e));return s}crop(t,e,i,r){if(e===void 0)var{top:t,bottom:e,left:i,right:r}=t;let s=this.width-i-r,o=this.height-t-e;return this.subset(i,t,s,o)}map(t){return new n(this.width,this.height,this.data.map(t))}col(t){let[e,i,r]=[this.width,this.height,this.data];if(t>=e)throw Error(`col: x out of range width: ${e} x: ${t}`);let s=this.emptyArray(i);for(let o=0;o<i;o++)s[o]=r[t+o*e];return s}row(t){let[e,i]=[this.width,this.height];if(t>=i)throw Error(`row: y out of range height: ${i} x: ${t}`);return this.data.slice(t*e,(t+1)*e)}convertType(t){this.data=Or(this.data,t)}concatEast(t){let[e,i]=[this.width,this.height],[r,s]=[t.width,t.height];if(i!==s)throw Error(`concatEast: heights not equal ${i}, ${s}`);let o=this.emptyDataSet(e+r,i);for(let a=0;a<e;a++)for(let c=0;c<i;c++)o.setXY(a,c,this.getXY(a,c));for(let a=0;a<r;a++)for(let c=0;c<s;c++)o.setXY(a+e,c,t.getXY(a,c));return o}concatSouth(t){let[e,i,r]=[this.width,this.height,this.data];if(e!==t.width)throw Error(`concatSouth: widths not equal ${e}, ${t.width}`);let s=dh(r,t.data);return new n(e,i+t.height,s)}transformCoords(t,e,i,r,s,o){let a=(t-i)*(this.width-1)/s,c=(r-e)*(this.height-1)/o;return[a,c]}coordSample(t,e,i,r,s,o,a=!0){let[c,l]=this.transformCoords(t,e,i,r,s,o);return this.sample(c,l,a)}neighborhood(t,e,i=[]){i.length=0;let r=t===0||t===this.width-1||e===0||e===this.height-1;for(let s=-1;s<=1;s++)for(let o=-1;o<=1;o++){let a=t+o,c=e+s;r&&(a=Dn(a,0,this.width-1),c=Dn(c,0,this.height-1)),i.push(this.data[this.toIndex(a,c)])}return i}convolve(t,e=1,i=!1){let[r,s,o,a]=i?[1,1,this.height-1,this.width-1]:[0,0,this.height,this.width],c=this.emptyDataSet(a,o),l=c.data,u=0;for(let h=s;h<o;h++)for(let d=r;d<a;d++){let f=this.neighborhood(d,h),p=0;for(let y=0;y<t.length;y++)p=p+t[y]*f[y];l[u++]=p*e}return c}dzdx(t=2,e=1/8){return this.convolve([-1,0,1,-t,0,t,-1,0,1],e)}dzdy(t=2,e=1/8){return this.convolve([1,t,1,0,0,0,-1,-t,-1],e)}laplace8(){return this.convolve([-1,-1,-1,-1,8,-1,-1,-1,-1])}laplace4(){return this.convolve([0,-1,0,-1,4,-1,0,-1,0])}blur(t=.0625){return this.convolve([1,2,1,2,4,2,1,2,1],t)}edge(){return this.convolve([1,1,1,1,-7,1,1,1,1])}slopeAndAspect(t=1,e=!0){let i=this.dzdx(),r=this.dzdy(),[s,o]=[[],[]],[a,c]=[i.height,i.width];for(let l=0;l<a;l++)for(let u=0;u<c;u++){let[h,d]=[i.getXY(u,l),r.getXY(u,l)];o.push(Math.atan(Gi(0,0,h,d))/t);let f=Math.atan2(-d,-h);e&&f<0&&(f+=2*Math.PI),s.push(f)}return o=new n(c,a,o),s=new n(c,a,s),{slope:o,aspect:s,dzdx:i,dzdy:r}}max(){return this.data.reduce((t,e)=>Math.max(t,e))}min(){return this.data.reduce((t,e)=>Math.min(t,e))}extent(){return[this.min(),this.max()]}sum(){return this.data.reduce((t,e)=>t+e)}normalize(t=0,e=1,i=!1){let[r,s]=this.extent(),o=1/(s-r),a=this.data.map(c=>qs(t,e,o*(c-r)));return i&&(a=a.map(c=>Math.round(c))),new n(this.width,this.height,a)}equals(t){return this.width===t.width&&this.height===t.height&&uh(this.data,t.data)}},Nn=Ph;var Rh=class n{static defaults={width:1,hidden:!1,agentSet:null,model:null,name:null};static variables={id:null,theta:0,x:0,y:0};constructor(){Object.assign(this,n.defaults)}newInstance(t){let e=Object.create(t);return Object.assign(e,n.variables),e}init(t,e){this.end0=t,this.end1=e,t.links.push(this),e.links.push(this)}die(){this.id!==-1&&(this.agentSet.removeAgent(this),On(this.end0.links,this),On(this.end1.links,this),this.id=-1)}isDead(){return this.id===-1}bothEnds(){return xn.fromArray([this.end0,this.end1])}length(){return this.end0.distance(this.end1)}get heading(){let{x0:t,x1:e,y0:i,y1:r}=this,s=Math.atan2(r-i,e-t);return this.model.fromRads(s)}otherEnd(t){if(t===this.end0)return this.end1;if(t===this.end1)return this.end0;throw Error(`Link.otherEnd: turtle not a link turtle: ${t}`)}distanceXY(t,e){return this.bothEnds().map(i=>i.distanceXY(t,e)).sum()-this.length()}get x0(){return this.end0.x}get y0(){return this.end0.y}get z0(){return this.end0.z?this.end0.z:0}get x1(){return this.end1.x}get y1(){return this.end1.y}get z1(){return this.end1.z?this.end1.z:0}},Ih=Rh;var Dh=class extends Xi{constructor(t,e,i,r=null){super(t,e,i,r)}createOne(t,e,i=r=>{}){let r=this.addAgent();return r.init(t,e),i(r),r}create(t,e,i=r=>{}){return Array.isArray(e)||(e=[e]),e.map(r=>this.createOne(t,r,i))}},Oh=Dh;var Fh=class n{maxX=16;minX=-16;maxY=16;minY=-16;maxZ=16;minZ=-16;static defaultOptions(t=16,e=t,i=Math.max(t,e)){return{minX:-t,maxX:t,minY:-e,maxY:e,minZ:-i,maxZ:i}}static defaultWorld(t=16,e=t,i=t){return new n(n.defaultOptions(t,e,i))}constructor(t={}){Object.assign(this,t),this.setWorld()}setWorld(){let{minX:t,maxX:e,minY:i,maxY:r,minZ:s,maxZ:o}=this;zt({minX:t,maxX:e,minY:i,maxY:r,minZ:s,maxZ:o},(a,c)=>{if(!Number.isInteger(a))throw Error(`World: ${c}:${a} must be an integer`)}),this.numX=this.width=e-t+1,this.numY=this.height=r-i+1,this.numZ=this.depth=o-s+1,this.minXcor=t-.5,this.maxXcor=e+.5,this.minYcor=i-.5,this.maxYcor=r+.5,this.minZcor=s-.5,this.maxZcor=o+.5,this.centerX=(t+e)/2,this.centerY=(i+r)/2,this.centerZ=(s+o)/2,this.numPatches=this.numX*this.numY}getOptions(){let{minX:t,minY:e,minZ:i,maxX:r,maxY:s,maxZ:o}=this;return{minX:t,minY:e,minZ:i,maxX:r,maxY:s,maxZ:o}}randomPoint(){return[ii(this.minXcor,this.maxXcor),ii(this.minYcor,this.maxYcor)]}random3DPoint(){return[ii(this.minXcor,this.maxXcor),ii(this.minYcor,this.maxYcor),ii(this.minZcor,this.maxZcor)]}randomPatchPoint(){return[ni(this.minX,this.maxX),ni(this.minY,this.maxY)]}isOnWorld(t,e,i=this.centerZ){return this.minXcor<=t&&t<=this.maxXcor&&this.minYcor<=e&&e<=this.maxYcor&&this.minZcor<=i&&i<=this.maxZcor}bboxTransform(t,e,i,r){return new zh(t,e,i,r,this)}getWorldSize(){return[this.numX,this.numY]}setEuclideanTransform(t,e){this.setCanvasSize(t.canvas,e),t.restore(),t.save(),t.scale(e,-e),t.translate(-this.minXcor,-this.maxYcor)}patchSize(t){let{numX:e,numY:i}=this,{clientWidth:r,clientHeight:s}=t,o=r/e,a=s/i;if(o!==a)throw Error(`World patchSize: x/y sizes differ ${o}, ${a}`);return o}setCanvasSize(t,e){Na(t,this.numX*e,this.numY*e)}pixelXYtoPatchXY(t,e,i){return[this.minXcor+t/i,this.maxYcor-e/i]}patchXYtoPixelXY(t,e,i){return[(t-this.minXcor)*i,(this.maxYcor-e)*i]}xyToPatchIndex(t,e){if(!this.isOnWorld(t,e))return;let{minX:i,maxX:r,maxY:s,numX:o,maxXcor:a,maxYcor:c}=this;return t=t===a?r:Math.round(t),e=e===c?s:Math.round(e),t-i+o*(s-e)}},Bn=Fh,zh=class{constructor(t,e,i,r,s){this.bbox=[t,e,i,r],t<i&&console.log("flipX"),r<e&&console.log("flipY"),t<i&&([t,i]=[i,t]),r<e&&([r,e]=[e,r]);let{maxXcor:o,maxYcor:a,minXcor:c,minYcor:l}=s,u=(t-i)/(o-c),h=(r-e)/(a-l),d=(t+i-u*(o+c))/2,f=(r+e-h*(a+l))/2;Object.assign(this,{mx:u,my:h,bx:d,by:f})}toWorld(t){let{mx:e,my:i,bx:r,by:s}=this,[o,a]=t,c=(o-r)/e,l=(a-s)/i;return[c,l]}toBBox(t){let{mx:e,my:i,bx:r,by:s}=this,[o,a]=t,c=e*o+r,l=i*a+s;return[c,l]}};var Va={};Ui(Va,{Lbounds2bbox:()=>jv,attribution:()=>sb,bboxAspect:()=>tb,bboxBounds:()=>Yv,bboxCenter:()=>eo,bboxCoords:()=>kr,bboxFeature:()=>Zh,bboxFromCenter:()=>Jh,bboxMetricAspect:()=>Qh,bboxMetricSize:()=>no,bboxSize:()=>Yp,elevationTemplate:()=>cb,fetchStreetsJson:()=>nb,getOsmURL:()=>Zp,isBBox:()=>qv,jsonToBBox:()=>Zv,latlon:()=>Vp,latz2y:()=>jp,latz2yFloat:()=>jh,lonLat2meters:()=>Vh,lonLatz2bbox:()=>Wv,lonlatz2xy:()=>Xh,lonlatz2xyFloat:()=>Xp,lonz2x:()=>Wp,lonz2xFloat:()=>Wh,newMexicoBBox:()=>qa,newMexicoCenter:()=>Qv,santaFeBBox:()=>Jv,santaFeCenter:()=>$h,santaFeSmallBBox:()=>$v,template:()=>ob,tilesBBox:()=>Xv,url:()=>ab,usaBBox:()=>qp,usaCenter:()=>Kv,xyInBBox:()=>Uh,xyz2bbox:()=>Xa,xyz2centerLonlat:()=>Vv,xyz2lonlat:()=>Hh,xz2lon:()=>qh,yz2lat:()=>Yh});var Bh={};Ui(Bh,{bboxFeature:()=>Cv,clone:()=>hi,flatten:()=>Ha,flattenMultiLineStrings:()=>zp,geojsonBBox:()=>Nh,getCoordinates:()=>Ks,isGeojson:()=>Tv,lineStringsToLinks:()=>Lv,minify:()=>Av});function Tv(n){return typeof n=="object"&&n.type==="FeatureCollection"}function hi(n){return JSON.parse(JSON.stringify(n))}function Av(n){return typeof n=="string"&&(n=JSON.parse(n)),JSON.stringify(n).replace(/},{/g,`},

{`)}function Cv(n,t={}){let e=kr(n);return e.push(e[0]),{type:"Feature",geometry:{cordinates:e,type:"Polygon"},properties:t}}function zp(n,t=!0){return t&&(n=hi(n)),(n.features||n).reduce((r,s)=>{let o=s.geometry;return o.type==="LineString"?(o.coordinates.properties=s.properties,r.push(o.coordinates)):o.type==="MultiLineString"&&o.coordinates.forEach(a=>{a.properties=s.properties,r.push(a)}),r},[])}function Lv(n,t,e){let i=n.world.xfm||n.world.bboxTransform(...t);e=zp(e);let r={},s=[],o=[];function a(u){let h=u.toString(),d=r[h];return d||(d=n.turtles.createOne(f=>{f.setxy(...i.toWorld(u)),f.lon=u[0],f.lat=u[1]}),r[h]=d,s.push(d),d)}function c(u,h){let d=a(u),f=a(h),p=n.links.createOne(d,f);return o.push(p),p}function l(u){u.reduce((h,d,f,p)=>{let y=c(p[f-1],d);return f===1?(h=[y],h.properties=u.properties):h.push(y),y.lineString=h,h})}return e.forEach(u=>l(u)),[s,o]}function Ha(n,t=!0){switch(t&&(n=hi(n)),n&&n.type||null){case"FeatureCollection":return n.features=n.features.reduce(function(e,i){return e.concat(Ha(i))},[]),n;case"Feature":return n.geometry?Ha(n.geometry).map(function(e){var i={type:"Feature",properties:JSON.parse(JSON.stringify(n.properties)),geometry:e};return n.id!==void 0&&(i.id=n.id),i}):[n];case"MultiPoint":return n.coordinates.map(function(e){return{type:"Point",coordinates:e}});case"MultiPolygon":return n.coordinates.map(function(e){return{type:"Polygon",coordinates:e}});case"MultiLineString":return n.coordinates.map(function(e){return{type:"LineString",coordinates:e}});case"GeometryCollection":return n.geometries.map(Ha).reduce(function(e,i){return e.concat(i)},[]);case"Point":case"Polygon":case"LineString":return[n]}}function Nh(n){var t,e;if(n.hasOwnProperty("type"))return t=Ks(n),e=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],t.reduce(function(i,r){return[Math.min(r[0],i[0]),Math.min(r[1],i[1]),Math.max(r[0],i[2]),Math.max(r[1],i[3])]},e)}function Ks(n){switch(n.type){case"Point":return[n.coordinates];case"LineString":case"MultiPoint":return n.coordinates;case"Polygon":case"MultiLineString":return n.coordinates.reduce(function(t,e){return t.concat(e)},[]);case"MultiPolygon":return n.coordinates.reduce(function(t,e){return t.concat(e.reduce(function(i,r){return i.concat(r)},[]))},[]);case"Feature":return Ks(n.geometry);case"GeometryCollection":return n.geometries.reduce(function(t,e){return t.concat(Ks(e))},[]);case"FeatureCollection":return n.features.reduce(function(t,e){return t.concat(Ks(e))},[])}}function Pv(n,t){return typeof t=="string"&&(t=t.split(".")),t.reduce((e,i)=>e[i],n)}function Np(n,t,e=!0){e&&(n=hi(n));let i=n.features.filter(r=>{let s=r.geometry.coordinates;return s=s.filter(o=>Uh(t,o)),r.geometry.coordinates=s,s.length>=2});return n.features=i,n}function Rv(n,t){return n.features=n.features.filter(t),n}function Bp(n,t,e){return typeof e=="string"&&(e=e.split(" ")),Rv(n,i=>{let r=Pv(i,t);return e.includes(r)}),n}function Iv(n,t,e=!0){return e&&(n=hi(n)),Bp(n,"geometry.type",t)}function Dv(n,t,e=!0){return e&&(n=hi(n)),typeof t=="string"&&(t=t.split(" ")),n.features.forEach(i=>{let r={};t.forEach(s=>{i.properties[s]!==void 0&&(r[s]=i.properties[s])}),i.properties=r}),n}var Ov=["motorway","trunk","residential","primary","secondary","tertiary","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"],Fv=["highway","oneway","name","tiger:name_base"];function Up(n,t=Ov,e=Fv,i=!0){return i&&(n=hi(n)),Iv(n,"LineString"),Bp(n,"properties.highway",t),Dv(n,e),n}var{PI:to,atan:Nv,atan2:Bv,cos:kh,floor:Wa,log:Uv,pow:ja,sin:kp,sinh:kv,sqrt:Gp,tan:Gv,abs:Hp}=Math,Gh=n=>n*to/180,Hv=n=>n*180/to;function Vp(n){return typeof n[0]!="number"?n.map(t=>Vp(t)):[n[1],n[0]]}function Wh(n,t){return(n+180)/360*ja(2,t)}function Wp(n,t){return Wa(Wh(n,t))}function jh(n,t){let e=Gh(n);return(1-Uv(Gv(e)+1/kh(e))/to)*ja(2,t-1)}function jp(n,t){return Wa(jh(n,t))}function Xp(n,t,e){return[Wh(n,e),jh(t,e)]}function Xh(n,t,e){return[Wp(n,e),jp(t,e)]}function qh(n,t){return n/ja(2,t)*360-180}function Yh(n,t){let e=Nv(kv(to-2*to*n/ja(2,t)));return Hv(e)}function Hh(n,t,e){return[qh(n,e),Yh(t,e)]}function Vv(n,t,e){return[qh(n+.5,e),Yh(t+.5,e)]}function Xa(n,t,e,i=null){let[r,s]=Hh(n,t,e),[o,a]=Hh(n+1,t+1,e);return i?Ra([r,a,o,s],i):[r,a,o,s]}function Uh(n,t){let[e,i,r,s]=n,[o,a]=t;return Rn(o,e,r)&&Rn(a,i,s)}function Wv(n,t,e){let[i,r]=Xh(n,t,e);return Xa(i,r,e)}function jv(n){let{lng:t,lat:e}=n.getNorthWest(),{lng:i,lat:r}=n.getSouthEast();return[t,r,i,e]}function Xv(n,t){let[e,i,r,s]=n,[o,a]=Xh(e,s,t),[c,l]=Xp(r,i,t);return c=Wa(c),l=Number.isInteger(l)?l-1:Wa(l),[o,l,c,a]}function eo(n){let[t,e,i,r]=n;return[(t+i)/2,(e+r)/2]}function qv(n){return!Array.isArray(n)||n.length!==4?!1:n.every(t=>ai(t))}function kr(n){let[t,e,i,r]=n;return[[t,r],[i,r],[i,e],[t,e]]}function Yv(n){let[t,e,i,r]=n;return[[t,r],[i,e]]}function Zv(n){return Nh(n)}function Zh(n,t={}){let e=kr(n);return e.push(e[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[e]},properties:t}}function Jh(n,t=1,e=t){let[i,r]=n;return[i-t,r-e,i+t,r+e]}var $h=[-105.978,35.66],Jv=Jh($h,.2,.1),$v=Jh($h,.02,.01),qa=[-109.050044,31.332301,-103.001964,37.000104],Qv=eo(qa),qp=[-124.733174,24.544701,-66.949895,49.384358],Kv=eo(qp);function Yp(n){let[t,e,i,r]=n,s=Hp(t-i),o=Hp(r-e);return[s,o]}function tb(n){let[t,e]=Yp(n);return t/e}function no(n){let[t,e,i,r]=n,s=[t,r],o=[t,e],c=Vh(s,[i,r]),l=Vh(s,o);return[c,l]}function Qh(n){let[t,e]=no(n);return t/e}function Zp(n,t,e,i){let r="https://overpass-api.de/api/interpreter?data=",s=`
    [out:json][timeout:25];
    (
      way["highway"](${n},${t},${e},${i});
    );
    (._;>;);
    out body;
  `.trim();return r+encodeURIComponent(s)}async function eb(n){let[t,e,i,r]=n,s=Zp(e,t,r,i);return await fetch(s).then(a=>a.json())}async function nb(n){let t=await eb(n);console.log("osmJson",t,t.elements.length.toLocaleString());let e=ib(t);return e=rb(e),e=Up(e),e=Np(e,n),console.log("geojson",e,e.features.length.toLocaleString()),e}function ib(n){let t=new Map,e=[];for(let i of n.elements)i.type==="node"&&t.set(i.id,{lat:i.lat,lon:i.lon});for(let i of n.elements)if(i.type==="way"&&i.nodes&&i.tags&&i.tags.highway){let r=i.nodes.map(s=>t.get(s)).filter(Boolean);r.length>1&&e.push({name:i.tags.name||"(unnamed)",type:i.tags.highway,path:r})}return e}function rb(n){return{type:"FeatureCollection",features:n.map(t=>({type:"Feature",properties:{name:t.name,highway:t.type},geometry:{type:"LineString",coordinates:t.path.map(e=>[e.lon,e.lat])}}))}}function Vh(n,t){let[e,i]=n.map(d=>Gh(d)),[r,s]=t.map(d=>Gh(d)),o=6378.137,a=s-i,c=r-e,l=kp(a/2)**2+kh(i)*kh(s)*kp(c/2)**2,u=2*Bv(Gp(l),Gp(1-l));return o*u*1e3}function sb(n="osm"){let t="Map data &copy; ";switch(n){case"osm":return t+'<a href="https://openstreetmap.org">OpenStreetMap</a>';case"topo":return t+'<a href="https://opentopomap.org">OpenTopoMap</a>';case"topo1":return t+'<a  href="https://www.maptiler.com">OpenTopoMap</a>';case"smooth":return t+'<a href="https://stadiamaps.com/">Stadia Maps</a>';case"usgs":return t+'Tiles courtesy of the <a href="https://usgs.gov/">U.S. Geological Survey</a>'}throw Error("gis.attribution: name unknown:",n)}function ob(n="osm"){switch(n){case"osm":return"https://tile.openstreetmap.org/{z}/{x}/{y}.png";case"topo":return"https://a.tile.opentopomap.org/{z}/{x}/{y}.png";case"topo1":return"https://api.maptiler.com/maps/topo/{z}/{x}/{y}.png?key=iQurAP6lArV1UP4gfSVs";case"smooth":return"https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png";case"usgs":return"https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}";case"contour":return"https://api.maptiler.com/tiles/contours/tiles.json?key=iQurAP6lArV1UP4gfSVs"}throw Error("gis.template: name unknown:",n)}function ab(n,t,e,i="osm"){switch(i){case"osm":return`https://tile.openstreetmap.org/${n}/${t}/${e}.png`;case"topo":return`https://tile.opentopomap.org/${n}/${t}/${e}.png`;case"topo1":return`https://api.maptiler.com/maps/topo/${n}/${t}/${e}.png?key=iQurAP6lArV1UP4gfSVs`;case"smooth":return`https://tiles.stadiamaps.com/tiles/alidade_smooth/${n}/${t}/${e}{r}.png`;case"usgs":return`https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/${n}/${e}/${t}`}throw Error("gis.url: name unknown:",i)}function cb(n="mapzen"){switch(n){case"mapzen":return"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png";case"maptiler":return"https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=iQurAP6lArV1UP4gfSVs";case"redfishUSA":return"https://s3-us-west-2.amazonaws.com/simtable-elevation-tiles/{z}/{x}/{y}.png";case"redfishWorld":return"https://s3-us-west-2.amazonaws.com/world-elevation-tiles/DEM_tiles/{z}/{x}/{y}.png";case"mapbox":return"https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiYmFja3NwYWNlcyIsImEiOiJjanVrbzI4dncwOXl3M3ptcGJtN3oxMmhoIn0.x9iSCrtm0iADEqixVgPwqQ"}throw Error("gis.elevationTemplate: name unknown:",n)}var Kh=class n extends Bn{static defaultOptions(t=qa,e=100){return{bbox:t,patchesWidth:e}}constructor(t=n.defaultOptions()){let{bbox:e,patchesWidth:i}=t,r;Array.isArray(e)||(r=e,e=Qs(r)),console.log("GeoWorld bbox",e);let s=Qh(e),o=Math.round(i/2);super({minX:0,maxX:i-1,minY:0,maxY:Math.round(i/s),minZ:-o,maxZ:o}),this.bbox=e,this.xfm=this.bboxTransform(...e),r&&(this.geojson=r)}toGeo(t,e){return this.xfm.toBBox([t,e])}toWorld(t,e){return this.xfm.toWorld([t,e])}bboxCenter(){return eo(this.bbox)}bboxCoords(){return kr(this.bbox)}bboxFeature(t={}){return Zh(this.bbox,t)}},tu=Kh;var eu=class extends Xi{constructor(t,e,i,r=null){super(t,e,i,r),!this.isBreedSet()&&(this.populate(),this.labels=[])}populate(){Qe(this.model.world.numX*this.model.world.numY,t=>{this.addAgent()})}neighborsOffsets(t,e){let{minX:i,maxX:r,minY:s,maxY:o,numX:a}=this.model.world;return t===i?e===s?[-a,-a+1,1]:e===o?[1,a+1,a]:[-a,-a+1,1,a+1,a]:t===r?e===s?[-a-1,-a,-1]:e===o?[a,a-1,-1]:[-a-1,-a,a,a-1,-1]:e===s?[-a-1,-a,-a+1,1,-1]:e===o?[1,a+1,a,a-1,-1]:[-a-1,-a,-a+1,1,a+1,a,a-1,-1]}neighbors4Offsets(t,e){let i=this.model.world.numX;return this.neighborsOffsets(t,e).filter(r=>Math.abs(r)===1||Math.abs(r)===i)}neighbors(t){let{id:e,x:i,y:r}=t,s=this.neighborsOffsets(i,r),o=new Ke(this.model,s.length);return s.forEach((a,c)=>{o[c]=this[a+e]}),o}neighbors4(t){let{id:e,x:i,y:r}=t,s=this.neighbors4Offsets(i,r),o=new Ke(this.model,s.length);return s.forEach((a,c)=>{o[c]=this[a+e]}),o}importDataSet(t,e,i=!1){if(this.isBreedSet()){ki("Patches: exportDataSet called with breed, using patches"),this.baseSet.importDataSet(t,e,i);return}let{numX:r,numY:s}=this.model.world,o=t.resample(r,s,i);this.ask(a=>{a[e]=o.data[a.id]})}exportDataSet(t,e=Array){if(this.isBreedSet())return ki("Patches: exportDataSet called with breed, using patches"),this.baseSet.exportDataSet(t,e);let{numX:i,numY:r}=this.model.world,s=this.props(t);return s=Or(s,e),new Nn(i,r,s)}patchIndex(t,e){let{minX:i,maxY:r,numX:s}=this.model.world;return t-i+s*(r-e)}patch(t,e){if(!this.model.world.isOnWorld(t,e))return;let i=t===this.model.world.maxXcor?this.model.world.maxX:Math.round(t),r=e===this.model.world.maxYcor?this.model.world.maxY:Math.round(e);return this.patchXY(i,r)}patchXY(t,e){return this[this.patchIndex(t,e)]}patchRect(t,e,i=e,r=!0){if(t.rectCache){let u=this.cacheIndex(e,i,r),h=t.rectCache[u];if(h)return h}let s=new Ke(this.model),{minX:o,maxX:a,minY:c,maxY:l}=this.model.world;o=Math.max(o,t.x-e),a=Math.min(a,t.x+e),c=Math.max(c,t.y-i),l=Math.min(l,t.y+i);for(let u=c;u<=l;u++)for(let h=o;h<=a;h++){let d=this.patchXY(h,u);(t!==d||r)&&s.push(d)}return s}patchRectXY(t,e,i,r=i,s=!0){return this.patchRect(this.patch(t,e),i,r,s)}cacheIndex(t,e=t,i=!0){return(2*t+1)*(2*e+1)+(i?0:-1)}cacheRect(t,e=t,i=!0,r=!0){let s=this.cacheIndex(t,e,i);this.ask(o=>{(!o.rectCache||r)&&(o.rectCache=[]);let a=this.inRect(o,t,e,i);o.rectCache[s]=a})}inRect(t,e,i=e,r=!0){let s=this.patchRect(t,e,i,r);return this.isBaseSet()?s:s.withBreed(this)}inRadius(t,e,i=!0){let r=Math.ceil(e);return this.inRect(t,r,r,i).inRadius(t,e,i)}inCone(t,e,i,r,s=!0){let o=Math.ceil(e);return this.inRect(t,o,o,s).inCone(t,e,i,r,s)}patchAtHeadingAndDistance(t,e,i){e=this.model.toRads(e);let{x:r,y:s}=t;return r=r+i*Math.cos(e),s=s+i*Math.sin(e),this.patch(r,s)}isOnEdge(t){let{x:e,y:i}=t,{minX:r,maxX:s,minY:o,maxY:a}=this.model.world;return e===r||e===s||i===o||i===a}edgePatches(){return this.filter(t=>this.isOnEdge(t))}diffuse(t,e){this.diffuseN(8,t,e)}diffuse4(t,e){this.diffuseN(4,t,e)}diffuseN(t,e,i){if(this[0]._diffuseNext===void 0)for(let r=0;r<this.length;r++)this[r]._diffuseNext=0;for(let r=0;r<this.length;r++){let s=this[r],o=s[e]*i,a=o/t,c=t===8?s.neighbors:s.neighbors4,l=c.length;s._diffuseNext+=s[e]-o+(t-l)*a;for(let u=0;u<c.length;u++)c[u]._diffuseNext+=a}for(let r=0;r<this.length;r++){let s=this[r];s[e]=s._diffuseNext,s._diffuseNext=0}}},nu=eu;var iu=class n{static defaults={turtles:null,z:0,agentSet:null,model:null,name:null};static variables={};constructor(){Object.assign(this,n.defaults)}newInstance(t){let e=Object.create(t);return Object.assign(e,n.variables),e}get x(){return this.id%this.model.world.numX+this.model.world.minX}get y(){return this.model.world.maxY-Math.floor(this.id/this.model.world.numX)}isOnEdge(){return this.patches.isOnEdge(this)}get neighbors(){let t=this.patches.neighbors(this);return Object.defineProperty(this,"neighbors",{value:t,enumerable:!0}),t}get neighbors4(){let t=this.patches.neighbors4(this);return Object.defineProperty(this,"neighbors4",{value:t,enumerable:!0}),t}get turtlesHere(){return this.turtles==null&&(this.patches.ask(t=>{t.turtles=new Ke(this.model)}),this.model.turtles.ask(t=>{t.patch.turtles.push(t)})),this.turtles}breedsHere(t){return this.turtlesHere.withBreed(t)}distanceXY(t,e,i=null){return i!=null&&this.z!=null?Hi(this.x,this.y,this.z,t,e,i):Gi(this.x,this.y,t,e)}distance(t){let{x:e,y:i,z:r}=t;return this.distanceXY(e,i,r)}towards(t){return this.towardsXY(t.x,t.y)}towardsXY(t,e){let i=si(this.x,this.y,t,e);return this.model.fromRads(i)}patchAt(t,e){return this.patches.patch(this.x+t,this.y+e)}patchAtHeadingAndDistance(t,e){return this.patches.patchAtHeadingAndDistance(this,t,e)}sprout(t=1,e=this.model.turtles,i=r=>{}){return e.create(t,r=>{r.setxy(this.x,this.y),i(r)})}},ru=iu;var su=class extends Xi{constructor(t,e,i,r=null){super(t,e,i,r),i||console.log("Turtles empty name",this)}createOne(t=e=>{}){let e=this.addAgent();e.theta=rh(Math.PI*2);let i=e.patch;return i.turtles!=null&&i.turtles.push(e),t(e),e}create(t,e=i=>{}){return Qe(t,(i,r)=>{r.push(this.createOne(e))})}closestTurtle(t,e,i){let r=this.inPatchRectXY(t,e,i);return r.length===0?null:r.minOneOf(s=>s.distanceXY(t,e))}inPatches(t){let e=new Ke(this.model);for(let i of t)e.push(...i.turtlesHere);return this.isBreedSet()&&(e=e.filter(i=>i.agentSet===this)),e}inPatchRect(t,e,i=e,r=!1){let s=this.inPatchRectXY(t.x,t.y,e,i);return r||On(s,t),s}inPatchRectXY(t,e,i,r=i){let s=this.model.patches.patchRectXY(t,e,i,r,!0);return this.inPatches(s)}inRadius(t,e,i=!1){return this.inPatchRect(t,e,e,!0).inRadius(t,e,i)}inCone(t,e,i,r=!1){return this.inPatchRect(t,e,e,!0).inCone(t,e,i,t.heading,r)}layoutCircle(t=this.model.world.maxX*.9,e=[0,0]){let i=Math.PI/2,r=-1,s=2*Math.PI/this.length,[o,a]=e;this.ask((c,l)=>{c.setxy(o,a),c.theta=i+r*s*l,c.forward(t)})}},ou=su;var au=class n{static defaults={atEdge:"wrap",hidden:!1,z:0,agentSet:null,model:null,name:null};static variables={id:null,theta:0,x:0,y:0};constructor(){Object.assign(this,n.defaults)}newInstance(t){let e=Object.create(t);return Object.assign(e,n.variables),e}die(){if(this.id!==-1){if(this.agentSet.removeAgent(this),this.hasOwnProperty("links"))for(;this.links.length>0;)this.links[0].die();this.patch&&this.patch.turtles&&On(this.patch.turtles,this),this.id=-1}}isDead(){return this.id===-1}hatch(t=1,e=this.agentSet,i=r=>{}){return e.create(t,r=>{r.setxy(this.x,this.y,this.z),r.theta=this.theta,i(r)})}get links(){return Object.defineProperty(this,"links",{value:new Ke(this.model),enumerable:!0}),this.links}get patch(){return this.model.patches.patch(this.x,this.y)}get heading(){return this.model.fromRads(this.theta)}set heading(t){this.theta=this.model.toRads(t)}subtractHeading(t){return ch(t,this.heading)}setxy(t,e,i=void 0){let r=this.patch;this.x=t,this.y=e,i!=null&&(this.z=i),this.checkXYZ(r)}checkXYZ(t){this.checkEdge(),this.checkPatch(t)}checkEdge(){let{x:t,y:e,z:i}=this;!this.model.world.isOnWorld(t,e,i)&&this.atEdge!=="OK"&&this.handleEdge(t,e,i)}checkPatch(t){let e=this.patch;e!=t&&(t&&t.turtles&&On(t.turtles,this),e&&e.turtles&&e.turtles.push(this))}handleEdge(t,e,i=void 0){let r=this.atEdge;if(Le(r)){let{minXcor:s,maxXcor:o,minYcor:a,maxYcor:c,minZcor:l,maxZcor:u}=this.model.world;if(r==="wrap")this.x=Lr(t,s,o),this.y=Lr(e,a,c),i!=null&&(this.z=Lr(i,l,u));else if(r==="die")this.die();else if(r==="random")this.setxy(...this.model.world.randomPoint());else if(r==="clamp"||r==="bounce")this.x=Dn(t,s,o),this.y=Dn(e,a,c),i!=null&&(this.z=Dn(i,l,u)),r==="bounce"&&(this.x===s||this.x===o?this.theta=Math.PI-this.theta:this.y===a||this.y===c?this.theta=-this.theta:(this.z===l||this.z===u)&&(this.pitch?this.pitch=-this.pitch:this.z=Lr(i,l,u)));else throw Error(`turtle.handleEdge: bad atEdge: ${r}`)}else this.atEdge(this)}moveTo(t){this.setxy(t.x,t.y,t.z)}forward(t){this.setxy(this.x+t*Math.cos(this.theta),this.y+t*Math.sin(this.theta))}rotate(t){t=this.model.toCCW(t),this.heading+=t}right(t){this.rotate(-t)}left(t){this.rotate(t)}face(t){this.heading=this.towards(t)}facexy(t,e){this.heading=this.towardsXY(t,e)}patchAhead(t){return this.patchAtHeadingAndDistance(this.heading,t)}patchRightAndAhead(t,e){return t=this.model.toCCW(t),this.patchAtHeadingAndDistance(this.heading-t,e)}patchLeftAndAhead(t,e){return this.patchRightAndAhead(-t,e)}canMove(t){return this.patchAhead(t)!=null}distanceXY(t,e,i=null){return i!=null&&this.z!=null?Hi(this.x,this.y,this.z,t,e,i):Gi(this.x,this.y,t,e)}distance(t){let{x:e,y:i,z:r}=t;return this.distanceXY(e,i,r)}get dx(){return Math.cos(this.theta)}get dy(){return Math.sin(this.theta)}towards(t){return this.towardsXY(t.x,t.y)}towardsXY(t,e){let i=si(this.x,this.y,t,e);return this.model.fromRads(i)}patchAt(t,e){return this.model.patches.patch(this.x+t,this.y+e)}patchAtHeadingAndDistance(t,e){return this.model.patches.patchAtHeadingAndDistance(this,t,e)}otherEnd(t){return t.end0===this?t.end1:t.end0}linkNeighbors(){return this.links.map(t=>this.otherEnd(t))}isLinkNeighbor(t){return t in this.linkNeighbors()}},io=au;var cu=class{world;patches;turtles;links;ticks;done=!1;constructor(t=Bn.defaultOptions()){this.initModel(t),this.setAutoTick(!0),this.setGeometry("heading")}initAgentSet(t,e,i){this[t]=new e(this,i,t)}options2world(t){return t.bbox?new tu(t):new Bn(t)}initModel(t){this.ticks=0,this.world=t.maxXcor===void 0?this.options2world(t):t,this.initAgentSet("patches",nu,ru),this.initAgentSet("turtles",ou,io),this.initAgentSet("links",Oh,Ih)}reset(t=!0){this.turtles.clear(),this.turtles.ID=0,this.ticks=0,this.done=!1,t&&this.setup()}tick(){this.ticks++}async startup(){}setup(){}step(){}setAutoTick(t=!0){let e=!!this.stepTarget;if(t){if(e)return;this.stepTarget=this.step,this.step=new Proxy(this.stepTarget,{apply:(i,r,s)=>{this.stepTarget(),this.tick()}})}else this.step=this.stepTarget,delete this.stepTarget}patchBreeds(t){for(let e of t.split(" "))this[e]=this.patches.newBreed(e)}turtleBreeds(t){for(let e of t.split(" "))this[e]=this.turtles.newBreed(e)}linkBreeds(t){for(let e of t.split(" "))this[e]=this.links.newBreed(e)}setGeometry(t="heading"){let e=lb[t];if(!e)throw Error(`setGeometry: ${t} geometry not defined`);Object.assign(this,e)}},Ya=180/Math.PI,Za=Math.PI/180,lb={radians:{toRads:n=>n,fromRads:n=>n,toAngleRads:n=>n,fromAngleRads:n=>n,toCCW:n=>n},degrees:{toRads:n=>n*Za,fromRads:n=>n*Ya,toAngleRads:n=>n*Za,fromAngleRads:n=>n*Ya,toCCW:n=>n},heading:{toRads:n=>(90-n)*Za,fromRads:n=>90-n*Ya,toAngleRads:n=>n*Za,fromAngleRads:n=>n*Ya,toCCW:n=>-n}},lu=cu;var fe=[];for(let n=0;n<256;n++)fe[n]=(n<16?"0":"")+n.toString(16);var Ja=1234567,Vr={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){let n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(fe[n&255]+fe[n>>8&255]+fe[n>>16&255]+fe[n>>24&255]+"-"+fe[t&255]+fe[t>>8&255]+"-"+fe[t>>16&15|64]+fe[t>>24&255]+"-"+fe[e&63|128]+fe[e>>8&255]+"-"+fe[e>>16&255]+fe[e>>24&255]+fe[i&255]+fe[i>>8&255]+fe[i>>16&255]+fe[i>>24&255]).toUpperCase()},clamp:function(n,t,e){return Math.max(t,Math.min(e,n))},euclideanModulo:function(n,t){return(n%t+t)%t},mapLinear:function(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)},lerp:function(n,t,e){return(1-e)*n+e*t},smoothstep:function(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))},smootherstep:function(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))},randInt:function(n,t){return n+Math.floor(Math.random()*(t-n+1))},randFloat:function(n,t){return n+Math.random()*(t-n)},randFloatSpread:function(n){return n*(.5-Math.random())},seededRandom:function(n){return n!==void 0&&(Ja=n%2147483647),Ja=Ja*16807%2147483647,(Ja-1)/2147483646},degToRad:function(n){return n*Vr.DEG2RAD},radToDeg:function(n){return n*Vr.RAD2DEG},isPowerOfTwo:function(n){return(n&n-1)===0&&n!==0},ceilPowerOfTwo:function(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))},floorPowerOfTwo:function(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},setQuaternionFromProperEuler:function(n,t,e,i,r){let s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),p=o((i-t)/2);switch(r){case"XYX":n.set(a*u,c*h,c*d,a*l);break;case"YZY":n.set(c*d,a*u,c*h,a*l);break;case"ZXZ":n.set(c*h,c*d,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}},di=class{constructor(t=0,e=0,i=0,r=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=e,this._z=i,this._w=r}static slerp(t,e,i,r){return i.copy(t).slerp(e,r)}static slerpFlat(t,e,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],h=i[r+3],d=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(h!==y||c!==d||l!==f||u!==p){let x=1-a,g=c*d+l*f+u*p+h*y,m=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){let w=Math.sqrt(b),_=Math.atan2(w,g*m);x=Math.sin(x*_)/w,a=Math.sin(a*_)/w}let v=a*m;if(c=c*x+d*v,l=l*x+f*v,u=u*x+p*v,h=h*x+y*v,x===1-a){let w=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=w,l*=w,u*=w,h*=w}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+c*f-l*d,t[e+1]=c*p+u*d+l*h-a*f,t[e+2]=l*p+u*f+a*d-c*h,t[e+3]=u*p-a*h-c*d-l*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,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let i=t._x,r=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),h=a(s/2),d=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"YZX":this._x=d*u*h+l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h-d*f*p;break;case"XZY":this._x=d*u*h-l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,i=e[0],r=e[4],s=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],d=i+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>h){let f=2*Math.sqrt(1+i-a-h);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>h){let f=2*Math.sqrt(1+a-i-h);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+h-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-6?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Vr.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){let i=this.angleTo(t);if(i===0)return this;let r=Math.min(1,e/i);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}inverse(){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,e){return e!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let i=t._x,r=t._y,s=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-e;return this._w=f*o+e*this._w,this._x=f*i+e*this._x,this._y=f*r+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e){return e===void 0&&(e=0),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){return t===void 0&&(t=[]),e===void 0&&(e=0),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}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}},Jt=class{constructor(t=0,e=0,i=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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,e){return e!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(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 t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Jp.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jp.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,i=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(t){let e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=c*e+o*r-a*i,u=c*i+a*e-s*r,h=c*r+s*i-o*e,d=-s*e-o*i-a*r;return this.x=l*c+d*-s+u*-a-h*-o,this.y=u*c+d*-o+h*-s-l*-a,this.z=h*c+d*-a+l*-o-u*-s,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=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){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t,e){return e!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){let i=t.x,r=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return hu.copy(this).projectOnVector(t),this.sub(hu)}reflect(t){return this.sub(hu.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let i=this.dot(t)/e;return Math.acos(Vr.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){let r=Math.sin(e)*t;return this.x=r*Math.sin(i),this.y=Math.cos(e)*t,this.z=r*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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}},hu=new Jt,Jp=new di,fi=class n{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,r,s,o,a,c,l,u,h,d,f,p,y,x){let g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=u,g[10]=h,g[14]=d,g[3]=f,g[7]=p,g[11]=y,g[15]=x,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 n().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){let e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,i=t.elements,r=1/Gr.setFromMatrixColumn(t,0).length(),s=1/Gr.setFromMatrixColumn(t,1).length(),o=1/Gr.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let e=this.elements,i=t.x,r=t.y,s=t.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*u,f=o*h,p=a*u,y=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=f+p*l,e[5]=d-y*l,e[9]=-a*c,e[2]=y-d*l,e[6]=p+f*l,e[10]=o*c}else if(t.order==="YXZ"){let d=c*u,f=c*h,p=l*u,y=l*h;e[0]=d+y*a,e[4]=p*a-f,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=f*a-p,e[6]=y+d*a,e[10]=o*c}else if(t.order==="ZXY"){let d=c*u,f=c*h,p=l*u,y=l*h;e[0]=d-y*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*u,e[9]=y-d*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){let d=o*u,f=o*h,p=a*u,y=a*h;e[0]=c*u,e[4]=p*l-f,e[8]=d*l+y,e[1]=c*h,e[5]=y*l+d,e[9]=f*l-p,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){let d=o*c,f=o*l,p=a*c,y=a*l;e[0]=c*u,e[4]=y-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=f*h+p,e[10]=d-y*h}else if(t.order==="XZY"){let d=o*c,f=o*l,p=a*c,y=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=d*h+y,e[5]=o*u,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*u,e[10]=y*h+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(hb,t,ub)}lookAt(t,e,i){let r=this.elements;return Re.subVectors(t,e),Re.lengthSq()===0&&(Re.z=1),Re.normalize(),ui.crossVectors(i,Re),ui.lengthSq()===0&&(Math.abs(i.z)===1?Re.x+=1e-4:Re.z+=1e-4,Re.normalize(),ui.crossVectors(i,Re)),ui.normalize(),$a.crossVectors(Re,ui),r[0]=ui.x,r[4]=$a.x,r[8]=Re.x,r[1]=ui.y,r[5]=$a.y,r[9]=Re.y,r[2]=ui.z,r[6]=$a.z,r[10]=Re.z,this}multiply(t,e){return e!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],h=i[5],d=i[9],f=i[13],p=i[2],y=i[6],x=i[10],g=i[14],m=i[3],b=i[7],v=i[11],w=i[15],_=r[0],A=r[4],I=r[8],D=r[12],N=r[1],O=r[5],F=r[9],z=r[13],P=r[2],R=r[6],U=r[10],j=r[14],Z=r[3],K=r[7],ut=r[11],it=r[15];return s[0]=o*_+a*N+c*P+l*Z,s[4]=o*A+a*O+c*R+l*K,s[8]=o*I+a*F+c*U+l*ut,s[12]=o*D+a*z+c*j+l*it,s[1]=u*_+h*N+d*P+f*Z,s[5]=u*A+h*O+d*R+f*K,s[9]=u*I+h*F+d*U+f*ut,s[13]=u*D+h*z+d*j+f*it,s[2]=p*_+y*N+x*P+g*Z,s[6]=p*A+y*O+x*R+g*K,s[10]=p*I+y*F+x*U+g*ut,s[14]=p*D+y*z+x*j+g*it,s[3]=m*_+b*N+v*P+w*Z,s[7]=m*A+b*O+v*R+w*K,s[11]=m*I+b*F+v*U+w*ut,s[15]=m*D+b*z+v*j+w*it,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],y=t[7],x=t[11],g=t[15];return p*(+s*c*h-r*l*h-s*a*d+i*l*d+r*a*f-i*c*f)+y*(+e*c*f-e*l*d+s*o*d-r*o*f+r*l*u-s*c*u)+x*(+e*l*h-e*a*f-s*o*h+i*o*f+s*a*u-i*l*u)+g*(-r*a*u-e*c*h+e*a*d+r*o*h-i*o*d+i*c*u)}transpose(){let t=this.elements,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,i){let r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}getInverse(t,e){e!==void 0&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");let i=this.elements,r=t.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],p=r[9],y=r[10],x=r[11],g=r[12],m=r[13],b=r[14],v=r[15],w=p*b*d-m*y*d+m*h*x-u*b*x-p*h*v+u*y*v,_=g*y*d-f*b*d-g*h*x+l*b*x+f*h*v-l*y*v,A=f*m*d-g*p*d+g*u*x-l*m*x-f*u*v+l*p*v,I=g*p*h-f*m*h-g*u*y+l*m*y+f*u*b-l*p*b,D=s*w+o*_+a*A+c*I;if(D===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/D;return i[0]=w*N,i[1]=(m*y*c-p*b*c-m*a*x+o*b*x+p*a*v-o*y*v)*N,i[2]=(u*b*c-m*h*c+m*a*d-o*b*d-u*a*v+o*h*v)*N,i[3]=(p*h*c-u*y*c-p*a*d+o*y*d+u*a*x-o*h*x)*N,i[4]=_*N,i[5]=(f*b*c-g*y*c+g*a*x-s*b*x-f*a*v+s*y*v)*N,i[6]=(g*h*c-l*b*c-g*a*d+s*b*d+l*a*v-s*h*v)*N,i[7]=(l*y*c-f*h*c+f*a*d-s*y*d-l*a*x+s*h*x)*N,i[8]=A*N,i[9]=(g*p*c-f*m*c-g*o*x+s*m*x+f*o*v-s*p*v)*N,i[10]=(l*m*c-g*u*c+g*o*d-s*m*d-l*o*v+s*u*v)*N,i[11]=(f*u*c-l*p*c-f*o*d+s*p*d+l*o*x-s*u*x)*N,i[12]=I*N,i[13]=(f*m*a-g*p*a+g*o*y-s*m*y-f*o*b+s*p*b)*N,i[14]=(g*u*a-l*m*a-g*o*h+s*m*h+l*o*b-s*u*b)*N,i[15]=(l*p*a-f*u*a+f*o*h-s*p*h-l*o*y+s*u*y)*N,this}scale(t){let e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let i=Math.cos(e),r=Math.sin(e),s=1-i,o=t.x,a=t.y,c=t.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this}compose(t,e,i){let r=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,l=s+s,u=o+o,h=a+a,d=s*l,f=s*u,p=s*h,y=o*u,x=o*h,g=a*h,m=c*l,b=c*u,v=c*h,w=i.x,_=i.y,A=i.z;return r[0]=(1-(y+g))*w,r[1]=(f+v)*w,r[2]=(p-b)*w,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(d+g))*_,r[6]=(x+m)*_,r[7]=0,r[8]=(p+b)*A,r[9]=(x-m)*A,r[10]=(1-(d+y))*A,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){let r=this.elements,s=Gr.set(r[0],r[1],r[2]).length(),o=Gr.set(r[4],r[5],r[6]).length(),a=Gr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],tn.copy(this);let l=1/s,u=1/o,h=1/a;return tn.elements[0]*=l,tn.elements[1]*=l,tn.elements[2]*=l,tn.elements[4]*=u,tn.elements[5]*=u,tn.elements[6]*=u,tn.elements[8]*=h,tn.elements[9]*=h,tn.elements[10]*=h,e.setFromRotationMatrix(tn),i.x=s,i.y=o,i.z=a,this}makePerspective(t,e,i,r,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,c=2*s/(e-t),l=2*s/(i-r),u=(e+t)/(e-t),h=(i+r)/(i-r),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=c,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,r,s,o){let a=this.elements,c=1/(e-t),l=1/(i-r),u=1/(o-s),h=(e+t)*c,d=(i+r)*l,f=(o+s)*u;return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){let e=this.elements,i=t.elements;for(let r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e){e===void 0&&(e=0);for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}},Gr=new Jt,tn=new fi,hb=new Jt(0,0,0),ub=new Jt(1,1,1),ui=new Jt,$a=new Jt,Re=new Jt;function im(){}Object.assign(im.prototype,{addEventListener:function(n,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[n]===void 0&&(e[n]=[]),e[n].indexOf(t)===-1&&e[n].push(t)},hasEventListener:function(n,t){if(this._listeners===void 0)return!1;let e=this._listeners;return e[n]!==void 0&&e[n].indexOf(t)!==-1},removeEventListener:function(n,t){if(this._listeners===void 0)return;let i=this._listeners[n];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}},dispatchEvent:function(n){if(this._listeners===void 0)return;let e=this._listeners[n.type];if(e!==void 0){n.target=this;let i=e.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,n)}}});var so=class n{constructor(t=0,e=0,i=0,r=n.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=e,this._z=i,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._order=r||this._order,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,i){let r=Vr.clamp,s=t.elements,o=s[0],a=s[4],c=s[8],l=s[1],u=s[5],h=s[9],d=s[2],f=s[6],p=s[10];switch(e=e||this._order,e){case"XYZ":this._y=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(f,u),this._z=0);break;case"YXZ":this._x=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(c,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-d,o),this._z=0);break;case"ZXY":this._x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,o));break;case"ZYX":this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-d,o)):(this._x=0,this._y=Math.atan2(c,p));break;case"XZY":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,u),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i!==!1&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return $p.makeRotationFromQuaternion(t),this.setFromRotationMatrix($p,e,i)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return Qp.setFromEuler(this),this.setFromQuaternion(Qp,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){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Jt(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}};so.DefaultOrder="XYZ";so.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var $p=new fi,Qp=new di,uu=class{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}},fu=class{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,r,s,o,a,c,l){let u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let 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){let i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],h=i[7],d=i[2],f=i[5],p=i[8],y=r[0],x=r[3],g=r[6],m=r[1],b=r[4],v=r[7],w=r[2],_=r[5],A=r[8];return s[0]=o*y+a*m+c*w,s[3]=o*x+a*b+c*_,s[6]=o*g+a*v+c*A,s[1]=l*y+u*m+h*w,s[4]=l*x+u*b+h*_,s[7]=l*g+u*v+h*A,s[2]=d*y+f*m+p*w,s[5]=d*x+f*b+p*_,s[8]=d*g+f*v+p*A,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-i*s*u+i*a*c+r*s*l-r*o*c}getInverse(t,e){e!==void 0&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");let i=t.elements,r=this.elements,s=i[0],o=i[1],a=i[2],c=i[3],l=i[4],u=i[5],h=i[6],d=i[7],f=i[8],p=f*l-u*d,y=u*h-f*c,x=d*c-l*h,g=s*p+o*y+a*x;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/g;return r[0]=p*m,r[1]=(a*d-f*o)*m,r[2]=(u*o-a*l)*m,r[3]=y*m,r[4]=(f*s-a*h)*m,r[5]=(a*c-u*s)*m,r[6]=x*m,r[7]=(o*h-d*s)*m,r[8]=(l*s-o*c)*m,this}transpose(){let t,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).getInverse(this).transpose()}transposeIntoArray(t){let 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,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);this.set(i*c,i*l,-i*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1)}scale(t,e){let i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){let e=Math.cos(t),i=Math.sin(t),r=this.elements,s=r[0],o=r[3],a=r[6],c=r[1],l=r[4],u=r[7];return r[0]=e*s+i*c,r[3]=e*o+i*l,r[6]=e*a+i*u,r[1]=-i*s+e*c,r[4]=-i*o+e*l,r[7]=-i*a+e*u,this}translate(t,e){let i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){let e=this.elements,i=t.elements;for(let r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e){e===void 0&&(e=0);for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}},fb=0,Kp=new Jt,Hr=new di,Un=new fi,Qa=new Jt,ro=new Jt,db=new Jt,pb=new di,tm=new Jt(1,0,0),em=new Jt(0,1,0),nm=new Jt(0,0,1),mb={type:"added"},gb={type:"removed"};function vn(){Object.defineProperty(this,"id",{value:fb++}),this.uuid=Vr.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=vn.DefaultUp.clone();let n=new Jt,t=new so,e=new di,i=new Jt(1,1,1);function r(){e.setFromEuler(t,!1)}function s(){t.setFromQuaternion(e,void 0,!1)}t._onChange(r),e._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:n},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:e},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new fi},normalMatrix:{value:new fu}}),this.matrix=new fi,this.matrixWorld=new fi,this.matrixAutoUpdate=vn.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new uu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}vn.DefaultUp=new Jt(0,1,0);vn.DefaultMatrixAutoUpdate=!0;vn.prototype=Object.assign(Object.create(im.prototype),{constructor:vn,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(n){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(n),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(n){return this.quaternion.premultiply(n),this},setRotationFromAxisAngle:function(n,t){this.quaternion.setFromAxisAngle(n,t)},setRotationFromEuler:function(n){this.quaternion.setFromEuler(n,!0)},setRotationFromMatrix:function(n){this.quaternion.setFromRotationMatrix(n)},setRotationFromQuaternion:function(n){this.quaternion.copy(n)},rotateOnAxis:function(n,t){return Hr.setFromAxisAngle(n,t),this.quaternion.multiply(Hr),this},rotateOnWorldAxis:function(n,t){return Hr.setFromAxisAngle(n,t),this.quaternion.premultiply(Hr),this},rotateX:function(n){return this.rotateOnAxis(tm,n)},rotateY:function(n){return this.rotateOnAxis(em,n)},rotateZ:function(n){return this.rotateOnAxis(nm,n)},translateOnAxis:function(n,t){return Kp.copy(n).applyQuaternion(this.quaternion),this.position.add(Kp.multiplyScalar(t)),this},translateX:function(n){return this.translateOnAxis(tm,n)},translateY:function(n){return this.translateOnAxis(em,n)},translateZ:function(n){return this.translateOnAxis(nm,n)},localToWorld:function(n){return n.applyMatrix4(this.matrixWorld)},worldToLocal:function(n){return n.applyMatrix4(Un.getInverse(this.matrixWorld))},lookAt:function(n,t,e){n.isVector3?Qa.copy(n):Qa.set(n,t,e);let i=this.parent;this.updateWorldMatrix(!0,!1),ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Un.lookAt(ro,Qa,this.up):Un.lookAt(Qa,ro,this.up),this.quaternion.setFromRotationMatrix(Un),i&&(Un.extractRotation(i.matrixWorld),Hr.setFromRotationMatrix(Un),this.quaternion.premultiply(Hr.inverse()))},add:function(n){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return n===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",n),this):(n&&n.isObject3D?(n.parent!==null&&n.parent.remove(n),n.parent=this,this.children.push(n),n.dispatchEvent(mb)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",n),this)},remove:function(n){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(n);return t!==-1&&(n.parent=null,this.children.splice(t,1),n.dispatchEvent(gb)),this},attach:function(n){return this.updateWorldMatrix(!0,!1),Un.getInverse(this.matrixWorld),n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),Un.multiply(n.parent.matrixWorld)),n.applyMatrix4(Un),n.updateWorldMatrix(!1,!1),this.add(n),this},getObjectById:function(n){return this.getObjectByProperty("id",n)},getObjectByName:function(n){return this.getObjectByProperty("name",n)},getObjectByProperty:function(n,t){if(this[n]===t)return this;for(let e=0,i=this.children.length;e<i;e++){let s=this.children[e].getObjectByProperty(n,t);if(s!==void 0)return s}},getWorldPosition:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),n=new Jt),this.updateMatrixWorld(!0),n.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),n=new di),this.updateMatrixWorld(!0),this.matrixWorld.decompose(ro,n,db),n},getWorldScale:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),n=new Jt),this.updateMatrixWorld(!0),this.matrixWorld.decompose(ro,pb,n),n},getWorldDirection:function(n){n===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),n=new Jt),this.updateMatrixWorld(!0);let t=this.matrixWorld.elements;return n.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(n){n(this);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].traverse(n)},traverseVisible:function(n){if(this.visible===!1)return;n(this);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].traverseVisible(n)},traverseAncestors:function(n){let t=this.parent;t!==null&&(n(t),t.traverseAncestors(n))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,n=!0);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].updateMatrixWorld(n)},updateWorldMatrix:function(n,t){let e=this.parent;if(n===!0&&e!==null&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].updateWorldMatrix(!1,!0)}},toJSON:function(n){let t=n===void 0||typeof n=="string",e={};t&&(n={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON());function r(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(n)),a.uuid}if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(n.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(n.shapes,u)}else r(n.shapes,a)}}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(n.materials,this.material[a]));i.material=o}else i.material=r(n.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(n).object)}if(t){let o=s(n.geometries),a=s(n.materials),c=s(n.textures),l=s(n.images),u=s(n.shapes);o.length>0&&(e.geometries=o),a.length>0&&(e.materials=a),c.length>0&&(e.textures=c),l.length>0&&(e.images=l),u.length>0&&(e.shapes=u)}return e.object=i,e;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}},clone:function(n){return new this.constructor().copy(this,n)},copy:function(n,t){if(t===void 0&&(t=!0),this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.userData=JSON.parse(JSON.stringify(n.userData)),t===!0)for(let e=0;e<n.children.length;e++){let i=n.children[e];this.add(i.clone())}return this}});var{checkArg:jT,checkArgs:XT}=Nt,du=class extends io{constructor(){super(),this.obj3d=new vn}newInstance(t){let e=super.newInstance(t);return e.obj3d=new vn,e.obj3d.rotation.order="ZYX",e.reset(),e}reset(){this.obj3d.position.set(0,0,0),this.obj3d.rotation.set(0,0,0),this.heading=0}setxyz(t,e,i){super.setxy(t,e,i)}getxyz(){return this.obj3d.position.toArray()}setRotation(t,e,i){this.obj3d.rotation.set(t,e,i)}getRotation(){let{x:t,y:e,z:i}=this.obj3d.rotation;return[t,e,i]}getThetaPhiPsi(){return this.getRotation().reverse()}getHeadingPitchRoll(){let[t,e,i]=this.getRotation(),r=Ia(i),s=Pr(-e),o=Pr(t);return[r,s,o]}getDxDyDz(){return[this.dx,this.dy,this.dz]}get x(){return this.obj3d.position.x}set x(t){this.obj3d.position.x=t}get y(){return this.obj3d.position.y}set y(t){this.obj3d.position.y=t}get z(){return this.obj3d.position.z}set z(t){this.obj3d&&(this.obj3d.position.z=t)}get theta(){return this.obj3d.rotation.z}set theta(t){this.obj3d&&(this.obj3d.rotation.z=t)}get heading(){return this.model.fromRads(this.obj3d.rotation.z)}set heading(t){this.obj3d.rotation.z=this.model.toRads(t)}get pitch(){return-this.model.fromAngleRads(this.obj3d.rotation.y)}set pitch(t){this.obj3d.rotation.y=-this.model.toAngleRads(t)}get roll(){return this.model.fromAngleRads(this.obj3d.rotation.x)}set roll(t){this.obj3d.rotation.x=this.model.toAngleRads(t)}forward(t){let e=this.patch;this.obj3d.translateX(t),super.checkXYZ(e)}right(t){this.left(-t)}left(t){this.obj3d.rotateZ(this.model.toAngleRads(t))}tiltUp(t){this.tiltDown(-t)}tiltDown(t){this.obj3d.rotateY(this.model.toAngleRads(t))}rollRight(t){this.obj3d.rotateX(this.model.toAngleRads(t))}rollLeft(t){this.rollRight(-t)}facexyz(t,e,i){let r=this.towardsXY(t,e),s=this.towardsPitchXYZ(t,e,i);this.heading=r,this.pitch=s}face(t){let{x:e,y:i,z:r}=t;this.facexyz(e,i,r)}towardsPitchXYZ(t,e,i){let[r,s,o]=this.getxyz(),[a,c,l]=[t-r,e-s,i-o],u=Math.hypot(a,c),h=Math.atan2(l,u);return this.model.fromAngleRads(h)}towardsPitch(t){let{x:e,y:i,z:r}=t;this.towardsPitchXYZ(e,i,r)}distance(t){let{x:e,y:i,z:r}=t;return this.distanceXYZ(e,i,r)}distanceXYZ(t,e,i){let{x:r,y:s,z:o}=this;return Hi(r,s,o,t,e,i)}get dx(){let{y:t,z:e}=this.obj3d.rotation;return Math.cos(t)*Math.cos(e)}get dy(){let{y:t,z:e}=this.obj3d.rotation;return Math.cos(t)*Math.sin(e)}get dz(){let t=this.obj3d.rotation.y;return Math.sin(t)}},pu=du;var mu=class extends lu{initAgentSet(t,e,i){t==="turtles"&&(i=pu),super.initAgentSet(t,e,i)}},yb=mu;var gu={rgbaCssColor(n,t,e,i=255){i=i/255;let r=i.toPrecision(2);return i===1?`rgb(${n},${t},${e})`:`rgba(${n},${t},${e},${r})`},hslCssColor(n,t=100,e=50,i=255){i=i/255;let r=i.toPrecision(4);return i===1?`hsl(${n},${t}%,${e}%)`:`hsla(${n},${t}%,${e}%,${r})`},hexCssColor(n,t,e){return`#${(16777216|(e|t<<8|n<<16)).toString(16).slice(-6)}`},cssColor(n,t,e,i=255){return i===255?this.hexCssColor(n,t,e):this.rgbaCssColor(n,t,e,i)},randomCssColor(){let n=()=>In(256);return this.cssColor(n(),n(),n())},randomGrayCssColor(n=0,t=255){let e=ni(n,t);return this.cssColor(e,e,e)},cssToPixel(n){let t=this.cssToUint8Array(n);return this.rgbaToPixel(...t)},rgbaToPixel(n,t,e,i=255){let r=new Uint8Array([n,t,e,i]);return new Uint32Array(r.buffer)[0]},randomPixel(){let n=()=>In(256);return this.rgbaToPixel(n(),n(),n())},randomGrayPixel(n=0,t=255){let e=ni(n,t);return this.rgbaToPixel(e,e,e)},sharedCtx1x1:ue(1,1,!1,{willReadFrequently:!0}),cssToUint8Array(n){return this.sharedCtx1x1.clearRect(0,0,1,1),this.sharedCtx1x1.fillStyle=n,this.sharedCtx1x1.fillRect(0,0,1,1),this.sharedCtx1x1.getImageData(0,0,1,1).data},typedColor(n,t,e,i=255){if(t===void 0)return this.toTypedColor(n);let r=new Uint8ClampedArray([n,t,e,i]);return r.pixelArray=new Uint32Array(r.buffer),Object.setPrototypeOf(r,xb),r},isTypedColor(n){return n&&n.constructor===Uint8ClampedArray&&n.pixelArray},toTypedColor(n,t){if(this.isTypedColor(n))return n;let e=this.typedColor(0,0,0,0);if(t==null)if(Le(n))e.css=n;else if(ai(n))e.pixel=n;else if(Oa(n))e.rgb=n;else if(Dr(n))e.rgb=n;else throw Error(`toTypedColor: illegal value ${n}`);else e[t]=n;return e},randomTypedColor(){let n=()=>In(256);return this.typedColor(n(),n(),n())},randomGrayTypedColor(n=0,t=255){let e=ni(n,t);return this.typedColor(e,e,e)},randomColorArray(n){let t=new Array(n);return zt(t,(e,i)=>t[i]=this.randomTypedColor()),t},randomGrayArray(n,t=0,e=255){let i=new Array(n);return zt(i,(r,s)=>i[s]=this.randomGrayTypedColor(t,e)),i}},xb={__proto__:Uint8ClampedArray.prototype,setColor(n,t,e,i=255){this.checkColorChange(),this[0]=n,this[1]=t,this[2]=e,this[3]=i},set rgb(n){this.setColor(...n)},get rgb(){return this},setAlpha(n){this.checkColorChange(),this[3]=n},getAlpha(){return this[3]},get alpha(){return this.getAlpha()},set alpha(n){this.setAlpha(n)},setPixel(n){this.checkColorChange(),this.pixelArray[0]=n},getPixel(){return this.pixelArray[0]},get pixel(){return this.getPixel()},set pixel(n){this.setPixel(n)},setCss(n){return this.setColor(...gu.cssToUint8Array(n))},getCss(){return this.string==null&&(this.string=gu.cssColor(...this)),this.string},get css(){return this.getCss()},set css(n){this.setCss(n)},setWebgl(n){if(n.length!==3)throw Error("setWebgl array length must be 3, length:",n.length);this.setColor(n[0]*255,n[1]*255,n[2]*255)},getWebgl(){return[this[0]/255,this[1]/255,this[2]/255]},get webgl(){return this.getWebgl()},set webgl(n){this.setWebgl(n)},checkColorChange(){this.string=null},equals(n){return this.getPixel()===n.getPixel()},toString(){return`[${Array.from(this).toString()}]`},rgbDistance(n,t,e){let[i,r,s]=this,o=Math.round((i+n)/2),[a,c,l]=[i-n,r-t,s-e],[u,h,d]=[a*a,c*c,l*l];return((512+o)*u>>8)+4*h+((767-o)*d>>8)}},ve=gu;function yu(n){return typeof n=="number"?n:n.pixel?n.pixel:n==="transparent"?0:ve.toTypedColor(n).pixel}var xu=class{constructor(t,e){this.ctx=ue(t,e),this.resetImageData(),this.useImageSmoothing=!1}resetImageData(){this.imageData=ji(this.ctx),this.pixels=new Uint32Array(this.imageData.data.buffer)}setPatchesSmoothing(t){this.useImageSmoothing=t}setPixels(t,e=i=>i){if(mn(t)&&(t=gn(t)),t.length!==this.pixels.length)throw Error("setPixels, data.length != pixels.length "+t.length+" "+this.pixels.length);zt(t,(i,r)=>{this.pixels[r]=yu(e(i))})}createPixels(t){Qe(this.pixels.length,e=>{this.pixels[e]=yu(t(e))})}setPixel(t,e){this.pixels[t]=yu(e)}draw(t){let e=this.ctx.imageSmoothingEnabled;t.imageSmoothingEnabled=this.useImageSmoothing,this.ctx.putImageData(this.imageData,0,0),li(t,this.ctx.canvas),t.imageSmoothingEnabled=e}clear(t){if(t=t.css||t,!t||typeof t=="string")$s(this.ctx,t);else if(typeof t=="number")this.createPixels(()=>t);else throw Error("patchesView.clear(): illegal color "+t);typeof t=="number"?this.updateCanvas():this.resetImageData()}getImageBitmap(t={}){return createImageBitmap(this.imageData,t)}drawImageBitmap(t,e={}){createImageBitmap(this.imageData,e).then(i=>li(t,i))}updateCanvas(){return this.ctx.putImageData(this.imageData,0,0),this.ctx.canvas}},oo=xu;var vu=class n extends Nn{static rgbToInt24(t,e,i){return t*256*256+e*256+i}static rgbScaleFunction(t,e){return(i,r,s)=>t+rgbToInt24(i,r,s)*e}constructor(t,e=n.rgbToInt24,i=Float32Array){let{width:r,height:s}=t;super(r,s,new i(r*s));let o=Br(t),a=ji(o),c=this.data;for(var l=0;l<c.length;l++){let u=a.data[4*l],h=a.data[4*l+1],d=a.data[4*l+2];c[l]=e(u,h,d)}}},bu=vu;var sm={};Ui(sm,{default:()=>vb,imageToBytes:()=>rm});var wu=class extends Nn{constructor(t,e=Float32Array,i={}){let r=rm(t),s=new e(r.buffer),a=4*s.length/r.length*t.width,c=t.height;super(a,c,s),Object.assign(this,i),this.src=t.src}},_u=null;function rm(n,t=!1,e="RGBA"){_u||(_u=Fr(0,0).getContext("webgl",{premultipliedAlpha:!1}));let{width:i,height:r}=n,s=_u;Object.assign(s.canvas,{width:i,height:r});let o=s[e],a=s.createTexture();s.bindTexture(s.TEXTURE_2D,a),t&&s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!0),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texImage2D(s.TEXTURE_2D,0,o,o,s.UNSIGNED_BYTE,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST);let c=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,c),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a,0);let l=s.checkFramebufferStatus(s.FRAMEBUFFER);if(l!==s.FRAMEBUFFER_COMPLETE)throw Error(`imageToBytes: status not FRAMEBUFFER_COMPLETE: ${l}`);let u=e==="RGB"?3:4,h=new Uint8Array(u*i*r);return s.readPixels(0,0,i,r,o,s.UNSIGNED_BYTE,h),s.bindFramebuffer(s.FRAMEBUFFER,null),h}var vb=wu;var um={};Ui(um,{mapbox:()=>Mb,maplibre:()=>Sb,maptiler:()=>bb,mapzen:()=>hm,redfishUSA:()=>_b,redfishWorld:()=>wb});var Mu=class n extends Nn{constructor(t,e,i,r){super(t,e,r),this.bbox=i}static viewFromDataSet(t,e){return new n(t.width,t.height,e,t.data)}lat2y(t){let[e,i,r,s]=this.bbox;return Math.round(this.height*(t-i)/(s-i))}lon2x(t){let[e,i,r,s]=this.bbox;return Math.round(this.width*(t-e)/(r-e))}toPixel(t,e){return[this.lon2x(t),this.lat2y(e)]}getGeo(t,e){let[i,r]=this.toPixel(t,e);return this.getXY(i,r)}setGeo(t,e,i){let[r,s]=this.toPixel(t,e);return this.setXY(r,s,i)}sampleGeo(t,e,i=!0){let[r,s]=this.toPixel(t,e);return this.sample(r,s,i)}dzdx(){let[t,e]=no(this.bbox),i=t/this.width,r=super.dzdx(2,1/8*(1/i));return n.viewFromDataSet(r,this.bbox)}dzdy(){let[t,e]=no(this.bbox),i=e/this.height,r=super.dzdy(2,1/8*(1/i));return n.viewFromDataSet(r,this.bbox)}slopeAndAspect(){let t=this.dzdx(),e=this.dzdy(),i=this.slope(t,e),r=this.aspect(t,e);return{dzdx:t,dzdy:e,slope:i,aspect:r}}aspect(t=this.dzdx(),e=this.dzdy()){return t.map((r,s)=>{let o=e.data[s];return Math.atan2(-o,-r)})}slope(t=this.dzdx(),e=this.dzdy()){return t.map((r,s)=>{let o=e.data[s],a=Math.hypot(-r,-o);return Math.PI/2-Math.atan2(1,a)})}clone(){return new n(this.width,this.height,this.bbox,this.data)}resample(t,e,i=!0,r=Array){let s=super.resample(t,e,i,r);return n.viewFromDataSet(s,this.bbox)}convolve(t,e=1,i=!1){let r=super.convolve(t,e,i);return n.viewFromDataSet(r,this.bbox)}normalize(t=0,e=1,i=!1){let r=super.normalize(t,e,i);return n.viewFromDataSet(r,this.bbox)}map(t){let e=super.map(t);return n.viewFromDataSet(e,this.bbox)}},om=Mu;function cm(n,t,e){return n*256*256+t*256+e}function Su(n,t){return(e,i,r)=>n+cm(e,i,r)*t}function lm(n,t,e){let i=1;return n>63&&(i=-1,n=0),i*cm(n,t,e)/10}var ao={zxyToTile:async function(n,t,e){let i=this.zxyUrl(n,t,e),r=await Wi(i);return r.zxy=[n,t,e],r},zxyToDataSet:async function(n,t,e,i=Float32Array){let r=await this.zxyToTile(n,t,e),s=this.tileDataSet(r,i),o=Xa(t,e,n),a=om.viewFromDataSet(s,o);return a.zxy=[n,t,e],a},tileDataSet:function(n,t=Float32Array){let e=this.elevationFcn;return new bu(n,e,t)},tileSize:256},bb=Object.assign({elevationFcn:Su(-1e4,.1),zxyUrl:(n,t,e)=>`https://api.maptiler.com/tiles/terrain-rgb/${n}/${t}/${e}.png?key=iQurAP6lArV1UP4gfSVs`,zxyTemplate:"https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=iQurAP6lArV1UP4gfSVs",minZoom:0,maxZoom:15},ao),hm=Object.assign({elevationFcn:Su(-32768,1/256),zxyUrl:(n,t,e)=>`https://s3.amazonaws.com/elevation-tiles-prod/terrarium/${n}/${t}/${e}.png`,zxyTemplate:"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",minZoom:0,maxZoom:15},ao),_b=Object.assign({elevationFcn:lm,zxyUrl:(n,t,e)=>`https://s3-us-west-2.amazonaws.com/simtable-elevation-tiles/${n}/${t}/${e}.png`,zxyTemplate:"https://s3-us-west-2.amazonaws.com/simtable-elevation-tiles/{z}/{x}/{y}.png",minZoom:10,maxZoom:14},ao),wb=Object.assign({elevationFcn:lm,zxyUrl:(n,t,e)=>`https://s3-us-west-2.amazonaws.com/world-elevation-tiles/DEM_tiles/${n}/${t}/${e}.png`,zxyTemplate:"https://s3-us-west-2.amazonaws.com/world-elevation-tiles/DEM_tiles/{z}/{x}/{y}.png",minZoom:7,maxZoom:13},ao),am="pk.eyJ1IjoiYmFja3NwYWNlcyIsImEiOiJjanVrbzI4dncwOXl3M3ptcGJtN3oxMmhoIn0.x9iSCrtm0iADEqixVgPwqQ",Mb=Object.assign({elevationFcn:Su(-1e4,.1),zxyUrl:(n,t,e)=>`https://api.mapbox.com/v4/mapbox.terrain-rgb/${n}/${t}/${e}.png?access_token=`+am,zxyTemplate:"https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.png?access_token="+am,minZoom:0,maxZoom:18},ao),Sb=hm;var Eb={gradientImageData(n,t,e){let i=ue(n,1);e||(e=Da(0,1,t.length));let r=i.createLinearGradient(0,0,n,0);return Qe(t.length,s=>r.addColorStop(e[s],t[s])),i.fillStyle=r,i.fillRect(0,0,n,1),Mh(i)},arrayToTypedColors(n){return n.map(t=>ve.toTypedColor(t))},permuteArrays(n,t=n,e=n){let i=[];for(let r of e)for(let s of t)for(let o of n)i.push([o,s,r]);return i},permuteRGBColors(n,t=n,e=n){let i=s=>Js(0,255,s),r=[n,t,e].map(i);return this.permuteArrays(...r)},ColorMapProto:{__proto__:Array.prototype,createIndex(){this.index=[],Qe(this.length,n=>{let t=this[n].getPixel();this.index[t]=n,this.cssNames&&(this.index[this.cssNames[n]]=n)})},randomColor(){return this[In(this.length)]},setAlpha(n){zt(this,t=>t.setAlpha(n))},clone(){return this.cloneColorMap(this)},atIndex(n){return this[n%this.length]},indexOf(n){if(this.index)return this.index[n.getPixel()];for(let t=0;t<this.length;t++)if(n.equals(this[t]))return t},scaleColor(n,t=0,e=this.length-1){if(t===e)return this[t];let i=sh(n,t,e),r=Math.round(qs(0,this.length-1,i));return this[r]},toString(){return`${this.length} ${fh(this)}`},rgbClosestIndex(n,t,e){let i=1/0,r=0;for(var s=0;s<this.length;s++){let o=this[s].rgbDistance(n,t,e);if(o<i&&(i=o,r=s,o===0))return r}return r},rgbClosestColor(n,t,e){return this[this.rgbClosestIndex(n,t,e)]},cubeClosestIndex(n,t,e){let i=this.cube;if(!i)throw Error("cubeClosestIndex: requires the cube arrays");let r=i.map(l=>255/(l-1)),s=[n,t,e].map((l,u)=>Math.round(l/r[u])),[o,a,c]=s;return o+a*i[0]+c*i[0]*i[1]},cubeClosestColor(n,t,e){return this[this.cubeClosestIndex(n,t,e)]},closestIndex(n,t,e){return this.cube?this.cubeClosestIndex(n,t,e):this.rgbClosestIndex(n,t,e)},closestColor(n,t,e){return this[this.closestIndex(n,t,e)]}},basicColorMap(n){return n=this.arrayToTypedColors(n),Object.setPrototypeOf(n,this.ColorMapProto),n},grayColorMap(n=0,t=255,e=t-n+1){let i=Js(n,t,e);return this.basicColorMap(i.map(r=>[r,r,r]))},rgbColorCube(n,t=n,e=n){let i=this.permuteRGBColors(n,t,e),r=this.basicColorMap(i);return r.cube=[n,t,e],r},rgbColorMap(n,t,e){let i=this.permuteArrays(n,t,e);return this.basicColorMap(i)},hslColorMap(n=360,t=100,e=50){let s=Js(1,360,n).map(o=>ve.hslCssColor(o)).map(o=>ve.toTypedColor(o));return this.basicColorMap(s)},transparentColorMap(n=1){return this.staticColorMap(0,n)},staticColorMap(n,t=1){n=ve.toTypedColor(n);let e=Array(t).fill(n);return this.basicColorMap(e)},gradientColorMap(n,t,e){t=t.map(s=>s.css||s);let i=this.gradientImageData(n,t,e),r=this.arrayToTypedColors(i);return Object.setPrototypeOf(r,this.ColorMapProto),r},jetColors:["rgb(0, 0, 127)","rgb(0, 0, 255)","rgb(0, 127, 255)","rgb(0, 255, 255)","rgb(127, 255, 127)","rgb(255, 255, 0)","rgb(255, 127, 0)","rgb(255, 0, 0)","rgb(127, 0, 0)"],basicColorNames:"white silver gray black red maroon yellow orange olive lime green cyan teal blue navy magenta purple".split(" "),brightColorNames:"white silver red maroon yellow orange olive lime green cyan teal blue navy magenta purple".split(" "),cssColorMap(n,t=!1){let e=n.map(r=>ve.cssToUint8Array(r)),i=this.basicColorMap(e);return i.cssNames=n,t&&(n.forEach((r,s)=>{i[r]=i[s]}),i.cyan&&(i.aqua=i.cyan),i.magenta&&(i.fuchsia=i.magenta)),i},cloneColorMap(n){let t=Object.keys(n),e=this.basicColorMap(n);return zt(t,(i,r)=>{e[r]===void 0&&(e[i]=n[i])}),e},LazyMap(n,t){return Object.defineProperty(this,n,{value:t,enumerable:!0}),t},get Gray(){return this.LazyMap("Gray",this.grayColorMap())},get Hue(){return this.LazyMap("Hue",this.hslColorMap())},get LightGray(){return this.LazyMap("LightGray",this.grayColorMap(200))},get DarkGray(){return this.LazyMap("DarkGray",this.grayColorMap(0,100))},get Jet(){return this.LazyMap("Jet",this.gradientColorMap(256,this.jetColors))},get Rgb256(){return this.LazyMap("Rgb256",this.rgbColorCube(8,8,4))},get Rgb(){return this.LazyMap("Rgb",this.rgbColorCube(16))},get Transparent(){return this.LazyMap("Transparent",this.transparentColorMap())},get Basic16(){return this.LazyMap("Basic16",this.cssColorMap(this.basicColorNames,!0))}},qi=Eb;var fm=100;function Tb(n,t=fm){let e=ai(n)?String.fromCodePoint(n):n,i=`${t}px arial`,r=_h(e,i),s=r.width,o=r.height,a=ue(s,o);return Nr(a,i),a.fillText(e,s/2,r.actualBoundingBoxAscent),a}function dm(n,t=fm){return Tb(n,t).canvas}function pm(n){return n&&(n.css||n)}var Tu=class{constructor(){this.cache={},this.paths=Yi}addPath(t,e){this.getPath(t)&&Error("addPath: ${name} already defined"),Yi[t]=e}needsStrokeColor(t){return t.endsWith("2")}getPathNames(){return Object.keys(Yi)}getPath(t){return Yi[t]}oneOf(){return mh(Yi)}nameAtIndex(t){let e=this.getPathNames();return e[ri(t,e.length)]}atIndex(t){let e=this.nameAtIndex(t);return Yi[e]}imagePathPromise(t,e){return Wi(e).then(i=>{this.createImagePath(t,i)})}createImagePath(t,e,i=!0){if(!ci(e))throw Error("Shapes createImagePath: img not an imageable "+e);i&&(e=Cb(e));function r(s){s.drawImage(e,-.5,-.5,1,1)}this.addPath(t,r)}createEmojiPath(t,e){let i=dm(e);this.createImagePath(t,i)}imageName(t,e,i,r){let s=this.getPath(t);if(!Number.isInteger(e))throw Error(`imageName: pixels is not integer: ${t}`);if(!s)throw Error(`imageName: ${t} not in Shapes`);if(s.name==="imagePath")return`${t}_${e}_image`;if(!i)throw Error(`imageName: No color for shape ${t}`);return this.needsStrokeColor(t)||(r=null),`${t}_${e}_${i}${r?`_${r}`:""}`}shapeToImage(t,e,i,r){e=Math.ceil(e);let s=this.imageName(t,e,i,r);if(this.cache&&this.cache[s])return this.cache[s];let o=ue(e,e);return o.fillStyle=pm(i),o.strokeStyle=pm(r),o.scale(e,-e),o.translate(.5,-.5),o.beginPath(),Yi[t](o),o.closePath(),o.fill(),o.canvas.name=s,this.cache&&(this.cache[s]=o.canvas),o.canvas}imageNameToImage(t){let[e,i,r,s]=t.split("_");return this.shapeToImage(e,i,r,s)}};function Cb(n){let{width:t,height:e}=n,i=ue(t,e);return i.scale(1,-1),i.drawImage(n,0,-e),i.canvas}function kn(n,t){t.forEach((e,i)=>{i===0?n.moveTo(e[0],e[1]):n.lineTo(e[0],e[1])})}function Gn(n,t,e,i,r=!1){n.arc(t,e,i,0,2*Math.PI,r)}function Eu(n,t,e,i){n.fillRect(t-i/2,e-i/2,i,i)}var Yi={arrow(n){kn(n,[[.5,0],[0,.5],[0,.2],[-.5,.2],[-.5,-.2],[0,-.2],[0,-.5]])},bug(n){n.strokeStyle=n.fillStyle,this.bug2(n)},bug2(n){n.lineWidth=.05,kn(n,[[.4,.225],[.2,0],[.4,-.225]]),n.stroke(),n.beginPath(),Gn(n,.12,0,.13),Gn(n,-.05,0,.13),Gn(n,-.27,0,.2)},circle(n){Gn(n,0,0,.5)},dart(n){kn(n,[[.5,0],[-.5,.4],[-.25,0],[-.5,-.4]])},frame(n){kn(n,[[-.5,-.5],[.5,-.5],[.5,.5],[-.5,.5]]),n.closePath(),kn(n,[[-.3,-.3],[-.3,.3],[.3,.3],[.3,-.3]])},frame2(n){Eu(n,0,0,1),n.fillStyle=n.strokeStyle,Eu(n,0,0,1-2*.2)},person(n){n.strokeStyle=n.fillStyle,this.person2(n)},person2(n){kn(n,[[.15,.2],[.3,0],[.125,-.1],[.125,.05],[.1,-.15],[.25,-.5],[.05,-.5],[0,-.25],[-.05,-.5],[-.25,-.5],[-.1,-.15],[-.125,.05],[-.125,-.1],[-.3,0],[-.15,.2]]),n.closePath(),n.fill(),n.beginPath(),n.fillStyle=n.strokeStyle,Gn(n,0,.35,.15)},ring(n){let[t,e]=[.5,.3];Gn(n,0,0,t),n.lineTo(e,0),Gn(n,0,0,e,!0)},ring2(n){let[t,e]=[.5,.3];Gn(n,0,0,t),n.closePath(),n.fill(),n.beginPath(),n.fillStyle=n.strokeStyle,Gn(n,0,0,e)},square(n){Eu(n,0,0,1)},triangle(n){kn(n,[[.5,0],[-.5,-.4],[-.5,.4]])},pentagon(n){kn(n,[[0,-.5],[.48,-.15],[.29,.4],[-.29,.4],[-.48,-.15]])},butterfly(n){kn(n,[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]])}},co=Tu;var Au=class{constructor(t=64,e=16,i=!1){t=Math.ceil(t),Object.assign(this,{spriteSize:t,cols:e,usePowerOf2:i}),this.rows=1,this.nextCol=0,this.nextRow=0,this.spritesIndex={},this.sprites=[],this.shapes=new co,i&&this.checkPowerOf2(),this.ctx=ue(this.width,this.height),this.texture=null}getSprite(t,e,i){return this.newSprite(t,e,i)}oneOf(){return Vi(this.sprites)}draw(t,e,i,r,s,o,a,c=!1){let[l,u]=o.patchXYtoPixelXY(i,r,a),h=-s;this.drawCanvas(t,e,l,u,h,c)}drawCanvas(t,e,i,r,s=0,o=!1){let{x:a,y:c,size:l}=e,u=l/2;o&&(s=0),s===0?t.drawImage(this.ctx.canvas,a,c,l,l,i-u,r-u,l,l):(t.save(),t.translate(i,r),t.rotate(s),t.drawImage(this.ctx.canvas,a,c,l,l,-u,-u,l,l),t.restore())}newSprite(t,e,i=null){let r=this.shapes.imageName(t,this.spriteSize,e,i);if(this.spritesIndex[r])return this.spritesIndex[r];let s=this.shapes.shapeToImage(t,this.spriteSize,e,i);this.checkSheetSize();let[o,a,c]=[this.nextX,this.nextY,this.spriteSize];this.ctx.drawImage(s,o,a,c,c);let{nextRow:l,nextCol:u}=this,h={name:r,id:this.sprites.length,x:o,y:a,row:l,col:u,size:c,sheet:this};return h.uvs=this.getUVs(h),this.incrementRowCol(),this.spritesIndex[r]=h,this.sprites.push(h),this.texture&&(this.texture.needsUpdate=!0),h}get width(){return this.spriteSize*this.cols}get height(){return this.spriteSize*this.rows}get nextX(){return this.spriteSize*this.nextCol}get nextY(){return this.spriteSize*this.nextRow}checkPowerOf2(){let{width:t,height:e}=this;if(!(Cr(t)&&Cr(e)))throw Error(`SpriteSheet non power of 2: ${t}x${e}`)}checkSheetSize(){this.nextRow===this.rows&&(this.rows=this.usePowerOf2?this.rows*2:this.rows+1,bh(this.ctx,this.width,this.height),zt(this.sprites,t=>{t.uvs=this.getUVs(t)}))}incrementRowCol(){this.nextCol+=1,!(this.nextCol<this.cols)&&(this.nextCol=0,this.nextRow+=1)}getUVs(t){let{row:e,col:i}=t,{rows:r,cols:s}=this,o=i/s,a=(r-(e+1))/r,c=(i+1)/s,l=(r-e)/r;return[o,a,c,a,c,l,o,l]}},Cu=Au;function Ka(n){return n&&(n.css||n)}var Lu=class n{static defaultOptions(){return{useSprites:!1,patchSize:10}}constructor(t,e,i={}){i=Object.assign(n.defaultOptions(),i),Object.assign(this,{ctx:t,world:e},i),this.shapes=new co,this.reset(this.patchSize,this.useSprites)}reset(t,e=this.useSprites){this.useSprites=e,this.resetCtx(t)}getImageBitmap(){return createImageBitmap(this.ctx.canvas)}resetCtx(t){this.patchSize=t,this.useSprites?(this.world.setCanvasSize(this.ctx.canvas,t),this.ctx.restore()):this.world.setEuclideanTransform(this.ctx,t)}drawTurtles(t,e){mn(t)&&(t=gn(t));let i=oi(e);zt(t,(r,s)=>{let o=i?e:e(r,s,t);this.drawTurtle(r,o)})}drawTurtle(t,e){if(!t.hidden&&e.size!==0)if(this.useSprites){let{sprite:i,noRotate:r}=e;if(!i){let{shape:s,color:o,strokeColor:a,size:c}=e,l=c*this.patchSize;i=this.shapes.shapeToImage(s,l,o,a)}i.sheet?i.sheet.draw(this.ctx,i,t.x,t.y,t.theta,this.world,this.patchSize,r):this.drawImage(i,t.x,t.y,r?0:t.theta)}else{let{shape:i,color:r,strokeColor:s,size:o,noRotate:a}=e;this.drawShape(i,t.x,t.y,a?0:t.theta,o,r,s)}}drawShape(t,e,i,r=0,s=1,o,a){let c=this.ctx;c.save(),c.fillStyle=Ka(o),c.strokeStyle=Ka(a),c.translate(e,i),c.scale(s,s),r!==0&&c.rotate(r),c.beginPath(),this.shapes.paths[t](c),c.closePath(),c.fill(),c.restore()}drawImage(t,e,i,r=0){let s=t.width/2,o=this.patchSize,[a,c]=this.world.patchXYtoPixelXY(e,i,o),l=this.ctx;r===0?l.drawImage(t,a-s,c-s):(l.save(),l.translate(a,c),l.rotate(-r),l.drawImage(t,-s,-s),l.restore())}drawLinks(t,e){mn(t)&&(t=gn(t));let i=oi(e),r=this.ctx;zr(this.ctx),i&&(r.strokeStyle=Ka(e.color),r.lineWidth=e.width||1,r.beginPath()),zt(t,(s,o)=>{if(i)this.drawLink(s);else{let{color:a,width:c}=e(s,o,t);this.drawLink(s,a,c)}}),i&&(r.closePath(),r.stroke()),this.ctx.restore()}drawLink(t,e,i=1){this.drawLine(t.x0,t.y0,t.x1,t.y1,e,i)}drawLine(t,e,i,r,s,o=1){let a=this.ctx;[t,e]=this.world.patchXYtoPixelXY(t,e,this.patchSize),[i,r]=this.world.patchXYtoPixelXY(i,r,this.patchSize),s&&(a.strokeStyle=Ka(s),a.lineWidth=o,a.beginPath()),a.moveTo(t,e),a.lineTo(i,r),s&&(a.closePath(),a.stroke())}},Pu=Lu;var Ru=class n{static defaultOptions(){return{div:"modelDiv",useSprites:!1,patchSize:10}}constructor(t,e={}){t.world&&(t=t.world),e=Object.assign(n.defaultOptions(),e),e.width&&(e.patchSize=e.width/t.numX,delete e.width);let i=e.div;i=Le(i)?document.getElementById(i):i;let r;Fa(i)?r=i:Array.from(i.children).filter(a=>Fa(a)).length===0?(r=Fr(0,0,!0),i.appendChild(r)):r=i.firstChild,this.ctx=r.getContext("2d"),this.world=t,this.patchesView=new oo(this.world.numX,this.world.numY),this.turtlesView=new Pu(this.ctx,this.world,e),this.ticks=0,this.clear()}tick(){this.ticks++}get canvas(){return this.ctx.canvas}reset(t,e=this.useSprites){this.turtlesView.reset(t,e)}downloadCanvas(t=void 0,e=void 0,i=void 0){let r=this.canvas;i||(i=this.model.constructor.name.toLowerCase().replace(/model$/,"")),t&&e&&(r=document.createElement("canvas"),r.width=t,r.height=e,r.getContext("2d").drawImage(this.canvas,0,0,t,e)),za(r,i)}get width(){return this.world.numX*this.patchSize}set width(t){this.reset(t/this.world.numX)}get patchSize(){return this.turtlesView.patchSize}set patchSize(t){this.reset(t)}get useSprites(){return this.turtlesView.useSprites}set useSprites(t){this.reset(this.patchSize,t)}clear(t){$s(this.ctx,t)}createPatchPixels(t){this.patchesView.createPixels(t)}setPatchPixel(t,e){this.patchesView.setPixel(t,e)}setPatchesPixels(t,e){this.patchesView.setPixels(t,e)}setPatchesSmoothing(t){this.patchesView.setPatchesSmoothing(t)}drawPatchesImage(t){li(this.ctx,t)}drawPatches(t,e){t!=null&&this.patchesView.setPixels(t,e),this.patchesView.draw(this.ctx)}drawTurtles(t,e){this.turtlesView.drawTurtles(t,e)}drawLinks(t,e){this.turtlesView.drawLinks(t,e)}setTextProperties(t,e="center",i="middle"){typeof t=="number"&&(t=`${this.patchSize*t}px sans-serif`),Nr(this.ctx,t,e,i)}drawText(t,e,i,r="black"){[e,i]=this.world.patchXYtoPixelXY(e,i,this.patchSize),t=""+t,wh(this.ctx,t,e,i,r)}},Iu=Ru;var Du=class n extends Iu{static defaultOptions(t){return{patchesColor:"random",initPatches:null,turtles:t.turtles,turtlesColor:"random",turtlesStrokeColor:"random",turtlesShape:"dart",turtlesSize:1,turtlesRotate:!0,links:t.links,linksColor:"random",linksWidth:1,textProperty:null,textSize:.5,textColor:"black",patchesMap:"DarkGray",turtlesMap:"Basic16"}}static drawKeys(){let t=this.defaultOptions({});return Object.keys(t)}static separateDrawOptions(t,e){return t.drawOptions&&(Object.assign(e,t.drawOptions),delete t.drawOptions),n.drawKeys().forEach(r=>{t[r]&&(e[r]=t[r],delete t[r])}),e}static fullScreenOptions(t,e="black",i=10){document.body.style.backgroundColor=e,document.body.style.margin=`${i}px`;let r=window.innerWidth-2*i,s=window.innerHeight-2*i,o=Math.floor(r/(2*t)),a=Math.floor(s/(2*t)),c=1;return{maxX:o,maxY:a,maxZ:c,minX:-o,minY:-a,minZ:-c}}constructor(t,e={},i={}){i=n.separateDrawOptions(e,i),i=Object.assign(n.defaultOptions(t),i),super(t,e),this.model=t,this.checkOptions(i),this.drawOptions=i}checkOptions(t){let e=Object.keys(t),i=n.defaultOptions(this.model);e.forEach(r=>{if(i[r]===void 0)throw console.log("Legal TwoDraw parameters",Object.keys(n.defaultOptions(this.model))),Error("Unknown TwoDraw parameter: "+r)}),typeof t.patchesMap=="string"&&(t.patchesMap=qi[t.patchesMap],t.patchesMap||Error("Unknown patchMap: "+t.patchesMap)),typeof t.turtlesMap=="string"&&(t.turtlesMap=qi[t.turtlesMap],t.turtlesMap||Error("Unknown turtlesMap: "+t.turtlesMap))}resetOptions(t=this.drawOptions){this.checkOptions(t),this.drawOptions=t,this.ticks=0,this.draw()}reset(t){this.ticks=0,super.reset(t),this.draw()}setValue(t,e){if(t==="patchesSize"){this.reset(e);return}let i=["patchesSize"].concat(n.drawKeys());if(!i.includes(t))throw new Error(`setValue: ${t} not a valid TwoDraw key. Valid keys:
            ${i.join()}`);this.drawOptions[t]=e,this.draw()}draw(){let t=this.model,e=this,{patchesColor:i,initPatches:r,turtles:s,turtlesColor:o,turtlesStrokeColor:a,turtlesShape:c,turtlesSize:l,turtlesRotate:u,links:h,linksColor:d,linksWidth:f,textProperty:p,textSize:y,textColor:x,patchesMap:g,turtlesMap:m}=this.drawOptions;if(e.ticks===0)if(p&&e.setTextProperties(y),r){let v=r(t,e);e.createPatchPixels(w=>v[w])}else i==="random"&&e.createPatchPixels(v=>g.randomColor());ci(i)?e.drawPatchesImage(i):i==="random"||r?(e.clear(),e.drawPatches()):Ir(i)?(e.clear(),e.drawPatches(t.patches,v=>i(v))):e.clear(i);let b=(v,w)=>w==="random"?m.atIndex(v.id).css:w;e.drawLinks(h,v=>({color:d==="random"?m.atIndex(v.id):typeof d=="function"?b(v,d(v)):d,width:typeof f=="function"?f(v):f})),e.drawTurtles(s,v=>({shape:typeof c=="function"?c(v):c,color:o==="random"?m.atIndex(v.id).css:typeof o=="function"?b(v,o(v)):o,strokeColor:a==="random"?m.atIndex(v.id+4).css:typeof o=="function"?b(v,o(v)):o,size:typeof l=="function"?l(v):l,noRotate:typeof u=="function"?!u(v):!u})),p&&s.ask(v=>{v[p]!=null&&e.drawText(v[p],v.x,v.y,x)}),e.tick()}},Lb=Du;Number.EPSILON===void 0&&(Number.EPSILON=Math.pow(2,-52));Number.isInteger===void 0&&(Number.isInteger=function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n});Math.sign===void 0&&(Math.sign=function(n){return n<0?-1:n>0?1:+n});"name"in Function.prototype||Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}});Object.assign===void 0&&(Object.assign=function(n){if(n==null)throw new TypeError("Cannot convert undefined or null to object");let t=Object(n);for(let e=1;e<arguments.length;e++){let i=arguments[e];if(i!=null)for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t});var xg="120",qn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Yn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},vg=0,uf=1,bg=2,Pb=3,Rb=0,ud=1,_g=2,cs=3,Os=0,oe=1,xa=2,fd=1,Ib=2,$n=0,ds=1,ff=2,df=3,pf=4,wg=5,rr=100,Mg=101,Sg=102,mf=103,gf=104,Eg=200,Tg=201,Ag=202,Cg=203,dd=204,pd=205,Lg=206,Pg=207,Rg=208,Ig=209,Dg=210,Og=0,Fg=1,zg=2,Hc=3,Ng=4,Bg=5,Ug=6,kg=7,va=0,Gg=1,Hg=2,ar=0,Vg=1,Wg=2,jg=3,Xg=4,qg=5,Xl=300,ba=301,_a=302,Vc=303,Wc=304,Fs=306,wa=307,Ao=1e3,_e=1001,Co=1002,ae=1003,jc=1004,Db=1004,Xc=1005,Ob=1005,he=1006,md=1007,Fb=1007,zs=1008,zb=1008,Ns=1009,Yg=1010,Zg=1011,Lo=1012,Jg=1013,_o=1014,Zn=1015,Po=1016,$g=1017,Qg=1018,Kg=1019,ps=1020,ty=1021,Mi=1022,Fe=1023,ey=1024,ny=1025,iy=Fe,cr=1026,gs=1027,ry=1028,sy=1029,oy=1030,ay=1031,cy=1032,ly=1033,yf=33776,xf=33777,vf=33778,bf=33779,_f=35840,wf=35841,Mf=35842,Sf=35843,hy=36196,Ef=37492,Tf=37496,uy=37808,fy=37809,dy=37810,py=37811,my=37812,gy=37813,yy=37814,xy=37815,vy=37816,by=37817,_y=37818,wy=37819,My=37820,Sy=37821,Ey=36492,Ty=37840,Ay=37841,Cy=37842,Ly=37843,Py=37844,Ry=37845,Iy=37846,Dy=37847,Oy=37848,Fy=37849,zy=37850,Ny=37851,By=37852,Uy=37853,ky=2200,Gy=2201,Hy=2202,Ro=2300,wo=2301,kc=2302,sr=2400,or=2401,Io=2402,ql=2500,gd=2501,Vy=0,Nb=1,Bb=2,we=3e3,Ma=3001,Yl=3007,Zl=3002,Wy=3003,yd=3004,xd=3005,vd=3006,jy=3200,Xy=3201,Er=0,qy=1,Ub=0,Gc=7680,kb=7681,Gb=7682,Hb=7683,Vb=34055,Wb=34056,jb=5386,Xb=512,qb=513,Yb=514,Zb=515,Jb=516,$b=517,Qb=518,Yy=519,Sa=35044,lr=35048,Kb=35040,t_=35045,e_=35049,n_=35041,i_=35046,r_=35050,s_=35042,o_="100",Af="300 es";function Je(){}Object.assign(Je.prototype,{addEventListener:function(n,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[n]===void 0&&(e[n]=[]),e[n].indexOf(t)===-1&&e[n].push(t)},hasEventListener:function(n,t){if(this._listeners===void 0)return!1;let e=this._listeners;return e[n]!==void 0&&e[n].indexOf(t)!==-1},removeEventListener:function(n,t){if(this._listeners===void 0)return;let i=this._listeners[n];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}},dispatchEvent:function(n){if(this._listeners===void 0)return;let e=this._listeners[n.type];if(e!==void 0){n.target=this;let i=e.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,n)}}});var de=[];for(let n=0;n<256;n++)de[n]=(n<16?"0":"")+n.toString(16);var tc=1234567,_t={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){let n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(de[n&255]+de[n>>8&255]+de[n>>16&255]+de[n>>24&255]+"-"+de[t&255]+de[t>>8&255]+"-"+de[t>>16&15|64]+de[t>>24&255]+"-"+de[e&63|128]+de[e>>8&255]+"-"+de[e>>16&255]+de[e>>24&255]+de[i&255]+de[i>>8&255]+de[i>>16&255]+de[i>>24&255]).toUpperCase()},clamp:function(n,t,e){return Math.max(t,Math.min(e,n))},euclideanModulo:function(n,t){return(n%t+t)%t},mapLinear:function(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)},lerp:function(n,t,e){return(1-e)*n+e*t},smoothstep:function(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))},smootherstep:function(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))},randInt:function(n,t){return n+Math.floor(Math.random()*(t-n+1))},randFloat:function(n,t){return n+Math.random()*(t-n)},randFloatSpread:function(n){return n*(.5-Math.random())},seededRandom:function(n){return n!==void 0&&(tc=n%2147483647),tc=tc*16807%2147483647,(tc-1)/2147483646},degToRad:function(n){return n*_t.DEG2RAD},radToDeg:function(n){return n*_t.RAD2DEG},isPowerOfTwo:function(n){return(n&n-1)===0&&n!==0},ceilPowerOfTwo:function(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))},floorPowerOfTwo:function(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},setQuaternionFromProperEuler:function(n,t,e,i,r){let s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),l=s((t+i)/2),u=o((t+i)/2),h=s((t-i)/2),d=o((t-i)/2),f=s((i-t)/2),p=o((i-t)/2);switch(r){case"XYX":n.set(a*u,c*h,c*d,a*l);break;case"YZY":n.set(c*d,a*u,c*h,a*l);break;case"ZXZ":n.set(c*h,c*d,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}},G=class{constructor(t=0,e=0){Object.defineProperty(this,"isVector2",{value:!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,e){return e!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(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){let e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=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){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this}toArray(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*i-o*r+t.x,this.y=s*r+o*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}},pe=class{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,r,s,o,a,c,l){let u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let 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){let i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],h=i[7],d=i[2],f=i[5],p=i[8],y=r[0],x=r[3],g=r[6],m=r[1],b=r[4],v=r[7],w=r[2],_=r[5],A=r[8];return s[0]=o*y+a*m+c*w,s[3]=o*x+a*b+c*_,s[6]=o*g+a*v+c*A,s[1]=l*y+u*m+h*w,s[4]=l*x+u*b+h*_,s[7]=l*g+u*v+h*A,s[2]=d*y+f*m+p*w,s[5]=d*x+f*b+p*_,s[8]=d*g+f*v+p*A,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-i*s*u+i*a*c+r*s*l-r*o*c}getInverse(t,e){e!==void 0&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");let i=t.elements,r=this.elements,s=i[0],o=i[1],a=i[2],c=i[3],l=i[4],u=i[5],h=i[6],d=i[7],f=i[8],p=f*l-u*d,y=u*h-f*c,x=d*c-l*h,g=s*p+o*y+a*x;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/g;return r[0]=p*m,r[1]=(a*d-f*o)*m,r[2]=(u*o-a*l)*m,r[3]=y*m,r[4]=(f*s-a*h)*m,r[5]=(a*c-u*s)*m,r[6]=x*m,r[7]=(o*h-d*s)*m,r[8]=(l*s-o*c)*m,this}transpose(){let t,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).getInverse(this).transpose()}transposeIntoArray(t){let 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,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);this.set(i*c,i*l,-i*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1)}scale(t,e){let i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){let e=Math.cos(t),i=Math.sin(t),r=this.elements,s=r[0],o=r[3],a=r[6],c=r[1],l=r[4],u=r[7];return r[0]=e*s+i*c,r[3]=e*o+i*l,r[6]=e*a+i*u,r[1]=-i*s+e*c,r[4]=-i*o+e*l,r[7]=-i*a+e*u,this}translate(t,e){let i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){let e=this.elements,i=t.elements;for(let r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e){e===void 0&&(e=0);for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}},Wr,Ai={getDataURL:function(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement>"u")return n.src;let t;if(n instanceof HTMLCanvasElement)t=n;else{Wr===void 0&&(Wr=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Wr.width=n.width,Wr.height=n.height;let e=Wr.getContext("2d");n instanceof ImageData?e.putImageData(n,0,0):e.drawImage(n,0,0,n.width,n.height),t=Wr}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},a_=0;function Gt(n,t,e,i,r,s,o,a,c,l){Object.defineProperty(this,"id",{value:a_++}),this.uuid=_t.generateUUID(),this.name="",this.image=n!==void 0?n:Gt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=t!==void 0?t:Gt.DEFAULT_MAPPING,this.wrapS=e!==void 0?e:_e,this.wrapT=i!==void 0?i:_e,this.magFilter=r!==void 0?r:he,this.minFilter=s!==void 0?s:zs,this.anisotropy=c!==void 0?c:1,this.format=o!==void 0?o:Fe,this.internalFormat=null,this.type=a!==void 0?a:Ns,this.offset=new G(0,0),this.repeat=new G(1,1),this.center=new G(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=l!==void 0?l:we,this.version=0,this.onUpdate=null}Gt.DEFAULT_IMAGE=void 0;Gt.DEFAULT_MAPPING=Xl;Gt.prototype=Object.assign(Object.create(Je.prototype),{constructor:Gt,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(n){return this.name=n.name,this.image=n.image,this.mipmaps=n.mipmaps.slice(0),this.mapping=n.mapping,this.wrapS=n.wrapS,this.wrapT=n.wrapT,this.magFilter=n.magFilter,this.minFilter=n.minFilter,this.anisotropy=n.anisotropy,this.format=n.format,this.internalFormat=n.internalFormat,this.type=n.type,this.offset.copy(n.offset),this.repeat.copy(n.repeat),this.center.copy(n.center),this.rotation=n.rotation,this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrix.copy(n.matrix),this.generateMipmaps=n.generateMipmaps,this.premultiplyAlpha=n.premultiplyAlpha,this.flipY=n.flipY,this.unpackAlignment=n.unpackAlignment,this.encoding=n.encoding,this},toJSON:function(n){let t=n===void 0||typeof n=="string";if(!t&&n.textures[this.uuid]!==void 0)return n.textures[this.uuid];let e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let i=this.image;if(i.uuid===void 0&&(i.uuid=_t.generateUUID()),!t&&n.images[i.uuid]===void 0){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)r.push(Ai.getDataURL(i[s]))}else r=Ai.getDataURL(i);n.images[i.uuid]={uuid:i.uuid,url:r}}e.image=i.uuid}return t||(n.textures[this.uuid]=e),e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(n){if(this.mapping!==Xl)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case Ao:n.x=n.x-Math.floor(n.x);break;case _e:n.x=n.x<0?0:1;break;case Co:Math.abs(Math.floor(n.x)%2)===1?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x);break}if(n.y<0||n.y>1)switch(this.wrapT){case Ao:n.y=n.y-Math.floor(n.y);break;case _e:n.y=n.y<0?0:1;break;case Co:Math.abs(Math.floor(n.y)%2)===1?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y);break}return this.flipY&&(n.y=1-n.y),n}});Object.defineProperty(Gt.prototype,"needsUpdate",{set:function(n){n===!0&&this.version++}});var Bt=class{constructor(t=0,e=0,i=0,r=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=e,this.z=i,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t,e){return e!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(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}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,i=this.y,r=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*e+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*e+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*e+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let 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,i,r,s,c=t.elements,l=c[0],u=c[4],h=c[8],d=c[1],f=c[5],p=c[9],y=c[2],x=c[6],g=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-y)<.01&&Math.abs(p-x)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+y)<.1&&Math.abs(p+x)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let b=(l+1)/2,v=(f+1)/2,w=(g+1)/2,_=(u+d)/4,A=(h+y)/4,I=(p+x)/4;return b>v&&b>w?b<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(b),r=_/i,s=A/i):v>w?v<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(v),i=_/r,s=I/r):w<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(w),i=A/s,r=I/s),this.set(i,r,s,e),this}let m=Math.sqrt((x-p)*(x-p)+(h-y)*(h-y)+(d-u)*(d-u));return Math.abs(m)<.001&&(m=1),this.x=(x-p)/m,this.y=(h-y)/m,this.z=(d-u)/m,this.w=Math.acos((l+f+g-1)/2),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){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,i){return i!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),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}};function ze(n,t,e){this.width=n,this.height=t,this.scissor=new Bt(0,0,n,t),this.scissorTest=!1,this.viewport=new Bt(0,0,n,t),e=e||{},this.texture=new Gt(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.image={},this.texture.image.width=n,this.texture.image.height=t,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:he,this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0,this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!1,this.depthTexture=e.depthTexture!==void 0?e.depthTexture:null}ze.prototype=Object.assign(Object.create(Je.prototype),{constructor:ze,isWebGLRenderTarget:!0,setSize:function(n,t){(this.width!==n||this.height!==t)&&(this.width=n,this.height=t,this.texture.image.width=n,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,n,t),this.scissor.set(0,0,n,t)},clone:function(){return new this.constructor().copy(this)},copy:function(n){return this.width=n.width,this.height=n.height,this.viewport.copy(n.viewport),this.texture=n.texture.clone(),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});function Cf(n,t,e){ze.call(this,n,t,e),this.samples=4}Cf.prototype=Object.assign(Object.create(ze.prototype),{constructor:Cf,isWebGLMultisampleRenderTarget:!0,copy:function(n){return ze.prototype.copy.call(this,n),this.samples=n.samples,this}});var ie=class{constructor(t=0,e=0,i=0,r=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=e,this._z=i,this._w=r}static slerp(t,e,i,r){return i.copy(t).slerp(e,r)}static slerpFlat(t,e,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],h=i[r+3],d=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(h!==y||c!==d||l!==f||u!==p){let x=1-a,g=c*d+l*f+u*p+h*y,m=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){let w=Math.sqrt(b),_=Math.atan2(w,g*m);x=Math.sin(x*_)/w,a=Math.sin(a*_)/w}let v=a*m;if(c=c*x+d*v,l=l*x+f*v,u=u*x+p*v,h=h*x+y*v,x===1-a){let w=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=w,l*=w,u*=w,h*=w}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+c*f-l*d,t[e+1]=c*p+u*d+l*h-a*f,t[e+2]=l*p+u*f+a*d-c*h,t[e+3]=u*p-a*h-c*d-l*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,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let i=t._x,r=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),h=a(s/2),d=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h+d*f*p;break;case"YZX":this._x=d*u*h+l*f*p,this._y=l*f*h+d*u*p,this._z=l*u*p-d*f*h,this._w=l*u*h-d*f*p;break;case"XZY":this._x=d*u*h-l*f*p,this._y=l*f*h-d*u*p,this._z=l*u*p+d*f*h,this._w=l*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,i=e[0],r=e[4],s=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],d=i+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>h){let f=2*Math.sqrt(1+i-a-h);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>h){let f=2*Math.sqrt(1+a-i-h);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+h-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-6?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(_t.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){let i=this.angleTo(t);if(i===0)return this;let r=Math.min(1,e/i);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}inverse(){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,e){return e!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let i=t._x,r=t._y,s=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-e;return this._w=f*o+e*this._w,this._x=f*i+e*this._x,this._y=f*r+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e){return e===void 0&&(e=0),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){return t===void 0&&(t=[]),e===void 0&&(e=0),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}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}},M=class{constructor(t=0,e=0,i=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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,e){return e!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(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,e){return e!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(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 t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(mm.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(mm.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,i=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(t){let e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=c*e+o*r-a*i,u=c*i+a*e-s*r,h=c*r+s*i-o*e,d=-s*e-o*i-a*r;return this.x=l*c+d*-s+u*-a-h*-o,this.y=u*c+d*-o+h*-s-l*-a,this.z=h*c+d*-a+l*-o-u*-s,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=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){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t,e){return e!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){let i=t.x,r=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Ou.copy(this).projectOnVector(t),this.sub(Ou)}reflect(t){return this.sub(Ou.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let i=this.dot(t)/e;return Math.acos(_t.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){let r=Math.sin(e)*t;return this.x=r*Math.sin(i),this.y=Math.cos(e)*t,this.z=r*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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}},Ou=new M,mm=new ie,je=class{constructor(t,e){Object.defineProperty(this,"isBox3",{value:!0}),this.min=t!==void 0?t:new M(1/0,1/0,1/0),this.max=e!==void 0?e:new M(-1/0,-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,i=1/0,r=1/0,s=-1/0,o=-1/0,a=-1/0;for(let c=0,l=t.length;c<l;c+=3){let u=t[c],h=t[c+1],d=t[c+2];u<e&&(e=u),h<i&&(i=h),d<r&&(r=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,i,r),this.max.set(s,o,a),this}setFromBufferAttribute(t){let e=1/0,i=1/0,r=1/0,s=-1/0,o=-1/0,a=-1/0;for(let c=0,l=t.count;c<l;c++){let u=t.getX(c),h=t.getY(c),d=t.getZ(c);u<e&&(e=u),h<i&&(i=h),d<r&&(r=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,i,r),this.max.set(s,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let i=lo.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return t===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new M),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return t===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new M),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);let e=t.geometry;e!==void 0&&(e.boundingBox===null&&e.computeBoundingBox(),zu.copy(e.boundingBox),zu.applyMatrix4(t.matrixWorld),this.union(zu));let i=t.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new M),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,lo),lo.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ho),ec.subVectors(this.max,ho),jr.subVectors(t.a,ho),Xr.subVectors(t.b,ho),qr.subVectors(t.c,ho),pi.subVectors(Xr,jr),mi.subVectors(qr,Xr),Zi.subVectors(jr,qr);let e=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-Zi.z,Zi.y,pi.z,0,-pi.x,mi.z,0,-mi.x,Zi.z,0,-Zi.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-Zi.y,Zi.x,0];return!Fu(e,jr,Xr,qr,ec)||(e=[1,0,0,0,1,0,0,0,1],!Fu(e,jr,Xr,qr,ec))?!1:(nc.crossVectors(pi,mi),e=[nc.x,nc.y,nc.z],Fu(e,jr,Xr,qr,ec))}clampPoint(t,e){return e===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new M),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return lo.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return t===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=this.getSize(lo).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:(Hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Hn),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)}};function Fu(n,t,e,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Ji.fromArray(n,s);let a=r.x*Math.abs(Ji.x)+r.y*Math.abs(Ji.y)+r.z*Math.abs(Ji.z),c=t.dot(Ji),l=e.dot(Ji),u=i.dot(Ji);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Hn=[new M,new M,new M,new M,new M,new M,new M,new M],lo=new M,zu=new je,jr=new M,Xr=new M,qr=new M,pi=new M,mi=new M,Zi=new M,ho=new M,ec=new M,nc=new M,Ji=new M,c_=new je,cn=class{constructor(t,e){this.center=t!==void 0?t:new M,this.radius=e!==void 0?e:-1}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let i=this.center;e!==void 0?i.copy(e):c_.setFromPoints(t).getCenter(i);let r=0;for(let s=0,o=t.length;s<o;s++)r=Math.max(r,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let i=this.center.distanceToSquared(t);return e===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new M),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return t===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new je),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}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}},Vn=new M,Nu=new M,ic=new M,gi=new M,Bu=new M,rc=new M,Uu=new M,Ci=class{constructor(t,e){this.origin=t!==void 0?t:new M,this.direction=e!==void 0?e:new M(0,0,-1)}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}clone(){return new this.constructor().copy(this)}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e===void 0&&(console.warn("THREE.Ray: .at() target is now required"),e=new M),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Vn)),this}closestPointToPoint(t,e){e===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new M),e.subVectors(t,this.origin);let i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Vn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Vn.copy(this.direction).multiplyScalar(e).add(this.origin),Vn.distanceToSquared(t))}distanceSqToSegment(t,e,i,r){Nu.copy(t).add(e).multiplyScalar(.5),ic.copy(e).sub(t).normalize(),gi.copy(this.origin).sub(Nu);let s=t.distanceTo(e)*.5,o=-this.direction.dot(ic),a=gi.dot(this.direction),c=-gi.dot(ic),l=gi.lengthSq(),u=Math.abs(1-o*o),h,d,f,p;if(u>0)if(h=o*c-a,d=o*a-c,p=s*u,h>=0)if(d>=-p)if(d<=p){let y=1/u;h*=y,d*=y,f=h*(h+o*d+2*a)+d*(o*h+d+2*c)+l}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*c)+l;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*c)+l;else d<=-p?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-c),s),f=-h*h+d*(d+2*c)+l):d<=p?(h=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-c),s),f=-h*h+d*(d+2*c)+l);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*c)+l;return i&&i.copy(this.direction).multiplyScalar(h).add(this.origin),r&&r.copy(ic).multiplyScalar(d).add(Nu),f}intersectSphere(t,e){Vn.subVectors(t.center,this.origin);let i=Vn.dot(this.direction),r=Vn.dot(Vn)-i*i,s=t.radius*t.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return a<0&&c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){let i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(i=(t.min.x-d.x)*l,r=(t.max.x-d.x)*l):(i=(t.max.x-d.x)*l,r=(t.min.x-d.x)*l),u>=0?(s=(t.min.y-d.y)*u,o=(t.max.y-d.y)*u):(s=(t.max.y-d.y)*u,o=(t.min.y-d.y)*u),i>o||s>r||((s>i||i!==i)&&(i=s),(o<r||r!==r)&&(r=o),h>=0?(a=(t.min.z-d.z)*h,c=(t.max.z-d.z)*h):(a=(t.max.z-d.z)*h,c=(t.min.z-d.z)*h),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,e)}intersectsBox(t){return this.intersectBox(t,Vn)!==null}intersectTriangle(t,e,i,r,s){Bu.subVectors(e,t),rc.subVectors(i,t),Uu.crossVectors(Bu,rc);let o=this.direction.dot(Uu),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;gi.subVectors(this.origin,t);let c=a*this.direction.dot(rc.crossVectors(gi,rc));if(c<0)return null;let l=a*this.direction.dot(Bu.cross(gi));if(l<0||c+l>o)return null;let u=-a*gi.dot(Uu);return u<0?null:this.at(u/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}},At=class n{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,r,s,o,a,c,l,u,h,d,f,p,y,x){let g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=u,g[10]=h,g[14]=d,g[3]=f,g[7]=p,g[11]=y,g[15]=x,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 n().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){let e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,i=t.elements,r=1/Yr.setFromMatrixColumn(t,0).length(),s=1/Yr.setFromMatrixColumn(t,1).length(),o=1/Yr.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let e=this.elements,i=t.x,r=t.y,s=t.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*u,f=o*h,p=a*u,y=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=f+p*l,e[5]=d-y*l,e[9]=-a*c,e[2]=y-d*l,e[6]=p+f*l,e[10]=o*c}else if(t.order==="YXZ"){let d=c*u,f=c*h,p=l*u,y=l*h;e[0]=d+y*a,e[4]=p*a-f,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=f*a-p,e[6]=y+d*a,e[10]=o*c}else if(t.order==="ZXY"){let d=c*u,f=c*h,p=l*u,y=l*h;e[0]=d-y*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*u,e[9]=y-d*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){let d=o*u,f=o*h,p=a*u,y=a*h;e[0]=c*u,e[4]=p*l-f,e[8]=d*l+y,e[1]=c*h,e[5]=y*l+d,e[9]=f*l-p,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){let d=o*c,f=o*l,p=a*c,y=a*l;e[0]=c*u,e[4]=y-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=f*h+p,e[10]=d-y*h}else if(t.order==="XZY"){let d=o*c,f=o*l,p=a*c,y=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=d*h+y,e[5]=o*u,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*u,e[10]=y*h+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(l_,t,h_)}lookAt(t,e,i){let r=this.elements;return Ie.subVectors(t,e),Ie.lengthSq()===0&&(Ie.z=1),Ie.normalize(),yi.crossVectors(i,Ie),yi.lengthSq()===0&&(Math.abs(i.z)===1?Ie.x+=1e-4:Ie.z+=1e-4,Ie.normalize(),yi.crossVectors(i,Ie)),yi.normalize(),sc.crossVectors(Ie,yi),r[0]=yi.x,r[4]=sc.x,r[8]=Ie.x,r[1]=yi.y,r[5]=sc.y,r[9]=Ie.y,r[2]=yi.z,r[6]=sc.z,r[10]=Ie.z,this}multiply(t,e){return e!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,r=e.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],h=i[5],d=i[9],f=i[13],p=i[2],y=i[6],x=i[10],g=i[14],m=i[3],b=i[7],v=i[11],w=i[15],_=r[0],A=r[4],I=r[8],D=r[12],N=r[1],O=r[5],F=r[9],z=r[13],P=r[2],R=r[6],U=r[10],j=r[14],Z=r[3],K=r[7],ut=r[11],it=r[15];return s[0]=o*_+a*N+c*P+l*Z,s[4]=o*A+a*O+c*R+l*K,s[8]=o*I+a*F+c*U+l*ut,s[12]=o*D+a*z+c*j+l*it,s[1]=u*_+h*N+d*P+f*Z,s[5]=u*A+h*O+d*R+f*K,s[9]=u*I+h*F+d*U+f*ut,s[13]=u*D+h*z+d*j+f*it,s[2]=p*_+y*N+x*P+g*Z,s[6]=p*A+y*O+x*R+g*K,s[10]=p*I+y*F+x*U+g*ut,s[14]=p*D+y*z+x*j+g*it,s[3]=m*_+b*N+v*P+w*Z,s[7]=m*A+b*O+v*R+w*K,s[11]=m*I+b*F+v*U+w*ut,s[15]=m*D+b*z+v*j+w*it,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],y=t[7],x=t[11],g=t[15];return p*(+s*c*h-r*l*h-s*a*d+i*l*d+r*a*f-i*c*f)+y*(+e*c*f-e*l*d+s*o*d-r*o*f+r*l*u-s*c*u)+x*(+e*l*h-e*a*f-s*o*h+i*o*f+s*a*u-i*l*u)+g*(-r*a*u-e*c*h+e*a*d+r*o*h-i*o*d+i*c*u)}transpose(){let t=this.elements,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,i){let r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}getInverse(t,e){e!==void 0&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");let i=this.elements,r=t.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],p=r[9],y=r[10],x=r[11],g=r[12],m=r[13],b=r[14],v=r[15],w=p*b*d-m*y*d+m*h*x-u*b*x-p*h*v+u*y*v,_=g*y*d-f*b*d-g*h*x+l*b*x+f*h*v-l*y*v,A=f*m*d-g*p*d+g*u*x-l*m*x-f*u*v+l*p*v,I=g*p*h-f*m*h-g*u*y+l*m*y+f*u*b-l*p*b,D=s*w+o*_+a*A+c*I;if(D===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/D;return i[0]=w*N,i[1]=(m*y*c-p*b*c-m*a*x+o*b*x+p*a*v-o*y*v)*N,i[2]=(u*b*c-m*h*c+m*a*d-o*b*d-u*a*v+o*h*v)*N,i[3]=(p*h*c-u*y*c-p*a*d+o*y*d+u*a*x-o*h*x)*N,i[4]=_*N,i[5]=(f*b*c-g*y*c+g*a*x-s*b*x-f*a*v+s*y*v)*N,i[6]=(g*h*c-l*b*c-g*a*d+s*b*d+l*a*v-s*h*v)*N,i[7]=(l*y*c-f*h*c+f*a*d-s*y*d-l*a*x+s*h*x)*N,i[8]=A*N,i[9]=(g*p*c-f*m*c-g*o*x+s*m*x+f*o*v-s*p*v)*N,i[10]=(l*m*c-g*u*c+g*o*d-s*m*d-l*o*v+s*u*v)*N,i[11]=(f*u*c-l*p*c-f*o*d+s*p*d+l*o*x-s*u*x)*N,i[12]=I*N,i[13]=(f*m*a-g*p*a+g*o*y-s*m*y-f*o*b+s*p*b)*N,i[14]=(g*u*a-l*m*a-g*o*h+s*m*h+l*o*b-s*u*b)*N,i[15]=(l*p*a-f*u*a+f*o*h-s*p*h-l*o*y+s*u*y)*N,this}scale(t){let e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let i=Math.cos(e),r=Math.sin(e),s=1-i,o=t.x,a=t.y,c=t.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this}compose(t,e,i){let r=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,l=s+s,u=o+o,h=a+a,d=s*l,f=s*u,p=s*h,y=o*u,x=o*h,g=a*h,m=c*l,b=c*u,v=c*h,w=i.x,_=i.y,A=i.z;return r[0]=(1-(y+g))*w,r[1]=(f+v)*w,r[2]=(p-b)*w,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(d+g))*_,r[6]=(x+m)*_,r[7]=0,r[8]=(p+b)*A,r[9]=(x-m)*A,r[10]=(1-(d+y))*A,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){let r=this.elements,s=Yr.set(r[0],r[1],r[2]).length(),o=Yr.set(r[4],r[5],r[6]).length(),a=Yr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],en.copy(this);let l=1/s,u=1/o,h=1/a;return en.elements[0]*=l,en.elements[1]*=l,en.elements[2]*=l,en.elements[4]*=u,en.elements[5]*=u,en.elements[6]*=u,en.elements[8]*=h,en.elements[9]*=h,en.elements[10]*=h,e.setFromRotationMatrix(en),i.x=s,i.y=o,i.z=a,this}makePerspective(t,e,i,r,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,c=2*s/(e-t),l=2*s/(i-r),u=(e+t)/(e-t),h=(i+r)/(i-r),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=c,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,r,s,o){let a=this.elements,c=1/(e-t),l=1/(i-r),u=1/(o-s),h=(e+t)*c,d=(i+r)*l,f=(o+s)*u;return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){let e=this.elements,i=t.elements;for(let r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e){e===void 0&&(e=0);for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}},Yr=new M,en=new At,l_=new M(0,0,0),h_=new M(1,1,1),yi=new M,sc=new M,Ie=new M,ys=class n{constructor(t=0,e=0,i=0,r=n.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=e,this._z=i,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._order=r||this._order,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,i){let r=_t.clamp,s=t.elements,o=s[0],a=s[4],c=s[8],l=s[1],u=s[5],h=s[9],d=s[2],f=s[6],p=s[10];switch(e=e||this._order,e){case"XYZ":this._y=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(f,u),this._z=0);break;case"YXZ":this._x=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(c,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-d,o),this._z=0);break;case"ZXY":this._x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,o));break;case"ZYX":this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-d,o)):(this._x=0,this._y=Math.atan2(c,p));break;case"XZY":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,u),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i!==!1&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return gm.makeRotationFromQuaternion(t),this.setFromRotationMatrix(gm,e,i)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return ym.setFromEuler(this),this.setFromQuaternion(ym,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){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new M(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}};ys.DefaultOrder="XYZ";ys.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var gm=new At,ym=new ie,Do=class{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}},u_=0,xm=new M,Zr=new ie,Wn=new At,oc=new M,uo=new M,f_=new M,d_=new ie,vm=new M(1,0,0),bm=new M(0,1,0),_m=new M(0,0,1),p_={type:"added"},m_={type:"removed"};function dt(){Object.defineProperty(this,"id",{value:u_++}),this.uuid=_t.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=dt.DefaultUp.clone();let n=new M,t=new ys,e=new ie,i=new M(1,1,1);function r(){e.setFromEuler(t,!1)}function s(){t.setFromQuaternion(e,void 0,!1)}t._onChange(r),e._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:n},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:e},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new At},normalMatrix:{value:new pe}}),this.matrix=new At,this.matrixWorld=new At,this.matrixAutoUpdate=dt.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Do,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}dt.DefaultUp=new M(0,1,0);dt.DefaultMatrixAutoUpdate=!0;dt.prototype=Object.assign(Object.create(Je.prototype),{constructor:dt,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(n){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(n),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(n){return this.quaternion.premultiply(n),this},setRotationFromAxisAngle:function(n,t){this.quaternion.setFromAxisAngle(n,t)},setRotationFromEuler:function(n){this.quaternion.setFromEuler(n,!0)},setRotationFromMatrix:function(n){this.quaternion.setFromRotationMatrix(n)},setRotationFromQuaternion:function(n){this.quaternion.copy(n)},rotateOnAxis:function(n,t){return Zr.setFromAxisAngle(n,t),this.quaternion.multiply(Zr),this},rotateOnWorldAxis:function(n,t){return Zr.setFromAxisAngle(n,t),this.quaternion.premultiply(Zr),this},rotateX:function(n){return this.rotateOnAxis(vm,n)},rotateY:function(n){return this.rotateOnAxis(bm,n)},rotateZ:function(n){return this.rotateOnAxis(_m,n)},translateOnAxis:function(n,t){return xm.copy(n).applyQuaternion(this.quaternion),this.position.add(xm.multiplyScalar(t)),this},translateX:function(n){return this.translateOnAxis(vm,n)},translateY:function(n){return this.translateOnAxis(bm,n)},translateZ:function(n){return this.translateOnAxis(_m,n)},localToWorld:function(n){return n.applyMatrix4(this.matrixWorld)},worldToLocal:function(n){return n.applyMatrix4(Wn.getInverse(this.matrixWorld))},lookAt:function(n,t,e){n.isVector3?oc.copy(n):oc.set(n,t,e);let i=this.parent;this.updateWorldMatrix(!0,!1),uo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wn.lookAt(uo,oc,this.up):Wn.lookAt(oc,uo,this.up),this.quaternion.setFromRotationMatrix(Wn),i&&(Wn.extractRotation(i.matrixWorld),Zr.setFromRotationMatrix(Wn),this.quaternion.premultiply(Zr.inverse()))},add:function(n){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return n===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",n),this):(n&&n.isObject3D?(n.parent!==null&&n.parent.remove(n),n.parent=this,this.children.push(n),n.dispatchEvent(p_)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",n),this)},remove:function(n){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(n);return t!==-1&&(n.parent=null,this.children.splice(t,1),n.dispatchEvent(m_)),this},attach:function(n){return this.updateWorldMatrix(!0,!1),Wn.getInverse(this.matrixWorld),n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),Wn.multiply(n.parent.matrixWorld)),n.applyMatrix4(Wn),n.updateWorldMatrix(!1,!1),this.add(n),this},getObjectById:function(n){return this.getObjectByProperty("id",n)},getObjectByName:function(n){return this.getObjectByProperty("name",n)},getObjectByProperty:function(n,t){if(this[n]===t)return this;for(let e=0,i=this.children.length;e<i;e++){let s=this.children[e].getObjectByProperty(n,t);if(s!==void 0)return s}},getWorldPosition:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),n=new M),this.updateMatrixWorld(!0),n.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),n=new ie),this.updateMatrixWorld(!0),this.matrixWorld.decompose(uo,n,f_),n},getWorldScale:function(n){return n===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),n=new M),this.updateMatrixWorld(!0),this.matrixWorld.decompose(uo,d_,n),n},getWorldDirection:function(n){n===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),n=new M),this.updateMatrixWorld(!0);let t=this.matrixWorld.elements;return n.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(n){n(this);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].traverse(n)},traverseVisible:function(n){if(this.visible===!1)return;n(this);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].traverseVisible(n)},traverseAncestors:function(n){let t=this.parent;t!==null&&(n(t),t.traverseAncestors(n))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,n=!0);let t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].updateMatrixWorld(n)},updateWorldMatrix:function(n,t){let e=this.parent;if(n===!0&&e!==null&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].updateWorldMatrix(!1,!0)}},toJSON:function(n){let t=n===void 0||typeof n=="string",e={};t&&(n={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON());function r(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(n)),a.uuid}if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(n.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(n.shapes,u)}else r(n.shapes,a)}}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(n.materials,this.material[a]));i.material=o}else i.material=r(n.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(n).object)}if(t){let o=s(n.geometries),a=s(n.materials),c=s(n.textures),l=s(n.images),u=s(n.shapes);o.length>0&&(e.geometries=o),a.length>0&&(e.materials=a),c.length>0&&(e.textures=c),l.length>0&&(e.images=l),u.length>0&&(e.shapes=u)}return e.object=i,e;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}},clone:function(n){return new this.constructor().copy(this,n)},copy:function(n,t){if(t===void 0&&(t=!0),this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.userData=JSON.parse(JSON.stringify(n.userData)),t===!0)for(let e=0;e<n.children.length;e++){let i=n.children[e];this.add(i.clone())}return this}});var ku=new M,g_=new M,y_=new pe,Ge=class{constructor(t,e){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=t!==void 0?t:new M(1,0,0),this.constant=e!==void 0?e:0}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){let r=ku.subVectors(i,e).cross(g_.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}clone(){return new this.constructor().copy(this)}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let 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===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new M),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){e===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new M);let i=t.delta(ku),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):void 0;let s=-(t.start.dot(this.normal)+this.constant)/r;if(!(s<0||s>1))return e.copy(i).multiplyScalar(s).add(t.start)}intersectsLine(t){let e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new M),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let i=e||y_.getNormalMatrix(t),r=this.coplanarPoint(ku).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},nn=new M,jn=new M,Gu=new M,Xn=new M,Jr=new M,$r=new M,wm=new M,Hu=new M,Vu=new M,Wu=new M,Ve=class n{constructor(t,e,i){this.a=t!==void 0?t:new M,this.b=e!==void 0?e:new M,this.c=i!==void 0?i:new M}static getNormal(t,e,i,r){r===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new M),r.subVectors(i,e),nn.subVectors(t,e),r.cross(nn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,i,r,s){nn.subVectors(r,e),jn.subVectors(i,e),Gu.subVectors(t,e);let o=nn.dot(nn),a=nn.dot(jn),c=nn.dot(Gu),l=jn.dot(jn),u=jn.dot(Gu),h=o*l-a*a;if(s===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),s=new M),h===0)return s.set(-2,-1,-1);let d=1/h,f=(l*c-a*u)*d,p=(o*u-a*c)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,i,r){return this.getBarycoord(t,e,i,r,Xn),Xn.x>=0&&Xn.y>=0&&Xn.x+Xn.y<=1}static getUV(t,e,i,r,s,o,a,c){return this.getBarycoord(t,e,i,r,Xn),c.set(0,0),c.addScaledVector(s,Xn.x),c.addScaledVector(o,Xn.y),c.addScaledVector(a,Xn.z),c}static isFrontFacing(t,e,i,r){return nn.subVectors(i,e),jn.subVectors(t,e),nn.cross(jn).dot(r)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,r){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[r]),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return nn.subVectors(this.c,this.b),jn.subVectors(this.a,this.b),nn.cross(jn).length()*.5}getMidpoint(t){return t===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new M),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return n.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ge),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return n.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,r,s){return n.getUV(t,this.a,this.b,this.c,e,i,r,s)}containsPoint(t){return n.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return n.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){e===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new M);let i=this.a,r=this.b,s=this.c,o,a;Jr.subVectors(r,i),$r.subVectors(s,i),Hu.subVectors(t,i);let c=Jr.dot(Hu),l=$r.dot(Hu);if(c<=0&&l<=0)return e.copy(i);Vu.subVectors(t,r);let u=Jr.dot(Vu),h=$r.dot(Vu);if(u>=0&&h<=u)return e.copy(r);let d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(i).addScaledVector(Jr,o);Wu.subVectors(t,s);let f=Jr.dot(Wu),p=$r.dot(Wu);if(p>=0&&f<=p)return e.copy(s);let y=f*l-c*p;if(y<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector($r,a);let x=u*p-f*h;if(x<=0&&h-u>=0&&f-p>=0)return wm.subVectors(s,r),a=(h-u)/(h-u+(f-p)),e.copy(r).addScaledVector(wm,a);let g=1/(x+y+d);return o=y*g,a=d*g,e.copy(i).addScaledVector(Jr,o).addScaledVector($r,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Zy={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},rn={h:0,s:0,l:0},ac={h:0,s:0,l:0};function ju(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}function Xu(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function qu(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var lt=class{constructor(t,e,i){return Object.defineProperty(this,"isColor",{value:!0}),e===void 0&&i===void 0?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,this}setRGB(t,e,i){return this.r=t,this.g=e,this.b=i,this}setHSL(t,e,i){if(t=_t.euclideanModulo(t,1),e=_t.clamp(e,0,1),i=_t.clamp(i,0,1),e===0)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+e):i+e-i*e,s=2*i-r;this.r=ju(s,r,t+1/3),this.g=ju(s,r,t),this.b=ju(s,r,t-1/3)}return this}setStyle(t){function e(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){let a=parseFloat(r[1])/360,c=parseInt(r[2],10)/100,l=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(a,c,l)}break}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){let r=i[1],s=r.length;if(s===3)return this.r=parseInt(r.charAt(0)+r.charAt(0),16)/255,this.g=parseInt(r.charAt(1)+r.charAt(1),16)/255,this.b=parseInt(r.charAt(2)+r.charAt(2),16)/255,this;if(s===6)return this.r=parseInt(r.charAt(0)+r.charAt(1),16)/255,this.g=parseInt(r.charAt(2)+r.charAt(3),16)/255,this.b=parseInt(r.charAt(4)+r.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){let e=Zy[t];return e!==void 0?this.setHex(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}copyGammaToLinear(t,e){return e===void 0&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e){e===void 0&&(e=2);let i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Xu(t.r),this.g=Xu(t.g),this.b=Xu(t.b),this}copyLinearToSRGB(t){return this.r=qu(t.r),this.g=qu(t.g),this.b=qu(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){t===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});let e=this.r,i=this.g,r=this.b,s=Math.max(e,i,r),o=Math.min(e,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=.5?u/(s+o):u/(2-s-o),s){case e:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-e)/u+2;break;case r:a=(e-i)/u+4;break}a/=6}return t.h=a,t.s=c,t.l=l,t}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(t,e,i){return this.getHSL(rn),rn.h+=t,rn.s+=e,rn.l+=i,this.setHSL(rn.h,rn.s,rn.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpHSL(t,e){this.getHSL(rn),t.getHSL(ac);let i=_t.lerp(rn.h,ac.h,e),r=_t.lerp(rn.s,ac.s,e),s=_t.lerp(rn.l,ac.l,e);return this.setHSL(i,r,s),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e){return e===void 0&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),t.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}};lt.NAMES=Zy;lt.prototype.r=1;lt.prototype.g=1;lt.prototype.b=1;var hr=class{constructor(t,e,i,r,s,o){this.a=t,this.b=e,this.c=i,this.normal=r&&r.isVector3?r:new M,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new lt,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o!==void 0?o:0}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}},x_=0;function bt(){Object.defineProperty(this,"id",{value:x_++}),this.uuid=_t.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=ds,this.side=Os,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=dd,this.blendDst=pd,this.blendEquation=rr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Hc,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Yy,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gc,this.stencilZFail=Gc,this.stencilZPass=Gc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}bt.prototype=Object.assign(Object.create(Je.prototype),{constructor:bt,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(n){if(n!==void 0)for(let t in n){let e=n[t];if(e===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===fd;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(e):i&&i.isVector3&&e&&e.isVector3?i.copy(e):this[t]=e}},toJSON:function(n){let t=n===void 0||typeof n=="string";t&&(n={textures:{},images:{}});let e={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.color&&this.color.isColor&&(e.color=this.color.getHex()),this.roughness!==void 0&&(e.roughness=this.roughness),this.metalness!==void 0&&(e.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(e.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(e.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(e.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(e.specular=this.specular.getHex()),this.shininess!==void 0&&(e.shininess=this.shininess),this.clearcoat!==void 0&&(e.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(e.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(e.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(e.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(e.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,e.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(e.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(e.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(e.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(e.lightMap=this.lightMap.toJSON(n).uuid),this.aoMap&&this.aoMap.isTexture&&(e.aoMap=this.aoMap.toJSON(n).uuid,e.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(e.bumpMap=this.bumpMap.toJSON(n).uuid,e.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(e.normalMap=this.normalMap.toJSON(n).uuid,e.normalMapType=this.normalMapType,e.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(e.displacementMap=this.displacementMap.toJSON(n).uuid,e.displacementScale=this.displacementScale,e.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(e.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(e.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(e.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(e.specularMap=this.specularMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(e.envMap=this.envMap.toJSON(n).uuid,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,this.combine!==void 0&&(e.combine=this.combine),this.envMapIntensity!==void 0&&(e.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(e.gradientMap=this.gradientMap.toJSON(n).uuid),this.size!==void 0&&(e.size=this.size),this.sizeAttenuation!==void 0&&(e.sizeAttenuation=this.sizeAttenuation),this.blending!==ds&&(e.blending=this.blending),this.flatShading===!0&&(e.flatShading=this.flatShading),this.side!==Os&&(e.side=this.side),this.vertexColors&&(e.vertexColors=!0),this.opacity<1&&(e.opacity=this.opacity),this.transparent===!0&&(e.transparent=this.transparent),e.depthFunc=this.depthFunc,e.depthTest=this.depthTest,e.depthWrite=this.depthWrite,e.stencilWrite=this.stencilWrite,e.stencilWriteMask=this.stencilWriteMask,e.stencilFunc=this.stencilFunc,e.stencilRef=this.stencilRef,e.stencilFuncMask=this.stencilFuncMask,e.stencilFail=this.stencilFail,e.stencilZFail=this.stencilZFail,e.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(e.rotation=this.rotation),this.polygonOffset===!0&&(e.polygonOffset=!0),this.polygonOffsetFactor!==0&&(e.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(e.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(e.linewidth=this.linewidth),this.dashSize!==void 0&&(e.dashSize=this.dashSize),this.gapSize!==void 0&&(e.gapSize=this.gapSize),this.scale!==void 0&&(e.scale=this.scale),this.dithering===!0&&(e.dithering=!0),this.alphaTest>0&&(e.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(e.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(e.wireframe=this.wireframe),this.wireframeLinewidth>1&&(e.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(e.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(e.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(e.morphTargets=!0),this.morphNormals===!0&&(e.morphNormals=!0),this.skinning===!0&&(e.skinning=!0),this.visible===!1&&(e.visible=!1),this.toneMapped===!1&&(e.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(e.userData=this.userData);function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(n.textures),s=i(n.images);r.length>0&&(e.textures=r),s.length>0&&(e.images=s)}return e},clone:function(){return new this.constructor().copy(this)},copy:function(n){this.name=n.name,this.fog=n.fog,this.blending=n.blending,this.side=n.side,this.flatShading=n.flatShading,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;let t=n.clippingPlanes,e=null;if(t!==null){let i=t.length;e=new Array(i);for(let r=0;r!==i;++r)e[r]=t[r].clone()}return this.clippingPlanes=e,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.premultipliedAlpha=n.premultipliedAlpha,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(bt.prototype,"needsUpdate",{set:function(n){n===!0&&this.version++}});function Xe(n){bt.call(this),this.type="MeshBasicMaterial",this.color=new lt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=va,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(n)}Xe.prototype=Object.create(bt.prototype);Xe.prototype.constructor=Xe;Xe.prototype.isMeshBasicMaterial=!0;Xe.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this};var jt=new M,cc=new G;function xt(n,t,e){if(Array.isArray(n))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=n,this.itemSize=t,this.count=n!==void 0?n.length/t:0,this.normalized=e===!0,this.usage=Sa,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(xt.prototype,"needsUpdate",{set:function(n){n===!0&&this.version++}});Object.assign(xt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(n){return this.usage=n,this},copy:function(n){return this.name=n.name,this.array=new n.array.constructor(n.array),this.itemSize=n.itemSize,this.count=n.count,this.normalized=n.normalized,this.usage=n.usage,this},copyAt:function(n,t,e){n*=this.itemSize,e*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[n+i]=t.array[e+i];return this},copyArray:function(n){return this.array.set(n),this},copyColorsArray:function(n){let t=this.array,e=0;for(let i=0,r=n.length;i<r;i++){let s=n[i];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),s=new lt),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this},copyVector2sArray:function(n){let t=this.array,e=0;for(let i=0,r=n.length;i<r;i++){let s=n[i];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),s=new G),t[e++]=s.x,t[e++]=s.y}return this},copyVector3sArray:function(n){let t=this.array,e=0;for(let i=0,r=n.length;i<r;i++){let s=n[i];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),s=new M),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this},copyVector4sArray:function(n){let t=this.array,e=0;for(let i=0,r=n.length;i<r;i++){let s=n[i];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),s=new Bt),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this},applyMatrix3:function(n){if(this.itemSize===2)for(let t=0,e=this.count;t<e;t++)cc.fromBufferAttribute(this,t),cc.applyMatrix3(n),this.setXY(t,cc.x,cc.y);else if(this.itemSize===3)for(let t=0,e=this.count;t<e;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix3(n),this.setXYZ(t,jt.x,jt.y,jt.z);return this},applyMatrix4:function(n){for(let t=0,e=this.count;t<e;t++)jt.x=this.getX(t),jt.y=this.getY(t),jt.z=this.getZ(t),jt.applyMatrix4(n),this.setXYZ(t,jt.x,jt.y,jt.z);return this},applyNormalMatrix:function(n){for(let t=0,e=this.count;t<e;t++)jt.x=this.getX(t),jt.y=this.getY(t),jt.z=this.getZ(t),jt.applyNormalMatrix(n),this.setXYZ(t,jt.x,jt.y,jt.z);return this},transformDirection:function(n){for(let t=0,e=this.count;t<e;t++)jt.x=this.getX(t),jt.y=this.getY(t),jt.z=this.getZ(t),jt.transformDirection(n),this.setXYZ(t,jt.x,jt.y,jt.z);return this},set:function(n,t){return t===void 0&&(t=0),this.array.set(n,t),this},getX:function(n){return this.array[n*this.itemSize]},setX:function(n,t){return this.array[n*this.itemSize]=t,this},getY:function(n){return this.array[n*this.itemSize+1]},setY:function(n,t){return this.array[n*this.itemSize+1]=t,this},getZ:function(n){return this.array[n*this.itemSize+2]},setZ:function(n,t){return this.array[n*this.itemSize+2]=t,this},getW:function(n){return this.array[n*this.itemSize+3]},setW:function(n,t){return this.array[n*this.itemSize+3]=t,this},setXY:function(n,t,e){return n*=this.itemSize,this.array[n+0]=t,this.array[n+1]=e,this},setXYZ:function(n,t,e,i){return n*=this.itemSize,this.array[n+0]=t,this.array[n+1]=e,this.array[n+2]=i,this},setXYZW:function(n,t,e,i,r){return n*=this.itemSize,this.array[n+0]=t,this.array[n+1]=e,this.array[n+2]=i,this.array[n+3]=r,this},onUpload:function(n){return this.onUploadCallback=n,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function Oo(n,t,e){xt.call(this,new Int8Array(n),t,e)}Oo.prototype=Object.create(xt.prototype);Oo.prototype.constructor=Oo;function Fo(n,t,e){xt.call(this,new Uint8Array(n),t,e)}Fo.prototype=Object.create(xt.prototype);Fo.prototype.constructor=Fo;function zo(n,t,e){xt.call(this,new Uint8ClampedArray(n),t,e)}zo.prototype=Object.create(xt.prototype);zo.prototype.constructor=zo;function No(n,t,e){xt.call(this,new Int16Array(n),t,e)}No.prototype=Object.create(xt.prototype);No.prototype.constructor=No;function ur(n,t,e){xt.call(this,new Uint16Array(n),t,e)}ur.prototype=Object.create(xt.prototype);ur.prototype.constructor=ur;function Bo(n,t,e){xt.call(this,new Int32Array(n),t,e)}Bo.prototype=Object.create(xt.prototype);Bo.prototype.constructor=Bo;function fr(n,t,e){xt.call(this,new Uint32Array(n),t,e)}fr.prototype=Object.create(xt.prototype);fr.prototype.constructor=fr;function st(n,t,e){xt.call(this,new Float32Array(n),t,e)}st.prototype=Object.create(xt.prototype);st.prototype.constructor=st;function Uo(n,t,e){xt.call(this,new Float64Array(n),t,e)}Uo.prototype=Object.create(xt.prototype);Uo.prototype.constructor=Uo;var Lf=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],i,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,e.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,e.push(i)),this.groups=e}fromGeometry(t){let e=t.faces,i=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,c=a.length,l;if(c>0){l=[];for(let g=0;g<c;g++)l[g]={name:a[g].name,data:[]};this.morphTargets.position=l}let u=t.morphNormals,h=u.length,d;if(h>0){d=[];for(let g=0;g<h;g++)d[g]={name:u[g].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,y=f.length===i.length,x=p.length===i.length;i.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let m=e[g];this.vertices.push(i[m.a],i[m.b],i[m.c]);let b=m.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let w=m.normal;this.normals.push(w,w,w)}let v=m.vertexColors;if(v.length===3)this.colors.push(v[0],v[1],v[2]);else{let w=m.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][g];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new G,new G,new G))}if(o===!0){let w=r[1][g];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new G,new G,new G))}for(let w=0;w<c;w++){let _=a[w].vertices;l[w].data.push(_[m.a],_[m.b],_[m.c])}for(let w=0;w<h;w++){let _=u[w].vertexNormals[g];d[w].data.push(_.a,_.b,_.c)}y&&this.skinIndices.push(f[m.a],f[m.b],f[m.c]),x&&this.skinWeights.push(p[m.a],p[m.b],p[m.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}};function Jy(n){if(n.length===0)return-1/0;let t=n[0];for(let e=1,i=n.length;e<i;++e)n[e]>t&&(t=n[e]);return t}var v_=1,bn=new At,Yu=new dt,Qr=new M,De=new je,fo=new je,le=new M;function yt(){Object.defineProperty(this,"id",{value:v_+=2}),this.uuid=_t.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}yt.prototype=Object.assign(Object.create(Je.prototype),{constructor:yt,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(n){Array.isArray(n)?this.index=new(Jy(n)>65535?fr:ur)(n,1):this.index=n},getAttribute:function(n){return this.attributes[n]},setAttribute:function(n,t){return this.attributes[n]=t,this},deleteAttribute:function(n){return delete this.attributes[n],this},addGroup:function(n,t,e){this.groups.push({start:n,count:t,materialIndex:e!==void 0?e:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(n,t){this.drawRange.start=n,this.drawRange.count=t},applyMatrix4:function(n){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(n),t.needsUpdate=!0);let e=this.attributes.normal;if(e!==void 0){let r=new pe().getNormalMatrix(n);e.applyNormalMatrix(r),e.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(n),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(n){return bn.makeRotationX(n),this.applyMatrix4(bn),this},rotateY:function(n){return bn.makeRotationY(n),this.applyMatrix4(bn),this},rotateZ:function(n){return bn.makeRotationZ(n),this.applyMatrix4(bn),this},translate:function(n,t,e){return bn.makeTranslation(n,t,e),this.applyMatrix4(bn),this},scale:function(n,t,e){return bn.makeScale(n,t,e),this.applyMatrix4(bn),this},lookAt:function(n){return Yu.lookAt(n),Yu.updateMatrix(),this.applyMatrix4(Yu.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qr).negate(),this.translate(Qr.x,Qr.y,Qr.z),this},setFromObject:function(n){let t=n.geometry;if(n.isPoints||n.isLine){let e=new st(t.vertices.length*3,3),i=new st(t.colors.length*3,3);if(this.setAttribute("position",e.copyVector3sArray(t.vertices)),this.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let r=new st(t.lineDistances.length,1);this.setAttribute("lineDistance",r.copyArray(t.lineDistances))}t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone())}else n.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(n){let t=[];for(let e=0,i=n.length;e<i;e++){let r=n[e];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new st(t,3)),this},updateFromObject:function(n){let t=n.geometry;if(n.isMesh){let e=t.__directGeometry;if(t.elementsNeedUpdate===!0&&(e=void 0,t.elementsNeedUpdate=!1),e===void 0)return this.fromGeometry(t);e.verticesNeedUpdate=t.verticesNeedUpdate,e.normalsNeedUpdate=t.normalsNeedUpdate,e.colorsNeedUpdate=t.colorsNeedUpdate,e.uvsNeedUpdate=t.uvsNeedUpdate,e.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=e}if(t.verticesNeedUpdate===!0){let e=this.attributes.position;e!==void 0&&(e.copyVector3sArray(t.vertices),e.needsUpdate=!0),t.verticesNeedUpdate=!1}if(t.normalsNeedUpdate===!0){let e=this.attributes.normal;e!==void 0&&(e.copyVector3sArray(t.normals),e.needsUpdate=!0),t.normalsNeedUpdate=!1}if(t.colorsNeedUpdate===!0){let e=this.attributes.color;e!==void 0&&(e.copyColorsArray(t.colors),e.needsUpdate=!0),t.colorsNeedUpdate=!1}if(t.uvsNeedUpdate){let e=this.attributes.uv;e!==void 0&&(e.copyVector2sArray(t.uvs),e.needsUpdate=!0),t.uvsNeedUpdate=!1}if(t.lineDistancesNeedUpdate){let e=this.attributes.lineDistance;e!==void 0&&(e.copyArray(t.lineDistances),e.needsUpdate=!0),t.lineDistancesNeedUpdate=!1}return t.groupsNeedUpdate&&(t.computeGroups(n.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(n){return n.__directGeometry=new Lf().fromGeometry(n),this.fromDirectGeometry(n.__directGeometry)},fromDirectGeometry:function(n){let t=new Float32Array(n.vertices.length*3);if(this.setAttribute("position",new xt(t,3).copyVector3sArray(n.vertices)),n.normals.length>0){let e=new Float32Array(n.normals.length*3);this.setAttribute("normal",new xt(e,3).copyVector3sArray(n.normals))}if(n.colors.length>0){let e=new Float32Array(n.colors.length*3);this.setAttribute("color",new xt(e,3).copyColorsArray(n.colors))}if(n.uvs.length>0){let e=new Float32Array(n.uvs.length*2);this.setAttribute("uv",new xt(e,2).copyVector2sArray(n.uvs))}if(n.uvs2.length>0){let e=new Float32Array(n.uvs2.length*2);this.setAttribute("uv2",new xt(e,2).copyVector2sArray(n.uvs2))}this.groups=n.groups;for(let e in n.morphTargets){let i=[],r=n.morphTargets[e];for(let s=0,o=r.length;s<o;s++){let a=r[s],c=new st(a.data.length*3,3);c.name=a.name,i.push(c.copyVector3sArray(a.data))}this.morphAttributes[e]=i}if(n.skinIndices.length>0){let e=new st(n.skinIndices.length*4,4);this.setAttribute("skinIndex",e.copyVector4sArray(n.skinIndices))}if(n.skinWeights.length>0){let e=new st(n.skinWeights.length*4,4);this.setAttribute("skinWeight",e.copyVector4sArray(n.skinWeights))}return n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new je);let n=this.attributes.position,t=this.morphAttributes.position;if(n&&n.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(n!==void 0){if(this.boundingBox.setFromBufferAttribute(n),t)for(let e=0,i=t.length;e<i;e++){let r=t[e];De.setFromBufferAttribute(r),this.morphTargetsRelative?(le.addVectors(this.boundingBox.min,De.min),this.boundingBox.expandByPoint(le),le.addVectors(this.boundingBox.max,De.max),this.boundingBox.expandByPoint(le)):(this.boundingBox.expandByPoint(De.min),this.boundingBox.expandByPoint(De.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new cn);let n=this.attributes.position,t=this.morphAttributes.position;if(n&&n.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new M,1/0);return}if(n){let e=this.boundingSphere.center;if(De.setFromBufferAttribute(n),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];fo.setFromBufferAttribute(o),this.morphTargetsRelative?(le.addVectors(De.min,fo.min),De.expandByPoint(le),le.addVectors(De.max,fo.max),De.expandByPoint(le)):(De.expandByPoint(fo.min),De.expandByPoint(fo.max))}De.getCenter(e);let i=0;for(let r=0,s=n.count;r<s;r++)le.fromBufferAttribute(n,r),i=Math.max(i,e.distanceToSquared(le));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++)le.fromBufferAttribute(o,c),a&&(Qr.fromBufferAttribute(n,c),le.add(Qr)),i=Math.max(i,e.distanceToSquared(le))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){let n=this.index,t=this.getAttribute("position");if(t!==void 0){let e=this.getAttribute("normal");if(e===void 0)e=new xt(new Float32Array(t.count*3),3),this.setAttribute("normal",e);else for(let h=0,d=e.count;h<d;h++)e.setXYZ(h,0,0,0);let i=new M,r=new M,s=new M,o=new M,a=new M,c=new M,l=new M,u=new M;if(n)for(let h=0,d=n.count;h<d;h+=3){let f=n.getX(h+0),p=n.getX(h+1),y=n.getX(h+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(e,f),a.fromBufferAttribute(e,p),c.fromBufferAttribute(e,y),o.add(l),a.add(l),c.add(l),e.setXYZ(f,o.x,o.y,o.z),e.setXYZ(p,a.x,a.y,a.z),e.setXYZ(y,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),e.setXYZ(h+0,l.x,l.y,l.z),e.setXYZ(h+1,l.x,l.y,l.z),e.setXYZ(h+2,l.x,l.y,l.z);this.normalizeNormals(),e.needsUpdate=!0}},merge:function(n,t){if(!(n&&n.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",n);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let e=this.attributes;for(let i in e){if(n.attributes[i]===void 0)continue;let s=e[i].array,o=n.attributes[i],a=o.array,c=o.itemSize*t,l=Math.min(a.length,s.length-c);for(let u=0,h=c;u<l;u++,h++)s[h]=a[u]}return this},normalizeNormals:function(){let n=this.attributes.normal;for(let t=0,e=n.count;t<e;t++)le.fromBufferAttribute(n,t),le.normalize(),n.setXYZ(t,le.x,le.y,le.z)},toNonIndexed:function(){function n(o,a){let c=o.array,l=o.itemSize,u=o.normalized,h=new c.constructor(a.length*l),d=0,f=0;for(let p=0,y=a.length;p<y;p++){d=a[p]*l;for(let x=0;x<l;x++)h[f++]=c[d++]}return new xt(h,l,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;let t=new yt,e=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=n(a,e);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let h=c[l],d=n(h,e);a.push(d)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t},toJSON:function(){let n={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),Object.keys(this.userData).length>0&&(n.userData=this.userData),this.parameters!==void 0){let a=this.parameters;for(let c in a)a[c]!==void 0&&(n[c]=a[c]);return n}n.data={attributes:{}};let t=this.index;t!==null&&(n.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let e=this.attributes;for(let a in e){let c=e[a],l=c.toJSON(n.data);c.name!==""&&(l.name=c.name),n.data.attributes[a]=l}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u],f=d.toJSON(n.data);d.name!==""&&(f.name=d.name),l.push(f)}l.length>0&&(i[a]=l,r=!0)}r&&(n.data.morphAttributes=i,n.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(n.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(n.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),n},clone:function(){return new yt().copy(this)},copy:function(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=n.name;let e=n.index;e!==null&&this.setIndex(e.clone(t));let i=n.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=n.morphAttributes;for(let c in r){let l=[],u=r[c];for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=n.morphTargetsRelative;let s=n.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=n.boundingBox;o!==null&&(this.boundingBox=o.clone());let a=n.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=n.drawRange.start,this.drawRange.count=n.drawRange.count,this.userData=n.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Mm=new At,$i=new Ci,Zu=new cn,xi=new M,vi=new M,bi=new M,Ju=new M,$u=new M,Qu=new M,lc=new M,hc=new M,uc=new M,ls=new G,hs=new G,us=new G,Mo=new M,fc=new M;function Yt(n,t){dt.call(this),this.type="Mesh",this.geometry=n!==void 0?n:new yt,this.material=t!==void 0?t:new Xe,this.updateMorphTargets()}Yt.prototype=Object.assign(Object.create(dt.prototype),{constructor:Yt,isMesh:!0,copy:function(n){return dt.prototype.copy.call(this,n),n.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=n.morphTargetInfluences.slice()),n.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},n.morphTargetDictionary)),this.material=n.material,this.geometry=n.geometry,this},updateMorphTargets:function(){let n=this.geometry;if(n.isBufferGeometry){let t=n.morphAttributes,e=Object.keys(t);if(e.length>0){let i=t[e[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}else{let t=n.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(n,t){let e=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0||(e.boundingSphere===null&&e.computeBoundingSphere(),Zu.copy(e.boundingSphere),Zu.applyMatrix4(r),n.ray.intersectsSphere(Zu)===!1)||(Mm.getInverse(r),$i.copy(n.ray).applyMatrix4(Mm),e.boundingBox!==null&&$i.intersectsBox(e.boundingBox)===!1))return;let s;if(e.isBufferGeometry){let o=e.index,a=e.attributes.position,c=e.morphAttributes.position,l=e.morphTargetsRelative,u=e.attributes.uv,h=e.attributes.uv2,d=e.groups,f=e.drawRange;if(o!==null)if(Array.isArray(i))for(let p=0,y=d.length;p<y;p++){let x=d[p],g=i[x.materialIndex],m=Math.max(x.start,f.start),b=Math.min(x.start+x.count,f.start+f.count);for(let v=m,w=b;v<w;v+=3){let _=o.getX(v),A=o.getX(v+1),I=o.getX(v+2);s=dc(this,g,n,$i,a,c,l,u,h,_,A,I),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=x.materialIndex,t.push(s))}}else{let p=Math.max(0,f.start),y=Math.min(o.count,f.start+f.count);for(let x=p,g=y;x<g;x+=3){let m=o.getX(x),b=o.getX(x+1),v=o.getX(x+2);s=dc(this,i,n,$i,a,c,l,u,h,m,b,v),s&&(s.faceIndex=Math.floor(x/3),t.push(s))}}else if(a!==void 0)if(Array.isArray(i))for(let p=0,y=d.length;p<y;p++){let x=d[p],g=i[x.materialIndex],m=Math.max(x.start,f.start),b=Math.min(x.start+x.count,f.start+f.count);for(let v=m,w=b;v<w;v+=3){let _=v,A=v+1,I=v+2;s=dc(this,g,n,$i,a,c,l,u,h,_,A,I),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=x.materialIndex,t.push(s))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let x=p,g=y;x<g;x+=3){let m=x,b=x+1,v=x+2;s=dc(this,i,n,$i,a,c,l,u,h,m,b,v),s&&(s.faceIndex=Math.floor(x/3),t.push(s))}}}else if(e.isGeometry){let o=Array.isArray(i),a=e.vertices,c=e.faces,l,u=e.faceVertexUvs[0];u.length>0&&(l=u);for(let h=0,d=c.length;h<d;h++){let f=c[h],p=o?i[f.materialIndex]:i;if(p===void 0)continue;let y=a[f.a],x=a[f.b],g=a[f.c];if(s=$y(this,p,n,$i,y,x,g,Mo),s){if(l&&l[h]){let m=l[h];ls.copy(m[0]),hs.copy(m[1]),us.copy(m[2]),s.uv=Ve.getUV(Mo,y,x,g,ls,hs,us,new G)}s.face=f,s.faceIndex=h,t.push(s)}}}}});function $y(n,t,e,i,r,s,o,a){let c;if(t.side===oe?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,t.side!==xa,a),c===null)return null;fc.copy(a),fc.applyMatrix4(n.matrixWorld);let l=e.ray.origin.distanceTo(fc);return l<e.near||l>e.far?null:{distance:l,point:fc.clone(),object:n}}function dc(n,t,e,i,r,s,o,a,c,l,u,h){xi.fromBufferAttribute(r,l),vi.fromBufferAttribute(r,u),bi.fromBufferAttribute(r,h);let d=n.morphTargetInfluences;if(t.morphTargets&&s&&d){lc.set(0,0,0),hc.set(0,0,0),uc.set(0,0,0);for(let p=0,y=s.length;p<y;p++){let x=d[p],g=s[p];x!==0&&(Ju.fromBufferAttribute(g,l),$u.fromBufferAttribute(g,u),Qu.fromBufferAttribute(g,h),o?(lc.addScaledVector(Ju,x),hc.addScaledVector($u,x),uc.addScaledVector(Qu,x)):(lc.addScaledVector(Ju.sub(xi),x),hc.addScaledVector($u.sub(vi),x),uc.addScaledVector(Qu.sub(bi),x)))}xi.add(lc),vi.add(hc),bi.add(uc)}n.isSkinnedMesh&&(n.boneTransform(l,xi),n.boneTransform(u,vi),n.boneTransform(h,bi));let f=$y(n,t,e,i,xi,vi,bi,Mo);if(f){a&&(ls.fromBufferAttribute(a,l),hs.fromBufferAttribute(a,u),us.fromBufferAttribute(a,h),f.uv=Ve.getUV(Mo,xi,vi,bi,ls,hs,us,new G)),c&&(ls.fromBufferAttribute(c,l),hs.fromBufferAttribute(c,u),us.fromBufferAttribute(c,h),f.uv2=Ve.getUV(Mo,xi,vi,bi,ls,hs,us,new G));let p=new hr(l,u,h);Ve.getNormal(xi,vi,bi,p.normal),f.face=p}return f}var b_=0,_n=new At,Ku=new dt,pc=new M;function Ut(){Object.defineProperty(this,"id",{value:b_+=2}),this.uuid=_t.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Ut.prototype=Object.assign(Object.create(Je.prototype),{constructor:Ut,isGeometry:!0,applyMatrix4:function(n){let t=new pe().getNormalMatrix(n);for(let e=0,i=this.vertices.length;e<i;e++)this.vertices[e].applyMatrix4(n);for(let e=0,i=this.faces.length;e<i;e++){let r=this.faces[e];r.normal.applyMatrix3(t).normalize();for(let s=0,o=r.vertexNormals.length;s<o;s++)r.vertexNormals[s].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(n){return _n.makeRotationX(n),this.applyMatrix4(_n),this},rotateY:function(n){return _n.makeRotationY(n),this.applyMatrix4(_n),this},rotateZ:function(n){return _n.makeRotationZ(n),this.applyMatrix4(_n),this},translate:function(n,t,e){return _n.makeTranslation(n,t,e),this.applyMatrix4(_n),this},scale:function(n,t,e){return _n.makeScale(n,t,e),this.applyMatrix4(_n),this},lookAt:function(n){return Ku.lookAt(n),Ku.updateMatrix(),this.applyMatrix4(Ku.matrix),this},fromBufferGeometry:function(n){let t=this,e=n.index!==null?n.index:void 0,i=n.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let r=i.position,s=i.normal,o=i.color,a=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<r.count;h++)t.vertices.push(new M().fromBufferAttribute(r,h)),o!==void 0&&t.colors.push(new lt().fromBufferAttribute(o,h));function l(h,d,f,p){let y=o===void 0?[]:[t.colors[h].clone(),t.colors[d].clone(),t.colors[f].clone()],x=s===void 0?[]:[new M().fromBufferAttribute(s,h),new M().fromBufferAttribute(s,d),new M().fromBufferAttribute(s,f)],g=new hr(h,d,f,x,y,p);t.faces.push(g),a!==void 0&&t.faceVertexUvs[0].push([new G().fromBufferAttribute(a,h),new G().fromBufferAttribute(a,d),new G().fromBufferAttribute(a,f)]),c!==void 0&&t.faceVertexUvs[1].push([new G().fromBufferAttribute(c,h),new G().fromBufferAttribute(c,d),new G().fromBufferAttribute(c,f)])}let u=n.groups;if(u.length>0)for(let h=0;h<u.length;h++){let d=u[h],f=d.start,p=d.count;for(let y=f,x=f+p;y<x;y+=3)e!==void 0?l(e.getX(y),e.getX(y+1),e.getX(y+2),d.materialIndex):l(y,y+1,y+2,d.materialIndex)}else if(e!==void 0)for(let h=0;h<e.count;h+=3)l(e.getX(h),e.getX(h+1),e.getX(h+2));else for(let h=0;h<r.count;h+=3)l(h,h+1,h+2);return this.computeFaceNormals(),n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(pc).negate(),this.translate(pc.x,pc.y,pc.z),this},normalize:function(){this.computeBoundingSphere();let n=this.boundingSphere.center,t=this.boundingSphere.radius,e=t===0?1:1/t,i=new At;return i.set(e,0,0,-e*n.x,0,e,0,-e*n.y,0,0,e,-e*n.z,0,0,0,1),this.applyMatrix4(i),this},computeFaceNormals:function(){let n=new M,t=new M;for(let e=0,i=this.faces.length;e<i;e++){let r=this.faces[e],s=this.vertices[r.a],o=this.vertices[r.b],a=this.vertices[r.c];n.subVectors(a,o),t.subVectors(s,o),n.cross(t),n.normalize(),r.normal.copy(n)}},computeVertexNormals:function(n){n===void 0&&(n=!0);let t=new Array(this.vertices.length);for(let e=0,i=this.vertices.length;e<i;e++)t[e]=new M;if(n){let e=new M,i=new M;for(let r=0,s=this.faces.length;r<s;r++){let o=this.faces[r],a=this.vertices[o.a],c=this.vertices[o.b],l=this.vertices[o.c];e.subVectors(l,c),i.subVectors(a,c),e.cross(i),t[o.a].add(e),t[o.b].add(e),t[o.c].add(e)}}else{this.computeFaceNormals();for(let e=0,i=this.faces.length;e<i;e++){let r=this.faces[e];t[r.a].add(r.normal),t[r.b].add(r.normal),t[r.c].add(r.normal)}}for(let e=0,i=this.vertices.length;e<i;e++)t[e].normalize();for(let e=0,i=this.faces.length;e<i;e++){let r=this.faces[e],s=r.vertexNormals;s.length===3?(s[0].copy(t[r.a]),s[1].copy(t[r.b]),s[2].copy(t[r.c])):(s[0]=t[r.a].clone(),s[1]=t[r.b].clone(),s[2]=t[r.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let n=0,t=this.faces.length;n<t;n++){let e=this.faces[n],i=e.vertexNormals;i.length===3?(i[0].copy(e.normal),i[1].copy(e.normal),i[2].copy(e.normal)):(i[0]=e.normal.clone(),i[1]=e.normal.clone(),i[2]=e.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let t=0,e=this.faces.length;t<e;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let r=0,s=i.vertexNormals.length;r<s;r++)i.__originalVertexNormals[r]?i.__originalVertexNormals[r].copy(i.vertexNormals[r]):i.__originalVertexNormals[r]=i.vertexNormals[r].clone()}let n=new Ut;n.faces=this.faces;for(let t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let r=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(let o=0,a=this.faces.length;o<a;o++){let c=new M,l={a:new M,b:new M,c:new M};r.push(c),s.push(l)}}let i=this.morphNormals[t];n.vertices=this.morphTargets[t].vertices,n.computeFaceNormals(),n.computeVertexNormals();for(let r=0,s=this.faces.length;r<s;r++){let o=this.faces[r],a=i.faceNormals[r],c=i.vertexNormals[r];a.copy(o.normal),c.a.copy(o.vertexNormals[0]),c.b.copy(o.vertexNormals[1]),c.c.copy(o.vertexNormals[2])}}for(let t=0,e=this.faces.length;t<e;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new je),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new cn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(n,t,e){if(!(n&&n.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",n);return}let i,r=this.vertices.length,s=this.vertices,o=n.vertices,a=this.faces,c=n.faces,l=this.colors,u=n.colors;e===void 0&&(e=0),t!==void 0&&(i=new pe().getNormalMatrix(t));for(let h=0,d=o.length;h<d;h++){let p=o[h].clone();t!==void 0&&p.applyMatrix4(t),s.push(p)}for(let h=0,d=u.length;h<d;h++)l.push(u[h].clone());for(let h=0,d=c.length;h<d;h++){let f=c[h],p,y,x=f.vertexNormals,g=f.vertexColors,m=new hr(f.a+r,f.b+r,f.c+r);m.normal.copy(f.normal),i!==void 0&&m.normal.applyMatrix3(i).normalize();for(let b=0,v=x.length;b<v;b++)p=x[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),m.vertexNormals.push(p);m.color.copy(f.color);for(let b=0,v=g.length;b<v;b++)y=g[b],m.vertexColors.push(y.clone());m.materialIndex=f.materialIndex+e,a.push(m)}for(let h=0,d=n.faceVertexUvs.length;h<d;h++){let f=n.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,y=f.length;p<y;p++){let x=f[p],g=[];for(let m=0,b=x.length;m<b;m++)g.push(x[m].clone());this.faceVertexUvs[h].push(g)}}},mergeMesh:function(n){if(!(n&&n.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",n);return}n.matrixAutoUpdate&&n.updateMatrix(),this.merge(n.geometry,n.matrix)},mergeVertices:function(){let n={},t=[],e=[],r=Math.pow(10,4);for(let a=0,c=this.vertices.length;a<c;a++){let l=this.vertices[a],u=Math.round(l.x*r)+"_"+Math.round(l.y*r)+"_"+Math.round(l.z*r);n[u]===void 0?(n[u]=a,t.push(this.vertices[a]),e[a]=t.length-1):e[a]=e[n[u]]}let s=[];for(let a=0,c=this.faces.length;a<c;a++){let l=this.faces[a];l.a=e[l.a],l.b=e[l.b],l.c=e[l.c];let u=[l.a,l.b,l.c];for(let h=0;h<3;h++)if(u[h]===u[(h+1)%3]){s.push(a);break}}for(let a=s.length-1;a>=0;a--){let c=s[a];this.faces.splice(c,1);for(let l=0,u=this.faceVertexUvs.length;l<u;l++)this.faceVertexUvs[l].splice(c,1)}let o=this.vertices.length-t.length;return this.vertices=t,o},setFromPoints:function(n){this.vertices=[];for(let t=0,e=n.length;t<e;t++){let i=n[t];this.vertices.push(new M(i.x,i.y,i.z||0))}return this},sortFacesByMaterialIndex:function(){let n=this.faces,t=n.length;for(let a=0;a<t;a++)n[a]._id=a;function e(a,c){return a.materialIndex-c.materialIndex}n.sort(e);let i=this.faceVertexUvs[0],r=this.faceVertexUvs[1],s,o;i&&i.length===t&&(s=[]),r&&r.length===t&&(o=[]);for(let a=0;a<t;a++){let c=n[a]._id;s&&s.push(i[c]),o&&o.push(r[c])}s&&(this.faceVertexUvs[0]=s),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){let n={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.parameters!==void 0){let f=this.parameters;for(let p in f)f[p]!==void 0&&(n[p]=f[p]);return n}let t=[];for(let f=0;f<this.vertices.length;f++){let p=this.vertices[f];t.push(p.x,p.y,p.z)}let e=[],i=[],r={},s=[],o={},a=[],c={};for(let f=0;f<this.faces.length;f++){let p=this.faces[f],y=!0,x=!1,g=this.faceVertexUvs[0][f]!==void 0,m=p.normal.length()>0,b=p.vertexNormals.length>0,v=p.color.r!==1||p.color.g!==1||p.color.b!==1,w=p.vertexColors.length>0,_=0;if(_=l(_,0,0),_=l(_,1,y),_=l(_,2,x),_=l(_,3,g),_=l(_,4,m),_=l(_,5,b),_=l(_,6,v),_=l(_,7,w),e.push(_),e.push(p.a,p.b,p.c),e.push(p.materialIndex),g){let A=this.faceVertexUvs[0][f];e.push(d(A[0]),d(A[1]),d(A[2]))}if(m&&e.push(u(p.normal)),b){let A=p.vertexNormals;e.push(u(A[0]),u(A[1]),u(A[2]))}if(v&&e.push(h(p.color)),w){let A=p.vertexColors;e.push(h(A[0]),h(A[1]),h(A[2]))}}function l(f,p,y){return y?f|1<<p:f&~(1<<p)}function u(f){let p=f.x.toString()+f.y.toString()+f.z.toString();return r[p]!==void 0||(r[p]=i.length/3,i.push(f.x,f.y,f.z)),r[p]}function h(f){let p=f.r.toString()+f.g.toString()+f.b.toString();return o[p]!==void 0||(o[p]=s.length,s.push(f.getHex())),o[p]}function d(f){let p=f.x.toString()+f.y.toString();return c[p]!==void 0||(c[p]=a.length/2,a.push(f.x,f.y)),c[p]}return n.data={},n.data.vertices=t,n.data.normals=i,s.length>0&&(n.data.colors=s),a.length>0&&(n.data.uvs=[a]),n.data.faces=e,n},clone:function(){return new Ut().copy(this)},copy:function(n){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=n.name;let t=n.vertices;for(let h=0,d=t.length;h<d;h++)this.vertices.push(t[h].clone());let e=n.colors;for(let h=0,d=e.length;h<d;h++)this.colors.push(e[h].clone());let i=n.faces;for(let h=0,d=i.length;h<d;h++)this.faces.push(i[h].clone());for(let h=0,d=n.faceVertexUvs.length;h<d;h++){let f=n.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,y=f.length;p<y;p++){let x=f[p],g=[];for(let m=0,b=x.length;m<b;m++){let v=x[m];g.push(v.clone())}this.faceVertexUvs[h].push(g)}}let r=n.morphTargets;for(let h=0,d=r.length;h<d;h++){let f={};if(f.name=r[h].name,r[h].vertices!==void 0){f.vertices=[];for(let p=0,y=r[h].vertices.length;p<y;p++)f.vertices.push(r[h].vertices[p].clone())}if(r[h].normals!==void 0){f.normals=[];for(let p=0,y=r[h].normals.length;p<y;p++)f.normals.push(r[h].normals[p].clone())}this.morphTargets.push(f)}let s=n.morphNormals;for(let h=0,d=s.length;h<d;h++){let f={};if(s[h].vertexNormals!==void 0){f.vertexNormals=[];for(let p=0,y=s[h].vertexNormals.length;p<y;p++){let x=s[h].vertexNormals[p],g={};g.a=x.a.clone(),g.b=x.b.clone(),g.c=x.c.clone(),f.vertexNormals.push(g)}}if(s[h].faceNormals!==void 0){f.faceNormals=[];for(let p=0,y=s[h].faceNormals.length;p<y;p++)f.faceNormals.push(s[h].faceNormals[p].clone())}this.morphNormals.push(f)}let o=n.skinWeights;for(let h=0,d=o.length;h<d;h++)this.skinWeights.push(o[h].clone());let a=n.skinIndices;for(let h=0,d=a.length;h<d;h++)this.skinIndices.push(a[h].clone());let c=n.lineDistances;for(let h=0,d=c.length;h<d;h++)this.lineDistances.push(c[h]);let l=n.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=n.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=n.elementsNeedUpdate,this.verticesNeedUpdate=n.verticesNeedUpdate,this.uvsNeedUpdate=n.uvsNeedUpdate,this.normalsNeedUpdate=n.normalsNeedUpdate,this.colorsNeedUpdate=n.colorsNeedUpdate,this.lineDistancesNeedUpdate=n.lineDistancesNeedUpdate,this.groupsNeedUpdate=n.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var ko=class extends Ut{constructor(t,e,i,r,s,o){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:s,depthSegments:o},this.fromBufferGeometry(new dr(t,e,i,r,s,o)),this.mergeVertices()}},dr=class extends yt{constructor(t=1,e=1,i=1,r=1,s=1,o=1){super(),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],h=[],d=0,f=0;p("z","y","x",-1,-1,i,e,t,o,s,0),p("z","y","x",1,-1,i,e,-t,o,s,1),p("x","z","y",1,1,t,i,e,r,o,2),p("x","z","y",1,-1,t,i,-e,r,o,3),p("x","y","z",1,-1,t,e,i,r,s,4),p("x","y","z",-1,-1,t,e,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new st(l,3)),this.setAttribute("normal",new st(u,3)),this.setAttribute("uv",new st(h,2));function p(y,x,g,m,b,v,w,_,A,I,D){let N=v/A,O=w/I,F=v/2,z=w/2,P=_/2,R=A+1,U=I+1,j=0,Z=0,K=new M;for(let ut=0;ut<U;ut++){let it=ut*O-z;for(let St=0;St<R;St++){let wt=St*N-F;K[y]=wt*m,K[x]=it*b,K[g]=P,l.push(K.x,K.y,K.z),K[y]=0,K[x]=0,K[g]=_>0?1:-1,u.push(K.x,K.y,K.z),h.push(St/A),h.push(1-ut/I),j+=1}}for(let ut=0;ut<I;ut++)for(let it=0;it<A;it++){let St=d+it+R*ut,wt=d+it+R*(ut+1),Ht=d+(it+1)+R*(ut+1),V=d+(it+1)+R*ut;c.push(St,wt,V),c.push(wt,Ht,V),Z+=6}a.addGroup(f,Z,D),f+=Z,d+=j}}};function xs(n){let t={};for(let e in n){t[e]={};for(let i in n[e]){let r=n[e][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?t[e][i]=r.clone():Array.isArray(r)?t[e][i]=r.slice():t[e][i]=r}}return t}function ge(n){let t={};for(let e=0;e<n.length;e++){let i=xs(n[e]);for(let r in i)t[r]=i[r]}return t}var Qy={clone:xs,merge:ge},__=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,w_=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;function Me(n){bt.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=__,this.fragmentShader=w_,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,n!==void 0&&(n.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(n))}Me.prototype=Object.create(bt.prototype);Me.prototype.constructor=Me;Me.prototype.isShaderMaterial=!0;Me.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.fragmentShader=n.fragmentShader,this.vertexShader=n.vertexShader,this.uniforms=xs(n.uniforms),this.defines=Object.assign({},n.defines),this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.lights=n.lights,this.clipping=n.clipping,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this.extensions=Object.assign({},n.extensions),this.glslVersion=n.glslVersion,this};Me.prototype.toJSON=function(n){let t=bt.prototype.toJSON.call(this,n);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;s&&s.isTexture?t.uniforms[i]={type:"t",value:s.toJSON(n).uuid}:s&&s.isColor?t.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[i]={type:"m4",value:s.toArray()}:t.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let e={};for(let i in this.extensions)this.extensions[i]===!0&&(e[i]=!0);return Object.keys(e).length>0&&(t.extensions=e),t};function Sn(){dt.call(this),this.type="Camera",this.matrixWorldInverse=new At,this.projectionMatrix=new At,this.projectionMatrixInverse=new At}Sn.prototype=Object.assign(Object.create(dt.prototype),{constructor:Sn,isCamera:!0,copy:function(n,t){return dt.prototype.copy.call(this,n,t),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this},getWorldDirection:function(n){n===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),n=new M),this.updateMatrixWorld(!0);let t=this.matrixWorld.elements;return n.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(n){dt.prototype.updateMatrixWorld.call(this,n),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(n,t){dt.prototype.updateWorldMatrix.call(this,n,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function ne(n,t,e,i){Sn.call(this),this.type="PerspectiveCamera",this.fov=n!==void 0?n:50,this.zoom=1,this.near=e!==void 0?e:.1,this.far=i!==void 0?i:2e3,this.focus=10,this.aspect=t!==void 0?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}ne.prototype=Object.assign(Object.create(Sn.prototype),{constructor:ne,isPerspectiveCamera:!0,copy:function(n,t){return Sn.prototype.copy.call(this,n,t),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this},setFocalLength:function(n){let t=.5*this.getFilmHeight()/n;this.fov=_t.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){let n=Math.tan(_t.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/n},getEffectiveFOV:function(){return _t.RAD2DEG*2*Math.atan(Math.tan(_t.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(n,t,e,i,r,s){this.aspect=n/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=t,this.view.offsetX=e,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let n=this.near,t=n*Math.tan(_t.DEG2RAD*.5*this.fov)/this.zoom,e=2*t,i=this.aspect*e,r=-.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let a=s.fullWidth,c=s.fullHeight;r+=s.offsetX*i/a,t-=s.offsetY*e/c,i*=s.width/a,e*=s.height/c}let o=this.filmOffset;o!==0&&(r+=n*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-e,n,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(n){let t=dt.prototype.toJSON.call(this,n);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var Kr=90,ts=1;function vs(n,t,e){if(dt.call(this),this.type="CubeCamera",e.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=e;let i=new ne(Kr,ts,n,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new M(1,0,0)),this.add(i);let r=new ne(Kr,ts,n,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new M(-1,0,0)),this.add(r);let s=new ne(Kr,ts,n,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new M(0,1,0)),this.add(s);let o=new ne(Kr,ts,n,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new M(0,-1,0)),this.add(o);let a=new ne(Kr,ts,n,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new M(0,0,1)),this.add(a);let c=new ne(Kr,ts,n,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new M(0,0,-1)),this.add(c),this.update=function(l,u){this.parent===null&&this.updateMatrixWorld();let h=l.xr.enabled,d=l.getRenderTarget();l.xr.enabled=!1;let f=e.texture.generateMipmaps;e.texture.generateMipmaps=!1,l.setRenderTarget(e,0),l.render(u,i),l.setRenderTarget(e,1),l.render(u,r),l.setRenderTarget(e,2),l.render(u,s),l.setRenderTarget(e,3),l.render(u,o),l.setRenderTarget(e,4),l.render(u,a),e.texture.generateMipmaps=f,l.setRenderTarget(e,5),l.render(u,c),l.setRenderTarget(d),l.xr.enabled=h},this.clear=function(l,u,h,d){let f=l.getRenderTarget();for(let p=0;p<6;p++)l.setRenderTarget(e,p),l.clear(u,h,d);l.setRenderTarget(f)}}vs.prototype=Object.create(dt.prototype);vs.prototype.constructor=vs;function Li(n,t,e){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=e),ze.call(this,n,n,t),this.texture.isWebGLCubeRenderTargetTexture=!0}Li.prototype=Object.create(ze.prototype);Li.prototype.constructor=Li;Li.prototype.isWebGLCubeRenderTarget=!0;Li.prototype.fromEquirectangularTexture=function(n,t){this.texture.type=t.type,this.texture.format=Fe,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let e={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 <begin_vertex>
				#include <project_vertex>

			}
		`,fragmentShader:`

			uniform sampler2D tEquirect;

			varying vec3 vWorldDirection;

			#include <common>

			void main() {

				vec3 direction = normalize( vWorldDirection );

				vec2 sampleUV = equirectUv( direction );

				gl_FragColor = texture2D( tEquirect, sampleUV );

			}
		`},i=new dr(5,5,5),r=new Me({name:"CubemapFromEquirect",uniforms:xs(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:oe,blending:$n});r.uniforms.tEquirect.value=t;let s=new Yt(i,r),o=t.minFilter;return t.minFilter===zs&&(t.minFilter=he),new vs(1,10,this).update(n,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this};function pr(n,t,e,i,r,s,o,a,c,l,u,h){Gt.call(this,null,s,o,a,c,l,i,r,u,h),this.image={data:n||null,width:t||1,height:e||1},this.magFilter=c!==void 0?c:ae,this.minFilter=l!==void 0?l:ae,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}pr.prototype=Object.create(Gt.prototype);pr.prototype.constructor=pr;pr.prototype.isDataTexture=!0;var es=new cn,mc=new M,mr=class{constructor(t,e,i,r,s,o){this.planes=[t!==void 0?t:new Ge,e!==void 0?e:new Ge,i!==void 0?i:new Ge,r!==void 0?r:new Ge,s!==void 0?s:new Ge,o!==void 0?o:new Ge]}set(t,e,i,r,s,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}clone(){return new this.constructor().copy(this)}copy(t){let e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){let e=this.planes,i=t.elements,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],l=i[5],u=i[6],h=i[7],d=i[8],f=i[9],p=i[10],y=i[11],x=i[12],g=i[13],m=i[14],b=i[15];return e[0].setComponents(a-r,h-c,y-d,b-x).normalize(),e[1].setComponents(a+r,h+c,y+d,b+x).normalize(),e[2].setComponents(a+s,h+l,y+f,b+g).normalize(),e[3].setComponents(a-s,h-l,y-f,b-g).normalize(),e[4].setComponents(a-o,h-u,y-p,b-m).normalize(),e[5].setComponents(a+o,h+u,y+p,b+m).normalize(),this}intersectsObject(t){let e=t.geometry;return e.boundingSphere===null&&e.computeBoundingSphere(),es.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(es)}intersectsSprite(t){return es.center.set(0,0,0),es.radius=.7071067811865476,es.applyMatrix4(t.matrixWorld),this.intersectsSphere(es)}intersectsSphere(t){let e=this.planes,i=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(t){let e=this.planes;for(let i=0;i<6;i++){let r=e[i];if(mc.x=r.normal.x>0?t.max.x:t.min.x,mc.y=r.normal.y>0?t.max.y:t.min.y,mc.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(mc)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}};function Ky(){let n=null,t=!1,e=null,i=null;function r(s,o){e(s,o),i=n.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(i=n.requestAnimationFrame(r),t=!0)},stop:function(){n.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){n=s}}}function M_(n,t){let e=t.isWebGL2,i=new WeakMap;function r(l,u){let h=l.array,d=l.usage,f=n.createBuffer();n.bindBuffer(u,f),n.bufferData(u,h,d),l.onUploadCallback();let p=5126;return h instanceof Float32Array?p=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?p=5123:h instanceof Int16Array?p=5122:h instanceof Uint32Array?p=5125:h instanceof Int32Array?p=5124:h instanceof Int8Array?p=5120:h instanceof Uint8Array&&(p=5121),{buffer:f,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){let d=u.array,f=u.updateRange;n.bindBuffer(h,l),f.count===-1?n.bufferSubData(h,0,d):(e?n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),i.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);let u=i.get(l);u&&(n.deleteBuffer(u.buffer),i.delete(l))}function c(l,u){if(l.isGLBufferAttribute){var h=i.get(l);(!h||h.version<l.version)&&i.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);let d=i.get(l);d===void 0?i.set(l,r(l,u)):d.version<l.version&&(s(d.buffer,l,u),d.version=l.version)}return{get:o,remove:a,update:c}}var qc=class extends Ut{constructor(t,e,i,r){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new bs(t,e,i,r)),this.mergeVertices()}},bs=class extends yt{constructor(t,e,i,r){super(),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r},t=t||1,e=e||1;let s=t/2,o=e/2,a=Math.floor(i)||1,c=Math.floor(r)||1,l=a+1,u=c+1,h=t/a,d=e/c,f=[],p=[],y=[],x=[];for(let g=0;g<u;g++){let m=g*d-o;for(let b=0;b<l;b++){let v=b*h-s;p.push(v,-m,0),y.push(0,0,1),x.push(b/a),x.push(1-g/c)}}for(let g=0;g<c;g++)for(let m=0;m<a;m++){let b=m+l*g,v=m+l*(g+1),w=m+1+l*(g+1),_=m+1+l*g;f.push(b,v,_),f.push(v,w,_)}this.setIndex(f),this.setAttribute("position",new st(p,3)),this.setAttribute("normal",new st(y,3)),this.setAttribute("uv",new st(x,2))}},S_=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif`,E_=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,T_=`#ifdef ALPHATEST
	if ( diffuseColor.a < ALPHATEST ) discard;
#endif`,A_=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
	#endif
#endif`,C_=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,L_="vec3 transformed = vec3( position );",P_=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,R_=`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
	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;
	return vec2( -1.04, 1.04 ) * a004 + r.zw;
}
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
#else
	if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
		return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
	}
	return 1.0;
#endif
}
vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
	float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
	return ( 1.0 - specularColor ) * fresnel + specularColor;
}
vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
	float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
	vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
	return Fr * fresnel + F0;
}
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	return 1.0 / ( gl * gv );
}
float G_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 );
}
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( incidentLight.direction + viewDir );
	float dotNL = saturate( dot( normal, incidentLight.direction ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
	vec3 F = F_Schlick( specularColor, dotLH );
	float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
	float D = D_GGX( alpha, dotNH );
	return F * ( G * 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 );
}
vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
	return specularColor * brdf.x + brdf.y;
}
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
	float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
	vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
	vec3 FssEss = F * brdf.x + brdf.y;
	float Ess = brdf.x + brdf.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
	float dotNH = saturate( dot( geometry.normal, halfDir ) );
	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
	vec3 F = F_Schlick( specularColor, dotLH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
}
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
	return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
}
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
	return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
}
#if defined( USE_SHEEN )
float D_Charlie(float roughness, float NoH) {
	float invAlpha = 1.0 / roughness;
	float cos2h = NoH * NoH;
	float sin2h = max(1.0 - cos2h, 0.0078125);	return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
}
float V_Neubelt(float NoV, float NoL) {
	return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
}
vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
	vec3 N = geometry.normal;
	vec3 V = geometry.viewDir;
	vec3 H = normalize( V + L );
	float dotNH = saturate( dot( N, H ) );
	return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
}
#endif`,I_=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vUv );
		vec2 dSTdy = dFdy( vUv );
		float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
		vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
		vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 );
		fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,D_=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#pragma unroll_loop_start
	for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
		plane = clippingPlanes[ i ];
		if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
	}
	#pragma unroll_loop_end
	#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
		bool clipped = true;
		#pragma unroll_loop_start
		for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
		}
		#pragma unroll_loop_end
		if ( clipped ) discard;
	#endif
#endif`,O_=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,F_=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,z_=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,N_=`#ifdef USE_COLOR
	diffuseColor.rgb *= vColor;
#endif`,B_=`#ifdef USE_COLOR
	varying vec3 vColor;
#endif`,U_=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	varying vec3 vColor;
#endif`,k_=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor.xyz *= color.xyz;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif`,G_=`#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; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
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 max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
struct GeometricContext {
	vec3 position;
	vec3 normal;
	vec3 viewDir;
#ifdef CLEARCOAT
	vec3 clearcoatNormal;
#endif
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
	float distance = dot( planeNormal, point - pointOnPlane );
	return - distance * planeNormal + point;
}
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
	return sign( dot( point - pointOnPlane, planeNormal ) );
}
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
	return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
float linearToRelativeLuminance( const in vec3 color ) {
	vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
	return dot( weights, color.rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}`,H_=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_maxMipLevel 8.0
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_maxTileSize 256.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 );
		float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
		vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );
		vec2 f = fract( uv );
		uv += 0.5 - f;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		if ( mipInt < cubeUV_maxMipLevel ) {
			uv.y += 2.0 * cubeUV_maxTileSize;
		}
		uv.y += filterInt * 2.0 * cubeUV_minTileSize;
		uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
		uv *= texelSize;
		vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.x += texelSize;
		vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.y += texelSize;
		vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		uv.x -= texelSize;
		vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
		vec3 tm = mix( tl, tr, f.x );
		vec3 bm = mix( bl, br, f.x );
		return mix( tm, bm, f.y );
	}
	#define r0 1.0
	#define v0 0.339
	#define m0 - 2.0
	#define r1 0.8
	#define v1 0.276
	#define m1 - 1.0
	#define r4 0.4
	#define v4 0.046
	#define m4 2.0
	#define r5 0.305
	#define v5 0.016
	#define m5 3.0
	#define r6 0.21
	#define v6 0.0038
	#define m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= r1 ) {
			mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
		} else if ( roughness >= r4 ) {
			mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
		} else if ( roughness >= r5 ) {
			mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
		} else if ( roughness >= r6 ) {
			mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
		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`,V_=`vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
	mat3 m = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
	transformedNormal = m * transformedNormal;
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,W_=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,j_=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif`,X_=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vUv );
	emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,q_=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,Y_="gl_FragColor = linearToOutputTexel( gl_FragColor );",Z_=`
vec4 LinearToLinear( in vec4 value ) {
	return value;
}
vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
}
vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
	return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
}
vec4 sRGBToLinear( 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 LinearTosRGB( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
vec4 RGBEToLinear( in vec4 value ) {
	return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
}
vec4 LinearToRGBE( in vec4 value ) {
	float maxComponent = max( max( value.r, value.g ), value.b );
	float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
	return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
}
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * value.a * maxRange, 1.0 );
}
vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
	M = ceil( M * 255.0 ) / 255.0;
	return vec4( value.rgb / ( M * maxRange ), M );
}
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
	return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
}
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
	float maxRGB = max( value.r, max( value.g, value.b ) );
	float D = max( maxRange / maxRGB, 1.0 );
	D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
	return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
}
const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
vec4 LinearToLogLuv( in vec4 value ) {
	vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
	Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
	vec4 vResult;
	vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
	float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
	vResult.w = fract( Le );
	vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
	return vResult;
}
const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
vec4 LogLuvToLinear( in vec4 value ) {
	float Le = value.z * 255.0 + value.w;
	vec3 Xp_Y_XYZp;
	Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
	Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
	Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
	vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
	return vec4( max( vRGB, 0.0 ), 1.0 );
}`,J_=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifndef ENVMAP_TYPE_CUBE_UV
		envColor = envMapTexelToLinear( envColor );
	#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`,$_=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform int maxMipLevel;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,Q_=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,K_=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,tw=`#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`,ew=`#ifdef USE_FOG
	fogDepth = - mvPosition.z;
#endif`,nw=`#ifdef USE_FOG
	varying float fogDepth;
#endif`,iw=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,rw=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float fogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,sw=`#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 texture2D( gradientMap, coord ).rgb;
	#else
		return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
	#endif
}`,ow=`#ifdef USE_LIGHTMAP
	vec4 lightMapTexel= texture2D( lightMap, vUv2 );
	reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
#endif`,aw=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,cw=`vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
	vLightBack = vec3( 0.0 );
	vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry );
#ifdef DOUBLE_SIDED
	vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
	vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );
#endif
#if NUM_POINT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = PI * directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_HEMI_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
		vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
		#ifdef DOUBLE_SIDED
			vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
		#endif
	}
	#pragma unroll_loop_end
#endif`,lw=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
	vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	return irradiance;
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		directLight.color = directionalLight.color;
		directLight.direction = directionalLight.direction;
		directLight.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 getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		vec3 lVector = pointLight.position - geometry.position;
		directLight.direction = normalize( lVector );
		float lightDistance = length( lVector );
		directLight.color = pointLight.color;
		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
		directLight.visible = ( directLight.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 getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
		vec3 lVector = spotLight.position - geometry.position;
		directLight.direction = normalize( lVector );
		float lightDistance = length( lVector );
		float angleCos = dot( directLight.direction, spotLight.direction );
		if ( angleCos > spotLight.coneCos ) {
			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
			directLight.color = spotLight.color;
			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
			directLight.visible = true;
		} else {
			directLight.color = vec3( 0.0 );
			directLight.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 GeometricContext geometry ) {
		float dotNL = dot( geometry.normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			irradiance *= PI;
		#endif
		return irradiance;
	}
#endif`,hw=`#if defined( USE_ENVMAP )
	#ifdef ENVMAP_MODE_REFRACTION
		uniform float refractionRatio;
	#endif
	vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
		vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
		#ifdef ENVMAP_TYPE_CUBE
			vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
			#ifdef TEXTURE_LOD_EXT
				vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
			#else
				vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
			#endif
			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
		#elif defined( ENVMAP_TYPE_CUBE_UV )
			vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
		#else
			vec4 envMapColor = vec4( 0.0 );
		#endif
		return PI * envMapColor.rgb * envMapIntensity;
	}
	float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
		float maxMIPLevelScalar = float( maxMIPLevel );
		float sigma = PI * roughness * roughness / ( 1.0 + roughness );
		float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
		return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
	}
	vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( -viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
		#else
			vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
		#endif
		reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
		float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
		#ifdef ENVMAP_TYPE_CUBE
			vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
			#ifdef TEXTURE_LOD_EXT
				vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
			#else
				vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
			#endif
			envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
		#elif defined( ENVMAP_TYPE_CUBE_UV )
			vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
		#endif
		return envMapColor.rgb * envMapIntensity;
	}
#endif`,uw=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,fw=`varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon
#define Material_LightProbeLOD( material )	(0)`,dw=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,pw=`varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong
#define Material_LightProbeLOD( material )	(0)`,mw=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
material.specularRoughness = min( material.specularRoughness, 1.0 );
#ifdef REFLECTIVITY
	material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
#endif
#ifdef CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_SHEEN
	material.sheenColor = sheen;
#endif`,gw=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float specularRoughness;
	vec3 specularColor;
#ifdef CLEARCOAT
	float clearcoat;
	float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
	vec3 sheenColor;
#endif
};
#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
#define DEFAULT_SPECULAR_COEFFICIENT 0.04
float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
	return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometry.normal;
		vec3 viewDir = geometry.viewDir;
		vec3 position = geometry.position;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.specularRoughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifndef PHYSICALLY_CORRECT_LIGHTS
		irradiance *= PI;
	#endif
	#ifdef CLEARCOAT
		float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = ccDotNL * directLight.color;
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			ccIrradiance *= PI;
		#endif
		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
		reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
	#else
		float clearcoatDHR = 0.0;
	#endif
	#ifdef USE_SHEEN
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
			material.specularRoughness,
			directLight.direction,
			geometry,
			material.sheenColor
		);
	#else
		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
	#endif
	reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef CLEARCOAT
		float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
		reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
		float ccDotNL = ccDotNV;
		float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
	#else
		float clearcoatDHR = 0.0;
	#endif
	float clearcoatInv = 1.0 - clearcoatDHR;
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
	reflectedLight.indirectSpecular += clearcoatInv * 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 );
}`,yw=`
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef CLEARCOAT
	geometry.clearcoatNormal = clearcoatNormal;
#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 ];
		getPointDirectLightIrradiance( pointLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	#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 ];
		getSpotDirectLightIrradiance( spotLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	irradiance += getLightProbeIrradiance( lightProbe, geometry );
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,xw=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
		#ifndef PHYSICALLY_CORRECT_LIGHTS
			lightMapIrradiance *= PI;
		#endif
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
	#ifdef CLEARCOAT
		clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
	#endif
#endif`,vw=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif`,bw=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,_w=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,ww=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		varying float vFragDepth;
		varying float vIsPerspective;
	#else
		uniform float logDepthBufFC;
	#endif
#endif`,Mw=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		vFragDepth = 1.0 + gl_Position.w;
		vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
	#else
		if ( isPerspectiveMatrix( projectionMatrix ) ) {
			gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
			gl_Position.z *= gl_Position.w;
		}
	#endif
#endif`,Sw=`#ifdef USE_MAP
	vec4 texelColor = texture2D( map, vUv );
	texelColor = mapTexelToLinear( texelColor );
	diffuseColor *= texelColor;
#endif`,Ew=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,Tw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
	vec4 mapTexel = texture2D( map, uv );
	diffuseColor *= mapTexelToLinear( mapTexel );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,Aw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,Cw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vUv );
	metalnessFactor *= texelMetalness.b;
#endif`,Lw=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,Pw=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
	objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
	objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
	objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
#endif`,Rw=`#ifdef USE_MORPHTARGETS
	uniform float morphTargetBaseInfluence;
	#ifndef USE_MORPHNORMALS
		uniform float morphTargetInfluences[ 8 ];
	#else
		uniform float morphTargetInfluences[ 4 ];
	#endif
#endif`,Iw=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	transformed += morphTarget0 * morphTargetInfluences[ 0 ];
	transformed += morphTarget1 * morphTargetInfluences[ 1 ];
	transformed += morphTarget2 * morphTargetInfluences[ 2 ];
	transformed += morphTarget3 * morphTargetInfluences[ 3 ];
	#ifndef USE_MORPHNORMALS
		transformed += morphTarget4 * morphTargetInfluences[ 4 ];
		transformed += morphTarget5 * morphTargetInfluences[ 5 ];
		transformed += morphTarget6 * morphTargetInfluences[ 6 ];
		transformed += morphTarget7 * morphTargetInfluences[ 7 ];
	#endif
#endif`,Dw=`#ifdef FLAT_SHADED
	vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
	vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
	#endif
	#ifdef USE_TANGENT
		vec3 tangent = normalize( vTangent );
		vec3 bitangent = normalize( vBitangent );
		#ifdef DOUBLE_SIDED
			tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
			bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		#endif
		#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
			mat3 vTBN = mat3( tangent, bitangent, normal );
		#endif
	#endif
#endif
vec3 geometryNormal = normal;`,Ow=`#ifdef OBJECTSPACE_NORMALMAP
	normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( TANGENTSPACE_NORMALMAP )
	vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	#ifdef USE_TANGENT
		normal = normalize( vTBN * mapN );
	#else
		normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
	#endif
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
#endif`,Fw=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef OBJECTSPACE_NORMALMAP
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
	vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
		vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
		vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
		vec2 st0 = dFdx( vUv.st );
		vec2 st1 = dFdy( vUv.st );
		float scale = sign( st1.t * st0.s - st0.t * st1.s );
		vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
		vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
		vec3 N = normalize( surf_norm );
		mat3 tsn = mat3( S, T, N );
		mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
		return normalize( tsn * mapN );
	}
#endif`,zw=`#ifdef CLEARCOAT
	vec3 clearcoatNormal = geometryNormal;
#endif`,Nw=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	#ifdef USE_TANGENT
		clearcoatNormal = normalize( vTBN * clearcoatMapN );
	#else
		clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
	#endif
#endif`,Bw=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif`,Uw=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}
vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
	return linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * invClipZ - far );
}`,kw=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Gw=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,Hw=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Vw=`#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`,Ww=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vUv );
	roughnessFactor *= texelRoughness.g;
#endif`,jw=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,Xw=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
		bool inFrustum = all( inFrustumVec );
		bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
		bool frustumTest = all( frustumTestVec );
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return shadow;
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
		vec3 lightToPosition = shadowCoord.xyz;
		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );		dp += shadowBias;
		vec3 bd3D = normalize( lightToPosition );
		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
			return (
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
			) * ( 1.0 / 9.0 );
		#else
			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
		#endif
	}
#endif`,qw=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,Yw=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
		vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		vec4 shadowWorldPosition;
	#endif
	#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_SPOT_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
		vSpotShadowCoord[ i ] = spotShadowMatrix[ 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`,Zw=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,Jw=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,$w=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	#ifdef BONE_TEXTURE
		uniform highp sampler2D boneTexture;
		uniform int boneTextureSize;
		mat4 getBoneMatrix( const in float i ) {
			float j = i * 4.0;
			float x = mod( j, float( boneTextureSize ) );
			float y = floor( j / float( boneTextureSize ) );
			float dx = 1.0 / float( boneTextureSize );
			float dy = 1.0 / float( boneTextureSize );
			y = dy * ( y + 0.5 );
			vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
			vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
			vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
			vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
			mat4 bone = mat4( v1, v2, v3, v4 );
			return bone;
		}
	#else
		uniform mat4 boneMatrices[ MAX_BONES ];
		mat4 getBoneMatrix( const in float i ) {
			mat4 bone = boneMatrices[ int(i) ];
			return bone;
		}
	#endif
#endif`,Qw=`#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`,Kw=`#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`,tM=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,eM=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,nM=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,iM=`#ifndef saturate
#define saturate(a) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return toneMappingExposure * color;
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,rM=`#ifdef USE_TRANSMISSIONMAP
	totalTransmission *= texture2D( transmissionMap, vUv ).r;
#endif`,sM=`#ifdef USE_TRANSMISSIONMAP
	uniform sampler2D transmissionMap;
#endif`,oM=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
	varying vec2 vUv;
#endif`,aM=`#ifdef USE_UV
	#ifdef UVS_VERTEX_ONLY
		vec2 vUv;
	#else
		varying vec2 vUv;
	#endif
	uniform mat3 uvTransform;
#endif`,cM=`#ifdef USE_UV
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif`,lM=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	varying vec2 vUv2;
#endif`,hM=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	attribute vec2 uv2;
	varying vec2 vUv2;
	uniform mat3 uv2Transform;
#endif`,uM=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif`,fM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,dM=`uniform sampler2D t2D;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	gl_FragColor = mapTexelToLinear( texColor );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,pM=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,mM=`#include <envmap_common_pars_fragment>
uniform float opacity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	vec3 vReflect = vWorldDirection;
	#include <envmap_fragment>
	gl_FragColor = envColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,gM=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,yM=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#endif
}`,xM=`#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,vM=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,bM=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,_M=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	vec4 texColor = texture2D( tEquirect, sampleUV );
	gl_FragColor = mapTexelToLinear( texColor );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,wM=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,MM=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,SM=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,EM=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
	
		vec4 lightMapTexel= texture2D( lightMap, vUv2 );
		reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,TM=`#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <skinbase_vertex>
	#ifdef USE_ENVMAP
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,AM=`uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <emissivemap_fragment>
	#ifdef DOUBLE_SIDED
		reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
	#else
		reflectedLight.indirectDiffuse += vIndirectFront;
	#endif
	#include <lightmap_fragment>
	reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
	#ifdef DOUBLE_SIDED
		reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
	#else
		reflectedLight.directDiffuse = vLightFront;
	#endif
	reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,CM=`#define LAMBERT
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <lights_lambert_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,LM=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <fog_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	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 );
		matcapColor = matcapTexelToLinear( matcapColor );
	#else
		vec4 matcapColor = vec4( 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,PM=`#define MATCAP
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#ifndef FLAT_SHADED
		vNormal = normalize( transformedNormal );
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,RM=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,IM=`#define TOON
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,DM=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,OM=`#define PHONG
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,FM=`#define STANDARD
#ifdef PHYSICAL
	#define REFLECTIVITY
	#define CLEARCOAT
	#define TRANSMISSION
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef TRANSMISSION
	uniform float transmission;
#endif
#ifdef REFLECTIVITY
	uniform float reflectivity;
#endif
#ifdef CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheen;
#endif
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <transmissionmap_pars_fragment>
#include <bsdfs>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <lights_physical_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#ifdef TRANSMISSION
		float totalTransmission = transmission;
	#endif
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <transmissionmap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#ifdef TRANSMISSION
		diffuseColor.a *= saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );
	#endif
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,zM=`#define STANDARD
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,NM=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <packing>
#include <uv_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
}`,BM=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	vViewPosition = - mvPosition.xyz;
#endif
}`,UM=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,kM=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <color_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,GM=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,HM=`#include <common>
#include <fog_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <begin_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,VM=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,WM=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,Pt={alphamap_fragment:S_,alphamap_pars_fragment:E_,alphatest_fragment:T_,aomap_fragment:A_,aomap_pars_fragment:C_,begin_vertex:L_,beginnormal_vertex:P_,bsdfs:R_,bumpmap_pars_fragment:I_,clipping_planes_fragment:D_,clipping_planes_pars_fragment:O_,clipping_planes_pars_vertex:F_,clipping_planes_vertex:z_,color_fragment:N_,color_pars_fragment:B_,color_pars_vertex:U_,color_vertex:k_,common:G_,cube_uv_reflection_fragment:H_,defaultnormal_vertex:V_,displacementmap_pars_vertex:W_,displacementmap_vertex:j_,emissivemap_fragment:X_,emissivemap_pars_fragment:q_,encodings_fragment:Y_,encodings_pars_fragment:Z_,envmap_fragment:J_,envmap_common_pars_fragment:$_,envmap_pars_fragment:Q_,envmap_pars_vertex:K_,envmap_physical_pars_fragment:hw,envmap_vertex:tw,fog_vertex:ew,fog_pars_vertex:nw,fog_fragment:iw,fog_pars_fragment:rw,gradientmap_pars_fragment:sw,lightmap_fragment:ow,lightmap_pars_fragment:aw,lights_lambert_vertex:cw,lights_pars_begin:lw,lights_toon_fragment:uw,lights_toon_pars_fragment:fw,lights_phong_fragment:dw,lights_phong_pars_fragment:pw,lights_physical_fragment:mw,lights_physical_pars_fragment:gw,lights_fragment_begin:yw,lights_fragment_maps:xw,lights_fragment_end:vw,logdepthbuf_fragment:bw,logdepthbuf_pars_fragment:_w,logdepthbuf_pars_vertex:ww,logdepthbuf_vertex:Mw,map_fragment:Sw,map_pars_fragment:Ew,map_particle_fragment:Tw,map_particle_pars_fragment:Aw,metalnessmap_fragment:Cw,metalnessmap_pars_fragment:Lw,morphnormal_vertex:Pw,morphtarget_pars_vertex:Rw,morphtarget_vertex:Iw,normal_fragment_begin:Dw,normal_fragment_maps:Ow,normalmap_pars_fragment:Fw,clearcoat_normal_fragment_begin:zw,clearcoat_normal_fragment_maps:Nw,clearcoat_pars_fragment:Bw,packing:Uw,premultiplied_alpha_fragment:kw,project_vertex:Gw,dithering_fragment:Hw,dithering_pars_fragment:Vw,roughnessmap_fragment:Ww,roughnessmap_pars_fragment:jw,shadowmap_pars_fragment:Xw,shadowmap_pars_vertex:qw,shadowmap_vertex:Yw,shadowmask_pars_fragment:Zw,skinbase_vertex:Jw,skinning_pars_vertex:$w,skinning_vertex:Qw,skinnormal_vertex:Kw,specularmap_fragment:tM,specularmap_pars_fragment:eM,tonemapping_fragment:nM,tonemapping_pars_fragment:iM,transmissionmap_fragment:rM,transmissionmap_pars_fragment:sM,uv_pars_fragment:oM,uv_pars_vertex:aM,uv_vertex:cM,uv2_pars_fragment:lM,uv2_pars_vertex:hM,uv2_vertex:uM,worldpos_vertex:fM,background_frag:dM,background_vert:pM,cube_frag:mM,cube_vert:gM,depth_frag:yM,depth_vert:xM,distanceRGBA_frag:vM,distanceRGBA_vert:bM,equirect_frag:_M,equirect_vert:wM,linedashed_frag:MM,linedashed_vert:SM,meshbasic_frag:EM,meshbasic_vert:TM,meshlambert_frag:AM,meshlambert_vert:CM,meshmatcap_frag:LM,meshmatcap_vert:PM,meshtoon_frag:RM,meshtoon_vert:IM,meshphong_frag:DM,meshphong_vert:OM,meshphysical_frag:FM,meshphysical_vert:zM,normal_frag:NM,normal_vert:BM,points_frag:UM,points_vert:kM,shadow_frag:GM,shadow_vert:HM,sprite_frag:VM,sprite_vert:WM},ct={common:{diffuse:{value:new lt(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new pe},uv2Transform:{value:new pe},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new G(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new lt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new lt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pe}},sprite:{diffuse:{value:new lt(15658734)},opacity:{value:1},center:{value:new G(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pe}}},on={basic:{uniforms:ge([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.fog]),vertexShader:Pt.meshbasic_vert,fragmentShader:Pt.meshbasic_frag},lambert:{uniforms:ge([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.fog,ct.lights,{emissive:{value:new lt(0)}}]),vertexShader:Pt.meshlambert_vert,fragmentShader:Pt.meshlambert_frag},phong:{uniforms:ge([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new lt(0)},specular:{value:new lt(1118481)},shininess:{value:30}}]),vertexShader:Pt.meshphong_vert,fragmentShader:Pt.meshphong_frag},standard:{uniforms:ge([ct.common,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.roughnessmap,ct.metalnessmap,ct.fog,ct.lights,{emissive:{value:new lt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pt.meshphysical_vert,fragmentShader:Pt.meshphysical_frag},toon:{uniforms:ge([ct.common,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.gradientmap,ct.fog,ct.lights,{emissive:{value:new lt(0)}}]),vertexShader:Pt.meshtoon_vert,fragmentShader:Pt.meshtoon_frag},matcap:{uniforms:ge([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,{matcap:{value:null}}]),vertexShader:Pt.meshmatcap_vert,fragmentShader:Pt.meshmatcap_frag},points:{uniforms:ge([ct.points,ct.fog]),vertexShader:Pt.points_vert,fragmentShader:Pt.points_frag},dashed:{uniforms:ge([ct.common,ct.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pt.linedashed_vert,fragmentShader:Pt.linedashed_frag},depth:{uniforms:ge([ct.common,ct.displacementmap]),vertexShader:Pt.depth_vert,fragmentShader:Pt.depth_frag},normal:{uniforms:ge([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,{opacity:{value:1}}]),vertexShader:Pt.normal_vert,fragmentShader:Pt.normal_frag},sprite:{uniforms:ge([ct.sprite,ct.fog]),vertexShader:Pt.sprite_vert,fragmentShader:Pt.sprite_frag},background:{uniforms:{uvTransform:{value:new pe},t2D:{value:null}},vertexShader:Pt.background_vert,fragmentShader:Pt.background_frag},cube:{uniforms:ge([ct.envmap,{opacity:{value:1}}]),vertexShader:Pt.cube_vert,fragmentShader:Pt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pt.equirect_vert,fragmentShader:Pt.equirect_frag},distanceRGBA:{uniforms:ge([ct.common,ct.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pt.distanceRGBA_vert,fragmentShader:Pt.distanceRGBA_frag},shadow:{uniforms:ge([ct.lights,ct.fog,{color:{value:new lt(0)},opacity:{value:1}}]),vertexShader:Pt.shadow_vert,fragmentShader:Pt.shadow_frag}};on.physical={uniforms:ge([on.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new G(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new lt(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Pt.meshphysical_vert,fragmentShader:Pt.meshphysical_frag};function jM(n,t,e,i,r){let s=new lt(0),o=0,a,c,l=null,u=0,h=null;function d(p,y,x,g){let m=y.isScene===!0?y.background:null;m&&m.isTexture&&(m=t.get(m));let b=n.xr,v=b.getSession&&b.getSession();v&&v.environmentBlendMode==="additive"&&(m=null),m===null?f(s,o):m&&m.isColor&&(f(m,1),g=!0),(n.autoClear||g)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),m&&(m.isCubeTexture||m.isWebGLCubeRenderTarget||m.isWebGLCubeRenderTargetTexture||m.mapping===Fs)?(c===void 0&&(c=new Yt(new dr(1,1,1),new Me({name:"BackgroundCubeMaterial",uniforms:xs(on.cube.uniforms),vertexShader:on.cube.vertexShader,fragmentShader:on.cube.fragmentShader,side:oe,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(w,_,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),m.isWebGLCubeRenderTarget&&(m=m.texture),c.material.uniforms.envMap.value=m,c.material.uniforms.flipEnvMap.value=m.isCubeTexture?-1:1,(l!==m||u!==m.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,l=m,u=m.version,h=n.toneMapping),p.unshift(c,c.geometry,c.material,0,0,null)):m&&m.isTexture&&(a===void 0&&(a=new Yt(new bs(2,2),new Me({name:"BackgroundMaterial",uniforms:xs(on.background.uniforms),vertexShader:on.background.vertexShader,fragmentShader:on.background.fragmentShader,side:Os,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(a)),a.material.uniforms.t2D.value=m,m.matrixAutoUpdate===!0&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),(l!==m||u!==m.version||h!==n.toneMapping)&&(a.material.needsUpdate=!0,l=m,u=m.version,h=n.toneMapping),p.unshift(a,a.geometry,a.material,0,0,null))}function f(p,y){e.buffers.color.setClear(p.r,p.g,p.b,y,r)}return{getClearColor:function(){return s},setClearColor:function(p,y){s.set(p),o=y!==void 0?y:1,f(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(p){o=p,f(s,o)},render:d}}function XM(n,t,e,i){let r=n.getParameter(34921),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},c=y(null),l=c;function u(z,P,R,U,j){let Z=!1;if(o){let K=p(U,R,P);l!==K&&(l=K,d(l.object)),Z=x(U,j),Z&&g(U,j)}else{let K=P.wireframe===!0;(l.geometry!==U.id||l.program!==R.id||l.wireframe!==K)&&(l.geometry=U.id,l.program=R.id,l.wireframe=K,Z=!0)}z.isInstancedMesh===!0&&(Z=!0),j!==null&&e.update(j,34963),Z&&(A(z,P,R,U),j!==null&&n.bindBuffer(34963,e.get(j).buffer))}function h(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function d(z){return i.isWebGL2?n.bindVertexArray(z):s.bindVertexArrayOES(z)}function f(z){return i.isWebGL2?n.deleteVertexArray(z):s.deleteVertexArrayOES(z)}function p(z,P,R){let U=R.wireframe===!0,j=a[z.id];j===void 0&&(j={},a[z.id]=j);let Z=j[P.id];Z===void 0&&(Z={},j[P.id]=Z);let K=Z[U];return K===void 0&&(K=y(h()),Z[U]=K),K}function y(z){let P=[],R=[],U=[];for(let j=0;j<r;j++)P[j]=0,R[j]=0,U[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:R,attributeDivisors:U,object:z,attributes:{},index:null}}function x(z,P){let R=l.attributes,U=z.attributes;if(Object.keys(R).length!==Object.keys(U).length)return!0;for(let j in U){let Z=R[j],K=U[j];if(Z===void 0||Z.attribute!==K||Z.data!==K.data)return!0}return l.index!==P}function g(z,P){let R={},U=z.attributes;for(let j in U){let Z=U[j],K={};K.attribute=Z,Z.data&&(K.data=Z.data),R[j]=K}l.attributes=R,l.index=P}function m(){let z=l.newAttributes;for(let P=0,R=z.length;P<R;P++)z[P]=0}function b(z){v(z,0)}function v(z,P){let R=l.newAttributes,U=l.enabledAttributes,j=l.attributeDivisors;R[z]=1,U[z]===0&&(n.enableVertexAttribArray(z),U[z]=1),j[z]!==P&&((i.isWebGL2?n:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](z,P),j[z]=P)}function w(){let z=l.newAttributes,P=l.enabledAttributes;for(let R=0,U=P.length;R<U;R++)P[R]!==z[R]&&(n.disableVertexAttribArray(R),P[R]=0)}function _(z,P,R,U,j,Z){i.isWebGL2===!0&&(R===5124||R===5125)?n.vertexAttribIPointer(z,P,R,j,Z):n.vertexAttribPointer(z,P,R,U,j,Z)}function A(z,P,R,U){if(i.isWebGL2===!1&&(z.isInstancedMesh||U.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;m();let j=U.attributes,Z=R.getAttributes(),K=P.defaultAttributeValues;for(let ut in Z){let it=Z[ut];if(it>=0){let St=j[ut];if(St!==void 0){let wt=St.normalized,Ht=St.itemSize,V=e.get(St);if(V===void 0)continue;let re=V.buffer,vt=V.type,It=V.bytesPerElement;if(St.isInterleavedBufferAttribute){let Mt=St.data,Ot=Mt.stride,Et=St.offset;Mt&&Mt.isInstancedInterleavedBuffer?(v(it,Mt.meshPerAttribute),U._maxInstanceCount===void 0&&(U._maxInstanceCount=Mt.meshPerAttribute*Mt.count)):b(it),n.bindBuffer(34962,re),_(it,Ht,vt,wt,Ot*It,Et*It)}else St.isInstancedBufferAttribute?(v(it,St.meshPerAttribute),U._maxInstanceCount===void 0&&(U._maxInstanceCount=St.meshPerAttribute*St.count)):b(it),n.bindBuffer(34962,re),_(it,Ht,vt,wt,0,0)}else if(ut==="instanceMatrix"){let wt=e.get(z.instanceMatrix);if(wt===void 0)continue;let Ht=wt.buffer,V=wt.type;v(it+0,1),v(it+1,1),v(it+2,1),v(it+3,1),n.bindBuffer(34962,Ht),n.vertexAttribPointer(it+0,4,V,!1,64,0),n.vertexAttribPointer(it+1,4,V,!1,64,16),n.vertexAttribPointer(it+2,4,V,!1,64,32),n.vertexAttribPointer(it+3,4,V,!1,64,48)}else if(ut==="instanceColor"){let wt=e.get(z.instanceColor);if(wt===void 0)continue;let Ht=wt.buffer,V=wt.type;v(it,1),n.bindBuffer(34962,Ht),n.vertexAttribPointer(it,3,V,!1,12,0)}else if(K!==void 0){let wt=K[ut];if(wt!==void 0)switch(wt.length){case 2:n.vertexAttrib2fv(it,wt);break;case 3:n.vertexAttrib3fv(it,wt);break;case 4:n.vertexAttrib4fv(it,wt);break;default:n.vertexAttrib1fv(it,wt)}}}}w()}function I(){O();for(let z in a){let P=a[z];for(let R in P){let U=P[R];for(let j in U)f(U[j].object),delete U[j];delete P[R]}delete a[z]}}function D(z){if(a[z.id]===void 0)return;let P=a[z.id];for(let R in P){let U=P[R];for(let j in U)f(U[j].object),delete U[j];delete P[R]}delete a[z.id]}function N(z){for(let P in a){let R=a[P];if(R[z.id]===void 0)continue;let U=R[z.id];for(let j in U)f(U[j].object),delete U[j];delete R[z.id]}}function O(){F(),l!==c&&(l=c,d(l.object))}function F(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:u,reset:O,resetDefaultState:F,dispose:I,releaseStatesOfGeometry:D,releaseStatesOfProgram:N,initAttributes:m,enableAttribute:b,disableUnusedAttributes:w}}function qM(n,t,e,i){let r=i.isWebGL2,s;function o(l){s=l}function a(l,u){n.drawArrays(s,l,u),e.update(u,s,1)}function c(l,u,h){if(h===0)return;let d,f;if(r)d=n,f="drawArraysInstanced";else if(d=t.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,l,u,h),e.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=c}function YM(n,t,e){let i;function r(){if(i!==void 0)return i;let _=t.get("EXT_texture_filter_anisotropic");return _!==null?i=n.getParameter(_.MAX_TEXTURE_MAX_ANISOTROPY_EXT):i=0,i}function s(_){if(_==="highp"){if(n.getShaderPrecisionFormat(35633,36338).precision>0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";_="mediump"}return _==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&n instanceof WebGL2ComputeRenderingContext,a=e.precision!==void 0?e.precision:"highp",c=s(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);let l=e.logarithmicDepthBuffer===!0,u=n.getParameter(34930),h=n.getParameter(35660),d=n.getParameter(3379),f=n.getParameter(34076),p=n.getParameter(34921),y=n.getParameter(36347),x=n.getParameter(36348),g=n.getParameter(36349),m=h>0,b=o||!!t.get("OES_texture_float"),v=m&&b,w=o?n.getParameter(36183):0;return{isWebGL2:o,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:g,vertexTextures:m,floatFragmentTextures:b,floatVertexTextures:v,maxSamples:w}}function ZM(n){let t=this,e=null,i=0,r=!1,s=!1,o=new Ge,a=new pe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,f){let p=h.length!==0||d||i!==0||r;return r=d,e=u(h,f,0),i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,l()},this.setState=function(h,d,f){let p=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,g=n.get(h);if(!r||p===null||p.length===0||s&&!x)s?u(null):l();else{let m=s?0:i,b=m*4,v=g.clippingState||null;c.value=v,v=u(p,d,b,f);for(let w=0;w!==b;++w)v[w]=e[w];g.clippingState=v,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=m}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(h,d,f,p){let y=h!==null?h.length:0,x=null;if(y!==0){if(x=c.value,p!==!0||x===null){let g=f+y*4,m=d.matrixWorldInverse;a.getNormalMatrix(m),(x===null||x.length<g)&&(x=new Float32Array(g));for(let b=0,v=f;b!==y;++b,v+=4)o.copy(h[b]).applyMatrix4(m,a),o.normal.toArray(x,v),x[v+3]=o.constant}c.value=x,c.needsUpdate=!0}return t.numPlanes=y,t.numIntersection=0,x}}function JM(n){let t=new WeakMap;function e(s,o){return o===Vc?s.mapping=ba:o===Wc&&(s.mapping=_a),s}function i(s){if(s&&s.isTexture){let o=s.mapping;if(o===Vc||o===Wc)if(t.has(s)){let a=t.get(s).texture;return e(a,s.mapping)}else{let a=s.image;if(a&&a.height>0){let c=n.getRenderList(),l=n.getRenderTarget(),u=n.getRenderState(),h=new Li(a.height/2);return h.fromEquirectangularTexture(n,s),t.set(s,h),n.setRenderTarget(l),n.setRenderList(c),n.setRenderState(u),e(h.texture,s.mapping)}else return null}}return s}function r(){t=new WeakMap}return{get:i,dispose:r}}function $M(n){let t={};return{has:function(e){if(t[e]!==void 0)return t[e]!==null;let i;switch(e){case"WEBGL_depth_texture":i=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=n.getExtension(e)}return t[e]=i,i!==null},get:function(e){return this.has(e)||console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t[e]}}}function QM(n,t,e,i){let r=new WeakMap,s=new WeakMap;function o(h){let d=h.target,f=r.get(d);f.index!==null&&t.remove(f.index);for(let y in f.attributes)t.remove(f.attributes[y]);d.removeEventListener("dispose",o),r.delete(d);let p=s.get(f);p&&(t.remove(p),s.delete(f)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function a(h,d){let f=r.get(d);return f||(d.addEventListener("dispose",o),d.isBufferGeometry?f=d:d.isGeometry&&(d._bufferGeometry===void 0&&(d._bufferGeometry=new yt().setFromObject(h)),f=d._bufferGeometry),r.set(d,f),e.memory.geometries++,f)}function c(h){let d=h.attributes;for(let p in d)t.update(d[p],34962);let f=h.morphAttributes;for(let p in f){let y=f[p];for(let x=0,g=y.length;x<g;x++)t.update(y[x],34962)}}function l(h){let d=[],f=h.index,p=h.attributes.position,y=0;if(f!==null){let m=f.array;y=f.version;for(let b=0,v=m.length;b<v;b+=3){let w=m[b+0],_=m[b+1],A=m[b+2];d.push(w,_,_,A,A,w)}}else{let m=p.array;y=p.version;for(let b=0,v=m.length/3-1;b<v;b+=3){let w=b+0,_=b+1,A=b+2;d.push(w,_,_,A,A,w)}}let x=new(Jy(d)>65535?fr:ur)(d,1);x.version=y;let g=s.get(h);g&&t.remove(g),s.set(h,x)}function u(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version<f.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function KM(n,t,e,i){let r=i.isWebGL2,s;function o(d){s=d}let a,c;function l(d){a=d.type,c=d.bytesPerElement}function u(d,f){n.drawElements(s,f,a,d*c),e.update(f,s,1)}function h(d,f,p){if(p===0)return;let y,x;if(r)y=n,x="drawElementsInstanced";else if(y=t.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[x](s,f,a,d*c,p),e.update(f,s,p)}this.setMode=o,this.setIndex=l,this.render=u,this.renderInstances=h}function t1(n){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(e.calls++,o){case 4:e.triangles+=a*(s/3);break;case 1:e.lines+=a*(s/2);break;case 3:e.lines+=a*(s-1);break;case 2:e.lines+=a*s;break;case 0:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:i}}function e1(n,t){return n[0]-t[0]}function n1(n,t){return Math.abs(t[1])-Math.abs(n[1])}function i1(n){let t={},e=new Float32Array(8),i=[];for(let s=0;s<8;s++)i[s]=[s,0];function r(s,o,a,c){let l=s.morphTargetInfluences,u=l===void 0?0:l.length,h=t[o.id];if(h===void 0){h=[];for(let x=0;x<u;x++)h[x]=[x,0];t[o.id]=h}for(let x=0;x<u;x++){let g=h[x];g[0]=x,g[1]=l[x]}h.sort(n1);for(let x=0;x<8;x++)x<u&&h[x][1]?(i[x][0]=h[x][0],i[x][1]=h[x][1]):(i[x][0]=Number.MAX_SAFE_INTEGER,i[x][1]=0);i.sort(e1);let d=a.morphTargets&&o.morphAttributes.position,f=a.morphNormals&&o.morphAttributes.normal,p=0;for(let x=0;x<8;x++){let g=i[x],m=g[0],b=g[1];m!==Number.MAX_SAFE_INTEGER&&b?(d&&o.getAttribute("morphTarget"+x)!==d[m]&&o.setAttribute("morphTarget"+x,d[m]),f&&o.getAttribute("morphNormal"+x)!==f[m]&&o.setAttribute("morphNormal"+x,f[m]),e[x]=b,p+=b):(d&&o.getAttribute("morphTarget"+x)!==void 0&&o.deleteAttribute("morphTarget"+x),f&&o.getAttribute("morphNormal"+x)!==void 0&&o.deleteAttribute("morphNormal"+x),e[x]=0)}let y=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(n,"morphTargetBaseInfluence",y),c.getUniforms().setValue(n,"morphTargetInfluences",e)}return{update:r}}function r1(n,t,e,i){let r=new WeakMap;function s(a){let c=i.render.frame,l=a.geometry,u=t.get(a,l);return r.get(u)!==c&&(l.isGeometry&&u.updateFromObject(a),t.update(u),r.set(u,c)),a.isInstancedMesh&&(e.update(a.instanceMatrix,34962),a.instanceColor!==null&&e.update(a.instanceColor,34962)),u}function o(){r=new WeakMap}return{update:s,dispose:o}}function Kn(n,t,e,i,r,s,o,a,c,l){n=n!==void 0?n:[],t=t!==void 0?t:ba,o=o!==void 0?o:Mi,Gt.call(this,n,t,e,i,r,s,o,a,c,l),this.flipY=!1}Kn.prototype=Object.create(Gt.prototype);Kn.prototype.constructor=Kn;Kn.prototype.isCubeTexture=!0;Object.defineProperty(Kn.prototype,"images",{get:function(){return this.image},set:function(n){this.image=n}});function _s(n,t,e,i){Gt.call(this,null),this.image={data:n||null,width:t||1,height:e||1,depth:i||1},this.magFilter=ae,this.minFilter=ae,this.wrapR=_e,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}_s.prototype=Object.create(Gt.prototype);_s.prototype.constructor=_s;_s.prototype.isDataTexture2DArray=!0;function ws(n,t,e,i){Gt.call(this,null),this.image={data:n||null,width:t||1,height:e||1,depth:i||1},this.magFilter=ae,this.minFilter=ae,this.wrapR=_e,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}ws.prototype=Object.create(Gt.prototype);ws.prototype.constructor=ws;ws.prototype.isDataTexture3D=!0;var tx=new Gt,s1=new _s,o1=new ws,ex=new Kn,Sm=[],Em=[],Tm=new Float32Array(16),Am=new Float32Array(9),Cm=new Float32Array(4);function Bs(n,t,e){let i=n[0];if(i<=0||i>0)return n;let r=t*e,s=Sm[r];if(s===void 0&&(s=new Float32Array(r),Sm[r]=s),t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,n[o].toArray(s,a)}return s}function qe(n,t){if(n.length!==t.length)return!1;for(let e=0,i=n.length;e<i;e++)if(n[e]!==t[e])return!1;return!0}function Be(n,t){for(let e=0,i=t.length;e<i;e++)n[e]=t[e]}function nx(n,t){let e=Em[t];e===void 0&&(e=new Int32Array(t),Em[t]=e);for(let i=0;i!==t;++i)e[i]=n.allocateTextureUnit();return e}function a1(n,t){let e=this.cache;e[0]!==t&&(n.uniform1f(this.addr,t),e[0]=t)}function c1(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(n.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(qe(e,t))return;n.uniform2fv(this.addr,t),Be(e,t)}}function l1(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(n.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(n.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(qe(e,t))return;n.uniform3fv(this.addr,t),Be(e,t)}}function h1(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(n.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(qe(e,t))return;n.uniform4fv(this.addr,t),Be(e,t)}}function u1(n,t){let e=this.cache,i=t.elements;if(i===void 0){if(qe(e,t))return;n.uniformMatrix2fv(this.addr,!1,t),Be(e,t)}else{if(qe(e,i))return;Cm.set(i),n.uniformMatrix2fv(this.addr,!1,Cm),Be(e,i)}}function f1(n,t){let e=this.cache,i=t.elements;if(i===void 0){if(qe(e,t))return;n.uniformMatrix3fv(this.addr,!1,t),Be(e,t)}else{if(qe(e,i))return;Am.set(i),n.uniformMatrix3fv(this.addr,!1,Am),Be(e,i)}}function d1(n,t){let e=this.cache,i=t.elements;if(i===void 0){if(qe(e,t))return;n.uniformMatrix4fv(this.addr,!1,t),Be(e,t)}else{if(qe(e,i))return;Tm.set(i),n.uniformMatrix4fv(this.addr,!1,Tm),Be(e,i)}}function p1(n,t,e){let i=this.cache,r=e.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),e.safeSetTexture2D(t||tx,r)}function m1(n,t,e){let i=this.cache,r=e.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),e.setTexture2DArray(t||s1,r)}function g1(n,t,e){let i=this.cache,r=e.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),e.setTexture3D(t||o1,r)}function y1(n,t,e){let i=this.cache,r=e.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),e.safeSetTextureCube(t||ex,r)}function x1(n,t){let e=this.cache;e[0]!==t&&(n.uniform1i(this.addr,t),e[0]=t)}function v1(n,t){let e=this.cache;qe(e,t)||(n.uniform2iv(this.addr,t),Be(e,t))}function b1(n,t){let e=this.cache;qe(e,t)||(n.uniform3iv(this.addr,t),Be(e,t))}function _1(n,t){let e=this.cache;qe(e,t)||(n.uniform4iv(this.addr,t),Be(e,t))}function w1(n,t){let e=this.cache;e[0]!==t&&(n.uniform1ui(this.addr,t),e[0]=t)}function M1(n){switch(n){case 5126:return a1;case 35664:return c1;case 35665:return l1;case 35666:return h1;case 35674:return u1;case 35675:return f1;case 35676:return d1;case 5124:case 35670:return x1;case 35667:case 35671:return v1;case 35668:case 35672:return b1;case 35669:case 35673:return _1;case 5125:return w1;case 35678:case 36198:case 36298:case 36306:case 35682:return p1;case 35679:case 36299:case 36307:return g1;case 35680:case 36300:case 36308:case 36293:return y1;case 36289:case 36303:case 36311:case 36292:return m1}}function S1(n,t){n.uniform1fv(this.addr,t)}function E1(n,t){n.uniform1iv(this.addr,t)}function T1(n,t){n.uniform2iv(this.addr,t)}function A1(n,t){n.uniform3iv(this.addr,t)}function C1(n,t){n.uniform4iv(this.addr,t)}function L1(n,t){let e=Bs(t,this.size,2);n.uniform2fv(this.addr,e)}function P1(n,t){let e=Bs(t,this.size,3);n.uniform3fv(this.addr,e)}function R1(n,t){let e=Bs(t,this.size,4);n.uniform4fv(this.addr,e)}function I1(n,t){let e=Bs(t,this.size,4);n.uniformMatrix2fv(this.addr,!1,e)}function D1(n,t){let e=Bs(t,this.size,9);n.uniformMatrix3fv(this.addr,!1,e)}function O1(n,t){let e=Bs(t,this.size,16);n.uniformMatrix4fv(this.addr,!1,e)}function F1(n,t,e){let i=t.length,r=nx(e,i);n.uniform1iv(this.addr,r);for(let s=0;s!==i;++s)e.safeSetTexture2D(t[s]||tx,r[s])}function z1(n,t,e){let i=t.length,r=nx(e,i);n.uniform1iv(this.addr,r);for(let s=0;s!==i;++s)e.safeSetTextureCube(t[s]||ex,r[s])}function N1(n){switch(n){case 5126:return S1;case 35664:return L1;case 35665:return P1;case 35666:return R1;case 35674:return I1;case 35675:return D1;case 35676:return O1;case 5124:case 35670:return E1;case 35667:case 35671:return T1;case 35668:case 35672:return A1;case 35669:case 35673:return C1;case 35678:case 36198:case 36298:case 36306:case 35682:return F1;case 35680:case 36300:case 36308:case 36293:return z1}}function B1(n,t,e){this.id=n,this.addr=e,this.cache=[],this.setValue=M1(t.type)}function ix(n,t,e){this.id=n,this.addr=e,this.cache=[],this.size=t.size,this.setValue=N1(t.type)}ix.prototype.updateCache=function(n){let t=this.cache;n instanceof Float32Array&&t.length!==n.length&&(this.cache=new Float32Array(n.length)),Be(t,n)};function rx(n){this.id=n,this.seq=[],this.map={}}rx.prototype.setValue=function(n,t,e){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let o=i[r];o.setValue(n,t[o.id],e)}};var tf=/([\w\d_]+)(\])?(\[|\.)?/g;function Lm(n,t){n.seq.push(t),n.map[t.id]=t}function U1(n,t,e){let i=n.name,r=i.length;for(tf.lastIndex=0;;){let s=tf.exec(i),o=tf.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){Lm(e,l===void 0?new B1(a,n,t):new ix(a,n,t));break}else{let h=e.map[a];h===void 0&&(h=new rx(a),Lm(e,h)),e=h}}}function Si(n,t){this.seq=[],this.map={};let e=n.getProgramParameter(t,35718);for(let i=0;i<e;++i){let r=n.getActiveUniform(t,i),s=n.getUniformLocation(t,r.name);U1(r,s,this)}}Si.prototype.setValue=function(n,t,e,i){let r=this.map[t];r!==void 0&&r.setValue(n,e,i)};Si.prototype.setOptional=function(n,t,e){let i=t[e];i!==void 0&&this.setValue(n,e,i)};Si.upload=function(n,t,e,i){for(let r=0,s=t.length;r!==s;++r){let o=t[r],a=e[o.id];a.needsUpdate!==!1&&o.setValue(n,a.value,i)}};Si.seqWithValue=function(n,t){let e=[];for(let i=0,r=n.length;i!==r;++i){let s=n[i];s.id in t&&e.push(s)}return e};function Pm(n,t,e){let i=n.createShader(t);return n.shaderSource(i,e),n.compileShader(i),i}var k1=0;function G1(n){let t=n.split(`
`);for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join(`
`)}function sx(n){switch(n){case we:return["Linear","( value )"];case Ma:return["sRGB","( value )"];case Zl:return["RGBE","( value )"];case yd:return["RGBM","( value, 7.0 )"];case xd:return["RGBM","( value, 16.0 )"];case vd:return["RGBD","( value, 256.0 )"];case Yl:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case Wy:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function Rm(n,t,e){let i=n.getShaderParameter(t,35713),r=n.getShaderInfoLog(t).trim();if(i&&r==="")return"";let s=n.getShaderSource(t);return"THREE.WebGLShader: gl.getShaderInfoLog() "+e+`
`+r+G1(s)}function po(n,t){let e=sx(t);return"vec4 "+n+"( vec4 value ) { return "+e[0]+"ToLinear"+e[1]+"; }"}function H1(n,t){let e=sx(t);return"vec4 "+n+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function V1(n,t){let e;switch(t){case Vg:e="Linear";break;case Wg:e="Reinhard";break;case jg:e="OptimizedCineon";break;case Xg:e="ACESFilmic";break;case qg:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+n+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function W1(n){return[n.extensionDerivatives||n.envMapCubeUV||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(bo).join(`
`)}function j1(n){let t=[];for(let e in n){let i=n[e];i!==!1&&t.push("#define "+e+" "+i)}return t.join(`
`)}function X1(n,t){let e={},i=n.getProgramParameter(t,35721);for(let r=0;r<i;r++){let o=n.getActiveAttrib(t,r).name;e[o]=n.getAttribLocation(t,o)}return e}function bo(n){return n!==""}function Im(n,t){return n.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dm(n,t){return n.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var q1=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pf(n){return n.replace(q1,Y1)}function Y1(n,t){let e=Pt[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return Pf(e)}var Z1=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,J1=/#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 Om(n){return n.replace(J1,ox).replace(Z1,$1)}function $1(n,t,e,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ox(n,t,e,i)}function ox(n,t,e,i){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Fm(n){let t="precision "+n.precision+` float;
precision `+n.precision+" int;";return n.precision==="highp"?t+=`
#define HIGH_PRECISION`:n.precision==="mediump"?t+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(t+=`
#define LOW_PRECISION`),t}function Q1(n){let t="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===ud?t="SHADOWMAP_TYPE_PCF":n.shadowMapType===_g?t="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===cs&&(t="SHADOWMAP_TYPE_VSM"),t}function K1(n){let t="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case ba:case _a:t="ENVMAP_TYPE_CUBE";break;case Fs:case wa:t="ENVMAP_TYPE_CUBE_UV";break}return t}function tS(n){let t="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case _a:case wa:t="ENVMAP_MODE_REFRACTION";break}return t}function eS(n){let t="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case va:t="ENVMAP_BLENDING_MULTIPLY";break;case Gg:t="ENVMAP_BLENDING_MIX";break;case Hg:t="ENVMAP_BLENDING_ADD";break}return t}function nS(n,t,e,i){let r=n.getContext(),s=e.defines,o=e.vertexShader,a=e.fragmentShader,c=Q1(e),l=K1(e),u=tS(e),h=eS(e),d=n.gammaFactor>0?n.gammaFactor:1,f=e.isWebGL2?"":W1(e),p=j1(s),y=r.createProgram(),x,g,m=e.glslVersion?"#version "+e.glslVersion+`
`:"";e.isRawShaderMaterial?(x=[p].filter(bo).join(`
`),x.length>0&&(x+=`
`),g=[f,p].filter(bo).join(`
`),g.length>0&&(g+=`
`)):(x=[Fm(e),"#define SHADER_NAME "+e.shaderName,p,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+e.maxBones,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.displacementMap&&e.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.useVertexTexture?"#define BONE_TEXTURE":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#ifdef USE_COLOR","	attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","	attribute vec3 morphTarget0;","	attribute vec3 morphTarget1;","	attribute vec3 morphTarget2;","	attribute vec3 morphTarget3;","	#ifdef USE_MORPHNORMALS","		attribute vec3 morphNormal0;","		attribute vec3 morphNormal1;","		attribute vec3 morphNormal2;","		attribute vec3 morphNormal3;","	#else","		attribute vec3 morphTarget4;","		attribute vec3 morphTarget5;","		attribute vec3 morphTarget6;","		attribute vec3 morphTarget7;","	#endif","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(bo).join(`
`),g=[f,Fm(e),"#define SHADER_NAME "+e.shaderName,p,e.alphaTest?"#define ALPHATEST "+e.alphaTest+(e.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.sheen?"#define USE_SHEEN":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==ar?"#define TONE_MAPPING":"",e.toneMapping!==ar?Pt.tonemapping_pars_fragment:"",e.toneMapping!==ar?V1("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",Pt.encodings_pars_fragment,e.map?po("mapTexelToLinear",e.mapEncoding):"",e.matcap?po("matcapTexelToLinear",e.matcapEncoding):"",e.envMap?po("envMapTexelToLinear",e.envMapEncoding):"",e.emissiveMap?po("emissiveMapTexelToLinear",e.emissiveMapEncoding):"",e.lightMap?po("lightMapTexelToLinear",e.lightMapEncoding):"",H1("linearToOutputTexel",e.outputEncoding),e.depthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
`].filter(bo).join(`
`)),o=Pf(o),o=Im(o,e),o=Dm(o,e),a=Pf(a),a=Im(a,e),a=Dm(a,e),o=Om(o),a=Om(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(m=`#version 300 es
`,x=["#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+x,g=["#define varying in",e.glslVersion===Af?"":"out highp vec4 pc_fragColor;",e.glslVersion===Af?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+g);let b=m+x+o,v=m+g+a,w=Pm(r,35633,b),_=Pm(r,35632,v);if(r.attachShader(y,w),r.attachShader(y,_),e.index0AttributeName!==void 0?r.bindAttribLocation(y,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y),n.debug.checkShaderErrors){let D=r.getProgramInfoLog(y).trim(),N=r.getShaderInfoLog(w).trim(),O=r.getShaderInfoLog(_).trim(),F=!0,z=!0;if(r.getProgramParameter(y,35714)===!1){F=!1;let P=Rm(r,w,"vertex"),R=Rm(r,_,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(y,35715),"gl.getProgramInfoLog",D,P,R)}else D!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",D):(N===""||O==="")&&(z=!1);z&&(this.diagnostics={runnable:F,programLog:D,vertexShader:{log:N,prefix:x},fragmentShader:{log:O,prefix:g}})}r.deleteShader(w),r.deleteShader(_);let A;this.getUniforms=function(){return A===void 0&&(A=new Si(r,y)),A};let I;return this.getAttributes=function(){return I===void 0&&(I=X1(r,y)),I},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.name=e.shaderName,this.id=k1++,this.cacheKey=t,this.usedTimes=1,this.program=y,this.vertexShader=w,this.fragmentShader=_,this}function iS(n,t,e,i,r,s){let o=[],a=i.isWebGL2,c=i.logarithmicDepthBuffer,l=i.floatVertexTextures,u=i.maxVertexUniforms,h=i.vertexTextures,d=i.precision,f={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"},p=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function y(_){let I=_.skeleton.bones;if(l)return 1024;{let N=Math.floor((u-20)/4),O=Math.min(N,I.length);return O<I.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+I.length+" bones. This GPU supports "+O+"."),0):O}}function x(_){let A;return _?_.isTexture?A=_.encoding:_.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),A=_.texture.encoding):A=we,A}function g(_,A,I,D,N){let O=D.fog,F=_.isMeshStandardMaterial?D.environment:null,z=t.get(_.envMap||F),P=f[_.type],R=N.isSkinnedMesh?y(N):0;_.precision!==null&&(d=i.getMaxPrecision(_.precision),d!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));let U,j;if(P){let ut=on[P];U=ut.vertexShader,j=ut.fragmentShader}else U=_.vertexShader,j=_.fragmentShader;let Z=n.getRenderTarget();return{isWebGL2:a,shaderID:P,shaderName:_.type,vertexShader:U,fragmentShader:j,defines:_.defines,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,instancing:N.isInstancedMesh===!0,instancingColor:N.isInstancedMesh===!0&&N.instanceColor!==null,supportsVertexTextures:h,outputEncoding:Z!==null?x(Z.texture):n.outputEncoding,map:!!_.map,mapEncoding:x(_.map),matcap:!!_.matcap,matcapEncoding:x(_.matcap),envMap:!!z,envMapMode:z&&z.mapping,envMapEncoding:x(z),envMapCubeUV:!!z&&(z.mapping===Fs||z.mapping===wa),lightMap:!!_.lightMap,lightMapEncoding:x(_.lightMap),aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,emissiveMapEncoding:x(_.emissiveMap),bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===qy,tangentSpaceNormalMap:_.normalMapType===Er,clearcoatMap:!!_.clearcoatMap,clearcoatRoughnessMap:!!_.clearcoatRoughnessMap,clearcoatNormalMap:!!_.clearcoatNormalMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,alphaMap:!!_.alphaMap,gradientMap:!!_.gradientMap,sheen:!!_.sheen,transmissionMap:!!_.transmissionMap,combine:_.combine,vertexTangents:_.normalMap&&_.vertexTangents,vertexColors:_.vertexColors,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.displacementMap||!!_.transmissionMap,uvsVertexOnly:!(_.map||_.bumpMap||_.normalMap||_.specularMap||_.alphaMap||_.emissiveMap||_.roughnessMap||_.metalnessMap||_.clearcoatNormalMap||_.transmissionMap)&&!!_.displacementMap,fog:!!O,useFog:_.fog,fogExp2:O&&O.isFogExp2,flatShading:_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:c,skinning:_.skinning&&R>0,maxBones:R,useVertexTexture:l,morphTargets:_.morphTargets,morphNormals:_.morphNormals,maxMorphTargets:n.maxMorphTargets,maxMorphNormals:n.maxMorphNormals,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:_.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:_.toneMapped?n.toneMapping:ar,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,alphaTest:_.alphaTest,doubleSided:_.side===xa,flipSided:_.side===oe,depthPacking:_.depthPacking!==void 0?_.depthPacking:!1,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||e.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||e.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||e.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function m(_){let A=[];if(_.shaderID?A.push(_.shaderID):(A.push(_.fragmentShader),A.push(_.vertexShader)),_.defines!==void 0)for(let I in _.defines)A.push(I),A.push(_.defines[I]);if(_.isRawShaderMaterial===!1){for(let I=0;I<p.length;I++)A.push(_[p[I]]);A.push(n.outputEncoding),A.push(n.gammaFactor)}return A.push(_.customProgramCacheKey),A.join()}function b(_){let A=f[_.type],I;if(A){let D=on[A];I=Qy.clone(D.uniforms)}else I=_.uniforms;return I}function v(_,A){let I;for(let D=0,N=o.length;D<N;D++){let O=o[D];if(O.cacheKey===A){I=O,++I.usedTimes;break}}return I===void 0&&(I=new nS(n,A,_,r),o.push(I)),I}function w(_){if(--_.usedTimes===0){let A=o.indexOf(_);o[A]=o[o.length-1],o.pop(),_.destroy()}}return{getParameters:g,getProgramCacheKey:m,getUniforms:b,acquireProgram:v,releaseProgram:w,programs:o}}function rS(){let n=new WeakMap;function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function e(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:t,remove:e,update:i,dispose:r}}function sS(n,t){return n.groupOrder!==t.groupOrder?n.groupOrder-t.groupOrder:n.renderOrder!==t.renderOrder?n.renderOrder-t.renderOrder:n.program!==t.program?n.program.id-t.program.id:n.material.id!==t.material.id?n.material.id-t.material.id:n.z!==t.z?n.z-t.z:n.id-t.id}function oS(n,t){return n.groupOrder!==t.groupOrder?n.groupOrder-t.groupOrder:n.renderOrder!==t.renderOrder?n.renderOrder-t.renderOrder:n.z!==t.z?t.z-n.z:n.id-t.id}function zm(n){let t=[],e=0,i=[],r=[],s={id:-1};function o(){e=0,i.length=0,r.length=0}function a(d,f,p,y,x,g){let m=t[e],b=n.get(p);return m===void 0?(m={id:d.id,object:d,geometry:f,material:p,program:b.program||s,groupOrder:y,renderOrder:d.renderOrder,z:x,group:g},t[e]=m):(m.id=d.id,m.object=d,m.geometry=f,m.material=p,m.program=b.program||s,m.groupOrder=y,m.renderOrder=d.renderOrder,m.z=x,m.group=g),e++,m}function c(d,f,p,y,x,g){let m=a(d,f,p,y,x,g);(p.transparent===!0?r:i).push(m)}function l(d,f,p,y,x,g){let m=a(d,f,p,y,x,g);(p.transparent===!0?r:i).unshift(m)}function u(d,f){i.length>1&&i.sort(d||sS),r.length>1&&r.sort(f||oS)}function h(){for(let d=e,f=t.length;d<f;d++){let p=t[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.program=null,p.group=null}}return{opaque:i,transparent:r,init:o,push:c,unshift:l,finish:h,sort:u}}function aS(n){let t=new WeakMap;function e(r,s){let o=t.get(r),a;return o===void 0?(a=new zm(n),t.set(r,new WeakMap),t.get(r).set(s,a)):(a=o.get(s),a===void 0&&(a=new zm(n),o.set(s,a))),a}function i(){t=new WeakMap}return{get:e,dispose:i}}function cS(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new M,color:new lt};break;case"SpotLight":e={position:new M,direction:new M,color:new lt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new M,color:new lt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new M,skyColor:new lt,groundColor:new lt};break;case"RectAreaLight":e={color:new lt,position:new M,halfWidth:new M,halfHeight:new M};break}return n[t.id]=e,e}}}function lS(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new G,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[t.id]=e,e}}}var hS=0;function uS(n,t){return(t.castShadow?1:0)-(n.castShadow?1:0)}function fS(){let n=new cS,t=lS(),e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let a=0;a<9;a++)e.probe.push(new M);let i=new M,r=new At,s=new At;function o(a,c,l){let u=0,h=0,d=0;for(let A=0;A<9;A++)e.probe[A].set(0,0,0);let f=0,p=0,y=0,x=0,g=0,m=0,b=0,v=0,w=l.matrixWorldInverse;a.sort(uS);for(let A=0,I=a.length;A<I;A++){let D=a[A],N=D.color,O=D.intensity,F=D.distance,z=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)u+=N.r*O,h+=N.g*O,d+=N.b*O;else if(D.isLightProbe)for(let P=0;P<9;P++)e.probe[P].addScaledVector(D.sh.coefficients[P],O);else if(D.isDirectionalLight){let P=n.get(D);if(P.color.copy(D.color).multiplyScalar(D.intensity),P.direction.setFromMatrixPosition(D.matrixWorld),i.setFromMatrixPosition(D.target.matrixWorld),P.direction.sub(i),P.direction.transformDirection(w),D.castShadow){let R=D.shadow,U=t.get(D);U.shadowBias=R.bias,U.shadowNormalBias=R.normalBias,U.shadowRadius=R.radius,U.shadowMapSize=R.mapSize,e.directionalShadow[f]=U,e.directionalShadowMap[f]=z,e.directionalShadowMatrix[f]=D.shadow.matrix,m++}e.directional[f]=P,f++}else if(D.isSpotLight){let P=n.get(D);if(P.position.setFromMatrixPosition(D.matrixWorld),P.position.applyMatrix4(w),P.color.copy(N).multiplyScalar(O),P.distance=F,P.direction.setFromMatrixPosition(D.matrixWorld),i.setFromMatrixPosition(D.target.matrixWorld),P.direction.sub(i),P.direction.transformDirection(w),P.coneCos=Math.cos(D.angle),P.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),P.decay=D.decay,D.castShadow){let R=D.shadow,U=t.get(D);U.shadowBias=R.bias,U.shadowNormalBias=R.normalBias,U.shadowRadius=R.radius,U.shadowMapSize=R.mapSize,e.spotShadow[y]=U,e.spotShadowMap[y]=z,e.spotShadowMatrix[y]=D.shadow.matrix,v++}e.spot[y]=P,y++}else if(D.isRectAreaLight){let P=n.get(D);P.color.copy(N).multiplyScalar(O),P.position.setFromMatrixPosition(D.matrixWorld),P.position.applyMatrix4(w),s.identity(),r.copy(D.matrixWorld),r.premultiply(w),s.extractRotation(r),P.halfWidth.set(D.width*.5,0,0),P.halfHeight.set(0,D.height*.5,0),P.halfWidth.applyMatrix4(s),P.halfHeight.applyMatrix4(s),e.rectArea[x]=P,x++}else if(D.isPointLight){let P=n.get(D);if(P.position.setFromMatrixPosition(D.matrixWorld),P.position.applyMatrix4(w),P.color.copy(D.color).multiplyScalar(D.intensity),P.distance=D.distance,P.decay=D.decay,D.castShadow){let R=D.shadow,U=t.get(D);U.shadowBias=R.bias,U.shadowNormalBias=R.normalBias,U.shadowRadius=R.radius,U.shadowMapSize=R.mapSize,U.shadowCameraNear=R.camera.near,U.shadowCameraFar=R.camera.far,e.pointShadow[p]=U,e.pointShadowMap[p]=z,e.pointShadowMatrix[p]=D.shadow.matrix,b++}e.point[p]=P,p++}else if(D.isHemisphereLight){let P=n.get(D);P.direction.setFromMatrixPosition(D.matrixWorld),P.direction.transformDirection(w),P.direction.normalize(),P.skyColor.copy(D.color).multiplyScalar(O),P.groundColor.copy(D.groundColor).multiplyScalar(O),e.hemi[g]=P,g++}}x>0&&(e.rectAreaLTC1=ct.LTC_1,e.rectAreaLTC2=ct.LTC_2),e.ambient[0]=u,e.ambient[1]=h,e.ambient[2]=d;let _=e.hash;(_.directionalLength!==f||_.pointLength!==p||_.spotLength!==y||_.rectAreaLength!==x||_.hemiLength!==g||_.numDirectionalShadows!==m||_.numPointShadows!==b||_.numSpotShadows!==v)&&(e.directional.length=f,e.spot.length=y,e.rectArea.length=x,e.point.length=p,e.hemi.length=g,e.directionalShadow.length=m,e.directionalShadowMap.length=m,e.pointShadow.length=b,e.pointShadowMap.length=b,e.spotShadow.length=v,e.spotShadowMap.length=v,e.directionalShadowMatrix.length=m,e.pointShadowMatrix.length=b,e.spotShadowMatrix.length=v,_.directionalLength=f,_.pointLength=p,_.spotLength=y,_.rectAreaLength=x,_.hemiLength=g,_.numDirectionalShadows=m,_.numPointShadows=b,_.numSpotShadows=v,e.version=hS++)}return{setup:o,state:e}}function Nm(){let n=new fS,t=[],e=[];function i(){t.length=0,e.length=0}function r(c){t.push(c)}function s(c){e.push(c)}function o(c){n.setup(t,e,c)}return{init:i,state:{lightsArray:t,shadowsArray:e,lights:n},setupLights:o,pushLight:r,pushShadow:s}}function dS(){let n=new WeakMap;function t(i,r){let s;return n.has(i)===!1?(s=new Nm,n.set(i,new WeakMap),n.get(i).set(r,s)):n.get(i).has(r)===!1?(s=new Nm,n.get(i).set(r,s)):s=n.get(i).get(r),s}function e(){n=new WeakMap}return{get:t,dispose:e}}function Pi(n){bt.call(this),this.type="MeshDepthMaterial",this.depthPacking=jy,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(n)}Pi.prototype=Object.create(bt.prototype);Pi.prototype.constructor=Pi;Pi.prototype.isMeshDepthMaterial=!0;Pi.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.depthPacking=n.depthPacking,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this};function Ri(n){bt.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new M,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(n)}Ri.prototype=Object.create(bt.prototype);Ri.prototype.constructor=Ri;Ri.prototype.isMeshDistanceMaterial=!0;Ri.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.referencePosition.copy(n.referencePosition),this.nearDistance=n.nearDistance,this.farDistance=n.farDistance,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this};var pS=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	float mean = 0.0;
	float squared_mean = 0.0;
	float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
	for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
		#ifdef HORIZONAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 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, i ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean * HALF_SAMPLE_RATE;
	squared_mean = squared_mean * HALF_SAMPLE_RATE;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`,mS=`void main() {
	gl_Position = vec4( position, 1.0 );
}`;function ax(n,t,e){let i=new mr,r=new G,s=new G,o=new Bt,a=[],c=[],l={},u={0:oe,1:Os,2:xa},h=new Me({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:mS,fragmentShader:pS}),d=h.clone();d.defines.HORIZONAL_PASS=1;let f=new yt;f.setAttribute("position",new xt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Yt(f,h),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ud,this.render=function(w,_,A){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||w.length===0)return;let I=n.getRenderTarget(),D=n.getActiveCubeFace(),N=n.getActiveMipmapLevel(),O=n.state;O.setBlending($n),O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);for(let F=0,z=w.length;F<z;F++){let P=w[F],R=P.shadow;if(R.autoUpdate===!1&&R.needsUpdate===!1)continue;if(R===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}r.copy(R.mapSize);let U=R.getFrameExtents();if(r.multiply(U),s.copy(R.mapSize),(r.x>e||r.y>e)&&(r.x>e&&(s.x=Math.floor(e/U.x),r.x=s.x*U.x,R.mapSize.x=s.x),r.y>e&&(s.y=Math.floor(e/U.y),r.y=s.y*U.y,R.mapSize.y=s.y)),R.map===null&&!R.isPointLightShadow&&this.type===cs){let Z={minFilter:he,magFilter:he,format:Fe};R.map=new ze(r.x,r.y,Z),R.map.texture.name=P.name+".shadowMap",R.mapPass=new ze(r.x,r.y,Z),R.camera.updateProjectionMatrix()}if(R.map===null){let Z={minFilter:ae,magFilter:ae,format:Fe};R.map=new ze(r.x,r.y,Z),R.map.texture.name=P.name+".shadowMap",R.camera.updateProjectionMatrix()}n.setRenderTarget(R.map),n.clear();let j=R.getViewportCount();for(let Z=0;Z<j;Z++){let K=R.getViewport(Z);o.set(s.x*K.x,s.y*K.y,s.x*K.z,s.y*K.w),O.viewport(o),R.updateMatrices(P,Z),i=R.getFrustum(),v(_,A,R.camera,P,this.type)}!R.isPointLightShadow&&this.type===cs&&x(R,A),R.needsUpdate=!1}y.needsUpdate=!1,n.setRenderTarget(I,D,N)};function x(w,_){let A=t.update(p);h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,n.setRenderTarget(w.mapPass),n.clear(),n.renderBufferDirect(_,null,A,h,p,null),d.uniforms.shadow_pass.value=w.mapPass.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,n.setRenderTarget(w.map),n.clear(),n.renderBufferDirect(_,null,A,d,p,null)}function g(w,_,A){let I=w<<0|_<<1|A<<2,D=a[I];return D===void 0&&(D=new Pi({depthPacking:Xy,morphTargets:w,skinning:_}),a[I]=D),D}function m(w,_,A){let I=w<<0|_<<1|A<<2,D=c[I];return D===void 0&&(D=new Ri({morphTargets:w,skinning:_}),c[I]=D),D}function b(w,_,A,I,D,N,O){let F=null,z=g,P=w.customDepthMaterial;if(I.isPointLight===!0&&(z=m,P=w.customDistanceMaterial),P===void 0){let R=!1;A.morphTargets===!0&&(R=_.morphAttributes&&_.morphAttributes.position&&_.morphAttributes.position.length>0);let U=!1;w.isSkinnedMesh===!0&&(A.skinning===!0?U=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",w));let j=w.isInstancedMesh===!0;F=z(R,U,j)}else F=P;if(n.localClippingEnabled&&A.clipShadows===!0&&A.clippingPlanes.length!==0){let R=F.uuid,U=A.uuid,j=l[R];j===void 0&&(j={},l[R]=j);let Z=j[U];Z===void 0&&(Z=F.clone(),j[U]=Z),F=Z}return F.visible=A.visible,F.wireframe=A.wireframe,O===cs?F.side=A.shadowSide!==null?A.shadowSide:A.side:F.side=A.shadowSide!==null?A.shadowSide:u[A.side],F.clipShadows=A.clipShadows,F.clippingPlanes=A.clippingPlanes,F.clipIntersection=A.clipIntersection,F.wireframeLinewidth=A.wireframeLinewidth,F.linewidth=A.linewidth,I.isPointLight===!0&&F.isMeshDistanceMaterial===!0&&(F.referencePosition.setFromMatrixPosition(I.matrixWorld),F.nearDistance=D,F.farDistance=N),F}function v(w,_,A,I,D){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&D===cs)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let F=t.update(w),z=w.material;if(Array.isArray(z)){let P=F.groups;for(let R=0,U=P.length;R<U;R++){let j=P[R],Z=z[j.materialIndex];if(Z&&Z.visible){let K=b(w,F,Z,I,A.near,A.far,D);n.renderBufferDirect(A,null,F,K,w,j)}}}else if(z.visible){let P=b(w,F,z,I,A.near,A.far,D);n.renderBufferDirect(A,null,F,P,w,null)}}let O=w.children;for(let F=0,z=O.length;F<z;F++)v(O[F],_,A,I,D)}}function gS(n,t,e){let i=e.isWebGL2;function r(){let L=!1,Y=new Bt,rt=null,ft=new Bt(0,0,0,0);return{setMask:function(tt){rt!==tt&&!L&&(n.colorMask(tt,tt,tt,tt),rt=tt)},setLocked:function(tt){L=tt},setClear:function(tt,C,J,ht,nt){nt===!0&&(tt*=ht,C*=ht,J*=ht),Y.set(tt,C,J,ht),ft.equals(Y)===!1&&(n.clearColor(tt,C,J,ht),ft.copy(Y))},reset:function(){L=!1,rt=null,ft.set(-1,0,0,0)}}}function s(){let L=!1,Y=null,rt=null,ft=null;return{setTest:function(tt){tt?ut(2929):it(2929)},setMask:function(tt){Y!==tt&&!L&&(n.depthMask(tt),Y=tt)},setFunc:function(tt){if(rt!==tt){if(tt)switch(tt){case Og:n.depthFunc(512);break;case Fg:n.depthFunc(519);break;case zg:n.depthFunc(513);break;case Hc:n.depthFunc(515);break;case Ng:n.depthFunc(514);break;case Bg:n.depthFunc(518);break;case Ug:n.depthFunc(516);break;case kg:n.depthFunc(517);break;default:n.depthFunc(515)}else n.depthFunc(515);rt=tt}},setLocked:function(tt){L=tt},setClear:function(tt){ft!==tt&&(n.clearDepth(tt),ft=tt)},reset:function(){L=!1,Y=null,rt=null,ft=null}}}function o(){let L=!1,Y=null,rt=null,ft=null,tt=null,C=null,J=null,ht=null,nt=null;return{setTest:function(mt){L||(mt?ut(2960):it(2960))},setMask:function(mt){Y!==mt&&!L&&(n.stencilMask(mt),Y=mt)},setFunc:function(mt,Ft,se){(rt!==mt||ft!==Ft||tt!==se)&&(n.stencilFunc(mt,Ft,se),rt=mt,ft=Ft,tt=se)},setOp:function(mt,Ft,se){(C!==mt||J!==Ft||ht!==se)&&(n.stencilOp(mt,Ft,se),C=mt,J=Ft,ht=se)},setLocked:function(mt){L=mt},setClear:function(mt){nt!==mt&&(n.clearStencil(mt),nt=mt)},reset:function(){L=!1,Y=null,rt=null,ft=null,tt=null,C=null,J=null,ht=null,nt=null}}}let a=new r,c=new s,l=new o,u={},h=null,d=null,f=null,p=null,y=null,x=null,g=null,m=null,b=null,v=!1,w=null,_=null,A=null,I=null,D=null,N=n.getParameter(35661),O=!1,F=0,z=n.getParameter(7938);z.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL\ ([0-9])/.exec(z)[1]),O=F>=1):z.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(z)[1]),O=F>=2);let P=null,R={},U=new Bt,j=new Bt;function Z(L,Y,rt){let ft=new Uint8Array(4),tt=n.createTexture();n.bindTexture(L,tt),n.texParameteri(L,10241,9728),n.texParameteri(L,10240,9728);for(let C=0;C<rt;C++)n.texImage2D(Y+C,0,6408,1,1,0,6408,5121,ft);return tt}let K={};K[3553]=Z(3553,3553,1),K[34067]=Z(34067,34069,6),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),ut(2929),c.setFunc(Hc),vt(!1),It(uf),ut(2884),V($n);function ut(L){u[L]!==!0&&(n.enable(L),u[L]=!0)}function it(L){u[L]!==!1&&(n.disable(L),u[L]=!1)}function St(L){return h!==L?(n.useProgram(L),h=L,!0):!1}let wt={[rr]:32774,[Mg]:32778,[Sg]:32779};if(i)wt[mf]=32775,wt[gf]=32776;else{let L=t.get("EXT_blend_minmax");L!==null&&(wt[mf]=L.MIN_EXT,wt[gf]=L.MAX_EXT)}let Ht={[Eg]:0,[Tg]:1,[Ag]:768,[dd]:770,[Dg]:776,[Rg]:774,[Lg]:772,[Cg]:769,[pd]:771,[Ig]:775,[Pg]:773};function V(L,Y,rt,ft,tt,C,J,ht){if(L===$n){d&&(it(3042),d=!1);return}if(d||(ut(3042),d=!0),L!==wg){if(L!==f||ht!==v){if((p!==rr||g!==rr)&&(n.blendEquation(32774),p=rr,g=rr),ht)switch(L){case ds:n.blendFuncSeparate(1,771,1,771);break;case ff:n.blendFunc(1,1);break;case df:n.blendFuncSeparate(0,0,769,771);break;case pf:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}else switch(L){case ds:n.blendFuncSeparate(770,771,1,771);break;case ff:n.blendFunc(770,1);break;case df:n.blendFunc(0,769);break;case pf:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}y=null,x=null,m=null,b=null,f=L,v=ht}return}tt=tt||Y,C=C||rt,J=J||ft,(Y!==p||tt!==g)&&(n.blendEquationSeparate(wt[Y],wt[tt]),p=Y,g=tt),(rt!==y||ft!==x||C!==m||J!==b)&&(n.blendFuncSeparate(Ht[rt],Ht[ft],Ht[C],Ht[J]),y=rt,x=ft,m=C,b=J),f=L,v=null}function re(L,Y){L.side===xa?it(2884):ut(2884);let rt=L.side===oe;Y&&(rt=!rt),vt(rt),L.blending===ds&&L.transparent===!1?V($n):V(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.premultipliedAlpha),c.setFunc(L.depthFunc),c.setTest(L.depthTest),c.setMask(L.depthWrite),a.setMask(L.colorWrite);let ft=L.stencilWrite;l.setTest(ft),ft&&(l.setMask(L.stencilWriteMask),l.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),l.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Ot(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits)}function vt(L){w!==L&&(L?n.frontFace(2304):n.frontFace(2305),w=L)}function It(L){L!==vg?(ut(2884),L!==_&&(L===uf?n.cullFace(1029):L===bg?n.cullFace(1028):n.cullFace(1032))):it(2884),_=L}function Mt(L){L!==A&&(O&&n.lineWidth(L),A=L)}function Ot(L,Y,rt){L?(ut(32823),(I!==Y||D!==rt)&&(n.polygonOffset(Y,rt),I=Y,D=rt)):it(32823)}function Et(L){L?ut(3089):it(3089)}function X(L){L===void 0&&(L=33984+N-1),P!==L&&(n.activeTexture(L),P=L)}function Q(L,Y){P===null&&X();let rt=R[P];rt===void 0&&(rt={type:void 0,texture:void 0},R[P]=rt),(rt.type!==L||rt.texture!==Y)&&(n.bindTexture(L,Y||K[L]),rt.type=L,rt.texture=Y)}function et(){let L=R[P];L!==void 0&&L.type!==void 0&&(n.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function pt(){try{n.compressedTexImage2D.apply(n,arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ot(){try{n.texImage2D.apply(n,arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function S(){try{n.texImage3D.apply(n,arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function T(L){U.equals(L)===!1&&(n.scissor(L.x,L.y,L.z,L.w),U.copy(L))}function q(L){j.equals(L)===!1&&(n.viewport(L.x,L.y,L.z,L.w),j.copy(L))}function W(){u={},P=null,R={},h=null,f=null,w=null,_=null,a.reset(),c.reset(),l.reset()}return{buffers:{color:a,depth:c,stencil:l},enable:ut,disable:it,useProgram:St,setBlending:V,setMaterial:re,setFlipSided:vt,setCullFace:It,setLineWidth:Mt,setPolygonOffset:Ot,setScissorTest:Et,activeTexture:X,bindTexture:Q,unbindTexture:et,compressedTexImage2D:pt,texImage2D:ot,texImage3D:S,scissor:T,viewport:q,reset:W}}function yS(n,t,e,i,r,s,o){let a=r.isWebGL2,c=r.maxTextures,l=r.maxCubemapSize,u=r.maxTextureSize,h=r.maxSamples,d=new WeakMap,f,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(S,T){return p?new OffscreenCanvas(S,T):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function x(S,T,q,W){let L=1;if((S.width>W||S.height>W)&&(L=W/Math.max(S.width,S.height)),L<1||T===!0)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap){let Y=T?_t.floorPowerOfTwo:Math.floor,rt=Y(L*S.width),ft=Y(L*S.height);f===void 0&&(f=y(rt,ft));let tt=q?y(rt,ft):f;return tt.width=rt,tt.height=ft,tt.getContext("2d").drawImage(S,0,0,rt,ft),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+S.width+"x"+S.height+") to ("+rt+"x"+ft+")."),tt}else return"data"in S&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+S.width+"x"+S.height+")."),S;return S}function g(S){return _t.isPowerOfTwo(S.width)&&_t.isPowerOfTwo(S.height)}function m(S){return a?!1:S.wrapS!==_e||S.wrapT!==_e||S.minFilter!==ae&&S.minFilter!==he}function b(S,T){return S.generateMipmaps&&T&&S.minFilter!==ae&&S.minFilter!==he}function v(S,T,q,W){n.generateMipmap(S);let L=i.get(T);L.__maxMipLevel=Math.log(Math.max(q,W))*Math.LOG2E}function w(S,T,q){if(a===!1)return T;if(S!==null){if(n[S]!==void 0)return n[S];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let W=T;return T===6403&&(q===5126&&(W=33326),q===5131&&(W=33325),q===5121&&(W=33321)),T===6407&&(q===5126&&(W=34837),q===5131&&(W=34843),q===5121&&(W=32849)),T===6408&&(q===5126&&(W=34836),q===5131&&(W=34842),q===5121&&(W=32856)),(W===33325||W===33326||W===34842||W===34836)&&t.get("EXT_color_buffer_float"),W}function _(S){return S===ae||S===jc||S===Xc?9728:9729}function A(S){let T=S.target;T.removeEventListener("dispose",A),D(T),T.isVideoTexture&&d.delete(T),o.memory.textures--}function I(S){let T=S.target;T.removeEventListener("dispose",I),N(T),o.memory.textures--}function D(S){let T=i.get(S);T.__webglInit!==void 0&&(n.deleteTexture(T.__webglTexture),i.remove(S))}function N(S){let T=i.get(S),q=i.get(S.texture);if(S){if(q.__webglTexture!==void 0&&n.deleteTexture(q.__webglTexture),S.depthTexture&&S.depthTexture.dispose(),S.isWebGLCubeRenderTarget)for(let W=0;W<6;W++)n.deleteFramebuffer(T.__webglFramebuffer[W]),T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer[W]);else n.deleteFramebuffer(T.__webglFramebuffer),T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer),T.__webglMultisampledFramebuffer&&n.deleteFramebuffer(T.__webglMultisampledFramebuffer),T.__webglColorRenderbuffer&&n.deleteRenderbuffer(T.__webglColorRenderbuffer),T.__webglDepthRenderbuffer&&n.deleteRenderbuffer(T.__webglDepthRenderbuffer);i.remove(S.texture),i.remove(S)}}let O=0;function F(){O=0}function z(){let S=O;return S>=c&&console.warn("THREE.WebGLTextures: Trying to use "+S+" texture units while this GPU supports only "+c),O+=1,S}function P(S,T){let q=i.get(S);if(S.isVideoTexture&&X(S),S.version>0&&q.__version!==S.version){let W=S.image;if(W===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(W.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{wt(q,S,T);return}}e.activeTexture(33984+T),e.bindTexture(3553,q.__webglTexture)}function R(S,T){let q=i.get(S);if(S.version>0&&q.__version!==S.version){wt(q,S,T);return}e.activeTexture(33984+T),e.bindTexture(35866,q.__webglTexture)}function U(S,T){let q=i.get(S);if(S.version>0&&q.__version!==S.version){wt(q,S,T);return}e.activeTexture(33984+T),e.bindTexture(32879,q.__webglTexture)}function j(S,T){if(S.image.length!==6)return;let q=i.get(S);if(S.version>0&&q.__version!==S.version){St(q,S),e.activeTexture(33984+T),e.bindTexture(34067,q.__webglTexture),n.pixelStorei(37440,S.flipY);let W=S&&(S.isCompressedTexture||S.image[0].isCompressedTexture),L=S.image[0]&&S.image[0].isDataTexture,Y=[];for(let nt=0;nt<6;nt++)!W&&!L?Y[nt]=x(S.image[nt],!1,!0,l):Y[nt]=L?S.image[nt].image:S.image[nt];let rt=Y[0],ft=g(rt)||a,tt=s.convert(S.format),C=s.convert(S.type),J=w(S.internalFormat,tt,C);it(34067,S,ft);let ht;if(W){for(let nt=0;nt<6;nt++){ht=Y[nt].mipmaps;for(let mt=0;mt<ht.length;mt++){let Ft=ht[mt];S.format!==Fe&&S.format!==Mi?tt!==null?e.compressedTexImage2D(34069+nt,mt,J,Ft.width,Ft.height,0,Ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):e.texImage2D(34069+nt,mt,J,Ft.width,Ft.height,0,tt,C,Ft.data)}}q.__maxMipLevel=ht.length-1}else{ht=S.mipmaps;for(let nt=0;nt<6;nt++)if(L){e.texImage2D(34069+nt,0,J,Y[nt].width,Y[nt].height,0,tt,C,Y[nt].data);for(let mt=0;mt<ht.length;mt++){let se=ht[mt].image[nt].image;e.texImage2D(34069+nt,mt+1,J,se.width,se.height,0,tt,C,se.data)}}else{e.texImage2D(34069+nt,0,J,tt,C,Y[nt]);for(let mt=0;mt<ht.length;mt++){let Ft=ht[mt];e.texImage2D(34069+nt,mt+1,J,tt,C,Ft.image[nt])}}q.__maxMipLevel=ht.length}b(S,ft)&&v(34067,S,rt.width,rt.height),q.__version=S.version,S.onUpdate&&S.onUpdate(S)}else e.activeTexture(33984+T),e.bindTexture(34067,q.__webglTexture)}function Z(S,T){e.activeTexture(33984+T),e.bindTexture(34067,i.get(S).__webglTexture)}let K={[Ao]:10497,[_e]:33071,[Co]:33648},ut={[ae]:9728,[jc]:9984,[Xc]:9986,[he]:9729,[md]:9985,[zs]:9987};function it(S,T,q){q?(n.texParameteri(S,10242,K[T.wrapS]),n.texParameteri(S,10243,K[T.wrapT]),(S===32879||S===35866)&&n.texParameteri(S,32882,K[T.wrapR]),n.texParameteri(S,10240,ut[T.magFilter]),n.texParameteri(S,10241,ut[T.minFilter])):(n.texParameteri(S,10242,33071),n.texParameteri(S,10243,33071),(S===32879||S===35866)&&n.texParameteri(S,32882,33071),(T.wrapS!==_e||T.wrapT!==_e)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(S,10240,_(T.magFilter)),n.texParameteri(S,10241,_(T.minFilter)),T.minFilter!==ae&&T.minFilter!==he&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));let W=t.get("EXT_texture_filter_anisotropic");if(W){if(T.type===Zn&&t.get("OES_texture_float_linear")===null||T.type===Po&&(a||t.get("OES_texture_half_float_linear"))===null)return;(T.anisotropy>1||i.get(T).__currentAnisotropy)&&(n.texParameterf(S,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(T.anisotropy,r.getMaxAnisotropy())),i.get(T).__currentAnisotropy=T.anisotropy)}}function St(S,T){S.__webglInit===void 0&&(S.__webglInit=!0,T.addEventListener("dispose",A),S.__webglTexture=n.createTexture(),o.memory.textures++)}function wt(S,T,q){let W=3553;T.isDataTexture2DArray&&(W=35866),T.isDataTexture3D&&(W=32879),St(S,T),e.activeTexture(33984+q),e.bindTexture(W,S.__webglTexture),n.pixelStorei(37440,T.flipY),n.pixelStorei(37441,T.premultiplyAlpha),n.pixelStorei(3317,T.unpackAlignment);let L=m(T)&&g(T.image)===!1,Y=x(T.image,L,!1,u),rt=g(Y)||a,ft=s.convert(T.format),tt=s.convert(T.type),C=w(T.internalFormat,ft,tt);it(W,T,rt);let J,ht=T.mipmaps;if(T.isDepthTexture)C=6402,a?T.type===Zn?C=36012:T.type===_o?C=33190:T.type===ps?C=35056:C=33189:T.type===Zn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),T.format===cr&&C===6402&&T.type!==Lo&&T.type!==_o&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),T.type=Lo,tt=s.convert(T.type)),T.format===gs&&C===6402&&(C=34041,T.type!==ps&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),T.type=ps,tt=s.convert(T.type))),e.texImage2D(3553,0,C,Y.width,Y.height,0,ft,tt,null);else if(T.isDataTexture)if(ht.length>0&&rt){for(let nt=0,mt=ht.length;nt<mt;nt++)J=ht[nt],e.texImage2D(3553,nt,C,J.width,J.height,0,ft,tt,J.data);T.generateMipmaps=!1,S.__maxMipLevel=ht.length-1}else e.texImage2D(3553,0,C,Y.width,Y.height,0,ft,tt,Y.data),S.__maxMipLevel=0;else if(T.isCompressedTexture){for(let nt=0,mt=ht.length;nt<mt;nt++)J=ht[nt],T.format!==Fe&&T.format!==Mi?ft!==null?e.compressedTexImage2D(3553,nt,C,J.width,J.height,0,J.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):e.texImage2D(3553,nt,C,J.width,J.height,0,ft,tt,J.data);S.__maxMipLevel=ht.length-1}else if(T.isDataTexture2DArray)e.texImage3D(35866,0,C,Y.width,Y.height,Y.depth,0,ft,tt,Y.data),S.__maxMipLevel=0;else if(T.isDataTexture3D)e.texImage3D(32879,0,C,Y.width,Y.height,Y.depth,0,ft,tt,Y.data),S.__maxMipLevel=0;else if(ht.length>0&&rt){for(let nt=0,mt=ht.length;nt<mt;nt++)J=ht[nt],e.texImage2D(3553,nt,C,ft,tt,J);T.generateMipmaps=!1,S.__maxMipLevel=ht.length-1}else e.texImage2D(3553,0,C,ft,tt,Y),S.__maxMipLevel=0;b(T,rt)&&v(W,T,Y.width,Y.height),S.__version=T.version,T.onUpdate&&T.onUpdate(T)}function Ht(S,T,q,W){let L=s.convert(T.texture.format),Y=s.convert(T.texture.type),rt=w(T.texture.internalFormat,L,Y);e.texImage2D(W,0,rt,T.width,T.height,0,L,Y,null),n.bindFramebuffer(36160,S),n.framebufferTexture2D(36160,q,W,i.get(T.texture).__webglTexture,0),n.bindFramebuffer(36160,null)}function V(S,T,q){if(n.bindRenderbuffer(36161,S),T.depthBuffer&&!T.stencilBuffer){let W=33189;if(q){let L=T.depthTexture;L&&L.isDepthTexture&&(L.type===Zn?W=36012:L.type===_o&&(W=33190));let Y=Et(T);n.renderbufferStorageMultisample(36161,Y,W,T.width,T.height)}else n.renderbufferStorage(36161,W,T.width,T.height);n.framebufferRenderbuffer(36160,36096,36161,S)}else if(T.depthBuffer&&T.stencilBuffer){if(q){let W=Et(T);n.renderbufferStorageMultisample(36161,W,35056,T.width,T.height)}else n.renderbufferStorage(36161,34041,T.width,T.height);n.framebufferRenderbuffer(36160,33306,36161,S)}else{let W=s.convert(T.texture.format),L=s.convert(T.texture.type),Y=w(T.texture.internalFormat,W,L);if(q){let rt=Et(T);n.renderbufferStorageMultisample(36161,rt,Y,T.width,T.height)}else n.renderbufferStorage(36161,Y,T.width,T.height)}n.bindRenderbuffer(36161,null)}function re(S,T){if(T&&T.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,S),!(T.depthTexture&&T.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(T.depthTexture).__webglTexture||T.depthTexture.image.width!==T.width||T.depthTexture.image.height!==T.height)&&(T.depthTexture.image.width=T.width,T.depthTexture.image.height=T.height,T.depthTexture.needsUpdate=!0),P(T.depthTexture,0);let W=i.get(T.depthTexture).__webglTexture;if(T.depthTexture.format===cr)n.framebufferTexture2D(36160,36096,3553,W,0);else if(T.depthTexture.format===gs)n.framebufferTexture2D(36160,33306,3553,W,0);else throw new Error("Unknown depthTexture format")}function vt(S){let T=i.get(S),q=S.isWebGLCubeRenderTarget===!0;if(S.depthTexture){if(q)throw new Error("target.depthTexture not supported in Cube render targets");re(T.__webglFramebuffer,S)}else if(q){T.__webglDepthbuffer=[];for(let W=0;W<6;W++)n.bindFramebuffer(36160,T.__webglFramebuffer[W]),T.__webglDepthbuffer[W]=n.createRenderbuffer(),V(T.__webglDepthbuffer[W],S,!1)}else n.bindFramebuffer(36160,T.__webglFramebuffer),T.__webglDepthbuffer=n.createRenderbuffer(),V(T.__webglDepthbuffer,S,!1);n.bindFramebuffer(36160,null)}function It(S){let T=i.get(S),q=i.get(S.texture);S.addEventListener("dispose",I),q.__webglTexture=n.createTexture(),o.memory.textures++;let W=S.isWebGLCubeRenderTarget===!0,L=S.isWebGLMultisampleRenderTarget===!0,Y=g(S)||a;if(a&&S.texture.format===Mi&&(S.texture.type===Zn||S.texture.type===Po)&&(S.texture.format=Fe,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),W){T.__webglFramebuffer=[];for(let rt=0;rt<6;rt++)T.__webglFramebuffer[rt]=n.createFramebuffer()}else if(T.__webglFramebuffer=n.createFramebuffer(),L)if(a){T.__webglMultisampledFramebuffer=n.createFramebuffer(),T.__webglColorRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(36161,T.__webglColorRenderbuffer);let rt=s.convert(S.texture.format),ft=s.convert(S.texture.type),tt=w(S.texture.internalFormat,rt,ft),C=Et(S);n.renderbufferStorageMultisample(36161,C,tt,S.width,S.height),n.bindFramebuffer(36160,T.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064,36161,T.__webglColorRenderbuffer),n.bindRenderbuffer(36161,null),S.depthBuffer&&(T.__webglDepthRenderbuffer=n.createRenderbuffer(),V(T.__webglDepthRenderbuffer,S,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(W){e.bindTexture(34067,q.__webglTexture),it(34067,S.texture,Y);for(let rt=0;rt<6;rt++)Ht(T.__webglFramebuffer[rt],S,36064,34069+rt);b(S.texture,Y)&&v(34067,S.texture,S.width,S.height),e.bindTexture(34067,null)}else e.bindTexture(3553,q.__webglTexture),it(3553,S.texture,Y),Ht(T.__webglFramebuffer,S,36064,3553),b(S.texture,Y)&&v(3553,S.texture,S.width,S.height),e.bindTexture(3553,null);S.depthBuffer&&vt(S)}function Mt(S){let T=S.texture,q=g(S)||a;if(b(T,q)){let W=S.isWebGLCubeRenderTarget?34067:3553,L=i.get(T).__webglTexture;e.bindTexture(W,L),v(W,T,S.width,S.height),e.bindTexture(W,null)}}function Ot(S){if(S.isWebGLMultisampleRenderTarget)if(a){let T=i.get(S);n.bindFramebuffer(36008,T.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,T.__webglFramebuffer);let q=S.width,W=S.height,L=16384;S.depthBuffer&&(L|=256),S.stencilBuffer&&(L|=1024),n.blitFramebuffer(0,0,q,W,0,0,q,W,L,9728),n.bindFramebuffer(36160,T.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function Et(S){return a&&S.isWebGLMultisampleRenderTarget?Math.min(h,S.samples):0}function X(S){let T=o.render.frame;d.get(S)!==T&&(d.set(S,T),S.update())}let Q=!1,et=!1;function pt(S,T){S&&S.isWebGLRenderTarget&&(Q===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),Q=!0),S=S.texture),P(S,T)}function ot(S,T){S&&S.isWebGLCubeRenderTarget&&(et===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),et=!0),S=S.texture),S&&S.isCubeTexture||Array.isArray(S.image)&&S.image.length===6?j(S,T):Z(S,T)}this.allocateTextureUnit=z,this.resetTextureUnits=F,this.setTexture2D=P,this.setTexture2DArray=R,this.setTexture3D=U,this.setTextureCube=j,this.setTextureCubeDynamic=Z,this.setupRenderTarget=It,this.updateRenderTargetMipmap=Mt,this.updateMultisampleRenderTarget=Ot,this.safeSetTexture2D=pt,this.safeSetTextureCube=ot}function cx(n,t,e){let i=e.isWebGL2;function r(s){let o;if(s===Ns)return 5121;if(s===$g)return 32819;if(s===Qg)return 32820;if(s===Kg)return 33635;if(s===Yg)return 5120;if(s===Zg)return 5122;if(s===Lo)return 5123;if(s===Jg)return 5124;if(s===_o)return 5125;if(s===Zn)return 5126;if(s===Po)return i?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===ty)return 6406;if(s===Mi)return 6407;if(s===Fe)return 6408;if(s===ey)return 6409;if(s===ny)return 6410;if(s===cr)return 6402;if(s===gs)return 34041;if(s===ry)return 6403;if(s===sy)return 36244;if(s===oy)return 33319;if(s===ay)return 33320;if(s===cy)return 36248;if(s===ly)return 36249;if(s===yf||s===xf||s===vf||s===bf)if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===yf)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===xf)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===vf)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===bf)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===_f||s===wf||s===Mf||s===Sf)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===_f)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===wf)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Mf)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Sf)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===hy)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if((s===Ef||s===Tf)&&(o=t.get("WEBGL_compressed_texture_etc"),o!==null)){if(s===Ef)return o.COMPRESSED_RGB8_ETC2;if(s===Tf)return o.COMPRESSED_RGBA8_ETC2_EAC}if(s===uy||s===fy||s===dy||s===py||s===my||s===gy||s===yy||s===xy||s===vy||s===by||s===_y||s===wy||s===My||s===Sy||s===Ty||s===Ay||s===Cy||s===Ly||s===Py||s===Ry||s===Iy||s===Dy||s===Oy||s===Fy||s===zy||s===Ny||s===By||s===Uy)return o=t.get("WEBGL_compressed_texture_astc"),o!==null?s:null;if(s===Ey)return o=t.get("EXT_texture_compression_bptc"),o!==null?s:null;if(s===ps)return i?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:r}}function Yc(n){ne.call(this),this.cameras=n||[]}Yc.prototype=Object.assign(Object.create(ne.prototype),{constructor:Yc,isArrayCamera:!0});function wi(){dt.call(this),this.type="Group"}wi.prototype=Object.assign(Object.create(dt.prototype),{constructor:wi,isGroup:!0});function So(){this._targetRay=null,this._grip=null,this._hand=null}Object.assign(So.prototype,{constructor:So,getHandSpace:function(){if(this._hand===null&&(this._hand=new wi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(let n=0;n<=window.XRHand.LITTLE_PHALANX_TIP;n++){let t=new wi;t.matrixAutoUpdate=!1,t.visible=!1,this._hand.joints.push(t),this._hand.add(t)}return this._hand},getTargetRaySpace:function(){return this._targetRay===null&&(this._targetRay=new wi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return this._grip===null&&(this._grip=new wi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(n){return this._targetRay!==null&&this._targetRay.dispatchEvent(n),this._grip!==null&&this._grip.dispatchEvent(n),this._hand!==null&&this._hand.dispatchEvent(n),this},disconnect:function(n){return this.dispatchEvent({type:"disconnected",data:n}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},update:function(n,t,e){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(n)if(c&&n.hand){s=!0;for(let l=0;l<=window.XRHand.LITTLE_PHALANX_TIP;l++)if(n.hand[l]){let u=t.getJointPose(n.hand[l],e),h=c.joints[l];u!==null&&(h.matrix.fromArray(u.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.jointRadius=u.radius),h.visible=u!==null;let d=c.joints[window.XRHand.INDEX_PHALANX_TIP],f=c.joints[window.XRHand.THUMB_PHALANX_TIP],p=d.position.distanceTo(f.position),y=.02,x=.005;c.inputState.pinching&&p>y+x?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:n.handedness,target:this})):!c.inputState.pinching&&p<=y-x&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:n.handedness,target:this}))}}else o!==null&&(i=t.getPose(n.targetRaySpace,e),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale))),a!==null&&n.gripSpace&&(r=t.getPose(n.gripSpace,e),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return o!==null&&(o.visible=i!==null),a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),this}});function lx(n,t){let e=this,i=null,r=1,s=null,o="local-floor",a=null,c=[],l=new Map,u=new ne;u.layers.enable(1),u.viewport=new Bt;let h=new ne;h.layers.enable(2),h.viewport=new Bt;let d=[u,h],f=new Yc;f.layers.enable(1),f.layers.enable(2);let p=null,y=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let F=c[O];return F===void 0&&(F=new So,c[O]=F),F.getTargetRaySpace()},this.getControllerGrip=function(O){let F=c[O];return F===void 0&&(F=new So,c[O]=F),F.getGripSpace()},this.getHand=function(O){let F=c[O];return F===void 0&&(F=new So,c[O]=F),F.getHandSpace()};function x(O){let F=l.get(O.inputSource);F&&F.dispatchEvent({type:O.type})}function g(){l.forEach(function(O,F){O.disconnect(F)}),l.clear(),n.setFramebuffer(null),n.setRenderTarget(n.getRenderTarget()),N.stop(),e.isPresenting=!1,e.dispatchEvent({type:"sessionend"})}function m(O){s=O,N.setContext(i),N.start(),e.isPresenting=!0,e.dispatchEvent({type:"sessionstart"})}this.setFramebufferScaleFactor=function(O){r=O,e.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){o=O,e.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getSession=function(){return i},this.setSession=function(O){if(i=O,i!==null){i.addEventListener("select",x),i.addEventListener("selectstart",x),i.addEventListener("selectend",x),i.addEventListener("squeeze",x),i.addEventListener("squeezestart",x),i.addEventListener("squeezeend",x),i.addEventListener("end",g);let F=t.getContextAttributes();F.xrCompatible!==!0&&t.makeXRCompatible();let z={antialias:F.antialias,alpha:F.alpha,depth:F.depth,stencil:F.stencil,framebufferScaleFactor:r},P=new XRWebGLLayer(i,t,z);i.updateRenderState({baseLayer:P}),i.requestReferenceSpace(o).then(m),i.addEventListener("inputsourceschange",b)}};function b(O){let F=i.inputSources;for(let z=0;z<c.length;z++)l.set(F[z],c[z]);for(let z=0;z<O.removed.length;z++){let P=O.removed[z],R=l.get(P);R&&(R.dispatchEvent({type:"disconnected",data:P}),l.delete(P))}for(let z=0;z<O.added.length;z++){let P=O.added[z],R=l.get(P);R&&R.dispatchEvent({type:"connected",data:P})}}let v=new M,w=new M;function _(O,F,z){v.setFromMatrixPosition(F.matrixWorld),w.setFromMatrixPosition(z.matrixWorld);let P=v.distanceTo(w),R=F.projectionMatrix.elements,U=z.projectionMatrix.elements,j=R[14]/(R[10]-1),Z=R[14]/(R[10]+1),K=(R[9]+1)/R[5],ut=(R[9]-1)/R[5],it=(R[8]-1)/R[0],St=(U[8]+1)/U[0],wt=j*it,Ht=j*St,V=P/(-it+St),re=V*-it;F.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(re),O.translateZ(V),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.getInverse(O.matrixWorld);let vt=j+V,It=Z+V,Mt=wt-re,Ot=Ht+(P-re),Et=K*Z/It*vt,X=ut*Z/It*vt;O.projectionMatrix.makePerspective(Mt,Ot,Et,X,vt,It)}function A(O,F){F===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(F.matrixWorld,O.matrix),O.matrixWorldInverse.getInverse(O.matrixWorld)}this.getCamera=function(O){f.near=h.near=u.near=O.near,f.far=h.far=u.far=O.far,(p!==f.near||y!==f.far)&&(i.updateRenderState({depthNear:f.near,depthFar:f.far}),p=f.near,y=f.far);let F=O.parent,z=f.cameras;A(f,F);for(let R=0;R<z.length;R++)A(z[R],F);O.matrixWorld.copy(f.matrixWorld);let P=O.children;for(let R=0,U=P.length;R<U;R++)P[R].updateMatrixWorld(!0);return z.length===2?_(f,u,h):f.projectionMatrix.copy(u.projectionMatrix),f};let I=null;function D(O,F){if(a=F.getViewerPose(s),a!==null){let P=a.views,R=i.renderState.baseLayer;n.setFramebuffer(R.framebuffer);let U=!1;P.length!==f.cameras.length&&(f.cameras.length=0,U=!0);for(let j=0;j<P.length;j++){let Z=P[j],K=R.getViewport(Z),ut=d[j];ut.matrix.fromArray(Z.transform.matrix),ut.projectionMatrix.fromArray(Z.projectionMatrix),ut.viewport.set(K.x,K.y,K.width,K.height),j===0&&f.matrix.copy(ut.matrix),U===!0&&f.cameras.push(ut)}}let z=i.inputSources;for(let P=0;P<c.length;P++){let R=c[P],U=z[P];R.update(U,F,s)}I&&I(O,F)}let N=new Ky;N.setAnimationLoop(D),this.setAnimationLoop=function(O){I=O},this.dispose=function(){}}Object.assign(lx.prototype,Je.prototype);function xS(n){function t(g,m){g.fogColor.value.copy(m.color),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function e(g,m,b,v){m.isMeshBasicMaterial?i(g,m):m.isMeshLambertMaterial?(i(g,m),c(g,m)):m.isMeshToonMaterial?(i(g,m),u(g,m)):m.isMeshPhongMaterial?(i(g,m),l(g,m)):m.isMeshStandardMaterial?(i(g,m),m.isMeshPhysicalMaterial?d(g,m):h(g,m)):m.isMeshMatcapMaterial?(i(g,m),f(g,m)):m.isMeshDepthMaterial?(i(g,m),p(g,m)):m.isMeshDistanceMaterial?(i(g,m),y(g,m)):m.isMeshNormalMaterial?(i(g,m),x(g,m)):m.isLineBasicMaterial?(r(g,m),m.isLineDashedMaterial&&s(g,m)):m.isPointsMaterial?o(g,m,b,v):m.isSpriteMaterial?a(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function i(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.specularMap&&(g.specularMap.value=m.specularMap);let b=n.get(m).envMap;if(b){g.envMap.value=b,g.flipEnvMap.value=b.isCubeTexture?-1:1,g.reflectivity.value=m.reflectivity,g.refractionRatio.value=m.refractionRatio;let _=n.get(b).__maxMipLevel;_!==void 0&&(g.maxMipLevel.value=_)}m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap&&(v=m.clearcoatRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix));let w;m.aoMap?w=m.aoMap:m.lightMap&&(w=m.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),g.uv2Transform.value.copy(w.matrix))}function r(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function s(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,b,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*b,g.scale.value=v*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap);let w;m.map?w=m.map:m.alphaMap&&(w=m.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),g.uvTransform.value.copy(w.matrix))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap);let b;m.map?b=m.map:m.alphaMap&&(b=m.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uvTransform.value.copy(b.matrix))}function c(g,m){m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap)}function l(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===oe&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===oe&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===oe&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===oe&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias)}function h(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===oe&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===oe&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),n.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m){h(g,m),g.reflectivity.value=m.reflectivity,g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.sheen&&g.sheen.value.copy(m.sheen),m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===oe&&g.clearcoatNormalScale.value.negate()),g.transmission.value=m.transmission,m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap)}function f(g,m){m.matcap&&(g.matcap.value=m.matcap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===oe&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===oe&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias)}function p(g,m){m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias)}function y(g,m){m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}function x(g,m){m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===oe&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===oe&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias)}return{refreshFogUniforms:t,refreshMaterialUniforms:e}}function Ea(n){n=n||{};let t=n.canvas!==void 0?n.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),e=n.context!==void 0?n.context:null,i=n.alpha!==void 0?n.alpha:!1,r=n.depth!==void 0?n.depth:!0,s=n.stencil!==void 0?n.stencil:!0,o=n.antialias!==void 0?n.antialias:!1,a=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,c=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",u=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,h=null,d=null;this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=we,this.physicallyCorrectLights=!1,this.toneMapping=ar,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;let f=this,p=!1,y=null,x=0,g=0,m=null,b=null,v=-1,w=null,_=null,A=new Bt,I=new Bt,D=null,N=t.width,O=t.height,F=1,z=null,P=null,R=new Bt(0,0,N,O),U=new Bt(0,0,N,O),j=!1,Z=new mr,K=!1,ut=!1,it=new At,St=new M,wt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ht(){return m===null?F:1}let V=e;function re(E,k){for(let B=0;B<E.length;B++){let H=E[B],at=t.getContext(H,k);if(at!==null)return at}return null}try{let E={alpha:i,depth:r,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(t.addEventListener("webglcontextlost",Ft,!1),t.addEventListener("webglcontextrestored",se,!1),V===null){let k=["webgl2","webgl","experimental-webgl"];if(f.isWebGL1Renderer===!0&&k.shift(),V=re(k,E),V===null)throw re(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let vt,It,Mt,Ot,Et,X,Q,et,pt,ot,S,T,q,W,L,Y,rt,ft,tt,C,J;function ht(){vt=new $M(V),It=new YM(V,vt,n),It.isWebGL2===!1&&(vt.get("WEBGL_depth_texture"),vt.get("OES_texture_float"),vt.get("OES_texture_half_float"),vt.get("OES_texture_half_float_linear"),vt.get("OES_standard_derivatives"),vt.get("OES_element_index_uint"),vt.get("OES_vertex_array_object"),vt.get("ANGLE_instanced_arrays")),vt.get("OES_texture_float_linear"),C=new cx(V,vt,It),Mt=new gS(V,vt,It),Mt.scissor(I.copy(U).multiplyScalar(F).floor()),Mt.viewport(A.copy(R).multiplyScalar(F).floor()),Ot=new t1,Et=new rS,X=new yS(V,vt,Mt,Et,It,C,Ot),Q=new JM(f),et=new M_(V,It),J=new XM(V,vt,et,It),pt=new QM(V,et,Ot,J),ot=new r1(V,pt,et,Ot),rt=new i1(V),L=new ZM(Et),S=new iS(f,Q,vt,It,J,L),T=new xS(Et),q=new aS(Et),W=new dS,Y=new jM(f,Q,Mt,ot,a),ft=new qM(V,vt,Ot,It),tt=new KM(V,vt,Ot,It),Ot.programs=S.programs,f.capabilities=It,f.extensions=vt,f.properties=Et,f.renderLists=q,f.state=Mt,f.info=Ot}ht();let nt=new lx(f,V);this.xr=nt;let mt=new ax(f,ot,It.maxTextureSize);this.shadowMap=mt,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let E=vt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=vt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(E){E!==void 0&&(F=E,this.setSize(N,O,!1))},this.getSize=function(E){return E===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),E=new G),E.set(N,O)},this.setSize=function(E,k,B){if(nt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}N=E,O=k,t.width=Math.floor(E*F),t.height=Math.floor(k*F),B!==!1&&(t.style.width=E+"px",t.style.height=k+"px"),this.setViewport(0,0,E,k)},this.getDrawingBufferSize=function(E){return E===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),E=new G),E.set(N*F,O*F).floor()},this.setDrawingBufferSize=function(E,k,B){N=E,O=k,F=B,t.width=Math.floor(E*B),t.height=Math.floor(k*B),this.setViewport(0,0,E,k)},this.getCurrentViewport=function(E){return E===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),E=new Bt),E.copy(A)},this.getViewport=function(E){return E.copy(R)},this.setViewport=function(E,k,B,H){E.isVector4?R.set(E.x,E.y,E.z,E.w):R.set(E,k,B,H),Mt.viewport(A.copy(R).multiplyScalar(F).floor())},this.getScissor=function(E){return E.copy(U)},this.setScissor=function(E,k,B,H){E.isVector4?U.set(E.x,E.y,E.z,E.w):U.set(E,k,B,H),Mt.scissor(I.copy(U).multiplyScalar(F).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(E){Mt.setScissorTest(j=E)},this.setOpaqueSort=function(E){z=E},this.setTransparentSort=function(E){P=E},this.getClearColor=function(){return Y.getClearColor()},this.setClearColor=function(){Y.setClearColor.apply(Y,arguments)},this.getClearAlpha=function(){return Y.getClearAlpha()},this.setClearAlpha=function(){Y.setClearAlpha.apply(Y,arguments)},this.clear=function(E,k,B){let H=0;(E===void 0||E)&&(H|=16384),(k===void 0||k)&&(H|=256),(B===void 0||B)&&(H|=1024),V.clear(H)},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(){t.removeEventListener("webglcontextlost",Ft,!1),t.removeEventListener("webglcontextrestored",se,!1),q.dispose(),W.dispose(),Et.dispose(),Q.dispose(),ot.dispose(),J.dispose(),nt.dispose(),Hs.stop()};function Ft(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),p=!0}function se(){console.log("THREE.WebGLRenderer: Context Restored."),p=!1,ht()}function Gs(E){let k=E.target;k.removeEventListener("dispose",Gs),$e(k)}function $e(E){ke(E),Et.remove(E)}function ke(E){let k=Et.get(E).program;k!==void 0&&S.releaseProgram(k)}function Tx(E,k){E.render(function(B){f.renderBufferImmediate(B,k)})}this.renderBufferImmediate=function(E,k){J.initAttributes();let B=Et.get(E);E.hasPositions&&!B.position&&(B.position=V.createBuffer()),E.hasNormals&&!B.normal&&(B.normal=V.createBuffer()),E.hasUvs&&!B.uv&&(B.uv=V.createBuffer()),E.hasColors&&!B.color&&(B.color=V.createBuffer());let H=k.getAttributes();E.hasPositions&&(V.bindBuffer(34962,B.position),V.bufferData(34962,E.positionArray,35048),J.enableAttribute(H.position),V.vertexAttribPointer(H.position,3,5126,!1,0,0)),E.hasNormals&&(V.bindBuffer(34962,B.normal),V.bufferData(34962,E.normalArray,35048),J.enableAttribute(H.normal),V.vertexAttribPointer(H.normal,3,5126,!1,0,0)),E.hasUvs&&(V.bindBuffer(34962,B.uv),V.bufferData(34962,E.uvArray,35048),J.enableAttribute(H.uv),V.vertexAttribPointer(H.uv,2,5126,!1,0,0)),E.hasColors&&(V.bindBuffer(34962,B.color),V.bufferData(34962,E.colorArray,35048),J.enableAttribute(H.color),V.vertexAttribPointer(H.color,3,5126,!1,0,0)),J.disableUnusedAttributes(),V.drawArrays(4,0,E.count),E.count=0},this.renderBufferDirect=function(E,k,B,H,at,Rt){k===null&&(k=wt);let Ct=at.isMesh&&at.matrixWorld.determinant()<0,Dt=Zd(E,k,H,at);Mt.setMaterial(H,Ct);let Lt=B.index,ee=B.attributes.position;if(Lt===null){if(ee===void 0||ee.count===0)return}else if(Lt.count===0)return;let Kt=1;H.wireframe===!0&&(Lt=pt.getWireframeAttribute(B),Kt=2),(H.morphTargets||H.morphNormals)&&rt.update(at,B,H,Dt),J.setup(at,H,Dt,B,Lt);let Tt,Vt=ft;Lt!==null&&(Tt=et.get(Lt),Vt=tt,Vt.setIndex(Tt));let Pn=Lt!==null?Lt.count:ee.count,Wt=B.drawRange.start*Kt,Bi=B.drawRange.count*Kt,ce=Rt!==null?Rt.start*Kt:0,nh=Rt!==null?Rt.count*Kt:1/0,Ee=Math.max(Wt,ce),Vs=Math.min(Pn,Wt+Bi,ce+nh)-1,Ar=Math.max(0,Vs-Ee+1);if(Ar!==0){if(at.isMesh)H.wireframe===!0?(Mt.setLineWidth(H.wireframeLinewidth*Ht()),Vt.setMode(1)):Vt.setMode(4);else if(at.isLine){let Ws=H.linewidth;Ws===void 0&&(Ws=1),Mt.setLineWidth(Ws*Ht()),at.isLineSegments?Vt.setMode(1):at.isLineLoop?Vt.setMode(2):Vt.setMode(3)}else at.isPoints?Vt.setMode(0):at.isSprite&&Vt.setMode(4);if(at.isInstancedMesh)Vt.renderInstances(Ee,Ar,at.count);else if(B.isInstancedBufferGeometry){let Ws=Math.min(B.instanceCount,B._maxInstanceCount);Vt.renderInstances(Ee,Ar,Ws)}else Vt.render(Ee,Ar)}},this.compile=function(E,k){d=W.get(E,k),d.init(),E.traverse(function(H){H.isLight&&(d.pushLight(H),H.castShadow&&d.pushShadow(H))}),d.setupLights(k);let B=new WeakMap;E.traverse(function(H){let at=H.material;if(at)if(Array.isArray(at))for(let Rt=0;Rt<at.length;Rt++){let Ct=at[Rt];B.has(Ct)===!1&&(Ln(Ct,E,H),B.set(Ct))}else B.has(at)===!1&&(Ln(at,E,H),B.set(at))})};let eh=null;function Ax(E){nt.isPresenting||eh&&eh(E)}let Hs=new Ky;Hs.setAnimationLoop(Ax),typeof window<"u"&&Hs.setContext(window),this.setAnimationLoop=function(E){eh=E,nt.setAnimationLoop(E),E===null?Hs.stop():Hs.start()},this.render=function(E,k){let B,H;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),B=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),H=arguments[3]),k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(p===!0)return;J.resetDefaultState(),v=-1,w=null,E.autoUpdate===!0&&E.updateMatrixWorld(),k.parent===null&&k.updateMatrixWorld(),nt.enabled===!0&&nt.isPresenting===!0&&(k=nt.getCamera(k)),E.isScene===!0&&E.onBeforeRender(f,E,k,B||m),d=W.get(E,k),d.init(),it.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Z.setFromProjectionMatrix(it),ut=this.localClippingEnabled,K=L.init(this.clippingPlanes,ut,k),h=q.get(E,k),h.init(),Xd(E,k,0,f.sortObjects),h.finish(),f.sortObjects===!0&&h.sort(z,P),K===!0&&L.beginShadows();let at=d.state.shadowsArray;mt.render(at,E,k),d.setupLights(k),K===!0&&L.endShadows(),this.info.autoReset===!0&&this.info.reset(),B!==void 0&&this.setRenderTarget(B),Y.render(h,E,k,H);let Rt=h.opaque,Ct=h.transparent;Rt.length>0&&qd(Rt,E,k),Ct.length>0&&qd(Ct,E,k),E.isScene===!0&&E.onAfterRender(f,E,k),m!==null&&(X.updateRenderTargetMipmap(m),X.updateMultisampleRenderTarget(m)),Mt.buffers.depth.setTest(!0),Mt.buffers.depth.setMask(!0),Mt.buffers.color.setMask(!0),Mt.setPolygonOffset(!1),h=null,d=null};function Xd(E,k,B,H){if(E.visible===!1)return;if(E.layers.test(k.layers)){if(E.isGroup)B=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(k);else if(E.isLight)d.pushLight(E),E.castShadow&&d.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Z.intersectsSprite(E)){H&&St.setFromMatrixPosition(E.matrixWorld).applyMatrix4(it);let Ct=ot.update(E),Dt=E.material;Dt.visible&&h.push(E,Ct,Dt,B,St.z,null)}}else if(E.isImmediateRenderObject)H&&St.setFromMatrixPosition(E.matrixWorld).applyMatrix4(it),h.push(E,null,E.material,B,St.z,null);else if((E.isMesh||E.isLine||E.isPoints)&&(E.isSkinnedMesh&&E.skeleton.frame!==Ot.render.frame&&(E.skeleton.update(),E.skeleton.frame=Ot.render.frame),!E.frustumCulled||Z.intersectsObject(E))){H&&St.setFromMatrixPosition(E.matrixWorld).applyMatrix4(it);let Ct=ot.update(E),Dt=E.material;if(Array.isArray(Dt)){let Lt=Ct.groups;for(let ee=0,Kt=Lt.length;ee<Kt;ee++){let Tt=Lt[ee],Vt=Dt[Tt.materialIndex];Vt&&Vt.visible&&h.push(E,Ct,Vt,B,St.z,Tt)}}else Dt.visible&&h.push(E,Ct,Dt,B,St.z,null)}}let Rt=E.children;for(let Ct=0,Dt=Rt.length;Ct<Dt;Ct++)Xd(Rt[Ct],k,B,H)}function qd(E,k,B){let H=k.isScene===!0?k.overrideMaterial:null;for(let at=0,Rt=E.length;at<Rt;at++){let Ct=E[at],Dt=Ct.object,Lt=Ct.geometry,ee=H===null?Ct.material:H,Kt=Ct.group;if(B.isArrayCamera){_=B;let Tt=B.cameras;for(let Vt=0,Pn=Tt.length;Vt<Pn;Vt++){let Wt=Tt[Vt];Dt.layers.test(Wt.layers)&&(Mt.viewport(A.copy(Wt.viewport)),d.setupLights(Wt),Yd(Dt,k,Wt,Lt,ee,Kt))}}else _=null,Yd(Dt,k,B,Lt,ee,Kt)}}function Yd(E,k,B,H,at,Rt){if(E.onBeforeRender(f,k,B,H,at,Rt),d=W.get(k,_||B),E.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),E.isImmediateRenderObject){let Ct=Zd(B,k,at,E);Mt.setMaterial(at),J.reset(),Tx(E,Ct)}else f.renderBufferDirect(B,k,H,at,E,Rt);E.onAfterRender(f,k,B,H,at,Rt),d=W.get(k,_||B)}function Ln(E,k,B){k.isScene!==!0&&(k=wt);let H=Et.get(E),at=d.state.lights,Rt=d.state.shadowsArray,Ct=at.state.version,Dt=S.getParameters(E,at.state,Rt,k,B),Lt=S.getProgramCacheKey(Dt),ee=H.program,Kt=!0;if(ee===void 0)E.addEventListener("dispose",Gs);else if(ee.cacheKey!==Lt)ke(E);else if(H.lightsStateVersion!==Ct)Kt=!1;else if(Dt.shaderID!==void 0){let Wt=E.isMeshStandardMaterial?k.environment:null;H.envMap=Q.get(E.envMap||Wt);return}else Kt=!1;Kt&&(Dt.uniforms=S.getUniforms(E),E.onBeforeCompile(Dt,f),ee=S.acquireProgram(Dt,Lt),H.program=ee,H.uniforms=Dt.uniforms,H.outputEncoding=Dt.outputEncoding);let Tt=H.uniforms;(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(H.numClippingPlanes=L.numPlanes,H.numIntersection=L.numIntersection,Tt.clippingPlanes=L.uniform),H.environment=E.isMeshStandardMaterial?k.environment:null,H.fog=k.fog,H.envMap=Q.get(E.envMap||H.environment),H.needsLights=Lx(E),H.lightsStateVersion=Ct,H.needsLights&&(Tt.ambientLightColor.value=at.state.ambient,Tt.lightProbe.value=at.state.probe,Tt.directionalLights.value=at.state.directional,Tt.directionalLightShadows.value=at.state.directionalShadow,Tt.spotLights.value=at.state.spot,Tt.spotLightShadows.value=at.state.spotShadow,Tt.rectAreaLights.value=at.state.rectArea,Tt.ltc_1.value=at.state.rectAreaLTC1,Tt.ltc_2.value=at.state.rectAreaLTC2,Tt.pointLights.value=at.state.point,Tt.pointLightShadows.value=at.state.pointShadow,Tt.hemisphereLights.value=at.state.hemi,Tt.directionalShadowMap.value=at.state.directionalShadowMap,Tt.directionalShadowMatrix.value=at.state.directionalShadowMatrix,Tt.spotShadowMap.value=at.state.spotShadowMap,Tt.spotShadowMatrix.value=at.state.spotShadowMatrix,Tt.pointShadowMap.value=at.state.pointShadowMap,Tt.pointShadowMatrix.value=at.state.pointShadowMatrix);let Vt=H.program.getUniforms(),Pn=Si.seqWithValue(Vt.seq,Tt);H.uniformsList=Pn}function Zd(E,k,B,H){k.isScene!==!0&&(k=wt),X.resetTextureUnits();let at=k.fog,Rt=B.isMeshStandardMaterial?k.environment:null,Ct=m===null?f.outputEncoding:m.texture.encoding,Dt=Q.get(B.envMap||Rt),Lt=Et.get(B),ee=d.state.lights;if(K===!0&&(ut===!0||E!==w)){let ce=E===w&&B.id===v;L.setState(B,E,ce)}B.version===Lt.__version?(B.fog&&Lt.fog!==at||Lt.environment!==Rt||Lt.needsLights&&Lt.lightsStateVersion!==ee.state.version||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==L.numPlanes||Lt.numIntersection!==L.numIntersection)||Lt.outputEncoding!==Ct||Lt.envMap!==Dt)&&Ln(B,k,H):(Ln(B,k,H),Lt.__version=B.version);let Kt=!1,Tt=!1,Vt=!1,Pn=Lt.program,Wt=Pn.getUniforms(),Bi=Lt.uniforms;if(Mt.useProgram(Pn.program)&&(Kt=!0,Tt=!0,Vt=!0),B.id!==v&&(v=B.id,Tt=!0),Kt||w!==E){if(Wt.setValue(V,"projectionMatrix",E.projectionMatrix),It.logarithmicDepthBuffer&&Wt.setValue(V,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),w!==E&&(w=E,Tt=!0,Vt=!0),B.isShaderMaterial||B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshStandardMaterial||B.envMap){let ce=Wt.map.cameraPosition;ce!==void 0&&ce.setValue(V,St.setFromMatrixPosition(E.matrixWorld))}(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Wt.setValue(V,"isOrthographic",E.isOrthographicCamera===!0),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial||B.isShadowMaterial||B.skinning)&&Wt.setValue(V,"viewMatrix",E.matrixWorldInverse)}if(B.skinning){Wt.setOptional(V,H,"bindMatrix"),Wt.setOptional(V,H,"bindMatrixInverse");let ce=H.skeleton;if(ce){let nh=ce.bones;if(It.floatVertexTextures){if(ce.boneTexture===void 0){let Ee=Math.sqrt(nh.length*4);Ee=_t.ceilPowerOfTwo(Ee),Ee=Math.max(Ee,4);let Vs=new Float32Array(Ee*Ee*4);Vs.set(ce.boneMatrices);let Ar=new pr(Vs,Ee,Ee,Fe,Zn);ce.boneMatrices=Vs,ce.boneTexture=Ar,ce.boneTextureSize=Ee}Wt.setValue(V,"boneTexture",ce.boneTexture,X),Wt.setValue(V,"boneTextureSize",ce.boneTextureSize)}else Wt.setOptional(V,ce,"boneMatrices")}}return(Tt||Lt.receiveShadow!==H.receiveShadow)&&(Lt.receiveShadow=H.receiveShadow,Wt.setValue(V,"receiveShadow",H.receiveShadow)),Tt&&(Wt.setValue(V,"toneMappingExposure",f.toneMappingExposure),Lt.needsLights&&Cx(Bi,Vt),at&&B.fog&&T.refreshFogUniforms(Bi,at),T.refreshMaterialUniforms(Bi,B,F,O),Si.upload(V,Lt.uniformsList,Bi,X)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Si.upload(V,Lt.uniformsList,Bi,X),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Wt.setValue(V,"center",H.center),Wt.setValue(V,"modelViewMatrix",H.modelViewMatrix),Wt.setValue(V,"normalMatrix",H.normalMatrix),Wt.setValue(V,"modelMatrix",H.matrixWorld),Pn}function Cx(E,k){E.ambientLightColor.needsUpdate=k,E.lightProbe.needsUpdate=k,E.directionalLights.needsUpdate=k,E.directionalLightShadows.needsUpdate=k,E.pointLights.needsUpdate=k,E.pointLightShadows.needsUpdate=k,E.spotLights.needsUpdate=k,E.spotLightShadows.needsUpdate=k,E.rectAreaLights.needsUpdate=k,E.hemisphereLights.needsUpdate=k}function Lx(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.setFramebuffer=function(E){y!==E&&m===null&&V.bindFramebuffer(36160,E),y=E},this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return g},this.getRenderList=function(){return h},this.setRenderList=function(E){h=E},this.getRenderState=function(){return d},this.setRenderState=function(E){d=E},this.getRenderTarget=function(){return m},this.setRenderTarget=function(E,k=0,B=0){m=E,x=k,g=B,E&&Et.get(E).__webglFramebuffer===void 0&&X.setupRenderTarget(E);let H=y,at=!1;if(E){let Rt=Et.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(H=Rt[k],at=!0):E.isWebGLMultisampleRenderTarget?H=Et.get(E).__webglMultisampledFramebuffer:H=Rt,A.copy(E.viewport),I.copy(E.scissor),D=E.scissorTest}else A.copy(R).multiplyScalar(F).floor(),I.copy(U).multiplyScalar(F).floor(),D=j;if(b!==H&&(V.bindFramebuffer(36160,H),b=H),Mt.viewport(A),Mt.scissor(I),Mt.setScissorTest(D),at){let Rt=Et.get(E.texture);V.framebufferTexture2D(36160,36064,34069+k,Rt.__webglTexture,B)}},this.readRenderTargetPixels=function(E,k,B,H,at,Rt,Ct){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Dt=Et.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ct!==void 0&&(Dt=Dt[Ct]),Dt){let Lt=!1;Dt!==b&&(V.bindFramebuffer(36160,Dt),Lt=!0);try{let ee=E.texture,Kt=ee.format,Tt=ee.type;if(Kt!==Fe&&C.convert(Kt)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Tt!==Ns&&C.convert(Tt)!==V.getParameter(35738)&&!(Tt===Zn&&(It.isWebGL2||vt.get("OES_texture_float")||vt.get("WEBGL_color_buffer_float")))&&!(Tt===Po&&(It.isWebGL2?vt.get("EXT_color_buffer_float"):vt.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V.checkFramebufferStatus(36160)===36053?k>=0&&k<=E.width-H&&B>=0&&B<=E.height-at&&V.readPixels(k,B,H,at,C.convert(Kt),C.convert(Tt),Rt):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Lt&&V.bindFramebuffer(36160,b)}}},this.copyFramebufferToTexture=function(E,k,B){B===void 0&&(B=0);let H=Math.pow(2,-B),at=Math.floor(k.image.width*H),Rt=Math.floor(k.image.height*H),Ct=C.convert(k.format);X.setTexture2D(k,0),V.copyTexImage2D(3553,B,Ct,E.x,E.y,at,Rt,0),Mt.unbindTexture()},this.copyTextureToTexture=function(E,k,B,H){H===void 0&&(H=0);let at=k.image.width,Rt=k.image.height,Ct=C.convert(B.format),Dt=C.convert(B.type);X.setTexture2D(B,0),V.pixelStorei(37440,B.flipY),V.pixelStorei(37441,B.premultiplyAlpha),V.pixelStorei(3317,B.unpackAlignment),k.isDataTexture?V.texSubImage2D(3553,H,E.x,E.y,at,Rt,Ct,Dt,k.image.data):k.isCompressedTexture?V.compressedTexSubImage2D(3553,H,E.x,E.y,k.mipmaps[0].width,k.mipmaps[0].height,Ct,k.mipmaps[0].data):V.texSubImage2D(3553,H,E.x,E.y,Ct,Dt,k.image),H===0&&B.generateMipmaps&&V.generateMipmap(3553),Mt.unbindTexture()},this.initTexture=function(E){X.setTexture2D(E,0),Mt.unbindTexture()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Rf(n){Ea.call(this,n)}Rf.prototype=Object.assign(Object.create(Ea.prototype),{constructor:Rf,isWebGL1Renderer:!0});var Zc=class n{constructor(t,e){Object.defineProperty(this,"isFogExp2",{value:!0}),this.name="",this.color=new lt(t),this.density=e!==void 0?e:25e-5}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},Jc=class n{constructor(t,e,i){Object.defineProperty(this,"isFog",{value:!0}),this.name="",this.color=new lt(t),this.near=e!==void 0?e:1,this.far=i!==void 0?i:1e3}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Go=class extends dt{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.background!==null&&(e.object.background=this.background.toJSON(t)),this.environment!==null&&(e.object.environment=this.environment.toJSON(t)),this.fog!==null&&(e.object.fog=this.fog.toJSON()),e}};function Oe(n,t){this.array=n,this.stride=t,this.count=n!==void 0?n.length/t:0,this.usage=Sa,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=_t.generateUUID()}Object.defineProperty(Oe.prototype,"needsUpdate",{set:function(n){n===!0&&this.version++}});Object.assign(Oe.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(n){return this.usage=n,this},copy:function(n){return this.array=new n.array.constructor(n.array),this.count=n.count,this.stride=n.stride,this.usage=n.usage,this},copyAt:function(n,t,e){n*=this.stride,e*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[n+i]=t.array[e+i];return this},set:function(n,t){return t===void 0&&(t=0),this.array.set(n,t),this},clone:function(n){n.arrayBuffers===void 0&&(n.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=_t.generateUUID()),n.arrayBuffers[this.array.buffer._uuid]===void 0&&(n.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(n.arrayBuffers[this.array.buffer._uuid]),e=new Oe(t,this.stride);return e.setUsage(this.usage),e},onUpload:function(n){return this.onUploadCallback=n,this},toJSON:function(n){return n.arrayBuffers===void 0&&(n.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=_t.generateUUID()),n.arrayBuffers[this.array.buffer._uuid]===void 0&&(n.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});var Qi=new M;function Ii(n,t,e,i){this.name="",this.data=n,this.itemSize=t,this.offset=e,this.normalized=i===!0}Object.defineProperties(Ii.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(n){this.data.needsUpdate=n}}});Object.assign(Ii.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(n){for(let t=0,e=this.data.count;t<e;t++)Qi.x=this.getX(t),Qi.y=this.getY(t),Qi.z=this.getZ(t),Qi.applyMatrix4(n),this.setXYZ(t,Qi.x,Qi.y,Qi.z);return this},setX:function(n,t){return this.data.array[n*this.data.stride+this.offset]=t,this},setY:function(n,t){return this.data.array[n*this.data.stride+this.offset+1]=t,this},setZ:function(n,t){return this.data.array[n*this.data.stride+this.offset+2]=t,this},setW:function(n,t){return this.data.array[n*this.data.stride+this.offset+3]=t,this},getX:function(n){return this.data.array[n*this.data.stride+this.offset]},getY:function(n){return this.data.array[n*this.data.stride+this.offset+1]},getZ:function(n){return this.data.array[n*this.data.stride+this.offset+2]},getW:function(n){return this.data.array[n*this.data.stride+this.offset+3]},setXY:function(n,t,e){return n=n*this.data.stride+this.offset,this.data.array[n+0]=t,this.data.array[n+1]=e,this},setXYZ:function(n,t,e,i){return n=n*this.data.stride+this.offset,this.data.array[n+0]=t,this.data.array[n+1]=e,this.data.array[n+2]=i,this},setXYZW:function(n,t,e,i,r){return n=n*this.data.stride+this.offset,this.data.array[n+0]=t,this.data.array[n+1]=e,this.data.array[n+2]=i,this.data.array[n+3]=r,this},clone:function(n){if(n===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let e=0;e<this.count;e++){let i=e*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new xt(new this.array.constructor(t),this.itemSize,this.normalized)}else return n.interleavedBuffers===void 0&&(n.interleavedBuffers={}),n.interleavedBuffers[this.data.uuid]===void 0&&(n.interleavedBuffers[this.data.uuid]=this.data.clone(n)),new Ii(n.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(n){if(n===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let e=0;e<this.count;e++){let i=e*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return n.interleavedBuffers===void 0&&(n.interleavedBuffers={}),n.interleavedBuffers[this.data.uuid]===void 0&&(n.interleavedBuffers[this.data.uuid]=this.data.toJSON(n)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});function Di(n){bt.call(this),this.type="SpriteMaterial",this.color=new lt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(n)}Di.prototype=Object.create(bt.prototype);Di.prototype.constructor=Di;Di.prototype.isSpriteMaterial=!0;Di.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.map=n.map,this.alphaMap=n.alphaMap,this.rotation=n.rotation,this.sizeAttenuation=n.sizeAttenuation,this};var ns,mo=new M,is=new M,rs=new M,ss=new G,go=new G,hx=new At,gc=new M,yo=new M,yc=new M,Bm=new G,ef=new G,Um=new G;function Ho(n){if(dt.call(this),this.type="Sprite",ns===void 0){ns=new yt;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Oe(t,5);ns.setIndex([0,1,2,0,2,3]),ns.setAttribute("position",new Ii(e,3,0,!1)),ns.setAttribute("uv",new Ii(e,2,3,!1))}this.geometry=ns,this.material=n!==void 0?n:new Di,this.center=new G(.5,.5)}Ho.prototype=Object.assign(Object.create(dt.prototype),{constructor:Ho,isSprite:!0,raycast:function(n,t){n.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),is.setFromMatrixScale(this.matrixWorld),hx.copy(n.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(n.camera.matrixWorldInverse,this.matrixWorld),rs.setFromMatrixPosition(this.modelViewMatrix),n.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&is.multiplyScalar(-rs.z);let e=this.material.rotation,i,r;e!==0&&(r=Math.cos(e),i=Math.sin(e));let s=this.center;xc(gc.set(-.5,-.5,0),rs,s,is,i,r),xc(yo.set(.5,-.5,0),rs,s,is,i,r),xc(yc.set(.5,.5,0),rs,s,is,i,r),Bm.set(0,0),ef.set(1,0),Um.set(1,1);let o=n.ray.intersectTriangle(gc,yo,yc,!1,mo);if(o===null&&(xc(yo.set(-.5,.5,0),rs,s,is,i,r),ef.set(0,1),o=n.ray.intersectTriangle(gc,yc,yo,!1,mo),o===null))return;let a=n.ray.origin.distanceTo(mo);a<n.near||a>n.far||t.push({distance:a,point:mo.clone(),uv:Ve.getUV(mo,gc,yo,yc,Bm,ef,Um,new G),face:null,object:this})},copy:function(n){return dt.prototype.copy.call(this,n),n.center!==void 0&&this.center.copy(n.center),this.material=n.material,this}});function xc(n,t,e,i,r,s){ss.subVectors(n,e).addScalar(.5).multiply(i),r!==void 0?(go.x=s*ss.x-r*ss.y,go.y=r*ss.x+s*ss.y):go.copy(ss),n.copy(t),n.x+=go.x,n.y+=go.y,n.applyMatrix4(hx)}var vc=new M,km=new M;function Vo(){dt.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Vo.prototype=Object.assign(Object.create(dt.prototype),{constructor:Vo,isLOD:!0,copy:function(n){dt.prototype.copy.call(this,n,!1);let t=n.levels;for(let e=0,i=t.length;e<i;e++){let r=t[e];this.addLevel(r.object.clone(),r.distance)}return this.autoUpdate=n.autoUpdate,this},addLevel:function(n,t){t===void 0&&(t=0),t=Math.abs(t);let e=this.levels,i;for(i=0;i<e.length&&!(t<e[i].distance);i++);return e.splice(i,0,{distance:t,object:n}),this.add(n),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(n){let t=this.levels;if(t.length>0){let e,i;for(e=1,i=t.length;e<i&&!(n<t[e].distance);e++);return t[e-1].object}return null},raycast:function(n,t){if(this.levels.length>0){vc.setFromMatrixPosition(this.matrixWorld);let i=n.ray.origin.distanceTo(vc);this.getObjectForDistance(i).raycast(n,t)}},update:function(n){let t=this.levels;if(t.length>1){vc.setFromMatrixPosition(n.matrixWorld),km.setFromMatrixPosition(this.matrixWorld);let e=vc.distanceTo(km)/n.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i<r&&e>=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}},toJSON:function(n){let t=dt.prototype.toJSON.call(this,n);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let e=this.levels;for(let i=0,r=e.length;i<r;i++){let s=e[i];t.object.levels.push({object:s.object.uuid,distance:s.distance})}return t}});function $c(n,t){n&&n.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Yt.call(this,n,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new At,this.bindMatrixInverse=new At}$c.prototype=Object.assign(Object.create(Yt.prototype),{constructor:$c,isSkinnedMesh:!0,copy:function(n){return Yt.prototype.copy.call(this,n),this.bindMode=n.bindMode,this.bindMatrix.copy(n.bindMatrix),this.bindMatrixInverse.copy(n.bindMatrixInverse),this.skeleton=n.skeleton,this},bind:function(n,t){this.skeleton=n,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){let n=new Bt,t=this.geometry.attributes.skinWeight;for(let e=0,i=t.count;e<i;e++){n.x=t.getX(e),n.y=t.getY(e),n.z=t.getZ(e),n.w=t.getW(e);let r=1/n.manhattanLength();r!==1/0?n.multiplyScalar(r):n.set(1,0,0,0),t.setXYZW(e,n.x,n.y,n.z,n.w)}},updateMatrixWorld:function(n){Yt.prototype.updateMatrixWorld.call(this,n),this.bindMode==="attached"?this.bindMatrixInverse.getInverse(this.matrixWorld):this.bindMode==="detached"?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(){let n=new M,t=new Bt,e=new Bt,i=new M,r=new At;return function(s,o){let a=this.skeleton,c=this.geometry;t.fromBufferAttribute(c.attributes.skinIndex,s),e.fromBufferAttribute(c.attributes.skinWeight,s),n.fromBufferAttribute(c.attributes.position,s).applyMatrix4(this.bindMatrix),o.set(0,0,0);for(let l=0;l<4;l++){let u=e.getComponent(l);if(u!==0){let h=t.getComponent(l);r.multiplyMatrices(a.bones[h].matrixWorld,a.boneInverses[h]),o.addScaledVector(i.copy(n).applyMatrix4(r),u)}}return o.applyMatrix4(this.bindMatrixInverse)}}()});var Gm=new At,vS=new At;function Qc(n,t){if(n=n||[],this.bones=n.slice(0),this.boneMatrices=new Float32Array(this.bones.length*16),this.frame=-1,t===void 0)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(let e=0,i=this.bones.length;e<i;e++)this.boneInverses.push(new At)}}Object.assign(Qc.prototype,{calculateInverses:function(){this.boneInverses=[];for(let n=0,t=this.bones.length;n<t;n++){let e=new At;this.bones[n]&&e.getInverse(this.bones[n].matrixWorld),this.boneInverses.push(e)}},pose:function(){for(let n=0,t=this.bones.length;n<t;n++){let e=this.bones[n];e&&e.matrixWorld.getInverse(this.boneInverses[n])}for(let n=0,t=this.bones.length;n<t;n++){let e=this.bones[n];e&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}},update:function(){let n=this.bones,t=this.boneInverses,e=this.boneMatrices,i=this.boneTexture;for(let r=0,s=n.length;r<s;r++){let o=n[r]?n[r].matrixWorld:vS;Gm.multiplyMatrices(o,t[r]),Gm.toArray(e,r*16)}i!==void 0&&(i.needsUpdate=!0)},clone:function(){return new Qc(this.bones,this.boneInverses)},getBoneByName:function(n){for(let t=0,e=this.bones.length;t<e;t++){let i=this.bones[t];if(i.name===n)return i}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}});function If(){dt.call(this),this.type="Bone"}If.prototype=Object.assign(Object.create(dt.prototype),{constructor:If,isBone:!0});var Hm=new At,Vm=new At,bc=[],xo=new Yt;function Kc(n,t,e){Yt.call(this,n,t),this.instanceMatrix=new xt(new Float32Array(e*16),16),this.instanceColor=null,this.count=e,this.frustumCulled=!1}Kc.prototype=Object.assign(Object.create(Yt.prototype),{constructor:Kc,isInstancedMesh:!0,copy:function(n){return Yt.prototype.copy.call(this,n),this.instanceMatrix.copy(n.instanceMatrix),this.count=n.count,this},setColorAt:function(n,t){this.instanceColor===null&&(this.instanceColor=new xt(new Float32Array(this.count*3),3)),t.toArray(this.instanceColor.array,n*3)},getMatrixAt:function(n,t){t.fromArray(this.instanceMatrix.array,n*16)},raycast:function(n,t){let e=this.matrixWorld,i=this.count;if(xo.geometry=this.geometry,xo.material=this.material,xo.material!==void 0)for(let r=0;r<i;r++){this.getMatrixAt(r,Hm),Vm.multiplyMatrices(e,Hm),xo.matrixWorld=Vm,xo.raycast(n,bc);for(let s=0,o=bc.length;s<o;s++){let a=bc[s];a.instanceId=r,a.object=this,t.push(a)}bc.length=0}},setMatrixAt:function(n,t){t.toArray(this.instanceMatrix.array,n*16)},updateMorphTargets:function(){}});function Zt(n){bt.call(this),this.type="LineBasicMaterial",this.color=new lt(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(n)}Zt.prototype=Object.create(bt.prototype);Zt.prototype.constructor=Zt;Zt.prototype.isLineBasicMaterial=!0;Zt.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.linewidth=n.linewidth,this.linecap=n.linecap,this.linejoin=n.linejoin,this.morphTargets=n.morphTargets,this};var Wm=new M,jm=new M,Xm=new At,_c=new Ci,wc=new cn;function Ye(n,t,e){e===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),dt.call(this),this.type="Line",this.geometry=n!==void 0?n:new yt,this.material=t!==void 0?t:new Zt,this.updateMorphTargets()}Ye.prototype=Object.assign(Object.create(dt.prototype),{constructor:Ye,isLine:!0,copy:function(n){return dt.prototype.copy.call(this,n),this.material=n.material,this.geometry=n.geometry,this},computeLineDistances:function(){let n=this.geometry;if(n.isBufferGeometry)if(n.index===null){let t=n.attributes.position,e=[0];for(let i=1,r=t.count;i<r;i++)Wm.fromBufferAttribute(t,i-1),jm.fromBufferAttribute(t,i),e[i]=e[i-1],e[i]+=Wm.distanceTo(jm);n.setAttribute("lineDistance",new st(e,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(n.isGeometry){let t=n.vertices,e=n.lineDistances;e[0]=0;for(let i=1,r=t.length;i<r;i++)e[i]=e[i-1],e[i]+=t[i-1].distanceTo(t[i])}return this},raycast:function(n,t){let e=this.geometry,i=this.matrixWorld,r=n.params.Line.threshold;if(e.boundingSphere===null&&e.computeBoundingSphere(),wc.copy(e.boundingSphere),wc.applyMatrix4(i),wc.radius+=r,n.ray.intersectsSphere(wc)===!1)return;Xm.getInverse(i),_c.copy(n.ray).applyMatrix4(Xm);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,a=new M,c=new M,l=new M,u=new M,h=this&&this.isLineSegments?2:1;if(e.isBufferGeometry){let d=e.index,p=e.attributes.position.array;if(d!==null){let y=d.array;for(let x=0,g=y.length-1;x<g;x+=h){let m=y[x],b=y[x+1];if(a.fromArray(p,m*3),c.fromArray(p,b*3),_c.distanceSqToSegment(a,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let w=n.ray.origin.distanceTo(u);w<n.near||w>n.far||t.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else for(let y=0,x=p.length/3-1;y<x;y+=h){if(a.fromArray(p,3*y),c.fromArray(p,3*y+3),_c.distanceSqToSegment(a,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let m=n.ray.origin.distanceTo(u);m<n.near||m>n.far||t.push({distance:m,point:l.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else if(e.isGeometry){let d=e.vertices,f=d.length;for(let p=0;p<f-1;p+=h){if(_c.distanceSqToSegment(d[p],d[p+1],u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let x=n.ray.origin.distanceTo(u);x<n.near||x>n.far||t.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}}},updateMorphTargets:function(){let n=this.geometry;if(n.isBufferGeometry){let t=n.morphAttributes,e=Object.keys(t);if(e.length>0){let i=t[e[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}else{let t=n.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});var Mc=new M,Sc=new M;function Se(n,t){Ye.call(this,n,t),this.type="LineSegments"}Se.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Se,isLineSegments:!0,computeLineDistances:function(){let n=this.geometry;if(n.isBufferGeometry)if(n.index===null){let t=n.attributes.position,e=[];for(let i=0,r=t.count;i<r;i+=2)Mc.fromBufferAttribute(t,i),Sc.fromBufferAttribute(t,i+1),e[i]=i===0?0:e[i-1],e[i+1]=e[i]+Mc.distanceTo(Sc);n.setAttribute("lineDistance",new st(e,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(n.isGeometry){let t=n.vertices,e=n.lineDistances;for(let i=0,r=t.length;i<r;i+=2)Mc.copy(t[i]),Sc.copy(t[i+1]),e[i]=i===0?0:e[i-1],e[i+1]=e[i]+Mc.distanceTo(Sc)}return this}});function tl(n,t){Ye.call(this,n,t),this.type="LineLoop"}tl.prototype=Object.assign(Object.create(Ye.prototype),{constructor:tl,isLineLoop:!0});function ln(n){bt.call(this),this.type="PointsMaterial",this.color=new lt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(n)}ln.prototype=Object.create(bt.prototype);ln.prototype.constructor=ln;ln.prototype.isPointsMaterial=!0;ln.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.map=n.map,this.alphaMap=n.alphaMap,this.size=n.size,this.sizeAttenuation=n.sizeAttenuation,this.morphTargets=n.morphTargets,this};var qm=new At,Df=new Ci,Ec=new cn,Tc=new M;function Ms(n,t){dt.call(this),this.type="Points",this.geometry=n!==void 0?n:new yt,this.material=t!==void 0?t:new ln,this.updateMorphTargets()}Ms.prototype=Object.assign(Object.create(dt.prototype),{constructor:Ms,isPoints:!0,copy:function(n){return dt.prototype.copy.call(this,n),this.material=n.material,this.geometry=n.geometry,this},raycast:function(n,t){let e=this.geometry,i=this.matrixWorld,r=n.params.Points.threshold;if(e.boundingSphere===null&&e.computeBoundingSphere(),Ec.copy(e.boundingSphere),Ec.applyMatrix4(i),Ec.radius+=r,n.ray.intersectsSphere(Ec)===!1)return;qm.getInverse(i),Df.copy(n.ray).applyMatrix4(qm);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s;if(e.isBufferGeometry){let a=e.index,l=e.attributes.position.array;if(a!==null){let u=a.array;for(let h=0,d=u.length;h<d;h++){let f=u[h];Tc.fromArray(l,f*3),nf(Tc,f,o,i,n,t,this)}}else for(let u=0,h=l.length/3;u<h;u++)Tc.fromArray(l,u*3),nf(Tc,u,o,i,n,t,this)}else{let a=e.vertices;for(let c=0,l=a.length;c<l;c++)nf(a[c],c,o,i,n,t,this)}},updateMorphTargets:function(){let n=this.geometry;if(n.isBufferGeometry){let t=n.morphAttributes,e=Object.keys(t);if(e.length>0){let i=t[e[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}else{let t=n.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});function nf(n,t,e,i,r,s,o){let a=Df.distanceSqToPoint(n);if(a<e){let c=new M;Df.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,object:o})}}function Of(n,t,e,i,r,s,o,a,c){Gt.call(this,n,t,e,i,r,s,o,a,c),this.format=o!==void 0?o:Mi,this.minFilter=s!==void 0?s:he,this.magFilter=r!==void 0?r:he,this.generateMipmaps=!1;let l=this;function u(){l.needsUpdate=!0,n.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in n&&n.requestVideoFrameCallback(u)}Of.prototype=Object.assign(Object.create(Gt.prototype),{constructor:Of,isVideoTexture:!0,update:function(){let n=this.image;"requestVideoFrameCallback"in n===!1&&n.readyState>=n.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Ss(n,t,e,i,r,s,o,a,c,l,u,h){Gt.call(this,null,s,o,a,c,l,i,r,u,h),this.image={width:t,height:e},this.mipmaps=n,this.flipY=!1,this.generateMipmaps=!1}Ss.prototype=Object.create(Gt.prototype);Ss.prototype.constructor=Ss;Ss.prototype.isCompressedTexture=!0;function Wo(n,t,e,i,r,s,o,a,c){Gt.call(this,n,t,e,i,r,s,o,a,c),this.needsUpdate=!0}Wo.prototype=Object.create(Gt.prototype);Wo.prototype.constructor=Wo;Wo.prototype.isCanvasTexture=!0;function jo(n,t,e,i,r,s,o,a,c,l){if(l=l!==void 0?l:cr,l!==cr&&l!==gs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");e===void 0&&l===cr&&(e=Lo),e===void 0&&l===gs&&(e=ps),Gt.call(this,null,i,r,s,o,a,l,e,c),this.image={width:n,height:t},this.magFilter=o!==void 0?o:ae,this.minFilter=a!==void 0?a:ae,this.flipY=!1,this.generateMipmaps=!1}jo.prototype=Object.create(Gt.prototype);jo.prototype.constructor=jo;jo.prototype.isDepthTexture=!0;var Xo=class extends yt{constructor(t){super(),this.type="WireframeGeometry";let e=[],i=[0,0],r={},s=["a","b","c"];if(t&&t.isGeometry){let o=t.faces;for(let a=0,c=o.length;a<c;a++){let l=o[a];for(let u=0;u<3;u++){let h=l[s[u]],d=l[s[(u+1)%3]];i[0]=Math.min(h,d),i[1]=Math.max(h,d);let f=i[0]+","+i[1];r[f]===void 0&&(r[f]={index1:i[0],index2:i[1]})}}for(let a in r){let c=r[a],l=t.vertices[c.index1];e.push(l.x,l.y,l.z),l=t.vertices[c.index2],e.push(l.x,l.y,l.z)}}else if(t&&t.isBufferGeometry){let o=new M;if(t.index!==null){let a=t.attributes.position,c=t.index,l=t.groups;l.length===0&&(l=[{start:0,count:c.count,materialIndex:0}]);for(let u=0,h=l.length;u<h;++u){let d=l[u],f=d.start,p=d.count;for(let y=f,x=f+p;y<x;y+=3)for(let g=0;g<3;g++){let m=c.getX(y+g),b=c.getX(y+(g+1)%3);i[0]=Math.min(m,b),i[1]=Math.max(m,b);let v=i[0]+","+i[1];r[v]===void 0&&(r[v]={index1:i[0],index2:i[1]})}}for(let u in r){let h=r[u];o.fromBufferAttribute(a,h.index1),e.push(o.x,o.y,o.z),o.fromBufferAttribute(a,h.index2),e.push(o.x,o.y,o.z)}}else{let a=t.attributes.position;for(let c=0,l=a.count/3;c<l;c++)for(let u=0;u<3;u++){let h=3*c+u;o.fromBufferAttribute(a,h),e.push(o.x,o.y,o.z);let d=3*c+(u+1)%3;o.fromBufferAttribute(a,d),e.push(o.x,o.y,o.z)}}}this.setAttribute("position",new st(e,3))}};function qo(n,t,e){Ut.call(this),this.type="ParametricGeometry",this.parameters={func:n,slices:t,stacks:e},this.fromBufferGeometry(new Es(n,t,e)),this.mergeVertices()}qo.prototype=Object.create(Ut.prototype);qo.prototype.constructor=qo;function Es(n,t,e){yt.call(this),this.type="ParametricBufferGeometry",this.parameters={func:n,slices:t,stacks:e};let i=[],r=[],s=[],o=[],a=1e-5,c=new M,l=new M,u=new M,h=new M,d=new M;n.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");let f=t+1;for(let p=0;p<=e;p++){let y=p/e;for(let x=0;x<=t;x++){let g=x/t;n(g,y,l),r.push(l.x,l.y,l.z),g-a>=0?(n(g-a,y,u),h.subVectors(l,u)):(n(g+a,y,u),h.subVectors(u,l)),y-a>=0?(n(g,y-a,u),d.subVectors(l,u)):(n(g,y+a,u),d.subVectors(u,l)),c.crossVectors(h,d).normalize(),s.push(c.x,c.y,c.z),o.push(g,y)}}for(let p=0;p<e;p++)for(let y=0;y<t;y++){let x=p*f+y,g=p*f+y+1,m=(p+1)*f+y+1,b=(p+1)*f+y;i.push(x,g,b),i.push(g,m,b)}this.setIndex(i),this.setAttribute("position",new st(r,3)),this.setAttribute("normal",new st(s,3)),this.setAttribute("uv",new st(o,2))}Es.prototype=Object.create(yt.prototype);Es.prototype.constructor=Es;var el=class extends Ut{constructor(t,e,i,r){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},this.fromBufferGeometry(new ti(t,e,i,r)),this.mergeVertices()}},ti=class extends yt{constructor(t,e,i,r){super(),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},i=i||1,r=r||0;let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new st(s,3)),this.setAttribute("normal",new st(s.slice(),3)),this.setAttribute("uv",new st(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(m){let b=new M,v=new M,w=new M;for(let _=0;_<e.length;_+=3)f(e[_+0],b),f(e[_+1],v),f(e[_+2],w),c(b,v,w,m)}function c(m,b,v,w){let _=Math.pow(2,w),A=[];for(let I=0;I<=_;I++){A[I]=[];let D=m.clone().lerp(v,I/_),N=b.clone().lerp(v,I/_),O=_-I;for(let F=0;F<=O;F++)F===0&&I===_?A[I][F]=D:A[I][F]=D.clone().lerp(N,F/O)}for(let I=0;I<_;I++)for(let D=0;D<2*(_-I)-1;D++){let N=Math.floor(D/2);D%2===0?(d(A[I][N+1]),d(A[I+1][N]),d(A[I][N])):(d(A[I][N+1]),d(A[I+1][N+1]),d(A[I+1][N]))}}function l(m){let b=new M;for(let v=0;v<s.length;v+=3)b.x=s[v+0],b.y=s[v+1],b.z=s[v+2],b.normalize().multiplyScalar(m),s[v+0]=b.x,s[v+1]=b.y,s[v+2]=b.z}function u(){let m=new M;for(let b=0;b<s.length;b+=3){m.x=s[b+0],m.y=s[b+1],m.z=s[b+2];let v=x(m)/2/Math.PI+.5,w=g(m)/Math.PI+.5;o.push(v,1-w)}p(),h()}function h(){for(let m=0;m<o.length;m+=6){let b=o[m+0],v=o[m+2],w=o[m+4],_=Math.max(b,v,w),A=Math.min(b,v,w);_>.9&&A<.1&&(b<.2&&(o[m+0]+=1),v<.2&&(o[m+2]+=1),w<.2&&(o[m+4]+=1))}}function d(m){s.push(m.x,m.y,m.z)}function f(m,b){let v=m*3;b.x=t[v+0],b.y=t[v+1],b.z=t[v+2]}function p(){let m=new M,b=new M,v=new M,w=new M,_=new G,A=new G,I=new G;for(let D=0,N=0;D<s.length;D+=9,N+=6){m.set(s[D+0],s[D+1],s[D+2]),b.set(s[D+3],s[D+4],s[D+5]),v.set(s[D+6],s[D+7],s[D+8]),_.set(o[N+0],o[N+1]),A.set(o[N+2],o[N+3]),I.set(o[N+4],o[N+5]),w.copy(m).add(b).add(v).divideScalar(3);let O=x(w);y(_,N+0,m,O),y(A,N+2,b,O),y(I,N+4,v,O)}}function y(m,b,v,w){w<0&&m.x===1&&(o[b]=m.x-1),v.x===0&&v.z===0&&(o[b]=w/2/Math.PI+.5)}function x(m){return Math.atan2(m.z,-m.x)}function g(m){return Math.atan2(-m.y,Math.sqrt(m.x*m.x+m.z*m.z))}}},nl=class extends Ut{constructor(t,e){super(),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Yo(t,e)),this.mergeVertices()}},Yo=class extends ti{constructor(t,e){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}},il=class extends Ut{constructor(t,e){super(),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ts(t,e)),this.mergeVertices()}},Ts=class extends ti{constructor(t,e){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}},rl=class extends Ut{constructor(t,e){super(),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Zo(t,e)),this.mergeVertices()}},Zo=class extends ti{constructor(t,e){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}},sl=class extends Ut{constructor(t,e){super(),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Jo(t,e)),this.mergeVertices()}},Jo=class extends ti{constructor(t,e){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}},ol=class extends Ut{constructor(t,e,i,r,s,o){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:s},o!==void 0&&console.warn("THREE.TubeGeometry: taper has been removed.");let a=new $o(t,e,i,r,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}},$o=class extends yt{constructor(t,e,i,r,s){super(),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:s},e=e||64,i=i||1,r=r||8,s=s||!1;let o=t.computeFrenetFrames(e,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new M,c=new M,l=new G,u=new M,h=[],d=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new st(h,3)),this.setAttribute("normal",new st(d,3)),this.setAttribute("uv",new st(f,2));function y(){for(let b=0;b<e;b++)x(b);x(s===!1?e:0),m(),g()}function x(b){u=t.getPointAt(b/e,u);let v=o.normals[b],w=o.binormals[b];for(let _=0;_<=r;_++){let A=_/r*Math.PI*2,I=Math.sin(A),D=-Math.cos(A);c.x=D*v.x+I*w.x,c.y=D*v.y+I*w.y,c.z=D*v.z+I*w.z,c.normalize(),d.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,h.push(a.x,a.y,a.z)}}function g(){for(let b=1;b<=e;b++)for(let v=1;v<=r;v++){let w=(r+1)*(b-1)+(v-1),_=(r+1)*b+(v-1),A=(r+1)*b+v,I=(r+1)*(b-1)+v;p.push(w,_,I),p.push(_,A,I)}}function m(){for(let b=0;b<=e;b++)for(let v=0;v<=r;v++)l.x=b/e,l.y=v/r,f.push(l.x,l.y)}}toJSON(){let t=yt.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t}},al=class extends Ut{constructor(t,e,i,r,s,o,a){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:s,q:o},a!==void 0&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new Qo(t,e,i,r,s,o)),this.mergeVertices()}},Qo=class extends yt{constructor(t,e,i,r,s,o){super(),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:s,q:o},t=t||1,e=e||.4,i=Math.floor(i)||64,r=Math.floor(r)||8,s=s||2,o=o||3;let a=[],c=[],l=[],u=[],h=new M,d=new M,f=new M,p=new M,y=new M,x=new M,g=new M;for(let b=0;b<=i;++b){let v=b/i*s*Math.PI*2;m(v,s,o,t,f),m(v+.01,s,o,t,p),x.subVectors(p,f),g.addVectors(p,f),y.crossVectors(x,g),g.crossVectors(y,x),y.normalize(),g.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,A=-e*Math.cos(_),I=e*Math.sin(_);h.x=f.x+(A*g.x+I*y.x),h.y=f.y+(A*g.y+I*y.y),h.z=f.z+(A*g.z+I*y.z),c.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),l.push(d.x,d.y,d.z),u.push(b/i),u.push(w/r)}}for(let b=1;b<=i;b++)for(let v=1;v<=r;v++){let w=(r+1)*(b-1)+(v-1),_=(r+1)*b+(v-1),A=(r+1)*b+v,I=(r+1)*(b-1)+v;a.push(w,_,I),a.push(_,A,I)}this.setIndex(a),this.setAttribute("position",new st(c,3)),this.setAttribute("normal",new st(l,3)),this.setAttribute("uv",new st(u,2));function m(b,v,w,_,A){let I=Math.cos(b),D=Math.sin(b),N=w/v*b,O=Math.cos(N);A.x=_*(2+O)*.5*I,A.y=_*(2+O)*D*.5,A.z=_*Math.sin(N)*.5}}},cl=class extends Ut{constructor(t,e,i,r,s){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:s},this.fromBufferGeometry(new Ko(t,e,i,r,s)),this.mergeVertices()}},Ko=class extends yt{constructor(t,e,i,r,s){super(),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:s},t=t||1,e=e||.4,i=Math.floor(i)||8,r=Math.floor(r)||6,s=s||Math.PI*2;let o=[],a=[],c=[],l=[],u=new M,h=new M,d=new M;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,x=f/i*Math.PI*2;h.x=(t+e*Math.cos(x))*Math.cos(y),h.y=(t+e*Math.cos(x))*Math.sin(y),h.z=e*Math.sin(x),a.push(h.x,h.y,h.z),u.x=t*Math.cos(y),u.y=t*Math.sin(y),d.subVectors(h,u).normalize(),c.push(d.x,d.y,d.z),l.push(p/r),l.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,x=(r+1)*(f-1)+p-1,g=(r+1)*(f-1)+p,m=(r+1)*f+p;o.push(y,x,m),o.push(x,g,m)}this.setIndex(o),this.setAttribute("position",new st(a,3)),this.setAttribute("normal",new st(c,3)),this.setAttribute("uv",new st(l,2))}},bS={triangulate:function(n,t,e){e=e||2;let i=t&&t.length,r=i?t[0]*e:n.length,s=ux(n,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,d,f;if(i&&(s=ES(n,t,s,e)),n.length>80*e){a=l=n[0],c=u=n[1];for(let p=e;p<r;p+=e)h=n[p],d=n[p+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);f=Math.max(l-a,u-c),f=f!==0?1/f:0}return ta(s,o,e,a,c,f),o}};function ux(n,t,e,i,r){let s,o;if(r===zS(n,t,e,i)>0)for(s=t;s<e;s+=i)o=Ym(s,n[s],n[s+1],o);else for(s=e-i;s>=t;s-=i)o=Ym(s,n[s],n[s+1],o);return o&&Jl(o,o.next)&&(na(o),o=o.next),o}function Oi(n,t){if(!n)return n;t||(t=n);let e=n,i;do if(i=!1,!e.steiner&&(Jl(e,e.next)||$t(e.prev,e,e.next)===0)){if(na(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ta(n,t,e,i,r,s,o){if(!n)return;!o&&s&&PS(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?wS(n,i,r,s):_S(n)){t.push(c.i/e),t.push(n.i/e),t.push(l.i/e),na(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=MS(Oi(n),t,e),ta(n,t,e,i,r,s,2)):o===2&&SS(n,t,e,i,r,s):ta(Oi(n),t,e,i,r,s,1);break}}}function _S(n){let t=n.prev,e=n,i=n.next;if($t(t,e,i)>=0)return!1;let r=n.next.next;for(;r!==n.prev;){if(fs(t.x,t.y,e.x,e.y,i.x,i.y,r.x,r.y)&&$t(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function wS(n,t,e,i){let r=n.prev,s=n,o=n.next;if($t(r,s,o)>=0)return!1;let a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,c=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,l=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,u=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,h=Ff(a,c,t,e,i),d=Ff(l,u,t,e,i),f=n.prevZ,p=n.nextZ;for(;f&&f.z>=h&&p&&p.z<=d;){if(f!==n.prev&&f!==n.next&&fs(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&$t(f.prev,f,f.next)>=0||(f=f.prevZ,p!==n.prev&&p!==n.next&&fs(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&$t(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;f&&f.z>=h;){if(f!==n.prev&&f!==n.next&&fs(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&$t(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=d;){if(p!==n.prev&&p!==n.next&&fs(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&$t(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function MS(n,t,e){let i=n;do{let r=i.prev,s=i.next.next;!Jl(r,s)&&fx(r,i,i.next,s)&&ea(r,s)&&ea(s,r)&&(t.push(r.i/e),t.push(i.i/e),t.push(s.i/e),na(i),na(i.next),i=n=s),i=i.next}while(i!==n);return Oi(i)}function SS(n,t,e,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&DS(o,a)){let c=dx(o,a);o=Oi(o,o.next),c=Oi(c,c.next),ta(o,t,e,i,r,s),ta(c,t,e,i,r,s);return}a=a.next}o=o.next}while(o!==n)}function ES(n,t,e,i){let r=[],s,o,a,c,l;for(s=0,o=t.length;s<o;s++)a=t[s]*i,c=s<o-1?t[s+1]*i:n.length,l=ux(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(IS(l));for(r.sort(TS),s=0;s<r.length;s++)AS(r[s],e),e=Oi(e,e.next);return e}function TS(n,t){return n.x-t.x}function AS(n,t){if(t=CS(n,t),t){let e=dx(t,n);Oi(t,t.next),Oi(e,e.next)}}function CS(n,t){let e=t,i=n.x,r=n.y,s=-1/0,o;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){let d=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=i&&d>s){if(s=d,d===i){if(r===e.y)return e;if(r===e.next.y)return e.next}o=e.x<e.next.x?e:e.next}}e=e.next}while(e!==t);if(!o)return null;if(i===s)return o;let a=o,c=o.x,l=o.y,u=1/0,h;e=o;do i>=e.x&&e.x>=c&&i!==e.x&&fs(r<l?i:s,r,c,l,r<l?s:i,r,e.x,e.y)&&(h=Math.abs(r-e.y)/(i-e.x),ea(e,n)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&LS(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function LS(n,t){return $t(n.prev,n,t.prev)<0&&$t(t.next,n,n.next)<0}function PS(n,t,e,i){let r=n;do r.z===null&&(r.z=Ff(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,RS(r)}function RS(n){let t,e,i,r,s,o,a,c,l=1;do{for(e=n,n=null,s=null,o=0;e;){for(o++,i=e,a=0,t=0;t<l&&(a++,i=i.nextZ,!!i);t++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;e=i}s.nextZ=null,l*=2}while(o>1);return n}function Ff(n,t,e,i,r){return n=32767*(n-e)*r,t=32767*(t-i)*r,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function IS(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function fs(n,t,e,i,r,s,o,a){return(r-o)*(t-a)-(n-o)*(s-a)>=0&&(n-o)*(i-a)-(e-o)*(t-a)>=0&&(e-o)*(s-a)-(r-o)*(i-a)>=0}function DS(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!OS(n,t)&&(ea(n,t)&&ea(t,n)&&FS(n,t)&&($t(n.prev,n,t.prev)||$t(n,t.prev,t))||Jl(n,t)&&$t(n.prev,n,n.next)>0&&$t(t.prev,t,t.next)>0)}function $t(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function Jl(n,t){return n.x===t.x&&n.y===t.y}function fx(n,t,e,i){let r=Cc($t(n,t,e)),s=Cc($t(n,t,i)),o=Cc($t(e,i,n)),a=Cc($t(e,i,t));return!!(r!==s&&o!==a||r===0&&Ac(n,e,t)||s===0&&Ac(n,i,t)||o===0&&Ac(e,n,i)||a===0&&Ac(e,t,i))}function Ac(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function Cc(n){return n>0?1:n<0?-1:0}function OS(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&fx(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function ea(n,t){return $t(n.prev,n,n.next)<0?$t(n,t,n.next)>=0&&$t(n,n.prev,t)>=0:$t(n,t,n.prev)<0||$t(n,n.next,t)<0}function FS(n,t){let e=n,i=!1,r=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==n);return i}function dx(n,t){let e=new zf(n.i,n.x,n.y),i=new zf(t.i,t.x,t.y),r=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=r,r.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function Ym(n,t,e,i){let r=new zf(n,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function na(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function zf(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function zS(n,t,e,i){let r=0;for(let s=t,o=e-i;s<e;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}var Qn={area:function(n){let t=n.length,e=0;for(let i=t-1,r=0;r<t;i=r++)e+=n[i].x*n[r].y-n[r].x*n[i].y;return e*.5},isClockWise:function(n){return Qn.area(n)<0},triangulateShape:function(n,t){let e=[],i=[],r=[];Zm(n),Jm(e,n);let s=n.length;t.forEach(Zm);for(let a=0;a<t.length;a++)i.push(s),s+=t[a].length,Jm(e,t[a]);let o=bS.triangulate(e,i);for(let a=0;a<o.length;a+=3)r.push(o.slice(a,a+3));return r}};function Zm(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function Jm(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var ia=class extends Ut{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new gr(t,e)),this.mergeVertices()}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,i=this.parameters.options;return px(e,i,t)}},gr=class extends yt{constructor(t,e){super(),this.type="ExtrudeBufferGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let i=this,r=[],s=[];for(let a=0,c=t.length;a<c;a++){let l=t[a];o(l)}this.setAttribute("position",new st(r,3)),this.setAttribute("uv",new st(s,2)),this.computeVertexNormals();function o(a){let c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:100,d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:6,p=e.bevelSize!==void 0?e.bevelSize:f-2,y=e.bevelOffset!==void 0?e.bevelOffset:0,x=e.bevelSegments!==void 0?e.bevelSegments:3,g=e.extrudePath,m=e.UVGenerator!==void 0?e.UVGenerator:NS;e.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=e.amount);let b,v=!1,w,_,A,I;g&&(b=g.getSpacedPoints(u),v=!0,d=!1,w=g.computeFrenetFrames(u,!1),_=new M,A=new M,I=new M),d||(x=0,f=0,p=0,y=0);let D=a.extractPoints(l),N=D.shape,O=D.holes;if(!Qn.isClockWise(N)){N=N.reverse();for(let X=0,Q=O.length;X<Q;X++){let et=O[X];Qn.isClockWise(et)&&(O[X]=et.reverse())}}let z=Qn.triangulateShape(N,O),P=N;for(let X=0,Q=O.length;X<Q;X++){let et=O[X];N=N.concat(et)}function R(X,Q,et){return Q||console.error("THREE.ExtrudeGeometry: vec does not exist"),Q.clone().multiplyScalar(et).add(X)}let U=N.length,j=z.length;function Z(X,Q,et){let pt,ot,S,T=X.x-Q.x,q=X.y-Q.y,W=et.x-X.x,L=et.y-X.y,Y=T*T+q*q,rt=T*L-q*W;if(Math.abs(rt)>Number.EPSILON){let ft=Math.sqrt(Y),tt=Math.sqrt(W*W+L*L),C=Q.x-q/ft,J=Q.y+T/ft,ht=et.x-L/tt,nt=et.y+W/tt,mt=((ht-C)*L-(nt-J)*W)/(T*L-q*W);pt=C+T*mt-X.x,ot=J+q*mt-X.y;let Ft=pt*pt+ot*ot;if(Ft<=2)return new G(pt,ot);S=Math.sqrt(Ft/2)}else{let ft=!1;T>Number.EPSILON?W>Number.EPSILON&&(ft=!0):T<-Number.EPSILON?W<-Number.EPSILON&&(ft=!0):Math.sign(q)===Math.sign(L)&&(ft=!0),ft?(pt=-q,ot=T,S=Math.sqrt(Y)):(pt=T,ot=q,S=Math.sqrt(Y/2))}return new G(pt/S,ot/S)}let K=[];for(let X=0,Q=P.length,et=Q-1,pt=X+1;X<Q;X++,et++,pt++)et===Q&&(et=0),pt===Q&&(pt=0),K[X]=Z(P[X],P[et],P[pt]);let ut=[],it,St=K.concat();for(let X=0,Q=O.length;X<Q;X++){let et=O[X];it=[];for(let pt=0,ot=et.length,S=ot-1,T=pt+1;pt<ot;pt++,S++,T++)S===ot&&(S=0),T===ot&&(T=0),it[pt]=Z(et[pt],et[S],et[T]);ut.push(it),St=St.concat(it)}for(let X=0;X<x;X++){let Q=X/x,et=f*Math.cos(Q*Math.PI/2),pt=p*Math.sin(Q*Math.PI/2)+y;for(let ot=0,S=P.length;ot<S;ot++){let T=R(P[ot],K[ot],pt);vt(T.x,T.y,-et)}for(let ot=0,S=O.length;ot<S;ot++){let T=O[ot];it=ut[ot];for(let q=0,W=T.length;q<W;q++){let L=R(T[q],it[q],pt);vt(L.x,L.y,-et)}}}let wt=p+y;for(let X=0;X<U;X++){let Q=d?R(N[X],St[X],wt):N[X];v?(A.copy(w.normals[0]).multiplyScalar(Q.x),_.copy(w.binormals[0]).multiplyScalar(Q.y),I.copy(b[0]).add(A).add(_),vt(I.x,I.y,I.z)):vt(Q.x,Q.y,0)}for(let X=1;X<=u;X++)for(let Q=0;Q<U;Q++){let et=d?R(N[Q],St[Q],wt):N[Q];v?(A.copy(w.normals[X]).multiplyScalar(et.x),_.copy(w.binormals[X]).multiplyScalar(et.y),I.copy(b[X]).add(A).add(_),vt(I.x,I.y,I.z)):vt(et.x,et.y,h/u*X)}for(let X=x-1;X>=0;X--){let Q=X/x,et=f*Math.cos(Q*Math.PI/2),pt=p*Math.sin(Q*Math.PI/2)+y;for(let ot=0,S=P.length;ot<S;ot++){let T=R(P[ot],K[ot],pt);vt(T.x,T.y,h+et)}for(let ot=0,S=O.length;ot<S;ot++){let T=O[ot];it=ut[ot];for(let q=0,W=T.length;q<W;q++){let L=R(T[q],it[q],pt);v?vt(L.x,L.y+b[u-1].y,b[u-1].x+et):vt(L.x,L.y,h+et)}}}Ht(),V();function Ht(){let X=r.length/3;if(d){let Q=0,et=U*Q;for(let pt=0;pt<j;pt++){let ot=z[pt];It(ot[2]+et,ot[1]+et,ot[0]+et)}Q=u+x*2,et=U*Q;for(let pt=0;pt<j;pt++){let ot=z[pt];It(ot[0]+et,ot[1]+et,ot[2]+et)}}else{for(let Q=0;Q<j;Q++){let et=z[Q];It(et[2],et[1],et[0])}for(let Q=0;Q<j;Q++){let et=z[Q];It(et[0]+U*u,et[1]+U*u,et[2]+U*u)}}i.addGroup(X,r.length/3-X,0)}function V(){let X=r.length/3,Q=0;re(P,Q),Q+=P.length;for(let et=0,pt=O.length;et<pt;et++){let ot=O[et];re(ot,Q),Q+=ot.length}i.addGroup(X,r.length/3-X,1)}function re(X,Q){let et=X.length;for(;--et>=0;){let pt=et,ot=et-1;ot<0&&(ot=X.length-1);for(let S=0,T=u+x*2;S<T;S++){let q=U*S,W=U*(S+1),L=Q+pt+q,Y=Q+ot+q,rt=Q+ot+W,ft=Q+pt+W;Mt(L,Y,rt,ft)}}}function vt(X,Q,et){c.push(X),c.push(Q),c.push(et)}function It(X,Q,et){Ot(X),Ot(Q),Ot(et);let pt=r.length/3,ot=m.generateTopUV(i,r,pt-3,pt-2,pt-1);Et(ot[0]),Et(ot[1]),Et(ot[2])}function Mt(X,Q,et,pt){Ot(X),Ot(Q),Ot(pt),Ot(Q),Ot(et),Ot(pt);let ot=r.length/3,S=m.generateSideWallUV(i,r,ot-6,ot-3,ot-2,ot-1);Et(S[0]),Et(S[1]),Et(S[3]),Et(S[1]),Et(S[2]),Et(S[3])}function Ot(X){r.push(c[X*3+0]),r.push(c[X*3+1]),r.push(c[X*3+2])}function Et(X){s.push(X.x),s.push(X.y)}}}toJSON(){let t=yt.prototype.toJSON.call(this),e=this.parameters.shapes,i=this.parameters.options;return px(e,i,t)}},NS={generateTopUV:function(n,t,e,i,r){let s=t[e*3],o=t[e*3+1],a=t[i*3],c=t[i*3+1],l=t[r*3],u=t[r*3+1];return[new G(s,o),new G(a,c),new G(l,u)]},generateSideWallUV:function(n,t,e,i,r,s){let o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[i*3],u=t[i*3+1],h=t[i*3+2],d=t[r*3],f=t[r*3+1],p=t[r*3+2],y=t[s*3],x=t[s*3+1],g=t[s*3+2];return Math.abs(a-u)<.01?[new G(o,1-c),new G(l,1-h),new G(d,1-p),new G(y,1-g)]:[new G(a,1-c),new G(u,1-h),new G(f,1-p),new G(x,1-g)]}};function px(n,t,e){if(e.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];e.shapes.push(s.uuid)}else e.shapes.push(n.uuid);return t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}var ll=class extends Ut{constructor(t,e){super(),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new ra(t,e)),this.mergeVertices()}},ra=class extends gr{constructor(t,e){e=e||{};let i=e.font;if(!(i&&i.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Ut;let r=i.generateShapes(t,e.size);e.depth=e.height!==void 0?e.height:50,e.bevelThickness===void 0&&(e.bevelThickness=10),e.bevelSize===void 0&&(e.bevelSize=8),e.bevelEnabled===void 0&&(e.bevelEnabled=!1),super(r,e),this.type="TextBufferGeometry"}},hl=class extends Ut{constructor(t,e,i,r,s,o,a){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new As(t,e,i,r,s,o,a)),this.mergeVertices()}},As=class extends yt{constructor(t,e,i,r,s,o,a){super(),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=t||1,e=Math.max(3,Math.floor(e)||8),i=Math.max(2,Math.floor(i)||6),r=r!==void 0?r:0,s=s!==void 0?s:Math.PI*2,o=o!==void 0?o:0,a=a!==void 0?a:Math.PI;let c=Math.min(o+a,Math.PI),l=0,u=[],h=new M,d=new M,f=[],p=[],y=[],x=[];for(let g=0;g<=i;g++){let m=[],b=g/i,v=0;g==0&&o==0?v=.5/e:g==i&&c==Math.PI&&(v=-.5/e);for(let w=0;w<=e;w++){let _=w/e;h.x=-t*Math.cos(r+_*s)*Math.sin(o+b*a),h.y=t*Math.cos(o+b*a),h.z=t*Math.sin(r+_*s)*Math.sin(o+b*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),y.push(d.x,d.y,d.z),x.push(_+v,1-b),m.push(l++)}u.push(m)}for(let g=0;g<i;g++)for(let m=0;m<e;m++){let b=u[g][m+1],v=u[g][m],w=u[g+1][m],_=u[g+1][m+1];(g!==0||o>0)&&f.push(b,v,_),(g!==i-1||c<Math.PI)&&f.push(v,w,_)}this.setIndex(f),this.setAttribute("position",new st(p,3)),this.setAttribute("normal",new st(y,3)),this.setAttribute("uv",new st(x,2))}},ul=class extends Ut{constructor(t,e,i,r,s,o){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},this.fromBufferGeometry(new sa(t,e,i,r,s,o)),this.mergeVertices()}},sa=class extends yt{constructor(t,e,i,r,s,o){super(),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},t=t||.5,e=e||1,s=s!==void 0?s:0,o=o!==void 0?o:Math.PI*2,i=i!==void 0?Math.max(3,i):8,r=r!==void 0?Math.max(1,r):1;let a=[],c=[],l=[],u=[],h=t,d=(e-t)/r,f=new M,p=new G;for(let y=0;y<=r;y++){for(let x=0;x<=i;x++){let g=s+x/i*o;f.x=h*Math.cos(g),f.y=h*Math.sin(g),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/e+1)/2,p.y=(f.y/e+1)/2,u.push(p.x,p.y)}h+=d}for(let y=0;y<r;y++){let x=y*(i+1);for(let g=0;g<i;g++){let m=g+x,b=m,v=m+i+1,w=m+i+2,_=m+1;a.push(b,v,_),a.push(v,w,_)}}this.setIndex(a),this.setAttribute("position",new st(c,3)),this.setAttribute("normal",new st(l,3)),this.setAttribute("uv",new st(u,2))}},fl=class extends Ut{constructor(t,e,i,r){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},this.fromBufferGeometry(new oa(t,e,i,r)),this.mergeVertices()}},oa=class extends yt{constructor(t,e,i,r){super(),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},e=Math.floor(e)||12,i=i||0,r=r||Math.PI*2,r=_t.clamp(r,0,Math.PI*2);let s=[],o=[],a=[],c=1/e,l=new M,u=new G;for(let h=0;h<=e;h++){let d=i+h*c*r,f=Math.sin(d),p=Math.cos(d);for(let y=0;y<=t.length-1;y++)l.x=t[y].x*f,l.y=t[y].y,l.z=t[y].x*p,o.push(l.x,l.y,l.z),u.x=h/e,u.y=y/(t.length-1),a.push(u.x,u.y)}for(let h=0;h<e;h++)for(let d=0;d<t.length-1;d++){let f=d+h*t.length,p=f,y=f+t.length,x=f+t.length+1,g=f+1;s.push(p,y,g),s.push(y,x,g)}if(this.setIndex(s),this.setAttribute("position",new st(o,3)),this.setAttribute("uv",new st(a,2)),this.computeVertexNormals(),r===Math.PI*2){let h=this.attributes.normal.array,d=new M,f=new M,p=new M,y=e*t.length*3;for(let x=0,g=0;x<t.length;x++,g+=3)d.x=h[g+0],d.y=h[g+1],d.z=h[g+2],f.x=h[y+g+0],f.y=h[y+g+1],f.z=h[y+g+2],p.addVectors(d,f).normalize(),h[g+0]=h[y+g+0]=p.x,h[g+1]=h[y+g+1]=p.y,h[g+2]=h[y+g+2]=p.z}}},aa=class extends Ut{constructor(t,e){super(),this.type="ShapeGeometry",typeof e=="object"&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new ca(t,e)),this.mergeVertices()}toJSON(){let t=Ut.prototype.toJSON.call(this),e=this.parameters.shapes;return mx(e,t)}},ca=class extends yt{constructor(t,e){super(),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new st(r,3)),this.setAttribute("normal",new st(s,3)),this.setAttribute("uv",new st(o,2));function l(u){let h=r.length/3,d=u.extractPoints(e),f=d.shape,p=d.holes;Qn.isClockWise(f)===!1&&(f=f.reverse());for(let x=0,g=p.length;x<g;x++){let m=p[x];Qn.isClockWise(m)===!0&&(p[x]=m.reverse())}let y=Qn.triangulateShape(f,p);for(let x=0,g=p.length;x<g;x++){let m=p[x];f=f.concat(m)}for(let x=0,g=f.length;x<g;x++){let m=f[x];r.push(m.x,m.y,0),s.push(0,0,1),o.push(m.x,m.y)}for(let x=0,g=y.length;x<g;x++){let m=y[x],b=m[0]+h,v=m[1]+h,w=m[2]+h;i.push(b,v,w),c+=3}}}toJSON(){let t=yt.prototype.toJSON.call(this),e=this.parameters.shapes;return mx(e,t)}};function mx(n,t){if(t.shapes=[],Array.isArray(n))for(let e=0,i=n.length;e<i;e++){let r=n[e];t.shapes.push(r.uuid)}else t.shapes.push(n.uuid);return t}var la=class extends yt{constructor(t,e){super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=e!==void 0?e:1;let i=[],r=Math.cos(_t.DEG2RAD*e),s=[0,0],o={},a,c,l,u=["a","b","c"],h;t.isBufferGeometry?(h=new Ut,h.fromBufferGeometry(t)):h=t.clone(),h.mergeVertices(),h.computeFaceNormals();let d=h.vertices,f=h.faces;for(let p=0,y=f.length;p<y;p++){let x=f[p];for(let g=0;g<3;g++)a=x[u[g]],c=x[u[(g+1)%3]],s[0]=Math.min(a,c),s[1]=Math.max(a,c),l=s[0]+","+s[1],o[l]===void 0?o[l]={index1:s[0],index2:s[1],face1:p,face2:void 0}:o[l].face2=p}for(l in o){let p=o[l];if(p.face2===void 0||f[p.face1].normal.dot(f[p.face2].normal)<=r){let y=d[p.index1];i.push(y.x,y.y,y.z),y=d[p.index2],i.push(y.x,y.y,y.z)}}this.setAttribute("position",new st(i,3))}},ha=class extends Ut{constructor(t,e,i,r,s,o,a,c){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c},this.fromBufferGeometry(new yr(t,e,i,r,s,o,a,c)),this.mergeVertices()}},yr=class extends yt{constructor(t,e,i,r,s,o,a,c){super(),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,c=c!==void 0?c:Math.PI*2;let u=[],h=[],d=[],f=[],p=0,y=[],x=i/2,g=0;m(),o===!1&&(t>0&&b(!0),e>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new st(h,3)),this.setAttribute("normal",new st(d,3)),this.setAttribute("uv",new st(f,2));function m(){let v=new M,w=new M,_=0,A=(e-t)/i;for(let I=0;I<=s;I++){let D=[],N=I/s,O=N*(e-t)+t;for(let F=0;F<=r;F++){let z=F/r,P=z*c+a,R=Math.sin(P),U=Math.cos(P);w.x=O*R,w.y=-N*i+x,w.z=O*U,h.push(w.x,w.y,w.z),v.set(R,A,U).normalize(),d.push(v.x,v.y,v.z),f.push(z,1-N),D.push(p++)}y.push(D)}for(let I=0;I<r;I++)for(let D=0;D<s;D++){let N=y[D][I],O=y[D+1][I],F=y[D+1][I+1],z=y[D][I+1];u.push(N,O,z),u.push(O,F,z),_+=6}l.addGroup(g,_,0),g+=_}function b(v){let w=p,_=new G,A=new M,I=0,D=v===!0?t:e,N=v===!0?1:-1;for(let F=1;F<=r;F++)h.push(0,x*N,0),d.push(0,N,0),f.push(.5,.5),p++;let O=p;for(let F=0;F<=r;F++){let P=F/r*c+a,R=Math.cos(P),U=Math.sin(P);A.x=D*U,A.y=x*N,A.z=D*R,h.push(A.x,A.y,A.z),d.push(0,N,0),_.x=R*.5+.5,_.y=U*.5*N+.5,f.push(_.x,_.y),p++}for(let F=0;F<r;F++){let z=w+F,P=O+F;v===!0?u.push(P,P+1,z):u.push(P+1,P,z),I+=3}l.addGroup(g,I,v===!0?1:2),g+=I}}},dl=class extends ha{constructor(t,e,i,r,s,o,a){super(0,t,e,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}},pl=class extends yr{constructor(t,e,i,r,s,o,a){super(0,t,e,i,r,s,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}},ml=class extends Ut{constructor(t,e,i,r){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new ua(t,e,i,r)),this.mergeVertices()}},ua=class extends yt{constructor(t,e,i,r){super(),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},t=t||1,e=e!==void 0?Math.max(3,e):8,i=i!==void 0?i:0,r=r!==void 0?r:Math.PI*2;let s=[],o=[],a=[],c=[],l=new M,u=new G;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,d=3;h<=e;h++,d+=3){let f=i+h/e*r;l.x=t*Math.cos(f),l.y=t*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[d]/t+1)/2,u.y=(o[d+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new st(o,3)),this.setAttribute("normal",new st(a,3)),this.setAttribute("uv",new st(c,2))}},be=Object.freeze({__proto__:null,WireframeGeometry:Xo,ParametricGeometry:qo,ParametricBufferGeometry:Es,TetrahedronGeometry:nl,TetrahedronBufferGeometry:Yo,OctahedronGeometry:il,OctahedronBufferGeometry:Ts,IcosahedronGeometry:rl,IcosahedronBufferGeometry:Zo,DodecahedronGeometry:sl,DodecahedronBufferGeometry:Jo,PolyhedronGeometry:el,PolyhedronBufferGeometry:ti,TubeGeometry:ol,TubeBufferGeometry:$o,TorusKnotGeometry:al,TorusKnotBufferGeometry:Qo,TorusGeometry:cl,TorusBufferGeometry:Ko,TextGeometry:ll,TextBufferGeometry:ra,SphereGeometry:hl,SphereBufferGeometry:As,RingGeometry:ul,RingBufferGeometry:sa,PlaneGeometry:qc,PlaneBufferGeometry:bs,LatheGeometry:fl,LatheBufferGeometry:oa,ShapeGeometry:aa,ShapeBufferGeometry:ca,ExtrudeGeometry:ia,ExtrudeBufferGeometry:gr,EdgesGeometry:la,ConeGeometry:dl,ConeBufferGeometry:pl,CylinderGeometry:ha,CylinderBufferGeometry:yr,CircleGeometry:ml,CircleBufferGeometry:ua,BoxGeometry:ko,BoxBufferGeometry:dr});function xr(n){bt.call(this),this.type="ShadowMaterial",this.color=new lt(0),this.transparent=!0,this.setValues(n)}xr.prototype=Object.create(bt.prototype);xr.prototype.constructor=xr;xr.prototype.isShadowMaterial=!0;xr.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this};function ei(n){Me.call(this,n),this.type="RawShaderMaterial"}ei.prototype=Object.create(Me.prototype);ei.prototype.constructor=ei;ei.prototype.isRawShaderMaterial=!0;function En(n){bt.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new lt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(n)}En.prototype=Object.create(bt.prototype);En.prototype.constructor=En;En.prototype.isMeshStandardMaterial=!0;En.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.defines={STANDARD:""},this.color.copy(n.color),this.roughness=n.roughness,this.metalness=n.metalness,this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.roughnessMap=n.roughnessMap,this.metalnessMap=n.metalnessMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.envMapIntensity=n.envMapIntensity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this.vertexTangents=n.vertexTangents,this};function Fi(n){En.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new G(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(n)}Fi.prototype=Object.create(En.prototype);Fi.prototype.constructor=Fi;Fi.prototype.isMeshPhysicalMaterial=!0;Fi.prototype.copy=function(n){return En.prototype.copy.call(this,n),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=n.clearcoat,this.clearcoatMap=n.clearcoatMap,this.clearcoatRoughness=n.clearcoatRoughness,this.clearcoatRoughnessMap=n.clearcoatRoughnessMap,this.clearcoatNormalMap=n.clearcoatNormalMap,this.clearcoatNormalScale.copy(n.clearcoatNormalScale),this.reflectivity=n.reflectivity,n.sheen?this.sheen=(this.sheen||new lt).copy(n.sheen):this.sheen=null,this.transmission=n.transmission,this.transmissionMap=n.transmissionMap,this};function zi(n){bt.call(this),this.type="MeshPhongMaterial",this.color=new lt(16777215),this.specular=new lt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=va,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(n)}zi.prototype=Object.create(bt.prototype);zi.prototype.constructor=zi;zi.prototype.isMeshPhongMaterial=!0;zi.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.specular.copy(n.specular),this.shininess=n.shininess,this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this};function vr(n){bt.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new lt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new G(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(n)}vr.prototype=Object.create(bt.prototype);vr.prototype.constructor=vr;vr.prototype.isMeshToonMaterial=!0;vr.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.map=n.map,this.gradientMap=n.gradientMap,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.alphaMap=n.alphaMap,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this};function br(n){bt.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(n)}br.prototype=Object.create(bt.prototype);br.prototype.constructor=br;br.prototype.isMeshNormalMaterial=!0;br.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this};function _r(n){bt.call(this),this.type="MeshLambertMaterial",this.color=new lt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=va,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(n)}_r.prototype=Object.create(bt.prototype);_r.prototype.constructor=_r;_r.prototype.isMeshLambertMaterial=!0;_r.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this};function wr(n){bt.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new lt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new G(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(n)}wr.prototype=Object.create(bt.prototype);wr.prototype.constructor=wr;wr.prototype.isMeshMatcapMaterial=!0;wr.prototype.copy=function(n){return bt.prototype.copy.call(this,n),this.defines={MATCAP:""},this.color.copy(n.color),this.matcap=n.matcap,this.map=n.map,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.alphaMap=n.alphaMap,this.skinning=n.skinning,this.morphTargets=n.morphTargets,this.morphNormals=n.morphNormals,this};function Mr(n){Zt.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(n)}Mr.prototype=Object.create(Zt.prototype);Mr.prototype.constructor=Mr;Mr.prototype.isLineDashedMaterial=!0;Mr.prototype.copy=function(n){return Zt.prototype.copy.call(this,n),this.scale=n.scale,this.dashSize=n.dashSize,this.gapSize=n.gapSize,this};var BS=Object.freeze({__proto__:null,ShadowMaterial:xr,SpriteMaterial:Di,RawShaderMaterial:ei,ShaderMaterial:Me,PointsMaterial:ln,MeshPhysicalMaterial:Fi,MeshStandardMaterial:En,MeshPhongMaterial:zi,MeshToonMaterial:vr,MeshNormalMaterial:br,MeshLambertMaterial:_r,MeshDepthMaterial:Pi,MeshDistanceMaterial:Ri,MeshBasicMaterial:Xe,MeshMatcapMaterial:wr,LineDashedMaterial:Mr,LineBasicMaterial:Zt,Material:bt}),qt={arraySlice:function(n,t,e){return qt.isTypedArray(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)},convertArray:function(n,t,e){return!n||!e&&n.constructor===t?n:typeof t.BYTES_PER_ELEMENT=="number"?new t(n):Array.prototype.slice.call(n)},isTypedArray:function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},getKeyframeOrder:function(n){function t(r,s){return n[r]-n[s]}let e=n.length,i=new Array(e);for(let r=0;r!==e;++r)i[r]=r;return i.sort(t),i},sortedArray:function(n,t,e){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=e[s]*t;for(let c=0;c!==t;++c)r[o++]=n[a+c]}return r},flattenJSON:function(n,t,e,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(t.push(s.time),e.push(o)),s=n[r++];while(s!==void 0)},subclip:function(n,t,e,i,r){r=r||30;let s=n.clone();s.name=t;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),h=[],d=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*r;if(!(p<e||p>=i)){h.push(l.times[f]);for(let y=0;y<u;++y)d.push(l.values[f*u+y])}}h.length!==0&&(l.times=qt.convertArray(h,l.times.constructor),l.values=qt.convertArray(d,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(n,t,e,i){t===void 0&&(t=0),e===void 0&&(e=n),(i===void 0||i<=0)&&(i=30);let r=n.tracks.length,s=t/i;for(let o=0;o<r;++o){let a=e.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let g=u,m=h-u;y=qt.arraySlice(a.values,g,m)}else if(s>=a.times[p]){let g=p*h+u,m=g+h-u;y=qt.arraySlice(a.values,g,m)}else{let g=a.createInterpolant(),m=u,b=h-u;g.evaluate(s),y=qt.arraySlice(g.resultBuffer,m,b)}c==="quaternion"&&new ie().fromArray(y).normalize().conjugate().toArray(y);let x=l.times.length;for(let g=0;g<x;++g){let m=g*f+d;if(c==="quaternion")ie.multiplyQuaternionsFlat(l.values,m,y,0,l.values,m);else{let b=f-d*2;for(let v=0;v<b;++v)l.values[m+v]-=y[v]}}}return n.blendMode=gd,n}};function Ne(n,t,e,i){this.parameterPositions=n,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(e),this.sampleValues=t,this.valueSize=e}Object.assign(Ne.prototype,{evaluate:function(n){let t=this.parameterPositions,e=this._cachedIndex,i=t[e],r=t[e-1];t:{e:{let s;n:{i:if(!(n<i)){for(let o=e+2;;){if(i===void 0){if(n<r)break i;return e=t.length,this._cachedIndex=e,this.afterEnd_(e-1,n,r)}if(e===o)break;if(r=i,i=t[++e],n<i)break e}s=t.length;break n}if(!(n>=r)){let o=t[1];n<o&&(e=2,r=o);for(let a=e-2;;){if(r===void 0)return this._cachedIndex=0,this.beforeStart_(0,n,i);if(e===a)break;if(i=r,r=t[--e-1],n>=r)break e}s=e,e=0;break n}break t}for(;e<s;){let o=e+s>>>1;n<t[o]?s=o:e=o+1}if(i=t[e],r=t[e-1],r===void 0)return this._cachedIndex=0,this.beforeStart_(0,n,i);if(i===void 0)return e=t.length,this._cachedIndex=e,this.afterEnd_(e-1,r,n)}this._cachedIndex=e,this.intervalChanged_(e,r,i)}return this.interpolate_(e,r,n,i)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(n){let t=this.resultBuffer,e=this.sampleValues,i=this.valueSize,r=n*i;for(let s=0;s!==i;++s)t[s]=e[r+s];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}});Object.assign(Ne.prototype,{beforeStart_:Ne.prototype.copySampleValue_,afterEnd_:Ne.prototype.copySampleValue_});function gl(n,t,e,i){Ne.call(this,n,t,e,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}gl.prototype=Object.assign(Object.create(Ne.prototype),{constructor:gl,DefaultSettings_:{endingStart:sr,endingEnd:sr},intervalChanged_:function(n,t,e){let i=this.parameterPositions,r=n-2,s=n+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case or:r=n,o=2*t-e;break;case Io:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=n,o=e}if(a===void 0)switch(this.getSettings_().endingEnd){case or:s=n,a=2*e-t;break;case Io:s=1,a=e+i[1]-i[0];break;default:s=n-1,a=t}let c=(e-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-e),this._offsetPrev=r*l,this._offsetNext=s*l},interpolate_:function(n,t,e,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=n*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(e-t)/(i-t),p=f*f,y=p*f,x=-h*y+2*h*p-h*f,g=(1+h)*y+(-1.5-2*h)*p+(-.5+h)*f+1,m=(-1-d)*y+(1.5+d)*p+.5*f,b=d*y-d*p;for(let v=0;v!==o;++v)r[v]=x*s[l+v]+g*s[c+v]+m*s[a+v]+b*s[u+v];return r}});function fa(n,t,e,i){Ne.call(this,n,t,e,i)}fa.prototype=Object.assign(Object.create(Ne.prototype),{constructor:fa,interpolate_:function(n,t,e,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=n*o,c=a-o,l=(e-t)/(i-t),u=1-l;for(let h=0;h!==o;++h)r[h]=s[c+h]*u+s[a+h]*l;return r}});function yl(n,t,e,i){Ne.call(this,n,t,e,i)}yl.prototype=Object.assign(Object.create(Ne.prototype),{constructor:yl,interpolate_:function(n){return this.copySampleValue_(n-1)}});function me(n,t,e,i){if(n===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+n);this.name=n,this.times=qt.convertArray(t,this.TimeBufferType),this.values=qt.convertArray(e,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}Object.assign(me,{toJSON:function(n){let t=n.constructor,e;if(t.toJSON!==void 0)e=t.toJSON(n);else{e={name:n.name,times:qt.convertArray(n.times,Array),values:qt.convertArray(n.values,Array)};let i=n.getInterpolation();i!==n.DefaultInterpolation&&(e.interpolation=i)}return e.type=n.ValueTypeName,e}});Object.assign(me.prototype,{constructor:me,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:wo,InterpolantFactoryMethodDiscrete:function(n){return new yl(this.times,this.values,this.getValueSize(),n)},InterpolantFactoryMethodLinear:function(n){return new fa(this.times,this.values,this.getValueSize(),n)},InterpolantFactoryMethodSmooth:function(n){return new gl(this.times,this.values,this.getValueSize(),n)},setInterpolation:function(n){let t;switch(n){case Ro:t=this.InterpolantFactoryMethodDiscrete;break;case wo:t=this.InterpolantFactoryMethodLinear;break;case kc:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(n!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(e);return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ro;case this.InterpolantFactoryMethodLinear:return wo;case this.InterpolantFactoryMethodSmooth:return kc}},getValueSize:function(){return this.values.length/this.times.length},shift:function(n){if(n!==0){let t=this.times;for(let e=0,i=t.length;e!==i;++e)t[e]+=n}return this},scale:function(n){if(n!==1){let t=this.times;for(let e=0,i=t.length;e!==i;++e)t[e]*=n}return this},trim:function(n,t){let e=this.times,i=e.length,r=0,s=i-1;for(;r!==i&&e[r]<n;)++r;for(;s!==-1&&e[s]>t;)--s;if(++s,r!==0||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);let o=this.getValueSize();this.times=qt.arraySlice(e,r,s),this.values=qt.arraySlice(this.values,r*o,s*o)}return this},validate:function(){let n=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),n=!1);let e=this.times,i=this.values,r=e.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),n=!1);let s=null;for(let o=0;o!==r;o++){let a=e[o];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,a),n=!1;break}if(s!==null&&s>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,a,s),n=!1;break}s=a}if(i!==void 0&&qt.isTypedArray(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),n=!1;break}}return n},optimize:function(){let n=qt.arraySlice(this.times),t=qt.arraySlice(this.values),e=this.getValueSize(),i=this.getInterpolation()===kc,r=n.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=n[o],l=n[o+1];if(c!==l&&(o!==1||c!==c[0]))if(i)a=!0;else{let u=o*e,h=u-e,d=u+e;for(let f=0;f!==e;++f){let p=t[u+f];if(p!==t[h+f]||p!==t[d+f]){a=!0;break}}}if(a){if(o!==s){n[s]=n[o];let u=o*e,h=s*e;for(let d=0;d!==e;++d)t[h+d]=t[u+d]}++s}}if(r>0){n[s]=n[r];for(let o=r*e,a=s*e,c=0;c!==e;++c)t[a+c]=t[o+c];++s}return s!==n.length?(this.times=qt.arraySlice(n,0,s),this.values=qt.arraySlice(t,0,s*e)):(this.times=n,this.values=t),this},clone:function(){let n=qt.arraySlice(this.times,0),t=qt.arraySlice(this.values,0),e=this.constructor,i=new e(this.name,n,t);return i.createInterpolant=this.createInterpolant,i}});function xl(n,t,e){me.call(this,n,t,e)}xl.prototype=Object.assign(Object.create(me.prototype),{constructor:xl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Ro,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function vl(n,t,e,i){me.call(this,n,t,e,i)}vl.prototype=Object.assign(Object.create(me.prototype),{constructor:vl,ValueTypeName:"color"});function Cs(n,t,e,i){me.call(this,n,t,e,i)}Cs.prototype=Object.assign(Object.create(me.prototype),{constructor:Cs,ValueTypeName:"number"});function bl(n,t,e,i){Ne.call(this,n,t,e,i)}bl.prototype=Object.assign(Object.create(Ne.prototype),{constructor:bl,interpolate_:function(n,t,e,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(e-t)/(i-t),c=n*o;for(let l=c+o;c!==l;c+=4)ie.slerpFlat(r,0,s,c-o,s,c,a);return r}});function da(n,t,e,i){me.call(this,n,t,e,i)}da.prototype=Object.assign(Object.create(me.prototype),{constructor:da,ValueTypeName:"quaternion",DefaultInterpolation:wo,InterpolantFactoryMethodLinear:function(n){return new bl(this.times,this.values,this.getValueSize(),n)},InterpolantFactoryMethodSmooth:void 0});function _l(n,t,e,i){me.call(this,n,t,e,i)}_l.prototype=Object.assign(Object.create(me.prototype),{constructor:_l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Ro,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Ls(n,t,e,i){me.call(this,n,t,e,i)}Ls.prototype=Object.assign(Object.create(me.prototype),{constructor:Ls,ValueTypeName:"vector"});function He(n,t,e,i){this.name=n,this.tracks=e,this.duration=t!==void 0?t:-1,this.blendMode=i!==void 0?i:ql,this.uuid=_t.generateUUID(),this.duration<0&&this.resetDuration()}function US(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Cs;case"vector":case"vector2":case"vector3":case"vector4":return Ls;case"color":return vl;case"quaternion":return da;case"bool":case"boolean":return xl;case"string":return _l}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function kS(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=US(n.type);if(n.times===void 0){let e=[],i=[];qt.flattenJSON(n.keys,e,i,"value"),n.times=e,n.values=i}return t.parse!==void 0?t.parse(n):new t(n.name,n.times,n.values,n.interpolation)}Object.assign(He,{parse:function(n){let t=[],e=n.tracks,i=1/(n.fps||1);for(let r=0,s=e.length;r!==s;++r)t.push(kS(e[r]).scale(i));return new He(n.name,n.duration,t,n.blendMode)},toJSON:function(n){let t=[],e=n.tracks,i={name:n.name,duration:n.duration,tracks:t,uuid:n.uuid,blendMode:n.blendMode};for(let r=0,s=e.length;r!==s;++r)t.push(me.toJSON(e[r]));return i},CreateFromMorphTargetSequence:function(n,t,e,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=qt.getKeyframeOrder(a);a=qt.sortedArray(a,1,l),c=qt.sortedArray(c,1,l),!i&&a[0]===0&&(a.push(r),c.push(c[0])),s.push(new Cs(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/e))}return new He(n,-1,s)},findByName:function(n,t){let e=n;if(!Array.isArray(n)){let i=n;e=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<e.length;i++)if(e[i].name===t)return e[i];return null},CreateClipsFromMorphTargetSequences:function(n,t,e){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=n.length;o<a;o++){let c=n[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],h=i[u];h||(i[u]=h=[]),h.push(c)}}let s=[];for(let o in i)s.push(He.CreateFromMorphTargetSequence(o,i[o],t,e));return s},parseAnimation:function(n,t){if(!n)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let e=function(u,h,d,f,p){if(d.length!==0){let y=[],x=[];qt.flattenJSON(d,y,x,f),y.length!==0&&p.push(new u(h,y,x))}},i=[],r=n.name||"default",s=n.fps||30,o=n.blendMode,a=n.length||-1,c=n.hierarchy||[];for(let u=0;u<c.length;u++){let h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let d={},f;for(f=0;f<h.length;f++)if(h[f].morphTargets)for(let p=0;p<h[f].morphTargets.length;p++)d[h[f].morphTargets[p]]=-1;for(let p in d){let y=[],x=[];for(let g=0;g!==h[f].morphTargets.length;++g){let m=h[f];y.push(m.time),x.push(m.morphTarget===p?1:0)}i.push(new Cs(".morphTargetInfluence["+p+"]",y,x))}a=d.length*(s||1)}else{let d=".bones["+t[u].name+"]";e(Ls,d+".position",h,"pos",i),e(da,d+".quaternion",h,"rot",i),e(Ls,d+".scale",h,"scl",i)}}return i.length===0?null:new He(r,a,i,o)}});Object.assign(He.prototype,{resetDuration:function(){let n=this.tracks,t=0;for(let e=0,i=n.length;e!==i;++e){let r=this.tracks[e];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this},trim:function(){for(let n=0;n<this.tracks.length;n++)this.tracks[n].trim(0,this.duration);return this},validate:function(){let n=!0;for(let t=0;t<this.tracks.length;t++)n=n&&this.tracks[t].validate();return n},optimize:function(){for(let n=0;n<this.tracks.length;n++)this.tracks[n].optimize();return this},clone:function(){let n=[];for(let t=0;t<this.tracks.length;t++)n.push(this.tracks[t].clone());return new He(this.name,this.duration,n,this.blendMode)}});var Sr={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};function bd(n,t,e){let i=this,r=!1,s=0,o=0,a,c=[];this.onStart=void 0,this.onLoad=n,this.onProgress=t,this.onError=e,this.itemStart=function(l){o++,r===!1&&i.onStart!==void 0&&i.onStart(l,s,o),r=!0},this.itemEnd=function(l){s++,i.onProgress!==void 0&&i.onProgress(l,s,o),s===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(l){i.onError!==void 0&&i.onError(l)},this.resolveURL=function(l){return a?a(l):l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);return u!==-1&&c.splice(u,2),this},this.getHandler=function(l){for(let u=0,h=c.length;u<h;u+=2){let d=c[u],f=c[u+1];if(d.global&&(d.lastIndex=0),d.test(l))return f}return null}}var gx=new bd;function kt(n){this.manager=n!==void 0?n:gx,this.crossOrigin="anonymous",this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(kt.prototype,{load:function(){},loadAsync:function(n,t){let e=this;return new Promise(function(i,r){e.load(n,i,t,r)})},parse:function(){},setCrossOrigin:function(n){return this.crossOrigin=n,this},setPath:function(n){return this.path=n,this},setResourcePath:function(n){return this.resourcePath=n,this},setRequestHeader:function(n){return this.requestHeader=n,this}});var sn={};function Ze(n){kt.call(this,n)}Ze.prototype=Object.assign(Object.create(kt.prototype),{constructor:Ze,load:function(n,t,e,i){n===void 0&&(n=""),this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);let r=this,s=Sr.get(n);if(s!==void 0)return r.manager.itemStart(n),setTimeout(function(){t&&t(s),r.manager.itemEnd(n)},0),s;if(sn[n]!==void 0){sn[n].push({onLoad:t,onProgress:e,onError:i});return}let o=/^data:(.*?)(;base64)?,(.*)$/,a=n.match(o),c;if(a){let l=a[1],u=!!a[2],h=a[3];h=decodeURIComponent(h),u&&(h=atob(h));try{let d,f=(this.responseType||"").toLowerCase();switch(f){case"arraybuffer":case"blob":let p=new Uint8Array(h.length);for(let x=0;x<h.length;x++)p[x]=h.charCodeAt(x);f==="blob"?d=new Blob([p.buffer],{type:l}):d=p.buffer;break;case"document":d=new DOMParser().parseFromString(h,l);break;case"json":d=JSON.parse(h);break;default:d=h;break}setTimeout(function(){t&&t(d),r.manager.itemEnd(n)},0)}catch(d){setTimeout(function(){i&&i(d),r.manager.itemError(n),r.manager.itemEnd(n)},0)}}else{sn[n]=[],sn[n].push({onLoad:t,onProgress:e,onError:i}),c=new XMLHttpRequest,c.open("GET",n,!0),c.addEventListener("load",function(l){let u=this.response,h=sn[n];if(delete sn[n],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Sr.add(n,u);for(let d=0,f=h.length;d<f;d++){let p=h[d];p.onLoad&&p.onLoad(u)}r.manager.itemEnd(n)}else{for(let d=0,f=h.length;d<f;d++){let p=h[d];p.onError&&p.onError(l)}r.manager.itemError(n),r.manager.itemEnd(n)}},!1),c.addEventListener("progress",function(l){let u=sn[n];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onProgress&&f.onProgress(l)}},!1),c.addEventListener("error",function(l){let u=sn[n];delete sn[n];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(l)}r.manager.itemError(n),r.manager.itemEnd(n)},!1),c.addEventListener("abort",function(l){let u=sn[n];delete sn[n];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(l)}r.manager.itemError(n),r.manager.itemEnd(n)},!1),this.responseType!==void 0&&(c.responseType=this.responseType),this.withCredentials!==void 0&&(c.withCredentials=this.withCredentials),c.overrideMimeType&&c.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(let l in this.requestHeader)c.setRequestHeader(l,this.requestHeader[l]);c.send(null)}return r.manager.itemStart(n),c},setResponseType:function(n){return this.responseType=n,this},setWithCredentials:function(n){return this.withCredentials=n,this},setMimeType:function(n){return this.mimeType=n,this}});function Nf(n){kt.call(this,n)}Nf.prototype=Object.assign(Object.create(kt.prototype),{constructor:Nf,load:function(n,t,e,i){let r=this,s=new Ze(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.load(n,function(o){try{t(r.parse(JSON.parse(o)))}catch(a){i?i(a):console.error(a),r.manager.itemError(n)}},e,i)},parse:function(n){let t=[];for(let e=0;e<n.length;e++){let i=He.parse(n[e]);t.push(i)}return t}});function Bf(n){kt.call(this,n)}Bf.prototype=Object.assign(Object.create(kt.prototype),{constructor:Bf,load:function(n,t,e,i){let r=this,s=[],o=new Ss;o.image=s;let a=new Ze(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader);let c=0;function l(u){a.load(n[u],function(h){let d=r.parse(h,!0);s[u]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},c+=1,c===6&&(d.mipmapCount===1&&(o.minFilter=he),o.format=d.format,o.needsUpdate=!0,t&&t(o))},e,i)}if(Array.isArray(n))for(let u=0,h=n.length;u<h;++u)l(u);else a.load(n,function(u){let h=r.parse(u,!0);if(h.isCubemap){let d=h.mipmaps.length/h.mipmapCount;for(let f=0;f<d;f++){s[f]={mipmaps:[]};for(let p=0;p<h.mipmapCount;p++)s[f].mipmaps.push(h.mipmaps[f*h.mipmapCount+p]),s[f].format=h.format,s[f].width=h.width,s[f].height=h.height}}else o.image.width=h.width,o.image.height=h.height,o.mipmaps=h.mipmaps;h.mipmapCount===1&&(o.minFilter=he),o.format=h.format,o.needsUpdate=!0,t&&t(o)},e,i);return o}});function Ps(n){kt.call(this,n)}Ps.prototype=Object.assign(Object.create(kt.prototype),{constructor:Ps,load:function(n,t,e,i){this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);let r=this,s=Sr.get(n);if(s!==void 0)return r.manager.itemStart(n),setTimeout(function(){t&&t(s),r.manager.itemEnd(n)},0),s;let o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),Sr.add(n,this),t&&t(this),r.manager.itemEnd(n)}function c(l){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),i&&i(l),r.manager.itemError(n),r.manager.itemEnd(n)}return o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),n.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(n),o.src=n,o}});function wl(n){kt.call(this,n)}wl.prototype=Object.assign(Object.create(kt.prototype),{constructor:wl,load:function(n,t,e,i){let r=new Kn,s=new Ps(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function a(c){s.load(n[c],function(l){r.images[c]=l,o++,o===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let c=0;c<n.length;++c)a(c);return r}});function Ml(n){kt.call(this,n)}Ml.prototype=Object.assign(Object.create(kt.prototype),{constructor:Ml,load:function(n,t,e,i){let r=this,s=new pr,o=new Ze(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.load(n,function(a){let c=r.parse(a);c&&(c.image!==void 0?s.image=c.image:c.data!==void 0&&(s.image.width=c.width,s.image.height=c.height,s.image.data=c.data),s.wrapS=c.wrapS!==void 0?c.wrapS:_e,s.wrapT=c.wrapT!==void 0?c.wrapT:_e,s.magFilter=c.magFilter!==void 0?c.magFilter:he,s.minFilter=c.minFilter!==void 0?c.minFilter:he,s.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.format!==void 0&&(s.format=c.format),c.type!==void 0&&(s.type=c.type),c.mipmaps!==void 0&&(s.mipmaps=c.mipmaps,s.minFilter=zs),c.mipmapCount===1&&(s.minFilter=he),s.needsUpdate=!0,t&&t(s,c))},e,i),s}});function Sl(n){kt.call(this,n)}Sl.prototype=Object.assign(Object.create(kt.prototype),{constructor:Sl,load:function(n,t,e,i){let r=new Gt,s=new Ps(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(n,function(o){r.image=o;let a=n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0;r.format=a?Mi:Fe,r.needsUpdate=!0,t!==void 0&&t(r)},e,i),r}});function gt(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(gt.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(n,t){let e=this.getUtoTmapping(n);return this.getPoint(e,t)},getPoints:function(n){n===void 0&&(n=5);let t=[];for(let e=0;e<=n;e++)t.push(this.getPoint(e/n));return t},getSpacedPoints:function(n){n===void 0&&(n=5);let t=[];for(let e=0;e<=n;e++)t.push(this.getPointAt(e/n));return t},getLength:function(){let n=this.getLengths();return n[n.length-1]},getLengths:function(n){if(n===void 0&&(n=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===n+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],e,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=n;s++)e=this.getPoint(s/n),r+=e.distanceTo(i),t.push(r),i=e;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(n,t){let e=this.getLengths(),i=0,r=e.length,s;t?s=t:s=n*e[r-1];let o=0,a=r-1,c;for(;o<=a;)if(i=Math.floor(o+(a-o)/2),c=e[i]-s,c<0)o=i+1;else if(c>0)a=i-1;else{a=i;break}if(i=a,e[i]===s)return i/(r-1);let l=e[i],h=e[i+1]-l,d=(s-l)/h;return(i+d)/(r-1)},getTangent:function(n,t){let i=n-1e-4,r=n+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),o=this.getPoint(r),a=t||(s.isVector2?new G:new M);return a.copy(o).sub(s).normalize(),a},getTangentAt:function(n,t){let e=this.getUtoTmapping(n);return this.getTangent(e,t)},computeFrenetFrames:function(n,t){let e=new M,i=[],r=[],s=[],o=new M,a=new At;for(let d=0;d<=n;d++){let f=d/n;i[d]=this.getTangentAt(f,new M),i[d].normalize()}r[0]=new M,s[0]=new M;let c=Number.MAX_VALUE,l=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);l<=c&&(c=l,e.set(1,0,0)),u<=c&&(c=u,e.set(0,1,0)),h<=c&&e.set(0,0,1),o.crossVectors(i[0],e).normalize(),r[0].crossVectors(i[0],o),s[0].crossVectors(i[0],r[0]);for(let d=1;d<=n;d++){if(r[d]=r[d-1].clone(),s[d]=s[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();let f=Math.acos(_t.clamp(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(a.makeRotationAxis(o,f))}s[d].crossVectors(i[d],r[d])}if(t===!0){let d=Math.acos(_t.clamp(r[0].dot(r[n]),-1,1));d/=n,i[0].dot(o.crossVectors(r[0],r[n]))>0&&(d=-d);for(let f=1;f<=n;f++)r[f].applyMatrix4(a.makeRotationAxis(i[f],d*f)),s[f].crossVectors(i[f],r[f])}return{tangents:i,normals:r,binormals:s}},clone:function(){return new this.constructor().copy(this)},copy:function(n){return this.arcLengthDivisions=n.arcLengthDivisions,this},toJSON:function(){let n={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return n.arcLengthDivisions=this.arcLengthDivisions,n.type=this.type,n},fromJSON:function(n){return this.arcLengthDivisions=n.arcLengthDivisions,this}});function Ue(n,t,e,i,r,s,o,a){gt.call(this),this.type="EllipseCurve",this.aX=n||0,this.aY=t||0,this.xRadius=e||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=s||2*Math.PI,this.aClockwise=o||!1,this.aRotation=a||0}Ue.prototype=Object.create(gt.prototype);Ue.prototype.constructor=Ue;Ue.prototype.isEllipseCurve=!0;Ue.prototype.getPoint=function(n,t){let e=t||new G,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(s?r=0:r=i),this.aClockwise===!0&&!s&&(r===i?r=-i:r=r-i);let o=this.aStartAngle+n*r,a=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let l=Math.cos(this.aRotation),u=Math.sin(this.aRotation),h=a-this.aX,d=c-this.aY;a=h*l-d*u+this.aX,c=h*u+d*l+this.aY}return e.set(a,c)};Ue.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.aX=n.aX,this.aY=n.aY,this.xRadius=n.xRadius,this.yRadius=n.yRadius,this.aStartAngle=n.aStartAngle,this.aEndAngle=n.aEndAngle,this.aClockwise=n.aClockwise,this.aRotation=n.aRotation,this};Ue.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.aX=this.aX,n.aY=this.aY,n.xRadius=this.xRadius,n.yRadius=this.yRadius,n.aStartAngle=this.aStartAngle,n.aEndAngle=this.aEndAngle,n.aClockwise=this.aClockwise,n.aRotation=this.aRotation,n};Ue.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.aX=n.aX,this.aY=n.aY,this.xRadius=n.xRadius,this.yRadius=n.yRadius,this.aStartAngle=n.aStartAngle,this.aEndAngle=n.aEndAngle,this.aClockwise=n.aClockwise,this.aRotation=n.aRotation,this};function Rs(n,t,e,i,r,s){Ue.call(this,n,t,e,e,i,r,s),this.type="ArcCurve"}Rs.prototype=Object.create(Ue.prototype);Rs.prototype.constructor=Rs;Rs.prototype.isArcCurve=!0;function _d(){let n=0,t=0,e=0,i=0;function r(s,o,a,c){n=s,t=a,e=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let d=(o-s)/l-(a-s)/(l+u)+(a-o)/u,f=(a-o)/u-(c-o)/(u+h)+(c-a)/h;d*=u,f*=u,r(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return n+t*s+e*o+i*a}}}var Lc=new M,rf=new _d,sf=new _d,of=new _d;function xe(n,t,e,i){gt.call(this),this.type="CatmullRomCurve3",this.points=n||[],this.closed=t||!1,this.curveType=e||"centripetal",this.tension=i!==void 0?i:.5}xe.prototype=Object.create(gt.prototype);xe.prototype.constructor=xe;xe.prototype.isCatmullRomCurve3=!0;xe.prototype.getPoint=function(n,t){let e=t||new M,i=this.points,r=i.length,s=(r-(this.closed?0:1))*n,o=Math.floor(s),a=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:a===0&&o===r-1&&(o=r-2,a=1);let c,l;this.closed||o>0?c=i[(o-1)%r]:(Lc.subVectors(i[0],i[1]).add(i[0]),c=Lc);let u=i[o%r],h=i[(o+1)%r];if(this.closed||o+2<r?l=i[(o+2)%r]:(Lc.subVectors(i[r-1],i[r-2]).add(i[r-1]),l=Lc),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,f=Math.pow(c.distanceToSquared(u),d),p=Math.pow(u.distanceToSquared(h),d),y=Math.pow(h.distanceToSquared(l),d);p<1e-4&&(p=1),f<1e-4&&(f=p),y<1e-4&&(y=p),rf.initNonuniformCatmullRom(c.x,u.x,h.x,l.x,f,p,y),sf.initNonuniformCatmullRom(c.y,u.y,h.y,l.y,f,p,y),of.initNonuniformCatmullRom(c.z,u.z,h.z,l.z,f,p,y)}else this.curveType==="catmullrom"&&(rf.initCatmullRom(c.x,u.x,h.x,l.x,this.tension),sf.initCatmullRom(c.y,u.y,h.y,l.y,this.tension),of.initCatmullRom(c.z,u.z,h.z,l.z,this.tension));return e.set(rf.calc(a),sf.calc(a),of.calc(a)),e};xe.prototype.copy=function(n){gt.prototype.copy.call(this,n),this.points=[];for(let t=0,e=n.points.length;t<e;t++){let i=n.points[t];this.points.push(i.clone())}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this};xe.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);n.points=[];for(let t=0,e=this.points.length;t<e;t++){let i=this.points[t];n.points.push(i.toArray())}return n.closed=this.closed,n.curveType=this.curveType,n.tension=this.tension,n};xe.prototype.fromJSON=function(n){gt.prototype.fromJSON.call(this,n),this.points=[];for(let t=0,e=n.points.length;t<e;t++){let i=n.points[t];this.points.push(new M().fromArray(i))}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this};function $m(n,t,e,i,r){let s=(i-t)*.5,o=(r-e)*.5,a=n*n,c=n*a;return(2*e-2*i+s+o)*c+(-3*e+3*i-2*s-o)*a+s*n+e}function GS(n,t){let e=1-n;return e*e*t}function HS(n,t){return 2*(1-n)*n*t}function VS(n,t){return n*n*t}function Eo(n,t,e,i){return GS(n,t)+HS(n,e)+VS(n,i)}function WS(n,t){let e=1-n;return e*e*e*t}function jS(n,t){let e=1-n;return 3*e*e*n*t}function XS(n,t){return 3*(1-n)*n*n*t}function qS(n,t){return n*n*n*t}function To(n,t,e,i,r){return WS(n,t)+jS(n,e)+XS(n,i)+qS(n,r)}function hn(n,t,e,i){gt.call(this),this.type="CubicBezierCurve",this.v0=n||new G,this.v1=t||new G,this.v2=e||new G,this.v3=i||new G}hn.prototype=Object.create(gt.prototype);hn.prototype.constructor=hn;hn.prototype.isCubicBezierCurve=!0;hn.prototype.getPoint=function(n,t){let e=t||new G,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return e.set(To(n,i.x,r.x,s.x,o.x),To(n,i.y,r.y,s.y,o.y)),e};hn.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this.v3.copy(n.v3),this};hn.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n.v3=this.v3.toArray(),n};hn.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this.v3.fromArray(n.v3),this};function Tn(n,t,e,i){gt.call(this),this.type="CubicBezierCurve3",this.v0=n||new M,this.v1=t||new M,this.v2=e||new M,this.v3=i||new M}Tn.prototype=Object.create(gt.prototype);Tn.prototype.constructor=Tn;Tn.prototype.isCubicBezierCurve3=!0;Tn.prototype.getPoint=function(n,t){let e=t||new M,i=this.v0,r=this.v1,s=this.v2,o=this.v3;return e.set(To(n,i.x,r.x,s.x,o.x),To(n,i.y,r.y,s.y,o.y),To(n,i.z,r.z,s.z,o.z)),e};Tn.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this.v3.copy(n.v3),this};Tn.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n.v3=this.v3.toArray(),n};Tn.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this.v3.fromArray(n.v3),this};function Ae(n,t){gt.call(this),this.type="LineCurve",this.v1=n||new G,this.v2=t||new G}Ae.prototype=Object.create(gt.prototype);Ae.prototype.constructor=Ae;Ae.prototype.isLineCurve=!0;Ae.prototype.getPoint=function(n,t){let e=t||new G;return n===1?e.copy(this.v2):(e.copy(this.v2).sub(this.v1),e.multiplyScalar(n).add(this.v1)),e};Ae.prototype.getPointAt=function(n,t){return this.getPoint(n,t)};Ae.prototype.getTangent=function(n,t){let e=t||new G;return e.copy(this.v2).sub(this.v1).normalize(),e};Ae.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v1.copy(n.v1),this.v2.copy(n.v2),this};Ae.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n};Ae.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this};function un(n,t){gt.call(this),this.type="LineCurve3",this.v1=n||new M,this.v2=t||new M}un.prototype=Object.create(gt.prototype);un.prototype.constructor=un;un.prototype.isLineCurve3=!0;un.prototype.getPoint=function(n,t){let e=t||new M;return n===1?e.copy(this.v2):(e.copy(this.v2).sub(this.v1),e.multiplyScalar(n).add(this.v1)),e};un.prototype.getPointAt=function(n,t){return this.getPoint(n,t)};un.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v1.copy(n.v1),this.v2.copy(n.v2),this};un.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n};un.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this};function fn(n,t,e){gt.call(this),this.type="QuadraticBezierCurve",this.v0=n||new G,this.v1=t||new G,this.v2=e||new G}fn.prototype=Object.create(gt.prototype);fn.prototype.constructor=fn;fn.prototype.isQuadraticBezierCurve=!0;fn.prototype.getPoint=function(n,t){let e=t||new G,i=this.v0,r=this.v1,s=this.v2;return e.set(Eo(n,i.x,r.x,s.x),Eo(n,i.y,r.y,s.y)),e};fn.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this};fn.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n};fn.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this};function An(n,t,e){gt.call(this),this.type="QuadraticBezierCurve3",this.v0=n||new M,this.v1=t||new M,this.v2=e||new M}An.prototype=Object.create(gt.prototype);An.prototype.constructor=An;An.prototype.isQuadraticBezierCurve3=!0;An.prototype.getPoint=function(n,t){let e=t||new M,i=this.v0,r=this.v1,s=this.v2;return e.set(Eo(n,i.x,r.x,s.x),Eo(n,i.y,r.y,s.y),Eo(n,i.z,r.z,s.z)),e};An.prototype.copy=function(n){return gt.prototype.copy.call(this,n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this};An.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n};An.prototype.fromJSON=function(n){return gt.prototype.fromJSON.call(this,n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this};function dn(n){gt.call(this),this.type="SplineCurve",this.points=n||[]}dn.prototype=Object.create(gt.prototype);dn.prototype.constructor=dn;dn.prototype.isSplineCurve=!0;dn.prototype.getPoint=function(n,t){let e=t||new G,i=this.points,r=(i.length-1)*n,s=Math.floor(r),o=r-s,a=i[s===0?s:s-1],c=i[s],l=i[s>i.length-2?i.length-1:s+1],u=i[s>i.length-3?i.length-1:s+2];return e.set($m(o,a.x,c.x,l.x,u.x),$m(o,a.y,c.y,l.y,u.y)),e};dn.prototype.copy=function(n){gt.prototype.copy.call(this,n),this.points=[];for(let t=0,e=n.points.length;t<e;t++){let i=n.points[t];this.points.push(i.clone())}return this};dn.prototype.toJSON=function(){let n=gt.prototype.toJSON.call(this);n.points=[];for(let t=0,e=this.points.length;t<e;t++){let i=this.points[t];n.points.push(i.toArray())}return n};dn.prototype.fromJSON=function(n){gt.prototype.fromJSON.call(this,n),this.points=[];for(let t=0,e=n.points.length;t<e;t++){let i=n.points[t];this.points.push(new G().fromArray(i))}return this};var Uf=Object.freeze({__proto__:null,ArcCurve:Rs,CatmullRomCurve3:xe,CubicBezierCurve:hn,CubicBezierCurve3:Tn,EllipseCurve:Ue,LineCurve:Ae,LineCurve3:un,QuadraticBezierCurve:fn,QuadraticBezierCurve3:An,SplineCurve:dn});function Jn(){gt.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}Jn.prototype=Object.assign(Object.create(gt.prototype),{constructor:Jn,add:function(n){this.curves.push(n)},closePath:function(){let n=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);n.equals(t)||this.curves.push(new Ae(t,n))},getPoint:function(n){let t=n*this.getLength(),e=this.getCurveLengths(),i=0;for(;i<e.length;){if(e[i]>=t){let r=e[i]-t,s=this.curves[i],o=s.getLength(),a=o===0?0:1-r/o;return s.getPointAt(a)}i++}return null},getLength:function(){let n=this.getCurveLengths();return n[n.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let n=[],t=0;for(let e=0,i=this.curves.length;e<i;e++)t+=this.curves[e].getLength(),n.push(t);return this.cacheLengths=n,n},getSpacedPoints:function(n){n===void 0&&(n=40);let t=[];for(let e=0;e<=n;e++)t.push(this.getPoint(e/n));return this.autoClose&&t.push(t[0]),t},getPoints:function(n){n=n||12;let t=[],e;for(let i=0,r=this.curves;i<r.length;i++){let s=r[i],o=s&&s.isEllipseCurve?n*2:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?n*s.points.length:n,a=s.getPoints(o);for(let c=0;c<a.length;c++){let l=a[c];e&&e.equals(l)||(t.push(l),e=l)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(n){gt.prototype.copy.call(this,n),this.curves=[];for(let t=0,e=n.curves.length;t<e;t++){let i=n.curves[t];this.curves.push(i.clone())}return this.autoClose=n.autoClose,this},toJSON:function(){let n=gt.prototype.toJSON.call(this);n.autoClose=this.autoClose,n.curves=[];for(let t=0,e=this.curves.length;t<e;t++){let i=this.curves[t];n.curves.push(i.toJSON())}return n},fromJSON:function(n){gt.prototype.fromJSON.call(this,n),this.autoClose=n.autoClose,this.curves=[];for(let t=0,e=n.curves.length;t<e;t++){let i=n.curves[t];this.curves.push(new Uf[i.type]().fromJSON(i))}return this}});function an(n){Jn.call(this),this.type="Path",this.currentPoint=new G,n&&this.setFromPoints(n)}an.prototype=Object.assign(Object.create(Jn.prototype),{constructor:an,setFromPoints:function(n){this.moveTo(n[0].x,n[0].y);for(let t=1,e=n.length;t<e;t++)this.lineTo(n[t].x,n[t].y);return this},moveTo:function(n,t){return this.currentPoint.set(n,t),this},lineTo:function(n,t){let e=new Ae(this.currentPoint.clone(),new G(n,t));return this.curves.push(e),this.currentPoint.set(n,t),this},quadraticCurveTo:function(n,t,e,i){let r=new fn(this.currentPoint.clone(),new G(n,t),new G(e,i));return this.curves.push(r),this.currentPoint.set(e,i),this},bezierCurveTo:function(n,t,e,i,r,s){let o=new hn(this.currentPoint.clone(),new G(n,t),new G(e,i),new G(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this},splineThru:function(n){let t=[this.currentPoint.clone()].concat(n),e=new dn(t);return this.curves.push(e),this.currentPoint.copy(n[n.length-1]),this},arc:function(n,t,e,i,r,s){let o=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(n+o,t+a,e,i,r,s),this},absarc:function(n,t,e,i,r,s){return this.absellipse(n,t,e,e,i,r,s),this},ellipse:function(n,t,e,i,r,s,o,a){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(n+c,t+l,e,i,r,s,o,a),this},absellipse:function(n,t,e,i,r,s,o,a){let c=new Ue(n,t,e,i,r,s,o,a);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this},copy:function(n){return Jn.prototype.copy.call(this,n),this.currentPoint.copy(n.currentPoint),this},toJSON:function(){let n=Jn.prototype.toJSON.call(this);return n.currentPoint=this.currentPoint.toArray(),n},fromJSON:function(n){return Jn.prototype.fromJSON.call(this,n),this.currentPoint.fromArray(n.currentPoint),this}});function Ei(n){an.call(this,n),this.uuid=_t.generateUUID(),this.type="Shape",this.holes=[]}Ei.prototype=Object.assign(Object.create(an.prototype),{constructor:Ei,getPointsHoles:function(n){let t=[];for(let e=0,i=this.holes.length;e<i;e++)t[e]=this.holes[e].getPoints(n);return t},extractPoints:function(n){return{shape:this.getPoints(n),holes:this.getPointsHoles(n)}},copy:function(n){an.prototype.copy.call(this,n),this.holes=[];for(let t=0,e=n.holes.length;t<e;t++){let i=n.holes[t];this.holes.push(i.clone())}return this},toJSON:function(){let n=an.prototype.toJSON.call(this);n.uuid=this.uuid,n.holes=[];for(let t=0,e=this.holes.length;t<e;t++){let i=this.holes[t];n.holes.push(i.toJSON())}return n},fromJSON:function(n){an.prototype.fromJSON.call(this,n),this.uuid=n.uuid,this.holes=[];for(let t=0,e=n.holes.length;t<e;t++){let i=n.holes[t];this.holes.push(new an().fromJSON(i))}return this}});function Xt(n,t){dt.call(this),this.type="Light",this.color=new lt(n),this.intensity=t!==void 0?t:1,this.receiveShadow=void 0}Xt.prototype=Object.assign(Object.create(dt.prototype),{constructor:Xt,isLight:!0,copy:function(n){return dt.prototype.copy.call(this,n),this.color.copy(n.color),this.intensity=n.intensity,this},toJSON:function(n){let t=dt.prototype.toJSON.call(this,n);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}});function El(n,t,e){Xt.call(this,n,e),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(dt.DefaultUp),this.updateMatrix(),this.groundColor=new lt(t)}El.prototype=Object.assign(Object.create(Xt.prototype),{constructor:El,isHemisphereLight:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.groundColor.copy(n.groundColor),this}});function Cn(n){this.camera=n,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new G(512,512),this.map=null,this.mapPass=null,this.matrix=new At,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new mr,this._frameExtents=new G(1,1),this._viewportCount=1,this._viewports=[new Bt(0,0,1,1)]}Object.assign(Cn.prototype,{_projScreenMatrix:new At,_lightPositionWorld:new M,_lookTarget:new M,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(n){let t=this.camera,e=this.matrix,i=this._projScreenMatrix,r=this._lookTarget,s=this._lightPositionWorld;s.setFromMatrixPosition(n.matrixWorld),t.position.copy(s),r.setFromMatrixPosition(n.target.matrixWorld),t.lookAt(r),t.updateMatrixWorld(),i.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(i),e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.matrixWorldInverse)},getViewport:function(n){return this._viewports[n]},getFrameExtents:function(){return this._frameExtents},copy:function(n){return this.camera=n.camera.clone(),this.bias=n.bias,this.radius=n.radius,this.mapSize.copy(n.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let n={};return this.bias!==0&&(n.bias=this.bias),this.normalBias!==0&&(n.normalBias=this.normalBias),this.radius!==1&&(n.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(n.mapSize=this.mapSize.toArray()),n.camera=this.camera.toJSON(!1).object,delete n.camera.matrix,n}});function kf(){Cn.call(this,new ne(50,1,.5,500))}kf.prototype=Object.assign(Object.create(Cn.prototype),{constructor:kf,isSpotLightShadow:!0,updateMatrices:function(n){let t=this.camera,e=_t.RAD2DEG*2*n.angle,i=this.mapSize.width/this.mapSize.height,r=n.distance||t.far;(e!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=e,t.aspect=i,t.far=r,t.updateProjectionMatrix()),Cn.prototype.updateMatrices.call(this,n)}});function Tl(n,t,e,i,r,s){Xt.call(this,n,t),this.type="SpotLight",this.position.copy(dt.DefaultUp),this.updateMatrix(),this.target=new dt,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(o){this.intensity=o/Math.PI}}),this.distance=e!==void 0?e:0,this.angle=i!==void 0?i:Math.PI/3,this.penumbra=r!==void 0?r:0,this.decay=s!==void 0?s:1,this.shadow=new kf}Tl.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Tl,isSpotLight:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.distance=n.distance,this.angle=n.angle,this.penumbra=n.penumbra,this.decay=n.decay,this.target=n.target.clone(),this.shadow=n.shadow.clone(),this}});function Gf(){Cn.call(this,new ne(90,1,.5,500)),this._frameExtents=new G(4,2),this._viewportCount=6,this._viewports=[new Bt(2,1,1,1),new Bt(0,1,1,1),new Bt(3,1,1,1),new Bt(1,1,1,1),new Bt(3,0,1,1),new Bt(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}Gf.prototype=Object.assign(Object.create(Cn.prototype),{constructor:Gf,isPointLightShadow:!0,updateMatrices:function(n,t){t===void 0&&(t=0);let e=this.camera,i=this.matrix,r=this._lightPositionWorld,s=this._lookTarget,o=this._projScreenMatrix;r.setFromMatrixPosition(n.matrixWorld),e.position.copy(r),s.copy(e.position),s.add(this._cubeDirections[t]),e.up.copy(this._cubeUps[t]),e.lookAt(s),e.updateMatrixWorld(),i.makeTranslation(-r.x,-r.y,-r.z),o.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}});function Al(n,t,e,i){Xt.call(this,n,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(r){this.intensity=r/(4*Math.PI)}}),this.distance=e!==void 0?e:0,this.decay=i!==void 0?i:1,this.shadow=new Gf}Al.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Al,isPointLight:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.distance=n.distance,this.decay=n.decay,this.shadow=n.shadow.clone(),this}});function Is(n,t,e,i,r,s){Sn.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=n!==void 0?n:-1,this.right=t!==void 0?t:1,this.top=e!==void 0?e:1,this.bottom=i!==void 0?i:-1,this.near=r!==void 0?r:.1,this.far=s!==void 0?s:2e3,this.updateProjectionMatrix()}Is.prototype=Object.assign(Object.create(Sn.prototype),{constructor:Is,isOrthographicCamera:!0,copy:function(n,t){return Sn.prototype.copy.call(this,n,t),this.left=n.left,this.right=n.right,this.top=n.top,this.bottom=n.bottom,this.near=n.near,this.far=n.far,this.zoom=n.zoom,this.view=n.view===null?null:Object.assign({},n.view),this},setViewOffset:function(n,t,e,i,r,s){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=n,this.view.fullHeight=t,this.view.offsetX=e,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let n=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),e=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=e-n,s=e+n,o=i+t,a=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,o-=l*this.view.offsetY,a=o-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(n){let t=dt.prototype.toJSON.call(this,n);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}});function Hf(){Cn.call(this,new Is(-5,5,5,-5,.5,500))}Hf.prototype=Object.assign(Object.create(Cn.prototype),{constructor:Hf,isDirectionalLightShadow:!0,updateMatrices:function(n){Cn.prototype.updateMatrices.call(this,n)}});function Cl(n,t){Xt.call(this,n,t),this.type="DirectionalLight",this.position.copy(dt.DefaultUp),this.updateMatrix(),this.target=new dt,this.shadow=new Hf}Cl.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Cl,isDirectionalLight:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.target=n.target.clone(),this.shadow=n.shadow.clone(),this}});function Ll(n,t){Xt.call(this,n,t),this.type="AmbientLight",this.castShadow=void 0}Ll.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Ll,isAmbientLight:!0});function Pl(n,t,e,i){Xt.call(this,n,t),this.type="RectAreaLight",this.width=e!==void 0?e:10,this.height=i!==void 0?i:10}Pl.prototype=Object.assign(Object.create(Xt.prototype),{constructor:Pl,isRectAreaLight:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.width=n.width,this.height=n.height,this},toJSON:function(n){let t=Xt.prototype.toJSON.call(this,n);return t.object.width=this.width,t.object.height=this.height,t}});var Rl=class{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new M)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){let i=t.x,r=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*r),e.addScaledVector(o[2],.488603*s),e.addScaledVector(o[3],.488603*i),e.addScaledVector(o[4],1.092548*(i*r)),e.addScaledVector(o[5],1.092548*(r*s)),e.addScaledVector(o[6],.315392*(3*s*s-1)),e.addScaledVector(o[7],1.092548*(i*s)),e.addScaledVector(o[8],.546274*(i*i-r*r)),e}getIrradianceAt(t,e){let i=t.x,r=t.y,s=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*r),e.addScaledVector(o[2],2*.511664*s),e.addScaledVector(o[3],2*.511664*i),e.addScaledVector(o[4],2*.429043*i*r),e.addScaledVector(o[5],2*.429043*r*s),e.addScaledVector(o[6],.743125*s*s-.247708),e.addScaledVector(o[7],2*.429043*i*s),e.addScaledVector(o[8],.429043*(i*i-r*r)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e){e===void 0&&(e=0);let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(t,e+r*3);return this}toArray(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(t,e+r*3);return t}static getBasisAt(t,e){let i=t.x,r=t.y,s=t.z;e[0]=.282095,e[1]=.488603*r,e[2]=.488603*s,e[3]=.488603*i,e[4]=1.092548*i*r,e[5]=1.092548*r*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*i*s,e[8]=.546274*(i*i-r*r)}};function We(n,t){Xt.call(this,void 0,t),this.type="LightProbe",this.sh=n!==void 0?n:new Rl}We.prototype=Object.assign(Object.create(Xt.prototype),{constructor:We,isLightProbe:!0,copy:function(n){return Xt.prototype.copy.call(this,n),this.sh.copy(n.sh),this},fromJSON:function(n){return this.intensity=n.intensity,this.sh.fromArray(n.sh),this},toJSON:function(n){let t=Xt.prototype.toJSON.call(this,n);return t.object.sh=this.sh.toArray(),t}});function Il(n){kt.call(this,n),this.textures={}}Il.prototype=Object.assign(Object.create(kt.prototype),{constructor:Il,load:function(n,t,e,i){let r=this,s=new Ze(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.load(n,function(o){try{t(r.parse(JSON.parse(o)))}catch(a){i?i(a):console.error(a),r.manager.itemError(n)}},e,i)},parse:function(n){let t=this.textures;function e(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}let i=new BS[n.type];if(n.uuid!==void 0&&(i.uuid=n.uuid),n.name!==void 0&&(i.name=n.name),n.color!==void 0&&i.color.setHex(n.color),n.roughness!==void 0&&(i.roughness=n.roughness),n.metalness!==void 0&&(i.metalness=n.metalness),n.sheen!==void 0&&(i.sheen=new lt().setHex(n.sheen)),n.emissive!==void 0&&i.emissive.setHex(n.emissive),n.specular!==void 0&&i.specular.setHex(n.specular),n.shininess!==void 0&&(i.shininess=n.shininess),n.clearcoat!==void 0&&(i.clearcoat=n.clearcoat),n.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=n.clearcoatRoughness),n.fog!==void 0&&(i.fog=n.fog),n.flatShading!==void 0&&(i.flatShading=n.flatShading),n.blending!==void 0&&(i.blending=n.blending),n.combine!==void 0&&(i.combine=n.combine),n.side!==void 0&&(i.side=n.side),n.opacity!==void 0&&(i.opacity=n.opacity),n.transparent!==void 0&&(i.transparent=n.transparent),n.alphaTest!==void 0&&(i.alphaTest=n.alphaTest),n.depthTest!==void 0&&(i.depthTest=n.depthTest),n.depthWrite!==void 0&&(i.depthWrite=n.depthWrite),n.colorWrite!==void 0&&(i.colorWrite=n.colorWrite),n.stencilWrite!==void 0&&(i.stencilWrite=n.stencilWrite),n.stencilWriteMask!==void 0&&(i.stencilWriteMask=n.stencilWriteMask),n.stencilFunc!==void 0&&(i.stencilFunc=n.stencilFunc),n.stencilRef!==void 0&&(i.stencilRef=n.stencilRef),n.stencilFuncMask!==void 0&&(i.stencilFuncMask=n.stencilFuncMask),n.stencilFail!==void 0&&(i.stencilFail=n.stencilFail),n.stencilZFail!==void 0&&(i.stencilZFail=n.stencilZFail),n.stencilZPass!==void 0&&(i.stencilZPass=n.stencilZPass),n.wireframe!==void 0&&(i.wireframe=n.wireframe),n.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=n.wireframeLinewidth),n.wireframeLinecap!==void 0&&(i.wireframeLinecap=n.wireframeLinecap),n.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=n.wireframeLinejoin),n.rotation!==void 0&&(i.rotation=n.rotation),n.linewidth!==1&&(i.linewidth=n.linewidth),n.dashSize!==void 0&&(i.dashSize=n.dashSize),n.gapSize!==void 0&&(i.gapSize=n.gapSize),n.scale!==void 0&&(i.scale=n.scale),n.polygonOffset!==void 0&&(i.polygonOffset=n.polygonOffset),n.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=n.polygonOffsetFactor),n.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=n.polygonOffsetUnits),n.skinning!==void 0&&(i.skinning=n.skinning),n.morphTargets!==void 0&&(i.morphTargets=n.morphTargets),n.morphNormals!==void 0&&(i.morphNormals=n.morphNormals),n.dithering!==void 0&&(i.dithering=n.dithering),n.vertexTangents!==void 0&&(i.vertexTangents=n.vertexTangents),n.visible!==void 0&&(i.visible=n.visible),n.toneMapped!==void 0&&(i.toneMapped=n.toneMapped),n.userData!==void 0&&(i.userData=n.userData),n.vertexColors!==void 0&&(typeof n.vertexColors=="number"?i.vertexColors=n.vertexColors>0:i.vertexColors=n.vertexColors),n.uniforms!==void 0)for(let r in n.uniforms){let s=n.uniforms[r];switch(i.uniforms[r]={},s.type){case"t":i.uniforms[r].value=e(s.value);break;case"c":i.uniforms[r].value=new lt().setHex(s.value);break;case"v2":i.uniforms[r].value=new G().fromArray(s.value);break;case"v3":i.uniforms[r].value=new M().fromArray(s.value);break;case"v4":i.uniforms[r].value=new Bt().fromArray(s.value);break;case"m3":i.uniforms[r].value=new pe().fromArray(s.value);break;case"m4":i.uniforms[r].value=new At().fromArray(s.value);break;default:i.uniforms[r].value=s.value}}if(n.defines!==void 0&&(i.defines=n.defines),n.vertexShader!==void 0&&(i.vertexShader=n.vertexShader),n.fragmentShader!==void 0&&(i.fragmentShader=n.fragmentShader),n.extensions!==void 0)for(let r in n.extensions)i.extensions[r]=n.extensions[r];if(n.shading!==void 0&&(i.flatShading=n.shading===1),n.size!==void 0&&(i.size=n.size),n.sizeAttenuation!==void 0&&(i.sizeAttenuation=n.sizeAttenuation),n.map!==void 0&&(i.map=e(n.map)),n.matcap!==void 0&&(i.matcap=e(n.matcap)),n.alphaMap!==void 0&&(i.alphaMap=e(n.alphaMap)),n.bumpMap!==void 0&&(i.bumpMap=e(n.bumpMap)),n.bumpScale!==void 0&&(i.bumpScale=n.bumpScale),n.normalMap!==void 0&&(i.normalMap=e(n.normalMap)),n.normalMapType!==void 0&&(i.normalMapType=n.normalMapType),n.normalScale!==void 0){let r=n.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new G().fromArray(r)}return n.displacementMap!==void 0&&(i.displacementMap=e(n.displacementMap)),n.displacementScale!==void 0&&(i.displacementScale=n.displacementScale),n.displacementBias!==void 0&&(i.displacementBias=n.displacementBias),n.roughnessMap!==void 0&&(i.roughnessMap=e(n.roughnessMap)),n.metalnessMap!==void 0&&(i.metalnessMap=e(n.metalnessMap)),n.emissiveMap!==void 0&&(i.emissiveMap=e(n.emissiveMap)),n.emissiveIntensity!==void 0&&(i.emissiveIntensity=n.emissiveIntensity),n.specularMap!==void 0&&(i.specularMap=e(n.specularMap)),n.envMap!==void 0&&(i.envMap=e(n.envMap)),n.envMapIntensity!==void 0&&(i.envMapIntensity=n.envMapIntensity),n.reflectivity!==void 0&&(i.reflectivity=n.reflectivity),n.refractionRatio!==void 0&&(i.refractionRatio=n.refractionRatio),n.lightMap!==void 0&&(i.lightMap=e(n.lightMap)),n.lightMapIntensity!==void 0&&(i.lightMapIntensity=n.lightMapIntensity),n.aoMap!==void 0&&(i.aoMap=e(n.aoMap)),n.aoMapIntensity!==void 0&&(i.aoMapIntensity=n.aoMapIntensity),n.gradientMap!==void 0&&(i.gradientMap=e(n.gradientMap)),n.clearcoatMap!==void 0&&(i.clearcoatMap=e(n.clearcoatMap)),n.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=e(n.clearcoatRoughnessMap)),n.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=e(n.clearcoatNormalMap)),n.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new G().fromArray(n.clearcoatNormalScale)),n.transmission!==void 0&&(i.transmission=n.transmission),n.transmissionMap!==void 0&&(i.transmissionMap=e(n.transmissionMap)),i},setTextures:function(n){return this.textures=n,this}});var wd={decodeText:function(n){if(typeof TextDecoder<"u")return new TextDecoder().decode(n);let t="";for(let e=0,i=n.length;e<i;e++)t+=String.fromCharCode(n[e]);try{return decodeURIComponent(escape(t))}catch{return t}},extractUrlBase:function(n){let t=n.lastIndexOf("/");return t===-1?"./":n.substr(0,t+1)}};function pa(){yt.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}pa.prototype=Object.assign(Object.create(yt.prototype),{constructor:pa,isInstancedBufferGeometry:!0,copy:function(n){return yt.prototype.copy.call(this,n),this.instanceCount=n.instanceCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let n=yt.prototype.toJSON.call(this);return n.instanceCount=this.instanceCount,n.isInstancedBufferGeometry=!0,n}});function Dl(n,t,e,i){typeof e=="number"&&(i=e,e=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),xt.call(this,n,t,e),this.meshPerAttribute=i||1}Dl.prototype=Object.assign(Object.create(xt.prototype),{constructor:Dl,isInstancedBufferAttribute:!0,copy:function(n){return xt.prototype.copy.call(this,n),this.meshPerAttribute=n.meshPerAttribute,this},toJSON:function(){let n=xt.prototype.toJSON.call(this);return n.meshPerAttribute=this.meshPerAttribute,n.isInstancedBufferAttribute=!0,n}});function Ol(n){kt.call(this,n)}Ol.prototype=Object.assign(Object.create(kt.prototype),{constructor:Ol,load:function(n,t,e,i){let r=this,s=new Ze(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.load(n,function(o){try{t(r.parse(JSON.parse(o)))}catch(a){i?i(a):console.error(a),r.manager.itemError(n)}},e,i)},parse:function(n){let t={},e={};function i(d,f){if(t[f]!==void 0)return t[f];let y=d.interleavedBuffers[f],x=r(d,y.buffer),g=new Pc[y.type](x),m=new Oe(g,y.stride);return m.uuid=y.uuid,t[f]=m,m}function r(d,f){if(e[f]!==void 0)return e[f];let y=d.arrayBuffers[f],x=new Uint32Array(y).buffer;return e[f]=x,x}let s=n.isInstancedBufferGeometry?new pa:new yt,o=n.data.index;if(o!==void 0){let d=new Pc[o.type](o.array);s.setIndex(new xt(d,1))}let a=n.data.attributes;for(let d in a){let f=a[d],p;if(f.isInterleavedBufferAttribute){let y=i(n.data,f.data);p=new Ii(y,f.itemSize,f.offset,f.normalized)}else{let y=new Pc[f.type](f.array),x=f.isInstancedBufferAttribute?Dl:xt;p=new x(y,f.itemSize,f.normalized)}f.name!==void 0&&(p.name=f.name),s.setAttribute(d,p)}let c=n.data.morphAttributes;if(c)for(let d in c){let f=c[d],p=[];for(let y=0,x=f.length;y<x;y++){let g=f[y],m;if(g.isInterleavedBufferAttribute){let b=i(n.data,g.data);m=new Ii(b,g.itemSize,g.offset,g.normalized)}else{let b=new Pc[g.type](g.array);m=new xt(b,g.itemSize,g.normalized)}g.name!==void 0&&(m.name=g.name),p.push(m)}s.morphAttributes[d]=p}n.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let u=n.data.groups||n.data.drawcalls||n.data.offsets;if(u!==void 0)for(let d=0,f=u.length;d!==f;++d){let p=u[d];s.addGroup(p.start,p.count,p.materialIndex)}let h=n.data.boundingSphere;if(h!==void 0){let d=new M;h.center!==void 0&&d.fromArray(h.center),s.boundingSphere=new cn(d,h.radius)}return n.name&&(s.name=n.name),n.userData&&(s.userData=n.userData),s}});var Pc={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray<"u"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Fl(n){kt.call(this,n)}Fl.prototype=Object.assign(Object.create(kt.prototype),{constructor:Fl,load:function(n,t,e,i){let r=this,s=this.path===""?wd.extractUrlBase(n):this.path;this.resourcePath=this.resourcePath||s;let o=new Ze(r.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.load(n,function(a){let c=null;try{c=JSON.parse(a)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+n+".",u.message);return}let l=c.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+n);return}r.parse(c,t)},e,i)},parse:function(n,t){let e=this.parseShape(n.shapes),i=this.parseGeometries(n.geometries,e),r=this.parseImages(n.images,function(){t!==void 0&&t(a)}),s=this.parseTextures(n.textures,r),o=this.parseMaterials(n.materials,s),a=this.parseObject(n.object,i,o);return n.animations&&(a.animations=this.parseAnimations(n.animations)),(n.images===void 0||n.images.length===0)&&t!==void 0&&t(a),a},parseShape:function(n){let t={};if(n!==void 0)for(let e=0,i=n.length;e<i;e++){let r=new Ei().fromJSON(n[e]);t[r.uuid]=r}return t},parseGeometries:function(n,t){let e={},i;if(n!==void 0){let r=new Ol;for(let s=0,o=n.length;s<o;s++){let a,c=n[s];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":a=new be[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":a=new be[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":a=new be[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":a=new be[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":a=new be[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":a=new be[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":a=new be[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":a=new be[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":a=new be[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":a=new be[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"TubeGeometry":case"TubeBufferGeometry":a=new be[c.type](new Uf[c.path.type]().fromJSON(c.path),c.tubularSegments,c.radius,c.radialSegments,c.closed);break;case"LatheGeometry":case"LatheBufferGeometry":a=new be[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":a=new be[c.type](c.vertices,c.indices,c.radius,c.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":i=[];for(let u=0,h=c.shapes.length;u<h;u++){let d=t[c.shapes[u]];i.push(d)}a=new be[c.type](i,c.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":i=[];for(let u=0,h=c.shapes.length;u<h;u++){let d=t[c.shapes[u]];i.push(d)}let l=c.options.extrudePath;l!==void 0&&(c.options.extrudePath=new Uf[l.type]().fromJSON(l)),a=new be[c.type](i,c.options);break;case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;case"Geometry":console.error('THREE.ObjectLoader: Loading "Geometry" is not supported anymore.');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),a.isBufferGeometry===!0&&c.userData!==void 0&&(a.userData=c.userData),e[c.uuid]=a}}return e},parseMaterials:function(n,t){let e={},i={};if(n!==void 0){let r=new Il;r.setTextures(t);for(let s=0,o=n.length;s<o;s++){let a=n[s];if(a.type==="MultiMaterial"){let c=[];for(let l=0;l<a.materials.length;l++){let u=a.materials[l];e[u.uuid]===void 0&&(e[u.uuid]=r.parse(u)),c.push(e[u.uuid])}i[a.uuid]=c}else e[a.uuid]===void 0&&(e[a.uuid]=r.parse(a)),i[a.uuid]=e[a.uuid]}}return i},parseAnimations:function(n){let t=[];for(let e=0;e<n.length;e++){let i=n[e],r=He.parse(i);i.uuid!==void 0&&(r.uuid=i.uuid),t.push(r)}return t},parseImages:function(n,t){let e=this,i={},r;function s(o){return e.manager.itemStart(o),r.load(o,function(){e.manager.itemEnd(o)},void 0,function(){e.manager.itemError(o),e.manager.itemEnd(o)})}if(n!==void 0&&n.length>0){let o=new bd(t);r=new Ps(o),r.setCrossOrigin(this.crossOrigin);for(let a=0,c=n.length;a<c;a++){let l=n[a],u=l.url;if(Array.isArray(u)){i[l.uuid]=[];for(let h=0,d=u.length;h<d;h++){let f=u[h],p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(f)?f:e.resourcePath+f;i[l.uuid].push(s(p))}}else{let h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l.url)?l.url:e.resourcePath+l.url;i[l.uuid]=s(h)}}}return i},parseTextures:function(n,t){function e(r,s){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),s[r])}let i={};if(n!==void 0)for(let r=0,s=n.length;r<s;r++){let o=n[r];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);let a;Array.isArray(t[o.image])?a=new Kn(t[o.image]):a=new Gt(t[o.image]),a.needsUpdate=!0,a.uuid=o.uuid,o.name!==void 0&&(a.name=o.name),o.mapping!==void 0&&(a.mapping=e(o.mapping,YS)),o.offset!==void 0&&a.offset.fromArray(o.offset),o.repeat!==void 0&&a.repeat.fromArray(o.repeat),o.center!==void 0&&a.center.fromArray(o.center),o.rotation!==void 0&&(a.rotation=o.rotation),o.wrap!==void 0&&(a.wrapS=e(o.wrap[0],Qm),a.wrapT=e(o.wrap[1],Qm)),o.format!==void 0&&(a.format=o.format),o.type!==void 0&&(a.type=o.type),o.encoding!==void 0&&(a.encoding=o.encoding),o.minFilter!==void 0&&(a.minFilter=e(o.minFilter,Km)),o.magFilter!==void 0&&(a.magFilter=e(o.magFilter,Km)),o.anisotropy!==void 0&&(a.anisotropy=o.anisotropy),o.flipY!==void 0&&(a.flipY=o.flipY),o.premultiplyAlpha!==void 0&&(a.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(a.unpackAlignment=o.unpackAlignment),i[o.uuid]=a}return i},parseObject:function(n,t,e){let i;function r(c){return t[c]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",c),t[c]}function s(c){if(c!==void 0){if(Array.isArray(c)){let l=[];for(let u=0,h=c.length;u<h;u++){let d=c[u];e[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),l.push(e[d])}return l}return e[c]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",c),e[c]}}let o,a;switch(n.type){case"Scene":i=new Go,n.background!==void 0&&Number.isInteger(n.background)&&(i.background=new lt(n.background)),n.fog!==void 0&&(n.fog.type==="Fog"?i.fog=new Jc(n.fog.color,n.fog.near,n.fog.far):n.fog.type==="FogExp2"&&(i.fog=new Zc(n.fog.color,n.fog.density)));break;case"PerspectiveCamera":i=new ne(n.fov,n.aspect,n.near,n.far),n.focus!==void 0&&(i.focus=n.focus),n.zoom!==void 0&&(i.zoom=n.zoom),n.filmGauge!==void 0&&(i.filmGauge=n.filmGauge),n.filmOffset!==void 0&&(i.filmOffset=n.filmOffset),n.view!==void 0&&(i.view=Object.assign({},n.view));break;case"OrthographicCamera":i=new Is(n.left,n.right,n.top,n.bottom,n.near,n.far),n.zoom!==void 0&&(i.zoom=n.zoom),n.view!==void 0&&(i.view=Object.assign({},n.view));break;case"AmbientLight":i=new Ll(n.color,n.intensity);break;case"DirectionalLight":i=new Cl(n.color,n.intensity);break;case"PointLight":i=new Al(n.color,n.intensity,n.distance,n.decay);break;case"RectAreaLight":i=new Pl(n.color,n.intensity,n.width,n.height);break;case"SpotLight":i=new Tl(n.color,n.intensity,n.distance,n.angle,n.penumbra,n.decay);break;case"HemisphereLight":i=new El(n.color,n.groundColor,n.intensity);break;case"LightProbe":i=new We().fromJSON(n);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":o=r(n.geometry),a=s(n.material),i=new Yt(o,a);break;case"InstancedMesh":o=r(n.geometry),a=s(n.material);let c=n.count,l=n.instanceMatrix;i=new Kc(o,a,c),i.instanceMatrix=new xt(new Float32Array(l.array),16);break;case"LOD":i=new Vo;break;case"Line":i=new Ye(r(n.geometry),s(n.material),n.mode);break;case"LineLoop":i=new tl(r(n.geometry),s(n.material));break;case"LineSegments":i=new Se(r(n.geometry),s(n.material));break;case"PointCloud":case"Points":i=new Ms(r(n.geometry),s(n.material));break;case"Sprite":i=new Ho(s(n.material));break;case"Group":i=new wi;break;default:i=new dt}if(i.uuid=n.uuid,n.name!==void 0&&(i.name=n.name),n.matrix!==void 0?(i.matrix.fromArray(n.matrix),n.matrixAutoUpdate!==void 0&&(i.matrixAutoUpdate=n.matrixAutoUpdate),i.matrixAutoUpdate&&i.matrix.decompose(i.position,i.quaternion,i.scale)):(n.position!==void 0&&i.position.fromArray(n.position),n.rotation!==void 0&&i.rotation.fromArray(n.rotation),n.quaternion!==void 0&&i.quaternion.fromArray(n.quaternion),n.scale!==void 0&&i.scale.fromArray(n.scale)),n.castShadow!==void 0&&(i.castShadow=n.castShadow),n.receiveShadow!==void 0&&(i.receiveShadow=n.receiveShadow),n.shadow&&(n.shadow.bias!==void 0&&(i.shadow.bias=n.shadow.bias),n.shadow.normalBias!==void 0&&(i.shadow.normalBias=n.shadow.normalBias),n.shadow.radius!==void 0&&(i.shadow.radius=n.shadow.radius),n.shadow.mapSize!==void 0&&i.shadow.mapSize.fromArray(n.shadow.mapSize),n.shadow.camera!==void 0&&(i.shadow.camera=this.parseObject(n.shadow.camera))),n.visible!==void 0&&(i.visible=n.visible),n.frustumCulled!==void 0&&(i.frustumCulled=n.frustumCulled),n.renderOrder!==void 0&&(i.renderOrder=n.renderOrder),n.userData!==void 0&&(i.userData=n.userData),n.layers!==void 0&&(i.layers.mask=n.layers),n.children!==void 0){let c=n.children;for(let l=0;l<c.length;l++)i.add(this.parseObject(c[l],t,e))}if(n.type==="LOD"){n.autoUpdate!==void 0&&(i.autoUpdate=n.autoUpdate);let c=n.levels;for(let l=0;l<c.length;l++){let u=c[l],h=i.getObjectByProperty("uuid",u.object);h!==void 0&&i.addLevel(h,u.distance)}}return i}});var YS={UVMapping:Xl,CubeReflectionMapping:ba,CubeRefractionMapping:_a,EquirectangularReflectionMapping:Vc,EquirectangularRefractionMapping:Wc,CubeUVReflectionMapping:Fs,CubeUVRefractionMapping:wa},Qm={RepeatWrapping:Ao,ClampToEdgeWrapping:_e,MirroredRepeatWrapping:Co},Km={NearestFilter:ae,NearestMipmapNearestFilter:jc,NearestMipmapLinearFilter:Xc,LinearFilter:he,LinearMipmapNearestFilter:md,LinearMipmapLinearFilter:zs};function Vf(n){typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),kt.call(this,n),this.options={premultiplyAlpha:"none"}}Vf.prototype=Object.assign(Object.create(kt.prototype),{constructor:Vf,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(n,t,e,i){n===void 0&&(n=""),this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);let r=this,s=Sr.get(n);if(s!==void 0)return r.manager.itemStart(n),setTimeout(function(){t&&t(s),r.manager.itemEnd(n)},0),s;fetch(n).then(function(o){return o.blob()}).then(function(o){return createImageBitmap(o,r.options)}).then(function(o){Sr.add(n,o),t&&t(o),r.manager.itemEnd(n)}).catch(function(o){i&&i(o),r.manager.itemError(n),r.manager.itemEnd(n)}),r.manager.itemStart(n)}});function Md(){this.type="ShapePath",this.color=new lt,this.subPaths=[],this.currentPath=null}Object.assign(Md.prototype,{moveTo:function(n,t){return this.currentPath=new an,this.subPaths.push(this.currentPath),this.currentPath.moveTo(n,t),this},lineTo:function(n,t){return this.currentPath.lineTo(n,t),this},quadraticCurveTo:function(n,t,e,i){return this.currentPath.quadraticCurveTo(n,t,e,i),this},bezierCurveTo:function(n,t,e,i,r,s){return this.currentPath.bezierCurveTo(n,t,e,i,r,s),this},splineThru:function(n){return this.currentPath.splineThru(n),this},toShapes:function(n,t){function e(g){let m=[];for(let b=0,v=g.length;b<v;b++){let w=g[b],_=new Ei;_.curves=w.curves,m.push(_)}return m}function i(g,m){let b=m.length,v=!1;for(let w=b-1,_=0;_<b;w=_++){let A=m[w],I=m[_],D=I.x-A.x,N=I.y-A.y;if(Math.abs(N)>Number.EPSILON){if(N<0&&(A=m[_],D=-D,I=m[w],N=-N),g.y<A.y||g.y>I.y)continue;if(g.y===A.y){if(g.x===A.x)return!0}else{let O=N*(g.x-A.x)-D*(g.y-A.y);if(O===0)return!0;if(O<0)continue;v=!v}}else{if(g.y!==A.y)continue;if(I.x<=g.x&&g.x<=A.x||A.x<=g.x&&g.x<=I.x)return!0}}return v}let r=Qn.isClockWise,s=this.subPaths;if(s.length===0)return[];if(t===!0)return e(s);let o,a,c,l=[];if(s.length===1)return a=s[0],c=new Ei,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=n?!u:u;let h=[],d=[],f=[],p=0,y;d[p]=void 0,f[p]=[];for(let g=0,m=s.length;g<m;g++)a=s[g],y=a.getPoints(),o=r(y),o=n?!o:o,o?(!u&&d[p]&&p++,d[p]={s:new Ei,p:y},d[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!d[0])return e(s);if(d.length>1){let g=!1,m=[];for(let b=0,v=d.length;b<v;b++)h[b]=[];for(let b=0,v=d.length;b<v;b++){let w=f[b];for(let _=0;_<w.length;_++){let A=w[_],I=!0;for(let D=0;D<d.length;D++)i(A.p,d[D].p)&&(b!==D&&m.push({froms:b,tos:D,hole:_}),I?(I=!1,h[D].push(A)):g=!0);I&&h[b].push(A)}}m.length>0&&(g||(f=h))}let x;for(let g=0,m=d.length;g<m;g++){c=d[g].s,l.push(c),x=f[g];for(let b=0,v=x.length;b<v;b++)c.holes.push(x[b].h)}return l}});function Sd(n){this.type="Font",this.data=n}Object.assign(Sd.prototype,{isFont:!0,generateShapes:function(n,t){t===void 0&&(t=100);let e=[],i=ZS(n,t,this.data);for(let r=0,s=i.length;r<s;r++)Array.prototype.push.apply(e,i[r].toShapes());return e}});function ZS(n,t,e){let i=Array.from?Array.from(n):String(n).split(""),r=t/e.resolution,s=(e.boundingBox.yMax-e.boundingBox.yMin+e.underlineThickness)*r,o=[],a=0,c=0;for(let l=0;l<i.length;l++){let u=i[l];if(u===`
`)a=0,c-=s;else{let h=JS(u,r,a,c,e);a+=h.offsetX,o.push(h.path)}}return o}function JS(n,t,e,i,r){let s=r.glyphs[n]||r.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}let o=new Md,a,c,l,u,h,d,f,p;if(s.o){let y=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let x=0,g=y.length;x<g;)switch(y[x++]){case"m":a=y[x++]*t+e,c=y[x++]*t+i,o.moveTo(a,c);break;case"l":a=y[x++]*t+e,c=y[x++]*t+i,o.lineTo(a,c);break;case"q":l=y[x++]*t+e,u=y[x++]*t+i,h=y[x++]*t+e,d=y[x++]*t+i,o.quadraticCurveTo(h,d,l,u);break;case"b":l=y[x++]*t+e,u=y[x++]*t+i,h=y[x++]*t+e,d=y[x++]*t+i,f=y[x++]*t+e,p=y[x++]*t+i,o.bezierCurveTo(h,d,f,p,l,u);break}}return{offsetX:s.ha*t,path:o}}function Wf(n){kt.call(this,n)}Wf.prototype=Object.assign(Object.create(kt.prototype),{constructor:Wf,load:function(n,t,e,i){let r=this,s=new Ze(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.load(n,function(o){let a;try{a=JSON.parse(o)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),a=JSON.parse(o.substring(65,o.length-2))}let c=r.parse(a);t&&t(c)},e,i)},parse:function(n){return new Sd(n)}});var Rc,Ed={getContext:function(){return Rc===void 0&&(Rc=new(window.AudioContext||window.webkitAudioContext)),Rc},setContext:function(n){Rc=n}};function zl(n){kt.call(this,n)}zl.prototype=Object.assign(Object.create(kt.prototype),{constructor:zl,load:function(n,t,e,i){let r=this,s=new Ze(r.manager);s.setResponseType("arraybuffer"),s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.load(n,function(o){try{let a=o.slice(0);Ed.getContext().decodeAudioData(a,function(l){t(l)})}catch(a){i?i(a):console.error(a),r.manager.itemError(n)}},e,i)}});function jf(n,t,e){We.call(this,void 0,e);let i=new lt().set(n),r=new lt().set(t),s=new M(i.r,i.g,i.b),o=new M(r.r,r.g,r.b),a=Math.sqrt(Math.PI),c=a*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(o).multiplyScalar(a),this.sh.coefficients[1].copy(s).sub(o).multiplyScalar(c)}jf.prototype=Object.assign(Object.create(We.prototype),{constructor:jf,isHemisphereLightProbe:!0,copy:function(n){return We.prototype.copy.call(this,n),this},toJSON:function(n){return We.prototype.toJSON.call(this,n)}});function Xf(n,t){We.call(this,void 0,t);let e=new lt().set(n);this.sh.coefficients[0].set(e.r,e.g,e.b).multiplyScalar(2*Math.sqrt(Math.PI))}Xf.prototype=Object.assign(Object.create(We.prototype),{constructor:Xf,isAmbientLightProbe:!0,copy:function(n){return We.prototype.copy.call(this,n),this},toJSON:function(n){return We.prototype.toJSON.call(this,n)}});var tg=new At,eg=new At;function yx(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ne,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ne,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}}Object.assign(yx.prototype,{update:function(n){let t=this._cache;if(t.focus!==n.focus||t.fov!==n.fov||t.aspect!==n.aspect*this.aspect||t.near!==n.near||t.far!==n.far||t.zoom!==n.zoom||t.eyeSep!==this.eyeSep){t.focus=n.focus,t.fov=n.fov,t.aspect=n.aspect*this.aspect,t.near=n.near,t.far=n.far,t.zoom=n.zoom,t.eyeSep=this.eyeSep;let i=n.projectionMatrix.clone(),r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(_t.DEG2RAD*t.fov*.5)/t.zoom,a,c;eg.elements[12]=-r,tg.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,i.elements[0]=2*t.near/(c-a),i.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(i),a=-o*t.aspect-s,c=o*t.aspect-s,i.elements[0]=2*t.near/(c-a),i.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(n.matrixWorld).multiply(eg),this.cameraR.matrixWorld.copy(n.matrixWorld).multiply(tg)}});var Nl=class{constructor(t){this.autoStart=t!==void 0?t:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=(typeof performance>"u"?Date:performance).now(),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){let e=(typeof performance>"u"?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}},Ki=new M,ng=new ie,$S=new M,tr=new M,qf=class extends dt{constructor(){super(),this.type="AudioListener",this.context=Ed.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Nl}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);let e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ki,ng,$S),tr.set(0,0,-1).applyQuaternion(ng),e.positionX){let r=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Ki.x,r),e.positionY.linearRampToValueAtTime(Ki.y,r),e.positionZ.linearRampToValueAtTime(Ki.z,r),e.forwardX.linearRampToValueAtTime(tr.x,r),e.forwardY.linearRampToValueAtTime(tr.y,r),e.forwardZ.linearRampToValueAtTime(tr.z,r),e.upX.linearRampToValueAtTime(i.x,r),e.upY.linearRampToValueAtTime(i.y,r),e.upZ.linearRampToValueAtTime(i.z,r)}else e.setPosition(Ki.x,Ki.y,Ki.z),e.setOrientation(tr.x,tr.y,tr.z,i.x,i.y,i.z)}},ma=class extends dt{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){if(t===void 0&&(t=0),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;let 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(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this}setDetune(t){if(this.detune=t,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}},er=new M,ig=new ie,QS=new M,nr=new M,Yf=class extends ma{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(er,ig,QS),nr.set(0,0,1).applyQuaternion(ig);let e=this.panner;if(e.positionX){let i=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(er.x,i),e.positionY.linearRampToValueAtTime(er.y,i),e.positionZ.linearRampToValueAtTime(er.z,i),e.orientationX.linearRampToValueAtTime(nr.x,i),e.orientationY.linearRampToValueAtTime(nr.y,i),e.orientationZ.linearRampToValueAtTime(nr.z,i)}else e.setPosition(er.x,er.y,er.z),e.setOrientation(nr.x,nr.y,nr.z)}},Bl=class{constructor(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e!==void 0?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0,e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}};function Td(n,t,e){this.binding=n,this.valueSize=e;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(e*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(e*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(e*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(Td.prototype,{accumulate:function(n,t){let e=this.buffer,i=this.valueSize,r=n*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)e[r+o]=e[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(e,r,0,o,i)}this.cumulativeWeight=s},accumulateAdditive:function(n){let t=this.buffer,e=this.valueSize,i=e*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,n,e),this.cumulativeWeightAdditive+=n},apply:function(n){let t=this.valueSize,e=this.buffer,i=n*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(e,i,a,1-r,t)}s>0&&this._mixBufferRegionAdditive(e,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(e[a]!==e[a+t]){o.setValue(e,i);break}},saveOriginalState:function(){let n=this.binding,t=this.buffer,e=this.valueSize,i=e*this._origIndex;n.getValue(t,i);for(let r=e,s=i;r!==s;++r)t[r]=t[i+r%e];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){let n=this.valueSize*3;this.binding.setValue(this.buffer,n)},_setAdditiveIdentityNumeric:function(){let n=this._addIndex*this.valueSize,t=n+this.valueSize;for(let e=n;e<t;e++)this.buffer[e]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){let n=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let e=0;e<this.valueSize;e++)this.buffer[t+e]=this.buffer[n+e]},_select:function(n,t,e,i,r){if(i>=.5)for(let s=0;s!==r;++s)n[t+s]=n[e+s]},_slerp:function(n,t,e,i){ie.slerpFlat(n,t,n,t,n,e,i)},_slerpAdditive:function(n,t,e,i,r){let s=this._workIndex*r;ie.multiplyQuaternionsFlat(n,s,n,t,n,e),ie.slerpFlat(n,t,n,t,n,s,i)},_lerp:function(n,t,e,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;n[a]=n[a]*s+n[e+o]*i}},_lerpAdditive:function(n,t,e,i,r){for(let s=0;s!==r;++s){let o=t+s;n[o]=n[o]+n[e+s]*i}}});var Ad="\\[\\]\\.:\\/",KS=new RegExp("["+Ad+"]","g"),Cd="[^"+Ad+"]",tE="[^"+Ad.replace("\\.","")+"]",eE=/((?:WC+[\/:])*)/.source.replace("WC",Cd),nE=/(WCOD+)?/.source.replace("WCOD",tE),iE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cd),rE=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cd),sE=new RegExp("^"+eE+nE+iE+rE+"$"),oE=["material","materials","bones"];function xx(n,t,e){let i=e||ye.parseTrackName(t);this._targetGroup=n,this._bindings=n.subscribe_(t,i)}Object.assign(xx.prototype,{getValue:function(n,t){this.bind();let e=this._targetGroup.nCachedObjects_,i=this._bindings[e];i!==void 0&&i.getValue(n,t)},setValue:function(n,t){let e=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=e.length;i!==r;++i)e[i].setValue(n,t)},bind:function(){let n=this._bindings;for(let t=this._targetGroup.nCachedObjects_,e=n.length;t!==e;++t)n[t].bind()},unbind:function(){let n=this._bindings;for(let t=this._targetGroup.nCachedObjects_,e=n.length;t!==e;++t)n[t].unbind()}});function ye(n,t,e){this.path=t,this.parsedPath=e||ye.parseTrackName(t),this.node=ye.findNode(n,this.parsedPath.nodeName)||n,this.rootNode=n}Object.assign(ye,{Composite:xx,create:function(n,t,e){return n&&n.isAnimationObjectGroup?new ye.Composite(n,t,e):new ye(n,t,e)},sanitizeNodeName:function(n){return n.replace(/\s/g,"_").replace(KS,"")},parseTrackName:function(n){let t=sE.exec(n);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+n);let e={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=e.nodeName&&e.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=e.nodeName.substring(i+1);oE.indexOf(r)!==-1&&(e.nodeName=e.nodeName.substring(0,i),e.objectName=r)}if(e.propertyName===null||e.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+n);return e},findNode:function(n,t){if(!t||t===""||t==="."||t===-1||t===n.name||t===n.uuid)return n;if(n.skeleton){let e=n.skeleton.getBoneByName(t);if(e!==void 0)return e}if(n.children){let e=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=e(o.children);if(a)return a}return null},i=e(n.children);if(i)return i}return null}});Object.assign(ye.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)t[e++]=i[r]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=t[e++]},function(t,e){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){let n=this.node,t=this.parsedPath,e=t.objectName,i=t.propertyName,r=t.propertyIndex;if(n||(n=ye.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=n),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!n){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(e){let c=t.objectIndex;switch(e){case"materials":if(!n.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!n.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}n=n.material.materials;break;case"bones":if(!n.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}n=n.skeleton.bones;for(let l=0;l<n.length;l++)if(n[l].name===c){c=l;break}break;default:if(n[e]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}n=n[e]}if(c!==void 0){if(n[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,n);return}n=n[c]}}let s=n[i];if(s===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",n);return}let o=this.Versioning.None;this.targetObject=n,n.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:n.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!n.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(n.geometry.isBufferGeometry){if(!n.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}n.morphTargetDictionary[r]!==void 0&&(r=n.morphTargetDictionary[r])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else s.fromArray!==void 0&&s.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}});Object.assign(ye.prototype,{_getValue_unbound:ye.prototype.getValue,_setValue_unbound:ye.prototype.setValue});function vx(){this.uuid=_t.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let n={};this._indicesByUUID=n;for(let e=0,i=arguments.length;e!==i;++e)n[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}Object.assign(vx.prototype,{isAnimationObjectGroup:!0,add:function(){let n=this._objects,t=this._indicesByUUID,e=this._paths,i=this._parsedPaths,r=this._bindings,s=r.length,o,a=n.length,c=this.nCachedObjects_;for(let l=0,u=arguments.length;l!==u;++l){let h=arguments[l],d=h.uuid,f=t[d];if(f===void 0){f=a++,t[d]=f,n.push(h);for(let p=0,y=s;p!==y;++p)r[p].push(new ye(h,e[p],i[p]))}else if(f<c){o=n[f];let p=--c,y=n[p];t[y.uuid]=f,n[f]=y,t[d]=p,n[p]=h;for(let x=0,g=s;x!==g;++x){let m=r[x],b=m[p],v=m[f];m[f]=b,v===void 0&&(v=new ye(h,e[x],i[x])),m[p]=v}}else n[f]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c},remove:function(){let n=this._objects,t=this._indicesByUUID,e=this._bindings,i=e.length,r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){let a=arguments[s],c=a.uuid,l=t[c];if(l!==void 0&&l>=r){let u=r++,h=n[u];t[h.uuid]=l,n[l]=h,t[c]=u,n[u]=a;for(let d=0,f=i;d!==f;++d){let p=e[d],y=p[u],x=p[l];p[l]=y,p[u]=x}}}this.nCachedObjects_=r},uncache:function(){let n=this._objects,t=this._indicesByUUID,e=this._bindings,i=e.length,r=this.nCachedObjects_,s=n.length;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0)if(delete t[l],u<r){let h=--r,d=n[h],f=--s,p=n[f];t[d.uuid]=u,n[u]=d,t[p.uuid]=h,n[h]=p,n.pop();for(let y=0,x=i;y!==x;++y){let g=e[y],m=g[h],b=g[f];g[u]=m,g[h]=b,g.pop()}}else{let h=--s,d=n[h];t[d.uuid]=u,n[u]=d,n.pop();for(let f=0,p=i;f!==p;++f){let y=e[f];y[u]=y[h],y.pop()}}}this.nCachedObjects_=r},subscribe_:function(n,t){let e=this._bindingsIndicesByPath,i=e[n],r=this._bindings;if(i!==void 0)return r[i];let s=this._paths,o=this._parsedPaths,a=this._objects,c=a.length,l=this.nCachedObjects_,u=new Array(c);i=r.length,e[n]=i,s.push(n),o.push(t),r.push(u);for(let h=l,d=a.length;h!==d;++h){let f=a[h];u[h]=new ye(f,n,t)}return u},unsubscribe_:function(n){let t=this._bindingsIndicesByPath,e=t[n];if(e!==void 0){let i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o],c=n[o];t[c]=e,s[e]=a,s.pop(),r[e]=r[o],r.pop(),i[e]=i[o],i.pop()}}});var Zf=class{constructor(t,e,i,r){this._mixer=t,this._clip=e,this._localRoot=i||null,this.blendMode=r||e.blendMode;let s=e.tracks,o=s.length,a=new Array(o),c={endingStart:sr,endingEnd:sr};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Gy,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,i){if(t.fadeOut(e),this.fadeIn(e),i){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){let 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,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=t/o,l[1]=e/o,this}stopWarping(){let 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,i,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let c=(t-s)*i;if(c<0||i===0)return;this._startTime=null,e=i*c}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case gd:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case ql:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(t)[0];e*=r,t>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(t)[0];e*=r,t>i.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,i=this.loop,r=this.time+t,s=this._loopCount,o=i===Hy;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(i===ky){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else if(r<0)r=0;else{this.time=r;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,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,o)):this._setEndings(this.repetitions===0,!0,o)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){let l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,i){let r=this._interpolantSettings;i?(r.endingStart=or,r.endingEnd=or):(t?r.endingStart=this.zeroSlopeAtStart?or:sr:r.endingStart=Io,e?r.endingEnd=this.zeroSlopeAtEnd?or:sr:r.endingEnd=Io)}_scheduleFading(t,e,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=e,a[1]=s+t,c[1]=i,this}};function Jf(n){this._root=n,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}Jf.prototype=Object.assign(Object.create(Je.prototype),{constructor:Jf,_bindAction:function(n,t){let e=n._localRoot||this._root,i=n._clip.tracks,r=i.length,s=n._propertyBindings,o=n._interpolants,a=e.uuid,c=this._bindingsByRootAndName,l=c[a];l===void 0&&(l={},c[a]=l);for(let u=0;u!==r;++u){let h=i[u],d=h.name,f=l[d];if(f!==void 0)s[u]=f;else{if(f=s[u],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,a,d));continue}let p=t&&t._propertyBindings[u].binding.parsedPath;f=new Td(ye.create(e,d,p),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),s[u]=f}o[u].resultBuffer=f.buffer}},_activateAction:function(n){if(!this._isActiveAction(n)){if(n._cacheIndex===null){let e=(n._localRoot||this._root).uuid,i=n._clip.uuid,r=this._actionsByClip[i];this._bindAction(n,r&&r.knownActions[0]),this._addInactiveAction(n,i,e)}let t=n._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let r=t[e];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(n)}},_deactivateAction:function(n){if(this._isActiveAction(n)){let t=n._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let r=t[e];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(n)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let n=this;this.stats={actions:{get total(){return n._actions.length},get inUse(){return n._nActiveActions}},bindings:{get total(){return n._bindings.length},get inUse(){return n._nActiveBindings}},controlInterpolants:{get total(){return n._controlInterpolants.length},get inUse(){return n._nActiveControlInterpolants}}}},_isActiveAction:function(n){let t=n._cacheIndex;return t!==null&&t<this._nActiveActions},_addInactiveAction:function(n,t,e){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[n],actionByRoot:{}},n._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;n._byClipCacheIndex=o.length,o.push(n)}n._cacheIndex=i.length,i.push(n),s.actionByRoot[e]=n},_removeInactiveAction:function(n){let t=this._actions,e=t[t.length-1],i=n._cacheIndex;e._cacheIndex=i,t[i]=e,t.pop(),n._cacheIndex=null;let r=n._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=n._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),n._byClipCacheIndex=null;let u=o.actionByRoot,h=(n._localRoot||this._root).uuid;delete u[h],a.length===0&&delete s[r],this._removeInactiveBindingsForAction(n)},_removeInactiveBindingsForAction:function(n){let t=n._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let r=t[e];--r.referenceCount===0&&this._removeInactiveBinding(r)}},_lendAction:function(n){let t=this._actions,e=n._cacheIndex,i=this._nActiveActions++,r=t[i];n._cacheIndex=i,t[i]=n,r._cacheIndex=e,t[e]=r},_takeBackAction:function(n){let t=this._actions,e=n._cacheIndex,i=--this._nActiveActions,r=t[i];n._cacheIndex=i,t[i]=n,r._cacheIndex=e,t[e]=r},_addInactiveBinding:function(n,t,e){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];s===void 0&&(s={},i[t]=s),s[e]=n,n._cacheIndex=r.length,r.push(n)},_removeInactiveBinding:function(n){let t=this._bindings,e=n.binding,i=e.rootNode.uuid,r=e.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=n._cacheIndex;a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0&&delete s[i]},_lendBinding:function(n){let t=this._bindings,e=n._cacheIndex,i=this._nActiveBindings++,r=t[i];n._cacheIndex=i,t[i]=n,r._cacheIndex=e,t[e]=r},_takeBackBinding:function(n){let t=this._bindings,e=n._cacheIndex,i=--this._nActiveBindings,r=t[i];n._cacheIndex=i,t[i]=n,r._cacheIndex=e,t[e]=r},_lendControlInterpolant:function(){let n=this._controlInterpolants,t=this._nActiveControlInterpolants++,e=n[t];return e===void 0&&(e=new fa(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),e.__cacheIndex=t,n[t]=e),e},_takeBackControlInterpolant:function(n){let t=this._controlInterpolants,e=n.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];n.__cacheIndex=i,t[i]=n,r.__cacheIndex=e,t[e]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(n,t,e){let i=t||this._root,r=i.uuid,s=typeof n=="string"?He.findByName(i,n):n,o=s!==null?s.uuid:n,a=this._actionsByClip[o],c=null;if(e===void 0&&(s!==null?e=s.blendMode:e=ql),a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===e)return u;c=a.knownActions[0],s===null&&(s=c._clip)}if(s===null)return null;let l=new Zf(this,s,t,e);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l},existingAction:function(n,t){let e=t||this._root,i=e.uuid,r=typeof n=="string"?He.findByName(e,n):n,s=r?r.uuid:n,o=this._actionsByClip[s];return o!==void 0&&o.actionByRoot[i]||null},stopAllAction:function(){let n=this._actions,t=this._nActiveActions;for(let e=t-1;e>=0;--e)n[e].stop();return this},update:function(n){n*=this.timeScale;let t=this._actions,e=this._nActiveActions,i=this.time+=n,r=Math.sign(n),s=this._accuIndex^=1;for(let c=0;c!==e;++c)t[c]._update(i,n,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this},setTime:function(n){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(n)},getRoot:function(){return this._root},uncacheClip:function(n){let t=this._actions,e=n.uuid,i=this._actionsByClip,r=i[e];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[e]}},uncacheRoot:function(n){let t=n.uuid,e=this._actionsByClip;for(let s in e){let o=e[s].actionByRoot,a=o[t];a!==void 0&&(this._deactivateAction(a),this._removeInactiveAction(a))}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}},uncacheAction:function(n,t){let e=this.existingAction(n,t);e!==null&&(this._deactivateAction(e),this._removeInactiveAction(e))}});var Ul=class n{constructor(t){typeof t=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}};function $f(n,t,e){Oe.call(this,n,t),this.meshPerAttribute=e||1}$f.prototype=Object.assign(Object.create(Oe.prototype),{constructor:$f,isInstancedInterleavedBuffer:!0,copy:function(n){return Oe.prototype.copy.call(this,n),this.meshPerAttribute=n.meshPerAttribute,this},clone:function(n){let t=Oe.prototype.clone.call(this,n);return t.meshPerAttribute=this.meshPerAttribute,t},toJSON:function(n){let t=Oe.prototype.toJSON.call(this,n);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}});function Ld(n,t,e,i,r){this.buffer=n,this.type=t,this.itemSize=e,this.elementSize=i,this.count=r,this.version=0}Object.defineProperty(Ld.prototype,"needsUpdate",{set:function(n){n===!0&&this.version++}});Object.assign(Ld.prototype,{isGLBufferAttribute:!0,setBuffer:function(n){return this.buffer=n,this},setType:function(n,t){return this.type=n,this.elementSize=t,this},setItemSize:function(n){return this.itemSize=n,this},setCount:function(n){return this.count=n,this}});function Pd(n,t,e,i){this.ray=new Ci(n,t),this.near=e||0,this.far=i||1/0,this.camera=null,this.layers=new Do,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function rg(n,t){return n.distance-t.distance}function Qf(n,t,e,i){if(n.layers.test(t.layers)&&n.raycast(t,e),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)Qf(r[s],t,e,!0)}}Object.assign(Pd.prototype,{set:function(n,t){this.ray.set(n,t)},setFromCamera:function(n,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(n.x,n.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(n.x,n.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(n,t,e){let i=e||[];return Qf(n,this,i,t),i.sort(rg),i},intersectObjects:function(n,t,e){let i=e||[];if(Array.isArray(n)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),i;for(let r=0,s=n.length;r<s;r++)Qf(n[r],this,i,t);return i.sort(rg),i}});var ga=class{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}clone(){return new this.constructor().copy(this)}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(_t.clamp(e/this.radius,-1,1))),this}},Kf=class{constructor(t,e,i){return this.radius=t!==void 0?t:1,this.theta=e!==void 0?e:0,this.y=i!==void 0?i:0,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}clone(){return new this.constructor().copy(this)}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}},sg=new G,kl=class{constructor(t,e){Object.defineProperty(this,"isBox2",{value:!0}),this.min=t!==void 0?t:new G(1/0,1/0),this.max=e!==void 0?e:new G(-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let i=sg.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return t===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new G),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return t===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new G),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<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===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new G),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===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new G),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return sg.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),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)}},og=new M,Ic=new M,Gl=class{constructor(t,e){this.start=t!==void 0?t:new M,this.end=e!==void 0?e:new M}set(t,e){return this.start.copy(t),this.end.copy(e),this}clone(){return new this.constructor().copy(this)}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t===void 0&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new M),t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t===void 0&&(console.warn("THREE.Line3: .delta() target is now required"),t=new M),t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return e===void 0&&(console.warn("THREE.Line3: .at() target is now required"),e=new M),this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){og.subVectors(t,this.start),Ic.subVectors(this.end,this.start);let i=Ic.dot(Ic),s=Ic.dot(og)/i;return e&&(s=_t.clamp(s,0,1)),s}closestPointToPoint(t,e,i){let r=this.closestPointToPointParameter(t,e);return i===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new M),this.delta(i).multiplyScalar(r).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)}};function ya(n){dt.call(this),this.material=n,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}ya.prototype=Object.create(dt.prototype);ya.prototype.constructor=ya;ya.prototype.isImmediateRenderObject=!0;var ag=new M,td=class extends dt{constructor(t,e){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;let i=new yt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new st(r,3));let s=new Zt({fog:!1,toneMapped:!1});this.cone=new Se(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),ag.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ag),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},_i=new M,Dc=new At,af=new At,Hl=class extends Se{constructor(t){let e=bx(t),i=new yt,r=[],s=[],o=new lt(0,0,1),a=new lt(0,1,0);for(let l=0;l<e.length;l++){let u=e[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new st(r,3)),i.setAttribute("color",new st(s,3));let c=new Zt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){let e=this.bones,i=this.geometry,r=i.getAttribute("position");af.getInverse(this.root.matrixWorld);for(let s=0,o=0;s<e.length;s++){let a=e[s];a.parent&&a.parent.isBone&&(Dc.multiplyMatrices(af,a.matrixWorld),_i.setFromMatrixPosition(Dc),r.setXYZ(o,_i.x,_i.y,_i.z),Dc.multiplyMatrices(af,a.parent.matrixWorld),_i.setFromMatrixPosition(Dc),r.setXYZ(o+1,_i.x,_i.y,_i.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}};function bx(n){let t=[];n&&n.isBone&&t.push(n);for(let e=0;e<n.children.length;e++)t.push.apply(t,bx(n.children[e]));return t}var ed=class extends Yt{constructor(t,e,i){let r=new As(e,4,2),s=new Xe({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.light.updateMatrixWorld(),this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},aE=new M,cg=new lt,lg=new lt,nd=class extends dt{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;let r=new Ts(e);r.rotateY(Math.PI*.5),this.material=new Xe({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new xt(o,3)),this.add(new Yt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let e=t.geometry.getAttribute("color");cg.copy(this.light.color),lg.copy(this.light.groundColor);for(let i=0,r=e.count;i<r;i++){let s=i<r/2?cg:lg;e.setXYZ(i,s.r,s.g,s.b)}e.needsUpdate=!0}t.lookAt(aE.setFromMatrixPosition(this.light.matrixWorld).negate())}},Vl=class extends Se{constructor(t,e,i,r){t=t||10,e=e||10,i=new lt(i!==void 0?i:4473924),r=new lt(r!==void 0?r:8947848);let s=e/2,o=t/e,a=t/2,c=[],l=[];for(let d=0,f=0,p=-a;d<=e;d++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);let y=d===s?i:r;y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3}let u=new yt;u.setAttribute("position",new st(c,3)),u.setAttribute("color",new st(l,3));let h=new Zt({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}},id=class extends Se{constructor(t,e,i,r,s,o){t=t||10,e=e||16,i=i||8,r=r||64,s=new lt(s!==void 0?s:4473924),o=new lt(o!==void 0?o:8947848);let a=[],c=[];for(let h=0;h<=e;h++){let d=h/e*(Math.PI*2),f=Math.sin(d)*t,p=Math.cos(d)*t;a.push(0,0,0),a.push(f,0,p);let y=h&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let h=0;h<=i;h++){let d=h&1?s:o,f=t-t/i*h;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),x=Math.sin(y)*f,g=Math.cos(y)*f;a.push(x,0,g),c.push(d.r,d.g,d.b),y=(p+1)/r*(Math.PI*2),x=Math.sin(y)*f,g=Math.cos(y)*f,a.push(x,0,g),c.push(d.r,d.g,d.b)}}let l=new yt;l.setAttribute("position",new st(a,3)),l.setAttribute("color",new st(c,3));let u=new Zt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}},hg=new M,Oc=new M,ug=new M,rd=class extends dt{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,e===void 0&&(e=1);let r=new yt;r.setAttribute("position",new st([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Zt({fog:!1,toneMapped:!1});this.lightPlane=new Ye(r,s),this.add(this.lightPlane),r=new yt,r.setAttribute("position",new st([0,0,0,0,0,1],3)),this.targetLine=new Ye(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){hg.setFromMatrixPosition(this.light.matrixWorld),Oc.setFromMatrixPosition(this.light.target.matrixWorld),ug.subVectors(Oc,hg),this.lightPlane.lookAt(Oc),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Oc),this.targetLine.scale.z=ug.length()}},Fc=new M,Qt=new Sn,sd=class extends Se{constructor(t){let e=new yt,i=new Zt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={},a=new lt(16755200),c=new lt(16711680),l=new lt(43775),u=new lt(16777215),h=new lt(3355443);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",c),d("p","n2",c),d("p","n3",c),d("p","n4",c),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l),d("c","t",u),d("p","c",h),d("cn1","cn2",h),d("cn3","cn4",h),d("cf1","cf2",h),d("cf3","cf4",h);function d(p,y,x){f(p,x),f(y,x)}function f(p,y){r.push(0,0,0),s.push(y.r,y.g,y.b),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}e.setAttribute("position",new st(r,3)),e.setAttribute("color",new st(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let t=this.geometry,e=this.pointMap,i=1,r=1;Qt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),te("c",e,t,Qt,0,0,-1),te("t",e,t,Qt,0,0,1),te("n1",e,t,Qt,-i,-r,-1),te("n2",e,t,Qt,i,-r,-1),te("n3",e,t,Qt,-i,r,-1),te("n4",e,t,Qt,i,r,-1),te("f1",e,t,Qt,-i,-r,1),te("f2",e,t,Qt,i,-r,1),te("f3",e,t,Qt,-i,r,1),te("f4",e,t,Qt,i,r,1),te("u1",e,t,Qt,i*.7,r*1.1,-1),te("u2",e,t,Qt,-i*.7,r*1.1,-1),te("u3",e,t,Qt,0,r*2,-1),te("cf1",e,t,Qt,-i,0,1),te("cf2",e,t,Qt,i,0,1),te("cf3",e,t,Qt,0,-r,1),te("cf4",e,t,Qt,0,r,1),te("cn1",e,t,Qt,-i,0,-1),te("cn2",e,t,Qt,i,0,-1),te("cn3",e,t,Qt,0,-r,-1),te("cn4",e,t,Qt,0,r,-1),t.getAttribute("position").needsUpdate=!0}};function te(n,t,e,i,r,s,o){Fc.set(r,s,o).unproject(i);let a=t[n];if(a!==void 0){let c=e.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],Fc.x,Fc.y,Fc.z)}}var zc=new je,Wl=class extends Se{constructor(t,e=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new yt;s.setIndex(new xt(i,1)),s.setAttribute("position",new xt(r,3)),super(s,new Zt({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(t!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&zc.setFromObject(this.object),zc.isEmpty())return;let e=zc.min,i=zc.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=e.x,s[4]=i.y,s[5]=i.z,s[6]=e.x,s[7]=e.y,s[8]=i.z,s[9]=i.x,s[10]=e.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=e.z,s[15]=e.x,s[16]=i.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=i.x,s[22]=e.y,s[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t){return Se.prototype.copy.call(this,t),this.object=t.object,this}},od=class extends Se{constructor(t,e=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new yt;s.setIndex(new xt(i,1)),s.setAttribute("position",new st(r,3)),super(s,new Zt({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},ad=class extends Ye{constructor(t,e,i){let r=i!==void 0?i:16776960,s=[1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],o=new yt;o.setAttribute("position",new st(s,3)),o.computeBoundingSphere(),super(o,new Zt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e===void 0?1:e;let a=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],c=new yt;c.setAttribute("position",new st(a,3)),c.computeBoundingSphere(),this.add(new Yt(c,new Xe({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){let e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.children[0].material.side=e<0?oe:Os,this.lookAt(this.plane.normal),super.updateMatrixWorld(t)}},fg=new M,Nc,cf,cd=class extends dt{constructor(t,e,i,r,s,o){super(),this.type="ArrowHelper",t===void 0&&(t=new M(0,0,1)),e===void 0&&(e=new M(0,0,0)),i===void 0&&(i=1),r===void 0&&(r=16776960),s===void 0&&(s=.2*i),o===void 0&&(o=.2*s),Nc===void 0&&(Nc=new yt,Nc.setAttribute("position",new st([0,0,0,0,1,0],3)),cf=new yr(0,.5,1,5,1),cf.translate(0,-.5,0)),this.position.copy(e),this.line=new Ye(Nc,new Zt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Yt(cf,new Xe({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{fg.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(fg,e)}}setLength(t,e,i){e===void 0&&(e=.2*t),i===void 0&&(i=.2*e),this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),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}},jl=class extends Se{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new yt;r.setAttribute("position",new st(e,3)),r.setAttribute("color",new st(i,3));let s=new Zt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}},ms=4,Ti=8,wn=Math.pow(2,Ti),_x=[.125,.215,.35,.446,.526,.582],wx=Ti-ms+1+_x.length,os=20,Mn={[we]:0,[Ma]:1,[Zl]:2,[yd]:3,[xd]:4,[vd]:5,[Yl]:6},lf=new Is,{_lodPlanes:vo,_sizeLods:dg,_sigmas:Bc}=lE(),hf=null,ir=(1+Math.sqrt(5))/2,as=1/ir,pg=[new M(1,1,1),new M(-1,1,1),new M(1,1,-1),new M(-1,1,-1),new M(0,ir,as),new M(0,ir,-as),new M(as,0,ir),new M(-as,0,ir),new M(ir,as,0),new M(-ir,as,0)],ld=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=hE(os),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,r=100){hf=this._renderer.getRenderTarget();let s=this._allocateTargets();return this._sceneToCubeUV(t,i,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=yg(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=gg(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let t=0;t<vo.length;t++)vo[t].dispose()}_cleanup(t){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(hf),t.scissorTest=!1,Uc(t,0,0,t.width,t.height)}_fromTexture(t){hf=this._renderer.getRenderTarget();let e=this._allocateTargets(t);return this._textureToCubeUV(t,e),this._applyPMREM(e),this._cleanup(e),e}_allocateTargets(t){let e={magFilter:ae,minFilter:ae,generateMipmaps:!1,type:Ns,format:iy,encoding:cE(t)?t.encoding:Zl,depthBuffer:!1},i=mg(e);return i.depthBuffer=!t,this._pingPongRenderTarget=mg(e),i}_compileMaterial(t){let e=new Yt(vo[0],t);this._renderer.compile(e,lf)}_sceneToCubeUV(t,e,i,r){let a=new ne(90,1,e,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.outputEncoding,d=u.toneMapping,f=u.getClearColor(),p=u.getClearAlpha();u.toneMapping=ar,u.outputEncoding=we;let y=t.background;if(y&&y.isColor){y.convertSRGBToLinear();let x=Math.max(y.r,y.g,y.b),g=Math.min(Math.max(Math.ceil(Math.log2(x)),-128),127);y=y.multiplyScalar(Math.pow(2,-g));let m=(g+128)/255;u.setClearColor(y,m),t.background=null}for(let x=0;x<6;x++){let g=x%3;g==0?(a.up.set(0,c[x],0),a.lookAt(l[x],0,0)):g==1?(a.up.set(0,0,c[x]),a.lookAt(0,l[x],0)):(a.up.set(0,c[x],0),a.lookAt(0,0,l[x])),Uc(r,g*wn,x>2?wn:0,wn,wn),u.setRenderTarget(r),u.render(t,a)}u.toneMapping=d,u.outputEncoding=h,u.setClearColor(f,p)}_textureToCubeUV(t,e){let i=this._renderer;t.isCubeTexture?this._cubemapShader==null&&(this._cubemapShader=yg()):this._equirectShader==null&&(this._equirectShader=gg());let r=t.isCubeTexture?this._cubemapShader:this._equirectShader,s=new Yt(vo[0],r),o=r.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=Mn[t.encoding],o.outputEncoding.value=Mn[e.texture.encoding],Uc(e,0,0,3*wn,2*wn),i.setRenderTarget(e),i.render(s,lf)}_applyPMREM(t){let e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let r=1;r<wx;r++){let s=Math.sqrt(Bc[r]*Bc[r]-Bc[r-1]*Bc[r-1]),o=pg[(r-1)%pg.length];this._blur(t,r-1,r,s,o)}e.autoClear=i}_blur(t,e,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,i,r,"latitudinal",s),this._halfBlur(o,t,i,i,r,"longitudinal",s)}_halfBlur(t,e,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new Yt(vo[r],l),d=l.uniforms,f=dg[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*os-1),y=s/p,x=isFinite(s)?1+Math.floor(u*y):os;x>os&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${os}`);let g=[],m=0;for(let _=0;_<os;++_){let A=_/y,I=Math.exp(-A*A/2);g.push(I),_==0?m+=I:_<x&&(m+=2*I)}for(let _=0;_<g.length;_++)g[_]=g[_]/m;d.envMap.value=t.texture,d.samples.value=x,d.weights.value=g,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a),d.dTheta.value=p,d.mipInt.value=Ti-i,d.inputEncoding.value=Mn[t.texture.encoding],d.outputEncoding.value=Mn[t.texture.encoding];let b=dg[r],v=3*Math.max(0,wn-2*b),w=(r===0?0:2*wn)+2*b*(r>Ti-ms?r-Ti+ms:0);Uc(e,v,w,3*b,2*b),c.setRenderTarget(e),c.render(h,lf)}};function cE(n){return n===void 0||n.type!==Ns?!1:n.encoding===we||n.encoding===Ma||n.encoding===Yl}function lE(){let n=[],t=[],e=[],i=Ti;for(let r=0;r<wx;r++){let s=Math.pow(2,i);t.push(s);let o=1/s;r>Ti-ms?o=_x[r-Ti+ms-1]:r==0&&(o=0),e.push(o);let a=1/(s-1),c=-a/2,l=1+a/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],h=6,d=6,f=3,p=2,y=1,x=new Float32Array(f*d*h),g=new Float32Array(p*d*h),m=new Float32Array(y*d*h);for(let v=0;v<h;v++){let w=v%3*2/3-1,_=v>2?0:-1,A=[w,_,0,w+2/3,_,0,w+2/3,_+1,0,w,_,0,w+2/3,_+1,0,w,_+1,0];x.set(A,f*d*v),g.set(u,p*d*v);let I=[v,v,v,v,v,v];m.set(I,y*d*v)}let b=new yt;b.setAttribute("position",new xt(x,f)),b.setAttribute("uv",new xt(g,p)),b.setAttribute("faceIndex",new xt(m,y)),n.push(b),i>ms&&i--}return{_lodPlanes:n,_sizeLods:t,_sigmas:e}}function mg(n){let t=new ze(3*wn,3*wn,n);return t.texture.mapping=Fs,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Uc(n,t,e,i,r){n.viewport.set(t,e,i,r),n.scissor.set(t,e,i,r)}function hE(n){let t=new Float32Array(n),e=new M(0,1,0);return new ei({name:"SphericalGaussianBlur",defines:{n},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:e},inputEncoding:{value:Mn[we]},outputEncoding:{value:Mn[we]}},vertexShader:Rd(),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;

			${Id()}

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			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 );

				}

				gl_FragColor = linearToOutputTexel( gl_FragColor );

			}
		`,blending:$n,depthTest:!1,depthWrite:!1})}function gg(){let n=new G(1,1);return new ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:n},inputEncoding:{value:Mn[we]},outputEncoding:{value:Mn[we]}},vertexShader:Rd(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform vec2 texelSize;

			${Id()}

			#include <common>

			void main() {

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				vec2 f = fract( uv / texelSize - 0.5 );
				uv -= f * texelSize;
				vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
				uv.x += texelSize.x;
				vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
				uv.y += texelSize.y;
				vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
				uv.x -= texelSize.x;
				vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;

				vec3 tm = mix( tl, tr, f.x );
				vec3 bm = mix( bl, br, f.x );
				gl_FragColor.rgb = mix( tm, bm, f.y );

				gl_FragColor = linearToOutputTexel( gl_FragColor );

			}
		`,blending:$n,depthTest:!1,depthWrite:!1})}function yg(){return new ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:Mn[we]},outputEncoding:{value:Mn[we]}},vertexShader:Rd(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			${Id()}

			void main() {

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
				gl_FragColor = linearToOutputTexel( gl_FragColor );

			}
		`,blending:$n,depthTest:!1,depthWrite:!1})}function Rd(){return`

		precision mediump float;
		precision mediump int;

		attribute vec3 position;
		attribute vec2 uv;
		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 Id(){return`

		uniform int inputEncoding;
		uniform int outputEncoding;

		#include <encodings_pars_fragment>

		vec4 inputTexelToLinear( vec4 value ) {

			if ( inputEncoding == 0 ) {

				return value;

			} else if ( inputEncoding == 1 ) {

				return sRGBToLinear( value );

			} else if ( inputEncoding == 2 ) {

				return RGBEToLinear( value );

			} else if ( inputEncoding == 3 ) {

				return RGBMToLinear( value, 7.0 );

			} else if ( inputEncoding == 4 ) {

				return RGBMToLinear( value, 16.0 );

			} else if ( inputEncoding == 5 ) {

				return RGBDToLinear( value, 256.0 );

			} else {

				return GammaToLinear( value, 2.2 );

			}

		}

		vec4 linearToOutputTexel( vec4 value ) {

			if ( outputEncoding == 0 ) {

				return value;

			} else if ( outputEncoding == 1 ) {

				return LinearTosRGB( value );

			} else if ( outputEncoding == 2 ) {

				return LinearToRGBE( value );

			} else if ( outputEncoding == 3 ) {

				return LinearToRGBM( value, 7.0 );

			} else if ( outputEncoding == 4 ) {

				return LinearToRGBM( value, 16.0 );

			} else if ( outputEncoding == 5 ) {

				return LinearToRGBD( value, 256.0 );

			} else {

				return LinearToGamma( value, 2.2 );

			}

		}

		vec4 envMapTexelToLinear( vec4 color ) {

			return inputTexelToLinear( color );

		}
	`}function uE(n,t,e,i,r,s,o){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new hr(n,t,e,r,s,o)}var fE=0,dE=1,pE=0,mE=1,gE=2;function yE(n){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),n}function xE(n){return n===void 0&&(n=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),n.isMultiMaterial=!0,n.materials=n,n.clone=function(){return n.slice()},n}function vE(n,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new Ms(n,t)}function bE(n){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Ho(n)}function _E(n,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new Ms(n,t)}function wE(n){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new ln(n)}function ME(n){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new ln(n)}function SE(n){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new ln(n)}function EE(n,t,e){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new M(n,t,e)}function TE(n,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new xt(n,t).setUsage(lr)}function AE(n,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new Oo(n,t)}function CE(n,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new Fo(n,t)}function LE(n,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new zo(n,t)}function PE(n,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new No(n,t)}function RE(n,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ur(n,t)}function IE(n,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new Bo(n,t)}function DE(n,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new fr(n,t)}function OE(n,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new st(n,t)}function FE(n,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new Uo(n,t)}gt.create=function(n,t){return console.log("THREE.Curve.create() has been deprecated"),n.prototype=Object.create(gt.prototype),n.prototype.constructor=n,n.prototype.getPoint=t,n};Object.assign(Jn.prototype,{createPointsGeometry:function(n){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let t=this.getPoints(n);return this.createGeometry(t)},createSpacedPointsGeometry:function(n){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let t=this.getSpacedPoints(n);return this.createGeometry(t)},createGeometry:function(n){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");let t=new Ut;for(let e=0,i=n.length;e<i;e++){let r=n[e];t.vertices.push(new M(r.x,r.y,r.z||0))}return t}});Object.assign(an.prototype,{fromPoints:function(n){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(n)}});function Mx(n){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),xe.call(this,n),this.type="catmullrom",this.closed=!0}Mx.prototype=Object.create(xe.prototype);function Sx(n){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),xe.call(this,n),this.type="catmullrom"}Sx.prototype=Object.create(xe.prototype);function Dd(n){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),xe.call(this,n),this.type="catmullrom"}Dd.prototype=Object.create(xe.prototype);Object.assign(Dd.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});function zE(n){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new jl(n)}function NE(n,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Wl(n,t)}function BE(n,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Se(new la(n.geometry),new Zt({color:t!==void 0?t:16777215}))}Vl.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Hl.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};function UE(n,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new Se(new Xo(n.geometry),new Zt({color:t!==void 0?t:16777215}))}Object.assign(kt.prototype,{extractUrlBase:function(n){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),wd.extractUrlBase(n)}});kt.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};function kE(n){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Ze(n)}function GE(n){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Ml(n)}Object.assign(Fl.prototype,{setTexturePath:function(n){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(n)}});Object.assign(kl.prototype,{center:function(n){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(n)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(n){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(n)},size:function(n){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(n)}});Object.assign(je.prototype,{center:function(n){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(n)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(n){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(n)},isIntersectionSphere:function(n){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(n)},size:function(n){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(n)}});Object.assign(cn.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}});mr.prototype.setFromMatrix=function(n){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(n)};Gl.prototype.center=function(n){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(n)};Object.assign(_t,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(n){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),_t.floorPowerOfTwo(n)},nextPowerOfTwo:function(n){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),_t.ceilPowerOfTwo(n)}});Object.assign(pe.prototype,{flattenToArrayOffset:function(n,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(n,t)},multiplyVector3:function(n){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),n.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(n){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),n.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(At.prototype,{extractPosition:function(n){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(n)},flattenToArrayOffset:function(n,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(n,t)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new M().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(n){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(n)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(n){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),n.applyMatrix4(this)},multiplyVector4:function(n){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),n.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(n){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),n.transformDirection(this)},crossVector:function(n){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),n.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(n){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),n.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(n,t,e,i,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(n,t,i,e,r,s)}});Ge.prototype.isIntersectionLine=function(n){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(n)};ie.prototype.multiplyVector3=function(n){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),n.applyQuaternion(this)};Object.assign(Ci.prototype,{isIntersectionBox:function(n){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(n)},isIntersectionPlane:function(n){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(n)},isIntersectionSphere:function(n){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(n)}});Object.assign(Ve.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(n,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(n,t)},midpoint:function(n){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(n)},normal:function(n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(n)},plane:function(n){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(n)}});Object.assign(Ve,{barycoordFromPoint:function(n,t,e,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Ve.getBarycoord(n,t,e,i,r)},normal:function(n,t,e,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Ve.getNormal(n,t,e,i)}});Object.assign(Ei.prototype,{extractAllPoints:function(n){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(n)},extrude:function(n){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ia(this,n)},makeGeometry:function(n){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new aa(this,n)}});Object.assign(G.prototype,{fromAttribute:function(n,t,e){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(n,t,e)},distanceToManhattan:function(n){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(n)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(M.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(n){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(n)},getScaleFromMatrix:function(n){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(n)},getColumnFromMatrix:function(n,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,n)},applyProjection:function(n){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(n)},fromAttribute:function(n,t,e){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(n,t,e)},distanceToManhattan:function(n){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(n)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(Bt.prototype,{fromAttribute:function(n,t,e){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(n,t,e)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}});Object.assign(Ut.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(n){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(n)}});Object.assign(dt.prototype,{getChildByName:function(n){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(n)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(n,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,n)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(n){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(n)}});Object.defineProperties(dt.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(n){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=n}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.assign(Yt.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}});Object.defineProperties(Yt.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Vy},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});Object.defineProperties(Vo.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}});Object.defineProperty(Qc.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});$c.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Object.defineProperty(gt.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(n){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=n}});ne.prototype.setLens=function(n,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),t!==void 0&&(this.filmGauge=t),this.setFocalLength(n)};Object.defineProperties(Xt.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(n){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=n}},shadowCameraLeft:{set:function(n){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=n}},shadowCameraRight:{set:function(n){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=n}},shadowCameraTop:{set:function(n){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=n}},shadowCameraBottom:{set:function(n){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=n}},shadowCameraNear:{set:function(n){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=n}},shadowCameraFar:{set:function(n){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=n}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(n){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=n}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(n){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=n}},shadowMapHeight:{set:function(n){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=n}}});Object.defineProperties(xt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===lr},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(lr)}}});Object.assign(xt.prototype,{setDynamic:function(n){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(n===!0?lr:Sa),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(yt.prototype,{addIndex:function(n){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(n)},addAttribute:function(n,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(t&&t.isBufferAttribute)&&!(t&&t.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(n,new xt(arguments[1],arguments[2]))):n==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(n,t)},addDrawCall:function(n,t,e){e!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(n,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(n){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(n)},applyMatrix:function(n){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(n)}});Object.defineProperties(yt.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}});Object.defineProperties(pa.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(n){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=n}}});Object.defineProperties(Pd.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(n){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=n}}});Object.defineProperties(Oe.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===lr},set:function(n){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(n)}}});Object.assign(Oe.prototype,{setDynamic:function(n){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(n===!0?lr:Sa),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(gr.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.assign(Go.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}});Object.defineProperties(Ul.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}});Object.defineProperties(bt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new lt}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(n){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===fd}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(n){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=n}}});Object.defineProperties(zi.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(Fi.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(n){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=n}}});Object.defineProperties(Me.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(n){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=n}}});Object.assign(Ea.prototype,{clearTarget:function(n,t,e,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(n),this.clear(t,e,i)},animate:function(n){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(n)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(n){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(n)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}});Object.defineProperties(Ea.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(n){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=n}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(n){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=n}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(n){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=n===!0?Ma:we}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}});Object.defineProperties(ax.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});function HE(n,t,e){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new Li(n,e)}Object.defineProperties(ze.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(n){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=n}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(n){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=n}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(n){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=n}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(n){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=n}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(n){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=n}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(n){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=n}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(n){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=n}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(n){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=n}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(n){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=n}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(n){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=n}}});Object.defineProperties(ma.prototype,{load:{value:function(n){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");let t=this;return new zl().load(n,function(i){t.setBuffer(i)}),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}});Bl.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};vs.prototype.updateCubeMap=function(n,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(n,t)};var VE={merge:function(n,t,e){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");let i;t.isMesh&&(t.matrixAutoUpdate&&t.updateMatrix(),i=t.matrix,t=t.geometry),n.merge(t,i,e)},center:function(n){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),n.center()}};Ai.crossOrigin=void 0;Ai.loadTexture=function(n,t,e,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");let r=new Sl;r.setCrossOrigin(this.crossOrigin);let s=r.load(n,e,void 0,i);return t&&(s.mapping=t),s};Ai.loadTextureCube=function(n,t,e,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");let r=new wl;r.setCrossOrigin(this.crossOrigin);let s=r.load(n,e,void 0,i);return t&&(s.mapping=t),s};Ai.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Ai.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};function WE(){console.error("THREE.CanvasRenderer has been removed")}function jE(){console.error("THREE.JSONLoader has been removed.")}var XE={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};function qE(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xg}}));var $=Object.freeze({__proto__:null,ACESFilmicToneMapping:Xg,AddEquation:rr,AddOperation:Hg,AdditiveAnimationBlendMode:gd,AdditiveBlending:ff,AlphaFormat:ty,AlwaysDepth:Fg,AlwaysStencilFunc:Yy,AmbientLight:Ll,AmbientLightProbe:Xf,AnimationClip:He,AnimationLoader:Nf,AnimationMixer:Jf,AnimationObjectGroup:vx,AnimationUtils:qt,ArcCurve:Rs,ArrayCamera:Yc,ArrowHelper:cd,Audio:ma,AudioAnalyser:Bl,AudioContext:Ed,AudioListener:qf,AudioLoader:zl,AxesHelper:jl,AxisHelper:zE,BackSide:oe,BasicDepthPacking:jy,BasicShadowMap:Rb,BinaryTextureLoader:GE,Bone:If,BooleanKeyframeTrack:xl,BoundingBoxHelper:NE,Box2:kl,Box3:je,Box3Helper:od,BoxBufferGeometry:dr,BoxGeometry:ko,BoxHelper:Wl,BufferAttribute:xt,BufferGeometry:yt,BufferGeometryLoader:Ol,ByteType:Yg,Cache:Sr,Camera:Sn,CameraHelper:sd,CanvasRenderer:WE,CanvasTexture:Wo,CatmullRomCurve3:xe,CineonToneMapping:jg,CircleBufferGeometry:ua,CircleGeometry:ml,ClampToEdgeWrapping:_e,Clock:Nl,ClosedSplineCurve3:Mx,Color:lt,ColorKeyframeTrack:vl,CompressedTexture:Ss,CompressedTextureLoader:Bf,ConeBufferGeometry:pl,ConeGeometry:dl,CubeCamera:vs,CubeGeometry:ko,CubeReflectionMapping:ba,CubeRefractionMapping:_a,CubeTexture:Kn,CubeTextureLoader:wl,CubeUVReflectionMapping:Fs,CubeUVRefractionMapping:wa,CubicBezierCurve:hn,CubicBezierCurve3:Tn,CubicInterpolant:gl,CullFaceBack:uf,CullFaceFront:bg,CullFaceFrontBack:Pb,CullFaceNone:vg,Curve:gt,CurvePath:Jn,CustomBlending:wg,CustomToneMapping:qg,CylinderBufferGeometry:yr,CylinderGeometry:ha,Cylindrical:Kf,DataTexture:pr,DataTexture2DArray:_s,DataTexture3D:ws,DataTextureLoader:Ml,DecrementStencilOp:Hb,DecrementWrapStencilOp:Wb,DefaultLoadingManager:gx,DepthFormat:cr,DepthStencilFormat:gs,DepthTexture:jo,DirectionalLight:Cl,DirectionalLightHelper:rd,DiscreteInterpolant:yl,DodecahedronBufferGeometry:Jo,DodecahedronGeometry:sl,DoubleSide:xa,DstAlphaFactor:Lg,DstColorFactor:Rg,DynamicBufferAttribute:TE,DynamicCopyUsage:r_,DynamicDrawUsage:lr,DynamicReadUsage:e_,EdgesGeometry:la,EdgesHelper:BE,EllipseCurve:Ue,EqualDepth:Ng,EqualStencilFunc:Yb,EquirectangularReflectionMapping:Vc,EquirectangularRefractionMapping:Wc,Euler:ys,EventDispatcher:Je,ExtrudeBufferGeometry:gr,ExtrudeGeometry:ia,Face3:hr,Face4:uE,FaceColors:mE,FileLoader:Ze,FlatShading:fd,Float32Attribute:OE,Float32BufferAttribute:st,Float64Attribute:FE,Float64BufferAttribute:Uo,FloatType:Zn,Fog:Jc,FogExp2:Zc,Font:Sd,FontLoader:Wf,FrontSide:Os,Frustum:mr,GLBufferAttribute:Ld,GLSL1:o_,GLSL3:Af,GammaEncoding:Yl,Geometry:Ut,GeometryUtils:VE,GreaterDepth:Ug,GreaterEqualDepth:Bg,GreaterEqualStencilFunc:Qb,GreaterStencilFunc:Jb,GridHelper:Vl,Group:wi,HalfFloatType:Po,HemisphereLight:El,HemisphereLightHelper:nd,HemisphereLightProbe:jf,IcosahedronBufferGeometry:Zo,IcosahedronGeometry:rl,ImageBitmapLoader:Vf,ImageLoader:Ps,ImageUtils:Ai,ImmediateRenderObject:ya,IncrementStencilOp:Gb,IncrementWrapStencilOp:Vb,InstancedBufferAttribute:Dl,InstancedBufferGeometry:pa,InstancedInterleavedBuffer:$f,InstancedMesh:Kc,Int16Attribute:PE,Int16BufferAttribute:No,Int32Attribute:IE,Int32BufferAttribute:Bo,Int8Attribute:AE,Int8BufferAttribute:Oo,IntType:Jg,InterleavedBuffer:Oe,InterleavedBufferAttribute:Ii,Interpolant:Ne,InterpolateDiscrete:Ro,InterpolateLinear:wo,InterpolateSmooth:kc,InvertStencilOp:jb,JSONLoader:jE,KeepStencilOp:Gc,KeyframeTrack:me,LOD:Vo,LatheBufferGeometry:oa,LatheGeometry:fl,Layers:Do,LensFlare:qE,LessDepth:zg,LessEqualDepth:Hc,LessEqualStencilFunc:Zb,LessStencilFunc:qb,Light:Xt,LightProbe:We,LightShadow:Cn,Line:Ye,Line3:Gl,LineBasicMaterial:Zt,LineCurve:Ae,LineCurve3:un,LineDashedMaterial:Mr,LineLoop:tl,LinePieces:dE,LineSegments:Se,LineStrip:fE,LinearEncoding:we,LinearFilter:he,LinearInterpolant:fa,LinearMipMapLinearFilter:zb,LinearMipMapNearestFilter:Fb,LinearMipmapLinearFilter:zs,LinearMipmapNearestFilter:md,LinearToneMapping:Vg,Loader:kt,LoaderUtils:wd,LoadingManager:bd,LogLuvEncoding:Wy,LoopOnce:ky,LoopPingPong:Hy,LoopRepeat:Gy,LuminanceAlphaFormat:ny,LuminanceFormat:ey,MOUSE:qn,Material:bt,MaterialLoader:Il,Math:_t,MathUtils:_t,Matrix3:pe,Matrix4:At,MaxEquation:gf,Mesh:Yt,MeshBasicMaterial:Xe,MeshDepthMaterial:Pi,MeshDistanceMaterial:Ri,MeshFaceMaterial:yE,MeshLambertMaterial:_r,MeshMatcapMaterial:wr,MeshNormalMaterial:br,MeshPhongMaterial:zi,MeshPhysicalMaterial:Fi,MeshStandardMaterial:En,MeshToonMaterial:vr,MinEquation:mf,MirroredRepeatWrapping:Co,MixOperation:Gg,MultiMaterial:xE,MultiplyBlending:pf,MultiplyOperation:va,NearestFilter:ae,NearestMipMapLinearFilter:Ob,NearestMipMapNearestFilter:Db,NearestMipmapLinearFilter:Xc,NearestMipmapNearestFilter:jc,NeverDepth:Og,NeverStencilFunc:Xb,NoBlending:$n,NoColors:pE,NoToneMapping:ar,NormalAnimationBlendMode:ql,NormalBlending:ds,NotEqualDepth:kg,NotEqualStencilFunc:$b,NumberKeyframeTrack:Cs,Object3D:dt,ObjectLoader:Fl,ObjectSpaceNormalMap:qy,OctahedronBufferGeometry:Ts,OctahedronGeometry:il,OneFactor:Tg,OneMinusDstAlphaFactor:Pg,OneMinusDstColorFactor:Ig,OneMinusSrcAlphaFactor:pd,OneMinusSrcColorFactor:Cg,OrthographicCamera:Is,PCFShadowMap:ud,PCFSoftShadowMap:_g,PMREMGenerator:ld,ParametricBufferGeometry:Es,ParametricGeometry:qo,Particle:bE,ParticleBasicMaterial:ME,ParticleSystem:_E,ParticleSystemMaterial:SE,Path:an,PerspectiveCamera:ne,Plane:Ge,PlaneBufferGeometry:bs,PlaneGeometry:qc,PlaneHelper:ad,PointCloud:vE,PointCloudMaterial:wE,PointLight:Al,PointLightHelper:ed,Points:Ms,PointsMaterial:ln,PolarGridHelper:id,PolyhedronBufferGeometry:ti,PolyhedronGeometry:el,PositionalAudio:Yf,PropertyBinding:ye,PropertyMixer:Td,QuadraticBezierCurve:fn,QuadraticBezierCurve3:An,Quaternion:ie,QuaternionKeyframeTrack:da,QuaternionLinearInterpolant:bl,REVISION:xg,RGBADepthPacking:Xy,RGBAFormat:Fe,RGBAIntegerFormat:ly,RGBA_ASTC_10x10_Format:wy,RGBA_ASTC_10x5_Format:vy,RGBA_ASTC_10x6_Format:by,RGBA_ASTC_10x8_Format:_y,RGBA_ASTC_12x10_Format:My,RGBA_ASTC_12x12_Format:Sy,RGBA_ASTC_4x4_Format:uy,RGBA_ASTC_5x4_Format:fy,RGBA_ASTC_5x5_Format:dy,RGBA_ASTC_6x5_Format:py,RGBA_ASTC_6x6_Format:my,RGBA_ASTC_8x5_Format:gy,RGBA_ASTC_8x6_Format:yy,RGBA_ASTC_8x8_Format:xy,RGBA_BPTC_Format:Ey,RGBA_ETC2_EAC_Format:Tf,RGBA_PVRTC_2BPPV1_Format:Sf,RGBA_PVRTC_4BPPV1_Format:Mf,RGBA_S3TC_DXT1_Format:xf,RGBA_S3TC_DXT3_Format:vf,RGBA_S3TC_DXT5_Format:bf,RGBDEncoding:vd,RGBEEncoding:Zl,RGBEFormat:iy,RGBFormat:Mi,RGBIntegerFormat:cy,RGBM16Encoding:xd,RGBM7Encoding:yd,RGB_ETC1_Format:hy,RGB_ETC2_Format:Ef,RGB_PVRTC_2BPPV1_Format:wf,RGB_PVRTC_4BPPV1_Format:_f,RGB_S3TC_DXT1_Format:yf,RGFormat:oy,RGIntegerFormat:ay,RawShaderMaterial:ei,Ray:Ci,Raycaster:Pd,RectAreaLight:Pl,RedFormat:ry,RedIntegerFormat:sy,ReinhardToneMapping:Wg,RepeatWrapping:Ao,ReplaceStencilOp:kb,ReverseSubtractEquation:Sg,RingBufferGeometry:sa,RingGeometry:ul,SRGB8_ALPHA8_ASTC_10x10_Format:Ny,SRGB8_ALPHA8_ASTC_10x5_Format:Oy,SRGB8_ALPHA8_ASTC_10x6_Format:Fy,SRGB8_ALPHA8_ASTC_10x8_Format:zy,SRGB8_ALPHA8_ASTC_12x10_Format:By,SRGB8_ALPHA8_ASTC_12x12_Format:Uy,SRGB8_ALPHA8_ASTC_4x4_Format:Ty,SRGB8_ALPHA8_ASTC_5x4_Format:Ay,SRGB8_ALPHA8_ASTC_5x5_Format:Cy,SRGB8_ALPHA8_ASTC_6x5_Format:Ly,SRGB8_ALPHA8_ASTC_6x6_Format:Py,SRGB8_ALPHA8_ASTC_8x5_Format:Ry,SRGB8_ALPHA8_ASTC_8x6_Format:Iy,SRGB8_ALPHA8_ASTC_8x8_Format:Dy,Scene:Go,SceneUtils:XE,ShaderChunk:Pt,ShaderLib:on,ShaderMaterial:Me,ShadowMaterial:xr,Shape:Ei,ShapeBufferGeometry:ca,ShapeGeometry:aa,ShapePath:Md,ShapeUtils:Qn,ShortType:Zg,Skeleton:Qc,SkeletonHelper:Hl,SkinnedMesh:$c,SmoothShading:Ib,Sphere:cn,SphereBufferGeometry:As,SphereGeometry:hl,Spherical:ga,SphericalHarmonics3:Rl,Spline:Dd,SplineCurve:dn,SplineCurve3:Sx,SpotLight:Tl,SpotLightHelper:td,Sprite:Ho,SpriteMaterial:Di,SrcAlphaFactor:dd,SrcAlphaSaturateFactor:Dg,SrcColorFactor:Ag,StaticCopyUsage:i_,StaticDrawUsage:Sa,StaticReadUsage:t_,StereoCamera:yx,StreamCopyUsage:s_,StreamDrawUsage:Kb,StreamReadUsage:n_,StringKeyframeTrack:_l,SubtractEquation:Mg,SubtractiveBlending:df,TOUCH:Yn,TangentSpaceNormalMap:Er,TetrahedronBufferGeometry:Yo,TetrahedronGeometry:nl,TextBufferGeometry:ra,TextGeometry:ll,Texture:Gt,TextureLoader:Sl,TorusBufferGeometry:Ko,TorusGeometry:cl,TorusKnotBufferGeometry:Qo,TorusKnotGeometry:al,Triangle:Ve,TriangleFanDrawMode:Bb,TriangleStripDrawMode:Nb,TrianglesDrawMode:Vy,TubeBufferGeometry:$o,TubeGeometry:ol,UVMapping:Xl,Uint16Attribute:RE,Uint16BufferAttribute:ur,Uint32Attribute:DE,Uint32BufferAttribute:fr,Uint8Attribute:CE,Uint8BufferAttribute:Fo,Uint8ClampedAttribute:LE,Uint8ClampedBufferAttribute:zo,Uniform:Ul,UniformsLib:ct,UniformsUtils:Qy,UnsignedByteType:Ns,UnsignedInt248Type:ps,UnsignedIntType:_o,UnsignedShort4444Type:$g,UnsignedShort5551Type:Qg,UnsignedShort565Type:Kg,UnsignedShortType:Lo,VSMShadowMap:cs,Vector2:G,Vector3:M,Vector4:Bt,VectorKeyframeTrack:Ls,Vertex:EE,VertexColors:gE,VideoTexture:Of,WebGL1Renderer:Rf,WebGLCubeRenderTarget:Li,WebGLMultisampleRenderTarget:Cf,WebGLRenderTarget:ze,WebGLRenderTargetCube:HE,WebGLRenderer:Ea,WebGLUtils:cx,WireframeGeometry:Xo,WireframeHelper:UE,WrapAroundEnding:Io,XHRLoader:kE,ZeroCurvatureEnding:sr,ZeroFactor:Eg,ZeroSlopeEnding:or,ZeroStencilOp:Ub,sRGBEncoding:Ma}),Ds=function(n,t){t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=n,this.domElement=t,this.enabled=!0,this.target=new M,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=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.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:qn.ROTATE,MIDDLE:qn.DOLLY,RIGHT:qn.PAN},this.touches={ONE:Yn.ROTATE,TWO:Yn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(i),e.update(),a=o.NONE},this.update=function(){var C=new M,J=new ie().setFromUnitVectors(n.up,new M(0,1,0)),ht=J.clone().inverse(),nt=new M,mt=new ie,Ft=2*Math.PI;return function(){var Gs=e.object.position;C.copy(Gs).sub(e.target),C.applyQuaternion(J),l.setFromVector3(C),e.autoRotate&&a===o.NONE&&D(A()),e.enableDamping?(l.theta+=u.theta*e.dampingFactor,l.phi+=u.phi*e.dampingFactor):(l.theta+=u.theta,l.phi+=u.phi);var $e=e.minAzimuthAngle,ke=e.maxAzimuthAngle;return isFinite($e)&&isFinite(ke)&&($e<-Math.PI?$e+=Ft:$e>Math.PI&&($e-=Ft),ke<-Math.PI?ke+=Ft:ke>Math.PI&&(ke-=Ft),$e<ke?l.theta=Math.max($e,Math.min(ke,l.theta)):l.theta=l.theta>($e+ke)/2?Math.max($e,l.theta):Math.min(ke,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),l.radius*=h,l.radius=Math.max(e.minDistance,Math.min(e.maxDistance,l.radius)),e.enableDamping===!0?e.target.addScaledVector(d,e.dampingFactor):e.target.add(d),C.setFromSpherical(l),C.applyQuaternion(ht),Gs.copy(e.target).add(C),e.object.lookAt(e.target),e.enableDamping===!0?(u.theta*=1-e.dampingFactor,u.phi*=1-e.dampingFactor,d.multiplyScalar(1-e.dampingFactor)):(u.set(0,0,0),d.set(0,0,0)),h=1,f||nt.distanceToSquared(e.object.position)>c||8*(1-mt.dot(e.object.quaternion))>c?(e.dispatchEvent(i),nt.copy(e.object.position),mt.copy(e.object.quaternion),f=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",tt,!1),e.domElement.removeEventListener("pointerdown",et,!1),e.domElement.removeEventListener("wheel",W,!1),e.domElement.removeEventListener("touchstart",Y,!1),e.domElement.removeEventListener("touchend",ft,!1),e.domElement.removeEventListener("touchmove",rt,!1),e.domElement.ownerDocument.removeEventListener("pointermove",pt,!1),e.domElement.ownerDocument.removeEventListener("pointerup",ot,!1),e.domElement.removeEventListener("keydown",L,!1)};var e=this,i={type:"change"},r={type:"start"},s={type:"end"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},a=o.NONE,c=1e-6,l=new ga,u=new ga,h=1,d=new M,f=!1,p=new G,y=new G,x=new G,g=new G,m=new G,b=new G,v=new G,w=new G,_=new G;function A(){return 2*Math.PI/60/60*e.autoRotateSpeed}function I(){return Math.pow(.95,e.zoomSpeed)}function D(C){u.theta-=C}function N(C){u.phi-=C}var O=function(){var C=new M;return function(ht,nt){C.setFromMatrixColumn(nt,0),C.multiplyScalar(-ht),d.add(C)}}(),F=function(){var C=new M;return function(ht,nt){e.screenSpacePanning===!0?C.setFromMatrixColumn(nt,1):(C.setFromMatrixColumn(nt,0),C.crossVectors(e.object.up,C)),C.multiplyScalar(ht),d.add(C)}}(),z=function(){var C=new M;return function(ht,nt){var mt=e.domElement;if(e.object.isPerspectiveCamera){var Ft=e.object.position;C.copy(Ft).sub(e.target);var se=C.length();se*=Math.tan(e.object.fov/2*Math.PI/180),O(2*ht*se/mt.clientHeight,e.object.matrix),F(2*nt*se/mt.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(O(ht*(e.object.right-e.object.left)/e.object.zoom/mt.clientWidth,e.object.matrix),F(nt*(e.object.top-e.object.bottom)/e.object.zoom/mt.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function P(C){e.object.isPerspectiveCamera?h/=C:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*C)),e.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function R(C){e.object.isPerspectiveCamera?h*=C:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/C)),e.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(C){p.set(C.clientX,C.clientY)}function j(C){v.set(C.clientX,C.clientY)}function Z(C){g.set(C.clientX,C.clientY)}function K(C){y.set(C.clientX,C.clientY),x.subVectors(y,p).multiplyScalar(e.rotateSpeed);var J=e.domElement;D(2*Math.PI*x.x/J.clientHeight),N(2*Math.PI*x.y/J.clientHeight),p.copy(y),e.update()}function ut(C){w.set(C.clientX,C.clientY),_.subVectors(w,v),_.y>0?P(I()):_.y<0&&R(I()),v.copy(w),e.update()}function it(C){m.set(C.clientX,C.clientY),b.subVectors(m,g).multiplyScalar(e.panSpeed),z(b.x,b.y),g.copy(m),e.update()}function St(C){C.deltaY<0?R(I()):C.deltaY>0&&P(I()),e.update()}function wt(C){var J=!1;switch(C.keyCode){case e.keys.UP:z(0,e.keyPanSpeed),J=!0;break;case e.keys.BOTTOM:z(0,-e.keyPanSpeed),J=!0;break;case e.keys.LEFT:z(e.keyPanSpeed,0),J=!0;break;case e.keys.RIGHT:z(-e.keyPanSpeed,0),J=!0;break}J&&(C.preventDefault(),e.update())}function Ht(C){if(C.touches.length==1)p.set(C.touches[0].pageX,C.touches[0].pageY);else{var J=.5*(C.touches[0].pageX+C.touches[1].pageX),ht=.5*(C.touches[0].pageY+C.touches[1].pageY);p.set(J,ht)}}function V(C){if(C.touches.length==1)g.set(C.touches[0].pageX,C.touches[0].pageY);else{var J=.5*(C.touches[0].pageX+C.touches[1].pageX),ht=.5*(C.touches[0].pageY+C.touches[1].pageY);g.set(J,ht)}}function re(C){var J=C.touches[0].pageX-C.touches[1].pageX,ht=C.touches[0].pageY-C.touches[1].pageY,nt=Math.sqrt(J*J+ht*ht);v.set(0,nt)}function vt(C){e.enableZoom&&re(C),e.enablePan&&V(C)}function It(C){e.enableZoom&&re(C),e.enableRotate&&Ht(C)}function Mt(C){if(C.touches.length==1)y.set(C.touches[0].pageX,C.touches[0].pageY);else{var J=.5*(C.touches[0].pageX+C.touches[1].pageX),ht=.5*(C.touches[0].pageY+C.touches[1].pageY);y.set(J,ht)}x.subVectors(y,p).multiplyScalar(e.rotateSpeed);var nt=e.domElement;D(2*Math.PI*x.x/nt.clientHeight),N(2*Math.PI*x.y/nt.clientHeight),p.copy(y)}function Ot(C){if(C.touches.length==1)m.set(C.touches[0].pageX,C.touches[0].pageY);else{var J=.5*(C.touches[0].pageX+C.touches[1].pageX),ht=.5*(C.touches[0].pageY+C.touches[1].pageY);m.set(J,ht)}b.subVectors(m,g).multiplyScalar(e.panSpeed),z(b.x,b.y),g.copy(m)}function Et(C){var J=C.touches[0].pageX-C.touches[1].pageX,ht=C.touches[0].pageY-C.touches[1].pageY,nt=Math.sqrt(J*J+ht*ht);w.set(0,nt),_.set(0,Math.pow(w.y/v.y,e.zoomSpeed)),P(_.y),v.copy(w)}function X(C){e.enableZoom&&Et(C),e.enablePan&&Ot(C)}function Q(C){e.enableZoom&&Et(C),e.enableRotate&&Mt(C)}function et(C){if(e.enabled!==!1)switch(C.pointerType){case"mouse":S(C);break}}function pt(C){if(e.enabled!==!1)switch(C.pointerType){case"mouse":T(C);break}}function ot(C){if(e.enabled!==!1)switch(C.pointerType){case"mouse":q();break}}function S(C){C.preventDefault(),e.domElement.focus?e.domElement.focus():window.focus();var J;switch(C.button){case 0:J=e.mouseButtons.LEFT;break;case 1:J=e.mouseButtons.MIDDLE;break;case 2:J=e.mouseButtons.RIGHT;break;default:J=-1}switch(J){case qn.DOLLY:if(e.enableZoom===!1)return;j(C),a=o.DOLLY;break;case qn.ROTATE:if(C.ctrlKey||C.metaKey||C.shiftKey){if(e.enablePan===!1)return;Z(C),a=o.PAN}else{if(e.enableRotate===!1)return;U(C),a=o.ROTATE}break;case qn.PAN:if(C.ctrlKey||C.metaKey||C.shiftKey){if(e.enableRotate===!1)return;U(C),a=o.ROTATE}else{if(e.enablePan===!1)return;Z(C),a=o.PAN}break;default:a=o.NONE}a!==o.NONE&&(e.domElement.ownerDocument.addEventListener("pointermove",pt,!1),e.domElement.ownerDocument.addEventListener("pointerup",ot,!1),e.dispatchEvent(r))}function T(C){if(e.enabled!==!1)switch(C.preventDefault(),a){case o.ROTATE:if(e.enableRotate===!1)return;K(C);break;case o.DOLLY:if(e.enableZoom===!1)return;ut(C);break;case o.PAN:if(e.enablePan===!1)return;it(C);break}}function q(C){e.enabled!==!1&&(e.domElement.ownerDocument.removeEventListener("pointermove",pt,!1),e.domElement.ownerDocument.removeEventListener("pointerup",ot,!1),e.dispatchEvent(s),a=o.NONE)}function W(C){e.enabled===!1||e.enableZoom===!1||a!==o.NONE&&a!==o.ROTATE||(C.preventDefault(),C.stopPropagation(),e.dispatchEvent(r),St(C),e.dispatchEvent(s))}function L(C){e.enabled===!1||e.enableKeys===!1||e.enablePan===!1||wt(C)}function Y(C){if(e.enabled!==!1){switch(C.preventDefault(),C.touches.length){case 1:switch(e.touches.ONE){case Yn.ROTATE:if(e.enableRotate===!1)return;Ht(C),a=o.TOUCH_ROTATE;break;case Yn.PAN:if(e.enablePan===!1)return;V(C),a=o.TOUCH_PAN;break;default:a=o.NONE}break;case 2:switch(e.touches.TWO){case Yn.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;vt(C),a=o.TOUCH_DOLLY_PAN;break;case Yn.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;It(C),a=o.TOUCH_DOLLY_ROTATE;break;default:a=o.NONE}break;default:a=o.NONE}a!==o.NONE&&e.dispatchEvent(r)}}function rt(C){if(e.enabled!==!1)switch(C.preventDefault(),C.stopPropagation(),a){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;Mt(C),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;Ot(C),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;X(C),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Q(C),e.update();break;default:a=o.NONE}}function ft(C){e.enabled!==!1&&(e.dispatchEvent(s),a=o.NONE)}function tt(C){e.enabled!==!1&&C.preventDefault()}e.domElement.addEventListener("contextmenu",tt,!1),e.domElement.addEventListener("pointerdown",et,!1),e.domElement.addEventListener("wheel",W,!1),e.domElement.addEventListener("touchstart",Y,!1),e.domElement.addEventListener("touchend",ft,!1),e.domElement.addEventListener("touchmove",rt,!1),e.domElement.addEventListener("keydown",L,!1),e.domElement.tabIndex===-1&&(e.domElement.tabIndex=0),this.update()};Ds.prototype=Object.create(Je.prototype);Ds.prototype.constructor=Ds;var hd=function(n,t){Ds.call(this,n,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=qn.PAN,this.mouseButtons.RIGHT=qn.ROTATE,this.touches.ONE=Yn.PAN,this.touches.TWO=Yn.DOLLY_ROTATE};hd.prototype=Object.create(Je.prototype);hd.prototype.constructor=hd;function YE(n,t=0){return{vertices:[-n,-n,t,n,-n,t,n,n,t,-n,n,t],indices:[0,1,2,0,2,3]}}var ZE=YE(.5,0);function Tr(n,t){return n[t.options.colorType]||n}function Us(n){n.parent.remove(n),n.geometry.dispose(),n.material.dispose(),n.material.map&&n.material.map.dispose(),zt(n.userData,(t,e)=>delete n.userData[e])}var JE=.25,$l=Math.PI,Ni=class{constructor(t,e={}){e=Object.assign(this.constructor.options(t),e);let{scene:i,world:r}=t;Object.assign(this,{scene:i,world:r,view:t,options:e}),this.mesh=null,this.name=this.constructor.name}centerMesh(){let{centerX:t,centerY:e,width:i,height:r}=this.world;this.canvas&&([t,e]=[0,0]);let s=this.view.meshes.patches===this&&this.view.options.turtles.meshClass==="Obj3DMesh"?this.world.minZ:this.options.z*JE;this.mesh.position.set(-t,-e,s)}init(){throw Error("init is abstract, must be overriden")}update(){throw Error("update is abstract, must be overriden")}get spriteSheetTexture(){if(this.view.spriteSheet.texture==null){let t=new $.CanvasTexture(this.view.spriteSheet.ctx.canvas);this.view.spriteSheet.texture=t}return this.view.spriteSheet.texture}},Od=class{constructor(){this.options={}}init(){}update(){}},Ql=class extends Ni{static options(t){return{textureOptions:{minFilter:$.LinearFilter,magFilter:$.LinearFilter},z:0,useSegments:!1,canvas:t.patchesCanvas()}}init(){this.mesh&&Us(this.mesh);let{canvas:t,textureOptions:e,useSegments:i,z:r}=this.options;Object.assign(this,{canvas:t,z:r,textureOptions:e});let{width:s,height:o,centerX:a,centerY:c}=this.world,l=new $.CanvasTexture(t);Object.assign(l,e);let u=new $.PlaneBufferGeometry(s,o,i?s:1,i?o:1),h=new $.MeshBasicMaterial({map:l,side:$.DoubleSide,transparent:!0});this.mesh=new $.Mesh(u,h),this.mesh.position.z=r,this.scene.add(this.mesh)}update(){this.mesh.material.map.needsUpdate=!0}},Fd=class extends Ql{static options(t){return{textureOptions:{minFilter:$.NearestFilter,magFilter:$.NearestFilter},z:0,useSegments:!1,colorType:"pixel",canvas:t.patchesCanvas()}}init(){super.init(),this.centerMesh()}update(t,e=i=>i){t&&this.view.patchesView.setPixels(t,e),this.view.patchesView.updateCanvas(),super.update()}};var zd=class extends Ni{static options(){return{z:2,colorType:"css"}}init(){this.mesh&&Us(this.mesh);let t=this.spriteSheetTexture,e=new $.BufferGeometry;e.setAttribute("position",new $.Float32BufferAttribute([],3)),e.setAttribute("uv",new $.Float32BufferAttribute([],2)),e.setIndex(new $.Uint32BufferAttribute([],1));let i=new $.MeshBasicMaterial({map:t,alphaTest:.5,side:$.DoubleSide});this.mesh=new $.Mesh(e,i),this.centerMesh(),this.scene.add(this.mesh)}update(t,e){let{vertices:i,indices:r}=ZE,s=new Float32Array(i.length*t.length),o=[],a=[];zt(t,(c,l)=>{if(c.hidden)return;let{x:u,y:h,z:d,theta:f}=c,p=e(c,l),{size:y,sprite:x}=p;x||(x=this.view.getSprite(p.shape,Tr(p.color,this)));let g=Math.cos(f),m=Math.sin(f),b=l*i.length;for(let v=0;v<i.length;v=v+3){let w=i[v],_=i[v+1];s[v+b]=y*(w*g-_*m)+u,s[v+b+1]=y*(w*m+_*g)+h,s[v+b+2]=d}a.push(...r.map(v=>v+l*4)),o.push(...x.uvs)}),this.mesh.geometry.setAttribute("position",new $.BufferAttribute(s,3)),this.mesh.geometry.setAttribute("uv",new $.Float32BufferAttribute(o,2)),this.mesh.geometry.setIndex(new $.Uint32BufferAttribute(a,1))}},Nd=class extends Ni{static options(){return{size:1,color:null,z:2.5,colorType:"webgl"}}init(){this.mesh&&Us(this.mesh);let t=this.options.size;this.fixedColor=this.options.color?new $.Color(...Tr(this.options.color,this)):null;let e=new $.BufferGeometry;e.setAttribute("position",new $.Float32BufferAttribute([],3)),this.fixedColor||e.setAttribute("color",new $.Float32BufferAttribute([],3));let i=this.fixedColor?new $.PointsMaterial({size:t,color:this.fixedColor}):new $.PointsMaterial({size:t,vertexColors:!0});this.mesh=new $.Points(e,i),this.centerMesh(),this.scene.add(this.mesh)}update(t,e){let i=[],r=this.fixedColor?null:[];zt(t,(s,o)=>{if(s.hidden)return;let{x:a,y:c,z:l}=s;i.push(a,c,l),r&&r.push(...Tr(e(s,o).color,this))}),this.mesh.geometry.setAttribute("position",new $.Float32BufferAttribute(i,3)),r&&this.mesh.geometry.setAttribute("color",new $.Float32BufferAttribute(r,3))}},Bd=class extends Ni{static options(){return{color:null,z:0,colorType:"webgl"}}init(){this.mesh&&Us(this.mesh),this.fixedColor=this.options.color?new $.Color(...Tr(this.options.color,this)):null;let t=new $.BufferGeometry;t.setAttribute("position",new $.Float32BufferAttribute([],3)),this.fixedColor||t.setAttribute("color",new $.Float32BufferAttribute([],3));let e=this.fixedColor?new $.LineBasicMaterial({color:this.fixedColor}):new $.LineBasicMaterial({vertexColors:!0});this.mesh=new $.LineSegments(t,e),this.centerMesh(),this.scene.add(this.mesh)}update(t,e){let i=[],r=this.fixedColor?null:[];zt(t,(s,o)=>{let{x0:a,y0:c,z0:l,x1:u,y1:h,z1:d}=s;if(l||(l=0),d||(d=0),i.push(a,c,l,u,h,d),r){let f=Tr(e(s,o).color,this);r.push(...f,...f)}}),this.mesh.geometry.setAttribute("position",new $.Float32BufferAttribute(i,3)),r&&this.mesh.geometry.setAttribute("color",new $.Float32BufferAttribute(r,3))}},Ud={Dart:()=>QE(),Cone0:()=>new $.ConeBufferGeometry(.5).rotateX($l/2),Cone:()=>new $.ConeBufferGeometry(.5).rotateZ(-$l/2),Cube:()=>new $.BoxBufferGeometry,Cylinder0:()=>new $.CylinderBufferGeometry(.5,.5,1).rotateX($l/2),Cylinder:()=>new $.CylinderBufferGeometry(.5,.5,1).rotateZ(-$l/2),Sphere:()=>new $.SphereBufferGeometry(.5)},$E=xn.fromArray(Object.keys(Ud));function Ex(n){let t=Ud[n];return t||(console.log("Geometry not found: ",n,"..using Default"),n="Dart",t=Ud[n]),[t(),n]}var kd=class extends Ni{static options(){return{z:2,colorType:"webgl",useAxes:!1}}init(){this.meshes&&this.meshes.forEach(t=>Us(t)),this.meshes=new Map,this.lastAgentsLength=null,this.lastAgentsMaxID=null}newMesh(s="Dart",e="red",i=1){var[r,s]=Ex(s);i!==1&&r.scale(i,i,i);let o={shape:s,color:e,size:i};e=new $.Color(...Tr(e,this));let a=this.view.options.useLights?new $.MeshPhongMaterial({color:e}):new $.MeshBasicMaterial({color:e}),c=new $.Mesh(r,a);return c.rotation.order="ZYX",this.options.useAxes&&c.add(new $.AxesHelper(i)),c.userData.view=o,this.scene.add(c),c}checkDeadAgents(t){let e=this.lastAgentsLength,i=this.lastAgentsMaxID;e!==0&&(e!=null&&(e>t.length||t.last().id!==i)&&this.meshes.forEach((r,s)=>{r.userData.agent.id===-1&&(Us(r),this.meshes.delete(s))}),this.lastAgentsLength=t.length,this.lastAgentsMaxID=t.length===0?null:t.last().id)}update(t,e){this.checkDeadAgents(t),!t.hidden&&zt(t,i=>{if(i.hidden)return;let r=e(i),s=this.meshes.get(i);if(s){var{shape:o,color:a,size:c}=s.userData.view;if(a!==r.color&&(a=s.userData.view.color=r.color,a=new $.Color(...Tr(a,this)),s.material.color=a),o!==r.shape){var[l,o]=Ex(r.shape);s.geometry.dispose(),s.geometry=l,s.geometry.scale(c,c,c),s.userData.view.shape=o}c!==r.size&&(c=r.size/c,s.geometry.scale(c,c,c),s.userData.view.size=r.size)}s||(s=this.newMesh(r.shape,r.color,r.size),this.meshes.set(i,s),s.userData.agent=i);let u=i.obj3d;if(u){let h=u.position;s.position.set(h.x,h.y,h.z);let d=u.rotation;s.rotation.set(d.x,d.y,d.z)}else s.position.set(i.x,i.y,i.z),s.rotation.set(0,0,0)})}};function QE(){let o=new $.Geometry;o.vertices.push(new $.Vector3(.5,0,0),new $.Vector3(-.5,-.5,0),new $.Vector3(-.3,0,.35),new $.Vector3(-.5,.5,0),new $.Vector3(-.3,0,0));let[a,c,l,u,h]=[0,1,2,3,4];return o.faces.push(new $.Face3(a,u,l),new $.Face3(a,l,c),new $.Face3(a,c,h),new $.Face3(a,h,u),new $.Face3(l,u,h),new $.Face3(l,h,c)),o.computeFaceNormals(),o}var Kl={BaseMesh:Ni,NullMesh:Od,CanvasMesh:Ql,PatchesMesh:Fd,QuadSpritesMesh:zd,PointsMesh:Nd,LinksMesh:Bd,Obj3DMesh:kd,Obj3DShapes:$E};var Gd=class n{static shapeNames(){return Kl.Obj3DShapes}static defaultOptions(t=!0){return{div:document.body,orthoView:!1,clearColor:0,useAxes:t,useGrid:t,useWorldOutline:t,useLights:!0,spriteSize:64,patches:{meshClass:"PatchesMesh"},turtles:{meshClass:"QuadSpritesMesh"},links:{meshClass:"LinksMesh"}}}constructor(t=Bn.defaultOptions(),e={}){if(e=Object.assign(n.defaultOptions(),e),e.useLights=e.useLights||e.turtles.meshClass==="Obj3DMesh",this.div=Le(e.div)?document.getElementById(e.div):e.div,this.div.height||(this.div.style.height="600px"),this.world=new Bn(t.world||t),this.options=e,this.ticks=0,this.options.spriteSize!==0){let i=Cr(this.options.spriteSize);this.spriteSheet=new Cu(this.options.spriteSize,16,i)}e.patches&&e.patches.meshClass==="PatchesMesh"&&(this.patchesView=new oo(this.world.numX,this.world.numY)),this.initThree(),this.initThreeHelpers(),this.initMeshes()}initThree(){let{clientWidth:t,clientHeight:e}=this.div,{orthoView:i,clearColor:r}=this.options,[s,o]=this.world.getWorldSize(),[a,c]=[s/2,o/2],l=new $.OrthographicCamera(-a,a,c,-c,1,20*s);l.position.set(0,0,10*s),l.up.set(0,0,1);let u=new $.PerspectiveCamera(45,t/e,.1,1e4);u.position.set(s,-s,1.2*s),u.up.set(0,0,1);let h=new $.Scene,d=i?l:u,f=new $.WebGLRenderer;f.setPixelRatio(window.devicePixelRatio),f.setSize(t,e),f.setClearColor(r),this.div.appendChild(f.domElement),this.orbitControls=new Ds(d,f.domElement),window.addEventListener("resize",()=>{this.resize()}),Object.assign(this,{scene:h,camera:d,renderer:f,orthographicCam:l,perspectiveCam:u})}resize(){let{clientWidth:t,clientHeight:e}=this.div,[i,r]=this.world.getWorldSize();if(this.options.orthoView){let s=Math.min(t/i,e/r);this.renderer.setSize(s*i,s*r)}else this.camera.aspect=t/e,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e)}toggleCamera(){this.options.orthoView=!this.options.orthoView,this.options.orthoView?this.camera=this.orthographicCam:this.camera=this.perspectiveCam,this.resize(),this.renderer.render(this.scene,this.camera)}snapshot(t=!0){let{scene:e,renderer:i,model:r}=this,s=t&&this.camera===this.perspectiveCam;s&&this.toggleCamera(),i.render(e,this.camera);let o=i.domElement.toDataURL();return s&&this.toggleCamera(),o}initThreeHelpers(){let{scene:t,renderer:e,camera:i,world:r}=this,{useAxes:s,useGrid:o,useLights:a,useWorldOutline:c}=this.options,{width:l,height:u,depth:h,minZ:d}=this.world,f={};if(s&&(f.axes=new $.AxesHelper(1.5*l/2),t.add(f.axes)),o&&(f.grid=new $.GridHelper(1.25*l,10),f.grid.rotation.x=$.Math.degToRad(90),f.grid.position.z=d,t.add(f.grid)),a){let p=r.numX;f.directionalLight=new $.DirectionalLight(16777215,1),f.directionalLight.position.set(p,p,p),t.add(f.directionalLight),f.diffuseLight=new $.AmbientLight(4210752),t.add(f.diffuseLight)}if(c){let p=new $.BoxBufferGeometry(l,u,h),y=new $.EdgesGeometry(p);f.outline=new $.LineSegments(y,new $.LineBasicMaterial({color:2155905152})),t.add(f.outline)}this.helpers=f}initMeshes(){this.meshes={},zt(this.options,(t,e)=>{if(t.meshClass&&t.meshClass!=="NullMesh"){let i=Kl[t.meshClass],r=t,s=new i(this,r);this.meshes[e]=s,s.init()}})}setPatchesSmoothing(t=!1){let e=t?$.LinearFilter:$.NearestFilter;this.meshes.patches.mesh.material.map.magFilter=e}idle(t=32){Pa(()=>this.render(),-1,t)}render(){this.renderer.render(this.scene,this.camera),this.ticks++}getSprite(t,e,i=null){return this.spriteSheet.getSprite(t,e,i)}checkViewFcn(t){return oi(t)?()=>t:t}patchesCanvas(){return this.patchesView.ctx.canvas}clearPatches(t){this.patchesView.clear(t),this.meshes.patches.update()}drawPatchesImage(t){let e=this.meshes.patches.options;e.textureOptions={minFilter:$.NearestFilter,magFilter:$.LinearFilter},e.canvas=t,this.meshes.patches.init()}createPatchPixels(t){this.patchesView.createPixels(t);let e=this.patchesView.pixels;this.meshes.patches.update(e,i=>i)}drawPatches(t,e){mn(t)&&(t=gn(t)),this.meshes.patches.update(t,e)}drawTurtles(t,e){mn(t)&&(t=gn(t)),e=this.checkViewFcn(e),this.meshes.turtles.update(t,e)}drawLinks(t,e){mn(t)&&(t=gn(t)),e=this.checkViewFcn(e),this.meshes.links.update(t,e)}},th=Gd;function KE(n){return!tT(n)}function tT(n){return n==="random"||ci(n)||Ir(n)}var Hd=class n extends th{static defaultOptions(){return{patchesMesh:null,turtlesMesh:null,linksMesh:null,patchesColor:"random",patchesSize:1,initPatches:null,turtlesColor:"random",turtlesShape:"dart",turtlesSize:1,linksColor:"random",linksWidth:1,patchesMap:"DarkGray",turtlesMap:"Basic16",lastClearColor:null,lastImage:null}}constructor(t,e={},i={}){e.drawOptions&&(i=e.drawOptions,delete e.drawOptions),i=Object.assign(n.defaultOptions(),i),typeof i.turtlesMap=="string"&&(i.turtlesMap=qi[i.turtlesMap]),typeof i.patchesMap=="string"&&(i.patchesMap=qi[i.patchesMap]);let{patches:r,turtles:s,links:o}=Object.assign(th.defaultOptions(),e),a={patches:r,turtles:s,links:o};for(let c of["patches","turtles","links"]){let l=c+"Mesh";if(i[l]){let d=i[l];a[c]=typeof d=="string"?{meshClass:d}:d}let u=c+"Color";KE(i[u])&&(i[u]=ve.toTypedColor(i[u]),a[c].color=i[u]);let h=c+"Size";typeof i[h]=="number"&&(a[c].size=i[h])}if(Object.assign(e,a),super(t.world,e),console.log("viewOptions",e),console.log("drawOptions",i),console.log("meshes",a),this.meshName("patches")==="PatchesMesh")if(i.initPatches){let c=i.initPatches(t,this);this.createPatchPixels(l=>c[l])}else i.patchesColor==="random"&&this.createPatchPixels(c=>i.patchesMap.randomColor());this.checkParams(i),Object.assign(this,{model:t,view:this,drawOptions:i})}checkParams(t){let e=Object.keys(t),i=n.defaultOptions();e.forEach(r=>{if(i[r]===void 0)throw console.log("Legal ThreeDraw parameters",Object.keys(n.defaultOptions())),Error("Unknown ThreeDraw parameter: "+r)})}getMesh(t){return this.meshes[t]}meshName(t){return this.meshes[t].name}getColor(t){let e=t.agentSet.name,i=e+"Color",r=e==="patches"?this.drawOptions.patchesMap:this.drawOptions.turtlesMap,s=this.drawOptions[i];return s==="random"?r.atIndex(t.id):typeof s=="function"?ve.toTypedColor(s(t)):ve.toTypedColor(s)}draw(){let{patchesColor:t,patchesShape:e,patchesSize:i,initPatches:r,turtlesColor:s,turtlesShape:o,turtlesSize:a,linksColor:c,linksWidth:l,patchesMap:u,turtlesMap:h,lastClearColor:d}=this.drawOptions,{model:f,view:p}=this,y=(m,b,v)=>b==="random"?v.atIndex(m.id):typeof b=="function"?ve.toTypedColor(b(m)):ve.toTypedColor(b),x=(m,b)=>typeof b=="function"?b(m):b,g=(m,b)=>typeof b=="function"?b(m):b;this.meshName("patches")==="PatchesMesh"?t==="random"||r||(typeof t=="function"?p.drawPatches(f.patches,m=>t(m)):ci(t)?t!==lastImage&&(p.drawPatchesImage(t),lastImage=t):t!==d&&(this.drawOptions.lastClearColor=t,p.clearPatches(t))):p.drawPatches(f.patches,m=>({shape:x(m,e),color:y(m,t,u),size:g(m,i)})),p.drawLinks(f.links,m=>({color:y(m,c,h),width:l})),p.drawTurtles(f.turtles,m=>({shape:x(m,o),color:y(m,s,h),size:g(m,a)})),p.render()}},eT=Hd;var ks=function(){var n=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(u){u.preventDefault(),i(++n%t.children.length)},!1);function e(u){return t.appendChild(u.dom),u}function i(u){for(var h=0;h<t.children.length;h++)t.children[h].style.display=h===u?"block":"none";n=u}var r=(performance||Date).now(),s=r,o=0,a=e(new ks.Panel("FPS","#0ff","#002")),c=e(new ks.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var l=e(new ks.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:e,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){o++;var u=(performance||Date).now();if(c.update(u-r,200),u>=s+1e3&&(a.update(o*1e3/(u-s),100),s=u,o=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){r=this.end()},domElement:t,setMode:i}};ks.Panel=function(n,t,e){var i=1/0,r=0,s=Math.round,o=s(window.devicePixelRatio||1),a=80*o,c=48*o,l=3*o,u=2*o,h=3*o,d=15*o,f=74*o,p=30*o,y=document.createElement("canvas");y.width=a,y.height=c,y.style.cssText="width:80px;height:48px";var x=y.getContext("2d");return x.font="bold "+9*o+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=e,x.fillRect(0,0,a,c),x.fillStyle=t,x.fillText(n,l,u),x.fillRect(h,d,f,p),x.fillStyle=e,x.globalAlpha=.9,x.fillRect(h,d,f,p),{dom:y,update:function(g,m){i=Math.min(i,g),r=Math.max(r,g),x.fillStyle=e,x.globalAlpha=1,x.fillRect(0,0,a,d),x.fillStyle=t,x.fillText(s(g)+" "+n+" ("+s(i)+"-"+s(r)+")",l,u),x.drawImage(y,h+o,d,f-o,p,h,d,f-o,p),x.fillRect(h+f-o,d,o,p),x.fillStyle=e,x.globalAlpha=.9,x.fillRect(h+f-o,d,o,s((1-g/m)*p))}}};var Vd=class{constructor(t,e=-1,i=30){Object.assign(this,{fcn:t,steps:e,fps:i,ticks:0}),this.stats=null,this.timeoutID=null,this.idle=null,this.idleFps=null,this.idleID=null,this.start()}start(){return this.clearIDs(),this.timeoutID=setInterval(()=>this.step(),1e3/this.fps),this}stop(){return this.clearIDs(),this.idle&&(this.idleID=setInterval(()=>this.idle(),1e3/this.idleFps)),this}step(){return this.ticks===this.steps?this.stop():(this.fcn(),this.ticks++,this.stats&&this.stats.update(),this)}clearIDs(){this.timeoutID&&(this.timeoutID=clearInterval(this.timeoutID)),this.idleID&&(this.idleID=clearInterval(this.idleID))}isRunning(){return this.timeoutID!=null}startStats(t="top:0px;left:0px",e=document.body){this.stats&&this.stopStats();let i=new ks,r=typeof e=="string"?document.getElementById(e):e;return r!=document.body&&(r.style.position="relative"),r.appendChild(i.dom),i.dom.style.cssText=t,i.dom.style.position="absolute",this.stats=i,this}stopStats(){let t=this.stats;return t&&t.dom&&t.dom.parentNode?t.dom.parentNode.removeChild(t.dom):console.warn("Stats panel not found or already removed."),this.stats=null,this}setFps(t){t<=0&&(console.log("fps must be > 0, using 0.00000001"),t=1e-8),this.reset(this.steps,t)}setSteps(t){this.reset(t,this.fps)}reset(t=this.steps,e=this.fps){let i=this.isRunning();i&&this.stop(),this.steps=t,this.ticks=0,this.fps=e,i&&this.start()}restart(t,e,i=void 0){t.reset(),this.reset(),e.draw(),i&&i.reset()}toggle(){this.isRunning()?this.stop():this.start()}once(){this.stop(),this.step()}setIdle(t,e=4){this.idle=t,this.idleFps=e}},nT=Vd;var Wd=class{events={};on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e=null){this.events[t]&&(e&&(this.events[t]=this.events[t].filter(i=>i!==e)),(this.events[t].length===0||!e)&&delete this.events[t])}emit(t,...e){this.events[t]&&this.events[t].forEach(i=>i(...e))}},iT=Wd;var jd=class{constructor(t,e,i){Object.assign(this,{model:t,view:e,callback:i}),this.canvas=e.canvas,this.world=t.world,this.callMouseHandler=r=>this.mouseHandler(r),this.isRunning=this.mouseDown=!1,this.x=this.y=this.action=null,this.setContinuous(!1)}setContinuous(t=!0){return this.continuous=t,this}start(){return this.canvas.addEventListener("mousedown",this.callMouseHandler),this.continuous&&this.startMouse(),this.isRunning=!0,this}stop(){return this.canvas.removeEventListener("mousedown",this.callMouseHandler),this.stopMouse(),this.isRunning=!1,this}startMouse(){document.body.addEventListener("mouseup",this.callMouseHandler),this.canvas.addEventListener("mousemove",this.callMouseHandler)}stopMouse(){document.body.removeEventListener("mouseup",this.callMouseHandler),this.canvas.removeEventListener("mousemove",this.callMouseHandler)}mouseHandler(t){t.type==="mousedown"&&(this.continuous||this.startMouse(),this.mouseDown=!0),t.type==="mouseup"&&(this.continuous||this.stopMouse(),this.mouseDown=!1),this.action=t.type,t.type==="mousemove"&&this.mouseDown&&(this.action="mousedrag"),this.setXY(t),this.callback(this)}setXY(t){let{canvas:e,world:i}=this,r=i.patchSize(e),s=this.canvas.getBoundingClientRect(),o=t.clientX-s.left,a=t.clientY-s.top,[c,l]=i.pixelXYtoPatchXY(o,a,r);Object.assign(this,{x:c,y:l})}},rT=jd;export{xn as AgentArray,Ke as AgentList,Xi as AgentSet,nT as Animator,ve as Color,qi as ColorMap,Nn as DataSet,iT as Evented,tu as GeoWorld,Ih as Link,Oh as Links,lu as Model,yb as Model3D,rT as Mouse,vn as Object3D,ru as Patch,nu as Patches,oo as PatchesView,sm as RGBADataSet,bu as RGBDataSet,co as Shapes,Cu as SpriteSheet,eT as ThreeDraw,Kl as ThreeMeshes,th as ThreeView,um as TileData,io as Turtle,pu as Turtle3D,ou as Turtles,Pu as TurtlesView,Lb as TwoDraw,Iu as TwoView,Bn as World,Bh as geojson,Va as gis,vp as steg,Fp as turfImports,Nt as util};
