mirror of
https://github.com/samvallad33/vestige.git
synced 2026-07-14 22:52:11 +02:00
* patch(backfill-safety): VESTIGE_BACKFILL_AUTOFIRE gate (default OFF) + bounded promote_memory_backfill
Off-by-default env gate around step-8.5 auto-fire in run_consolidation (decouples
backfill from consolidation cadence). New promote_memory_backfill caps stability at
MIN(stability*1.5, stability+365.0) (the bound retroactive_backfill.rs:300 already
computes but discarded); both backfill entry points use it. Fixes the false 'capped'
comment. Cloud-sync excluded at build (--no-default-features). Pending upstream PR to
samvallad33/vestige. omega-backfill-safety-v2.2.0 off tag v2.2.0 (3bcd4667).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* release: v2.2.1 — Windows embeddings fix + backfill safety + first-run guide
Board-clearing patch release.
Fixes:
- #101 Windows embeddings: release.yml already restores vector-search on the
x86_64-pc-windows-msvc target (merged in #102); this release rebuilds the
Windows binary so users actually get working embeddings.
- #103 Retroactive Salience Backfill safety (from community PR #104, adjusted):
* promote_memory_backfill bounds the stability multiply to
MIN(stability*1.5, stability+365.0) on both auto-fire and manual paths.
* VESTIGE_BACKFILL_AUTOFIRE gate — default ON (preserves the shipped/documented
v2.2.0 behavior), disable with 0/false/off/no. Env value is trimmed.
* Corrected the false "capped" comment and the promote_memory_backfill doc.
* Added 3 tests: +365 cap binds, *1.5 multiply below crossover, gate parsing.
Docs:
- #83 First-Run: new docs/GETTING-STARTED.md + README pointer.
- Consolidated roadmap issues #82,#84-#92 into docs/ROADMAP.md (Tracked Issues).
- Documented VESTIGE_BACKFILL_AUTOFIRE in docs/CONFIGURATION.md.
- CHANGELOG v2.2.1 entry.
Version bumped to 2.2.1 across all manifests + Cargo.lock + dashboard build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Peter Lauzon <inbijiburu@protonmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4118 lines
791 KiB
JavaScript
4118 lines
791 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Ma4NfFrG.js","./Dp1pzeXC.js"])))=>i.map(i=>d[i]);
|
||
var ff=Object.defineProperty;var pf=(r,e,t)=>e in r?ff(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ke=(r,e,t)=>pf(r,typeof e!="symbol"?e+"":e,t);import"./Bzak7iHL.js";import{o as od,a as Ac}from"./TZu9D97Z.js";import{s as Qe,d as Al,i as le,g as L,p as sr,o as Ga,a as ot,b as rr,j as ut,e as xe,h as Ee,n as Or,r as fe,t as Pt,u as ei,c as mf,f as no,m as gf,l as _f}from"./wpu9U-D0.js";import{s as ct,d as Cc,a as Ut}from"./D8mhvFt8.js";import{i as It}from"./DKve45Wd.js";import{e as Pr,i as Wa,a as Rt,r as Br,s as Ns,c as vf}from"./60_R_Vbt.js";import{s as zr}from"./EqHb-9AZ.js";import{b as Cl,a as ph}from"./CnZzd20v.js";import{p as Dr,a as xf,s as yf}from"./ByYB047u.js";import{b as mh}from"./Bxs5UR9-.js";import{b as Rl}from"./g5OnrUYZ.js";import{N as Il}from"./CcUbQ_Wl.js";import{b as Mf}from"./DrafHjYM.js";import{i as bf}from"./BLadwbF7.js";import{_ as Sf}from"./Dp1pzeXC.js";import{I as ps}from"./D7A-gG4Z.js";import{D as wf}from"./CmbJHhgy.js";import{a as ms}from"./CZfHMhLI.js";import{e as Ef}from"./BhIgFntf.js";/**
|
||
* @license
|
||
* Copyright 2010-2024 Three.js Authors
|
||
* SPDX-License-Identifier: MIT
|
||
*/const Rc="172",Xs={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Os={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Tf=0,gh=1,Af=2,sS=3,rS=0,ld=1,Cf=2,Qn=3,Ci=0,fn=1,Bn=2,ii=0,qs=1,Wt=2,_h=3,vh=4,Rf=5,Qi=100,If=101,Pf=102,Df=103,Lf=104,Uf=200,Nf=201,Ff=202,Of=203,Pl=204,Dl=205,Bf=206,zf=207,kf=208,Vf=209,Hf=210,Gf=211,Wf=212,Xf=213,qf=214,Ll=0,Ul=1,Nl=2,Ks=3,Fl=4,Ol=5,Bl=6,zl=7,bo=0,Yf=1,Zf=2,Ti=0,Jf=1,Kf=2,$f=3,cd=4,jf=5,Qf=6,ep=7,xh="attached",tp="detached",Ic=300,Ri=301,os=302,io=303,so=304,qr=306,ro=1e3,Nn=1001,ao=1002,Qt=1003,hd=1004,aS=1004,Cr=1005,oS=1005,Vt=1006,Xa=1007,lS=1007,ni=1008,cS=1008,li=1009,ud=1010,dd=1011,kr=1012,Pc=1013,Ii=1014,Mn=1015,si=1016,Dc=1017,Lc=1018,$s=1020,fd=35902,pd=1021,md=1022,dn=1023,gd=1024,_d=1025,Ys=1026,js=1027,Uc=1028,So=1029,vd=1030,Nc=1031,hS=1032,Fc=1033,qa=33776,Ya=33777,Za=33778,Ja=33779,kl=35840,Vl=35841,Hl=35842,Gl=35843,Wl=36196,Xl=37492,ql=37496,Yl=37808,Zl=37809,Jl=37810,Kl=37811,$l=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,Ka=36492,oc=36494,lc=36495,xd=36283,cc=36284,hc=36285,uc=36286,np=2200,ip=2201,sp=2202,oo=2300,dc=2301,Fo=2302,Bs=2400,zs=2401,lo=2402,Oc=2500,yd=2501,uS=0,dS=1,fS=2,rp=3200,ap=3201,pS=3202,mS=3203,cs=0,op=1,wi="",xn="srgb",Qs="srgb-linear",co="linear",vt="srgb",gS=0,gs=7680,_S=7681,vS=7682,xS=7683,yS=34055,MS=34056,bS=5386,SS=512,wS=513,ES=514,TS=515,AS=516,CS=517,RS=518,yh=519,lp=512,cp=513,hp=514,Md=515,up=516,dp=517,fp=518,pp=519,ho=35044,IS=35048,PS=35040,DS=35045,LS=35049,US=35041,NS=35046,FS=35050,OS=35042,BS="100",Mh="300 es",zn=2e3,uo=2001;class ci{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const Jt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let bh=1234567;const ss=Math.PI/180,er=180/Math.PI;function bn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Jt[r&255]+Jt[r>>8&255]+Jt[r>>16&255]+Jt[r>>24&255]+"-"+Jt[e&255]+Jt[e>>8&255]+"-"+Jt[e>>16&15|64]+Jt[e>>24&255]+"-"+Jt[t&63|128]+Jt[t>>8&255]+"-"+Jt[t>>16&255]+Jt[t>>24&255]+Jt[n&255]+Jt[n>>8&255]+Jt[n>>16&255]+Jt[n>>24&255]).toLowerCase()}function et(r,e,t){return Math.max(e,Math.min(t,r))}function Bc(r,e){return(r%e+e)%e}function mp(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function gp(r,e,t){return r!==e?(t-r)/(e-r):0}function Lr(r,e,t){return(1-t)*r+t*e}function _p(r,e,t,n){return Lr(r,e,1-Math.exp(-t*n))}function vp(r,e=1){return e-Math.abs(Bc(r,e*2)-e)}function xp(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function yp(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Mp(r,e){return r+Math.floor(Math.random()*(e-r+1))}function bp(r,e){return r+Math.random()*(e-r)}function Sp(r){return r*(.5-Math.random())}function wp(r){r!==void 0&&(bh=r);let e=bh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Ep(r){return r*ss}function Tp(r){return r*er}function Ap(r){return(r&r-1)===0&&r!==0}function Cp(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Rp(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Ip(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),f=a((e-n)/2),d=s((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":r.set(o*h,l*u,l*f,o*c);break;case"YZY":r.set(l*f,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*f,o*h,o*c);break;case"XZX":r.set(o*h,l*p,l*d,o*c);break;case"YXY":r.set(l*d,o*h,l*p,o*c);break;case"ZYZ":r.set(l*p,l*d,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function sn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function nt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const bd={DEG2RAD:ss,RAD2DEG:er,generateUUID:bn,clamp:et,euclideanModulo:Bc,mapLinear:mp,inverseLerp:gp,lerp:Lr,damp:_p,pingpong:vp,smoothstep:xp,smootherstep:yp,randInt:Mp,randFloat:bp,randFloatSpread:Sp,seededRandom:wp,degToRad:Ep,radToDeg:Tp,isPowerOfTwo:Ap,ceilPowerOfTwo:Cp,floorPowerOfTwo:Rp,setQuaternionFromProperEuler:Ip,normalize:nt,denormalize:sn};class j{constructor(e=0,t=0){j.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(et(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class tt{constructor(e,t,n,i,s,a,o,l,c){tt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c)}set(e,t,n,i,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],f=n[2],d=n[5],p=n[8],_=i[0],g=i[3],m=i[6],y=i[1],v=i[4],x=i[7],w=i[2],T=i[5],C=i[8];return s[0]=a*_+o*y+l*w,s[3]=a*g+o*v+l*T,s[6]=a*m+o*x+l*C,s[1]=c*_+h*y+u*w,s[4]=c*g+h*v+u*T,s[7]=c*m+h*x+u*C,s[2]=f*_+d*y+p*w,s[5]=f*g+d*v+p*T,s[8]=f*m+d*x+p*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,f=o*l-h*s,d=c*s-a*l,p=t*u+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=u*_,e[1]=(i*c-h*n)*_,e[2]=(o*n-i*a)*_,e[3]=f*_,e[4]=(h*t-i*l)*_,e[5]=(i*s-o*t)*_,e[6]=d*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*s)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Oo.makeScale(e,t)),this}rotate(e){return this.premultiply(Oo.makeRotation(-e)),this}translate(e,t){return this.premultiply(Oo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Oo=new tt;function Sd(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const Pp={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ks(r,e){return new Pp[r](e)}function Vr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Dp(){const r=Vr("canvas");return r.style.display="block",r}const Sh={};function Fs(r){r in Sh||(Sh[r]=!0,console.warn(r))}function Lp(r,e,t){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Up(r){const e=r.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Np(r){const e=r.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const wh=new tt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eh=new tt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fp(){const r={enabled:!0,workingColorSpace:Qs,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===vt&&(i.r=ri(i.r),i.g=ri(i.g),i.b=ri(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===vt&&(i.r=Zs(i.r),i.g=Zs(i.g),i.b=Zs(i.b))),i},fromWorkingColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},toWorkingColorSpace:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===wi?co:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[Qs]:{primaries:e,whitePoint:n,transfer:co,toXYZ:wh,fromXYZ:Eh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:xn},outputColorSpaceConfig:{drawingBufferColorSpace:xn}},[xn]:{primaries:e,whitePoint:n,transfer:vt,toXYZ:wh,fromXYZ:Eh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:xn}}}),r}const ht=Fp();function ri(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Zs(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let _s;class Op{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{_s===void 0&&(_s=Vr("canvas")),_s.width=e.width,_s.height=e.height;const n=_s.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=_s}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Vr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=ri(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ri(t[n]/255)*255):t[n]=ri(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Bp=0;class Vs{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Bp++}),this.uuid=bn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Bo(i[a].image)):s.push(Bo(i[a]))}else s=Bo(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Bo(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Op.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let zp=0;class Et extends ci{constructor(e=Et.DEFAULT_IMAGE,t=Et.DEFAULT_MAPPING,n=Nn,i=Nn,s=Vt,a=ni,o=dn,l=li,c=Et.DEFAULT_ANISOTROPY,h=wi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zp++}),this.uuid=bn(),this.name="",this.source=new Vs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new j(0,0),this.repeat=new j(1,1),this.center=new j(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ic)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ro:e.x=e.x-Math.floor(e.x);break;case Nn:e.x=e.x<0?0:1;break;case ao:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ro:e.y=e.y-Math.floor(e.y);break;case Nn:e.y=e.y<0?0:1;break;case ao:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Et.DEFAULT_IMAGE=null;Et.DEFAULT_MAPPING=Ic;Et.DEFAULT_ANISOTROPY=1;class pt{constructor(e=0,t=0,n=0,i=1){pt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const l=e.elements,c=l[0],h=l[4],u=l[8],f=l[1],d=l[5],p=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-f)<.01&&Math.abs(u-_)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+_)<.1&&Math.abs(p+g)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,x=(d+1)/2,w=(m+1)/2,T=(h+f)/4,C=(u+_)/4,P=(p+g)/4;return v>x&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=T/n,s=C/n):x>w?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=T/i,s=P/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=C/s,i=P/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(u-_)*(u-_)+(f-h)*(f-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-_)/y,this.z=(f-h)/y,this.w=Math.acos((c+d+m-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this.z=et(this.z,e.z,t.z),this.w=et(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this.z=et(this.z,e,t),this.w=et(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class zc extends ci{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Vt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Et(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const t=Object.assign({},e.texture.image);return this.texture.source=new Vs(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Sn extends zc{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class wo extends Et{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zS extends Sn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new wo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class kc extends Et{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class kS extends Sn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new kc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class rn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3];const f=s[a+0],d=s[a+1],p=s[a+2],_=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=f,e[t+1]=d,e[t+2]=p,e[t+3]=_;return}if(u!==_||l!==f||c!==d||h!==p){let g=1-o;const m=l*f+c*d+h*p+u*_,y=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){const w=Math.sqrt(v),T=Math.atan2(w,m*y);g=Math.sin(g*T)/w,o=Math.sin(o*T)/w}const x=o*y;if(l=l*g+f*x,c=c*g+d*x,h=h*g+p*x,u=u*g+_*x,g===1-o){const w=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=w,c*=w,h*=w,u*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],f=s[a+1],d=s[a+2],p=s[a+3];return e[t]=o*p+h*u+l*d-c*f,e[t+1]=l*p+h*f+c*u-o*d,e[t+2]=c*p+h*d+o*f-l*u,e[t+3]=h*p-o*u-l*f-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),f=l(n/2),d=l(i/2),p=l(s/2);switch(a){case"XYZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"YXZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"ZXY":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"ZYX":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"YZX":this._x=f*h*u+c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u-f*d*p;break;case"XZY":this._x=f*h*u-c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],f=n+o+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-l)*d,this._y=(s-c)*d,this._z=(a-i)*d}else if(n>o&&n>u){const d=2*Math.sqrt(1+n-o-u);this._w=(h-l)/d,this._x=.25*d,this._y=(i+a)/d,this._z=(s+c)/d}else if(o>u){const d=2*Math.sqrt(1+o-n-u);this._w=(s-c)/d,this._x=(i+a)/d,this._y=.25*d,this._z=(l+h)/d}else{const d=2*Math.sqrt(1+u-n-o);this._w=(a-i)/d,this._x=(s+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(et(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const d=1-t;return this._w=d*a+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=a*u+this._w*f,this._x=n*u+this._x*f,this._y=i*u+this._y*f,this._z=s*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class A{constructor(e=0,t=0,n=0){A.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Th.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Th.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),h=2*(o*t-s*i),u=2*(s*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=i+l*u+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this.z=et(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this.z=et(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return zo.copy(this).projectOnVector(e),this.sub(zo)}reflect(e){return this.sub(zo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(et(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const zo=new A,Th=new rn;class pn{constructor(e=new A(1/0,1/0,1/0),t=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Dn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Dn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Dn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Dn):Dn.fromBufferAttribute(s,a),Dn.applyMatrix4(e.matrixWorld),this.expandByPoint(Dn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Kr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Kr.copy(n.boundingBox)),Kr.applyMatrix4(e.matrixWorld),this.union(Kr)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mr),$r.subVectors(this.max,mr),vs.subVectors(e.a,mr),xs.subVectors(e.b,mr),ys.subVectors(e.c,mr),mi.subVectors(xs,vs),gi.subVectors(ys,xs),Fi.subVectors(vs,ys);let t=[0,-mi.z,mi.y,0,-gi.z,gi.y,0,-Fi.z,Fi.y,mi.z,0,-mi.x,gi.z,0,-gi.x,Fi.z,0,-Fi.x,-mi.y,mi.x,0,-gi.y,gi.x,0,-Fi.y,Fi.x,0];return!ko(t,vs,xs,ys,$r)||(t=[1,0,0,0,1,0,0,0,1],!ko(t,vs,xs,ys,$r))?!1:(jr.crossVectors(mi,gi),t=[jr.x,jr.y,jr.z],ko(t,vs,xs,ys,$r))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const qn=[new A,new A,new A,new A,new A,new A,new A,new A],Dn=new A,Kr=new pn,vs=new A,xs=new A,ys=new A,mi=new A,gi=new A,Fi=new A,mr=new A,$r=new A,jr=new A,Oi=new A;function ko(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){Oi.fromArray(r,s);const o=i.x*Math.abs(Oi.x)+i.y*Math.abs(Oi.y)+i.z*Math.abs(Oi.z),l=e.dot(Oi),c=t.dot(Oi),h=n.dot(Oi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const kp=new pn,gr=new A,Vo=new A;class an{constructor(e=new A,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):kp.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;gr.subVectors(e,this.center);const t=gr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(gr,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Vo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gr.copy(e.center).add(Vo)),this.expandByPoint(gr.copy(e.center).sub(Vo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Yn=new A,Ho=new A,Qr=new A,_i=new A,Go=new A,ea=new A,Wo=new A;class ar{constructor(e=new A,t=new A(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Yn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yn.copy(this.origin).addScaledVector(this.direction,t),Yn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ho.copy(e).add(t).multiplyScalar(.5),Qr.copy(t).sub(e).normalize(),_i.copy(this.origin).sub(Ho);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Qr),o=_i.dot(this.direction),l=-_i.dot(Qr),c=_i.lengthSq(),h=Math.abs(1-a*a);let u,f,d,p;if(h>0)if(u=a*l-o,f=a*o-l,p=s*h,u>=0)if(f>=-p)if(f<=p){const _=1/h;u*=_,f*=_,d=u*(u+a*f+2*o)+f*(a*u+f+2*l)+c}else f=s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f=-s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f<=-p?(u=Math.max(0,-(-a*s+o)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c):f<=p?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+c):(u=Math.max(0,-(a*s+o)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c);else f=a>0?-s:s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Ho).addScaledVector(Qr,f),d}intersectSphere(e,t){Yn.subVectors(e.center,this.origin);const n=Yn.dot(this.direction),i=Yn.dot(Yn)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c),h>=0?(s=(e.min.y-f.y)*h,a=(e.max.y-f.y)*h):(s=(e.max.y-f.y)*h,a=(e.min.y-f.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(o=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Yn)!==null}intersectTriangle(e,t,n,i,s){Go.subVectors(t,e),ea.subVectors(n,e),Wo.crossVectors(Go,ea);let a=this.direction.dot(Wo),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;_i.subVectors(this.origin,e);const l=o*this.direction.dot(ea.crossVectors(_i,ea));if(l<0)return null;const c=o*this.direction.dot(Go.cross(_i));if(c<0||l+c>a)return null;const h=-o*_i.dot(Wo);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ze{constructor(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){Ze.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g)}set(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=a,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=p,m[11]=_,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ze().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ms.setFromMatrixColumn(e,0).length(),s=1/Ms.setFromMatrixColumn(e,1).length(),a=1/Ms.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=d+p*c,t[5]=f-_*c,t[9]=-o*l,t[2]=_-f*c,t[6]=p+d*c,t[10]=a*l}else if(e.order==="YXZ"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f+_*o,t[4]=p*o-d,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=d*o-p,t[6]=_+f*o,t[10]=a*l}else if(e.order==="ZXY"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f-_*o,t[4]=-a*u,t[8]=p+d*o,t[1]=d+p*o,t[5]=a*h,t[9]=_-f*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=p*c-d,t[8]=f*c+_,t[1]=l*u,t[5]=_*c+f,t[9]=d*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=_-f*u,t[8]=p*u+d,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=d*u+p,t[10]=f-_*u}else if(e.order==="XZY"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=f*u+_,t[5]=a*h,t[9]=d*u-p,t[2]=p*u-d,t[6]=o*h,t[10]=_*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Vp,e,Hp)}lookAt(e,t,n){const i=this.elements;return _n.subVectors(e,t),_n.lengthSq()===0&&(_n.z=1),_n.normalize(),vi.crossVectors(n,_n),vi.lengthSq()===0&&(Math.abs(n.z)===1?_n.x+=1e-4:_n.z+=1e-4,_n.normalize(),vi.crossVectors(n,_n)),vi.normalize(),ta.crossVectors(_n,vi),i[0]=vi.x,i[4]=ta.x,i[8]=_n.x,i[1]=vi.y,i[5]=ta.y,i[9]=_n.y,i[2]=vi.z,i[6]=ta.z,i[10]=_n.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],f=n[9],d=n[13],p=n[2],_=n[6],g=n[10],m=n[14],y=n[3],v=n[7],x=n[11],w=n[15],T=i[0],C=i[4],P=i[8],S=i[12],M=i[1],D=i[5],G=i[9],F=i[13],V=i[2],J=i[6],q=i[10],se=i[14],Z=i[3],_e=i[7],be=i[11],Re=i[15];return s[0]=a*T+o*M+l*V+c*Z,s[4]=a*C+o*D+l*J+c*_e,s[8]=a*P+o*G+l*q+c*be,s[12]=a*S+o*F+l*se+c*Re,s[1]=h*T+u*M+f*V+d*Z,s[5]=h*C+u*D+f*J+d*_e,s[9]=h*P+u*G+f*q+d*be,s[13]=h*S+u*F+f*se+d*Re,s[2]=p*T+_*M+g*V+m*Z,s[6]=p*C+_*D+g*J+m*_e,s[10]=p*P+_*G+g*q+m*be,s[14]=p*S+_*F+g*se+m*Re,s[3]=y*T+v*M+x*V+w*Z,s[7]=y*C+v*D+x*J+w*_e,s[11]=y*P+v*G+x*q+w*be,s[15]=y*S+v*F+x*se+w*Re,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],f=e[10],d=e[14],p=e[3],_=e[7],g=e[11],m=e[15];return p*(+s*l*u-i*c*u-s*o*f+n*c*f+i*o*d-n*l*d)+_*(+t*l*d-t*c*f+s*a*f-i*a*d+i*c*h-s*l*h)+g*(+t*c*u-t*o*d-s*a*u+n*a*d+s*o*h-n*c*h)+m*(-i*o*h-t*l*u+t*o*f+i*a*u-n*a*f+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],_=e[13],g=e[14],m=e[15],y=u*g*c-_*f*c+_*l*d-o*g*d-u*l*m+o*f*m,v=p*f*c-h*g*c-p*l*d+a*g*d+h*l*m-a*f*m,x=h*_*c-p*u*c+p*o*d-a*_*d-h*o*m+a*u*m,w=p*u*l-h*_*l-p*o*f+a*_*f+h*o*g-a*u*g,T=t*y+n*v+i*x+s*w;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/T;return e[0]=y*C,e[1]=(_*f*s-u*g*s-_*i*d+n*g*d+u*i*m-n*f*m)*C,e[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*m+n*l*m)*C,e[3]=(u*l*s-o*f*s-u*i*c+n*f*c+o*i*d-n*l*d)*C,e[4]=v*C,e[5]=(h*g*s-p*f*s+p*i*d-t*g*d-h*i*m+t*f*m)*C,e[6]=(p*l*s-a*g*s-p*i*c+t*g*c+a*i*m-t*l*m)*C,e[7]=(a*f*s-h*l*s+h*i*c-t*f*c-a*i*d+t*l*d)*C,e[8]=x*C,e[9]=(p*u*s-h*_*s-p*n*d+t*_*d+h*n*m-t*u*m)*C,e[10]=(a*_*s-p*o*s+p*n*c-t*_*c-a*n*m+t*o*m)*C,e[11]=(h*o*s-a*u*s-h*n*c+t*u*c+a*n*d-t*o*d)*C,e[12]=w*C,e[13]=(h*_*i-p*u*i+p*n*f-t*_*f-h*n*g+t*u*g)*C,e[14]=(p*o*i-a*_*i-p*n*l+t*_*l+a*n*g-t*o*g)*C,e[15]=(a*u*i-h*o*i+h*n*l-t*u*l-a*n*f+t*o*f)*C,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,f=s*c,d=s*h,p=s*u,_=a*h,g=a*u,m=o*u,y=l*c,v=l*h,x=l*u,w=n.x,T=n.y,C=n.z;return i[0]=(1-(_+m))*w,i[1]=(d+x)*w,i[2]=(p-v)*w,i[3]=0,i[4]=(d-x)*T,i[5]=(1-(f+m))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+v)*C,i[9]=(g-y)*C,i[10]=(1-(f+_))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ms.set(i[0],i[1],i[2]).length();const a=Ms.set(i[4],i[5],i[6]).length(),o=Ms.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ln.copy(this);const c=1/s,h=1/a,u=1/o;return Ln.elements[0]*=c,Ln.elements[1]*=c,Ln.elements[2]*=c,Ln.elements[4]*=h,Ln.elements[5]*=h,Ln.elements[6]*=h,Ln.elements[8]*=u,Ln.elements[9]*=u,Ln.elements[10]*=u,t.setFromRotationMatrix(Ln),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=zn){const l=this.elements,c=2*s/(t-e),h=2*s/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let d,p;if(o===zn)d=-(a+s)/(a-s),p=-2*a*s/(a-s);else if(o===uo)d=-a/(a-s),p=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=d,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=zn){const l=this.elements,c=1/(t-e),h=1/(n-i),u=1/(a-s),f=(t+e)*c,d=(n+i)*h;let p,_;if(o===zn)p=(a+s)*u,_=-2*u;else if(o===uo)p=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-d,l[2]=0,l[6]=0,l[10]=_,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ms=new A,Ln=new Ze,Vp=new A(0,0,0),Hp=new A(1,1,1),vi=new A,ta=new A,_n=new A,Ah=new Ze,Ch=new rn;class In{constructor(e=0,t=0,n=0,i=In.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(et(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-et(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(et(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-et(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(et(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-et(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ah.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ah,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ch.setFromEuler(this),this.setFromQuaternion(Ch,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}In.DEFAULT_ORDER="XYZ";class Vc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Gp=0;const Rh=new A,bs=new rn,Zn=new Ze,na=new A,_r=new A,Wp=new A,Xp=new rn,Ih=new A(1,0,0),Ph=new A(0,1,0),Dh=new A(0,0,1),Lh={type:"added"},qp={type:"removed"},Ss={type:"childadded",child:null},Xo={type:"childremoved",child:null};class mt extends ci{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gp++}),this.uuid=bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=mt.DEFAULT_UP.clone();const e=new A,t=new In,n=new rn,i=new A(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ze},normalMatrix:{value:new tt}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=mt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Vc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return bs.setFromAxisAngle(e,t),this.quaternion.multiply(bs),this}rotateOnWorldAxis(e,t){return bs.setFromAxisAngle(e,t),this.quaternion.premultiply(bs),this}rotateX(e){return this.rotateOnAxis(Ih,e)}rotateY(e){return this.rotateOnAxis(Ph,e)}rotateZ(e){return this.rotateOnAxis(Dh,e)}translateOnAxis(e,t){return Rh.copy(e).applyQuaternion(this.quaternion),this.position.add(Rh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ih,e)}translateY(e){return this.translateOnAxis(Ph,e)}translateZ(e){return this.translateOnAxis(Dh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?na.copy(e):na.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),_r.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(_r,na,this.up):Zn.lookAt(na,_r,this.up),this.quaternion.setFromRotationMatrix(Zn),i&&(Zn.extractRotation(i.matrixWorld),bs.setFromRotationMatrix(Zn),this.quaternion.premultiply(bs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Lh),Ss.child=e,this.dispatchEvent(Ss),Ss.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(qp),Xo.child=e,this.dispatchEvent(Xo),Xo.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Zn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lh),Ss.child=e,this.dispatchEvent(Ss),Ss.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_r,e,Wp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_r,Xp,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const 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),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.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(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),f=a(e.skeletons),d=a(e.animations),p=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}mt.DEFAULT_UP=new A(0,1,0);mt.DEFAULT_MATRIX_AUTO_UPDATE=!0;mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Un=new A,Jn=new A,qo=new A,Kn=new A,ws=new A,Es=new A,Uh=new A,Yo=new A,Zo=new A,Jo=new A,Ko=new pt,$o=new pt,jo=new pt;class yn{constructor(e=new A,t=new A,n=new A){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Un.subVectors(e,t),i.cross(Un);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Un.subVectors(i,t),Jn.subVectors(n,t),qo.subVectors(e,t);const a=Un.dot(Un),o=Un.dot(Jn),l=Un.dot(qo),c=Jn.dot(Jn),h=Jn.dot(qo),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const f=1/u,d=(c*l-o*h)*f,p=(a*h-o*l)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Kn)===null?!1:Kn.x>=0&&Kn.y>=0&&Kn.x+Kn.y<=1}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,Kn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Kn.x),l.addScaledVector(a,Kn.y),l.addScaledVector(o,Kn.z),l)}static getInterpolatedAttribute(e,t,n,i,s,a){return Ko.setScalar(0),$o.setScalar(0),jo.setScalar(0),Ko.fromBufferAttribute(e,t),$o.fromBufferAttribute(e,n),jo.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(Ko,s.x),a.addScaledVector($o,s.y),a.addScaledVector(jo,s.z),a}static isFrontFacing(e,t,n,i){return Un.subVectors(n,t),Jn.subVectors(e,t),Un.cross(Jn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Un.subVectors(this.c,this.b),Jn.subVectors(this.a,this.b),Un.cross(Jn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return yn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return yn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;ws.subVectors(i,n),Es.subVectors(s,n),Yo.subVectors(e,n);const l=ws.dot(Yo),c=Es.dot(Yo);if(l<=0&&c<=0)return t.copy(n);Zo.subVectors(e,i);const h=ws.dot(Zo),u=Es.dot(Zo);if(h>=0&&u<=h)return t.copy(i);const f=l*u-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(ws,a);Jo.subVectors(e,s);const d=ws.dot(Jo),p=Es.dot(Jo);if(p>=0&&d<=p)return t.copy(s);const _=d*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Es,o);const g=h*p-d*u;if(g<=0&&u-h>=0&&d-p>=0)return Uh.subVectors(s,i),o=(u-h)/(u-h+(d-p)),t.copy(i).addScaledVector(Uh,o);const m=1/(g+_+f);return a=_*m,o=f*m,t.copy(n).addScaledVector(ws,a).addScaledVector(Es,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wd={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},xi={h:0,s:0,l:0},ia={h:0,s:0,l:0};function Qo(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class ne{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=xn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ht.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=ht.workingColorSpace){return this.r=e,this.g=t,this.b=n,ht.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=ht.workingColorSpace){if(e=Bc(e,1),t=et(t,0,1),n=et(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Qo(a,s,e+1/3),this.g=Qo(a,s,e),this.b=Qo(a,s,e-1/3)}return ht.toWorkingColorSpace(this,i),this}setStyle(e,t=xn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=xn){const n=wd[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ri(e.r),this.g=ri(e.g),this.b=ri(e.b),this}copyLinearToSRGB(e){return this.r=Zs(e.r),this.g=Zs(e.g),this.b=Zs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=xn){return ht.fromWorkingColorSpace(Kt.copy(this),e),Math.round(et(Kt.r*255,0,255))*65536+Math.round(et(Kt.g*255,0,255))*256+Math.round(et(Kt.b*255,0,255))}getHexString(e=xn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ht.workingColorSpace){ht.fromWorkingColorSpace(Kt.copy(this),t);const n=Kt.r,i=Kt.g,s=Kt.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=ht.workingColorSpace){return ht.fromWorkingColorSpace(Kt.copy(this),t),e.r=Kt.r,e.g=Kt.g,e.b=Kt.b,e}getStyle(e=xn){ht.fromWorkingColorSpace(Kt.copy(this),e);const t=Kt.r,n=Kt.g,i=Kt.b;return e!==xn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(xi),this.setHSL(xi.h+e,xi.s+t,xi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(xi),e.getHSL(ia);const n=Lr(xi.h,ia.h,t),i=Lr(xi.s,ia.s,t),s=Lr(xi.l,ia.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Kt=new ne;ne.NAMES=wd;let Yp=0;class on extends ci{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yp++}),this.uuid=bn(),this.name="",this.type="Material",this.blending=qs,this.side=Ci,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Pl,this.blendDst=Dl,this.blendEquation=Qi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ne(0,0,0),this.blendAlpha=0,this.depthFunc=Ks,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gs,this.stencilZFail=gs,this.stencilZPass=gs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==qs&&(n.blending=this.blending),this.side!==Ci&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Pl&&(n.blendSrc=this.blendSrc),this.blendDst!==Dl&&(n.blendDst=this.blendDst),this.blendEquation!==Qi&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ks&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==gs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==gs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class kn extends on{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.combine=bo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ti=Zp();function Zp(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function un(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=et(r,-65504,65504),ti.floatView[0]=r;const e=ti.uint32View[0],t=e>>23&511;return ti.baseTable[t]+((e&8388607)>>ti.shiftTable[t])}function Rr(r){const e=r>>10;return ti.uint32View[0]=ti.mantissaTable[ti.offsetTable[e]+(r&1023)]+ti.exponentTable[e],ti.floatView[0]}const VS={toHalfFloat:un,fromHalfFloat:Rr},Lt=new A,sa=new j;class rt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ho,this.updateRanges=[],this.gpuType=Mn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)sa.fromBufferAttribute(this,t),sa.applyMatrix3(e),this.setXY(t,sa.x,sa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix3(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix4(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyNormalMatrix(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.transformDirection(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=sn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array),s=nt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ho&&(e.usage=this.usage),e}}class HS extends rt{constructor(e,t,n){super(new Int8Array(e),t,n)}}class GS extends rt{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class WS extends rt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class XS extends rt{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Ed extends rt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class qS extends rt{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Td extends rt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class YS extends rt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Rr(this.array[e*this.itemSize]);return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=un(t),this}getY(e){let t=Rr(this.array[e*this.itemSize+1]);return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=un(t),this}getZ(e){let t=Rr(this.array[e*this.itemSize+2]);return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=un(t),this}getW(e){let t=Rr(this.array[e*this.itemSize+3]);return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=un(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(n),this.array[e+2]=un(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array),s=nt(s,this.array)),this.array[e+0]=un(t),this.array[e+1]=un(n),this.array[e+2]=un(i),this.array[e+3]=un(s),this}}class Fe extends rt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Jp=0;const Rn=new Ze,el=new mt,Ts=new A,vn=new pn,vr=new pn,zt=new A;class qe extends ci{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jp++}),this.uuid=bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Sd(e)?Td:Ed)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new tt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Rn.makeRotationFromQuaternion(e),this.applyMatrix4(Rn),this}rotateX(e){return Rn.makeRotationX(e),this.applyMatrix4(Rn),this}rotateY(e){return Rn.makeRotationY(e),this.applyMatrix4(Rn),this}rotateZ(e){return Rn.makeRotationZ(e),this.applyMatrix4(Rn),this}translate(e,t,n){return Rn.makeTranslation(e,t,n),this.applyMatrix4(Rn),this}scale(e,t,n){return Rn.makeScale(e,t,n),this.applyMatrix4(Rn),this}lookAt(e){return el.lookAt(e),el.updateMatrix(),this.applyMatrix4(el.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Fe(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];vn.setFromBufferAttribute(s),this.morphTargetsRelative?(zt.addVectors(this.boundingBox.min,vn.min),this.boundingBox.expandByPoint(zt),zt.addVectors(this.boundingBox.max,vn.max),this.boundingBox.expandByPoint(zt)):(this.boundingBox.expandByPoint(vn.min),this.boundingBox.expandByPoint(vn.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(){this.boundingSphere===null&&(this.boundingSphere=new an);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new A,1/0);return}if(e){const n=this.boundingSphere.center;if(vn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];vr.setFromBufferAttribute(o),this.morphTargetsRelative?(zt.addVectors(vn.min,vr.min),vn.expandByPoint(zt),zt.addVectors(vn.max,vr.max),vn.expandByPoint(zt)):(vn.expandByPoint(vr.min),vn.expandByPoint(vr.max))}vn.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)zt.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(zt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)zt.fromBufferAttribute(o,c),l&&(Ts.fromBufferAttribute(e,c),zt.add(Ts)),i=Math.max(i,n.distanceToSquared(zt))}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)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new rt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let P=0;P<n.count;P++)o[P]=new A,l[P]=new A;const c=new A,h=new A,u=new A,f=new j,d=new j,p=new j,_=new A,g=new A;function m(P,S,M){c.fromBufferAttribute(n,P),h.fromBufferAttribute(n,S),u.fromBufferAttribute(n,M),f.fromBufferAttribute(s,P),d.fromBufferAttribute(s,S),p.fromBufferAttribute(s,M),h.sub(c),u.sub(c),d.sub(f),p.sub(f);const D=1/(d.x*p.y-p.x*d.y);isFinite(D)&&(_.copy(h).multiplyScalar(p.y).addScaledVector(u,-d.y).multiplyScalar(D),g.copy(u).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(D),o[P].add(_),o[S].add(_),o[M].add(_),l[P].add(g),l[S].add(g),l[M].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let P=0,S=y.length;P<S;++P){const M=y[P],D=M.start,G=M.count;for(let F=D,V=D+G;F<V;F+=3)m(e.getX(F+0),e.getX(F+1),e.getX(F+2))}const v=new A,x=new A,w=new A,T=new A;function C(P){w.fromBufferAttribute(i,P),T.copy(w);const S=o[P];v.copy(S),v.sub(w.multiplyScalar(w.dot(S))).normalize(),x.crossVectors(T,S);const D=x.dot(l[P])<0?-1:1;a.setXYZW(P,v.x,v.y,v.z,D)}for(let P=0,S=y.length;P<S;++P){const M=y[P],D=M.start,G=M.count;for(let F=D,V=D+G;F<V;F+=3)C(e.getX(F+0)),C(e.getX(F+1)),C(e.getX(F+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new rt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const i=new A,s=new A,a=new A,o=new A,l=new A,c=new A,h=new A,u=new A;if(e)for(let f=0,d=e.count;f<d;f+=3){const p=e.getX(f+0),_=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,g),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,g),o.add(h),l.add(h),c.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),a.fromBufferAttribute(t,f+2),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)zt.fromBufferAttribute(e,t),zt.normalize(),e.setXYZ(t,zt.x,zt.y,zt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,f=new c.constructor(l.length*h);let d=0,p=0;for(let _=0,g=l.length;_<g;_++){o.isInterleavedBufferAttribute?d=l[_]*o.data.stride+o.offset:d=l[_]*h;for(let m=0;m<h;m++)f[p++]=c[d++]}return new rt(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new qe,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const f=c[h],d=e(f,n);l.push(d)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u];h.push(d.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Nh=new Ze,Bi=new ar,ra=new an,Fh=new A,aa=new A,oa=new A,la=new A,tl=new A,ca=new A,Oh=new A,ha=new A;class yt extends mt{constructor(e=new qe,t=new kn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){ca.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(tl.fromBufferAttribute(u,e),a?ca.addScaledVector(tl,h):ca.addScaledVector(tl.sub(t),h))}t.add(ca)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ra.copy(n.boundingSphere),ra.applyMatrix4(s),Bi.copy(e.ray).recast(e.near),!(ra.containsPoint(Bi.origin)===!1&&(Bi.intersectSphere(ra,Fh)===null||Bi.origin.distanceToSquared(Fh)>(e.far-e.near)**2))&&(Nh.copy(s).invert(),Bi.copy(e.ray).applyMatrix4(Nh),!(n.boundingBox!==null&&Bi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Bi)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,f=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),v=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let x=y,w=v;x<w;x+=3){const T=o.getX(x),C=o.getX(x+1),P=o.getX(x+2);i=ua(this,m,e,n,c,h,u,T,C,P),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(o.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=o.getX(g),v=o.getX(g+1),x=o.getX(g+2);i=ua(this,a,e,n,c,h,u,y,v,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),v=Math.min(l.count,Math.min(g.start+g.count,d.start+d.count));for(let x=y,w=v;x<w;x+=3){const T=x,C=x+1,P=x+2;i=ua(this,m,e,n,c,h,u,T,C,P),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(l.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=g,v=g+1,x=g+2;i=ua(this,a,e,n,c,h,u,y,v,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function Kp(r,e,t,n,i,s,a,o){let l;if(e.side===fn?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===Ci,o),l===null)return null;ha.copy(o),ha.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ha);return c<t.near||c>t.far?null:{distance:c,point:ha.clone(),object:r}}function ua(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,aa),r.getVertexPosition(l,oa),r.getVertexPosition(c,la);const h=Kp(r,e,t,n,aa,oa,la,Oh);if(h){const u=new A;yn.getBarycoord(Oh,aa,oa,la,u),i&&(h.uv=yn.getInterpolatedAttribute(i,o,l,c,u,new j)),s&&(h.uv1=yn.getInterpolatedAttribute(s,o,l,c,u,new j)),a&&(h.normal=yn.getInterpolatedAttribute(a,o,l,c,u,new A),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new A,materialIndex:0};yn.getNormal(aa,oa,la,f.normal),h.face=f,h.barycoord=u}return h}class or extends qe{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let f=0,d=0;p("z","y","x",-1,-1,n,t,e,a,s,0),p("z","y","x",1,-1,n,t,-e,a,s,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,s,4),p("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Fe(c,3)),this.setAttribute("normal",new Fe(h,3)),this.setAttribute("uv",new Fe(u,2));function p(_,g,m,y,v,x,w,T,C,P,S){const M=x/C,D=w/P,G=x/2,F=w/2,V=T/2,J=C+1,q=P+1;let se=0,Z=0;const _e=new A;for(let be=0;be<q;be++){const Re=be*D-F;for(let Ge=0;Ge<J;Ge++){const it=Ge*M-G;_e[_]=it*y,_e[g]=Re*v,_e[m]=V,c.push(_e.x,_e.y,_e.z),_e[_]=0,_e[g]=0,_e[m]=T>0?1:-1,h.push(_e.x,_e.y,_e.z),u.push(Ge/C),u.push(1-be/P),se+=1}}for(let be=0;be<P;be++)for(let Re=0;Re<C;Re++){const Ge=f+Re+J*be,it=f+Re+J*(be+1),Q=f+(Re+1)+J*(be+1),ue=f+(Re+1)+J*be;l.push(Ge,it,ue),l.push(it,Q,ue),Z+=6}o.addGroup(d,Z,S),d+=Z,f+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new or(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function tr(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function nn(r){const e={};for(let t=0;t<r.length;t++){const n=tr(r[t]);for(const i in n)e[i]=n[i]}return e}function $p(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Ad(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ht.workingColorSpace}const fo={clone:tr,merge:nn};var jp=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,Qp=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class Xt extends on{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jp,this.fragmentShader=Qp,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=tr(e.uniforms),this.uniformsGroups=$p(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Hc extends mt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=zn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const yi=new A,Bh=new j,zh=new j;class kt extends Hc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=er*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return er*2*Math.atan(Math.tan(ss*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){yi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yi.x,yi.y).multiplyScalar(-e/yi.z),yi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yi.x,yi.y).multiplyScalar(-e/yi.z)}getViewSize(e,t){return this.getViewBounds(e,Bh,zh),t.subVectors(zh,Bh)}setViewOffset(e,t,n,i,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ss*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const As=-90,Cs=1;class em extends mt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new kt(As,Cs,e,t);i.layers=this.layers,this.add(i);const s=new kt(As,Cs,e,t);s.layers=this.layers,this.add(s);const a=new kt(As,Cs,e,t);a.layers=this.layers,this.add(a);const o=new kt(As,Cs,e,t);o.layers=this.layers,this.add(o);const l=new kt(As,Cs,e,t);l.layers=this.layers,this.add(l);const c=new kt(As,Cs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===zn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===uo)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(u,f,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Eo extends Et{constructor(e,t,n,i,s,a,o,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:Ri,super(e,t,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class tm extends Sn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Eo(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Vt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
||
#include <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 or(5,5,5),s=new Xt({name:"CubemapFromEquirect",uniforms:tr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:fn,blending:ii});s.uniforms.tEquirect.value=t;const a=new yt(i,s),o=t.minFilter;return t.minFilter===ni&&(t.minFilter=Vt),new em(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}class Yr{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ne(e),this.density=t}clone(){return new Yr(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Gc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ne(e),this.near=t,this.far=n}clone(){return new Gc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Cd extends mt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new In,this.environmentIntensity=1,this.environmentRotation=new In,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Wc{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ho,this.updateRanges=[],this.version=0,this.uuid=bn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const tn=new A;class nr{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.applyMatrix4(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.applyNormalMatrix(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.transformDirection(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=sn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=sn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=sn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=sn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=sn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),i=nt(i,this.array),s=nt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new rt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new nr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class rs extends on{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ne(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Rs;const xr=new A,Is=new A,Ps=new A,Ds=new j,yr=new j,Rd=new Ze,da=new A,Mr=new A,fa=new A,kh=new j,nl=new j,Vh=new j;class ts extends mt{constructor(e=new rs){if(super(),this.isSprite=!0,this.type="Sprite",Rs===void 0){Rs=new qe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Wc(t,5);Rs.setIndex([0,1,2,0,2,3]),Rs.setAttribute("position",new nr(n,3,0,!1)),Rs.setAttribute("uv",new nr(n,2,3,!1))}this.geometry=Rs,this.material=e,this.center=new j(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Is.setFromMatrixScale(this.matrixWorld),Rd.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ps.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Is.multiplyScalar(-Ps.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;pa(da.set(-.5,-.5,0),Ps,a,Is,i,s),pa(Mr.set(.5,-.5,0),Ps,a,Is,i,s),pa(fa.set(.5,.5,0),Ps,a,Is,i,s),kh.set(0,0),nl.set(1,0),Vh.set(1,1);let o=e.ray.intersectTriangle(da,Mr,fa,!1,xr);if(o===null&&(pa(Mr.set(-.5,.5,0),Ps,a,Is,i,s),nl.set(0,1),o=e.ray.intersectTriangle(da,fa,Mr,!1,xr),o===null))return;const l=e.ray.origin.distanceTo(xr);l<e.near||l>e.far||t.push({distance:l,point:xr.clone(),uv:yn.getInterpolation(xr,da,Mr,fa,kh,nl,Vh,new j),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function pa(r,e,t,n,i,s){Ds.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(yr.x=s*Ds.x-i*Ds.y,yr.y=i*Ds.x+s*Ds.y):yr.copy(Ds),r.copy(e),r.x+=yr.x,r.y+=yr.y,r.applyMatrix4(Rd)}const ma=new A,Hh=new A;class nm extends mt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){ma.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(ma);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ma.setFromMatrixPosition(e.matrixWorld),Hh.setFromMatrixPosition(this.matrixWorld);const n=ma.distanceTo(Hh)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let a=t[i].distance;if(t[i].object.visible&&(a-=a*t[i].hysteresis),n>=a)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const a=n[i];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const Gh=new A,Wh=new pt,Xh=new pt,im=new A,qh=new Ze,ga=new A,il=new an,Yh=new Ze,sl=new ar;class sm extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=xh,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new pn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ga),this.boundingBox.expandByPoint(ga)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new an),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ga),this.boundingSphere.expandByPoint(ga)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),il.copy(this.boundingSphere),il.applyMatrix4(i),e.ray.intersectsSphere(il)!==!1&&(Yh.copy(i).invert(),sl.copy(e.ray).applyMatrix4(Yh),!(this.boundingBox!==null&&sl.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,sl)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===xh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===tp?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Wh.fromBufferAttribute(i.attributes.skinIndex,e),Xh.fromBufferAttribute(i.attributes.skinWeight,e),Gh.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=Xh.getComponent(s);if(a!==0){const o=Wh.getComponent(s);qh.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(im.copy(Gh).applyMatrix4(qh),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Id extends mt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ai extends Et{constructor(e=null,t=1,n=1,i,s,a,o,l,c=Qt,h=Qt,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Zh=new Ze,rm=new Ze;class Xc{constructor(e=[],t=[]){this.uuid=bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ze;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:rm;Zh.multiplyMatrices(o,t[s]),Zh.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Xc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ai(t,e,e,dn,Mn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Id),this.bones.push(a),this.boneInverses.push(new Ze().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class Hr extends rt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ls=new Ze,Jh=new Ze,_a=[],Kh=new pn,am=new Ze,br=new yt,Sr=new an;class Pd extends yt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Hr(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,am)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new pn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ls),Kh.copy(e.boundingBox).applyMatrix4(Ls),this.boundingBox.union(Kh)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new an),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ls),Sr.copy(e.boundingSphere).applyMatrix4(Ls),this.boundingSphere.union(Sr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(br.geometry=this.geometry,br.material=this.material,br.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Sr.copy(this.boundingSphere),Sr.applyMatrix4(n),e.ray.intersectsSphere(Sr)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Ls),Jh.multiplyMatrices(n,Ls),br.matrixWorld=Jh,br.raycast(e,_a);for(let a=0,o=_a.length;a<o;a++){const l=_a[a];l.instanceId=s,l.object=this,t.push(l)}_a.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Hr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new ai(new Float32Array(i*this.count),i,this.count,Uc,Mn));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}const rl=new A,om=new A,lm=new tt;class Si{constructor(e=new A(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=rl.subVectors(n,t).cross(om.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(rl),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||lm.getNormalMatrix(e),i=this.coplanarPoint(rl).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const zi=new an,va=new A;class To{constructor(e=new Si,t=new Si,n=new Si,i=new Si,s=new Si,a=new Si){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=zn){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],f=i[7],d=i[8],p=i[9],_=i[10],g=i[11],m=i[12],y=i[13],v=i[14],x=i[15];if(n[0].setComponents(l-s,f-c,g-d,x-m).normalize(),n[1].setComponents(l+s,f+c,g+d,x+m).normalize(),n[2].setComponents(l+a,f+h,g+p,x+y).normalize(),n[3].setComponents(l-a,f-h,g-p,x-y).normalize(),n[4].setComponents(l-o,f-u,g-_,x-v).normalize(),t===zn)n[5].setComponents(l+o,f+u,g+_,x+v).normalize();else if(t===uo)n[5].setComponents(o,u,_,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),zi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zi)}intersectsSprite(e){return zi.center.set(0,0,0),zi.radius=.7071067811865476,zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(zi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(va.x=i.normal.x>0?e.max.x:e.min.x,va.y=i.normal.y>0?e.max.y:e.min.y,va.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(va)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function al(r,e){return r-e}function cm(r,e){return r.z-e.z}function hm(r,e){return e.z-r.z}class um{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=i}reset(){this.list.length=0,this.index=0}}const cn=new Ze,dm=new ne(1,1,1),ol=new To,xa=new pn,ki=new an,wr=new A,$h=new A,fm=new A,ll=new um,$t=new yt,ya=[];function pm(r,e,t=0){const n=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const i=r.count;for(let s=0;s<i;s++)for(let a=0;a<n;a++)e.setComponent(s+t,a,r.getComponent(s,a))}else e.array.set(r.array,t*n);e.needsUpdate=!0}function Vi(r,e){if(r.constructor!==e.constructor){const t=Math.min(r.length,e.length);for(let n=0;n<t;n++)e[n]=r[n]}else{const t=Math.min(r.length,e.length);e.set(new r.constructor(r.buffer,0,t))}}class mm extends yt{get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}constructor(e,t,n=t*2,i){super(new qe,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new ai(t,e,e,dn,Mn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new ai(t,e,e,So,Ii);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new ai(t,e,e,dn,Mn);n.colorSpace=ht.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,h=new o.constructor(n*l),u=new rt(h,l,c);t.setAttribute(s,u)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new rt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),s=t.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pn);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,cn),this.getBoundingBoxAt(s,xa).applyMatrix4(cn),e.union(xa)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new an);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,cn),this.getBoundingSphereAt(s,ki).applyMatrix4(cn),e.union(ki)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(al),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;cn.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(dm.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?a.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(al),l=this._availableGeometryIds.shift(),s[l]=i):(l=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(l,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(i&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const h in n.attributes){const u=t.getAttribute(h),f=n.getAttribute(h);pm(u,f,l);const d=u.itemSize;for(let p=u.count,_=c;p<_;p++){const g=l+p;for(let m=0;m<d;m++)f.setComponent(g,m,0)}f.needsUpdate=!0,f.addUpdateRange(l*d,c*d)}if(i){const h=o.indexStart,u=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let f=0;f<a.count;f++)s.setX(h+f,l+a.getX(f));for(let f=a.count,d=u;f<d;f++)s.setX(h+f,l);s.needsUpdate=!0,s.addUpdateRange(h,o.reservedIndexCount)}return o.start=i?o.indexStart:o.vertexStart,o.count=i?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,s=n.length;i<s;i++)n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,i=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),s=this.geometry;for(let a=0,o=n.length;a<o;a++){const l=i[a],c=n[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==t){const{indexStart:h,vertexStart:u,reservedIndexCount:f}=c,d=s.index,p=d.array,_=e-u;for(let g=h;g<h+f;g++)p[g]=p[g]+_;d.array.copyWithin(t,h,h+f),d.addUpdateRange(t,f),c.indexStart=t}t+=c.reservedIndexCount}if(c.vertexStart!==e){const{vertexStart:h,reservedVertexCount:u}=c,f=s.attributes;for(const d in f){const p=f[d],{array:_,itemSize:g}=p;_.copyWithin(e*g,h*g,(h+u)*g),p.addUpdateRange(e*g,u*g)}c.vertexStart=e}e+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart,this._nextIndexStart=s.index?c.indexStart+c.reservedIndexCount:0,this._nextVertexStart=c.vertexStart+c.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new pn,a=n.index,o=n.attributes.position;for(let l=i.start,c=i.start+i.count;l<c;l++){let h=l;a&&(h=a.getX(h)),s.expandByPoint(wr.fromBufferAttribute(o,h))}i.boundingBox=s}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new an;this.getBoundingBoxAt(e,xa),xa.getCenter(s.center);const a=n.index,o=n.attributes.position;let l=0;for(let c=i.start,h=i.start+i.count;c<h;c++){let u=c;a&&(u=a.getX(u)),wr.fromBufferAttribute(o,u),l=Math.max(l,s.center.distanceToSquared(wr))}s.radius=Math.sqrt(l),i.boundingSphere=s}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(al);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),s=new Int32Array(e);Vi(this._multiDrawCounts,i),Vi(this._multiDrawStarts,s),this._multiDrawCounts=i,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Vi(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Vi(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),Vi(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new qe,this._initializeGeometry(s));const a=this.geometry;s.index&&Vi(s.index.array,a.index.array);for(const o in s.attributes)Vi(s.attributes[o].array,a.attributes[o].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,a=this.geometry;$t.material=this.material,$t.geometry.index=a.index,$t.geometry.attributes=a.attributes,$t.geometry.boundingBox===null&&($t.geometry.boundingBox=new pn),$t.geometry.boundingSphere===null&&($t.geometry.boundingSphere=new an);for(let o=0,l=n.length;o<l;o++){if(!n[o].visible||!n[o].active)continue;const c=n[o].geometryIndex,h=i[c];$t.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(o,$t.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,$t.geometry.boundingBox),this.getBoundingSphereAt(c,$t.geometry.boundingSphere),$t.raycast(e,ya);for(let u=0,f=ya.length;u<f;u++){const d=ya[u];d.object=this,d.batchId=o,t.push(d)}ya.length=0}$t.material=null,$t.geometry.index=null,$t.geometry.attributes={},$t.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._geometryInfo,f=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;f&&(cn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ol.setFromProjectionMatrix(cn,e.coordinateSystem));let _=0;if(this.sortObjects){cn.copy(this.matrixWorld).invert(),wr.setFromMatrixPosition(n.matrixWorld).applyMatrix4(cn),$h.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(cn);for(let y=0,v=l.length;y<v;y++)if(l[y].visible&&l[y].active){const x=l[y].geometryIndex;this.getMatrixAt(y,cn),this.getBoundingSphereAt(x,ki).applyMatrix4(cn);let w=!1;if(f&&(w=!ol.intersectsSphere(ki)),!w){const T=u[x],C=fm.subVectors(ki.center,wr).dot($h);ll.push(T.start,T.count,C,y)}}const g=ll.list,m=this.customSort;m===null?g.sort(s.transparent?hm:cm):m.call(this,g,n);for(let y=0,v=g.length;y<v;y++){const x=g[y];c[_]=x.start*o,h[_]=x.count,p[_]=x.index,_++}ll.reset()}else for(let g=0,m=l.length;g<m;g++)if(l[g].visible&&l[g].active){const y=l[g].geometryIndex;let v=!1;if(f&&(this.getMatrixAt(g,cn),this.getBoundingSphereAt(y,ki).applyMatrix4(cn),v=!ol.intersectsSphere(ki)),!v){const x=u[y];c[_]=x.start*o,h[_]=x.count,p[_]=g,_++}}d.needsUpdate=!0,this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,s,a){this.onBeforeRender(e,null,i,s,a)}}class qt extends on{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ne(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const po=new A,mo=new A,jh=new Ze,Er=new ar,Ma=new an,cl=new A,Qh=new A;class Vn extends mt{constructor(e=new qe,t=new qt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)po.fromBufferAttribute(t,i-1),mo.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=po.distanceTo(mo);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ma.copy(n.boundingSphere),Ma.applyMatrix4(i),Ma.radius+=s,e.ray.intersectsSphere(Ma)===!1)return;jh.copy(i).invert(),Er.copy(e.ray).applyMatrix4(jh);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let _=d,g=p-1;_<g;_+=c){const m=h.getX(_),y=h.getX(_+1),v=ba(this,e,Er,l,m,y);v&&t.push(v)}if(this.isLineLoop){const _=h.getX(p-1),g=h.getX(d),m=ba(this,e,Er,l,_,g);m&&t.push(m)}}else{const d=Math.max(0,a.start),p=Math.min(f.count,a.start+a.count);for(let _=d,g=p-1;_<g;_+=c){const m=ba(this,e,Er,l,_,_+1);m&&t.push(m)}if(this.isLineLoop){const _=ba(this,e,Er,l,p-1,d);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function ba(r,e,t,n,i,s){const a=r.geometry.attributes.position;if(po.fromBufferAttribute(a,i),mo.fromBufferAttribute(a,s),t.distanceSqToSegment(po,mo,cl,Qh)>n)return;cl.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(cl);if(!(l<e.near||l>e.far))return{distance:l,point:Qh.clone().applyMatrix4(r.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:r}}const eu=new A,tu=new A;class hi extends Vn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)eu.fromBufferAttribute(t,i),tu.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+eu.distanceTo(tu);e.setAttribute("lineDistance",new Fe(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gm extends Vn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ai extends on{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ne(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const nu=new Ze,fc=new ar,Sa=new an,wa=new A;class as extends mt{constructor(e=new qe,t=new Ai){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Sa.copy(n.boundingSphere),Sa.applyMatrix4(i),Sa.radius+=s,e.ray.intersectsSphere(Sa)===!1)return;nu.copy(i).invert(),fc.copy(e.ray).applyMatrix4(nu);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const f=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=f,_=d;p<_;p++){const g=c.getX(p);wa.fromBufferAttribute(u,g),iu(wa,g,l,i,e,t,this)}}else{const f=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=f,_=d;p<_;p++)wa.fromBufferAttribute(u,p),iu(wa,p,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function iu(r,e,t,n,i,s,a){const o=fc.distanceSqToPoint(r);if(o<t){const l=new A;fc.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class ns extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}}class ZS extends Et{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Vt,this.magFilter=s!==void 0?s:Vt,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class JS extends Et{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Qt,this.minFilter=Qt,this.generateMipmaps=!1,this.needsUpdate=!0}}class qc extends Et{constructor(e,t,n,i,s,a,o,l,c,h,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class KS extends qc{constructor(e,t,n,i,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Nn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class $S extends qc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ri),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Dd extends Et{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ld extends Et{constructor(e,t,n,i,s,a,o,l,c,h=Ys){if(h!==Ys&&h!==js)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Ys&&(n=Ii),n===void 0&&h===js&&(n=$s),super(null,i,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Qt,this.minFilter=l!==void 0?l:Qt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Hn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],f=n[i+1]-h,d=(a-h)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new j:new A);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new A,i=[],s=[],a=[],o=new A,l=new Ze;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new A)}s[0]=new A,a[0]=new A;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),f<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(et(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(o,p))}a[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(et(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],d*p)),a[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Yc extends Hn{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new j){const n=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=l-this.aX,d=c-this.aY;l=f*h-d*u+this.aX,c=f*u+d*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class _m extends Yc{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Zc(){let r=0,e=0,t=0,n=0;function i(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,u){let f=(a-s)/c-(o-s)/(c+h)+(o-a)/h,d=(o-a)/h-(l-a)/(h+u)+(l-o)/u;f*=h,d*=h,i(a,o,f,d)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const Ea=new A,hl=new Zc,ul=new Zc,dl=new Zc;class vm extends Hn{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(Ea.subVectors(i[0],i[1]).add(i[0]),c=Ea);const u=i[o%s],f=i[(o+1)%s];if(this.closed||o+2<s?h=i[(o+2)%s]:(Ea.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=Ea),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(u),d),_=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);_<1e-4&&(_=1),p<1e-4&&(p=_),g<1e-4&&(g=_),hl.initNonuniformCatmullRom(c.x,u.x,f.x,h.x,p,_,g),ul.initNonuniformCatmullRom(c.y,u.y,f.y,h.y,p,_,g),dl.initNonuniformCatmullRom(c.z,u.z,f.z,h.z,p,_,g)}else this.curveType==="catmullrom"&&(hl.initCatmullRom(c.x,u.x,f.x,h.x,this.tension),ul.initCatmullRom(c.y,u.y,f.y,h.y,this.tension),dl.initCatmullRom(c.z,u.z,f.z,h.z,this.tension));return n.set(hl.calc(l),ul.calc(l),dl.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function su(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,l=r*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*r+t}function xm(r,e){const t=1-r;return t*t*e}function ym(r,e){return 2*(1-r)*r*e}function Mm(r,e){return r*r*e}function Ur(r,e,t,n){return xm(r,e)+ym(r,t)+Mm(r,n)}function bm(r,e){const t=1-r;return t*t*t*e}function Sm(r,e){const t=1-r;return 3*t*t*r*e}function wm(r,e){return 3*(1-r)*r*r*e}function Em(r,e){return r*r*r*e}function Nr(r,e,t,n,i){return bm(r,e)+Sm(r,t)+wm(r,n)+Em(r,i)}class Ud extends Hn{constructor(e=new j,t=new j,n=new j,i=new j){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new j){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Nr(e,i.x,s.x,a.x,o.x),Nr(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Tm extends Hn{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Nr(e,i.x,s.x,a.x,o.x),Nr(e,i.y,s.y,a.y,o.y),Nr(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Nd extends Hn{constructor(e=new j,t=new j){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new j){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new j){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Am extends Hn{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new A){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Fd extends Hn{constructor(e=new j,t=new j,n=new j){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new j){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Ur(e,i.x,s.x,a.x),Ur(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Od extends Hn{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Ur(e,i.x,s.x,a.x),Ur(e,i.y,s.y,a.y),Ur(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Bd extends Hn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new j){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(su(o,l.x,c.x,h.x,u.x),su(o,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new j().fromArray(i))}return this}}var go=Object.freeze({__proto__:null,ArcCurve:_m,CatmullRomCurve3:vm,CubicBezierCurve:Ud,CubicBezierCurve3:Tm,EllipseCurve:Yc,LineCurve:Nd,LineCurve3:Am,QuadraticBezierCurve:Fd,QuadraticBezierCurve3:Od,SplineCurve:Bd});class Cm extends Hn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new go[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new go[i.type]().fromJSON(i))}return this}}class _o extends Cm{constructor(e){super(),this.type="Path",this.currentPoint=new j,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Nd(this.currentPoint.clone(),new j(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new Fd(this.currentPoint.clone(),new j(e,t),new j(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new Ud(this.currentPoint.clone(),new j(e,t),new j(n,i),new j(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Bd(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,a,o,l),this}absellipse(e,t,n,i,s,a,o,l){const c=new Yc(e,t,n,i,s,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ao extends qe{constructor(e=[new j(0,-.5),new j(.5,0),new j(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=et(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new A,f=new j,d=new A,p=new A,_=new A;let g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,_.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=_.x,d.y+=_.y,d.z+=_.z,d.normalize(),l.push(d.x,d.y,d.z),_.copy(p)}for(let y=0;y<=t;y++){const v=n+y*h*i,x=Math.sin(v),w=Math.cos(v);for(let T=0;T<=e.length-1;T++){u.x=e[T].x*x,u.y=e[T].y,u.z=e[T].x*w,a.push(u.x,u.y,u.z),f.x=y/t,f.y=T/(e.length-1),o.push(f.x,f.y);const C=l[3*T+0]*x,P=l[3*T+1],S=l[3*T+0]*w;c.push(C,P,S)}}for(let y=0;y<t;y++)for(let v=0;v<e.length-1;v++){const x=v+y*e.length,w=x,T=x+e.length,C=x+e.length+1,P=x+1;s.push(w,T,P),s.push(C,P,T)}this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("uv",new Fe(o,2)),this.setAttribute("normal",new Fe(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ao(e.points,e.segments,e.phiStart,e.phiLength)}}class Jc extends Ao{constructor(e=1,t=1,n=4,i=8){const s=new _o;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Jc(e.radius,e.length,e.capSegments,e.radialSegments)}}class Kc extends qe{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new A,h=new j;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,f=3;u<=t;u++,f+=3){const d=n+u/t*i;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[f]/e+1)/2,h.y=(a[f+1]/e+1)/2,l.push(h.x,h.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new Fe(a,3)),this.setAttribute("normal",new Fe(o,3)),this.setAttribute("uv",new Fe(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Zr extends qe{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],f=[],d=[];let p=0;const _=[],g=n/2;let m=0;y(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Fe(u,3)),this.setAttribute("normal",new Fe(f,3)),this.setAttribute("uv",new Fe(d,2));function y(){const x=new A,w=new A;let T=0;const C=(t-e)/n;for(let P=0;P<=s;P++){const S=[],M=P/s,D=M*(t-e)+e;for(let G=0;G<=i;G++){const F=G/i,V=F*l+o,J=Math.sin(V),q=Math.cos(V);w.x=D*J,w.y=-M*n+g,w.z=D*q,u.push(w.x,w.y,w.z),x.set(J,C,q).normalize(),f.push(x.x,x.y,x.z),d.push(F,1-M),S.push(p++)}_.push(S)}for(let P=0;P<i;P++)for(let S=0;S<s;S++){const M=_[S][P],D=_[S+1][P],G=_[S+1][P+1],F=_[S][P+1];(e>0||S!==0)&&(h.push(M,D,F),T+=3),(t>0||S!==s-1)&&(h.push(D,G,F),T+=3)}c.addGroup(m,T,0),m+=T}function v(x){const w=p,T=new j,C=new A;let P=0;const S=x===!0?e:t,M=x===!0?1:-1;for(let G=1;G<=i;G++)u.push(0,g*M,0),f.push(0,M,0),d.push(.5,.5),p++;const D=p;for(let G=0;G<=i;G++){const V=G/i*l+o,J=Math.cos(V),q=Math.sin(V);C.x=S*q,C.y=g*M,C.z=S*J,u.push(C.x,C.y,C.z),f.push(0,M,0),T.x=J*.5+.5,T.y=q*.5*M+.5,d.push(T.x,T.y),p++}for(let G=0;G<i;G++){const F=w+G,V=D+G;x===!0?h.push(V,V+1,F):h.push(V+1,V,F),P+=3}c.addGroup(m,P,x===!0?1:2),m+=P}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zr(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class $c extends Zr{constructor(e=1,t=1,n=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new $c(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hs extends qe{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],a=[];o(i),c(n),h(),this.setAttribute("position",new Fe(s,3)),this.setAttribute("normal",new Fe(s.slice(),3)),this.setAttribute("uv",new Fe(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const v=new A,x=new A,w=new A;for(let T=0;T<t.length;T+=3)d(t[T+0],v),d(t[T+1],x),d(t[T+2],w),l(v,x,w,y)}function l(y,v,x,w){const T=w+1,C=[];for(let P=0;P<=T;P++){C[P]=[];const S=y.clone().lerp(x,P/T),M=v.clone().lerp(x,P/T),D=T-P;for(let G=0;G<=D;G++)G===0&&P===T?C[P][G]=S:C[P][G]=S.clone().lerp(M,G/D)}for(let P=0;P<T;P++)for(let S=0;S<2*(T-P)-1;S++){const M=Math.floor(S/2);S%2===0?(f(C[P][M+1]),f(C[P+1][M]),f(C[P][M])):(f(C[P][M+1]),f(C[P+1][M+1]),f(C[P+1][M]))}}function c(y){const v=new A;for(let x=0;x<s.length;x+=3)v.x=s[x+0],v.y=s[x+1],v.z=s[x+2],v.normalize().multiplyScalar(y),s[x+0]=v.x,s[x+1]=v.y,s[x+2]=v.z}function h(){const y=new A;for(let v=0;v<s.length;v+=3){y.x=s[v+0],y.y=s[v+1],y.z=s[v+2];const x=g(y)/2/Math.PI+.5,w=m(y)/Math.PI+.5;a.push(x,1-w)}p(),u()}function u(){for(let y=0;y<a.length;y+=6){const v=a[y+0],x=a[y+2],w=a[y+4],T=Math.max(v,x,w),C=Math.min(v,x,w);T>.9&&C<.1&&(v<.2&&(a[y+0]+=1),x<.2&&(a[y+2]+=1),w<.2&&(a[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,v){const x=y*3;v.x=e[x+0],v.y=e[x+1],v.z=e[x+2]}function p(){const y=new A,v=new A,x=new A,w=new A,T=new j,C=new j,P=new j;for(let S=0,M=0;S<s.length;S+=9,M+=6){y.set(s[S+0],s[S+1],s[S+2]),v.set(s[S+3],s[S+4],s[S+5]),x.set(s[S+6],s[S+7],s[S+8]),T.set(a[M+0],a[M+1]),C.set(a[M+2],a[M+3]),P.set(a[M+4],a[M+5]),w.copy(y).add(v).add(x).divideScalar(3);const D=g(w);_(T,M+0,y,D),_(C,M+2,v,D),_(P,M+4,x,D)}}function _(y,v,x,w){w<0&&y.x===1&&(a[v]=y.x-1),x.x===0&&x.z===0&&(a[v]=w/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hs(e.vertices,e.indices,e.radius,e.details)}}class jc extends hs{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],a=[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,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new jc(e.radius,e.detail)}}const Ta=new A,Aa=new A,fl=new A,Ca=new yn;class Rm extends qe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(ss*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),f={},d=[];for(let p=0;p<l;p+=3){a?(c[0]=a.getX(p),c[1]=a.getX(p+1),c[2]=a.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:_,b:g,c:m}=Ca;if(_.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),m.fromBufferAttribute(o,c[2]),Ca.getNormal(fl),u[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const v=(y+1)%3,x=u[y],w=u[v],T=Ca[h[y]],C=Ca[h[v]],P=`${x}_${w}`,S=`${w}_${x}`;S in f&&f[S]?(fl.dot(f[S].normal)<=s&&(d.push(T.x,T.y,T.z),d.push(C.x,C.y,C.z)),f[S]=null):P in f||(f[P]={index0:c[y],index1:c[v],normal:fl.clone()})}}for(const p in f)if(f[p]){const{index0:_,index1:g}=f[p];Ta.fromBufferAttribute(o,_),Aa.fromBufferAttribute(o,g),d.push(Ta.x,Ta.y,Ta.z),d.push(Aa.x,Aa.y,Aa.z)}this.setAttribute("position",new Fe(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Js extends _o{constructor(e){super(e),this.uuid=bn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new _o().fromJSON(i))}return this}}const Im={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=zd(r,0,i,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,h,u,f,d;if(n&&(s=Nm(r,e,s,t)),r.length>80*t){o=c=r[0],l=h=r[1];for(let p=t;p<i;p+=t)u=r[p],f=r[p+1],u<o&&(o=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-o,h-l),d=d!==0?32767/d:0}return Gr(s,a,t,o,l,d,0),a}};function zd(r,e,t,n,i){let s,a;if(i===qm(r,e,t,n)>0)for(s=e;s<t;s+=n)a=ru(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=ru(s,r[s],r[s+1],a);return a&&Co(a,a.next)&&(Xr(a),a=a.next),a}function ls(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Co(t,t.next)||wt(t.prev,t,t.next)===0)){if(Xr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Gr(r,e,t,n,i,s,a){if(!r)return;!a&&s&&km(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Dm(r,n,i,s):Pm(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),Xr(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=Lm(ls(r),e,t),Gr(r,e,t,n,i,s,2)):a===2&&Um(r,e,t,n,i,s):Gr(ls(r),e,t,n,i,s,1);break}}}function Pm(r){const e=r.prev,t=r,n=r.next;if(wt(e,t,n)>=0)return!1;const i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,f=i>s?i>a?i:a:s>a?s:a,d=o>l?o>c?o:c:l>c?l:c;let p=n.next;for(;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&Hs(i,o,s,l,a,c,p.x,p.y)&&wt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Dm(r,e,t,n){const i=r.prev,s=r,a=r.next;if(wt(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,f=a.y,d=o<l?o<c?o:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>f?h:f:u>f?u:f,m=pc(d,p,e,t,n),y=pc(_,g,e,t,n);let v=r.prevZ,x=r.nextZ;for(;v&&v.z>=m&&x&&x.z<=y;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Hs(o,h,l,u,c,f,v.x,v.y)&&wt(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Hs(o,h,l,u,c,f,x.x,x.y)&&wt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=m;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Hs(o,h,l,u,c,f,v.x,v.y)&&wt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Hs(o,h,l,u,c,f,x.x,x.y)&&wt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Lm(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!Co(i,s)&&kd(i,n,n.next,s)&&Wr(i,s)&&Wr(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Xr(n),Xr(n.next),n=r=s),n=n.next}while(n!==r);return ls(n)}function Um(r,e,t,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Gm(a,o)){let l=Vd(a,o);a=ls(a,a.next),l=ls(l,l.next),Gr(a,e,t,n,i,s,0),Gr(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function Nm(r,e,t,n){const i=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=zd(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(Hm(c));for(i.sort(Fm),s=0;s<i.length;s++)t=Om(i[s],t);return t}function Fm(r,e){return r.x-e.x}function Om(r,e){const t=Bm(r,e);if(!t)return e;const n=Vd(t,r);return ls(n,n.next),ls(t,t.next)}function Bm(r,e){let t=e,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const f=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===s))return i}t=t.next}while(t!==e);if(!i)return null;const o=i,l=i.x,c=i.y;let h=1/0,u;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&Hs(a<c?s:n,a,l,c,a<c?n:s,a,t.x,t.y)&&(u=Math.abs(a-t.y)/(s-t.x),Wr(t,r)&&(u<h||u===h&&(t.x>i.x||t.x===i.x&&zm(i,t)))&&(i=t,h=u)),t=t.next;while(t!==o);return i}function zm(r,e){return wt(r.prev,r,e.prev)<0&&wt(e.next,r,r.next)<0}function km(r,e,t,n){let i=r;do i.z===0&&(i.z=pc(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Vm(i)}function Vm(r){let e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function pc(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function Hm(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Hs(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function Gm(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Wm(r,e)&&(Wr(r,e)&&Wr(e,r)&&Xm(r,e)&&(wt(r.prev,r,e.prev)||wt(r,e.prev,e))||Co(r,e)&&wt(r.prev,r,r.next)>0&&wt(e.prev,e,e.next)>0)}function wt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Co(r,e){return r.x===e.x&&r.y===e.y}function kd(r,e,t,n){const i=Ia(wt(r,e,t)),s=Ia(wt(r,e,n)),a=Ia(wt(t,n,r)),o=Ia(wt(t,n,e));return!!(i!==s&&a!==o||i===0&&Ra(r,t,e)||s===0&&Ra(r,n,e)||a===0&&Ra(t,r,n)||o===0&&Ra(t,e,n))}function Ra(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Ia(r){return r>0?1:r<0?-1:0}function Wm(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&kd(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Wr(r,e){return wt(r.prev,r,r.next)<0?wt(r,e,r.next)>=0&&wt(r,r.prev,e)>=0:wt(r,e,r.prev)<0||wt(r,r.next,e)<0}function Xm(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Vd(r,e){const t=new mc(r.i,r.x,r.y),n=new mc(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function ru(r,e,t,n){const i=new mc(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Xr(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function mc(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qm(r,e,t,n){let i=0;for(let s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class oi{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return oi.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];au(e),ou(n,e);let a=e.length;t.forEach(au);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,ou(n,t[l]);const o=Im.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function au(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function ou(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class Qc extends qe{constructor(e=new Js([new j(.5,.5),new j(-.5,.5),new j(-.5,-.5),new j(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new Fe(i,3)),this.setAttribute("uv",new Fe(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:Ym;let v,x=!1,w,T,C,P;m&&(v=m.getSpacedPoints(h),x=!0,f=!1,w=m.computeFrenetFrames(h,!1),T=new A,C=new A,P=new A),f||(g=0,d=0,p=0,_=0);const S=o.extractPoints(c);let M=S.shape;const D=S.holes;if(!oi.isClockWise(M)){M=M.reverse();for(let te=0,de=D.length;te<de;te++){const I=D[te];oi.isClockWise(I)&&(D[te]=I.reverse())}}const F=oi.triangulateShape(M,D),V=M;for(let te=0,de=D.length;te<de;te++){const I=D[te];M=M.concat(I)}function J(te,de,I){return de||console.error("THREE.ExtrudeGeometry: vec does not exist"),te.clone().addScaledVector(de,I)}const q=M.length,se=F.length;function Z(te,de,I){let De,re,Ae;const me=te.x-de.x,Ve=te.y-de.y,Se=I.x-te.x,R=I.y-te.y,b=me*me+Ve*Ve,H=me*R-Ve*Se;if(Math.abs(H)>Number.EPSILON){const k=Math.sqrt(b),X=Math.sqrt(Se*Se+R*R),W=de.x-Ve/k,ce=de.y+me/k,oe=I.x-R/X,ge=I.y+Se/X,Be=((oe-W)*R-(ge-ce)*Se)/(me*R-Ve*Se);De=W+me*Be-te.x,re=ce+Ve*Be-te.y;const $=De*De+re*re;if($<=2)return new j(De,re);Ae=Math.sqrt($/2)}else{let k=!1;me>Number.EPSILON?Se>Number.EPSILON&&(k=!0):me<-Number.EPSILON?Se<-Number.EPSILON&&(k=!0):Math.sign(Ve)===Math.sign(R)&&(k=!0),k?(De=-Ve,re=me,Ae=Math.sqrt(b)):(De=me,re=Ve,Ae=Math.sqrt(b/2))}return new j(De/Ae,re/Ae)}const _e=[];for(let te=0,de=V.length,I=de-1,De=te+1;te<de;te++,I++,De++)I===de&&(I=0),De===de&&(De=0),_e[te]=Z(V[te],V[I],V[De]);const be=[];let Re,Ge=_e.concat();for(let te=0,de=D.length;te<de;te++){const I=D[te];Re=[];for(let De=0,re=I.length,Ae=re-1,me=De+1;De<re;De++,Ae++,me++)Ae===re&&(Ae=0),me===re&&(me=0),Re[De]=Z(I[De],I[Ae],I[me]);be.push(Re),Ge=Ge.concat(Re)}for(let te=0;te<g;te++){const de=te/g,I=d*Math.cos(de*Math.PI/2),De=p*Math.sin(de*Math.PI/2)+_;for(let re=0,Ae=V.length;re<Ae;re++){const me=J(V[re],_e[re],De);pe(me.x,me.y,-I)}for(let re=0,Ae=D.length;re<Ae;re++){const me=D[re];Re=be[re];for(let Ve=0,Se=me.length;Ve<Se;Ve++){const R=J(me[Ve],Re[Ve],De);pe(R.x,R.y,-I)}}}const it=p+_;for(let te=0;te<q;te++){const de=f?J(M[te],Ge[te],it):M[te];x?(C.copy(w.normals[0]).multiplyScalar(de.x),T.copy(w.binormals[0]).multiplyScalar(de.y),P.copy(v[0]).add(C).add(T),pe(P.x,P.y,P.z)):pe(de.x,de.y,0)}for(let te=1;te<=h;te++)for(let de=0;de<q;de++){const I=f?J(M[de],Ge[de],it):M[de];x?(C.copy(w.normals[te]).multiplyScalar(I.x),T.copy(w.binormals[te]).multiplyScalar(I.y),P.copy(v[te]).add(C).add(T),pe(P.x,P.y,P.z)):pe(I.x,I.y,u/h*te)}for(let te=g-1;te>=0;te--){const de=te/g,I=d*Math.cos(de*Math.PI/2),De=p*Math.sin(de*Math.PI/2)+_;for(let re=0,Ae=V.length;re<Ae;re++){const me=J(V[re],_e[re],De);pe(me.x,me.y,u+I)}for(let re=0,Ae=D.length;re<Ae;re++){const me=D[re];Re=be[re];for(let Ve=0,Se=me.length;Ve<Se;Ve++){const R=J(me[Ve],Re[Ve],De);x?pe(R.x,R.y+v[h-1].y,v[h-1].x+I):pe(R.x,R.y,u+I)}}}Q(),ue();function Q(){const te=i.length/3;if(f){let de=0,I=q*de;for(let De=0;De<se;De++){const re=F[De];Oe(re[2]+I,re[1]+I,re[0]+I)}de=h+g*2,I=q*de;for(let De=0;De<se;De++){const re=F[De];Oe(re[0]+I,re[1]+I,re[2]+I)}}else{for(let de=0;de<se;de++){const I=F[de];Oe(I[2],I[1],I[0])}for(let de=0;de<se;de++){const I=F[de];Oe(I[0]+q*h,I[1]+q*h,I[2]+q*h)}}n.addGroup(te,i.length/3-te,0)}function ue(){const te=i.length/3;let de=0;Ie(V,de),de+=V.length;for(let I=0,De=D.length;I<De;I++){const re=D[I];Ie(re,de),de+=re.length}n.addGroup(te,i.length/3-te,1)}function Ie(te,de){let I=te.length;for(;--I>=0;){const De=I;let re=I-1;re<0&&(re=te.length-1);for(let Ae=0,me=h+g*2;Ae<me;Ae++){const Ve=q*Ae,Se=q*(Ae+1),R=de+De+Ve,b=de+re+Ve,H=de+re+Se,k=de+De+Se;We(R,b,H,k)}}}function pe(te,de,I){l.push(te),l.push(de),l.push(I)}function Oe(te,de,I){ze(te),ze(de),ze(I);const De=i.length/3,re=y.generateTopUV(n,i,De-3,De-2,De-1);Je(re[0]),Je(re[1]),Je(re[2])}function We(te,de,I,De){ze(te),ze(de),ze(De),ze(de),ze(I),ze(De);const re=i.length/3,Ae=y.generateSideWallUV(n,i,re-6,re-3,re-2,re-1);Je(Ae[0]),Je(Ae[1]),Je(Ae[3]),Je(Ae[1]),Je(Ae[2]),Je(Ae[3])}function ze(te){i.push(l[te*3+0]),i.push(l[te*3+1]),i.push(l[te*3+2])}function Je(te){s.push(te.x),s.push(te.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Zm(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new go[i.type]().fromJSON(i)),new Qc(n,e.options)}}const Ym={generateTopUV:function(r,e,t,n,i){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new j(s,a),new j(o,l),new j(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],_=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new j(a,1-l),new j(c,1-u),new j(f,1-p),new j(_,1-m)]:[new j(o,1-l),new j(h,1-u),new j(d,1-p),new j(g,1-m)]}};function Zm(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class eh extends hs{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,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(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new eh(e.radius,e.detail)}}class Ro extends hs{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[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(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ro(e.radius,e.detail)}}class lr extends qe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,u=e/o,f=t/l,d=[],p=[],_=[],g=[];for(let m=0;m<h;m++){const y=m*f-a;for(let v=0;v<c;v++){const x=v*u-s;p.push(x,-y,0),_.push(0,0,1),g.push(v/o),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<o;y++){const v=y+c*m,x=y+c*(m+1),w=y+1+c*(m+1),T=y+1+c*m;d.push(v,x,T),d.push(x,w,T)}this.setIndex(d),this.setAttribute("position",new Fe(p,3)),this.setAttribute("normal",new Fe(_,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lr(e.width,e.height,e.widthSegments,e.heightSegments)}}class Io extends qe{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],h=[];let u=e;const f=(t-e)/i,d=new A,p=new j;for(let _=0;_<=i;_++){for(let g=0;g<=n;g++){const m=s+g/n*a;d.x=u*Math.cos(m),d.y=u*Math.sin(m),l.push(d.x,d.y,d.z),c.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}u+=f}for(let _=0;_<i;_++){const g=_*(n+1);for(let m=0;m<n;m++){const y=m+g,v=y,x=y+n+1,w=y+n+2,T=y+1;o.push(v,x,T),o.push(x,w,T)}}this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Io(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class th extends qe{constructor(e=new Js([new j(0,.5),new j(-.5,-.5),new j(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new Fe(i,3)),this.setAttribute("normal",new Fe(s,3)),this.setAttribute("uv",new Fe(a,2));function c(h){const u=i.length/3,f=h.extractPoints(t);let d=f.shape;const p=f.holes;oi.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];oi.isClockWise(y)===!0&&(p[g]=y.reverse())}const _=oi.triangulateShape(d,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];d=d.concat(y)}for(let g=0,m=d.length;g<m;g++){const y=d[g];i.push(y.x,y.y,0),s.push(0,0,1),a.push(y.x,y.y)}for(let g=0,m=_.length;g<m;g++){const y=_[g],v=y[0]+u,x=y[1]+u,w=y[2]+u;n.push(v,x,w),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Jm(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const a=t[e.shapes[i]];n.push(a)}return new th(n,e.curveSegments)}}function Jm(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class cr extends qe{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new A,f=new A,d=[],p=[],_=[],g=[];for(let m=0;m<=n;m++){const y=[],v=m/n;let x=0;m===0&&a===0?x=.5/t:m===n&&l===Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){const T=w/t;u.x=-e*Math.cos(i+T*s)*Math.sin(a+v*o),u.y=e*Math.cos(a+v*o),u.z=e*Math.sin(i+T*s)*Math.sin(a+v*o),p.push(u.x,u.y,u.z),f.copy(u).normalize(),_.push(f.x,f.y,f.z),g.push(T+x,1-v),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<t;y++){const v=h[m][y+1],x=h[m][y],w=h[m+1][y],T=h[m+1][y+1];(m!==0||a>0)&&d.push(v,x,T),(m!==n-1||l<Math.PI)&&d.push(x,w,T)}this.setIndex(d),this.setAttribute("position",new Fe(p,3)),this.setAttribute("normal",new Fe(_,3)),this.setAttribute("uv",new Fe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class nh extends hs{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nh(e.radius,e.detail)}}class ih extends qe{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new A,u=new A,f=new A;for(let d=0;d<=n;d++)for(let p=0;p<=i;p++){const _=p/i*s,g=d/n*Math.PI*2;u.x=(e+t*Math.cos(g))*Math.cos(_),u.y=(e+t*Math.cos(g))*Math.sin(_),u.z=t*Math.sin(g),o.push(u.x,u.y,u.z),h.x=e*Math.cos(_),h.y=e*Math.sin(_),f.subVectors(u,h).normalize(),l.push(f.x,f.y,f.z),c.push(p/i),c.push(d/n)}for(let d=1;d<=n;d++)for(let p=1;p<=i;p++){const _=(i+1)*d+p-1,g=(i+1)*(d-1)+p-1,m=(i+1)*(d-1)+p,y=(i+1)*d+p;a.push(_,g,y),a.push(g,m,y)}this.setIndex(a),this.setAttribute("position",new Fe(o,3)),this.setAttribute("normal",new Fe(l,3)),this.setAttribute("uv",new Fe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ih(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class sh extends qe{constructor(e=1,t=.4,n=64,i=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:a},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],u=new A,f=new A,d=new A,p=new A,_=new A,g=new A,m=new A;for(let v=0;v<=n;++v){const x=v/n*s*Math.PI*2;y(x,s,a,e,d),y(x+.01,s,a,e,p),g.subVectors(p,d),m.addVectors(p,d),_.crossVectors(g,m),m.crossVectors(_,g),_.normalize(),m.normalize();for(let w=0;w<=i;++w){const T=w/i*Math.PI*2,C=-t*Math.cos(T),P=t*Math.sin(T);u.x=d.x+(C*m.x+P*_.x),u.y=d.y+(C*m.y+P*_.y),u.z=d.z+(C*m.z+P*_.z),l.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),c.push(f.x,f.y,f.z),h.push(v/n),h.push(w/i)}}for(let v=1;v<=n;v++)for(let x=1;x<=i;x++){const w=(i+1)*(v-1)+(x-1),T=(i+1)*v+(x-1),C=(i+1)*v+x,P=(i+1)*(v-1)+x;o.push(w,T,P),o.push(T,C,P)}this.setIndex(o),this.setAttribute("position",new Fe(l,3)),this.setAttribute("normal",new Fe(c,3)),this.setAttribute("uv",new Fe(h,2));function y(v,x,w,T,C){const P=Math.cos(v),S=Math.sin(v),M=w/x*v,D=Math.cos(M);C.x=T*(2+D)*.5*P,C.y=T*(2+D)*S*.5,C.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sh(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class rh extends qe{constructor(e=new Od(new A(-1,-1,0),new A(-1,1,0),new A(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new A,l=new A,c=new j;let h=new A;const u=[],f=[],d=[],p=[];_(),this.setIndex(p),this.setAttribute("position",new Fe(u,3)),this.setAttribute("normal",new Fe(f,3)),this.setAttribute("uv",new Fe(d,2));function _(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),y(),m()}function g(v){h=e.getPointAt(v/t,h);const x=a.normals[v],w=a.binormals[v];for(let T=0;T<=i;T++){const C=T/i*Math.PI*2,P=Math.sin(C),S=-Math.cos(C);l.x=S*x.x+P*w.x,l.y=S*x.y+P*w.y,l.z=S*x.z+P*w.z,l.normalize(),f.push(l.x,l.y,l.z),o.x=h.x+n*l.x,o.y=h.y+n*l.y,o.z=h.z+n*l.z,u.push(o.x,o.y,o.z)}}function m(){for(let v=1;v<=t;v++)for(let x=1;x<=i;x++){const w=(i+1)*(v-1)+(x-1),T=(i+1)*v+(x-1),C=(i+1)*v+x,P=(i+1)*(v-1)+x;p.push(w,T,P),p.push(T,C,P)}}function y(){for(let v=0;v<=t;v++)for(let x=0;x<=i;x++)c.x=v/t,c.y=x/i,d.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new rh(new go[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Km extends qe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new A,s=new A;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],f=u.start,d=u.count;for(let p=f,_=f+d;p<_;p+=3)for(let g=0;g<3;g++){const m=o.getX(p+g),y=o.getX(p+(g+1)%3);i.fromBufferAttribute(a,m),s.fromBufferAttribute(a,y),lu(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const h=3*o+c,u=3*o+(c+1)%3;i.fromBufferAttribute(a,h),s.fromBufferAttribute(a,u),lu(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Fe(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function lu(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var cu=Object.freeze({__proto__:null,BoxGeometry:or,CapsuleGeometry:Jc,CircleGeometry:Kc,ConeGeometry:$c,CylinderGeometry:Zr,DodecahedronGeometry:jc,EdgesGeometry:Rm,ExtrudeGeometry:Qc,IcosahedronGeometry:eh,LatheGeometry:Ao,OctahedronGeometry:Ro,PlaneGeometry:lr,PolyhedronGeometry:hs,RingGeometry:Io,ShapeGeometry:th,SphereGeometry:cr,TetrahedronGeometry:nh,TorusGeometry:ih,TorusKnotGeometry:sh,TubeGeometry:rh,WireframeGeometry:Km});class $m extends on{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ne(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class jm extends Xt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ah extends on{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ne(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 ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Qm extends ah{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new j(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return et(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ne(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ne(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ne(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class eg extends on{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ne(16777215),this.specular=new ne(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.combine=bo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class tg extends on{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ne(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class ng extends on{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class ig extends on{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new In,this.combine=bo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Hd extends on{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Gd extends on{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class sg extends on{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ne(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cs,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class rg extends qt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function is(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Wd(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Xd(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function gc(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=r[o+l]}return i}function oh(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}function ag(r,e,t,n,i=30){const s=r.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],f=[];for(let d=0;d<c.times.length;++d){const p=c.times[d]*i;if(!(p<t||p>=n)){u.push(c.times[d]);for(let _=0;_<h;++_)f.push(c.values[d*h+_])}}u.length!==0&&(c.times=is(u,c.times.constructor),c.values=is(f,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function og(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let a=0;a<i;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(m){return m.name===o.name&&m.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0;const d=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);const p=o.times.length-1;let _;if(s<=o.times[0]){const m=h,y=u-h;_=o.values.slice(m,y)}else if(s>=o.times[p]){const m=p*u+h,y=m+u-h;_=o.values.slice(m,y)}else{const m=o.createInterpolant(),y=h,v=u-h;m.evaluate(s),_=m.resultBuffer.slice(y,v)}l==="quaternion"&&new rn().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let m=0;m<g;++m){const y=m*d+f;if(l==="quaternion")rn.multiplyQuaternionsFlat(c.values,y,_,0,c.values,y);else{const v=d-f*2;for(let x=0;x<v;++x)c.values[y+x]-=_[x]}}}return r.blendMode=yd,r}const jS={convertArray:is,isTypedArray:Wd,getKeyframeOrder:Xd,sortedArray:gc,flattenJSON:oh,subclip:ag,makeClipAdditive:og};class Po{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lg extends Po{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Bs,endingEnd:Bs}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case zs:s=e,o=2*t-n;break;case lo:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case zs:a=e,l=2*n-t;break;case lo:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),_=p*p,g=_*p,m=-f*g+2*f*_-f*p,y=(1+f)*g+(-1.5-2*f)*_+(-.5+f)*p+1,v=(-1-d)*g+(1.5+d)*_+.5*p,x=d*g-d*_;for(let w=0;w!==o;++w)s[w]=m*a[h+w]+y*a[c+w]+v*a[l+w]+x*a[u+w];return s}}class qd extends Po{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),u=1-h;for(let f=0;f!==o;++f)s[f]=a[c+f]*u+a[l+f]*h;return s}}class cg extends Po{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Gn{constructor(e,t,n,i){if(e===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 "+e);this.name=e,this.times=is(t,this.TimeBufferType),this.values=is(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:is(e.times,Array),values:is(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new cg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new qd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new lg(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case oo:t=this.InterpolantFactoryMethodDiscrete;break;case dc:t=this.InterpolantFactoryMethodLinear;break;case Fo:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return oo;case this.InterpolantFactoryMethodLinear:return dc;case this.InterpolantFactoryMethodSmooth:return Fo}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Wd(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Fo,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(i)l=!0;else{const u=o*n,f=u-n,d=u+n;for(let p=0;p!==n;++p){const _=t[u+p];if(_!==t[f+p]||_!==t[d+p]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const u=o*n,f=a*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Gn.prototype.TimeBufferType=Float32Array;Gn.prototype.ValueBufferType=Float32Array;Gn.prototype.DefaultInterpolation=dc;class hr extends Gn{constructor(e,t,n){super(e,t,n)}}hr.prototype.ValueTypeName="bool";hr.prototype.ValueBufferType=Array;hr.prototype.DefaultInterpolation=oo;hr.prototype.InterpolantFactoryMethodLinear=void 0;hr.prototype.InterpolantFactoryMethodSmooth=void 0;class Yd extends Gn{}Yd.prototype.ValueTypeName="color";class vo extends Gn{}vo.prototype.ValueTypeName="number";class hg extends Po{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)rn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Do extends Gn{InterpolantFactoryMethodLinear(e){return new hg(this.times,this.values,this.getValueSize(),e)}}Do.prototype.ValueTypeName="quaternion";Do.prototype.InterpolantFactoryMethodSmooth=void 0;class ur extends Gn{constructor(e,t,n){super(e,t,n)}}ur.prototype.ValueTypeName="string";ur.prototype.ValueBufferType=Array;ur.prototype.DefaultInterpolation=oo;ur.prototype.InterpolantFactoryMethodLinear=void 0;ur.prototype.InterpolantFactoryMethodSmooth=void 0;class xo extends Gn{}xo.prototype.ValueTypeName="vector";class yo{constructor(e="",t=-1,n=[],i=Oc){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(dg(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Gn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=Xd(l);l=gc(l,1,h),c=gc(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new vo(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let f=i[u];f||(i[u]=f=[]),f.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,f,d,p,_){if(d.length!==0){const g=[],m=[];oh(d,g,m,p),g.length!==0&&_.push(new u(f,g,m))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const f=c[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const d={};let p;for(p=0;p<f.length;p++)if(f[p].morphTargets)for(let _=0;_<f[p].morphTargets.length;_++)d[f[p].morphTargets[_]]=-1;for(const _ in d){const g=[],m=[];for(let y=0;y!==f[p].morphTargets.length;++y){const v=f[p];g.push(v.time),m.push(v.morphTarget===_?1:0)}i.push(new vo(".morphTargetInfluence["+_+"]",g,m))}l=d.length*a}else{const d=".bones["+t[u].name+"]";n(xo,d+".position",f,"pos",i),n(Do,d+".quaternion",f,"rot",i),n(xo,d+".scale",f,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function ug(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return vo;case"vector":case"vector2":case"vector3":case"vector4":return xo;case"color":return Yd;case"quaternion":return Do;case"bool":case"boolean":return hr;case"string":return ur}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function dg(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=ug(r.type);if(r.times===void 0){const t=[],n=[];oh(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const Ei={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Zd{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){const d=c[u],p=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}}const fg=new Zd;class wn{constructor(e){this.manager=e!==void 0?e:fg,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}wn.DEFAULT_MATERIAL_NAME="__DEFAULT";const $n={};class pg extends Error{constructor(e,t){super(e),this.response=t}}class Pi extends wn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Ei.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if($n[e]!==void 0){$n[e].push({onLoad:t,onProgress:n,onError:i});return}$n[e]=[],$n[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=$n[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0;let _=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:v,value:x})=>{if(v)m.close();else{_+=x.byteLength;const w=new ProgressEvent("progress",{lengthComputable:p,loaded:_,total:d});for(let T=0,C=h.length;T<C;T++){const P=h[T];P.onProgress&&P.onProgress(w)}m.enqueue(x),y()}},v=>{m.error(v)})}}});return new Response(g)}else throw new pg(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{Ei.add(e,c);const h=$n[e];delete $n[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{const h=$n[e];if(h===void 0)throw this.manager.itemError(e),c;delete $n[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class QS extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Pi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=yo.parse(e[n]);t.push(i)}return t}}class ew extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=[],o=new qc,l=new Pi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(e[u],function(f){const d=s.parse(f,!0);a[u]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},c+=1,c===6&&(d.mipmapCount===1&&(o.minFilter=Vt),o.image=a,o.format=d.format,o.needsUpdate=!0,t&&t(o))},n,i)}if(Array.isArray(e))for(let u=0,f=e.length;u<f;++u)h(u);else l.load(e,function(u){const f=s.parse(u,!0);if(f.isCubemap){const d=f.mipmaps.length/f.mipmapCount;for(let p=0;p<d;p++){a[p]={mipmaps:[]};for(let _=0;_<f.mipmapCount;_++)a[p].mipmaps.push(f.mipmaps[p*f.mipmapCount+_]),a[p].format=f.format,a[p].width=f.width,a[p].height=f.height}o.image=a}else o.image.width=f.width,o.image.height=f.height,o.mipmaps=f.mipmaps;f.mipmapCount===1&&(o.minFilter=Vt),o.format=f.format,o.needsUpdate=!0,t&&t(o)},n,i);return o}}class Mo extends wn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Ei.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Vr("img");function l(){h(),Ei.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){h(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class tw extends wn{constructor(e){super(e)}load(e,t,n,i){const s=new Eo;s.colorSpace=xn;const a=new Mo(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){s.images[c]=h,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}}class nw extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new ai,o=new Pi(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(h){if(i!==void 0)i(h);else{console.error(h);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Nn,a.wrapT=c.wrapT!==void 0?c.wrapT:Nn,a.magFilter=c.magFilter!==void 0?c.magFilter:Vt,a.minFilter=c.minFilter!==void 0?c.minFilter:Vt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=ni),c.mipmapCount===1&&(a.minFilter=Vt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class iw extends wn{constructor(e){super(e)}load(e,t,n,i){const s=new Et,a=new Mo(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class us extends mt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ne(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);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()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class mg extends us{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ne(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const pl=new Ze,hu=new A,uu=new A;class lh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new j(512,512),this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new To,this._frameExtents=new j(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;hu.setFromMatrixPosition(e.matrixWorld),t.position.copy(hu),uu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(uu),t.updateMatrixWorld(),pl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(pl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class gg extends lh{constructor(){super(new kt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=er*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class _g extends us{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new gg}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const du=new Ze,Tr=new A,ml=new A;class vg extends lh{constructor(){super(new kt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new j(4,2),this._viewportCount=6,this._viewports=[new pt(2,1,1,1),new pt(0,1,1,1),new pt(3,1,1,1),new pt(1,1,1,1),new pt(3,0,1,1),new pt(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Tr.setFromMatrixPosition(e.matrixWorld),n.position.copy(Tr),ml.copy(n.position),ml.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ml),n.updateMatrixWorld(),i.makeTranslation(-Tr.x,-Tr.y,-Tr.z),du.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(du)}}class _c extends us{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new vg}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Lo extends Hc{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class xg extends lh{constructor(){super(new Lo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class yg extends us{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.shadow=new xg}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Jd extends us{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Mg extends us{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class bg{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new A)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*i)),t.addScaledVector(a[5],1.092548*(i*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*i),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*i),t.addScaledVector(a[5],2*.429043*i*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}class Sg extends us{constructor(e=new bg,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class ch extends wn{constructor(e){super(e),this.textures={}}load(e,t,n,i){const s=this,a=new Pi(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const i=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new ne().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(i.dispersion=e.dispersion),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(i.depthFunc=e.depthFunc),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(i.blendSrc=e.blendSrc),e.blendDst!==void 0&&(i.blendDst=e.blendDst),e.blendEquation!==void 0&&(i.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(i.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(i.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==void 0&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new ne().setHex(a.value);break;case"v2":i.uniforms[s].value=new j().fromArray(a.value);break;case"v3":i.uniforms[s].value=new A().fromArray(a.value);break;case"v4":i.uniforms[s].value=new pt().fromArray(a.value);break;case"m3":i.uniforms[s].value=new tt().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Ze().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new j().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new j().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return ch.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:$m,SpriteMaterial:rs,RawShaderMaterial:jm,ShaderMaterial:Xt,PointsMaterial:Ai,MeshPhysicalMaterial:Qm,MeshStandardMaterial:ah,MeshPhongMaterial:eg,MeshToonMaterial:tg,MeshNormalMaterial:ng,MeshLambertMaterial:ig,MeshDepthMaterial:Hd,MeshDistanceMaterial:Gd,MeshBasicMaterial:kn,MeshMatcapMaterial:sg,LineDashedMaterial:rg,LineBasicMaterial:qt,Material:on};return new t[e]}}class fu{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class wg extends qe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Eg extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Pi(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(d,p){if(t[p]!==void 0)return t[p];const g=d.interleavedBuffers[p],m=s(d,g.buffer),y=ks(g.type,m),v=new Wc(y,g.stride);return v.uuid=g.uuid,t[p]=v,v}function s(d,p){if(n[p]!==void 0)return n[p];const g=d.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const a=e.isInstancedBufferGeometry?new wg:new qe,o=e.data.index;if(o!==void 0){const d=ks(o.type,o.array);a.setIndex(new rt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let _;if(p.isInterleavedBufferAttribute){const g=i(e.data,p.data);_=new nr(g,p.itemSize,p.offset,p.normalized)}else{const g=ks(p.type,p.array),m=p.isInstancedBufferAttribute?Hr:rt;_=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(_.name=p.name),p.usage!==void 0&&_.setUsage(p.usage),a.setAttribute(d,_)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],_=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let v;if(y.isInterleavedBufferAttribute){const x=i(e.data,y.data);v=new nr(x,y.itemSize,y.offset,y.normalized)}else{const x=ks(y.type,y.array);v=new rt(x,y.itemSize,y.normalized)}y.name!==void 0&&(v.name=y.name),_.push(v)}a.morphAttributes[d]=_}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const _=u[d];a.addGroup(_.start,_.count,_.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const d=new A;f.center!==void 0&&d.fromArray(f.center),a.boundingSphere=new an(d,f.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class sw extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Pi(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+e+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?fu.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const s=new Pi(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,n),h=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,h),this.bindLightTargets(c),t!==void 0){let u=!1;for(const f in a)if(a[f].data instanceof HTMLImageElement){u=!0;break}u===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const s=new Js().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new Xc().fromJSON(e[s],i);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new Eg;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(l);break;default:l.type in cu?o=cu[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const s=new ch;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],s=yo.parse(i);t[s.uuid]=s}return t}parseImages(e,t){const n=this,i={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(h)}else return l.data?{data:ks(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Zd(t);s=new Mo(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c<h;c++){const u=e[c],f=u.url;if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p],m=o(g);m!==null&&(m instanceof HTMLImageElement?d.push(m):d.push(new ai(m.data,m.width,m.height)))}i[u.uuid]=new Vs(d)}else{const d=o(u.url);i[u.uuid]=new Vs(d)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await i.loadAsync(l)}else return a.data?{data:ks(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){i=new Mo(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u],p=await s(d);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new ai(p.data,p.width,p.height)))}n[l.uuid]=new Vs(h)}else{const h=await s(l.url);n[l.uuid]=new Vs(h)}}}return n}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const i={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];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);const l=t[o.image],c=l.data;let h;Array.isArray(c)?(h=new Eo,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new ai:h=new Et,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=n(o.mapping,Tg)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=n(o.wrap[0],pu),h.wrapT=n(o.wrap[1],pu)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.minFilter!==void 0&&(h.minFilter=n(o.minFilter,mu)),o.magFilter!==void 0&&(h.magFilter=n(o.magFilter,mu)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.userData!==void 0&&(h.userData=o.userData),i[o.uuid]=h}return i}parseObject(e,t,n,i,s){let a;function o(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function l(f){if(f!==void 0){if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(n[g])}return d}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function c(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let h,u;switch(e.type){case"Scene":a=new Cd,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new ne(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Gc(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Yr(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new kt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Lo(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Jd(e.color,e.intensity);break;case"DirectionalLight":a=new yg(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new _c(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Mg(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new _g(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new mg(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Sg().fromJSON(e);break;case"SkinnedMesh":h=o(e.geometry),u=l(e.material),a=new sm(h,u),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":h=o(e.geometry),u=l(e.material),a=new yt(h,u);break;case"InstancedMesh":h=o(e.geometry),u=l(e.material);const f=e.count,d=e.instanceMatrix,p=e.instanceColor;a=new Pd(h,u,f),a.instanceMatrix=new Hr(new Float32Array(d.array),16),p!==void 0&&(a.instanceColor=new Hr(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":h=o(e.geometry),u=l(e.material),a=new mm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,u),a.geometry=h,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(_=>{const g=new pn;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);const m=new an;return m.radius=_.sphereRadius,m.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:m}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new nm;break;case"Line":a=new Vn(o(e.geometry),l(e.material));break;case"LineLoop":a=new gm(o(e.geometry),l(e.material));break;case"LineSegments":a=new hi(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new as(o(e.geometry),l(e.material));break;case"Sprite":a=new ts(l(e.material));break;case"Group":a=new ns;break;case"Bone":a=new Id;break;default:a=new mt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let d=0;d<f.length;d++)a.add(this.parseObject(f[d],t,n,i,s))}if(e.animations!==void 0){const f=e.animations;for(let d=0;d<f.length;d++){const p=f[d];a.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const f=e.levels;for(let d=0;d<f.length;d++){const p=f[d],_=a.getObjectByProperty("uuid",p.object);_!==void 0&&a.addLevel(_,p.distance,p.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,i=e.getObjectByProperty("uuid",n);i!==void 0?t.target=i:t.target=new mt}})}}const Tg={UVMapping:Ic,CubeReflectionMapping:Ri,CubeRefractionMapping:os,EquirectangularReflectionMapping:io,EquirectangularRefractionMapping:so,CubeUVReflectionMapping:qr},pu={RepeatWrapping:ro,ClampToEdgeWrapping:Nn,MirroredRepeatWrapping:ao},mu={NearestFilter:Qt,NearestMipmapNearestFilter:hd,NearestMipmapLinearFilter:Cr,LinearFilter:Vt,LinearMipmapNearestFilter:Xa,LinearMipmapLinearFilter:ni};class rw extends wn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Ei.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Ei.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),Ei.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Ei.add(e,l),s.manager.itemStart(e)}}let Pa;class Kd{static getContext(){return Pa===void 0&&(Pa=new(window.AudioContext||window.webkitAudioContext)),Pa}static setContext(e){Pa=e}}class aw extends wn{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Pi(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Kd.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(e)}}}const gu=new Ze,_u=new Ze,Hi=new Ze;class ow{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new kt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new kt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Hi.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,a=t.near*Math.tan(ss*t.fov*.5)/t.zoom;let o,l;_u.elements[12]=-i,gu.elements[12]=i,o=-a*t.aspect+s,l=a*t.aspect+s,Hi.elements[0]=2*t.near/(l-o),Hi.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Hi),o=-a*t.aspect-s,l=a*t.aspect-s,Hi.elements[0]=2*t.near/(l-o),Hi.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Hi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(_u),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(gu)}}class Ag extends kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class $d{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=vu();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function vu(){return performance.now()}const Gi=new A,xu=new rn,Cg=new A,Wi=new A;class lw extends mt{constructor(){super(),this.type="AudioListener",this.context=Kd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new $d}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gi,xu,Cg),Wi.set(0,0,-1).applyQuaternion(xu),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gi.x,i),t.positionY.linearRampToValueAtTime(Gi.y,i),t.positionZ.linearRampToValueAtTime(Gi.z,i),t.forwardX.linearRampToValueAtTime(Wi.x,i),t.forwardY.linearRampToValueAtTime(Wi.y,i),t.forwardZ.linearRampToValueAtTime(Wi.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Gi.x,Gi.y,Gi.z),t.setOrientation(Wi.x,Wi.y,Wi.z,n.x,n.y,n.z)}}class Rg extends mt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);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(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const Xi=new A,yu=new rn,Ig=new A,qi=new A;class cw extends Rg{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Xi,yu,Ig),qi.set(0,0,1).applyQuaternion(yu);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Xi.x,n),t.positionY.linearRampToValueAtTime(Xi.y,n),t.positionZ.linearRampToValueAtTime(Xi.z,n),t.orientationX.linearRampToValueAtTime(qi.x,n),t.orientationY.linearRampToValueAtTime(qi.y,n),t.orientationZ.linearRampToValueAtTime(qi.z,n)}else t.setPosition(Xi.x,Xi.y,Xi.z),t.setOrientation(qi.x,qi.y,qi.z)}}class hw{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Pg{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,a;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,a=i;s!==a;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){rn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const a=this._workIndex*s;rn.multiplyQuaternionsFlat(e,a,e,t,e,n),rn.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*i}}}const hh="\\[\\]\\.:\\/",Dg=new RegExp("["+hh+"]","g"),uh="[^"+hh+"]",Lg="[^"+hh.replace("\\.","")+"]",Ug=/((?:WC+[\/:])*)/.source.replace("WC",uh),Ng=/(WCOD+)?/.source.replace("WCOD",Lg),Fg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",uh),Og=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",uh),Bg=new RegExp("^"+Ug+Ng+Fg+Og+"$"),zg=["material","materials","bones","map"];class kg{constructor(e,t,n){const i=n||ft.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ft{constructor(e,t,n){this.path=t,this.parsedPath=n||ft.parseTrackName(t),this.node=ft.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ft.Composite(e,t,n):new ft(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Dg,"")}static parseTrackName(e){const t=Bg.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);zg.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=ft.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ft.Composite=kg;ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ft.prototype.GetterByBindingType=[ft.prototype._getValue_direct,ft.prototype._getValue_array,ft.prototype._getValue_arrayElement,ft.prototype._getValue_toArray];ft.prototype.SetterByBindingTypeAndVersioning=[[ft.prototype._setValue_direct,ft.prototype._setValue_direct_setNeedsUpdate,ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_array,ft.prototype._setValue_array_setNeedsUpdate,ft.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_arrayElement,ft.prototype._setValue_arrayElement_setNeedsUpdate,ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_fromArray,ft.prototype._setValue_fromArray_setNeedsUpdate,ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class uw{constructor(){this.isAnimationObjectGroup=!0,this.uuid=bn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const f=arguments[h],d=f.uuid;let p=t[d];if(p===void 0){p=l++,t[d]=p,e.push(f);for(let _=0,g=a;_!==g;++_)s[_].push(new ft(f,n[_],i[_]))}else if(p<c){o=e[p];const _=--c,g=e[_];t[g.uuid]=p,e[p]=g,t[d]=_,e[_]=f;for(let m=0,y=a;m!==y;++m){const v=s[m],x=v[_];let w=v[p];v[p]=x,w===void 0&&(w=new ft(f,n[m],i[m])),v[_]=w}}else e[p]!==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(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,h=t[c];if(h!==void 0&&h>=s){const u=s++,f=e[u];t[f.uuid]=h,e[h]=f,t[c]=u,e[u]=l;for(let d=0,p=i;d!==p;++d){const _=n[d],g=_[u],m=_[h];_[h]=g,_[u]=m}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u<s){const f=--s,d=e[f],p=--a,_=e[p];t[d.uuid]=u,e[u]=d,t[_.uuid]=f,e[f]=_,e.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],v=y[f],x=y[p];y[u]=v,y[f]=x,y.pop()}}else{const f=--a,d=e[f];f>0&&(t[d.uuid]=u),e[u]=d,e.pop();for(let p=0,_=i;p!==_;++p){const g=n[p];g[u]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[e]=i,a.push(e),o.push(t),s.push(u);for(let f=h,d=l.length;f!==d;++f){const p=l[f];u[f]=new ft(p,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class Vg{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:Bs,endingEnd:Bs};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ip,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,a=s/i,o=i/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case yd:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Oc:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const a=n===sp;if(e===0)return s===-1?i:a&&(s&1)===1?t-i:i;if(n===np){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=zs,i.endingEnd=zs):(e?i.endingStart=this.zeroSlopeAtStart?zs:Bs:i.endingStart=lo,t?i.endingEnd=this.zeroSlopeAtEnd?zs:Bs:i.endingEnd=lo)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const Hg=new Float32Array(1);class dw extends ci{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const f=i[u],d=f.name;let p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,d));continue}const _=t&&t._propertyBindings[u].binding.parsedPath;p=new Pg(ft.create(n,d,_),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,d),a[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,f=(e._localRoot||this._root).uuid;delete u[f],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let a=i[t];a===void 0&&(a={},i[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new qd(new Float32Array(2),new Float32Array(2),1,Hg),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let a=typeof e=="string"?yo.findByName(i,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Oc),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const h=new Vg(this,a,t,n);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?yo.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const h=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class fw extends zc{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new kc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class pw extends zc{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isRenderTargetArray=!0,this.depth=n,this.texture=new wo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class jd{constructor(e){this.value=e}clone(){return new jd(this.value.clone===void 0?this.value:this.value.clone())}}let Gg=0;class mw extends ci{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Gg++}),this.name="",this.usage=ho,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++){const s=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class gw extends Wc{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class _w{constructor(e,t,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Mu=new Ze;class Wg{constructor(e,t,n=0,i=1/0){this.ray=new ar(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Vc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.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: "+t.type)}setFromXRController(e){return Mu.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mu),this}intersectObject(e,t=!0,n=[]){return vc(e,this,n,t),n.sort(bu),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)vc(e[i],this,n,t);return n.sort(bu),n}}function bu(r,e){return r.distance-e.distance}function vc(r,e,t,n){let i=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)vc(s[a],e,t,!0)}}class xc{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=et(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(et(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class vw{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Qd{constructor(e,t,n,i){Qd.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=i,this}}const Su=new j;class xw{constructor(e=new j(1/0,1/0),t=new j(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Su.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Su).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const wu=new A,Da=new A;class yw{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){wu.subVectors(e,this.start),Da.subVectors(this.end,this.start);const n=Da.dot(Da);let s=Da.dot(wu)/n;return t&&(s=et(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Eu=new A;class Mw extends mt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new qe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,h=o/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Fe(i,3));const s=new qt({fog:!1,toneMapped:!1});this.cone=new hi(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Eu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Eu),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Mi=new A,La=new Ze,gl=new Ze;class bw extends hi{constructor(e){const t=ef(e),n=new qe,i=[],s=[],a=new ne(0,0,1),o=new ne(0,1,0);for(let c=0;c<t.length;c++){const h=t[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new Fe(i,3)),n.setAttribute("color",new Fe(s,3));const l=new qt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");gl.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(La.multiplyMatrices(gl,o.matrixWorld),Mi.setFromMatrixPosition(La),i.setXYZ(a,Mi.x,Mi.y,Mi.z),La.multiplyMatrices(gl,o.parent.matrixWorld),Mi.setFromMatrixPosition(La),i.setXYZ(a+1,Mi.x,Mi.y,Mi.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function ef(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,ef(r.children[t]));return e}class Sw extends yt{constructor(e,t,n){const i=new cr(t,4,2),s=new kn({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Xg=new A,Tu=new ne,Au=new ne;class ww extends mt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new Ro(t);i.rotateY(Math.PI*.5),this.material=new kn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),a=new Float32Array(s.count*3);i.setAttribute("color",new rt(a,3)),this.add(new yt(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Tu.copy(this.light.color),Au.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const s=n<i/2?Tu:Au;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Xg.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Ew extends hi{constructor(e=10,t=10,n=4473924,i=8947848){n=new ne(n),i=new ne(i);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let f=0,d=0,p=-o;f<=t;f++,p+=a){l.push(-o,0,p,o,0,p),l.push(p,0,-o,p,0,o);const _=f===s?n:i;_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3}const h=new qe;h.setAttribute("position",new Fe(l,3)),h.setAttribute("color",new Fe(c,3));const u=new qt({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Tw extends hi{constructor(e=10,t=16,n=8,i=64,s=4473924,a=8947848){s=new ne(s),a=new ne(a);const o=[],l=[];if(t>1)for(let u=0;u<t;u++){const f=u/t*(Math.PI*2),d=Math.sin(f)*e,p=Math.cos(f)*e;o.push(0,0,0),o.push(d,0,p);const _=u&1?s:a;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let u=0;u<n;u++){const f=u&1?s:a,d=e-e/n*u;for(let p=0;p<i;p++){let _=p/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d;o.push(g,0,m),l.push(f.r,f.g,f.b),_=(p+1)/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d,o.push(g,0,m),l.push(f.r,f.g,f.b)}}const c=new qe;c.setAttribute("position",new Fe(o,3)),c.setAttribute("color",new Fe(l,3));const h=new qt({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Cu=new A,Ua=new A,Ru=new A;class Aw extends mt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new qe;i.setAttribute("position",new Fe([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new qt({fog:!1,toneMapped:!1});this.lightPlane=new Vn(i,s),this.add(this.lightPlane),i=new qe,i.setAttribute("position",new Fe([0,0,0,0,0,1],3)),this.targetLine=new Vn(i,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(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Cu.setFromMatrixPosition(this.light.matrixWorld),Ua.setFromMatrixPosition(this.light.target.matrixWorld),Ru.subVectors(Ua,Cu),this.lightPlane.lookAt(Ua),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(Ua),this.targetLine.scale.z=Ru.length()}}const Na=new A,At=new Hc;class Cw extends hi{constructor(e){const t=new qe,n=new qt({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(p,_){l(p),l(_)}function l(p){i.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(i.length/3-1)}t.setAttribute("position",new Fe(i,3)),t.setAttribute("color",new Fe(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new ne(16755200),h=new ne(16711680),u=new ne(43775),f=new ne(16777215),d=new ne(3355443);this.setColors(c,h,u,f,d)}setColors(e,t,n,i,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;At.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const s=this.camera.coordinateSystem===zn?-1:0;Ct("c",t,e,At,0,0,s),Ct("t",t,e,At,0,0,1),Ct("n1",t,e,At,-n,-i,s),Ct("n2",t,e,At,n,-i,s),Ct("n3",t,e,At,-n,i,s),Ct("n4",t,e,At,n,i,s),Ct("f1",t,e,At,-n,-i,1),Ct("f2",t,e,At,n,-i,1),Ct("f3",t,e,At,-n,i,1),Ct("f4",t,e,At,n,i,1),Ct("u1",t,e,At,n*.7,i*1.1,s),Ct("u2",t,e,At,-n*.7,i*1.1,s),Ct("u3",t,e,At,0,i*2,s),Ct("cf1",t,e,At,-n,0,1),Ct("cf2",t,e,At,n,0,1),Ct("cf3",t,e,At,0,-i,1),Ct("cf4",t,e,At,0,i,1),Ct("cn1",t,e,At,-n,0,s),Ct("cn2",t,e,At,n,0,s),Ct("cn3",t,e,At,0,-i,s),Ct("cn4",t,e,At,0,i,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Ct(r,e,t,n,i,s,a){Na.set(i,s,a).unproject(n);const o=e[r];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],Na.x,Na.y,Na.z)}}const Fa=new pn;class Rw extends hi{constructor(e,t=16776960){const n=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]),i=new Float32Array(24),s=new qe;s.setIndex(new rt(n,1)),s.setAttribute("position",new rt(i,3)),super(s,new qt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Fa.setFromObject(this.object),Fa.isEmpty())return;const t=Fa.min,n=Fa.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Iw extends hi{constructor(e,t=16776960){const n=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]),i=[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 qe;s.setIndex(new rt(n,1)),s.setAttribute("position",new Fe(i,3)),super(s,new qt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pw extends Vn{constructor(e,t=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new qe;a.setAttribute("position",new Fe(s,3)),a.computeBoundingSphere(),super(a,new qt({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new qe;l.setAttribute("position",new Fe(o,3)),l.computeBoundingSphere(),this.add(new yt(l,new kn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Iu=new A;let Oa,_l;class Dw extends mt{constructor(e=new A(0,0,1),t=new A(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Oa===void 0&&(Oa=new qe,Oa.setAttribute("position",new Fe([0,0,0,0,1,0],3)),_l=new Zr(0,.5,1,5,1),_l.translate(0,-.5,0)),this.position.copy(t),this.line=new Vn(Oa,new qt({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new yt(_l,new kn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Iu.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Iu,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Lw extends hi{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new qe;i.setAttribute("position",new Fe(t,3)),i.setAttribute("color",new Fe(n,3));const s=new qt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new ne,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Uw{constructor(){this.type="ShapePath",this.color=new ne,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _o,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,a){return this.currentPath.bezierCurveTo(e,t,n,i,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){const y=[];for(let v=0,x=m.length;v<x;v++){const w=m[v],T=new Js;T.curves=w.curves,y.push(T)}return y}function n(m,y){const v=y.length;let x=!1;for(let w=v-1,T=0;T<v;w=T++){let C=y[w],P=y[T],S=P.x-C.x,M=P.y-C.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(C=y[T],S=-S,P=y[w],M=-M),m.y<C.y||m.y>P.y)continue;if(m.y===C.y){if(m.x===C.x)return!0}else{const D=M*(m.x-C.x)-S*(m.y-C.y);if(D===0)return!0;if(D<0)continue;x=!x}}else{if(m.y!==C.y)continue;if(P.x<=m.x&&m.x<=C.x||C.x<=m.x&&m.x<=P.x)return!0}}return x}const i=oi.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new Js,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=e?!h:h;const u=[],f=[];let d=[],p=0,_;f[p]=void 0,d[p]=[];for(let m=0,y=s.length;m<y;m++)o=s[m],_=o.getPoints(),a=i(_),a=e?!a:a,a?(!h&&f[p]&&p++,f[p]={s:new Js,p:_},f[p].s.curves=o.curves,h&&p++,d[p]=[]):d[p].push({h:o,p:_[0]});if(!f[0])return t(s);if(f.length>1){let m=!1,y=0;for(let v=0,x=f.length;v<x;v++)u[v]=[];for(let v=0,x=f.length;v<x;v++){const w=d[v];for(let T=0;T<w.length;T++){const C=w[T];let P=!0;for(let S=0;S<f.length;S++)n(C.p,f[S].p)&&(v!==S&&y++,P?(P=!1,u[S].push(C)):m=!0);P&&u[v].push(C)}}y>0&&m===!1&&(d=u)}let g;for(let m=0,y=f.length;m<y;m++){l=f[m].s,c.push(l),g=d[m];for(let v=0,x=g.length;v<x;v++)l.holes.push(g[v].h)}return c}}class qg extends ci{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function Yg(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function Zg(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function Jg(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function yc(r,e,t,n){const i=Kg(n);switch(t){case pd:return r*e;case gd:return r*e;case _d:return r*e*2;case Uc:return r*e/i.components*i.byteLength;case So:return r*e/i.components*i.byteLength;case vd:return r*e*2/i.components*i.byteLength;case Nc:return r*e*2/i.components*i.byteLength;case md:return r*e*3/i.components*i.byteLength;case dn:return r*e*4/i.components*i.byteLength;case Fc:return r*e*4/i.components*i.byteLength;case qa:case Ya:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Za:case Ja:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Vl:case Gl:return Math.max(r,16)*Math.max(e,8)/4;case kl:case Hl:return Math.max(r,8)*Math.max(e,8)/2;case Wl:case Xl:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case ql:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Yl:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Jl:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case Kl:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case $l:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case Ka:case oc:case lc:return Math.ceil(r/4)*Math.ceil(e/4)*16;case xd:case cc:return Math.ceil(r/4)*Math.ceil(e/4)*8;case hc:case uc:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Kg(r){switch(r){case li:case ud:return{byteLength:1,components:1};case kr:case dd:case si:return{byteLength:2,components:1};case Dc:case Lc:return{byteLength:2,components:4};case Ii:case Pc:case Mn:return{byteLength:4,components:1};case fd:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}const Nw={contain:Yg,cover:Zg,fill:Jg,getByteLength:yc};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Rc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Rc);/**
|
||
* @license
|
||
* Copyright 2010-2024 Three.js Authors
|
||
* SPDX-License-Identifier: MIT
|
||
*/function tf(){let r=null,e=!1,t=null,n=null;function i(s,a){t(s,a),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function $g(r){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,f=r.createBuffer();r.bindBuffer(l,f),r.bufferData(l,c,h),o.onUploadCallback();let d;if(c instanceof Float32Array)d=r.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?d=r.HALF_FLOAT:d=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)d=r.SHORT;else if(c instanceof Uint32Array)d=r.UNSIGNED_INT;else if(c instanceof Int32Array)d=r.INT;else if(c instanceof Int8Array)d=r.BYTE;else if(c instanceof Uint8Array)d=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)d=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:d,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(r.bindBuffer(c,o),u.length===0)r.bufferSubData(c,0,h);else{u.sort((d,p)=>d.start-p.start);let f=0;for(let d=1;d<u.length;d++){const p=u[f],_=u[d];_.start<=p.start+p.count+1?p.count=Math.max(p.count,_.start+_.count-p.start):(++f,u[f]=_)}u.length=f+1;for(let d=0,p=u.length;d<p;d++){const _=u[d];r.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(r.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}var jg=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,Qg=`#ifdef USE_ALPHAHASH
|
||
const float ALPHA_HASH_SCALE = 0.05;
|
||
float hash2D( vec2 value ) {
|
||
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
||
}
|
||
float hash3D( vec3 value ) {
|
||
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
||
}
|
||
float getAlphaHashThreshold( vec3 position ) {
|
||
float maxDeriv = max(
|
||
length( dFdx( position.xyz ) ),
|
||
length( dFdy( position.xyz ) )
|
||
);
|
||
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
||
vec2 pixScales = vec2(
|
||
exp2( floor( log2( pixScale ) ) ),
|
||
exp2( ceil( log2( pixScale ) ) )
|
||
);
|
||
vec2 alpha = vec2(
|
||
hash3D( floor( pixScales.x * position.xyz ) ),
|
||
hash3D( floor( pixScales.y * position.xyz ) )
|
||
);
|
||
float lerpFactor = fract( log2( pixScale ) );
|
||
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
||
float a = min( lerpFactor, 1.0 - lerpFactor );
|
||
vec3 cases = vec3(
|
||
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
||
( x - 0.5 * a ) / ( 1.0 - a ),
|
||
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
||
);
|
||
float threshold = ( x < ( 1.0 - a ) )
|
||
? ( ( x < a ) ? cases.x : cases.y )
|
||
: cases.z;
|
||
return clamp( threshold , 1.0e-6, 1.0 );
|
||
}
|
||
#endif`,e0=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,t0=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,n0=`#ifdef USE_ALPHATEST
|
||
#ifdef ALPHA_TO_COVERAGE
|
||
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
||
if ( diffuseColor.a == 0.0 ) discard;
|
||
#else
|
||
if ( diffuseColor.a < alphaTest ) discard;
|
||
#endif
|
||
#endif`,i0=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,s0=`#ifdef USE_AOMAP
|
||
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
||
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
||
#if defined( USE_CLEARCOAT )
|
||
clearcoatSpecularIndirect *= ambientOcclusion;
|
||
#endif
|
||
#if defined( USE_SHEEN )
|
||
sheenSpecularIndirect *= ambientOcclusion;
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
||
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
||
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
||
#endif
|
||
#endif`,r0=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,a0=`#ifdef USE_BATCHING
|
||
#if ! defined( GL_ANGLE_multi_draw )
|
||
#define gl_DrawID _gl_DrawID
|
||
uniform int _gl_DrawID;
|
||
#endif
|
||
uniform highp sampler2D batchingTexture;
|
||
uniform highp usampler2D batchingIdTexture;
|
||
mat4 getBatchingMatrix( const in float i ) {
|
||
int size = textureSize( batchingTexture, 0 ).x;
|
||
int j = int( i ) * 4;
|
||
int x = j % size;
|
||
int y = j / size;
|
||
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
||
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
||
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
||
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
||
return mat4( v1, v2, v3, v4 );
|
||
}
|
||
float getIndirectIndex( const in int i ) {
|
||
int size = textureSize( batchingIdTexture, 0 ).x;
|
||
int x = i % size;
|
||
int y = i / size;
|
||
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
||
}
|
||
#endif
|
||
#ifdef USE_BATCHING_COLOR
|
||
uniform sampler2D batchingColorTexture;
|
||
vec3 getBatchingColor( const in float i ) {
|
||
int size = textureSize( batchingColorTexture, 0 ).x;
|
||
int j = int( i );
|
||
int x = j % size;
|
||
int y = j / size;
|
||
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
||
}
|
||
#endif`,o0=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,l0=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,c0=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,h0=`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_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
||
float G = G_BlinnPhong_Implicit( );
|
||
float D = D_BlinnPhong( shininess, dotNH );
|
||
return F * ( G * D );
|
||
} // validated`,u0=`#ifdef USE_IRIDESCENCE
|
||
const mat3 XYZ_TO_REC709 = mat3(
|
||
3.2404542, -0.9692660, 0.0556434,
|
||
-1.5371385, 1.8760108, -0.2040259,
|
||
-0.4985314, 0.0415560, 1.0572252
|
||
);
|
||
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
||
vec3 sqrtF0 = sqrt( fresnel0 );
|
||
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
||
}
|
||
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
||
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
||
}
|
||
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
||
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
||
}
|
||
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
||
float phase = 2.0 * PI * OPD * 1.0e-9;
|
||
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
||
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
||
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
||
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
||
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
||
xyz /= 1.0685e-7;
|
||
vec3 rgb = XYZ_TO_REC709 * xyz;
|
||
return rgb;
|
||
}
|
||
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
||
vec3 I;
|
||
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
||
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
||
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
||
if ( cosTheta2Sq < 0.0 ) {
|
||
return vec3( 1.0 );
|
||
}
|
||
float cosTheta2 = sqrt( cosTheta2Sq );
|
||
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
||
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
||
float T121 = 1.0 - R12;
|
||
float phi12 = 0.0;
|
||
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
||
float phi21 = PI - phi12;
|
||
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
||
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
||
vec3 phi23 = vec3( 0.0 );
|
||
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
||
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
||
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
||
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
||
vec3 phi = vec3( phi21 ) + phi23;
|
||
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
||
vec3 r123 = sqrt( R123 );
|
||
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
||
vec3 C0 = R12 + Rs;
|
||
I = C0;
|
||
vec3 Cm = Rs - T121;
|
||
for ( int m = 1; m <= 2; ++ m ) {
|
||
Cm *= r123;
|
||
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
||
I += Cm * Sm;
|
||
}
|
||
return max( I, vec3( 0.0 ) );
|
||
}
|
||
#endif`,d0=`#ifdef USE_BUMPMAP
|
||
uniform sampler2D bumpMap;
|
||
uniform float bumpScale;
|
||
vec2 dHdxy_fwd() {
|
||
vec2 dSTdx = dFdx( vBumpMapUv );
|
||
vec2 dSTdy = dFdy( vBumpMapUv );
|
||
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
||
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
||
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
||
return vec2( dBx, dBy );
|
||
}
|
||
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
||
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
||
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
||
vec3 vN = surf_norm;
|
||
vec3 R1 = cross( vSigmaY, vN );
|
||
vec3 R2 = cross( vN, vSigmaX );
|
||
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
||
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
||
return normalize( abs( fDet ) * surf_norm - vGrad );
|
||
}
|
||
#endif`,f0=`#if NUM_CLIPPING_PLANES > 0
|
||
vec4 plane;
|
||
#ifdef ALPHA_TO_COVERAGE
|
||
float distanceToPlane, distanceGradient;
|
||
float clipOpacity = 1.0;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
||
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
||
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
||
if ( clipOpacity == 0.0 ) discard;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
||
float unionClipOpacity = 1.0;
|
||
#pragma unroll_loop_start
|
||
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
||
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
||
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
||
}
|
||
#pragma unroll_loop_end
|
||
clipOpacity *= 1.0 - unionClipOpacity;
|
||
#endif
|
||
diffuseColor.a *= clipOpacity;
|
||
if ( diffuseColor.a == 0.0 ) discard;
|
||
#else
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
||
bool clipped = true;
|
||
#pragma unroll_loop_start
|
||
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
||
}
|
||
#pragma unroll_loop_end
|
||
if ( clipped ) discard;
|
||
#endif
|
||
#endif
|
||
#endif`,p0=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,m0=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,g0=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,_0=`#if defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#elif defined( USE_COLOR )
|
||
diffuseColor.rgb *= vColor;
|
||
#endif`,v0=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,x0=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,y0=`#if defined( USE_COLOR_ALPHA )
|
||
vColor = vec4( 1.0 );
|
||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
vColor = vec3( 1.0 );
|
||
#endif
|
||
#ifdef USE_COLOR
|
||
vColor *= color;
|
||
#endif
|
||
#ifdef USE_INSTANCING_COLOR
|
||
vColor.xyz *= instanceColor.xyz;
|
||
#endif
|
||
#ifdef USE_BATCHING_COLOR
|
||
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
||
vColor.xyz *= batchingColor.xyz;
|
||
#endif`,M0=`#define PI 3.141592653589793
|
||
#define PI2 6.283185307179586
|
||
#define PI_HALF 1.5707963267948966
|
||
#define RECIPROCAL_PI 0.3183098861837907
|
||
#define RECIPROCAL_PI2 0.15915494309189535
|
||
#define EPSILON 1e-6
|
||
#ifndef saturate
|
||
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
||
float pow2( const in float x ) { return x*x; }
|
||
vec3 pow2( const in vec3 x ) { return x*x; }
|
||
float pow3( const in float x ) { return x*x*x; }
|
||
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
||
highp float rand( const in vec2 uv ) {
|
||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||
return fract( sin( sn ) * c );
|
||
}
|
||
#ifdef HIGH_PRECISION
|
||
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||
#else
|
||
float precisionSafeLength( vec3 v ) {
|
||
float maxComponent = max3( abs( v ) );
|
||
return length( v / maxComponent ) * maxComponent;
|
||
}
|
||
#endif
|
||
struct IncidentLight {
|
||
vec3 color;
|
||
vec3 direction;
|
||
bool visible;
|
||
};
|
||
struct ReflectedLight {
|
||
vec3 directDiffuse;
|
||
vec3 directSpecular;
|
||
vec3 indirectDiffuse;
|
||
vec3 indirectSpecular;
|
||
};
|
||
#ifdef USE_ALPHAHASH
|
||
varying vec3 vPosition;
|
||
#endif
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
}
|
||
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||
}
|
||
mat3 transposeMat3( const in mat3 m ) {
|
||
mat3 tmp;
|
||
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
||
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
||
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
||
return tmp;
|
||
}
|
||
bool isPerspectiveMatrix( mat4 m ) {
|
||
return m[ 2 ][ 3 ] == - 1.0;
|
||
}
|
||
vec2 equirectUv( in vec3 dir ) {
|
||
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
||
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
return vec2( u, v );
|
||
}
|
||
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
||
return RECIPROCAL_PI * diffuseColor;
|
||
}
|
||
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
}
|
||
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
} // validated`,b0=`#ifdef ENVMAP_TYPE_CUBE_UV
|
||
#define cubeUV_minMipLevel 4.0
|
||
#define cubeUV_minTileSize 16.0
|
||
float getFace( vec3 direction ) {
|
||
vec3 absDirection = abs( direction );
|
||
float face = - 1.0;
|
||
if ( absDirection.x > absDirection.z ) {
|
||
if ( absDirection.x > absDirection.y )
|
||
face = direction.x > 0.0 ? 0.0 : 3.0;
|
||
else
|
||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
} else {
|
||
if ( absDirection.z > absDirection.y )
|
||
face = direction.z > 0.0 ? 2.0 : 5.0;
|
||
else
|
||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
}
|
||
return face;
|
||
}
|
||
vec2 getUV( vec3 direction, float face ) {
|
||
vec2 uv;
|
||
if ( face == 0.0 ) {
|
||
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
||
} else if ( face == 1.0 ) {
|
||
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
||
} else if ( face == 2.0 ) {
|
||
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
||
} else if ( face == 3.0 ) {
|
||
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
||
} else if ( face == 4.0 ) {
|
||
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
||
} else {
|
||
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
||
}
|
||
return 0.5 * ( uv + 1.0 );
|
||
}
|
||
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
||
float face = getFace( direction );
|
||
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
||
mipInt = max( mipInt, cubeUV_minMipLevel );
|
||
float faceSize = exp2( mipInt );
|
||
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
||
if ( face > 2.0 ) {
|
||
uv.y += faceSize;
|
||
face -= 3.0;
|
||
}
|
||
uv.x += face * faceSize;
|
||
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
||
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
||
uv.x *= CUBEUV_TEXEL_WIDTH;
|
||
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
||
#ifdef texture2DGradEXT
|
||
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
||
#else
|
||
return texture2D( envMap, uv ).rgb;
|
||
#endif
|
||
}
|
||
#define cubeUV_r0 1.0
|
||
#define cubeUV_m0 - 2.0
|
||
#define cubeUV_r1 0.8
|
||
#define cubeUV_m1 - 1.0
|
||
#define cubeUV_r4 0.4
|
||
#define cubeUV_m4 2.0
|
||
#define cubeUV_r5 0.305
|
||
#define cubeUV_m5 3.0
|
||
#define cubeUV_r6 0.21
|
||
#define cubeUV_m6 4.0
|
||
float roughnessToMip( float roughness ) {
|
||
float mip = 0.0;
|
||
if ( roughness >= cubeUV_r1 ) {
|
||
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
||
} else if ( roughness >= cubeUV_r4 ) {
|
||
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
||
} else if ( roughness >= cubeUV_r5 ) {
|
||
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
||
} else if ( roughness >= cubeUV_r6 ) {
|
||
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
||
} else {
|
||
mip = - 2.0 * log2( 1.16 * roughness ); }
|
||
return mip;
|
||
}
|
||
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
||
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
||
float mipF = fract( mip );
|
||
float mipInt = floor( mip );
|
||
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
||
if ( mipF == 0.0 ) {
|
||
return vec4( color0, 1.0 );
|
||
} else {
|
||
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
||
return vec4( mix( color0, color1, mipF ), 1.0 );
|
||
}
|
||
}
|
||
#endif`,S0=`vec3 transformedNormal = objectNormal;
|
||
#ifdef USE_TANGENT
|
||
vec3 transformedTangent = objectTangent;
|
||
#endif
|
||
#ifdef USE_BATCHING
|
||
mat3 bm = mat3( batchingMatrix );
|
||
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
||
transformedNormal = bm * transformedNormal;
|
||
#ifdef USE_TANGENT
|
||
transformedTangent = bm * transformedTangent;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_INSTANCING
|
||
mat3 im = mat3( instanceMatrix );
|
||
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
||
transformedNormal = im * transformedNormal;
|
||
#ifdef USE_TANGENT
|
||
transformedTangent = im * transformedTangent;
|
||
#endif
|
||
#endif
|
||
transformedNormal = normalMatrix * transformedNormal;
|
||
#ifdef FLIP_SIDED
|
||
transformedNormal = - transformedNormal;
|
||
#endif
|
||
#ifdef USE_TANGENT
|
||
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
||
#ifdef FLIP_SIDED
|
||
transformedTangent = - transformedTangent;
|
||
#endif
|
||
#endif`,w0=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,E0=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,T0=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,A0=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,C0="gl_FragColor = linearToOutputTexel( gl_FragColor );",R0=`vec4 LinearTransferOETF( in vec4 value ) {
|
||
return value;
|
||
}
|
||
vec4 sRGBTransferEOTF( in vec4 value ) {
|
||
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
||
}
|
||
vec4 sRGBTransferOETF( in vec4 value ) {
|
||
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
||
}`,I0=`#ifdef USE_ENVMAP
|
||
#ifdef ENV_WORLDPOS
|
||
vec3 cameraToFrag;
|
||
if ( isOrthographic ) {
|
||
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||
} else {
|
||
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
||
}
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
#ifdef ENVMAP_MODE_REFLECTION
|
||
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
||
#else
|
||
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
||
#endif
|
||
#else
|
||
vec3 reflectVec = vReflect;
|
||
#endif
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
||
#else
|
||
vec4 envColor = vec4( 0.0 );
|
||
#endif
|
||
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_MIX )
|
||
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_ADD )
|
||
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
||
#endif
|
||
#endif`,P0=`#ifdef USE_ENVMAP
|
||
uniform float envMapIntensity;
|
||
uniform float flipEnvMap;
|
||
uniform mat3 envMapRotation;
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#else
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
|
||
#endif`,D0=`#ifdef USE_ENVMAP
|
||
uniform float reflectivity;
|
||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
||
#define ENV_WORLDPOS
|
||
#endif
|
||
#ifdef ENV_WORLDPOS
|
||
varying vec3 vWorldPosition;
|
||
uniform float refractionRatio;
|
||
#else
|
||
varying vec3 vReflect;
|
||
#endif
|
||
#endif`,L0=`#ifdef USE_ENVMAP
|
||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
||
#define ENV_WORLDPOS
|
||
#endif
|
||
#ifdef ENV_WORLDPOS
|
||
|
||
varying vec3 vWorldPosition;
|
||
#else
|
||
varying vec3 vReflect;
|
||
uniform float refractionRatio;
|
||
#endif
|
||
#endif`,U0=`#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`,N0=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,F0=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,O0=`#ifdef USE_FOG
|
||
#ifdef FOG_EXP2
|
||
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
||
#else
|
||
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
||
#endif
|
||
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
||
#endif`,B0=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,z0=`#ifdef USE_GRADIENTMAP
|
||
uniform sampler2D gradientMap;
|
||
#endif
|
||
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
||
float dotNL = dot( normal, lightDirection );
|
||
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
||
#ifdef USE_GRADIENTMAP
|
||
return vec3( texture2D( gradientMap, coord ).r );
|
||
#else
|
||
vec2 fw = fwidth( coord ) * 0.5;
|
||
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
||
#endif
|
||
}`,k0=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,V0=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,H0=`varying vec3 vViewPosition;
|
||
struct LambertMaterial {
|
||
vec3 diffuseColor;
|
||
float specularStrength;
|
||
};
|
||
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
#define RE_Direct RE_Direct_Lambert
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,G0=`uniform bool receiveShadow;
|
||
uniform vec3 ambientLightColor;
|
||
#if defined( USE_LIGHT_PROBES )
|
||
uniform vec3 lightProbe[ 9 ];
|
||
#endif
|
||
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
||
float x = normal.x, y = normal.y, z = normal.z;
|
||
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
||
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
||
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
||
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
||
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
||
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
||
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
||
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
||
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
||
return result;
|
||
}
|
||
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
||
return irradiance;
|
||
}
|
||
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
||
vec3 irradiance = ambientLightColor;
|
||
return irradiance;
|
||
}
|
||
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
||
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
||
if ( cutoffDistance > 0.0 ) {
|
||
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
||
}
|
||
return distanceFalloff;
|
||
}
|
||
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
||
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
||
}
|
||
#if NUM_DIR_LIGHTS > 0
|
||
struct DirectionalLight {
|
||
vec3 direction;
|
||
vec3 color;
|
||
};
|
||
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
||
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
||
light.color = directionalLight.color;
|
||
light.direction = directionalLight.direction;
|
||
light.visible = true;
|
||
}
|
||
#endif
|
||
#if NUM_POINT_LIGHTS > 0
|
||
struct PointLight {
|
||
vec3 position;
|
||
vec3 color;
|
||
float distance;
|
||
float decay;
|
||
};
|
||
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
||
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
||
vec3 lVector = pointLight.position - geometryPosition;
|
||
light.direction = normalize( lVector );
|
||
float lightDistance = length( lVector );
|
||
light.color = pointLight.color;
|
||
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
||
light.visible = ( light.color != vec3( 0.0 ) );
|
||
}
|
||
#endif
|
||
#if NUM_SPOT_LIGHTS > 0
|
||
struct SpotLight {
|
||
vec3 position;
|
||
vec3 direction;
|
||
vec3 color;
|
||
float distance;
|
||
float decay;
|
||
float coneCos;
|
||
float penumbraCos;
|
||
};
|
||
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
||
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
||
vec3 lVector = spotLight.position - geometryPosition;
|
||
light.direction = normalize( lVector );
|
||
float angleCos = dot( light.direction, spotLight.direction );
|
||
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
||
if ( spotAttenuation > 0.0 ) {
|
||
float lightDistance = length( lVector );
|
||
light.color = spotLight.color * spotAttenuation;
|
||
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
||
light.visible = ( light.color != vec3( 0.0 ) );
|
||
} else {
|
||
light.color = vec3( 0.0 );
|
||
light.visible = false;
|
||
}
|
||
}
|
||
#endif
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
struct RectAreaLight {
|
||
vec3 color;
|
||
vec3 position;
|
||
vec3 halfWidth;
|
||
vec3 halfHeight;
|
||
};
|
||
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
||
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
||
#endif
|
||
#if NUM_HEMI_LIGHTS > 0
|
||
struct HemisphereLight {
|
||
vec3 direction;
|
||
vec3 skyColor;
|
||
vec3 groundColor;
|
||
};
|
||
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
||
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
||
float dotNL = dot( normal, hemiLight.direction );
|
||
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
||
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
||
return irradiance;
|
||
}
|
||
#endif`,W0=`#ifdef USE_ENVMAP
|
||
vec3 getIBLIrradiance( const in vec3 normal ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
||
return PI * envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 reflectVec = reflect( - viewDir, normal );
|
||
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
||
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
||
return envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 bentNormal = cross( bitangent, viewDir );
|
||
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
||
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
||
return getIBLRadiance( viewDir, bentNormal, roughness );
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#endif
|
||
#endif`,X0=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,q0=`varying vec3 vViewPosition;
|
||
struct ToonMaterial {
|
||
vec3 diffuseColor;
|
||
};
|
||
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
#define RE_Direct RE_Direct_Toon
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Y0=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,Z0=`varying vec3 vViewPosition;
|
||
struct BlinnPhongMaterial {
|
||
vec3 diffuseColor;
|
||
vec3 specularColor;
|
||
float specularShininess;
|
||
float specularStrength;
|
||
};
|
||
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
||
}
|
||
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
#define RE_Direct RE_Direct_BlinnPhong
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,J0=`PhysicalMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
||
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
||
material.roughness = min( material.roughness, 1.0 );
|
||
#ifdef IOR
|
||
material.ior = ior;
|
||
#ifdef USE_SPECULAR
|
||
float specularIntensityFactor = specularIntensity;
|
||
vec3 specularColorFactor = specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
||
#endif
|
||
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
||
#else
|
||
float specularIntensityFactor = 1.0;
|
||
vec3 specularColorFactor = vec3( 1.0 );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
||
#else
|
||
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
material.clearcoat = clearcoat;
|
||
material.clearcoatRoughness = clearcoatRoughness;
|
||
material.clearcoatF0 = vec3( 0.04 );
|
||
material.clearcoatF90 = 1.0;
|
||
#ifdef USE_CLEARCOATMAP
|
||
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
||
#endif
|
||
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
||
material.clearcoatRoughness += geometryRoughness;
|
||
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
material.dispersion = dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
material.iridescence = iridescence;
|
||
material.iridescenceIOR = iridescenceIOR;
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
||
#else
|
||
material.iridescenceThickness = iridescenceThicknessMaximum;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
material.sheenColor = sheenColor;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
||
#endif
|
||
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
#ifdef USE_ANISOTROPYMAP
|
||
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
||
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
||
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
||
#else
|
||
vec2 anisotropyV = anisotropyVector;
|
||
#endif
|
||
material.anisotropy = length( anisotropyV );
|
||
if( material.anisotropy == 0.0 ) {
|
||
anisotropyV = vec2( 1.0, 0.0 );
|
||
} else {
|
||
anisotropyV /= material.anisotropy;
|
||
material.anisotropy = saturate( material.anisotropy );
|
||
}
|
||
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
||
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
||
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
||
#endif`,K0=`struct PhysicalMaterial {
|
||
vec3 diffuseColor;
|
||
float roughness;
|
||
vec3 specularColor;
|
||
float specularF90;
|
||
float dispersion;
|
||
#ifdef USE_CLEARCOAT
|
||
float clearcoat;
|
||
float clearcoatRoughness;
|
||
vec3 clearcoatF0;
|
||
float clearcoatF90;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float iridescence;
|
||
float iridescenceIOR;
|
||
float iridescenceThickness;
|
||
vec3 iridescenceFresnel;
|
||
vec3 iridescenceF0;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
vec3 sheenColor;
|
||
float sheenRoughness;
|
||
#endif
|
||
#ifdef IOR
|
||
float ior;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
float transmission;
|
||
float transmissionAlpha;
|
||
float thickness;
|
||
float attenuationDistance;
|
||
vec3 attenuationColor;
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float anisotropy;
|
||
float alphaT;
|
||
vec3 anisotropyT;
|
||
vec3 anisotropyB;
|
||
#endif
|
||
};
|
||
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
||
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
||
vec3 sheenSpecularDirect = vec3( 0.0 );
|
||
vec3 sheenSpecularIndirect = vec3(0.0 );
|
||
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
||
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
||
float x2 = x * x;
|
||
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
||
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
||
}
|
||
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
float a2 = pow2( alpha );
|
||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
||
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
||
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
||
float v = 0.5 / ( gv + gl );
|
||
return saturate(v);
|
||
}
|
||
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
||
float a2 = alphaT * alphaB;
|
||
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
||
highp float v2 = dot( v, v );
|
||
float w2 = a2 / v2;
|
||
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
||
}
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
||
vec3 f0 = material.clearcoatF0;
|
||
float f90 = material.clearcoatF90;
|
||
float roughness = material.clearcoatRoughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
return F * ( V * D );
|
||
}
|
||
#endif
|
||
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 f0 = material.specularColor;
|
||
float f90 = material.specularF90;
|
||
float roughness = material.roughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
#ifdef USE_IRIDESCENCE
|
||
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float dotTL = dot( material.anisotropyT, lightDir );
|
||
float dotTV = dot( material.anisotropyT, viewDir );
|
||
float dotTH = dot( material.anisotropyT, halfDir );
|
||
float dotBL = dot( material.anisotropyB, lightDir );
|
||
float dotBV = dot( material.anisotropyB, viewDir );
|
||
float dotBH = dot( material.anisotropyB, halfDir );
|
||
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
||
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
||
#else
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
#endif
|
||
return F * ( V * D );
|
||
}
|
||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
const float LUT_SIZE = 64.0;
|
||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
float dotNV = saturate( dot( N, V ) );
|
||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
return uv;
|
||
}
|
||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
float l = length( f );
|
||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
}
|
||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
float x = dot( v1, v2 );
|
||
float y = abs( x );
|
||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
float v = a / b;
|
||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
return cross( v1, v2 ) * theta_sintheta;
|
||
}
|
||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
vec3 lightNormal = cross( v1, v2 );
|
||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
vec3 T1, T2;
|
||
T1 = normalize( V - N * dot( V, N ) );
|
||
T2 = - cross( N, T1 );
|
||
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
||
vec3 coords[ 4 ];
|
||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
vec3 vectorFormFactor = vec3( 0.0 );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
return vec3( result );
|
||
}
|
||
#if defined( USE_SHEEN )
|
||
float D_Charlie( float roughness, float dotNH ) {
|
||
float alpha = pow2( roughness );
|
||
float invAlpha = 1.0 / alpha;
|
||
float cos2h = dotNH * dotNH;
|
||
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
||
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
||
}
|
||
float V_Neubelt( float dotNV, float dotNL ) {
|
||
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
||
}
|
||
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float D = D_Charlie( sheenRoughness, dotNH );
|
||
float V = V_Neubelt( dotNV, dotNL );
|
||
return sheenColor * ( D * V );
|
||
}
|
||
#endif
|
||
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float r2 = roughness * roughness;
|
||
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
||
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
||
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
||
return saturate( DG * RECIPROCAL_PI );
|
||
}
|
||
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
||
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
||
vec4 r = roughness * c0 + c1;
|
||
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
||
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
||
return fab;
|
||
}
|
||
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||
return specularColor * fab.x + specularF90 * fab.y;
|
||
}
|
||
#ifdef USE_IRIDESCENCE
|
||
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#else
|
||
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#endif
|
||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||
#ifdef USE_IRIDESCENCE
|
||
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
||
#else
|
||
vec3 Fr = specularColor;
|
||
#endif
|
||
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
||
float Ess = fab.x + fab.y;
|
||
float Ems = 1.0 - Ess;
|
||
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
singleScatter += FssEss;
|
||
multiScatter += Fms * Ems;
|
||
}
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 normal = geometryNormal;
|
||
vec3 viewDir = geometryViewDir;
|
||
vec3 position = geometryPosition;
|
||
vec3 lightPos = rectAreaLight.position;
|
||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
vec3 lightColor = rectAreaLight.color;
|
||
float roughness = material.roughness;
|
||
vec3 rectCoords[ 4 ];
|
||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
vec4 t1 = texture2D( ltc_1, uv );
|
||
vec4 t2 = texture2D( ltc_2, uv );
|
||
mat3 mInv = mat3(
|
||
vec3( t1.x, 0, t1.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1.z, 0, t1.w )
|
||
);
|
||
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
}
|
||
#endif
|
||
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
||
vec3 ccIrradiance = dotNLcc * directLight.color;
|
||
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
||
#endif
|
||
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
#endif
|
||
vec3 singleScattering = vec3( 0.0 );
|
||
vec3 multiScattering = vec3( 0.0 );
|
||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
#ifdef USE_IRIDESCENCE
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
||
#else
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
||
#endif
|
||
vec3 totalScattering = singleScattering + multiScattering;
|
||
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
||
reflectedLight.indirectSpecular += radiance * singleScattering;
|
||
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
||
}
|
||
#define RE_Direct RE_Direct_Physical
|
||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
}`,$0=`
|
||
vec3 geometryPosition = - vViewPosition;
|
||
vec3 geometryNormal = normal;
|
||
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
||
#ifdef USE_CLEARCOAT
|
||
geometryClearcoatNormal = clearcoatNormal;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
||
if ( material.iridescenceThickness == 0.0 ) {
|
||
material.iridescence = 0.0;
|
||
} else {
|
||
material.iridescence = saturate( material.iridescence );
|
||
}
|
||
if ( material.iridescence > 0.0 ) {
|
||
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
||
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
||
}
|
||
#endif
|
||
IncidentLight directLight;
|
||
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
PointLight pointLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
pointLight = pointLights[ i ];
|
||
getPointLightInfo( pointLight, geometryPosition, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
||
pointLightShadow = pointLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
SpotLight spotLight;
|
||
vec4 spotColor;
|
||
vec3 spotLightCoord;
|
||
bool inSpotLightMap;
|
||
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
spotLight = spotLights[ i ];
|
||
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
||
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
||
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
||
#else
|
||
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#endif
|
||
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
||
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
||
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
||
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
||
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
||
#endif
|
||
#undef SPOT_LIGHT_MAP_INDEX
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
spotLightShadow = spotLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||
DirectionalLight directionalLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
directionalLight = directionalLights[ i ];
|
||
getDirectionalLightInfo( directionalLight, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||
directionalLightShadow = directionalLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||
RectAreaLight rectAreaLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||
rectAreaLight = rectAreaLights[ i ];
|
||
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if defined( RE_IndirectDiffuse )
|
||
vec3 iblIrradiance = vec3( 0.0 );
|
||
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||
#if defined( USE_LIGHT_PROBES )
|
||
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
||
#endif
|
||
#if ( NUM_HEMI_LIGHTS > 0 )
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
vec3 radiance = vec3( 0.0 );
|
||
vec3 clearcoatRadiance = vec3( 0.0 );
|
||
#endif`,j0=`#if defined( RE_IndirectDiffuse )
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
||
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
||
irradiance += lightMapIrradiance;
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
||
iblIrradiance += getIBLIrradiance( geometryNormal );
|
||
#endif
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
||
#ifdef USE_ANISOTROPY
|
||
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
||
#else
|
||
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
||
#endif
|
||
#endif`,Q0=`#if defined( RE_IndirectDiffuse )
|
||
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
#endif`,e_=`#if defined( USE_LOGDEPTHBUF )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,t_=`#if defined( USE_LOGDEPTHBUF )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,n_=`#ifdef USE_LOGDEPTHBUF
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,i_=`#ifdef USE_LOGDEPTHBUF
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,s_=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,r_=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,a_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
#if defined( USE_POINTS_UV )
|
||
vec2 uv = vUv;
|
||
#else
|
||
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_MAP
|
||
diffuseColor *= texture2D( map, uv );
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
||
#endif`,o_=`#if defined( USE_POINTS_UV )
|
||
varying vec2 vUv;
|
||
#else
|
||
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
uniform mat3 uvTransform;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,l_=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,c_=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,h_=`#ifdef USE_INSTANCING_MORPH
|
||
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
||
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
||
}
|
||
#endif`,u_=`#if defined( USE_MORPHCOLORS )
|
||
vColor *= morphTargetBaseInfluence;
|
||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||
#if defined( USE_COLOR_ALPHA )
|
||
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
||
#elif defined( USE_COLOR )
|
||
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
||
#endif
|
||
}
|
||
#endif`,d_=`#ifdef USE_MORPHNORMALS
|
||
objectNormal *= morphTargetBaseInfluence;
|
||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
||
}
|
||
#endif`,f_=`#ifdef USE_MORPHTARGETS
|
||
#ifndef USE_INSTANCING_MORPH
|
||
uniform float morphTargetBaseInfluence;
|
||
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
||
#endif
|
||
uniform sampler2DArray morphTargetsTexture;
|
||
uniform ivec2 morphTargetsTextureSize;
|
||
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
||
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
||
int y = texelIndex / morphTargetsTextureSize.x;
|
||
int x = texelIndex - y * morphTargetsTextureSize.x;
|
||
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
||
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
||
}
|
||
#endif`,p_=`#ifdef USE_MORPHTARGETS
|
||
transformed *= morphTargetBaseInfluence;
|
||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
||
}
|
||
#endif`,m_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
||
#ifdef FLAT_SHADED
|
||
vec3 fdx = dFdx( vViewPosition );
|
||
vec3 fdy = dFdy( vViewPosition );
|
||
vec3 normal = normalize( cross( fdx, fdy ) );
|
||
#else
|
||
vec3 normal = normalize( vNormal );
|
||
#ifdef DOUBLE_SIDED
|
||
normal *= faceDirection;
|
||
#endif
|
||
#endif
|
||
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
||
#ifdef USE_TANGENT
|
||
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
||
#else
|
||
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
||
#if defined( USE_NORMALMAP )
|
||
vNormalMapUv
|
||
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
||
vClearcoatNormalMapUv
|
||
#else
|
||
vUv
|
||
#endif
|
||
);
|
||
#endif
|
||
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
||
tbn[0] *= faceDirection;
|
||
tbn[1] *= faceDirection;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
#ifdef USE_TANGENT
|
||
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
||
#else
|
||
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
||
#endif
|
||
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
||
tbn2[0] *= faceDirection;
|
||
tbn2[1] *= faceDirection;
|
||
#endif
|
||
#endif
|
||
vec3 nonPerturbedNormal = normal;`,g_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
||
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
||
#ifdef FLIP_SIDED
|
||
normal = - normal;
|
||
#endif
|
||
#ifdef DOUBLE_SIDED
|
||
normal = normal * faceDirection;
|
||
#endif
|
||
normal = normalize( normalMatrix * normal );
|
||
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
||
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
||
mapN.xy *= normalScale;
|
||
normal = normalize( tbn * mapN );
|
||
#elif defined( USE_BUMPMAP )
|
||
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
||
#endif`,__=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,v_=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,x_=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,y_=`#ifdef USE_NORMALMAP
|
||
uniform sampler2D normalMap;
|
||
uniform vec2 normalScale;
|
||
#endif
|
||
#ifdef USE_NORMALMAP_OBJECTSPACE
|
||
uniform mat3 normalMatrix;
|
||
#endif
|
||
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
||
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
||
vec3 q0 = dFdx( eye_pos.xyz );
|
||
vec3 q1 = dFdy( eye_pos.xyz );
|
||
vec2 st0 = dFdx( uv.st );
|
||
vec2 st1 = dFdy( uv.st );
|
||
vec3 N = surf_norm;
|
||
vec3 q1perp = cross( q1, N );
|
||
vec3 q0perp = cross( N, q0 );
|
||
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
||
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
||
float det = max( dot( T, T ), dot( B, B ) );
|
||
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
||
return mat3( T * scale, B * scale, N );
|
||
}
|
||
#endif`,M_=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,b_=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,S_=`#ifdef USE_CLEARCOATMAP
|
||
uniform sampler2D clearcoatMap;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
uniform sampler2D clearcoatNormalMap;
|
||
uniform vec2 clearcoatNormalScale;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
uniform sampler2D clearcoatRoughnessMap;
|
||
#endif`,w_=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,E_=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,T_=`vec3 packNormalToRGB( const in vec3 normal ) {
|
||
return normalize( normal ) * 0.5 + 0.5;
|
||
}
|
||
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
||
return 2.0 * rgb.xyz - 1.0;
|
||
}
|
||
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
||
const float Inv255 = 1. / 255.;
|
||
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
||
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
||
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
||
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
||
vec4 packDepthToRGBA( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec4( 0., 0., 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec4( 1., 1., 1., 1. );
|
||
float vuf;
|
||
float af = modf( v * PackFactors.a, vuf );
|
||
float bf = modf( vuf * ShiftRight8, vuf );
|
||
float gf = modf( vuf * ShiftRight8, vuf );
|
||
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
||
}
|
||
vec3 packDepthToRGB( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec3( 0., 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec3( 1., 1., 1. );
|
||
float vuf;
|
||
float bf = modf( v * PackFactors.b, vuf );
|
||
float gf = modf( vuf * ShiftRight8, vuf );
|
||
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
||
}
|
||
vec2 packDepthToRG( const in float v ) {
|
||
if( v <= 0.0 )
|
||
return vec2( 0., 0. );
|
||
if( v >= 1.0 )
|
||
return vec2( 1., 1. );
|
||
float vuf;
|
||
float gf = modf( v * 256., vuf );
|
||
return vec2( vuf * Inv255, gf );
|
||
}
|
||
float unpackRGBAToDepth( const in vec4 v ) {
|
||
return dot( v, UnpackFactors4 );
|
||
}
|
||
float unpackRGBToDepth( const in vec3 v ) {
|
||
return dot( v, UnpackFactors3 );
|
||
}
|
||
float unpackRGToDepth( const in vec2 v ) {
|
||
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
||
}
|
||
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
||
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
||
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
||
}
|
||
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
||
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
||
}
|
||
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return ( viewZ + near ) / ( near - far );
|
||
}
|
||
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
||
return depth * ( near - far ) - near;
|
||
}
|
||
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
||
}
|
||
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
||
return ( near * far ) / ( ( far - near ) * depth - far );
|
||
}`,A_=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,C_=`vec4 mvPosition = vec4( transformed, 1.0 );
|
||
#ifdef USE_BATCHING
|
||
mvPosition = batchingMatrix * mvPosition;
|
||
#endif
|
||
#ifdef USE_INSTANCING
|
||
mvPosition = instanceMatrix * mvPosition;
|
||
#endif
|
||
mvPosition = modelViewMatrix * mvPosition;
|
||
gl_Position = projectionMatrix * mvPosition;`,R_=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,I_=`#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`,P_=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,D_=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,L_=`#if NUM_SPOT_LIGHT_COORDS > 0
|
||
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_MAPS > 0
|
||
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
||
#endif
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
struct SpotLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
||
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
||
}
|
||
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
||
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
||
}
|
||
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
||
float occlusion = 1.0;
|
||
vec2 distribution = texture2DDistribution( shadow, uv );
|
||
float hard_shadow = step( compare , distribution.x );
|
||
if (hard_shadow != 1.0 ) {
|
||
float distance = compare - distribution.x ;
|
||
float variance = max( 0.00000, distribution.y * distribution.y );
|
||
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
||
}
|
||
return occlusion;
|
||
}
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
shadowCoord.z += shadowBias;
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float dx0 = - texelSize.x * shadowRadius;
|
||
float dy0 = - texelSize.y * shadowRadius;
|
||
float dx1 = + texelSize.x * shadowRadius;
|
||
float dy1 = + texelSize.y * shadowRadius;
|
||
float dx2 = dx0 / 2.0;
|
||
float dy2 = dy0 / 2.0;
|
||
float dx3 = dx1 / 2.0;
|
||
float dy3 = dy1 / 2.0;
|
||
shadow = (
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
||
) * ( 1.0 / 17.0 );
|
||
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float dx = texelSize.x;
|
||
float dy = texelSize.y;
|
||
vec2 uv = shadowCoord.xy;
|
||
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
||
uv -= f * texelSize;
|
||
shadow = (
|
||
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
||
f.x ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
||
f.x ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
||
f.y ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
||
f.y ) +
|
||
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
||
f.x ),
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
||
f.x ),
|
||
f.y )
|
||
) * ( 1.0 / 9.0 );
|
||
#elif defined( SHADOWMAP_TYPE_VSM )
|
||
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
#else
|
||
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
#endif
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
||
vec3 absV = abs( v );
|
||
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
||
absV *= scaleToCube;
|
||
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
||
vec2 planar = v.xy;
|
||
float almostATexel = 1.5 * texelSizeY;
|
||
float almostOne = 1.0 - almostATexel;
|
||
if ( absV.z >= almostOne ) {
|
||
if ( v.z > 0.0 )
|
||
planar.x = 4.0 - v.x;
|
||
} else if ( absV.x >= almostOne ) {
|
||
float signX = sign( v.x );
|
||
planar.x = v.z * signX + 2.0 * signX;
|
||
} else if ( absV.y >= almostOne ) {
|
||
float signY = sign( v.y );
|
||
planar.x = v.x + 2.0 * signY + 2.0;
|
||
planar.y = v.z * signY - 2.0;
|
||
}
|
||
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
||
}
|
||
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
float shadow = 1.0;
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
|
||
float lightToPositionLength = length( lightToPosition );
|
||
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
||
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
||
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
||
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
||
shadow = (
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
||
) * ( 1.0 / 9.0 );
|
||
#else
|
||
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
||
#endif
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#endif`,U_=`#if NUM_SPOT_LIGHT_COORDS > 0
|
||
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
||
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
||
#endif
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
struct SpotLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#endif`,N_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
||
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||
vec4 shadowWorldPosition;
|
||
#endif
|
||
#if defined( USE_SHADOWMAP )
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
||
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_COORDS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
||
shadowWorldPosition = worldPosition;
|
||
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
||
#endif
|
||
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif`,F_=`float getShadowMask() {
|
||
float shadow = 1.0;
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
directionalLight = directionalLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
spotLight = spotLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
pointLight = pointLightShadows[ i ];
|
||
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
return shadow;
|
||
}`,O_=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,B_=`#ifdef USE_SKINNING
|
||
uniform mat4 bindMatrix;
|
||
uniform mat4 bindMatrixInverse;
|
||
uniform highp sampler2D boneTexture;
|
||
mat4 getBoneMatrix( const in float i ) {
|
||
int size = textureSize( boneTexture, 0 ).x;
|
||
int j = int( i ) * 4;
|
||
int x = j % size;
|
||
int y = j / size;
|
||
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
||
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
||
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
||
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
||
return mat4( v1, v2, v3, v4 );
|
||
}
|
||
#endif`,z_=`#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`,k_=`#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`,V_=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,H_=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,G_=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,W_=`#ifndef saturate
|
||
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
uniform float toneMappingExposure;
|
||
vec3 LinearToneMapping( vec3 color ) {
|
||
return saturate( toneMappingExposure * color );
|
||
}
|
||
vec3 ReinhardToneMapping( vec3 color ) {
|
||
color *= toneMappingExposure;
|
||
return saturate( color / ( vec3( 1.0 ) + color ) );
|
||
}
|
||
vec3 CineonToneMapping( vec3 color ) {
|
||
color *= toneMappingExposure;
|
||
color = max( vec3( 0.0 ), color - 0.004 );
|
||
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
||
}
|
||
vec3 RRTAndODTFit( vec3 v ) {
|
||
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
||
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
||
return a / b;
|
||
}
|
||
vec3 ACESFilmicToneMapping( vec3 color ) {
|
||
const mat3 ACESInputMat = mat3(
|
||
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
||
vec3( 0.04823, 0.01566, 0.83777 )
|
||
);
|
||
const mat3 ACESOutputMat = mat3(
|
||
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
||
vec3( -0.07367, -0.00605, 1.07602 )
|
||
);
|
||
color *= toneMappingExposure / 0.6;
|
||
color = ACESInputMat * color;
|
||
color = RRTAndODTFit( color );
|
||
color = ACESOutputMat * color;
|
||
return saturate( color );
|
||
}
|
||
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
||
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
||
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
||
vec3( - 0.0728, - 0.0083, 1.1187 )
|
||
);
|
||
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
||
vec3( 0.6274, 0.0691, 0.0164 ),
|
||
vec3( 0.3293, 0.9195, 0.0880 ),
|
||
vec3( 0.0433, 0.0113, 0.8956 )
|
||
);
|
||
vec3 agxDefaultContrastApprox( vec3 x ) {
|
||
vec3 x2 = x * x;
|
||
vec3 x4 = x2 * x2;
|
||
return + 15.5 * x4 * x2
|
||
- 40.14 * x4 * x
|
||
+ 31.96 * x4
|
||
- 6.868 * x2 * x
|
||
+ 0.4298 * x2
|
||
+ 0.1191 * x
|
||
- 0.00232;
|
||
}
|
||
vec3 AgXToneMapping( vec3 color ) {
|
||
const mat3 AgXInsetMatrix = mat3(
|
||
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
||
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
||
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
||
);
|
||
const mat3 AgXOutsetMatrix = mat3(
|
||
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
||
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
||
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
||
);
|
||
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
||
color *= toneMappingExposure;
|
||
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
||
color = AgXInsetMatrix * color;
|
||
color = max( color, 1e-10 ); color = log2( color );
|
||
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
||
color = clamp( color, 0.0, 1.0 );
|
||
color = agxDefaultContrastApprox( color );
|
||
color = AgXOutsetMatrix * color;
|
||
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
||
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
||
color = clamp( color, 0.0, 1.0 );
|
||
return color;
|
||
}
|
||
vec3 NeutralToneMapping( vec3 color ) {
|
||
const float StartCompression = 0.8 - 0.04;
|
||
const float Desaturation = 0.15;
|
||
color *= toneMappingExposure;
|
||
float x = min( color.r, min( color.g, color.b ) );
|
||
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
||
color -= offset;
|
||
float peak = max( color.r, max( color.g, color.b ) );
|
||
if ( peak < StartCompression ) return color;
|
||
float d = 1. - StartCompression;
|
||
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
||
color *= newPeak / peak;
|
||
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
||
return mix( color, vec3( newPeak ), g );
|
||
}
|
||
vec3 CustomToneMapping( vec3 color ) { return color; }`,X_=`#ifdef USE_TRANSMISSION
|
||
material.transmission = transmission;
|
||
material.transmissionAlpha = 1.0;
|
||
material.thickness = thickness;
|
||
material.attenuationDistance = attenuationDistance;
|
||
material.attenuationColor = attenuationColor;
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
||
#endif
|
||
vec3 pos = vWorldPosition;
|
||
vec3 v = normalize( cameraPosition - pos );
|
||
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
||
vec4 transmitted = getIBLVolumeRefraction(
|
||
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
||
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
||
material.attenuationColor, material.attenuationDistance );
|
||
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
||
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
||
#endif`,q_=`#ifdef USE_TRANSMISSION
|
||
uniform float transmission;
|
||
uniform float thickness;
|
||
uniform float attenuationDistance;
|
||
uniform vec3 attenuationColor;
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
uniform sampler2D transmissionMap;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
uniform sampler2D thicknessMap;
|
||
#endif
|
||
uniform vec2 transmissionSamplerSize;
|
||
uniform sampler2D transmissionSamplerMap;
|
||
uniform mat4 modelMatrix;
|
||
uniform mat4 projectionMatrix;
|
||
varying vec3 vWorldPosition;
|
||
float w0( float a ) {
|
||
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
||
}
|
||
float w1( float a ) {
|
||
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
||
}
|
||
float w2( float a ){
|
||
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
||
}
|
||
float w3( float a ) {
|
||
return ( 1.0 / 6.0 ) * ( a * a * a );
|
||
}
|
||
float g0( float a ) {
|
||
return w0( a ) + w1( a );
|
||
}
|
||
float g1( float a ) {
|
||
return w2( a ) + w3( a );
|
||
}
|
||
float h0( float a ) {
|
||
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
||
}
|
||
float h1( float a ) {
|
||
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
||
}
|
||
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
||
uv = uv * texelSize.zw + 0.5;
|
||
vec2 iuv = floor( uv );
|
||
vec2 fuv = fract( uv );
|
||
float g0x = g0( fuv.x );
|
||
float g1x = g1( fuv.x );
|
||
float h0x = h0( fuv.x );
|
||
float h1x = h1( fuv.x );
|
||
float h0y = h0( fuv.y );
|
||
float h1y = h1( fuv.y );
|
||
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
||
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
||
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
||
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
||
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
||
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
||
}
|
||
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
||
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
||
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
||
vec2 fLodSizeInv = 1.0 / fLodSize;
|
||
vec2 cLodSizeInv = 1.0 / cLodSize;
|
||
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
||
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
||
return mix( fSample, cSample, fract( lod ) );
|
||
}
|
||
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
||
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
||
vec3 modelScale;
|
||
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
||
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
||
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
||
return normalize( refractionVector ) * thickness * modelScale;
|
||
}
|
||
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
||
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
||
}
|
||
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
||
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
||
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
||
}
|
||
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
||
if ( isinf( attenuationDistance ) ) {
|
||
return vec3( 1.0 );
|
||
} else {
|
||
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
||
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
||
}
|
||
}
|
||
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
||
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
||
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
||
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
||
vec4 transmittedLight;
|
||
vec3 transmittance;
|
||
#ifdef USE_DISPERSION
|
||
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
||
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
||
for ( int i = 0; i < 3; i ++ ) {
|
||
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
||
vec3 refractedRayExit = position + transmissionRay;
|
||
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
||
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
||
refractionCoords += 1.0;
|
||
refractionCoords /= 2.0;
|
||
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
||
transmittedLight[ i ] = transmissionSample[ i ];
|
||
transmittedLight.a += transmissionSample.a;
|
||
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
||
}
|
||
transmittedLight.a /= 3.0;
|
||
#else
|
||
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
||
vec3 refractedRayExit = position + transmissionRay;
|
||
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
||
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
||
refractionCoords += 1.0;
|
||
refractionCoords /= 2.0;
|
||
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
||
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
||
#endif
|
||
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
||
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
||
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
||
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
||
}
|
||
#endif`,Y_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
||
varying vec2 vUv;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
varying vec2 vMapUv;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
varying vec2 vAlphaMapUv;
|
||
#endif
|
||
#ifdef USE_LIGHTMAP
|
||
varying vec2 vLightMapUv;
|
||
#endif
|
||
#ifdef USE_AOMAP
|
||
varying vec2 vAoMapUv;
|
||
#endif
|
||
#ifdef USE_BUMPMAP
|
||
varying vec2 vBumpMapUv;
|
||
#endif
|
||
#ifdef USE_NORMALMAP
|
||
varying vec2 vNormalMapUv;
|
||
#endif
|
||
#ifdef USE_EMISSIVEMAP
|
||
varying vec2 vEmissiveMapUv;
|
||
#endif
|
||
#ifdef USE_METALNESSMAP
|
||
varying vec2 vMetalnessMapUv;
|
||
#endif
|
||
#ifdef USE_ROUGHNESSMAP
|
||
varying vec2 vRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_ANISOTROPYMAP
|
||
varying vec2 vAnisotropyMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOATMAP
|
||
varying vec2 vClearcoatMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
varying vec2 vClearcoatNormalMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
varying vec2 vClearcoatRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
varying vec2 vIridescenceMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
varying vec2 vIridescenceThicknessMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
varying vec2 vSheenColorMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
varying vec2 vSheenRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULARMAP
|
||
varying vec2 vSpecularMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
varying vec2 vSpecularColorMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
varying vec2 vSpecularIntensityMapUv;
|
||
#endif
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
uniform mat3 transmissionMapTransform;
|
||
varying vec2 vTransmissionMapUv;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
uniform mat3 thicknessMapTransform;
|
||
varying vec2 vThicknessMapUv;
|
||
#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
||
varying vec2 vUv;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
uniform mat3 mapTransform;
|
||
varying vec2 vMapUv;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
uniform mat3 alphaMapTransform;
|
||
varying vec2 vAlphaMapUv;
|
||
#endif
|
||
#ifdef USE_LIGHTMAP
|
||
uniform mat3 lightMapTransform;
|
||
varying vec2 vLightMapUv;
|
||
#endif
|
||
#ifdef USE_AOMAP
|
||
uniform mat3 aoMapTransform;
|
||
varying vec2 vAoMapUv;
|
||
#endif
|
||
#ifdef USE_BUMPMAP
|
||
uniform mat3 bumpMapTransform;
|
||
varying vec2 vBumpMapUv;
|
||
#endif
|
||
#ifdef USE_NORMALMAP
|
||
uniform mat3 normalMapTransform;
|
||
varying vec2 vNormalMapUv;
|
||
#endif
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
uniform mat3 displacementMapTransform;
|
||
varying vec2 vDisplacementMapUv;
|
||
#endif
|
||
#ifdef USE_EMISSIVEMAP
|
||
uniform mat3 emissiveMapTransform;
|
||
varying vec2 vEmissiveMapUv;
|
||
#endif
|
||
#ifdef USE_METALNESSMAP
|
||
uniform mat3 metalnessMapTransform;
|
||
varying vec2 vMetalnessMapUv;
|
||
#endif
|
||
#ifdef USE_ROUGHNESSMAP
|
||
uniform mat3 roughnessMapTransform;
|
||
varying vec2 vRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_ANISOTROPYMAP
|
||
uniform mat3 anisotropyMapTransform;
|
||
varying vec2 vAnisotropyMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOATMAP
|
||
uniform mat3 clearcoatMapTransform;
|
||
varying vec2 vClearcoatMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
uniform mat3 clearcoatNormalMapTransform;
|
||
varying vec2 vClearcoatNormalMapUv;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
uniform mat3 clearcoatRoughnessMapTransform;
|
||
varying vec2 vClearcoatRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
uniform mat3 sheenColorMapTransform;
|
||
varying vec2 vSheenColorMapUv;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
uniform mat3 sheenRoughnessMapTransform;
|
||
varying vec2 vSheenRoughnessMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
uniform mat3 iridescenceMapTransform;
|
||
varying vec2 vIridescenceMapUv;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform mat3 iridescenceThicknessMapTransform;
|
||
varying vec2 vIridescenceThicknessMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULARMAP
|
||
uniform mat3 specularMapTransform;
|
||
varying vec2 vSpecularMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
uniform mat3 specularColorMapTransform;
|
||
varying vec2 vSpecularColorMapUv;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
uniform mat3 specularIntensityMapTransform;
|
||
varying vec2 vSpecularIntensityMapUv;
|
||
#endif
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
uniform mat3 transmissionMapTransform;
|
||
varying vec2 vTransmissionMapUv;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
uniform mat3 thicknessMapTransform;
|
||
varying vec2 vThicknessMapUv;
|
||
#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
||
vUv = vec3( uv, 1 ).xy;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_LIGHTMAP
|
||
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_AOMAP
|
||
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_BUMPMAP
|
||
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_NORMALMAP
|
||
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_EMISSIVEMAP
|
||
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_METALNESSMAP
|
||
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_ANISOTROPYMAP
|
||
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_CLEARCOATMAP
|
||
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_SPECULARMAP
|
||
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
||
#endif`,K_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
||
vec4 worldPosition = vec4( transformed, 1.0 );
|
||
#ifdef USE_BATCHING
|
||
worldPosition = batchingMatrix * worldPosition;
|
||
#endif
|
||
#ifdef USE_INSTANCING
|
||
worldPosition = instanceMatrix * worldPosition;
|
||
#endif
|
||
worldPosition = modelMatrix * worldPosition;
|
||
#endif`;const $_=`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,j_=`uniform sampler2D t2D;
|
||
uniform float backgroundIntensity;
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vec4 texColor = texture2D( t2D, vUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,Q_=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,ev=`#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
uniform float flipEnvMap;
|
||
uniform float backgroundBlurriness;
|
||
uniform float backgroundIntensity;
|
||
uniform mat3 backgroundRotation;
|
||
varying vec3 vWorldDirection;
|
||
#include <cube_uv_reflection_fragment>
|
||
void main() {
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
||
#else
|
||
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,tv=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,nv=`uniform samplerCube tCube;
|
||
uniform float tFlip;
|
||
uniform float opacity;
|
||
varying vec3 vWorldDirection;
|
||
void main() {
|
||
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
||
gl_FragColor = texColor;
|
||
gl_FragColor.a *= opacity;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,iv=`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#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 <batching_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <morphinstance_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;
|
||
}`,sv=`#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 <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#if DEPTH_PACKING == 3200
|
||
diffuseColor.a = opacity;
|
||
#endif
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_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 );
|
||
#elif DEPTH_PACKING == 3202
|
||
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
||
#elif DEPTH_PACKING == 3203
|
||
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
||
#endif
|
||
}`,rv=`#define DISTANCE
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#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 <batching_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <morphinstance_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;
|
||
}`,av=`#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 <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main () {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
float dist = length( vWorldPosition - referencePosition );
|
||
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
||
dist = saturate( dist );
|
||
gl_FragColor = packDepthToRGBA( dist );
|
||
}`,ov=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,lv=`uniform sampler2D tEquirect;
|
||
varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vec3 direction = normalize( vWorldDirection );
|
||
vec2 sampleUV = equirectUv( direction );
|
||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,cv=`uniform float scale;
|
||
attribute float lineDistance;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#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 <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
}`,hv=`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform float dashSize;
|
||
uniform float totalSize;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
||
discard;
|
||
}
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,uv=`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_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 <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#endif
|
||
#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 <fog_vertex>
|
||
}`,dv=`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 <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_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, vLightMapUv );
|
||
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
||
#else
|
||
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
||
#endif
|
||
#include <aomap_fragment>
|
||
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
||
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,fv=`#define LAMBERT
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_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 <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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>
|
||
}`,pv=`#define LAMBERT
|
||
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 <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_lambert_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() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
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 <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_lambert_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,mv=`#define MATCAP
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_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 <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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;
|
||
}`,gv=`#define MATCAP
|
||
uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform sampler2D matcap;
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <normal_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_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 );
|
||
#else
|
||
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
||
#endif
|
||
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,_v=`#define NORMAL
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <normal_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 <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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( USE_NORMALMAP_TANGENTSPACE )
|
||
vViewPosition = - mvPosition.xyz;
|
||
#endif
|
||
}`,vv=`#define NORMAL
|
||
uniform float opacity;
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <normal_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
||
#ifdef OPAQUE
|
||
gl_FragColor.a = 1.0;
|
||
#endif
|
||
}`,xv=`#define PHONG
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_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 <color_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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>
|
||
}`,yv=`#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 <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#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() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
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 <alphahash_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>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,Mv=`#define STANDARD
|
||
varying vec3 vViewPosition;
|
||
#ifdef USE_TRANSMISSION
|
||
varying vec3 vWorldPosition;
|
||
#endif
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_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 <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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>
|
||
#ifdef USE_TRANSMISSION
|
||
vWorldPosition = worldPosition.xyz;
|
||
#endif
|
||
}`,bv=`#define STANDARD
|
||
#ifdef PHYSICAL
|
||
#define IOR
|
||
#define USE_SPECULAR
|
||
#endif
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float roughness;
|
||
uniform float metalness;
|
||
uniform float opacity;
|
||
#ifdef IOR
|
||
uniform float ior;
|
||
#endif
|
||
#ifdef USE_SPECULAR
|
||
uniform float specularIntensity;
|
||
uniform vec3 specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
uniform sampler2D specularColorMap;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
uniform sampler2D specularIntensityMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
uniform float clearcoat;
|
||
uniform float clearcoatRoughness;
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
uniform float dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
uniform float iridescence;
|
||
uniform float iridescenceIOR;
|
||
uniform float iridescenceThicknessMinimum;
|
||
uniform float iridescenceThicknessMaximum;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
uniform vec3 sheenColor;
|
||
uniform float sheenRoughness;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
uniform sampler2D sheenColorMap;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
uniform sampler2D sheenRoughnessMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
uniform vec2 anisotropyVector;
|
||
#ifdef USE_ANISOTROPYMAP
|
||
uniform sampler2D anisotropyMap;
|
||
#endif
|
||
#endif
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <iridescence_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_physical_pars_fragment>
|
||
#include <transmission_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <clearcoat_pars_fragment>
|
||
#include <iridescence_pars_fragment>
|
||
#include <roughnessmap_pars_fragment>
|
||
#include <metalnessmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
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 <alphahash_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 <lights_physical_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
||
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
||
#include <transmission_fragment>
|
||
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
||
#ifdef USE_SHEEN
|
||
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
||
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
||
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
||
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
||
#endif
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,Sv=`#define TOON
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_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 <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#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>
|
||
}`,wv=`#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 <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_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 <normal_pars_fragment>
|
||
#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() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
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 <alphahash_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;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,Ev=`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>
|
||
#ifdef USE_POINTS_UV
|
||
varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
#endif
|
||
void main() {
|
||
#ifdef USE_POINTS_UV
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
#endif
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_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>
|
||
}`,Tv=`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <map_particle_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_particle_fragment>
|
||
#include <color_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,Av=`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
void main() {
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_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 <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,Cv=`uniform vec3 color;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
void main() {
|
||
#include <logdepthbuf_fragment>
|
||
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
}`,Rv=`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[ 3 ];
|
||
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
||
#ifndef USE_SIZEATTENUATION
|
||
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
if ( isPerspective ) scale *= - mvPosition.z;
|
||
#endif
|
||
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
||
vec2 rotatedPosition;
|
||
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
||
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
||
mvPosition.xy += rotatedPosition;
|
||
gl_Position = projectionMatrix * mvPosition;
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
}`,Iv=`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
}`,st={alphahash_fragment:jg,alphahash_pars_fragment:Qg,alphamap_fragment:e0,alphamap_pars_fragment:t0,alphatest_fragment:n0,alphatest_pars_fragment:i0,aomap_fragment:s0,aomap_pars_fragment:r0,batching_pars_vertex:a0,batching_vertex:o0,begin_vertex:l0,beginnormal_vertex:c0,bsdfs:h0,iridescence_fragment:u0,bumpmap_pars_fragment:d0,clipping_planes_fragment:f0,clipping_planes_pars_fragment:p0,clipping_planes_pars_vertex:m0,clipping_planes_vertex:g0,color_fragment:_0,color_pars_fragment:v0,color_pars_vertex:x0,color_vertex:y0,common:M0,cube_uv_reflection_fragment:b0,defaultnormal_vertex:S0,displacementmap_pars_vertex:w0,displacementmap_vertex:E0,emissivemap_fragment:T0,emissivemap_pars_fragment:A0,colorspace_fragment:C0,colorspace_pars_fragment:R0,envmap_fragment:I0,envmap_common_pars_fragment:P0,envmap_pars_fragment:D0,envmap_pars_vertex:L0,envmap_physical_pars_fragment:W0,envmap_vertex:U0,fog_vertex:N0,fog_pars_vertex:F0,fog_fragment:O0,fog_pars_fragment:B0,gradientmap_pars_fragment:z0,lightmap_pars_fragment:k0,lights_lambert_fragment:V0,lights_lambert_pars_fragment:H0,lights_pars_begin:G0,lights_toon_fragment:X0,lights_toon_pars_fragment:q0,lights_phong_fragment:Y0,lights_phong_pars_fragment:Z0,lights_physical_fragment:J0,lights_physical_pars_fragment:K0,lights_fragment_begin:$0,lights_fragment_maps:j0,lights_fragment_end:Q0,logdepthbuf_fragment:e_,logdepthbuf_pars_fragment:t_,logdepthbuf_pars_vertex:n_,logdepthbuf_vertex:i_,map_fragment:s_,map_pars_fragment:r_,map_particle_fragment:a_,map_particle_pars_fragment:o_,metalnessmap_fragment:l_,metalnessmap_pars_fragment:c_,morphinstance_vertex:h_,morphcolor_vertex:u_,morphnormal_vertex:d_,morphtarget_pars_vertex:f_,morphtarget_vertex:p_,normal_fragment_begin:m_,normal_fragment_maps:g_,normal_pars_fragment:__,normal_pars_vertex:v_,normal_vertex:x_,normalmap_pars_fragment:y_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:b_,clearcoat_pars_fragment:S_,iridescence_pars_fragment:w_,opaque_fragment:E_,packing:T_,premultiplied_alpha_fragment:A_,project_vertex:C_,dithering_fragment:R_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:D_,shadowmap_pars_fragment:L_,shadowmap_pars_vertex:U_,shadowmap_vertex:N_,shadowmask_pars_fragment:F_,skinbase_vertex:O_,skinning_pars_vertex:B_,skinning_vertex:z_,skinnormal_vertex:k_,specularmap_fragment:V_,specularmap_pars_fragment:H_,tonemapping_fragment:G_,tonemapping_pars_fragment:W_,transmission_fragment:X_,transmission_pars_fragment:q_,uv_pars_fragment:Y_,uv_pars_vertex:Z_,uv_vertex:J_,worldpos_vertex:K_,background_vert:$_,background_frag:j_,backgroundCube_vert:Q_,backgroundCube_frag:ev,cube_vert:tv,cube_frag:nv,depth_vert:iv,depth_frag:sv,distanceRGBA_vert:rv,distanceRGBA_frag:av,equirect_vert:ov,equirect_frag:lv,linedashed_vert:cv,linedashed_frag:hv,meshbasic_vert:uv,meshbasic_frag:dv,meshlambert_vert:fv,meshlambert_frag:pv,meshmatcap_vert:mv,meshmatcap_frag:gv,meshnormal_vert:_v,meshnormal_frag:vv,meshphong_vert:xv,meshphong_frag:yv,meshphysical_vert:Mv,meshphysical_frag:bv,meshtoon_vert:Sv,meshtoon_frag:wv,points_vert:Ev,points_frag:Tv,shadow_vert:Av,shadow_frag:Cv,sprite_vert:Rv,sprite_frag:Iv},Te={common:{diffuse:{value:new ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tt}},envmap:{envMap:{value:null},envMapRotation:{value:new tt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tt},normalScale:{value:new j(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new ne(16777215)},opacity:{value:1},center:{value:new j(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}}},On={basic:{uniforms:nn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:nn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new ne(0)}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:nn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new ne(0)},specular:{value:new ne(1118481)},shininess:{value:30}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:nn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:nn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new ne(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:nn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:nn([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:nn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:nn([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:nn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:nn([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tt}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distanceRGBA:{uniforms:nn([Te.common,Te.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:st.distanceRGBA_vert,fragmentShader:st.distanceRGBA_frag},shadow:{uniforms:nn([Te.lights,Te.fog,{color:{value:new ne(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};On.physical={uniforms:nn([On.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tt},clearcoatNormalScale:{value:new j(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tt},sheen:{value:0},sheenColor:{value:new ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tt},transmissionSamplerSize:{value:new j},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tt},attenuationDistance:{value:0},attenuationColor:{value:new ne(0)},specularColor:{value:new ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tt},anisotropyVector:{value:new j},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tt}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};const Ba={r:0,b:0,g:0},Yi=new In,Pv=new Ze;function Dv(r,e,t,n,i,s,a){const o=new ne(0);let l=s===!0?0:1,c,h,u=null,f=0,d=null;function p(v){let x=v.isScene===!0?v.background:null;return x&&x.isTexture&&(x=(v.backgroundBlurriness>0?t:e).get(x)),x}function _(v){let x=!1;const w=p(v);w===null?m(o,l):w&&w.isColor&&(m(w,1),x=!0);const T=r.xr.getEnvironmentBlendMode();T==="additive"?n.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function g(v,x){const w=p(x);w&&(w.isCubeTexture||w.mapping===qr)?(h===void 0&&(h=new yt(new or(1,1,1),new Xt({name:"BackgroundCubeMaterial",uniforms:tr(On.backgroundCube.uniforms),vertexShader:On.backgroundCube.vertexShader,fragmentShader:On.backgroundCube.fragmentShader,side:fn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,C,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),Yi.copy(x.backgroundRotation),Yi.x*=-1,Yi.y*=-1,Yi.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Yi.y*=-1,Yi.z*=-1),h.material.uniforms.envMap.value=w,h.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Pv.makeRotationFromEuler(Yi)),h.material.toneMapped=ht.getTransfer(w.colorSpace)!==vt,(u!==w||f!==w.version||d!==r.toneMapping)&&(h.material.needsUpdate=!0,u=w,f=w.version,d=r.toneMapping),h.layers.enableAll(),v.unshift(h,h.geometry,h.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new yt(new lr(2,2),new Xt({name:"BackgroundMaterial",uniforms:tr(On.background.uniforms),vertexShader:On.background.vertexShader,fragmentShader:On.background.fragmentShader,side:Ci,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=ht.getTransfer(w.colorSpace)!==vt,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(u!==w||f!==w.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=w,f=w.version,d=r.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function m(v,x){v.getRGB(Ba,Ad(r)),n.buffers.color.setClear(Ba.r,Ba.g,Ba.b,x,a)}function y(){h!==void 0&&(h.geometry.dispose(),h.material.dispose()),c!==void 0&&(c.geometry.dispose(),c.material.dispose())}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,m(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,m(o,l)},render:_,addToRenderList:g,dispose:y}}function Lv(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=f(null);let s=i,a=!1;function o(M,D,G,F,V){let J=!1;const q=u(F,G,D);s!==q&&(s=q,c(s.object)),J=d(M,F,G,V),J&&p(M,F,G,V),V!==null&&e.update(V,r.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,x(M,D,G,F),V!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(V).buffer))}function l(){return r.createVertexArray()}function c(M){return r.bindVertexArray(M)}function h(M){return r.deleteVertexArray(M)}function u(M,D,G){const F=G.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let J=V[D.id];J===void 0&&(J={},V[D.id]=J);let q=J[F];return q===void 0&&(q=f(l()),J[F]=q),q}function f(M){const D=[],G=[],F=[];for(let V=0;V<t;V++)D[V]=0,G[V]=0,F[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:G,attributeDivisors:F,object:M,attributes:{},index:null}}function d(M,D,G,F){const V=s.attributes,J=D.attributes;let q=0;const se=G.getAttributes();for(const Z in se)if(se[Z].location>=0){const be=V[Z];let Re=J[Z];if(Re===void 0&&(Z==="instanceMatrix"&&M.instanceMatrix&&(Re=M.instanceMatrix),Z==="instanceColor"&&M.instanceColor&&(Re=M.instanceColor)),be===void 0||be.attribute!==Re||Re&&be.data!==Re.data)return!0;q++}return s.attributesNum!==q||s.index!==F}function p(M,D,G,F){const V={},J=D.attributes;let q=0;const se=G.getAttributes();for(const Z in se)if(se[Z].location>=0){let be=J[Z];be===void 0&&(Z==="instanceMatrix"&&M.instanceMatrix&&(be=M.instanceMatrix),Z==="instanceColor"&&M.instanceColor&&(be=M.instanceColor));const Re={};Re.attribute=be,be&&be.data&&(Re.data=be.data),V[Z]=Re,q++}s.attributes=V,s.attributesNum=q,s.index=F}function _(){const M=s.newAttributes;for(let D=0,G=M.length;D<G;D++)M[D]=0}function g(M){m(M,0)}function m(M,D){const G=s.newAttributes,F=s.enabledAttributes,V=s.attributeDivisors;G[M]=1,F[M]===0&&(r.enableVertexAttribArray(M),F[M]=1),V[M]!==D&&(r.vertexAttribDivisor(M,D),V[M]=D)}function y(){const M=s.newAttributes,D=s.enabledAttributes;for(let G=0,F=D.length;G<F;G++)D[G]!==M[G]&&(r.disableVertexAttribArray(G),D[G]=0)}function v(M,D,G,F,V,J,q){q===!0?r.vertexAttribIPointer(M,D,G,V,J):r.vertexAttribPointer(M,D,G,F,V,J)}function x(M,D,G,F){_();const V=F.attributes,J=G.getAttributes(),q=D.defaultAttributeValues;for(const se in J){const Z=J[se];if(Z.location>=0){let _e=V[se];if(_e===void 0&&(se==="instanceMatrix"&&M.instanceMatrix&&(_e=M.instanceMatrix),se==="instanceColor"&&M.instanceColor&&(_e=M.instanceColor)),_e!==void 0){const be=_e.normalized,Re=_e.itemSize,Ge=e.get(_e);if(Ge===void 0)continue;const it=Ge.buffer,Q=Ge.type,ue=Ge.bytesPerElement,Ie=Q===r.INT||Q===r.UNSIGNED_INT||_e.gpuType===Pc;if(_e.isInterleavedBufferAttribute){const pe=_e.data,Oe=pe.stride,We=_e.offset;if(pe.isInstancedInterleavedBuffer){for(let ze=0;ze<Z.locationSize;ze++)m(Z.location+ze,pe.meshPerAttribute);M.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let ze=0;ze<Z.locationSize;ze++)g(Z.location+ze);r.bindBuffer(r.ARRAY_BUFFER,it);for(let ze=0;ze<Z.locationSize;ze++)v(Z.location+ze,Re/Z.locationSize,Q,be,Oe*ue,(We+Re/Z.locationSize*ze)*ue,Ie)}else{if(_e.isInstancedBufferAttribute){for(let pe=0;pe<Z.locationSize;pe++)m(Z.location+pe,_e.meshPerAttribute);M.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=_e.meshPerAttribute*_e.count)}else for(let pe=0;pe<Z.locationSize;pe++)g(Z.location+pe);r.bindBuffer(r.ARRAY_BUFFER,it);for(let pe=0;pe<Z.locationSize;pe++)v(Z.location+pe,Re/Z.locationSize,Q,be,Re*ue,Re/Z.locationSize*pe*ue,Ie)}}else if(q!==void 0){const be=q[se];if(be!==void 0)switch(be.length){case 2:r.vertexAttrib2fv(Z.location,be);break;case 3:r.vertexAttrib3fv(Z.location,be);break;case 4:r.vertexAttrib4fv(Z.location,be);break;default:r.vertexAttrib1fv(Z.location,be)}}}}y()}function w(){P();for(const M in n){const D=n[M];for(const G in D){const F=D[G];for(const V in F)h(F[V].object),delete F[V];delete D[G]}delete n[M]}}function T(M){if(n[M.id]===void 0)return;const D=n[M.id];for(const G in D){const F=D[G];for(const V in F)h(F[V].object),delete F[V];delete D[G]}delete n[M.id]}function C(M){for(const D in n){const G=n[D];if(G[M.id]===void 0)continue;const F=G[M.id];for(const V in F)h(F[V].object),delete F[V];delete G[M.id]}}function P(){S(),a=!0,s!==i&&(s=i,c(s.object))}function S(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:P,resetDefaultState:S,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfProgram:C,initAttributes:_,enableAttribute:g,disableUnusedAttributes:y}}function Uv(r,e,t){let n;function i(c){n=c}function s(c,h){r.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,u){u!==0&&(r.drawArraysInstanced(n,c,h,u),t.update(h,n,u))}function o(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let d=0;for(let p=0;p<u;p++)d+=h[p];t.update(d,n,1)}function l(c,h,u,f){if(u===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let p=0;p<c.length;p++)a(c[p],h[p],f[p]);else{d.multiDrawArraysInstancedWEBGL(n,c,0,h,0,f,0,u);let p=0;for(let _=0;_<u;_++)p+=h[_]*f[_];t.update(p,n,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Nv(r,e,t,n){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=r.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(C){return!(C!==dn&&n.convert(C)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const P=C===si&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==li&&n.convert(C)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Mn&&!P)}function l(C){if(C==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,f=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),d=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),m=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),w=p>0,T=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:w,maxSamples:T}}function Fv(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new Si,o=new tt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){const d=u.length!==0||f||n!==0||i;return i=f,n=u.length,d},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){const p=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,m=r.get(u);if(!i||p===null||p.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,v=y*4;let x=m.clippingState||null;l.value=x,x=h(p,f,v,d);for(let w=0;w!==v;++w)x[w]=t[w];m.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,p){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,p!==!0||g===null){const m=d+_*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,x=d;v!==_;++v,x+=4)a.copy(u[v]).applyMatrix4(y,o),a.normal.toArray(g,x),g[x+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,g}}function Ov(r){let e=new WeakMap;function t(a,o){return o===io?a.mapping=Ri:o===so&&(a.mapping=os),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===io||o===so)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new tm(l.height);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const Gs=4,Pu=[.125,.215,.35,.446,.526,.582],es=20,vl=new Lo,Du=new ne;let xl=null,yl=0,Ml=0,bl=!1;const $i=(1+Math.sqrt(5))/2,Us=1/$i,Lu=[new A(-$i,Us,0),new A($i,Us,0),new A(-Us,0,$i),new A(Us,0,$i),new A(0,$i,-Us),new A(0,$i,Us),new A(-1,1,-1),new A(1,1,-1),new A(-1,1,1),new A(1,1,1)];class Uu{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){xl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Ml=this._renderer.getActiveMipmapLevel(),bl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ou(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(xl,yl,Ml),this._renderer.xr.enabled=bl,e.scissorTest=!1,za(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ri||e.mapping===os?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Ml=this._renderer.getActiveMipmapLevel(),bl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Vt,minFilter:Vt,generateMipmaps:!1,type:si,format:dn,colorSpace:Qs,depthBuffer:!1},i=Nu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Nu(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Bv(s)),this._blurMaterial=zv(s,e,t)}return i}_compileMaterial(e){const t=new yt(this._lodPlanes[0],e);this._renderer.compile(t,vl)}_sceneToCubeUV(e,t,n,i){const o=new kt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Du),h.toneMapping=Ti,h.autoClear=!1;const d=new kn({name:"PMREM.Background",side:fn,depthWrite:!1,depthTest:!1}),p=new yt(new or,d);let _=!1;const g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,_=!0):(d.color.copy(Du),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(o.up.set(0,l[m],0),o.lookAt(c[m],0,0)):y===1?(o.up.set(0,0,l[m]),o.lookAt(0,c[m],0)):(o.up.set(0,l[m],0),o.lookAt(0,0,c[m]));const v=this._cubeSize;za(i,y*v,m>2?v:0,v,v),h.setRenderTarget(i),_&&h.render(p,o),h.render(e,o)}p.geometry.dispose(),p.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Ri||e.mapping===os;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ou()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fu());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new yt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;za(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,vl)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Lu[(i-s-1)%Lu.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new yt(this._lodPlanes[i],c),f=c.uniforms,d=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*es-1),_=s/p,g=isFinite(s)?1+Math.floor(h*_):es;g>es&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${es}`);const m=[];let y=0;for(let C=0;C<es;++C){const P=C/_,S=Math.exp(-P*P/2);m.push(S),C===0?y+=S:C<g&&(y+=2*S)}for(let C=0;C<m.length;C++)m[C]=m[C]/y;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=m,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);const{_lodMax:v}=this;f.dTheta.value=p,f.mipInt.value=v-n;const x=this._sizeLods[i],w=3*x*(i>v-Gs?i-v+Gs:0),T=4*(this._cubeSize-x);za(t,w,T,3*x,2*x),l.setRenderTarget(t),l.render(u,vl)}}function Bv(r){const e=[],t=[],n=[];let i=r;const s=r-Gs+1+Pu.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>r-Gs?l=Pu[a-r+Gs-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,p=6,_=3,g=2,m=1,y=new Float32Array(_*p*d),v=new Float32Array(g*p*d),x=new Float32Array(m*p*d);for(let T=0;T<d;T++){const C=T%3*2/3-1,P=T>2?0:-1,S=[C,P,0,C+2/3,P,0,C+2/3,P+1,0,C,P,0,C+2/3,P+1,0,C,P+1,0];y.set(S,_*p*T),v.set(f,g*p*T);const M=[T,T,T,T,T,T];x.set(M,m*p*T)}const w=new qe;w.setAttribute("position",new rt(y,_)),w.setAttribute("uv",new rt(v,g)),w.setAttribute("faceIndex",new rt(x,m)),e.push(w),i>Gs&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Nu(r,e,t){const n=new Sn(r,e,t);return n.texture.mapping=qr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function za(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function zv(r,e,t){const n=new Float32Array(es),i=new A(0,1,0);return new Xt({name:"SphericalGaussianBlur",defines:{n:es,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:dh(),fragmentShader:`
|
||
|
||
precision mediump float;
|
||
precision mediump int;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform sampler2D envMap;
|
||
uniform int samples;
|
||
uniform float weights[ n ];
|
||
uniform bool latitudinal;
|
||
uniform float dTheta;
|
||
uniform float mipInt;
|
||
uniform vec3 poleAxis;
|
||
|
||
#define ENVMAP_TYPE_CUBE_UV
|
||
#include <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 );
|
||
|
||
}
|
||
|
||
}
|
||
`,blending:ii,depthTest:!1,depthWrite:!1})}function Fu(){return new Xt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dh(),fragmentShader:`
|
||
|
||
precision mediump float;
|
||
precision mediump int;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform sampler2D envMap;
|
||
|
||
#include <common>
|
||
|
||
void main() {
|
||
|
||
vec3 outputDirection = normalize( vOutputDirection );
|
||
vec2 uv = equirectUv( outputDirection );
|
||
|
||
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
||
|
||
}
|
||
`,blending:ii,depthTest:!1,depthWrite:!1})}function Ou(){return new Xt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dh(),fragmentShader:`
|
||
|
||
precision mediump float;
|
||
precision mediump int;
|
||
|
||
uniform float flipEnvMap;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform samplerCube envMap;
|
||
|
||
void main() {
|
||
|
||
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
||
|
||
}
|
||
`,blending:ii,depthTest:!1,depthWrite:!1})}function dh(){return`
|
||
|
||
precision mediump float;
|
||
precision mediump int;
|
||
|
||
attribute float faceIndex;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
// RH coordinate system; PMREM face-indexing convention
|
||
vec3 getDirection( vec2 uv, float face ) {
|
||
|
||
uv = 2.0 * uv - 1.0;
|
||
|
||
vec3 direction = vec3( uv, 1.0 );
|
||
|
||
if ( face == 0.0 ) {
|
||
|
||
direction = direction.zyx; // ( 1, v, u ) pos x
|
||
|
||
} else if ( face == 1.0 ) {
|
||
|
||
direction = direction.xzy;
|
||
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
||
|
||
} else if ( face == 2.0 ) {
|
||
|
||
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
||
|
||
} else if ( face == 3.0 ) {
|
||
|
||
direction = direction.zyx;
|
||
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
||
|
||
} else if ( face == 4.0 ) {
|
||
|
||
direction = direction.xzy;
|
||
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
||
|
||
} else if ( face == 5.0 ) {
|
||
|
||
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
||
|
||
}
|
||
|
||
return direction;
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
vOutputDirection = getDirection( uv, faceIndex );
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}
|
||
`}function kv(r){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===io||l===so,h=l===Ri||l===os;if(c||h){let u=e.get(o);const f=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==f)return t===null&&(t=new Uu(r)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const d=o.image;return c&&d&&d.height>0||h&&d&&i(d)?(t===null&&(t=new Uu(r)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function i(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Vv(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&Fs("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function Hv(r,e,t,n){const i={},s=new WeakMap;function a(u){const f=u.target;f.index!==null&&e.remove(f.index);for(const p in f.attributes)e.remove(f.attributes[p]);f.removeEventListener("dispose",a),delete i[f.id];const d=s.get(f);d&&(e.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(u,f){return i[f.id]===!0||(f.addEventListener("dispose",a),i[f.id]=!0,t.memory.geometries++),f}function l(u){const f=u.attributes;for(const d in f)e.update(f[d],r.ARRAY_BUFFER)}function c(u){const f=[],d=u.index,p=u.attributes.position;let _=0;if(d!==null){const y=d.array;_=d.version;for(let v=0,x=y.length;v<x;v+=3){const w=y[v+0],T=y[v+1],C=y[v+2];f.push(w,T,T,C,C,w)}}else if(p!==void 0){const y=p.array;_=p.version;for(let v=0,x=y.length/3-1;v<x;v+=3){const w=v+0,T=v+1,C=v+2;f.push(w,T,T,C,C,w)}}else return;const g=new(Sd(f)?Td:Ed)(f,1);g.version=_;const m=s.get(u);m&&e.remove(m),s.set(u,g)}function h(u){const f=s.get(u);if(f){const d=u.index;d!==null&&f.version<d.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function Gv(r,e,t){let n;function i(f){n=f}let s,a;function o(f){s=f.type,a=f.bytesPerElement}function l(f,d){r.drawElements(n,d,s,f*a),t.update(d,n,1)}function c(f,d,p){p!==0&&(r.drawElementsInstanced(n,d,s,f*a,p),t.update(d,n,p))}function h(f,d,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,s,f,0,p);let g=0;for(let m=0;m<p;m++)g+=d[m];t.update(g,n,1)}function u(f,d,p,_){if(p===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<f.length;m++)c(f[m]/a,d[m],_[m]);else{g.multiDrawElementsInstancedWEBGL(n,d,0,s,f,0,_,0,p);let m=0;for(let y=0;y<p;y++)m+=d[y]*_[y];t.update(m,n,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function Wv(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Xv(r,e,t){const n=new WeakMap,i=new pt;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let f=n.get(o);if(f===void 0||f.count!==u){let S=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",S)};f!==void 0&&f.texture.dispose();const d=o.morphAttributes.position!==void 0,p=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let v=0;d===!0&&(v=1),p===!0&&(v=2),_===!0&&(v=3);let x=o.attributes.position.count*v,w=1;x>e.maxTextureSize&&(w=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const T=new Float32Array(x*w*4*u),C=new wo(T,x,w,u);C.type=Mn,C.needsUpdate=!0;const P=v*4;for(let M=0;M<u;M++){const D=g[M],G=m[M],F=y[M],V=x*w*4*M;for(let J=0;J<D.count;J++){const q=J*P;d===!0&&(i.fromBufferAttribute(D,J),T[V+q+0]=i.x,T[V+q+1]=i.y,T[V+q+2]=i.z,T[V+q+3]=0),p===!0&&(i.fromBufferAttribute(G,J),T[V+q+4]=i.x,T[V+q+5]=i.y,T[V+q+6]=i.z,T[V+q+7]=0),_===!0&&(i.fromBufferAttribute(F,J),T[V+q+8]=i.x,T[V+q+9]=i.y,T[V+q+10]=i.z,T[V+q+11]=F.itemSize===4?i.w:1)}}f={count:u,texture:C,size:new j(x,w)},n.set(o,f),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",a.morphTexture,t);else{let d=0;for(let _=0;_<c.length;_++)d+=c[_];const p=o.morphTargetsRelative?1:1-d;l.getUniforms().setValue(r,"morphTargetBaseInfluence",p),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(r,"morphTargetsTextureSize",f.size)}return{update:s}}function qv(r,e,t,n){let i=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);if(i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;i.get(f)!==c&&(f.update(),i.set(f,c))}return u}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const nf=new Et,Bu=new Ld(1,1),sf=new wo,rf=new kc,af=new Eo,zu=[],ku=[],Vu=new Float32Array(16),Hu=new Float32Array(9),Gu=new Float32Array(4);function dr(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=zu[i];if(s===void 0&&(s=new Float32Array(i),zu[i]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function Ot(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Bt(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Uo(r,e){let t=ku[e];t===void 0&&(t=new Int32Array(e),ku[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function Yv(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function Zv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;r.uniform2fv(this.addr,e),Bt(t,e)}}function Jv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ot(t,e))return;r.uniform3fv(this.addr,e),Bt(t,e)}}function Kv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;r.uniform4fv(this.addr,e),Bt(t,e)}}function $v(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Bt(t,e)}else{if(Ot(t,n))return;Gu.set(n),r.uniformMatrix2fv(this.addr,!1,Gu),Bt(t,n)}}function jv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Bt(t,e)}else{if(Ot(t,n))return;Hu.set(n),r.uniformMatrix3fv(this.addr,!1,Hu),Bt(t,n)}}function Qv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Bt(t,e)}else{if(Ot(t,n))return;Vu.set(n),r.uniformMatrix4fv(this.addr,!1,Vu),Bt(t,n)}}function ex(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function tx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;r.uniform2iv(this.addr,e),Bt(t,e)}}function nx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ot(t,e))return;r.uniform3iv(this.addr,e),Bt(t,e)}}function ix(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;r.uniform4iv(this.addr,e),Bt(t,e)}}function sx(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function rx(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;r.uniform2uiv(this.addr,e),Bt(t,e)}}function ax(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ot(t,e))return;r.uniform3uiv(this.addr,e),Bt(t,e)}}function ox(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;r.uniform4uiv(this.addr,e),Bt(t,e)}}function lx(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);let s;this.type===r.SAMPLER_2D_SHADOW?(Bu.compareFunction=Md,s=Bu):s=nf,t.setTexture2D(e||s,i)}function cx(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||rf,i)}function hx(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||af,i)}function ux(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||sf,i)}function dx(r){switch(r){case 5126:return Yv;case 35664:return Zv;case 35665:return Jv;case 35666:return Kv;case 35674:return $v;case 35675:return jv;case 35676:return Qv;case 5124:case 35670:return ex;case 35667:case 35671:return tx;case 35668:case 35672:return nx;case 35669:case 35673:return ix;case 5125:return sx;case 36294:return rx;case 36295:return ax;case 36296:return ox;case 35678:case 36198:case 36298:case 36306:case 35682:return lx;case 35679:case 36299:case 36307:return cx;case 35680:case 36300:case 36308:case 36293:return hx;case 36289:case 36303:case 36311:case 36292:return ux}}function fx(r,e){r.uniform1fv(this.addr,e)}function px(r,e){const t=dr(e,this.size,2);r.uniform2fv(this.addr,t)}function mx(r,e){const t=dr(e,this.size,3);r.uniform3fv(this.addr,t)}function gx(r,e){const t=dr(e,this.size,4);r.uniform4fv(this.addr,t)}function _x(r,e){const t=dr(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function vx(r,e){const t=dr(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function xx(r,e){const t=dr(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function yx(r,e){r.uniform1iv(this.addr,e)}function Mx(r,e){r.uniform2iv(this.addr,e)}function bx(r,e){r.uniform3iv(this.addr,e)}function Sx(r,e){r.uniform4iv(this.addr,e)}function wx(r,e){r.uniform1uiv(this.addr,e)}function Ex(r,e){r.uniform2uiv(this.addr,e)}function Tx(r,e){r.uniform3uiv(this.addr,e)}function Ax(r,e){r.uniform4uiv(this.addr,e)}function Cx(r,e,t){const n=this.cache,i=e.length,s=Uo(t,i);Ot(n,s)||(r.uniform1iv(this.addr,s),Bt(n,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||nf,s[a])}function Rx(r,e,t){const n=this.cache,i=e.length,s=Uo(t,i);Ot(n,s)||(r.uniform1iv(this.addr,s),Bt(n,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||rf,s[a])}function Ix(r,e,t){const n=this.cache,i=e.length,s=Uo(t,i);Ot(n,s)||(r.uniform1iv(this.addr,s),Bt(n,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||af,s[a])}function Px(r,e,t){const n=this.cache,i=e.length,s=Uo(t,i);Ot(n,s)||(r.uniform1iv(this.addr,s),Bt(n,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||sf,s[a])}function Dx(r){switch(r){case 5126:return fx;case 35664:return px;case 35665:return mx;case 35666:return gx;case 35674:return _x;case 35675:return vx;case 35676:return xx;case 5124:case 35670:return yx;case 35667:case 35671:return Mx;case 35668:case 35672:return bx;case 35669:case 35673:return Sx;case 5125:return wx;case 36294:return Ex;case 36295:return Tx;case 36296:return Ax;case 35678:case 36198:case 36298:case 36306:case 35682:return Cx;case 35679:case 36299:case 36307:return Rx;case 35680:case 36300:case 36308:case 36293:return Ix;case 36289:case 36303:case 36311:case 36292:return Px}}class Lx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=dx(t.type)}}class Ux{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Dx(t.type)}}class Nx{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],n)}}}const Sl=/(\w+)(\])?(\[|\.)?/g;function Wu(r,e){r.seq.push(e),r.map[e.id]=e}function Fx(r,e,t){const n=r.name,i=n.length;for(Sl.lastIndex=0;;){const s=Sl.exec(n),a=Sl.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){Wu(t,c===void 0?new Lx(o,r,e):new Ux(o,r,e));break}else{let u=t.map[o];u===void 0&&(u=new Nx(o),Wu(t,u)),t=u}}}class $a{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);Fx(s,a,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function Xu(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}const Ox=37297;let Bx=0;function zx(r,e){const t=r.split(`
|
||
`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
|
||
`)}const qu=new tt;function kx(r){ht._getMatrix(qu,ht.workingColorSpace,r);const e=`mat3( ${qu.elements.map(t=>t.toFixed(4))} )`;switch(ht.getTransfer(r)){case co:return[e,"LinearTransferOETF"];case vt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function Yu(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
|
||
|
||
`+i+`
|
||
|
||
`+zx(r.getShaderSource(e),a)}else return i}function Vx(r,e){const t=kx(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}function Hx(r,e){let t;switch(e){case Jf:t="Linear";break;case Kf:t="Reinhard";break;case $f:t="Cineon";break;case cd:t="ACESFilmic";break;case Qf:t="AgX";break;case ep:t="Neutral";break;case jf:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ka=new A;function Gx(){ht.getLuminanceCoefficients(ka);const r=ka.x.toFixed(4),e=ka.y.toFixed(4),t=ka.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function Wx(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ir).join(`
|
||
`)}function Xx(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
||
`)}function qx(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Ir(r){return r!==""}function Zu(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ju(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Yx=/^[ \t]*#include +<([\w\d./]+)>/gm;function Mc(r){return r.replace(Yx,Jx)}const Zx=new Map;function Jx(r,e){let t=st[e];if(t===void 0){const n=Zx.get(e);if(n!==void 0)t=st[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Mc(t)}const Kx=/#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 Ku(r){return r.replace(Kx,$x)}function $x(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function $u(r){let e=`precision ${r.precision} float;
|
||
precision ${r.precision} int;
|
||
precision ${r.precision} sampler2D;
|
||
precision ${r.precision} samplerCube;
|
||
precision ${r.precision} sampler3D;
|
||
precision ${r.precision} sampler2DArray;
|
||
precision ${r.precision} sampler2DShadow;
|
||
precision ${r.precision} samplerCubeShadow;
|
||
precision ${r.precision} sampler2DArrayShadow;
|
||
precision ${r.precision} isampler2D;
|
||
precision ${r.precision} isampler3D;
|
||
precision ${r.precision} isamplerCube;
|
||
precision ${r.precision} isampler2DArray;
|
||
precision ${r.precision} usampler2D;
|
||
precision ${r.precision} usampler3D;
|
||
precision ${r.precision} usamplerCube;
|
||
precision ${r.precision} usampler2DArray;
|
||
`;return r.precision==="highp"?e+=`
|
||
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
|
||
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
|
||
#define LOW_PRECISION`),e}function jx(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===ld?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===Cf?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Qn&&(e="SHADOWMAP_TYPE_VSM"),e}function Qx(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case Ri:case os:e="ENVMAP_TYPE_CUBE";break;case qr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ey(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case os:e="ENVMAP_MODE_REFRACTION";break}return e}function ty(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case bo:e="ENVMAP_BLENDING_MULTIPLY";break;case Yf:e="ENVMAP_BLENDING_MIX";break;case Zf:e="ENVMAP_BLENDING_ADD";break}return e}function ny(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function iy(r,e,t,n){const i=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=jx(t),c=Qx(t),h=ey(t),u=ty(t),f=ny(t),d=Wx(t),p=Xx(s),_=i.createProgram();let g,m,y=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Ir).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Ir).join(`
|
||
`),m.length>0&&(m+=`
|
||
`)):(g=[$u(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
||
`].filter(Ir).join(`
|
||
`),m=[$u(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ti?"#define TONE_MAPPING":"",t.toneMapping!==Ti?st.tonemapping_pars_fragment:"",t.toneMapping!==Ti?Hx("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,Vx("linearToOutputTexel",t.outputColorSpace),Gx(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(Ir).join(`
|
||
`)),a=Mc(a),a=Zu(a,t),a=Ju(a,t),o=Mc(o),o=Zu(o,t),o=Ju(o,t),a=Ku(a),o=Ku(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
||
`,g=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+g,m=["#define varying in",t.glslVersion===Mh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Mh?"":"#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(`
|
||
`)+`
|
||
`+m);const v=y+g+a,x=y+m+o,w=Xu(i,i.VERTEX_SHADER,v),T=Xu(i,i.FRAGMENT_SHADER,x);i.attachShader(_,w),i.attachShader(_,T),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function C(D){if(r.debug.checkShaderErrors){const G=i.getProgramInfoLog(_).trim(),F=i.getShaderInfoLog(w).trim(),V=i.getShaderInfoLog(T).trim();let J=!0,q=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(J=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,w,T);else{const se=Yu(i,w,"vertex"),Z=Yu(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+D.name+`
|
||
Material Type: `+D.type+`
|
||
|
||
Program Info Log: `+G+`
|
||
`+se+`
|
||
`+Z)}else G!==""?console.warn("THREE.WebGLProgram: Program Info Log:",G):(F===""||V==="")&&(q=!1);q&&(D.diagnostics={runnable:J,programLog:G,vertexShader:{log:F,prefix:g},fragmentShader:{log:V,prefix:m}})}i.deleteShader(w),i.deleteShader(T),P=new $a(i,_),S=qx(i,_)}let P;this.getUniforms=function(){return P===void 0&&C(this),P};let S;this.getAttributes=function(){return S===void 0&&C(this),S};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(_,Ox)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Bx++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=T,this}let sy=0;class ry{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new ay(e),t.set(e,n)),n}}class ay{constructor(e){this.id=sy++,this.code=e,this.usedTimes=0}}function oy(r,e,t,n,i,s,a){const o=new Vc,l=new ry,c=new Set,h=[],u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(S){return c.add(S),S===0?"uv":`uv${S}`}function g(S,M,D,G,F){const V=G.fog,J=F.geometry,q=S.isMeshStandardMaterial?G.environment:null,se=(S.isMeshStandardMaterial?t:e).get(S.envMap||q),Z=se&&se.mapping===qr?se.image.height:null,_e=p[S.type];S.precision!==null&&(d=i.getMaxPrecision(S.precision),d!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",d,"instead."));const be=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Re=be!==void 0?be.length:0;let Ge=0;J.morphAttributes.position!==void 0&&(Ge=1),J.morphAttributes.normal!==void 0&&(Ge=2),J.morphAttributes.color!==void 0&&(Ge=3);let it,Q,ue,Ie;if(_e){const at=On[_e];it=at.vertexShader,Q=at.fragmentShader}else it=S.vertexShader,Q=S.fragmentShader,l.update(S),ue=l.getVertexShaderID(S),Ie=l.getFragmentShaderID(S);const pe=r.getRenderTarget(),Oe=r.state.buffers.depth.getReversed(),We=F.isInstancedMesh===!0,ze=F.isBatchedMesh===!0,Je=!!S.map,te=!!S.matcap,de=!!se,I=!!S.aoMap,De=!!S.lightMap,re=!!S.bumpMap,Ae=!!S.normalMap,me=!!S.displacementMap,Ve=!!S.emissiveMap,Se=!!S.metalnessMap,R=!!S.roughnessMap,b=S.anisotropy>0,H=S.clearcoat>0,k=S.dispersion>0,X=S.iridescence>0,W=S.sheen>0,ce=S.transmission>0,oe=b&&!!S.anisotropyMap,ge=H&&!!S.clearcoatMap,Be=H&&!!S.clearcoatNormalMap,$=H&&!!S.clearcoatRoughnessMap,ve=X&&!!S.iridescenceMap,Y=X&&!!S.iridescenceThicknessMap,ie=W&&!!S.sheenColorMap,ae=W&&!!S.sheenRoughnessMap,Ne=!!S.specularMap,Pe=!!S.specularColorMap,Ke=!!S.specularIntensityMap,U=ce&&!!S.transmissionMap,ye=ce&&!!S.thicknessMap,K=!!S.gradientMap,ee=!!S.alphaMap,we=S.alphaTest>0,Me=!!S.alphaHash,Ye=!!S.extensions;let Mt=Ti;S.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(Mt=r.toneMapping);const St={shaderID:_e,shaderType:S.type,shaderName:S.name,vertexShader:it,fragmentShader:Q,defines:S.defines,customVertexShaderID:ue,customFragmentShaderID:Ie,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:d,batching:ze,batchingColor:ze&&F._colorsTexture!==null,instancing:We,instancingColor:We&&F.instanceColor!==null,instancingMorph:We&&F.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:pe===null?r.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:Qs,alphaToCoverage:!!S.alphaToCoverage,map:Je,matcap:te,envMap:de,envMapMode:de&&se.mapping,envMapCubeUVHeight:Z,aoMap:I,lightMap:De,bumpMap:re,normalMap:Ae,displacementMap:f&&me,emissiveMap:Ve,normalMapObjectSpace:Ae&&S.normalMapType===op,normalMapTangentSpace:Ae&&S.normalMapType===cs,metalnessMap:Se,roughnessMap:R,anisotropy:b,anisotropyMap:oe,clearcoat:H,clearcoatMap:ge,clearcoatNormalMap:Be,clearcoatRoughnessMap:$,dispersion:k,iridescence:X,iridescenceMap:ve,iridescenceThicknessMap:Y,sheen:W,sheenColorMap:ie,sheenRoughnessMap:ae,specularMap:Ne,specularColorMap:Pe,specularIntensityMap:Ke,transmission:ce,transmissionMap:U,thicknessMap:ye,gradientMap:K,opaque:S.transparent===!1&&S.blending===qs&&S.alphaToCoverage===!1,alphaMap:ee,alphaTest:we,alphaHash:Me,combine:S.combine,mapUv:Je&&_(S.map.channel),aoMapUv:I&&_(S.aoMap.channel),lightMapUv:De&&_(S.lightMap.channel),bumpMapUv:re&&_(S.bumpMap.channel),normalMapUv:Ae&&_(S.normalMap.channel),displacementMapUv:me&&_(S.displacementMap.channel),emissiveMapUv:Ve&&_(S.emissiveMap.channel),metalnessMapUv:Se&&_(S.metalnessMap.channel),roughnessMapUv:R&&_(S.roughnessMap.channel),anisotropyMapUv:oe&&_(S.anisotropyMap.channel),clearcoatMapUv:ge&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:Be&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:ve&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:ie&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:ae&&_(S.sheenRoughnessMap.channel),specularMapUv:Ne&&_(S.specularMap.channel),specularColorMapUv:Pe&&_(S.specularColorMap.channel),specularIntensityMapUv:Ke&&_(S.specularIntensityMap.channel),transmissionMapUv:U&&_(S.transmissionMap.channel),thicknessMapUv:ye&&_(S.thicknessMap.channel),alphaMapUv:ee&&_(S.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(Ae||b),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!J.attributes.uv&&(Je||ee),fog:!!V,useFog:S.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Oe,skinning:F.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Re,morphTextureStride:Ge,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&D.length>0,shadowMapType:r.shadowMap.type,toneMapping:Mt,decodeVideoTexture:Je&&S.map.isVideoTexture===!0&&ht.getTransfer(S.map.colorSpace)===vt,decodeVideoTextureEmissive:Ve&&S.emissiveMap.isVideoTexture===!0&&ht.getTransfer(S.emissiveMap.colorSpace)===vt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Bn,flipSided:S.side===fn,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:Ye&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ye&&S.extensions.multiDraw===!0||ze)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return St.vertexUv1s=c.has(1),St.vertexUv2s=c.has(2),St.vertexUv3s=c.has(3),c.clear(),St}function m(S){const M=[];if(S.shaderID?M.push(S.shaderID):(M.push(S.customVertexShaderID),M.push(S.customFragmentShaderID)),S.defines!==void 0)for(const D in S.defines)M.push(D),M.push(S.defines[D]);return S.isRawShaderMaterial===!1&&(y(M,S),v(M,S),M.push(r.outputColorSpace)),M.push(S.customProgramCacheKey),M.join()}function y(S,M){S.push(M.precision),S.push(M.outputColorSpace),S.push(M.envMapMode),S.push(M.envMapCubeUVHeight),S.push(M.mapUv),S.push(M.alphaMapUv),S.push(M.lightMapUv),S.push(M.aoMapUv),S.push(M.bumpMapUv),S.push(M.normalMapUv),S.push(M.displacementMapUv),S.push(M.emissiveMapUv),S.push(M.metalnessMapUv),S.push(M.roughnessMapUv),S.push(M.anisotropyMapUv),S.push(M.clearcoatMapUv),S.push(M.clearcoatNormalMapUv),S.push(M.clearcoatRoughnessMapUv),S.push(M.iridescenceMapUv),S.push(M.iridescenceThicknessMapUv),S.push(M.sheenColorMapUv),S.push(M.sheenRoughnessMapUv),S.push(M.specularMapUv),S.push(M.specularColorMapUv),S.push(M.specularIntensityMapUv),S.push(M.transmissionMapUv),S.push(M.thicknessMapUv),S.push(M.combine),S.push(M.fogExp2),S.push(M.sizeAttenuation),S.push(M.morphTargetsCount),S.push(M.morphAttributeCount),S.push(M.numDirLights),S.push(M.numPointLights),S.push(M.numSpotLights),S.push(M.numSpotLightMaps),S.push(M.numHemiLights),S.push(M.numRectAreaLights),S.push(M.numDirLightShadows),S.push(M.numPointLightShadows),S.push(M.numSpotLightShadows),S.push(M.numSpotLightShadowsWithMaps),S.push(M.numLightProbes),S.push(M.shadowMapType),S.push(M.toneMapping),S.push(M.numClippingPlanes),S.push(M.numClipIntersection),S.push(M.depthPacking)}function v(S,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),S.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reverseDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),S.push(o.mask)}function x(S){const M=p[S.type];let D;if(M){const G=On[M];D=fo.clone(G.uniforms)}else D=S.uniforms;return D}function w(S,M){let D;for(let G=0,F=h.length;G<F;G++){const V=h[G];if(V.cacheKey===M){D=V,++D.usedTimes;break}}return D===void 0&&(D=new iy(r,M,S,s),h.push(D)),D}function T(S){if(--S.usedTimes===0){const M=h.indexOf(S);h[M]=h[h.length-1],h.pop(),S.destroy()}}function C(S){l.remove(S)}function P(){l.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:x,acquireProgram:w,releaseProgram:T,releaseShaderCache:C,programs:h,dispose:P}}function ly(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function n(a){r.delete(a)}function i(a,o,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:s}}function cy(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function ju(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Qu(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(u,f,d,p,_,g){let m=r[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:p,renderOrder:u.renderOrder,z:_,group:g},r[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=p,m.renderOrder=u.renderOrder,m.z=_,m.group=g),e++,m}function o(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.push(m):d.transparent===!0?i.push(m):t.push(m)}function l(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.unshift(m):d.transparent===!0?i.unshift(m):t.unshift(m)}function c(u,f){t.length>1&&t.sort(u||cy),n.length>1&&n.sort(f||ju),i.length>1&&i.sort(f||ju)}function h(){for(let u=e,f=r.length;u<f;u++){const d=r[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:h,sort:c}}function hy(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new Qu,r.set(n,[a])):i>=s.length?(a=new Qu,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function uy(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new A,color:new ne};break;case"SpotLight":t={position:new A,direction:new A,color:new ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new A,color:new ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new A,skyColor:new ne,groundColor:new ne};break;case"RectAreaLight":t={color:new ne,position:new A,halfWidth:new A,halfHeight:new A};break}return r[e.id]=t,t}}}function dy(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let fy=0;function py(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function my(r){const e=new uy,t=dy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new A);const i=new A,s=new Ze,a=new Ze;function o(c){let h=0,u=0,f=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let d=0,p=0,_=0,g=0,m=0,y=0,v=0,x=0,w=0,T=0,C=0;c.sort(py);for(let S=0,M=c.length;S<M;S++){const D=c[S],G=D.color,F=D.intensity,V=D.distance,J=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)h+=G.r*F,u+=G.g*F,f+=G.b*F;else if(D.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(D.sh.coefficients[q],F);C++}else if(D.isDirectionalLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const se=D.shadow,Z=t.get(D);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,n.directionalShadow[d]=Z,n.directionalShadowMap[d]=J,n.directionalShadowMatrix[d]=D.shadow.matrix,y++}n.directional[d]=q,d++}else if(D.isSpotLight){const q=e.get(D);q.position.setFromMatrixPosition(D.matrixWorld),q.color.copy(G).multiplyScalar(F),q.distance=V,q.coneCos=Math.cos(D.angle),q.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),q.decay=D.decay,n.spot[_]=q;const se=D.shadow;if(D.map&&(n.spotLightMap[w]=D.map,w++,se.updateMatrices(D),D.castShadow&&T++),n.spotLightMatrix[_]=se.matrix,D.castShadow){const Z=t.get(D);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,n.spotShadow[_]=Z,n.spotShadowMap[_]=J,x++}_++}else if(D.isRectAreaLight){const q=e.get(D);q.color.copy(G).multiplyScalar(F),q.halfWidth.set(D.width*.5,0,0),q.halfHeight.set(0,D.height*.5,0),n.rectArea[g]=q,g++}else if(D.isPointLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),q.distance=D.distance,q.decay=D.decay,D.castShadow){const se=D.shadow,Z=t.get(D);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,Z.shadowCameraNear=se.camera.near,Z.shadowCameraFar=se.camera.far,n.pointShadow[p]=Z,n.pointShadowMap[p]=J,n.pointShadowMatrix[p]=D.shadow.matrix,v++}n.point[p]=q,p++}else if(D.isHemisphereLight){const q=e.get(D);q.skyColor.copy(D.color).multiplyScalar(F),q.groundColor.copy(D.groundColor).multiplyScalar(F),n.hemi[m]=q,m++}}g>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Te.LTC_FLOAT_1,n.rectAreaLTC2=Te.LTC_FLOAT_2):(n.rectAreaLTC1=Te.LTC_HALF_1,n.rectAreaLTC2=Te.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=f;const P=n.hash;(P.directionalLength!==d||P.pointLength!==p||P.spotLength!==_||P.rectAreaLength!==g||P.hemiLength!==m||P.numDirectionalShadows!==y||P.numPointShadows!==v||P.numSpotShadows!==x||P.numSpotMaps!==w||P.numLightProbes!==C)&&(n.directional.length=d,n.spot.length=_,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=x+w-T,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=C,P.directionalLength=d,P.pointLength=p,P.spotLength=_,P.rectAreaLength=g,P.hemiLength=m,P.numDirectionalShadows=y,P.numPointShadows=v,P.numSpotShadows=x,P.numSpotMaps=w,P.numLightProbes=C,n.version=fy++)}function l(c,h){let u=0,f=0,d=0,p=0,_=0;const g=h.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const v=c[m];if(v.isDirectionalLight){const x=n.directional[u];x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(g),u++}else if(v.isSpotLight){const x=n.spot[d];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(g),x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(g),d++}else if(v.isRectAreaLight){const x=n.rectArea[p];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(g),a.identity(),s.copy(v.matrixWorld),s.premultiply(g),a.extractRotation(s),x.halfWidth.set(v.width*.5,0,0),x.halfHeight.set(0,v.height*.5,0),x.halfWidth.applyMatrix4(a),x.halfHeight.applyMatrix4(a),p++}else if(v.isPointLight){const x=n.point[f];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(g),f++}else if(v.isHemisphereLight){const x=n.hemi[_];x.direction.setFromMatrixPosition(v.matrixWorld),x.direction.transformDirection(g),_++}}}return{setup:o,setupView:l,state:n}}function ed(r){const e=new my(r),t=[],n=[];function i(h){c.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function gy(r){let e=new WeakMap;function t(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new ed(r),e.set(i,[o])):s>=a.length?(o=new ed(r),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const _y=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,vy=`uniform sampler2D shadow_pass;
|
||
uniform vec2 resolution;
|
||
uniform float radius;
|
||
#include <packing>
|
||
void main() {
|
||
const float samples = float( VSM_SAMPLES );
|
||
float mean = 0.0;
|
||
float squared_mean = 0.0;
|
||
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
||
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
||
for ( float i = 0.0; i < samples; i ++ ) {
|
||
float uvOffset = uvStart + i * uvStride;
|
||
#ifdef HORIZONTAL_PASS
|
||
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
||
mean += distribution.x;
|
||
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
||
#else
|
||
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
||
mean += depth;
|
||
squared_mean += depth * depth;
|
||
#endif
|
||
}
|
||
mean = mean / samples;
|
||
squared_mean = squared_mean / samples;
|
||
float std_dev = sqrt( squared_mean - mean * mean );
|
||
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
||
}`;function xy(r,e,t){let n=new To;const i=new j,s=new j,a=new pt,o=new Hd({depthPacking:ap}),l=new Gd,c={},h=t.maxTextureSize,u={[Ci]:fn,[fn]:Ci,[Bn]:Bn},f=new Xt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new j},radius:{value:4}},vertexShader:_y,fragmentShader:vy}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new qe;p.setAttribute("position",new rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new yt(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ld;let m=this.type;this.render=function(T,C,P){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;const S=r.getRenderTarget(),M=r.getActiveCubeFace(),D=r.getActiveMipmapLevel(),G=r.state;G.setBlending(ii),G.buffers.color.setClear(1,1,1,1),G.buffers.depth.setTest(!0),G.setScissorTest(!1);const F=m!==Qn&&this.type===Qn,V=m===Qn&&this.type!==Qn;for(let J=0,q=T.length;J<q;J++){const se=T[J],Z=se.shadow;if(Z===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const _e=Z.getFrameExtents();if(i.multiply(_e),s.copy(Z.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/_e.x),i.x=s.x*_e.x,Z.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/_e.y),i.y=s.y*_e.y,Z.mapSize.y=s.y)),Z.map===null||F===!0||V===!0){const Re=this.type!==Qn?{minFilter:Qt,magFilter:Qt}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Sn(i.x,i.y,Re),Z.map.texture.name=se.name+".shadowMap",Z.camera.updateProjectionMatrix()}r.setRenderTarget(Z.map),r.clear();const be=Z.getViewportCount();for(let Re=0;Re<be;Re++){const Ge=Z.getViewport(Re);a.set(s.x*Ge.x,s.y*Ge.y,s.x*Ge.z,s.y*Ge.w),G.viewport(a),Z.updateMatrices(se,Re),n=Z.getFrustum(),x(C,P,Z.camera,se,this.type)}Z.isPointLightShadow!==!0&&this.type===Qn&&y(Z,P),Z.needsUpdate=!1}m=this.type,g.needsUpdate=!1,r.setRenderTarget(S,M,D)};function y(T,C){const P=e.update(_);f.defines.VSM_SAMPLES!==T.blurSamples&&(f.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Sn(i.x,i.y)),f.uniforms.shadow_pass.value=T.map.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(C,null,P,f,_,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(C,null,P,d,_,null)}function v(T,C,P,S){let M=null;const D=P.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)M=D;else if(M=P.isPointLight===!0?l:o,r.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const G=M.uuid,F=C.uuid;let V=c[G];V===void 0&&(V={},c[G]=V);let J=V[F];J===void 0&&(J=M.clone(),V[F]=J,C.addEventListener("dispose",w)),M=J}if(M.visible=C.visible,M.wireframe=C.wireframe,S===Qn?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,P.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const G=r.properties.get(M);G.light=P}return M}function x(T,C,P,S,M){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===Qn)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,T.matrixWorld);const F=e.update(T),V=T.material;if(Array.isArray(V)){const J=F.groups;for(let q=0,se=J.length;q<se;q++){const Z=J[q],_e=V[Z.materialIndex];if(_e&&_e.visible){const be=v(T,_e,S,M);T.onBeforeShadow(r,T,C,P,F,be,Z),r.renderBufferDirect(P,null,F,be,T,Z),T.onAfterShadow(r,T,C,P,F,be,Z)}}}else if(V.visible){const J=v(T,V,S,M);T.onBeforeShadow(r,T,C,P,F,J,null),r.renderBufferDirect(P,null,F,J,T,null),T.onAfterShadow(r,T,C,P,F,J,null)}}const G=T.children;for(let F=0,V=G.length;F<V;F++)x(G[F],C,P,S,M)}function w(T){T.target.removeEventListener("dispose",w);for(const P in c){const S=c[P],M=T.target.uuid;M in S&&(S[M].dispose(),delete S[M])}}}const yy={[Ll]:Ul,[Nl]:Bl,[Fl]:zl,[Ks]:Ol,[Ul]:Ll,[Bl]:Nl,[zl]:Fl,[Ol]:Ks};function My(r,e){function t(){let U=!1;const ye=new pt;let K=null;const ee=new pt(0,0,0,0);return{setMask:function(we){K!==we&&!U&&(r.colorMask(we,we,we,we),K=we)},setLocked:function(we){U=we},setClear:function(we,Me,Ye,Mt,St){St===!0&&(we*=Mt,Me*=Mt,Ye*=Mt),ye.set(we,Me,Ye,Mt),ee.equals(ye)===!1&&(r.clearColor(we,Me,Ye,Mt),ee.copy(ye))},reset:function(){U=!1,K=null,ee.set(-1,0,0,0)}}}function n(){let U=!1,ye=!1,K=null,ee=null,we=null;return{setReversed:function(Me){if(ye!==Me){const Ye=e.get("EXT_clip_control");ye?Ye.clipControlEXT(Ye.LOWER_LEFT_EXT,Ye.ZERO_TO_ONE_EXT):Ye.clipControlEXT(Ye.LOWER_LEFT_EXT,Ye.NEGATIVE_ONE_TO_ONE_EXT);const Mt=we;we=null,this.setClear(Mt)}ye=Me},getReversed:function(){return ye},setTest:function(Me){Me?pe(r.DEPTH_TEST):Oe(r.DEPTH_TEST)},setMask:function(Me){K!==Me&&!U&&(r.depthMask(Me),K=Me)},setFunc:function(Me){if(ye&&(Me=yy[Me]),ee!==Me){switch(Me){case Ll:r.depthFunc(r.NEVER);break;case Ul:r.depthFunc(r.ALWAYS);break;case Nl:r.depthFunc(r.LESS);break;case Ks:r.depthFunc(r.LEQUAL);break;case Fl:r.depthFunc(r.EQUAL);break;case Ol:r.depthFunc(r.GEQUAL);break;case Bl:r.depthFunc(r.GREATER);break;case zl:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}ee=Me}},setLocked:function(Me){U=Me},setClear:function(Me){we!==Me&&(ye&&(Me=1-Me),r.clearDepth(Me),we=Me)},reset:function(){U=!1,K=null,ee=null,we=null,ye=!1}}}function i(){let U=!1,ye=null,K=null,ee=null,we=null,Me=null,Ye=null,Mt=null,St=null;return{setTest:function(at){U||(at?pe(r.STENCIL_TEST):Oe(r.STENCIL_TEST))},setMask:function(at){ye!==at&&!U&&(r.stencilMask(at),ye=at)},setFunc:function(at,Yt,Ht){(K!==at||ee!==Yt||we!==Ht)&&(r.stencilFunc(at,Yt,Ht),K=at,ee=Yt,we=Ht)},setOp:function(at,Yt,Ht){(Me!==at||Ye!==Yt||Mt!==Ht)&&(r.stencilOp(at,Yt,Ht),Me=at,Ye=Yt,Mt=Ht)},setLocked:function(at){U=at},setClear:function(at){St!==at&&(r.clearStencil(at),St=at)},reset:function(){U=!1,ye=null,K=null,ee=null,we=null,Me=null,Ye=null,Mt=null,St=null}}}const s=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let h={},u={},f=new WeakMap,d=[],p=null,_=!1,g=null,m=null,y=null,v=null,x=null,w=null,T=null,C=new ne(0,0,0),P=0,S=!1,M=null,D=null,G=null,F=null,V=null;const J=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,se=0;const Z=r.getParameter(r.VERSION);Z.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec(Z)[1]),q=se>=1):Z.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),q=se>=2);let _e=null,be={};const Re=r.getParameter(r.SCISSOR_BOX),Ge=r.getParameter(r.VIEWPORT),it=new pt().fromArray(Re),Q=new pt().fromArray(Ge);function ue(U,ye,K,ee){const we=new Uint8Array(4),Me=r.createTexture();r.bindTexture(U,Me),r.texParameteri(U,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(U,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ye=0;Ye<K;Ye++)U===r.TEXTURE_3D||U===r.TEXTURE_2D_ARRAY?r.texImage3D(ye,0,r.RGBA,1,1,ee,0,r.RGBA,r.UNSIGNED_BYTE,we):r.texImage2D(ye+Ye,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,we);return Me}const Ie={};Ie[r.TEXTURE_2D]=ue(r.TEXTURE_2D,r.TEXTURE_2D,1),Ie[r.TEXTURE_CUBE_MAP]=ue(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),Ie[r.TEXTURE_2D_ARRAY]=ue(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),Ie[r.TEXTURE_3D]=ue(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),pe(r.DEPTH_TEST),a.setFunc(Ks),re(!1),Ae(gh),pe(r.CULL_FACE),I(ii);function pe(U){h[U]!==!0&&(r.enable(U),h[U]=!0)}function Oe(U){h[U]!==!1&&(r.disable(U),h[U]=!1)}function We(U,ye){return u[U]!==ye?(r.bindFramebuffer(U,ye),u[U]=ye,U===r.DRAW_FRAMEBUFFER&&(u[r.FRAMEBUFFER]=ye),U===r.FRAMEBUFFER&&(u[r.DRAW_FRAMEBUFFER]=ye),!0):!1}function ze(U,ye){let K=d,ee=!1;if(U){K=f.get(ye),K===void 0&&(K=[],f.set(ye,K));const we=U.textures;if(K.length!==we.length||K[0]!==r.COLOR_ATTACHMENT0){for(let Me=0,Ye=we.length;Me<Ye;Me++)K[Me]=r.COLOR_ATTACHMENT0+Me;K.length=we.length,ee=!0}}else K[0]!==r.BACK&&(K[0]=r.BACK,ee=!0);ee&&r.drawBuffers(K)}function Je(U){return p!==U?(r.useProgram(U),p=U,!0):!1}const te={[Qi]:r.FUNC_ADD,[If]:r.FUNC_SUBTRACT,[Pf]:r.FUNC_REVERSE_SUBTRACT};te[Df]=r.MIN,te[Lf]=r.MAX;const de={[Uf]:r.ZERO,[Nf]:r.ONE,[Ff]:r.SRC_COLOR,[Pl]:r.SRC_ALPHA,[Hf]:r.SRC_ALPHA_SATURATE,[kf]:r.DST_COLOR,[Bf]:r.DST_ALPHA,[Of]:r.ONE_MINUS_SRC_COLOR,[Dl]:r.ONE_MINUS_SRC_ALPHA,[Vf]:r.ONE_MINUS_DST_COLOR,[zf]:r.ONE_MINUS_DST_ALPHA,[Gf]:r.CONSTANT_COLOR,[Wf]:r.ONE_MINUS_CONSTANT_COLOR,[Xf]:r.CONSTANT_ALPHA,[qf]:r.ONE_MINUS_CONSTANT_ALPHA};function I(U,ye,K,ee,we,Me,Ye,Mt,St,at){if(U===ii){_===!0&&(Oe(r.BLEND),_=!1);return}if(_===!1&&(pe(r.BLEND),_=!0),U!==Rf){if(U!==g||at!==S){if((m!==Qi||x!==Qi)&&(r.blendEquation(r.FUNC_ADD),m=Qi,x=Qi),at)switch(U){case qs:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Wt:r.blendFunc(r.ONE,r.ONE);break;case _h:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case vh:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case qs:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Wt:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case _h:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case vh:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}y=null,v=null,w=null,T=null,C.set(0,0,0),P=0,g=U,S=at}return}we=we||ye,Me=Me||K,Ye=Ye||ee,(ye!==m||we!==x)&&(r.blendEquationSeparate(te[ye],te[we]),m=ye,x=we),(K!==y||ee!==v||Me!==w||Ye!==T)&&(r.blendFuncSeparate(de[K],de[ee],de[Me],de[Ye]),y=K,v=ee,w=Me,T=Ye),(Mt.equals(C)===!1||St!==P)&&(r.blendColor(Mt.r,Mt.g,Mt.b,St),C.copy(Mt),P=St),g=U,S=!1}function De(U,ye){U.side===Bn?Oe(r.CULL_FACE):pe(r.CULL_FACE);let K=U.side===fn;ye&&(K=!K),re(K),U.blending===qs&&U.transparent===!1?I(ii):I(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),a.setFunc(U.depthFunc),a.setTest(U.depthTest),a.setMask(U.depthWrite),s.setMask(U.colorWrite);const ee=U.stencilWrite;o.setTest(ee),ee&&(o.setMask(U.stencilWriteMask),o.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),o.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Ve(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?pe(r.SAMPLE_ALPHA_TO_COVERAGE):Oe(r.SAMPLE_ALPHA_TO_COVERAGE)}function re(U){M!==U&&(U?r.frontFace(r.CW):r.frontFace(r.CCW),M=U)}function Ae(U){U!==Tf?(pe(r.CULL_FACE),U!==D&&(U===gh?r.cullFace(r.BACK):U===Af?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):Oe(r.CULL_FACE),D=U}function me(U){U!==G&&(q&&r.lineWidth(U),G=U)}function Ve(U,ye,K){U?(pe(r.POLYGON_OFFSET_FILL),(F!==ye||V!==K)&&(r.polygonOffset(ye,K),F=ye,V=K)):Oe(r.POLYGON_OFFSET_FILL)}function Se(U){U?pe(r.SCISSOR_TEST):Oe(r.SCISSOR_TEST)}function R(U){U===void 0&&(U=r.TEXTURE0+J-1),_e!==U&&(r.activeTexture(U),_e=U)}function b(U,ye,K){K===void 0&&(_e===null?K=r.TEXTURE0+J-1:K=_e);let ee=be[K];ee===void 0&&(ee={type:void 0,texture:void 0},be[K]=ee),(ee.type!==U||ee.texture!==ye)&&(_e!==K&&(r.activeTexture(K),_e=K),r.bindTexture(U,ye||Ie[U]),ee.type=U,ee.texture=ye)}function H(){const U=be[_e];U!==void 0&&U.type!==void 0&&(r.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function k(){try{r.compressedTexImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function X(){try{r.compressedTexImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function W(){try{r.texSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ce(){try{r.texSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function oe(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ge(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Be(){try{r.texStorage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function $(){try{r.texStorage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ve(){try{r.texImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Y(){try{r.texImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ie(U){it.equals(U)===!1&&(r.scissor(U.x,U.y,U.z,U.w),it.copy(U))}function ae(U){Q.equals(U)===!1&&(r.viewport(U.x,U.y,U.z,U.w),Q.copy(U))}function Ne(U,ye){let K=c.get(ye);K===void 0&&(K=new WeakMap,c.set(ye,K));let ee=K.get(U);ee===void 0&&(ee=r.getUniformBlockIndex(ye,U.name),K.set(U,ee))}function Pe(U,ye){const ee=c.get(ye).get(U);l.get(ye)!==ee&&(r.uniformBlockBinding(ye,ee,U.__bindingPointIndex),l.set(ye,ee))}function Ke(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},_e=null,be={},u={},f=new WeakMap,d=[],p=null,_=!1,g=null,m=null,y=null,v=null,x=null,w=null,T=null,C=new ne(0,0,0),P=0,S=!1,M=null,D=null,G=null,F=null,V=null,it.set(0,0,r.canvas.width,r.canvas.height),Q.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:pe,disable:Oe,bindFramebuffer:We,drawBuffers:ze,useProgram:Je,setBlending:I,setMaterial:De,setFlipSided:re,setCullFace:Ae,setLineWidth:me,setPolygonOffset:Ve,setScissorTest:Se,activeTexture:R,bindTexture:b,unbindTexture:H,compressedTexImage2D:k,compressedTexImage3D:X,texImage2D:ve,texImage3D:Y,updateUBOMapping:Ne,uniformBlockBinding:Pe,texStorage2D:Be,texStorage3D:$,texSubImage2D:W,texSubImage3D:ce,compressedTexSubImage2D:oe,compressedTexSubImage3D:ge,scissor:ie,viewport:ae,reset:Ke}}function by(r,e,t,n,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new j,h=new WeakMap;let u;const f=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(R,b){return d?new OffscreenCanvas(R,b):Vr("canvas")}function _(R,b,H){let k=1;const X=Se(R);if((X.width>H||X.height>H)&&(k=H/Math.max(X.width,X.height)),k<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const W=Math.floor(k*X.width),ce=Math.floor(k*X.height);u===void 0&&(u=p(W,ce));const oe=b?p(W,ce):u;return oe.width=W,oe.height=ce,oe.getContext("2d").drawImage(R,0,0,W,ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+X.width+"x"+X.height+") to ("+W+"x"+ce+")."),oe}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+X.width+"x"+X.height+")."),R;return R}function g(R){return R.generateMipmaps}function m(R){r.generateMipmap(R)}function y(R){return R.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?r.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function v(R,b,H,k,X=!1){if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W=b;if(b===r.RED&&(H===r.FLOAT&&(W=r.R32F),H===r.HALF_FLOAT&&(W=r.R16F),H===r.UNSIGNED_BYTE&&(W=r.R8)),b===r.RED_INTEGER&&(H===r.UNSIGNED_BYTE&&(W=r.R8UI),H===r.UNSIGNED_SHORT&&(W=r.R16UI),H===r.UNSIGNED_INT&&(W=r.R32UI),H===r.BYTE&&(W=r.R8I),H===r.SHORT&&(W=r.R16I),H===r.INT&&(W=r.R32I)),b===r.RG&&(H===r.FLOAT&&(W=r.RG32F),H===r.HALF_FLOAT&&(W=r.RG16F),H===r.UNSIGNED_BYTE&&(W=r.RG8)),b===r.RG_INTEGER&&(H===r.UNSIGNED_BYTE&&(W=r.RG8UI),H===r.UNSIGNED_SHORT&&(W=r.RG16UI),H===r.UNSIGNED_INT&&(W=r.RG32UI),H===r.BYTE&&(W=r.RG8I),H===r.SHORT&&(W=r.RG16I),H===r.INT&&(W=r.RG32I)),b===r.RGB_INTEGER&&(H===r.UNSIGNED_BYTE&&(W=r.RGB8UI),H===r.UNSIGNED_SHORT&&(W=r.RGB16UI),H===r.UNSIGNED_INT&&(W=r.RGB32UI),H===r.BYTE&&(W=r.RGB8I),H===r.SHORT&&(W=r.RGB16I),H===r.INT&&(W=r.RGB32I)),b===r.RGBA_INTEGER&&(H===r.UNSIGNED_BYTE&&(W=r.RGBA8UI),H===r.UNSIGNED_SHORT&&(W=r.RGBA16UI),H===r.UNSIGNED_INT&&(W=r.RGBA32UI),H===r.BYTE&&(W=r.RGBA8I),H===r.SHORT&&(W=r.RGBA16I),H===r.INT&&(W=r.RGBA32I)),b===r.RGB&&H===r.UNSIGNED_INT_5_9_9_9_REV&&(W=r.RGB9_E5),b===r.RGBA){const ce=X?co:ht.getTransfer(k);H===r.FLOAT&&(W=r.RGBA32F),H===r.HALF_FLOAT&&(W=r.RGBA16F),H===r.UNSIGNED_BYTE&&(W=ce===vt?r.SRGB8_ALPHA8:r.RGBA8),H===r.UNSIGNED_SHORT_4_4_4_4&&(W=r.RGBA4),H===r.UNSIGNED_SHORT_5_5_5_1&&(W=r.RGB5_A1)}return(W===r.R16F||W===r.R32F||W===r.RG16F||W===r.RG32F||W===r.RGBA16F||W===r.RGBA32F)&&e.get("EXT_color_buffer_float"),W}function x(R,b){let H;return R?b===null||b===Ii||b===$s?H=r.DEPTH24_STENCIL8:b===Mn?H=r.DEPTH32F_STENCIL8:b===kr&&(H=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Ii||b===$s?H=r.DEPTH_COMPONENT24:b===Mn?H=r.DEPTH_COMPONENT32F:b===kr&&(H=r.DEPTH_COMPONENT16),H}function w(R,b){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Qt&&R.minFilter!==Vt?Math.log2(Math.max(b.width,b.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?b.mipmaps.length:1}function T(R){const b=R.target;b.removeEventListener("dispose",T),P(b),b.isVideoTexture&&h.delete(b)}function C(R){const b=R.target;b.removeEventListener("dispose",C),M(b)}function P(R){const b=n.get(R);if(b.__webglInit===void 0)return;const H=R.source,k=f.get(H);if(k){const X=k[b.__cacheKey];X.usedTimes--,X.usedTimes===0&&S(R),Object.keys(k).length===0&&f.delete(H)}n.remove(R)}function S(R){const b=n.get(R);r.deleteTexture(b.__webglTexture);const H=R.source,k=f.get(H);delete k[b.__cacheKey],a.memory.textures--}function M(R){const b=n.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),n.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(b.__webglFramebuffer[k]))for(let X=0;X<b.__webglFramebuffer[k].length;X++)r.deleteFramebuffer(b.__webglFramebuffer[k][X]);else r.deleteFramebuffer(b.__webglFramebuffer[k]);b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer[k])}else{if(Array.isArray(b.__webglFramebuffer))for(let k=0;k<b.__webglFramebuffer.length;k++)r.deleteFramebuffer(b.__webglFramebuffer[k]);else r.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&r.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let k=0;k<b.__webglColorRenderbuffer.length;k++)b.__webglColorRenderbuffer[k]&&r.deleteRenderbuffer(b.__webglColorRenderbuffer[k]);b.__webglDepthRenderbuffer&&r.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const H=R.textures;for(let k=0,X=H.length;k<X;k++){const W=n.get(H[k]);W.__webglTexture&&(r.deleteTexture(W.__webglTexture),a.memory.textures--),n.remove(H[k])}n.remove(R)}let D=0;function G(){D=0}function F(){const R=D;return R>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),D+=1,R}function V(R){const b=[];return b.push(R.wrapS),b.push(R.wrapT),b.push(R.wrapR||0),b.push(R.magFilter),b.push(R.minFilter),b.push(R.anisotropy),b.push(R.internalFormat),b.push(R.format),b.push(R.type),b.push(R.generateMipmaps),b.push(R.premultiplyAlpha),b.push(R.flipY),b.push(R.unpackAlignment),b.push(R.colorSpace),b.join()}function J(R,b){const H=n.get(R);if(R.isVideoTexture&&me(R),R.isRenderTargetTexture===!1&&R.version>0&&H.__version!==R.version){const k=R.image;if(k===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(H,R,b);return}}t.bindTexture(r.TEXTURE_2D,H.__webglTexture,r.TEXTURE0+b)}function q(R,b){const H=n.get(R);if(R.version>0&&H.__version!==R.version){Q(H,R,b);return}t.bindTexture(r.TEXTURE_2D_ARRAY,H.__webglTexture,r.TEXTURE0+b)}function se(R,b){const H=n.get(R);if(R.version>0&&H.__version!==R.version){Q(H,R,b);return}t.bindTexture(r.TEXTURE_3D,H.__webglTexture,r.TEXTURE0+b)}function Z(R,b){const H=n.get(R);if(R.version>0&&H.__version!==R.version){ue(H,R,b);return}t.bindTexture(r.TEXTURE_CUBE_MAP,H.__webglTexture,r.TEXTURE0+b)}const _e={[ro]:r.REPEAT,[Nn]:r.CLAMP_TO_EDGE,[ao]:r.MIRRORED_REPEAT},be={[Qt]:r.NEAREST,[hd]:r.NEAREST_MIPMAP_NEAREST,[Cr]:r.NEAREST_MIPMAP_LINEAR,[Vt]:r.LINEAR,[Xa]:r.LINEAR_MIPMAP_NEAREST,[ni]:r.LINEAR_MIPMAP_LINEAR},Re={[lp]:r.NEVER,[pp]:r.ALWAYS,[cp]:r.LESS,[Md]:r.LEQUAL,[hp]:r.EQUAL,[fp]:r.GEQUAL,[up]:r.GREATER,[dp]:r.NOTEQUAL};function Ge(R,b){if(b.type===Mn&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===Vt||b.magFilter===Xa||b.magFilter===Cr||b.magFilter===ni||b.minFilter===Vt||b.minFilter===Xa||b.minFilter===Cr||b.minFilter===ni)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(R,r.TEXTURE_WRAP_S,_e[b.wrapS]),r.texParameteri(R,r.TEXTURE_WRAP_T,_e[b.wrapT]),(R===r.TEXTURE_3D||R===r.TEXTURE_2D_ARRAY)&&r.texParameteri(R,r.TEXTURE_WRAP_R,_e[b.wrapR]),r.texParameteri(R,r.TEXTURE_MAG_FILTER,be[b.magFilter]),r.texParameteri(R,r.TEXTURE_MIN_FILTER,be[b.minFilter]),b.compareFunction&&(r.texParameteri(R,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(R,r.TEXTURE_COMPARE_FUNC,Re[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Qt||b.minFilter!==Cr&&b.minFilter!==ni||b.type===Mn&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");r.texParameterf(R,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,i.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function it(R,b){let H=!1;R.__webglInit===void 0&&(R.__webglInit=!0,b.addEventListener("dispose",T));const k=b.source;let X=f.get(k);X===void 0&&(X={},f.set(k,X));const W=V(b);if(W!==R.__cacheKey){X[W]===void 0&&(X[W]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,H=!0),X[W].usedTimes++;const ce=X[R.__cacheKey];ce!==void 0&&(X[R.__cacheKey].usedTimes--,ce.usedTimes===0&&S(b)),R.__cacheKey=W,R.__webglTexture=X[W].texture}return H}function Q(R,b,H){let k=r.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(k=r.TEXTURE_2D_ARRAY),b.isData3DTexture&&(k=r.TEXTURE_3D);const X=it(R,b),W=b.source;t.bindTexture(k,R.__webglTexture,r.TEXTURE0+H);const ce=n.get(W);if(W.version!==ce.__version||X===!0){t.activeTexture(r.TEXTURE0+H);const oe=ht.getPrimaries(ht.workingColorSpace),ge=b.colorSpace===wi?null:ht.getPrimaries(b.colorSpace),Be=b.colorSpace===wi||oe===ge?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be);let $=_(b.image,!1,i.maxTextureSize);$=Ve(b,$);const ve=s.convert(b.format,b.colorSpace),Y=s.convert(b.type);let ie=v(b.internalFormat,ve,Y,b.colorSpace,b.isVideoTexture);Ge(k,b);let ae;const Ne=b.mipmaps,Pe=b.isVideoTexture!==!0,Ke=ce.__version===void 0||X===!0,U=W.dataReady,ye=w(b,$);if(b.isDepthTexture)ie=x(b.format===js,b.type),Ke&&(Pe?t.texStorage2D(r.TEXTURE_2D,1,ie,$.width,$.height):t.texImage2D(r.TEXTURE_2D,0,ie,$.width,$.height,0,ve,Y,null));else if(b.isDataTexture)if(Ne.length>0){Pe&&Ke&&t.texStorage2D(r.TEXTURE_2D,ye,ie,Ne[0].width,Ne[0].height);for(let K=0,ee=Ne.length;K<ee;K++)ae=Ne[K],Pe?U&&t.texSubImage2D(r.TEXTURE_2D,K,0,0,ae.width,ae.height,ve,Y,ae.data):t.texImage2D(r.TEXTURE_2D,K,ie,ae.width,ae.height,0,ve,Y,ae.data);b.generateMipmaps=!1}else Pe?(Ke&&t.texStorage2D(r.TEXTURE_2D,ye,ie,$.width,$.height),U&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,$.width,$.height,ve,Y,$.data)):t.texImage2D(r.TEXTURE_2D,0,ie,$.width,$.height,0,ve,Y,$.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Pe&&Ke&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ye,ie,Ne[0].width,Ne[0].height,$.depth);for(let K=0,ee=Ne.length;K<ee;K++)if(ae=Ne[K],b.format!==dn)if(ve!==null)if(Pe){if(U)if(b.layerUpdates.size>0){const we=yc(ae.width,ae.height,b.format,b.type);for(const Me of b.layerUpdates){const Ye=ae.data.subarray(Me*we/ae.data.BYTES_PER_ELEMENT,(Me+1)*we/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,K,0,0,Me,ae.width,ae.height,1,ve,Ye)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,K,0,0,0,ae.width,ae.height,$.depth,ve,ae.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,K,ie,ae.width,ae.height,$.depth,0,ae.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Pe?U&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,K,0,0,0,ae.width,ae.height,$.depth,ve,Y,ae.data):t.texImage3D(r.TEXTURE_2D_ARRAY,K,ie,ae.width,ae.height,$.depth,0,ve,Y,ae.data)}else{Pe&&Ke&&t.texStorage2D(r.TEXTURE_2D,ye,ie,Ne[0].width,Ne[0].height);for(let K=0,ee=Ne.length;K<ee;K++)ae=Ne[K],b.format!==dn?ve!==null?Pe?U&&t.compressedTexSubImage2D(r.TEXTURE_2D,K,0,0,ae.width,ae.height,ve,ae.data):t.compressedTexImage2D(r.TEXTURE_2D,K,ie,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Pe?U&&t.texSubImage2D(r.TEXTURE_2D,K,0,0,ae.width,ae.height,ve,Y,ae.data):t.texImage2D(r.TEXTURE_2D,K,ie,ae.width,ae.height,0,ve,Y,ae.data)}else if(b.isDataArrayTexture)if(Pe){if(Ke&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ye,ie,$.width,$.height,$.depth),U)if(b.layerUpdates.size>0){const K=yc($.width,$.height,b.format,b.type);for(const ee of b.layerUpdates){const we=$.data.subarray(ee*K/$.data.BYTES_PER_ELEMENT,(ee+1)*K/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ee,$.width,$.height,1,ve,Y,we)}b.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ve,Y,$.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,ie,$.width,$.height,$.depth,0,ve,Y,$.data);else if(b.isData3DTexture)Pe?(Ke&&t.texStorage3D(r.TEXTURE_3D,ye,ie,$.width,$.height,$.depth),U&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ve,Y,$.data)):t.texImage3D(r.TEXTURE_3D,0,ie,$.width,$.height,$.depth,0,ve,Y,$.data);else if(b.isFramebufferTexture){if(Ke)if(Pe)t.texStorage2D(r.TEXTURE_2D,ye,ie,$.width,$.height);else{let K=$.width,ee=$.height;for(let we=0;we<ye;we++)t.texImage2D(r.TEXTURE_2D,we,ie,K,ee,0,ve,Y,null),K>>=1,ee>>=1}}else if(Ne.length>0){if(Pe&&Ke){const K=Se(Ne[0]);t.texStorage2D(r.TEXTURE_2D,ye,ie,K.width,K.height)}for(let K=0,ee=Ne.length;K<ee;K++)ae=Ne[K],Pe?U&&t.texSubImage2D(r.TEXTURE_2D,K,0,0,ve,Y,ae):t.texImage2D(r.TEXTURE_2D,K,ie,ve,Y,ae);b.generateMipmaps=!1}else if(Pe){if(Ke){const K=Se($);t.texStorage2D(r.TEXTURE_2D,ye,ie,K.width,K.height)}U&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,ve,Y,$)}else t.texImage2D(r.TEXTURE_2D,0,ie,ve,Y,$);g(b)&&m(k),ce.__version=W.version,b.onUpdate&&b.onUpdate(b)}R.__version=b.version}function ue(R,b,H){if(b.image.length!==6)return;const k=it(R,b),X=b.source;t.bindTexture(r.TEXTURE_CUBE_MAP,R.__webglTexture,r.TEXTURE0+H);const W=n.get(X);if(X.version!==W.__version||k===!0){t.activeTexture(r.TEXTURE0+H);const ce=ht.getPrimaries(ht.workingColorSpace),oe=b.colorSpace===wi?null:ht.getPrimaries(b.colorSpace),ge=b.colorSpace===wi||ce===oe?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,b.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,b.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge);const Be=b.isCompressedTexture||b.image[0].isCompressedTexture,$=b.image[0]&&b.image[0].isDataTexture,ve=[];for(let ee=0;ee<6;ee++)!Be&&!$?ve[ee]=_(b.image[ee],!0,i.maxCubemapSize):ve[ee]=$?b.image[ee].image:b.image[ee],ve[ee]=Ve(b,ve[ee]);const Y=ve[0],ie=s.convert(b.format,b.colorSpace),ae=s.convert(b.type),Ne=v(b.internalFormat,ie,ae,b.colorSpace),Pe=b.isVideoTexture!==!0,Ke=W.__version===void 0||k===!0,U=X.dataReady;let ye=w(b,Y);Ge(r.TEXTURE_CUBE_MAP,b);let K;if(Be){Pe&&Ke&&t.texStorage2D(r.TEXTURE_CUBE_MAP,ye,Ne,Y.width,Y.height);for(let ee=0;ee<6;ee++){K=ve[ee].mipmaps;for(let we=0;we<K.length;we++){const Me=K[we];b.format!==dn?ie!==null?Pe?U&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,Me.width,Me.height,ie,Me.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,Ne,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Pe?U&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,Me.width,Me.height,ie,ae,Me.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,Ne,Me.width,Me.height,0,ie,ae,Me.data)}}}else{if(K=b.mipmaps,Pe&&Ke){K.length>0&&ye++;const ee=Se(ve[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,ye,Ne,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if($){Pe?U&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ve[ee].width,ve[ee].height,ie,ae,ve[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ne,ve[ee].width,ve[ee].height,0,ie,ae,ve[ee].data);for(let we=0;we<K.length;we++){const Ye=K[we].image[ee].image;Pe?U&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,Ye.width,Ye.height,ie,ae,Ye.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,Ne,Ye.width,Ye.height,0,ie,ae,Ye.data)}}else{Pe?U&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ie,ae,ve[ee]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ne,ie,ae,ve[ee]);for(let we=0;we<K.length;we++){const Me=K[we];Pe?U&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,ie,ae,Me.image[ee]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,Ne,ie,ae,Me.image[ee])}}}g(b)&&m(r.TEXTURE_CUBE_MAP),W.__version=X.version,b.onUpdate&&b.onUpdate(b)}R.__version=b.version}function Ie(R,b,H,k,X,W){const ce=s.convert(H.format,H.colorSpace),oe=s.convert(H.type),ge=v(H.internalFormat,ce,oe,H.colorSpace),Be=n.get(b),$=n.get(H);if($.__renderTarget=b,!Be.__hasExternalTextures){const ve=Math.max(1,b.width>>W),Y=Math.max(1,b.height>>W);X===r.TEXTURE_3D||X===r.TEXTURE_2D_ARRAY?t.texImage3D(X,W,ge,ve,Y,b.depth,0,ce,oe,null):t.texImage2D(X,W,ge,ve,Y,0,ce,oe,null)}t.bindFramebuffer(r.FRAMEBUFFER,R),Ae(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,k,X,$.__webglTexture,0,re(b)):(X===r.TEXTURE_2D||X>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&X<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,k,X,$.__webglTexture,W),t.bindFramebuffer(r.FRAMEBUFFER,null)}function pe(R,b,H){if(r.bindRenderbuffer(r.RENDERBUFFER,R),b.depthBuffer){const k=b.depthTexture,X=k&&k.isDepthTexture?k.type:null,W=x(b.stencilBuffer,X),ce=b.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,oe=re(b);Ae(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,oe,W,b.width,b.height):H?r.renderbufferStorageMultisample(r.RENDERBUFFER,oe,W,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,W,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,ce,r.RENDERBUFFER,R)}else{const k=b.textures;for(let X=0;X<k.length;X++){const W=k[X],ce=s.convert(W.format,W.colorSpace),oe=s.convert(W.type),ge=v(W.internalFormat,ce,oe,W.colorSpace),Be=re(b);H&&Ae(b)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Be,ge,b.width,b.height):Ae(b)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Be,ge,b.width,b.height):r.renderbufferStorage(r.RENDERBUFFER,ge,b.width,b.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Oe(R,b){if(b&&b.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,R),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const k=n.get(b.depthTexture);k.__renderTarget=b,(!k.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),J(b.depthTexture,0);const X=k.__webglTexture,W=re(b);if(b.depthTexture.format===Ys)Ae(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,X,0,W):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,X,0);else if(b.depthTexture.format===js)Ae(b)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,X,0,W):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,X,0);else throw new Error("Unknown depthTexture format")}function We(R){const b=n.get(R),H=R.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==R.depthTexture){const k=R.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),k){const X=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,k.removeEventListener("dispose",X)};k.addEventListener("dispose",X),b.__depthDisposeCallback=X}b.__boundDepthTexture=k}if(R.depthTexture&&!b.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");Oe(b.__webglFramebuffer,R)}else if(H){b.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[k]),b.__webglDepthbuffer[k]===void 0)b.__webglDepthbuffer[k]=r.createRenderbuffer(),pe(b.__webglDepthbuffer[k],R,!1);else{const X=R.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,W=b.__webglDepthbuffer[k];r.bindRenderbuffer(r.RENDERBUFFER,W),r.framebufferRenderbuffer(r.FRAMEBUFFER,X,r.RENDERBUFFER,W)}}else if(t.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=r.createRenderbuffer(),pe(b.__webglDepthbuffer,R,!1);else{const k=R.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,X=b.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,X),r.framebufferRenderbuffer(r.FRAMEBUFFER,k,r.RENDERBUFFER,X)}t.bindFramebuffer(r.FRAMEBUFFER,null)}function ze(R,b,H){const k=n.get(R);b!==void 0&&Ie(k.__webglFramebuffer,R,R.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),H!==void 0&&We(R)}function Je(R){const b=R.texture,H=n.get(R),k=n.get(b);R.addEventListener("dispose",C);const X=R.textures,W=R.isWebGLCubeRenderTarget===!0,ce=X.length>1;if(ce||(k.__webglTexture===void 0&&(k.__webglTexture=r.createTexture()),k.__version=b.version,a.memory.textures++),W){H.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer[oe]=[];for(let ge=0;ge<b.mipmaps.length;ge++)H.__webglFramebuffer[oe][ge]=r.createFramebuffer()}else H.__webglFramebuffer[oe]=r.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){H.__webglFramebuffer=[];for(let oe=0;oe<b.mipmaps.length;oe++)H.__webglFramebuffer[oe]=r.createFramebuffer()}else H.__webglFramebuffer=r.createFramebuffer();if(ce)for(let oe=0,ge=X.length;oe<ge;oe++){const Be=n.get(X[oe]);Be.__webglTexture===void 0&&(Be.__webglTexture=r.createTexture(),a.memory.textures++)}if(R.samples>0&&Ae(R)===!1){H.__webglMultisampledFramebuffer=r.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let oe=0;oe<X.length;oe++){const ge=X[oe];H.__webglColorRenderbuffer[oe]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,H.__webglColorRenderbuffer[oe]);const Be=s.convert(ge.format,ge.colorSpace),$=s.convert(ge.type),ve=v(ge.internalFormat,Be,$,ge.colorSpace,R.isXRRenderTarget===!0),Y=re(R);r.renderbufferStorageMultisample(r.RENDERBUFFER,Y,ve,R.width,R.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+oe,r.RENDERBUFFER,H.__webglColorRenderbuffer[oe])}r.bindRenderbuffer(r.RENDERBUFFER,null),R.depthBuffer&&(H.__webglDepthRenderbuffer=r.createRenderbuffer(),pe(H.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(W){t.bindTexture(r.TEXTURE_CUBE_MAP,k.__webglTexture),Ge(r.TEXTURE_CUBE_MAP,b);for(let oe=0;oe<6;oe++)if(b.mipmaps&&b.mipmaps.length>0)for(let ge=0;ge<b.mipmaps.length;ge++)Ie(H.__webglFramebuffer[oe][ge],R,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+oe,ge);else Ie(H.__webglFramebuffer[oe],R,b,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0);g(b)&&m(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ce){for(let oe=0,ge=X.length;oe<ge;oe++){const Be=X[oe],$=n.get(Be);t.bindTexture(r.TEXTURE_2D,$.__webglTexture),Ge(r.TEXTURE_2D,Be),Ie(H.__webglFramebuffer,R,Be,r.COLOR_ATTACHMENT0+oe,r.TEXTURE_2D,0),g(Be)&&m(r.TEXTURE_2D)}t.unbindTexture()}else{let oe=r.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(oe=R.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(oe,k.__webglTexture),Ge(oe,b),b.mipmaps&&b.mipmaps.length>0)for(let ge=0;ge<b.mipmaps.length;ge++)Ie(H.__webglFramebuffer[ge],R,b,r.COLOR_ATTACHMENT0,oe,ge);else Ie(H.__webglFramebuffer,R,b,r.COLOR_ATTACHMENT0,oe,0);g(b)&&m(oe),t.unbindTexture()}R.depthBuffer&&We(R)}function te(R){const b=R.textures;for(let H=0,k=b.length;H<k;H++){const X=b[H];if(g(X)){const W=y(R),ce=n.get(X).__webglTexture;t.bindTexture(W,ce),m(W),t.unbindTexture()}}}const de=[],I=[];function De(R){if(R.samples>0){if(Ae(R)===!1){const b=R.textures,H=R.width,k=R.height;let X=r.COLOR_BUFFER_BIT;const W=R.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ce=n.get(R),oe=b.length>1;if(oe)for(let ge=0;ge<b.length;ge++)t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let ge=0;ge<b.length;ge++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(X|=r.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(X|=r.STENCIL_BUFFER_BIT)),oe){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,ce.__webglColorRenderbuffer[ge]);const Be=n.get(b[ge]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Be,0)}r.blitFramebuffer(0,0,H,k,0,0,H,k,X,r.NEAREST),l===!0&&(de.length=0,I.length=0,de.push(r.COLOR_ATTACHMENT0+ge),R.depthBuffer&&R.resolveDepthBuffer===!1&&(de.push(W),I.push(W),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,I)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,de))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),oe)for(let ge=0;ge<b.length;ge++){t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,ce.__webglColorRenderbuffer[ge]);const Be=n.get(b[ge]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,ce.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.TEXTURE_2D,Be,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const b=R.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[b])}}}function re(R){return Math.min(i.maxSamples,R.samples)}function Ae(R){const b=n.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function me(R){const b=a.render.frame;h.get(R)!==b&&(h.set(R,b),R.update())}function Ve(R,b){const H=R.colorSpace,k=R.format,X=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||H!==Qs&&H!==wi&&(ht.getTransfer(H)===vt?(k!==dn||X!==li)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),b}function Se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=F,this.resetTextureUnits=G,this.setTexture2D=J,this.setTexture2DArray=q,this.setTexture3D=se,this.setTextureCube=Z,this.rebindTextures=ze,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=te,this.updateMultisampleRenderTarget=De,this.setupDepthRenderbuffer=We,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=Ae}function Sy(r,e){function t(n,i=wi){let s;const a=ht.getTransfer(i);if(n===li)return r.UNSIGNED_BYTE;if(n===Dc)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Lc)return r.UNSIGNED_SHORT_5_5_5_1;if(n===fd)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===ud)return r.BYTE;if(n===dd)return r.SHORT;if(n===kr)return r.UNSIGNED_SHORT;if(n===Pc)return r.INT;if(n===Ii)return r.UNSIGNED_INT;if(n===Mn)return r.FLOAT;if(n===si)return r.HALF_FLOAT;if(n===pd)return r.ALPHA;if(n===md)return r.RGB;if(n===dn)return r.RGBA;if(n===gd)return r.LUMINANCE;if(n===_d)return r.LUMINANCE_ALPHA;if(n===Ys)return r.DEPTH_COMPONENT;if(n===js)return r.DEPTH_STENCIL;if(n===Uc)return r.RED;if(n===So)return r.RED_INTEGER;if(n===vd)return r.RG;if(n===Nc)return r.RG_INTEGER;if(n===Fc)return r.RGBA_INTEGER;if(n===qa||n===Ya||n===Za||n===Ja)if(a===vt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===qa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ya)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Za)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ja)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===qa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ya)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Za)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ja)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===kl||n===Vl||n===Hl||n===Gl)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===kl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Vl)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Hl)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Wl||n===Xl||n===ql)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Wl||n===Xl)return a===vt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ql)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Yl||n===Zl||n===Jl||n===Kl||n===$l||n===jl||n===Ql||n===ec||n===tc||n===nc||n===ic||n===sc||n===rc||n===ac)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Yl)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Zl)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Jl)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Kl)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===$l)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===jl)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ql)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ec)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===tc)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===nc)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ic)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===sc)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===rc)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ac)return a===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ka||n===oc||n===lc)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Ka)return a===vt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===oc)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===lc)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xd||n===cc||n===hc||n===uc)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Ka)return s.COMPRESSED_RED_RGTC1_EXT;if(n===cc)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===hc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===uc)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===$s?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const wy={type:"move"};class wl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ns,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ns,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ns,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const g=t.getJointPose(_,n),m=this._getHandJoint(c,_);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,p=.005;c.inputState.pinching&&f>d+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(wy)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ns;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Ey=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,Ty=`
|
||
uniform sampler2DArray depthColor;
|
||
uniform float depthWidth;
|
||
uniform float depthHeight;
|
||
|
||
void main() {
|
||
|
||
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
||
|
||
if ( coord.x >= 1.0 ) {
|
||
|
||
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
||
|
||
} else {
|
||
|
||
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
||
|
||
}
|
||
|
||
}`;class Ay{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new Et,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Xt({vertexShader:Ey,fragmentShader:Ty,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new lr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Cy extends ci{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,f=null,d=null,p=null;const _=new Ay,g=t.getContextAttributes();let m=null,y=null;const v=[],x=[],w=new j;let T=null;const C=new kt;C.viewport=new pt;const P=new kt;P.viewport=new pt;const S=[C,P],M=new Ag;let D=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let ue=v[Q];return ue===void 0&&(ue=new wl,v[Q]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(Q){let ue=v[Q];return ue===void 0&&(ue=new wl,v[Q]=ue),ue.getGripSpace()},this.getHand=function(Q){let ue=v[Q];return ue===void 0&&(ue=new wl,v[Q]=ue),ue.getHandSpace()};function F(Q){const ue=x.indexOf(Q.inputSource);if(ue===-1)return;const Ie=v[ue];Ie!==void 0&&(Ie.update(Q.inputSource,Q.frame,c||a),Ie.dispatchEvent({type:Q.type,data:Q.inputSource}))}function V(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",J);for(let Q=0;Q<v.length;Q++){const ue=x[Q];ue!==null&&(x[Q]=null,v[Q].disconnect(ue))}D=null,G=null,_.reset(),e.setRenderTarget(m),d=null,f=null,u=null,i=null,y=null,it.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(w.width,w.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){s=Q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){o=Q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Q){c=Q},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Q){if(i=Q,i!==null){if(m=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",V),i.addEventListener("inputsourceschange",J),g.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(w),i.enabledFeatures!==void 0&&i.enabledFeatures.includes("layers")){let Ie=null,pe=null,Oe=null;g.depth&&(Oe=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ie=g.stencil?js:Ys,pe=g.stencil?$s:Ii);const We={colorFormat:t.RGBA8,depthFormat:Oe,scaleFactor:s};u=new XRWebGLBinding(i,t),f=u.createProjectionLayer(We),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),y=new Sn(f.textureWidth,f.textureHeight,{format:dn,type:li,depthTexture:new Ld(f.textureWidth,f.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,Ie),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}else{const Ie={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,Ie),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),y=new Sn(d.framebufferWidth,d.framebufferHeight,{format:dn,type:li,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),it.setContext(i),it.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function J(Q){for(let ue=0;ue<Q.removed.length;ue++){const Ie=Q.removed[ue],pe=x.indexOf(Ie);pe>=0&&(x[pe]=null,v[pe].disconnect(Ie))}for(let ue=0;ue<Q.added.length;ue++){const Ie=Q.added[ue];let pe=x.indexOf(Ie);if(pe===-1){for(let We=0;We<v.length;We++)if(We>=x.length){x.push(Ie),pe=We;break}else if(x[We]===null){x[We]=Ie,pe=We;break}if(pe===-1)break}const Oe=v[pe];Oe&&Oe.connect(Ie)}}const q=new A,se=new A;function Z(Q,ue,Ie){q.setFromMatrixPosition(ue.matrixWorld),se.setFromMatrixPosition(Ie.matrixWorld);const pe=q.distanceTo(se),Oe=ue.projectionMatrix.elements,We=Ie.projectionMatrix.elements,ze=Oe[14]/(Oe[10]-1),Je=Oe[14]/(Oe[10]+1),te=(Oe[9]+1)/Oe[5],de=(Oe[9]-1)/Oe[5],I=(Oe[8]-1)/Oe[0],De=(We[8]+1)/We[0],re=ze*I,Ae=ze*De,me=pe/(-I+De),Ve=me*-I;if(ue.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(Ve),Q.translateZ(me),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),Oe[10]===-1)Q.projectionMatrix.copy(ue.projectionMatrix),Q.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const Se=ze+me,R=Je+me,b=re-Ve,H=Ae+(pe-Ve),k=te*Je/R*Se,X=de*Je/R*Se;Q.projectionMatrix.makePerspective(b,H,k,X,Se,R),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function _e(Q,ue){ue===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(ue.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(i===null)return;let ue=Q.near,Ie=Q.far;_.texture!==null&&(_.depthNear>0&&(ue=_.depthNear),_.depthFar>0&&(Ie=_.depthFar)),M.near=P.near=C.near=ue,M.far=P.far=C.far=Ie,(D!==M.near||G!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),D=M.near,G=M.far),C.layers.mask=Q.layers.mask|2,P.layers.mask=Q.layers.mask|4,M.layers.mask=C.layers.mask|P.layers.mask;const pe=Q.parent,Oe=M.cameras;_e(M,pe);for(let We=0;We<Oe.length;We++)_e(Oe[We],pe);Oe.length===2?Z(M,C,P):M.projectionMatrix.copy(C.projectionMatrix),be(Q,M,pe)};function be(Q,ue,Ie){Ie===null?Q.matrix.copy(ue.matrixWorld):(Q.matrix.copy(Ie.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(ue.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(ue.projectionMatrix),Q.projectionMatrixInverse.copy(ue.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=er*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&d===null))return l},this.setFoveation=function(Q){l=Q,f!==null&&(f.fixedFoveation=Q),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(M)};let Re=null;function Ge(Q,ue){if(h=ue.getViewerPose(c||a),p=ue,h!==null){const Ie=h.views;d!==null&&(e.setRenderTargetFramebuffer(y,d.framebuffer),e.setRenderTarget(y));let pe=!1;Ie.length!==M.cameras.length&&(M.cameras.length=0,pe=!0);for(let We=0;We<Ie.length;We++){const ze=Ie[We];let Je=null;if(d!==null)Je=d.getViewport(ze);else{const de=u.getViewSubImage(f,ze);Je=de.viewport,We===0&&(e.setRenderTargetTextures(y,de.colorTexture,f.ignoreDepthValues?void 0:de.depthStencilTexture),e.setRenderTarget(y))}let te=S[We];te===void 0&&(te=new kt,te.layers.enable(We),te.viewport=new pt,S[We]=te),te.matrix.fromArray(ze.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(ze.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(Je.x,Je.y,Je.width,Je.height),We===0&&(M.matrix.copy(te.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),pe===!0&&M.cameras.push(te)}const Oe=i.enabledFeatures;if(Oe&&Oe.includes("depth-sensing")){const We=u.getDepthInformation(Ie[0]);We&&We.isValid&&We.texture&&_.init(e,We,i.renderState)}}for(let Ie=0;Ie<v.length;Ie++){const pe=x[Ie],Oe=v[Ie];pe!==null&&Oe!==void 0&&Oe.update(pe,ue,c||a)}Re&&Re(Q,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),p=null}const it=new tf;it.setAnimationLoop(Ge),this.setAnimationLoop=function(Q){Re=Q},this.dispose=function(){}}}const Zi=new In,Ry=new Ze;function Iy(r,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Ad(r)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),f(g,m),m.isMeshPhysicalMaterial&&d(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),_(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?l(g,m,y,v):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(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,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===fn&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===fn&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=e.get(m),v=y.envMap,x=y.envMapRotation;v&&(g.envMap.value=v,Zi.copy(x),Zi.x*=-1,Zi.y*=-1,Zi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Zi.y*=-1,Zi.z*=-1),g.envMapRotation.value.setFromMatrix4(Ry.makeRotationFromEuler(Zi)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,y,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=v*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(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,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function f(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===fn&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function _(g,m){const y=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Py(r,e,t,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const x=v.program;n.uniformBlockBinding(y,x)}function c(y,v){let x=i[y.id];x===void 0&&(p(y),x=h(y),i[y.id]=x,y.addEventListener("dispose",g));const w=v.program;n.updateUBOMapping(y,w);const T=e.render.frame;s[y.id]!==T&&(f(y),s[y.id]=T)}function h(y){const v=u();y.__bindingPointIndex=v;const x=r.createBuffer(),w=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,w,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,x),x}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){const v=i[y.id],x=y.uniforms,w=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,v);for(let T=0,C=x.length;T<C;T++){const P=Array.isArray(x[T])?x[T]:[x[T]];for(let S=0,M=P.length;S<M;S++){const D=P[S];if(d(D,T,S,w)===!0){const G=D.__offset,F=Array.isArray(D.value)?D.value:[D.value];let V=0;for(let J=0;J<F.length;J++){const q=F[J],se=_(q);typeof q=="number"||typeof q=="boolean"?(D.__data[0]=q,r.bufferSubData(r.UNIFORM_BUFFER,G+V,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=0,D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=0,D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=0):(q.toArray(D.__data,V),V+=se.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,G,D.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(y,v,x,w){const T=y.value,C=v+"_"+x;if(w[C]===void 0)return typeof T=="number"||typeof T=="boolean"?w[C]=T:w[C]=T.clone(),!0;{const P=w[C];if(typeof T=="number"||typeof T=="boolean"){if(P!==T)return w[C]=T,!0}else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function p(y){const v=y.uniforms;let x=0;const w=16;for(let C=0,P=v.length;C<P;C++){const S=Array.isArray(v[C])?v[C]:[v[C]];for(let M=0,D=S.length;M<D;M++){const G=S[M],F=Array.isArray(G.value)?G.value:[G.value];for(let V=0,J=F.length;V<J;V++){const q=F[V],se=_(q),Z=x%w,_e=Z%se.boundary,be=Z+_e;x+=_e,be!==0&&w-be<se.storage&&(x+=w-be),G.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=x,x+=se.storage}}}const T=x%w;return T>0&&(x+=w-T),y.__size=x,y.__cache={},this}function _(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),v}function g(y){const v=y.target;v.removeEventListener("dispose",g);const x=a.indexOf(v.__bindingPointIndex);a.splice(x,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function m(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:m}}class Dy{constructor(e={}){const{canvas:t=Dp(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:f=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),_=new Int32Array(4);let g=null,m=null;const y=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=xn,this.toneMapping=Ti,this.toneMappingExposure=1;const x=this;let w=!1,T=0,C=0,P=null,S=-1,M=null;const D=new pt,G=new pt;let F=null;const V=new ne(0);let J=0,q=t.width,se=t.height,Z=1,_e=null,be=null;const Re=new pt(0,0,q,se),Ge=new pt(0,0,q,se);let it=!1;const Q=new To;let ue=!1,Ie=!1;this.transmissionResolutionScale=1;const pe=new Ze,Oe=new Ze,We=new A,ze=new pt,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let te=!1;function de(){return P===null?Z:1}let I=n;function De(E,B){return t.getContext(E,B)}try{const E={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Rc}`),t.addEventListener("webglcontextlost",ee,!1),t.addEventListener("webglcontextrestored",we,!1),t.addEventListener("webglcontextcreationerror",Me,!1),I===null){const B="webgl2";if(I=De(B,E),I===null)throw De(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let re,Ae,me,Ve,Se,R,b,H,k,X,W,ce,oe,ge,Be,$,ve,Y,ie,ae,Ne,Pe,Ke,U;function ye(){re=new Vv(I),re.init(),Pe=new Sy(I,re),Ae=new Nv(I,re,e,Pe),me=new My(I,re),Ae.reverseDepthBuffer&&f&&me.buffers.depth.setReversed(!0),Ve=new Wv(I),Se=new ly,R=new by(I,re,me,Se,Ae,Pe,Ve),b=new Ov(x),H=new kv(x),k=new $g(I),Ke=new Lv(I,k),X=new Hv(I,k,Ve,Ke),W=new qv(I,X,k,Ve),ie=new Xv(I,Ae,R),$=new Fv(Se),ce=new oy(x,b,H,re,Ae,Ke,$),oe=new Iy(x,Se),ge=new hy,Be=new gy(re),Y=new Dv(x,b,H,me,W,d,l),ve=new xy(x,W,Ae),U=new Py(I,Ve,Ae,me),ae=new Uv(I,re,Ve),Ne=new Gv(I,re,Ve),Ve.programs=ce.programs,x.capabilities=Ae,x.extensions=re,x.properties=Se,x.renderLists=ge,x.shadowMap=ve,x.state=me,x.info=Ve}ye();const K=new Cy(x,I);this.xr=K,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const E=re.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=re.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(E){E!==void 0&&(Z=E,this.setSize(q,se,!1))},this.getSize=function(E){return E.set(q,se)},this.setSize=function(E,B,N=!0){if(K.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}q=E,se=B,t.width=Math.floor(E*Z),t.height=Math.floor(B*Z),N===!0&&(t.style.width=E+"px",t.style.height=B+"px"),this.setViewport(0,0,E,B)},this.getDrawingBufferSize=function(E){return E.set(q*Z,se*Z).floor()},this.setDrawingBufferSize=function(E,B,N){q=E,se=B,Z=N,t.width=Math.floor(E*N),t.height=Math.floor(B*N),this.setViewport(0,0,E,B)},this.getCurrentViewport=function(E){return E.copy(D)},this.getViewport=function(E){return E.copy(Re)},this.setViewport=function(E,B,N,z){E.isVector4?Re.set(E.x,E.y,E.z,E.w):Re.set(E,B,N,z),me.viewport(D.copy(Re).multiplyScalar(Z).round())},this.getScissor=function(E){return E.copy(Ge)},this.setScissor=function(E,B,N,z){E.isVector4?Ge.set(E.x,E.y,E.z,E.w):Ge.set(E,B,N,z),me.scissor(G.copy(Ge).multiplyScalar(Z).round())},this.getScissorTest=function(){return it},this.setScissorTest=function(E){me.setScissorTest(it=E)},this.setOpaqueSort=function(E){_e=E},this.setTransparentSort=function(E){be=E},this.getClearColor=function(E){return E.copy(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=!0,B=!0,N=!0){let z=0;if(E){let O=!1;if(P!==null){const he=P.texture.format;O=he===Fc||he===Nc||he===So}if(O){const he=P.texture.type,Ce=he===li||he===Ii||he===kr||he===$s||he===Dc||he===Lc,Le=Y.getClearColor(),Ue=Y.getClearAlpha(),$e=Le.r,je=Le.g,He=Le.b;Ce?(p[0]=$e,p[1]=je,p[2]=He,p[3]=Ue,I.clearBufferuiv(I.COLOR,0,p)):(_[0]=$e,_[1]=je,_[2]=He,_[3]=Ue,I.clearBufferiv(I.COLOR,0,_))}else z|=I.COLOR_BUFFER_BIT}B&&(z|=I.DEPTH_BUFFER_BIT),N&&(z|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ee,!1),t.removeEventListener("webglcontextrestored",we,!1),t.removeEventListener("webglcontextcreationerror",Me,!1),Y.dispose(),ge.dispose(),Be.dispose(),Se.dispose(),b.dispose(),H.dispose(),W.dispose(),Ke.dispose(),U.dispose(),ce.dispose(),K.dispose(),K.removeEventListener("sessionstart",Di),K.removeEventListener("sessionend",ui),En.stop()};function ee(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function we(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;const E=Ve.autoReset,B=ve.enabled,N=ve.autoUpdate,z=ve.needsUpdate,O=ve.type;ye(),Ve.autoReset=E,ve.enabled=B,ve.autoUpdate=N,ve.needsUpdate=z,ve.type=O}function Me(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Ye(E){const B=E.target;B.removeEventListener("dispose",Ye),Mt(B)}function Mt(E){St(E),Se.remove(E)}function St(E){const B=Se.get(E).programs;B!==void 0&&(B.forEach(function(N){ce.releaseProgram(N)}),E.isShaderMaterial&&ce.releaseShaderCache(E))}this.renderBufferDirect=function(E,B,N,z,O,he){B===null&&(B=Je);const Ce=O.isMesh&&O.matrixWorld.determinant()<0,Le=Nt(E,B,N,z,O);me.setMaterial(z,Ce);let Ue=N.index,$e=1;if(z.wireframe===!0){if(Ue=X.getWireframeAttribute(N),Ue===void 0)return;$e=2}const je=N.drawRange,He=N.attributes.position;let lt=je.start*$e,gt=(je.start+je.count)*$e;he!==null&&(lt=Math.max(lt,he.start*$e),gt=Math.min(gt,(he.start+he.count)*$e)),Ue!==null?(lt=Math.max(lt,0),gt=Math.min(gt,Ue.count)):He!=null&&(lt=Math.max(lt,0),gt=Math.min(gt,He.count));const Dt=gt-lt;if(Dt<0||Dt===1/0)return;Ke.setup(O,z,Le,N,Ue);let Tt,dt=ae;if(Ue!==null&&(Tt=k.get(Ue),dt=Ne,dt.setIndex(Tt)),O.isMesh)z.wireframe===!0?(me.setLineWidth(z.wireframeLinewidth*de()),dt.setMode(I.LINES)):dt.setMode(I.TRIANGLES);else if(O.isLine){let Xe=z.linewidth;Xe===void 0&&(Xe=1),me.setLineWidth(Xe*de()),O.isLineSegments?dt.setMode(I.LINES):O.isLineLoop?dt.setMode(I.LINE_LOOP):dt.setMode(I.LINE_STRIP)}else O.isPoints?dt.setMode(I.POINTS):O.isSprite&&dt.setMode(I.TRIANGLES);if(O.isBatchedMesh)if(O._multiDrawInstances!==null)dt.renderMultiDrawInstances(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount,O._multiDrawInstances);else if(re.get("WEBGL_multi_draw"))dt.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else{const Xe=O._multiDrawStarts,Gt=O._multiDrawCounts,_t=O._multiDrawCount,Pn=Ue?k.get(Ue).bytesPerElement:1,fs=Se.get(z).currentProgram.getUniforms();for(let gn=0;gn<_t;gn++)fs.setValue(I,"_gl_DrawID",gn),dt.render(Xe[gn]/Pn,Gt[gn])}else if(O.isInstancedMesh)dt.renderInstances(lt,Dt,O.count);else if(N.isInstancedBufferGeometry){const Xe=N._maxInstanceCount!==void 0?N._maxInstanceCount:1/0,Gt=Math.min(N.instanceCount,Xe);dt.renderInstances(lt,Dt,Gt)}else dt.render(lt,Dt)};function at(E,B,N){E.transparent===!0&&E.side===Bn&&E.forceSinglePass===!1?(E.side=fn,E.needsUpdate=!0,Fn(E,B,N),E.side=Ci,E.needsUpdate=!0,Fn(E,B,N),E.side=Bn):Fn(E,B,N)}this.compile=function(E,B,N=null){N===null&&(N=E),m=Be.get(N),m.init(B),v.push(m),N.traverseVisible(function(O){O.isLight&&O.layers.test(B.layers)&&(m.pushLight(O),O.castShadow&&m.pushShadow(O))}),E!==N&&E.traverseVisible(function(O){O.isLight&&O.layers.test(B.layers)&&(m.pushLight(O),O.castShadow&&m.pushShadow(O))}),m.setupLights();const z=new Set;return E.traverse(function(O){if(!(O.isMesh||O.isPoints||O.isLine||O.isSprite))return;const he=O.material;if(he)if(Array.isArray(he))for(let Ce=0;Ce<he.length;Ce++){const Le=he[Ce];at(Le,N,O),z.add(Le)}else at(he,N,O),z.add(he)}),v.pop(),m=null,z},this.compileAsync=function(E,B,N=null){const z=this.compile(E,B,N);return new Promise(O=>{function he(){if(z.forEach(function(Ce){Se.get(Ce).currentProgram.isReady()&&z.delete(Ce)}),z.size===0){O(E);return}setTimeout(he,10)}re.get("KHR_parallel_shader_compile")!==null?he():setTimeout(he,10)})};let Yt=null;function Ht(E){Yt&&Yt(E)}function Di(){En.stop()}function ui(){En.start()}const En=new tf;En.setAnimationLoop(Ht),typeof self<"u"&&En.setContext(self),this.setAnimationLoop=function(E){Yt=E,K.setAnimationLoop(E),E===null?En.stop():En.start()},K.addEventListener("sessionstart",Di),K.addEventListener("sessionend",ui),this.render=function(E,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(K.cameraAutoUpdate===!0&&K.updateCamera(B),B=K.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,B,P),m=Be.get(E,v.length),m.init(B),v.push(m),Oe.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),Q.setFromProjectionMatrix(Oe),Ie=this.localClippingEnabled,ue=$.init(this.clippingPlanes,Ie),g=ge.get(E,y.length),g.init(),y.push(g),K.enabled===!0&&K.isPresenting===!0){const he=x.xr.getDepthSensingMesh();he!==null&&di(he,B,-1/0,x.sortObjects)}di(E,B,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(_e,be),te=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,te&&Y.addToRenderList(g,E),this.info.render.frame++,ue===!0&&$.beginShadows();const N=m.state.shadowsArray;ve.render(N,E,B),ue===!0&&$.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=g.opaque,O=g.transmissive;if(m.setupLights(),B.isArrayCamera){const he=B.cameras;if(O.length>0)for(let Ce=0,Le=he.length;Ce<Le;Ce++){const Ue=he[Ce];Wn(z,O,E,Ue)}te&&Y.render(E);for(let Ce=0,Le=he.length;Ce<Le;Ce++){const Ue=he[Ce];Li(g,E,Ue,Ue.viewport)}}else O.length>0&&Wn(z,O,E,B),te&&Y.render(E),Li(g,E,B);P!==null&&C===0&&(R.updateMultisampleRenderTarget(P),R.updateRenderTargetMipmap(P)),E.isScene===!0&&E.onAfterRender(x,E,B),Ke.resetDefaultState(),S=-1,M=null,v.pop(),v.length>0?(m=v[v.length-1],ue===!0&&$.setGlobalState(x.clippingPlanes,m.state.camera)):m=null,y.pop(),y.length>0?g=y[y.length-1]:g=null};function di(E,B,N,z){if(E.visible===!1)return;if(E.layers.test(B.layers)){if(E.isGroup)N=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(B);else if(E.isLight)m.pushLight(E),E.castShadow&&m.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Q.intersectsSprite(E)){z&&ze.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Oe);const Ce=W.update(E),Le=E.material;Le.visible&&g.push(E,Ce,Le,N,ze.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Q.intersectsObject(E))){const Ce=W.update(E),Le=E.material;if(z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),ze.copy(E.boundingSphere.center)):(Ce.boundingSphere===null&&Ce.computeBoundingSphere(),ze.copy(Ce.boundingSphere.center)),ze.applyMatrix4(E.matrixWorld).applyMatrix4(Oe)),Array.isArray(Le)){const Ue=Ce.groups;for(let $e=0,je=Ue.length;$e<je;$e++){const He=Ue[$e],lt=Le[He.materialIndex];lt&<.visible&&g.push(E,Ce,lt,N,ze.z,He)}}else Le.visible&&g.push(E,Ce,Le,N,ze.z,null)}}const he=E.children;for(let Ce=0,Le=he.length;Ce<Le;Ce++)di(he[Ce],B,N,z)}function Li(E,B,N,z){const O=E.opaque,he=E.transmissive,Ce=E.transparent;m.setupLightsView(N),ue===!0&&$.setGlobalState(x.clippingPlanes,N),z&&me.viewport(D.copy(z)),O.length>0&&Xn(O,B,N),he.length>0&&Xn(he,B,N),Ce.length>0&&Xn(Ce,B,N),me.buffers.depth.setTest(!0),me.buffers.depth.setMask(!0),me.buffers.color.setMask(!0),me.setPolygonOffset(!1)}function Wn(E,B,N,z){if((N.isScene===!0?N.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[z.id]===void 0&&(m.state.transmissionRenderTarget[z.id]=new Sn(1,1,{generateMipmaps:!0,type:re.has("EXT_color_buffer_half_float")||re.has("EXT_color_buffer_float")?si:li,minFilter:ni,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ht.workingColorSpace}));const he=m.state.transmissionRenderTarget[z.id],Ce=z.viewport||D;he.setSize(Ce.z*x.transmissionResolutionScale,Ce.w*x.transmissionResolutionScale);const Le=x.getRenderTarget();x.setRenderTarget(he),x.getClearColor(V),J=x.getClearAlpha(),J<1&&x.setClearColor(16777215,.5),x.clear(),te&&Y.render(N);const Ue=x.toneMapping;x.toneMapping=Ti;const $e=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),m.setupLightsView(z),ue===!0&&$.setGlobalState(x.clippingPlanes,z),Xn(E,N,z),R.updateMultisampleRenderTarget(he),R.updateRenderTargetMipmap(he),re.has("WEBGL_multisampled_render_to_texture")===!1){let je=!1;for(let He=0,lt=B.length;He<lt;He++){const gt=B[He],Dt=gt.object,Tt=gt.geometry,dt=gt.material,Xe=gt.group;if(dt.side===Bn&&Dt.layers.test(z.layers)){const Gt=dt.side;dt.side=fn,dt.needsUpdate=!0,fi(Dt,N,z,Tt,dt,Xe),dt.side=Gt,dt.needsUpdate=!0,je=!0}}je===!0&&(R.updateMultisampleRenderTarget(he),R.updateRenderTargetMipmap(he))}x.setRenderTarget(Le),x.setClearColor(V,J),$e!==void 0&&(z.viewport=$e),x.toneMapping=Ue}function Xn(E,B,N){const z=B.isScene===!0?B.overrideMaterial:null;for(let O=0,he=E.length;O<he;O++){const Ce=E[O],Le=Ce.object,Ue=Ce.geometry,$e=z===null?Ce.material:z,je=Ce.group;Le.layers.test(N.layers)&&fi(Le,B,N,Ue,$e,je)}}function fi(E,B,N,z,O,he){E.onBeforeRender(x,B,N,z,O,he),E.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),O.onBeforeRender(x,B,N,z,E,he),O.transparent===!0&&O.side===Bn&&O.forceSinglePass===!1?(O.side=fn,O.needsUpdate=!0,x.renderBufferDirect(N,B,z,O,E,he),O.side=Ci,O.needsUpdate=!0,x.renderBufferDirect(N,B,z,O,E,he),O.side=Bn):x.renderBufferDirect(N,B,z,O,E,he),E.onAfterRender(x,B,N,z,O,he)}function Fn(E,B,N){B.isScene!==!0&&(B=Je);const z=Se.get(E),O=m.state.lights,he=m.state.shadowsArray,Ce=O.state.version,Le=ce.getParameters(E,O.state,he,B,N),Ue=ce.getProgramCacheKey(Le);let $e=z.programs;z.environment=E.isMeshStandardMaterial?B.environment:null,z.fog=B.fog,z.envMap=(E.isMeshStandardMaterial?H:b).get(E.envMap||z.environment),z.envMapRotation=z.environment!==null&&E.envMap===null?B.environmentRotation:E.envMapRotation,$e===void 0&&(E.addEventListener("dispose",Ye),$e=new Map,z.programs=$e);let je=$e.get(Ue);if(je!==void 0){if(z.currentProgram===je&&z.lightsStateVersion===Ce)return Zt(E,Le),je}else Le.uniforms=ce.getUniforms(E),E.onBeforeCompile(Le,x),je=ce.acquireProgram(Le,Ue),$e.set(Ue,je),z.uniforms=Le.uniforms;const He=z.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(He.clippingPlanes=$.uniform),Zt(E,Le),z.needsLights=Tn(E),z.lightsStateVersion=Ce,z.needsLights&&(He.ambientLightColor.value=O.state.ambient,He.lightProbe.value=O.state.probe,He.directionalLights.value=O.state.directional,He.directionalLightShadows.value=O.state.directionalShadow,He.spotLights.value=O.state.spot,He.spotLightShadows.value=O.state.spotShadow,He.rectAreaLights.value=O.state.rectArea,He.ltc_1.value=O.state.rectAreaLTC1,He.ltc_2.value=O.state.rectAreaLTC2,He.pointLights.value=O.state.point,He.pointLightShadows.value=O.state.pointShadow,He.hemisphereLights.value=O.state.hemi,He.directionalShadowMap.value=O.state.directionalShadowMap,He.directionalShadowMatrix.value=O.state.directionalShadowMatrix,He.spotShadowMap.value=O.state.spotShadowMap,He.spotLightMatrix.value=O.state.spotLightMatrix,He.spotLightMap.value=O.state.spotLightMap,He.pointShadowMap.value=O.state.pointShadowMap,He.pointShadowMatrix.value=O.state.pointShadowMatrix),z.currentProgram=je,z.uniformsList=null,je}function Ui(E){if(E.uniformsList===null){const B=E.currentProgram.getUniforms();E.uniformsList=$a.seqWithValue(B.seq,E.uniforms)}return E.uniformsList}function Zt(E,B){const N=Se.get(E);N.outputColorSpace=B.outputColorSpace,N.batching=B.batching,N.batchingColor=B.batchingColor,N.instancing=B.instancing,N.instancingColor=B.instancingColor,N.instancingMorph=B.instancingMorph,N.skinning=B.skinning,N.morphTargets=B.morphTargets,N.morphNormals=B.morphNormals,N.morphColors=B.morphColors,N.morphTargetsCount=B.morphTargetsCount,N.numClippingPlanes=B.numClippingPlanes,N.numIntersection=B.numClipIntersection,N.vertexAlphas=B.vertexAlphas,N.vertexTangents=B.vertexTangents,N.toneMapping=B.toneMapping}function Nt(E,B,N,z,O){B.isScene!==!0&&(B=Je),R.resetTextureUnits();const he=B.fog,Ce=z.isMeshStandardMaterial?B.environment:null,Le=P===null?x.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Qs,Ue=(z.isMeshStandardMaterial?H:b).get(z.envMap||Ce),$e=z.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,je=!!N.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),He=!!N.morphAttributes.position,lt=!!N.morphAttributes.normal,gt=!!N.morphAttributes.color;let Dt=Ti;z.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(Dt=x.toneMapping);const Tt=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,dt=Tt!==void 0?Tt.length:0,Xe=Se.get(z),Gt=m.state.lights;if(ue===!0&&(Ie===!0||E!==M)){const en=E===M&&z.id===S;$.setState(z,E,en)}let _t=!1;z.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Gt.state.version||Xe.outputColorSpace!==Le||O.isBatchedMesh&&Xe.batching===!1||!O.isBatchedMesh&&Xe.batching===!0||O.isBatchedMesh&&Xe.batchingColor===!0&&O.colorTexture===null||O.isBatchedMesh&&Xe.batchingColor===!1&&O.colorTexture!==null||O.isInstancedMesh&&Xe.instancing===!1||!O.isInstancedMesh&&Xe.instancing===!0||O.isSkinnedMesh&&Xe.skinning===!1||!O.isSkinnedMesh&&Xe.skinning===!0||O.isInstancedMesh&&Xe.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Xe.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Xe.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Xe.instancingMorph===!1&&O.morphTexture!==null||Xe.envMap!==Ue||z.fog===!0&&Xe.fog!==he||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==$.numPlanes||Xe.numIntersection!==$.numIntersection)||Xe.vertexAlphas!==$e||Xe.vertexTangents!==je||Xe.morphTargets!==He||Xe.morphNormals!==lt||Xe.morphColors!==gt||Xe.toneMapping!==Dt||Xe.morphTargetsCount!==dt)&&(_t=!0):(_t=!0,Xe.__version=z.version);let Pn=Xe.currentProgram;_t===!0&&(Pn=Fn(z,B,O));let fs=!1,gn=!1,pr=!1;const bt=Pn.getUniforms(),An=Xe.uniforms;if(me.useProgram(Pn.program)&&(fs=!0,gn=!0,pr=!0),z.id!==S&&(S=z.id,gn=!0),fs||M!==E){me.buffers.depth.getReversed()?(pe.copy(E.projectionMatrix),Up(pe),Np(pe),bt.setValue(I,"projectionMatrix",pe)):bt.setValue(I,"projectionMatrix",E.projectionMatrix),bt.setValue(I,"viewMatrix",E.matrixWorldInverse);const ln=bt.map.cameraPosition;ln!==void 0&&ln.setValue(I,We.setFromMatrixPosition(E.matrixWorld)),Ae.logarithmicDepthBuffer&&bt.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&bt.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),M!==E&&(M=E,gn=!0,pr=!0)}if(O.isSkinnedMesh){bt.setOptional(I,O,"bindMatrix"),bt.setOptional(I,O,"bindMatrixInverse");const en=O.skeleton;en&&(en.boneTexture===null&&en.computeBoneTexture(),bt.setValue(I,"boneTexture",en.boneTexture,R))}O.isBatchedMesh&&(bt.setOptional(I,O,"batchingTexture"),bt.setValue(I,"batchingTexture",O._matricesTexture,R),bt.setOptional(I,O,"batchingIdTexture"),bt.setValue(I,"batchingIdTexture",O._indirectTexture,R),bt.setOptional(I,O,"batchingColorTexture"),O._colorsTexture!==null&&bt.setValue(I,"batchingColorTexture",O._colorsTexture,R));const Cn=N.morphAttributes;if((Cn.position!==void 0||Cn.normal!==void 0||Cn.color!==void 0)&&ie.update(O,N,Pn),(gn||Xe.receiveShadow!==O.receiveShadow)&&(Xe.receiveShadow=O.receiveShadow,bt.setValue(I,"receiveShadow",O.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(An.envMap.value=Ue,An.flipEnvMap.value=Ue.isCubeTexture&&Ue.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&B.environment!==null&&(An.envMapIntensity.value=B.environmentIntensity),gn&&(bt.setValue(I,"toneMappingExposure",x.toneMappingExposure),Xe.needsLights&&mn(An,pr),he&&z.fog===!0&&oe.refreshFogUniforms(An,he),oe.refreshMaterialUniforms(An,z,Z,se,m.state.transmissionRenderTarget[E.id]),$a.upload(I,Ui(Xe),An,R)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&($a.upload(I,Ui(Xe),An,R),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&bt.setValue(I,"center",O.center),bt.setValue(I,"modelViewMatrix",O.modelViewMatrix),bt.setValue(I,"normalMatrix",O.normalMatrix),bt.setValue(I,"modelMatrix",O.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const en=z.uniformsGroups;for(let ln=0,No=en.length;ln<No;ln++){const Ni=en[ln];U.update(Ni,Pn),U.bind(Ni,Pn)}}return Pn}function mn(E,B){E.ambientLightColor.needsUpdate=B,E.lightProbe.needsUpdate=B,E.directionalLights.needsUpdate=B,E.directionalLightShadows.needsUpdate=B,E.pointLights.needsUpdate=B,E.pointLightShadows.needsUpdate=B,E.spotLights.needsUpdate=B,E.spotLightShadows.needsUpdate=B,E.rectAreaLights.needsUpdate=B,E.hemisphereLights.needsUpdate=B}function Tn(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(E,B,N){Se.get(E.texture).__webglTexture=B,Se.get(E.depthTexture).__webglTexture=N;const z=Se.get(E);z.__hasExternalTextures=!0,z.__autoAllocateDepthBuffer=N===void 0,z.__autoAllocateDepthBuffer||re.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(E,B){const N=Se.get(E);N.__webglFramebuffer=B,N.__useDefaultFramebuffer=B===void 0};const pi=I.createFramebuffer();this.setRenderTarget=function(E,B=0,N=0){P=E,T=B,C=N;let z=!0,O=null,he=!1,Ce=!1;if(E){const Ue=Se.get(E);if(Ue.__useDefaultFramebuffer!==void 0)me.bindFramebuffer(I.FRAMEBUFFER,null),z=!1;else if(Ue.__webglFramebuffer===void 0)R.setupRenderTarget(E);else if(Ue.__hasExternalTextures)R.rebindTextures(E,Se.get(E.texture).__webglTexture,Se.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const He=E.depthTexture;if(Ue.__boundDepthTexture!==He){if(He!==null&&Se.has(He)&&(E.width!==He.image.width||E.height!==He.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(E)}}const $e=E.texture;($e.isData3DTexture||$e.isDataArrayTexture||$e.isCompressedArrayTexture)&&(Ce=!0);const je=Se.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(je[B])?O=je[B][N]:O=je[B],he=!0):E.samples>0&&R.useMultisampledRTT(E)===!1?O=Se.get(E).__webglMultisampledFramebuffer:Array.isArray(je)?O=je[N]:O=je,D.copy(E.viewport),G.copy(E.scissor),F=E.scissorTest}else D.copy(Re).multiplyScalar(Z).floor(),G.copy(Ge).multiplyScalar(Z).floor(),F=it;if(N!==0&&(O=pi),me.bindFramebuffer(I.FRAMEBUFFER,O)&&z&&me.drawBuffers(E,O),me.viewport(D),me.scissor(G),me.setScissorTest(F),he){const Ue=Se.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+B,Ue.__webglTexture,N)}else if(Ce){const Ue=Se.get(E.texture),$e=B;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ue.__webglTexture,N,$e)}else if(E!==null&&N!==0){const Ue=Se.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Ue.__webglTexture,N)}S=-1},this.readRenderTargetPixels=function(E,B,N,z,O,he,Ce){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Le=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ce!==void 0&&(Le=Le[Ce]),Le){me.bindFramebuffer(I.FRAMEBUFFER,Le);try{const Ue=E.texture,$e=Ue.format,je=Ue.type;if(!Ae.textureFormatReadable($e)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ae.textureTypeReadable(je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=E.width-z&&N>=0&&N<=E.height-O&&I.readPixels(B,N,z,O,Pe.convert($e),Pe.convert(je),he)}finally{const Ue=P!==null?Se.get(P).__webglFramebuffer:null;me.bindFramebuffer(I.FRAMEBUFFER,Ue)}}},this.readRenderTargetPixelsAsync=async function(E,B,N,z,O,he,Ce){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Le=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ce!==void 0&&(Le=Le[Ce]),Le){const Ue=E.texture,$e=Ue.format,je=Ue.type;if(!Ae.textureFormatReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ae.textureTypeReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=E.width-z&&N>=0&&N<=E.height-O){me.bindFramebuffer(I.FRAMEBUFFER,Le);const He=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,He),I.bufferData(I.PIXEL_PACK_BUFFER,he.byteLength,I.STREAM_READ),I.readPixels(B,N,z,O,Pe.convert($e),Pe.convert(je),0);const lt=P!==null?Se.get(P).__webglFramebuffer:null;me.bindFramebuffer(I.FRAMEBUFFER,lt);const gt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await Lp(I,gt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,He),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,he),I.deleteBuffer(He),I.deleteSync(gt),he}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,B=null,N=0){E.isTexture!==!0&&(Fs("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,E=arguments[1]);const z=Math.pow(2,-N),O=Math.floor(E.image.width*z),he=Math.floor(E.image.height*z),Ce=B!==null?B.x:0,Le=B!==null?B.y:0;R.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,N,0,0,Ce,Le,O,he),me.unbindTexture()};const fr=I.createFramebuffer(),ds=I.createFramebuffer();this.copyTextureToTexture=function(E,B,N=null,z=null,O=0,he=null){E.isTexture!==!0&&(Fs("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,E=arguments[1],B=arguments[2],he=arguments[3]||0,N=null),he===null&&(O!==0?(Fs("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),he=O,O=0):he=0);let Ce,Le,Ue,$e,je,He,lt,gt,Dt;const Tt=E.isCompressedTexture?E.mipmaps[he]:E.image;if(N!==null)Ce=N.max.x-N.min.x,Le=N.max.y-N.min.y,Ue=N.isBox3?N.max.z-N.min.z:1,$e=N.min.x,je=N.min.y,He=N.isBox3?N.min.z:0;else{const Cn=Math.pow(2,-O);Ce=Math.floor(Tt.width*Cn),Le=Math.floor(Tt.height*Cn),E.isDataArrayTexture?Ue=Tt.depth:E.isData3DTexture?Ue=Math.floor(Tt.depth*Cn):Ue=1,$e=0,je=0,He=0}z!==null?(lt=z.x,gt=z.y,Dt=z.z):(lt=0,gt=0,Dt=0);const dt=Pe.convert(B.format),Xe=Pe.convert(B.type);let Gt;B.isData3DTexture?(R.setTexture3D(B,0),Gt=I.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(R.setTexture2DArray(B,0),Gt=I.TEXTURE_2D_ARRAY):(R.setTexture2D(B,0),Gt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,B.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,B.unpackAlignment);const _t=I.getParameter(I.UNPACK_ROW_LENGTH),Pn=I.getParameter(I.UNPACK_IMAGE_HEIGHT),fs=I.getParameter(I.UNPACK_SKIP_PIXELS),gn=I.getParameter(I.UNPACK_SKIP_ROWS),pr=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Tt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Tt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,$e),I.pixelStorei(I.UNPACK_SKIP_ROWS,je),I.pixelStorei(I.UNPACK_SKIP_IMAGES,He);const bt=E.isDataArrayTexture||E.isData3DTexture,An=B.isDataArrayTexture||B.isData3DTexture;if(E.isDepthTexture){const Cn=Se.get(E),en=Se.get(B),ln=Se.get(Cn.__renderTarget),No=Se.get(en.__renderTarget);me.bindFramebuffer(I.READ_FRAMEBUFFER,ln.__webglFramebuffer),me.bindFramebuffer(I.DRAW_FRAMEBUFFER,No.__webglFramebuffer);for(let Ni=0;Ni<Ue;Ni++)bt&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Se.get(E).__webglTexture,O,He+Ni),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Se.get(B).__webglTexture,he,Dt+Ni)),I.blitFramebuffer($e,je,Ce,Le,lt,gt,Ce,Le,I.DEPTH_BUFFER_BIT,I.NEAREST);me.bindFramebuffer(I.READ_FRAMEBUFFER,null),me.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(O!==0||E.isRenderTargetTexture||Se.has(E)){const Cn=Se.get(E),en=Se.get(B);me.bindFramebuffer(I.READ_FRAMEBUFFER,fr),me.bindFramebuffer(I.DRAW_FRAMEBUFFER,ds);for(let ln=0;ln<Ue;ln++)bt?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Cn.__webglTexture,O,He+ln):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Cn.__webglTexture,O),An?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,en.__webglTexture,he,Dt+ln):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,en.__webglTexture,he),O!==0?I.blitFramebuffer($e,je,Ce,Le,lt,gt,Ce,Le,I.COLOR_BUFFER_BIT,I.NEAREST):An?I.copyTexSubImage3D(Gt,he,lt,gt,Dt+ln,$e,je,Ce,Le):I.copyTexSubImage2D(Gt,he,lt,gt,$e,je,Ce,Le);me.bindFramebuffer(I.READ_FRAMEBUFFER,null),me.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else An?E.isDataTexture||E.isData3DTexture?I.texSubImage3D(Gt,he,lt,gt,Dt,Ce,Le,Ue,dt,Xe,Tt.data):B.isCompressedArrayTexture?I.compressedTexSubImage3D(Gt,he,lt,gt,Dt,Ce,Le,Ue,dt,Tt.data):I.texSubImage3D(Gt,he,lt,gt,Dt,Ce,Le,Ue,dt,Xe,Tt):E.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,he,lt,gt,Ce,Le,dt,Xe,Tt.data):E.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,he,lt,gt,Tt.width,Tt.height,dt,Tt.data):I.texSubImage2D(I.TEXTURE_2D,he,lt,gt,Ce,Le,dt,Xe,Tt);I.pixelStorei(I.UNPACK_ROW_LENGTH,_t),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Pn),I.pixelStorei(I.UNPACK_SKIP_PIXELS,fs),I.pixelStorei(I.UNPACK_SKIP_ROWS,gn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,pr),he===0&&B.generateMipmaps&&I.generateMipmap(Gt),me.unbindTexture()},this.copyTextureToTexture3D=function(E,B,N=null,z=null,O=0){return E.isTexture!==!0&&(Fs("WebGLRenderer: copyTextureToTexture3D function signature has changed."),N=arguments[0]||null,z=arguments[1]||null,E=arguments[2],B=arguments[3],O=arguments[4]||0),Fs('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(E,B,N,z,O)},this.initRenderTarget=function(E){Se.get(E).__webglFramebuffer===void 0&&R.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?R.setTextureCube(E,0):E.isData3DTexture?R.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?R.setTexture2DArray(E,0):R.setTexture2D(E,0),me.unbindTexture()},this.resetState=function(){T=0,C=0,P=null,me.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return zn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=ht._getDrawingBufferColorSpace(e),t.unpackColorSpace=ht._getUnpackColorSpace()}}const td={type:"change"},fh={type:"start"},of={type:"end"},Va=new ar,nd=new Si,Ly=Math.cos(70*bd.DEG2RAD),Ft=new A,hn=2*Math.PI,xt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},El=1e-6;class Uy extends qg{constructor(e,t=null){super(e,t),this.state=xt.NONE,this.enabled=!0,this.target=new A,this.cursor=new A,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Xs.ROTATE,MIDDLE:Xs.DOLLY,RIGHT:Xs.PAN},this.touches={ONE:Os.ROTATE,TWO:Os.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new A,this._lastQuaternion=new rn,this._lastTargetPosition=new A,this._quat=new rn().setFromUnitVectors(e.up,new A(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new xc,this._sphericalDelta=new xc,this._scale=1,this._panOffset=new A,this._rotateStart=new j,this._rotateEnd=new j,this._rotateDelta=new j,this._panStart=new j,this._panEnd=new j,this._panDelta=new j,this._dollyStart=new j,this._dollyEnd=new j,this._dollyDelta=new j,this._dollyDirection=new A,this._mouse=new j,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Fy.bind(this),this._onPointerDown=Ny.bind(this),this._onPointerUp=Oy.bind(this),this._onContextMenu=Wy.bind(this),this._onMouseWheel=ky.bind(this),this._onKeyDown=Vy.bind(this),this._onTouchStart=Hy.bind(this),this._onTouchMove=Gy.bind(this),this._onMouseDown=By.bind(this),this._onMouseMove=zy.bind(this),this._interceptControlDown=Xy.bind(this),this._interceptControlUp=qy.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(td),this.update(),this.state=xt.NONE}update(e=null){const t=this.object.position;Ft.copy(t).sub(this.target),Ft.applyQuaternion(this._quat),this._spherical.setFromVector3(Ft),this.autoRotate&&this.state===xt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=hn:n>Math.PI&&(n-=hn),i<-Math.PI?i+=hn:i>Math.PI&&(i-=hn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(Ft.setFromSpherical(this._spherical),Ft.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ft),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ft.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new A(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new A(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ft.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Va.origin.copy(this.object.position),Va.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Va.direction))<Ly?this.object.lookAt(this.target):(nd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Va.intersectPlane(nd,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>El||8*(1-this._lastQuaternion.dot(this.object.quaternion))>El||this._lastTargetPosition.distanceToSquared(this.target)>El?(this.dispatchEvent(td),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?hn/60*this.autoRotateSpeed*e:hn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ft.setFromMatrixColumn(t,0),Ft.multiplyScalar(-e),this._panOffset.add(Ft)}_panUp(e,t){this.screenSpacePanning===!0?Ft.setFromMatrixColumn(t,1):(Ft.setFromMatrixColumn(t,0),Ft.crossVectors(this.object.up,Ft)),Ft.multiplyScalar(e),this._panOffset.add(Ft)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ft.copy(i).sub(this.target);let s=Ft.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(hn*this._rotateDelta.x/t.clientHeight),this._rotateUp(hn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(hn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-hn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(hn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-hn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(hn*this._rotateDelta.x/t.clientHeight),this._rotateUp(hn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new j,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Ny(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function Fy(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function Oy(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(of),this.state=xt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function By(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Xs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=xt.DOLLY;break;case Xs.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=xt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=xt.ROTATE}break;case Xs.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=xt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=xt.PAN}break;default:this.state=xt.NONE}this.state!==xt.NONE&&this.dispatchEvent(fh)}function zy(r){switch(this.state){case xt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case xt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case xt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function ky(r){this.enabled===!1||this.enableZoom===!1||this.state!==xt.NONE||(r.preventDefault(),this.dispatchEvent(fh),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(of))}function Vy(r){this.enabled!==!1&&this._handleKeyDown(r)}function Hy(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Os.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=xt.TOUCH_ROTATE;break;case Os.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=xt.TOUCH_PAN;break;default:this.state=xt.NONE}break;case 2:switch(this.touches.TWO){case Os.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=xt.TOUCH_DOLLY_PAN;break;case Os.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=xt.TOUCH_DOLLY_ROTATE;break;default:this.state=xt.NONE}break;default:this.state=xt.NONE}this.state!==xt.NONE&&this.dispatchEvent(fh)}function Gy(r){switch(this._trackPointer(r),this.state){case xt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case xt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case xt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case xt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=xt.NONE}}function Wy(r){this.enabled!==!1&&r.preventDefault()}function Xy(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function qy(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const lf={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
|
||
uniform float opacity;
|
||
|
||
uniform sampler2D tDiffuse;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vec4 texel = texture2D( tDiffuse, vUv );
|
||
gl_FragColor = opacity * texel;
|
||
|
||
|
||
}`};class Jr{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Yy=new Lo(-1,1,1,-1,0,1);class Zy extends qe{constructor(){super(),this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe([0,2,0,0,2,0],2))}}const Jy=new Zy;class cf{constructor(e){this._mesh=new yt(Jy,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Yy)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class ja extends Jr{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Xt?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=fo.clone(e.uniforms),this.material=new Xt({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new cf(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class id extends Jr{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),s.buffers.stencil.setClear(o),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class Ky extends Jr{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class $y{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new j);this._width=n.width,this._height=n.height,t=new Sn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:si}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new ja(lf),this.copyPass.material.blending=ii,this.clock=new $d}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const a=this.passes[i];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}id!==void 0&&(a instanceof id?n=!0:a instanceof Ky&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new j);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class jy extends Jr{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new ne}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=i}}const Qy={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new ne(0)},defaultOpacity:{value:0}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
|
||
uniform sampler2D tDiffuse;
|
||
uniform vec3 defaultColor;
|
||
uniform float defaultOpacity;
|
||
uniform float luminosityThreshold;
|
||
uniform float smoothWidth;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vec4 texel = texture2D( tDiffuse, vUv );
|
||
|
||
float v = luminance( texel.xyz );
|
||
|
||
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
||
|
||
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
||
|
||
gl_FragColor = mix( outputColor, texel, alpha );
|
||
|
||
}`};class ir extends Jr{constructor(e,t,n,i){super(),this.strength=t!==void 0?t:1,this.radius=n,this.threshold=i,this.resolution=e!==void 0?new j(e.x,e.y):new j(256,256),this.clearColor=new ne(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new Sn(s,a,{type:si}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let u=0;u<this.nMips;u++){const f=new Sn(s,a,{type:si});f.texture.name="UnrealBloomPass.h"+u,f.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(f);const d=new Sn(s,a,{type:si});d.texture.name="UnrealBloomPass.v"+u,d.texture.generateMipmaps=!1,this.renderTargetsVertical.push(d),s=Math.round(s/2),a=Math.round(a/2)}const o=Qy;this.highPassUniforms=fo.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Xt({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];const l=[3,5,7,9,11];s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let u=0;u<this.nMips;u++)this.separableBlurMaterials.push(this.getSeparableBlurMaterial(l[u])),this.separableBlurMaterials[u].uniforms.invSize.value=new j(1/s,1/a),s=Math.round(s/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;const c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new A(1,1,1),new A(1,1,1),new A(1,1,1),new A(1,1,1),new A(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;const h=lf;this.copyUniforms=fo.clone(h.uniforms),this.blendMaterial=new Xt({uniforms:this.copyUniforms,vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,blending:Wt,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new ne,this.oldClearAlpha=1,this.basic=new kn,this.fsQuad=new cf(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this.basic.dispose(),this.fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(n,i);for(let s=0;s<this.nMips;s++)this.renderTargetsHorizontal[s].setSize(n,i),this.renderTargetsVertical[s].setSize(n,i),this.separableBlurMaterials[s].uniforms.invSize.value=new j(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}render(e,t,n,i,s){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),s&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);let o=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this.fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[l].uniforms.direction.value=ir.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=ir.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this.fsQuad.render(e),o=this.renderTargetsVertical[l];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,s&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(n),this.fsQuad.render(e)),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}getSeparableBlurMaterial(e){const t=[];for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(e*e))/e);return new Xt({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new j(.5,.5)},direction:{value:new j(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`#include <common>
|
||
varying vec2 vUv;
|
||
uniform sampler2D colorTexture;
|
||
uniform vec2 invSize;
|
||
uniform vec2 direction;
|
||
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
||
|
||
void main() {
|
||
float weightSum = gaussianCoefficients[0];
|
||
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
||
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
||
float x = float(i);
|
||
float w = gaussianCoefficients[i];
|
||
vec2 uvOffset = direction * invSize * x;
|
||
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
||
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
||
diffuseSum += (sample1 + sample2) * w;
|
||
weightSum += 2.0 * w;
|
||
}
|
||
gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
|
||
}`})}getCompositeMaterial(e){return new Xt({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`varying vec2 vUv;
|
||
uniform sampler2D blurTexture1;
|
||
uniform sampler2D blurTexture2;
|
||
uniform sampler2D blurTexture3;
|
||
uniform sampler2D blurTexture4;
|
||
uniform sampler2D blurTexture5;
|
||
uniform float bloomStrength;
|
||
uniform float bloomRadius;
|
||
uniform float bloomFactors[NUM_MIPS];
|
||
uniform vec3 bloomTintColors[NUM_MIPS];
|
||
|
||
float lerpBloomFactor(const in float factor) {
|
||
float mirrorFactor = 1.2 - factor;
|
||
return mix(factor, mirrorFactor, bloomRadius);
|
||
}
|
||
|
||
void main() {
|
||
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
|
||
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
|
||
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
|
||
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
|
||
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
|
||
}`})}}ir.BlurDirectionX=new j(1,0);ir.BlurDirectionY=new j(0,1);function eM(){const e=new Float32Array(6e3),t=new Float32Array(2e3*3);for(let s=0;s<2e3;s++){const a=Math.random()*Math.PI*2,o=Math.acos(2*Math.random()-1),l=600+Math.random()*400;e[s*3]=l*Math.sin(o)*Math.cos(a),e[s*3+1]=l*Math.sin(o)*Math.sin(a),e[s*3+2]=l*Math.cos(o);const c=Math.random();t[s*3]=.55+c*.25,t[s*3+1]=.55+c*.15,t[s*3+2]=.75+c*.25}const n=new qe;n.setAttribute("position",new rt(e,3)),n.setAttribute("color",new rt(t,3));const i=new Ai({size:1.6,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.6,depthWrite:!1,blending:Wt});return new as(n,i)}function tM(r){const e=new Cd;e.background=new ne(328975),e.fog=new Yr(657946,.0035);const t=new kt(60,r.clientWidth/r.clientHeight,.1,2e3);t.position.set(0,30,80);const n=new Dy({antialias:!0,alpha:!0,powerPreference:"high-performance"});n.setSize(r.clientWidth,r.clientHeight),n.setPixelRatio(Math.min(window.devicePixelRatio,2)),n.toneMapping=cd,n.toneMappingExposure=1.25,r.appendChild(n.domElement);const i=new Uy(t,n.domElement);i.enableDamping=!0,i.dampingFactor=.05,i.rotateSpeed=.5,i.zoomSpeed=.8,i.minDistance=12,i.maxDistance=180,i.autoRotate=!0,i.autoRotateSpeed=.3;const s=new $y(n);s.addPass(new jy(e,t));const a=new ir(new j(r.clientWidth,r.clientHeight),.55,.6,.2);s.addPass(a);const o=new Jd(2763354,.7);e.add(o);const l=new _c(6514417,1.8,240);l.position.set(50,50,50),e.add(l);const c=new _c(11032055,1.2,240);c.position.set(-50,-30,-50),e.add(c);const h=eM();e.add(h);const u=new Wg;u.params.Points={threshold:2};const f=new j;return{scene:e,camera:t,renderer:n,controls:i,composer:s,bloomPass:a,raycaster:u,mouse:f,lights:{ambient:o,point1:l,point2:c},starfield:h}}function nM(r,e){const t=e.clientWidth,n=e.clientHeight;r.camera.aspect=t/n,r.camera.updateProjectionMatrix(),r.renderer.setSize(t,n),r.composer.setSize(t,n)}function iM(r){r.scene.traverse(e=>{var t;(e instanceof yt||e instanceof Pd)&&((t=e.geometry)==null||t.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material&&e.material.dispose())}),r.renderer.dispose(),r.composer.dispose()}class sM{constructor(e){ke(this,"positions");ke(this,"velocities");ke(this,"running",!0);ke(this,"step",0);ke(this,"repulsionStrength",500);ke(this,"attractionStrength",.01);ke(this,"dampening",.9);ke(this,"baseMaxSteps",300);ke(this,"maxSteps",300);ke(this,"cooldownExtension",0);this.positions=e,this.velocities=new Map;for(const t of e.keys())this.velocities.set(t,new A)}addNode(e,t){this.positions.set(e,t.clone()),this.velocities.set(e,new A),this.cooldownExtension=100,this.maxSteps=Math.max(this.maxSteps,this.step+this.cooldownExtension),this.running=!0}removeNode(e){this.positions.delete(e),this.velocities.delete(e)}tick(e){if(!this.running)return;if(this.step>this.maxSteps){this.cooldownExtension>0&&(this.cooldownExtension=0,this.maxSteps=this.baseMaxSteps);return}this.step++;const t=Math.max(.001,1-this.step/this.maxSteps),n=Array.from(this.positions.keys());for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++){const a=this.positions.get(n[i]),o=this.positions.get(n[s]),l=new A().subVectors(a,o),c=l.length()||1,h=this.repulsionStrength/(c*c)*t,u=l.normalize().multiplyScalar(h);this.velocities.get(n[i]).add(u),this.velocities.get(n[s]).sub(u)}for(const i of e){const s=this.positions.get(i.source),a=this.positions.get(i.target);if(!s||!a)continue;const o=new A().subVectors(a,s),c=o.length()*this.attractionStrength*i.weight*t,h=o.normalize().multiplyScalar(c);this.velocities.get(i.source).add(h),this.velocities.get(i.target).sub(h)}for(const i of n){const s=this.positions.get(i),a=this.velocities.get(i);a.sub(s.clone().multiplyScalar(.001*t)),a.multiplyScalar(this.dampening),s.add(a)}}reset(){this.step=0,this.running=!0;for(const e of this.velocities.values())e.set(0,0,0)}}function rM(r){return r>=.7?"active":r>=.4?"dormant":r>=.1?"silent":"unavailable"}const bc={active:"#10b981",dormant:"#f59e0b",silent:"#8b5cf6",unavailable:"#6b7280"},aM={active:"Easily retrievable (retention ≥ 70%)",dormant:"Retrievable with effort (40–70%)",silent:"Difficult, needs cues (10–40%)",unavailable:"Needs reinforcement (< 10%)"},Qa={aha:"#FFD700",confusion:"#EF4444",failure:"#9CA3AF"},oM={aha:"Aha moments and breakthroughs",confusion:"Confusions and weak spots",failure:"Failures and guardrails"};function sd(r,e){return e==="state"?bc[rM(r.retention)]:e==="ahagraph"?lM(r)??Il[r.type]??"#8B95A5":Il[r.type]||"#8B95A5"}function lM(r){const e=new Set((r.tags??[]).map(t=>t.toLowerCase()));return e.has("aha")?Qa.aha:e.has("confusion")||e.has("weak-spot")?Qa.confusion:e.has("failure")||e.has("guardrail")?Qa.failure:null}let Ar=null;function Sc(){if(Ar)return Ar;const r=128,e=document.createElement("canvas");e.width=r,e.height=r;const t=e.getContext("2d");if(!t)return Ar=new Et,Ar;const n=t.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);n.addColorStop(0,"rgba(255, 255, 255, 1.0)"),n.addColorStop(.25,"rgba(255, 255, 255, 0.7)"),n.addColorStop(.55,"rgba(255, 255, 255, 0.2)"),n.addColorStop(1,"rgba(255, 255, 255, 0.0)"),t.fillStyle=n,t.fillRect(0,0,r,r);const i=new Dd(e);return i.needsUpdate=!0,Ar=i,i}function rd(r){if(r===0||r===1)return r;const e=.3;return Math.pow(2,-10*r)*Math.sin((r-e/4)*(2*Math.PI)/e)+1}function cM(r){return r*r*((1.70158+1)*r-1.70158)}class hM{constructor(){ke(this,"group");ke(this,"meshMap",new Map);ke(this,"glowMap",new Map);ke(this,"positions",new Map);ke(this,"labelSprites",new Map);ke(this,"hoveredNode",null);ke(this,"selectedNode",null);ke(this,"colorMode","type");ke(this,"materializingNodes",[]);ke(this,"dissolvingNodes",[]);ke(this,"growingNodes",[]);this.group=new ns}setColorMode(e){if(this.colorMode!==e){this.colorMode=e;for(const[t,n]of this.meshMap){const i=n.userData.retention??0,s=n.userData.type??"fact",a=Array.isArray(n.userData.tags)?n.userData.tags:[],l=sd({type:s,retention:i,tags:a},e),c=new ne(l),h=n.material;h.color.copy(c),h.emissive.copy(c);const u=this.glowMap.get(t);u&&u.material.color.copy(c)}}}createNodes(e){const t=(1+Math.sqrt(5))/2,n=e.length;for(let i=0;i<n;i++){const s=e[i],a=1-2*i/(n-1||1),o=Math.sqrt(1-a*a),l=2*Math.PI*i/t,c=30+n*.5,h=new A(o*Math.cos(l)*c,a*c,o*Math.sin(l)*c);s.isCenter&&h.set(0,0,0),this.positions.set(s.id,h),this.createNodeMeshes(s,h,1)}return this.positions}createNodeMeshes(e,t,n){const i=.5+e.retention*2,s=sd(e,this.colorMode),a=(e.suppression_count??0)>0,o=new cr(i,16,16),l=new ah({color:new ne(s),emissive:new ne(s),emissiveIntensity:a?0:.3+e.retention*.5,roughness:.3,metalness:.1,transparent:!0,opacity:a?.2:.3+e.retention*.7}),c=new yt(o,l);c.position.copy(t),c.scale.setScalar(n),c.userData={nodeId:e.id,type:e.type,retention:e.retention,tags:e.tags},this.meshMap.set(e.id,c),this.group.add(c);const h=new rs({map:Sc(),color:new ne(s),transparent:!0,opacity:n>0?a?.1:.3+e.retention*.35:0,blending:Wt,depthWrite:!1}),u=new ts(h);u.scale.set(i*6*n,i*6*n,1),u.position.copy(t),u.userData={isGlow:!0,nodeId:e.id},this.glowMap.set(e.id,u),this.group.add(u);const f=e.label||e.type,d=this.createTextSprite(f,"#94a3b8");return d.position.copy(t),d.position.y+=i*2+1.5,d.userData={isLabel:!0,nodeId:e.id,offset:i*2+1.5},this.group.add(d),this.labelSprites.set(e.id,d),{mesh:c,glow:u,label:d,size:i}}addNode(e,t,n={}){const i=(t==null?void 0:t.clone())??new A((Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40);this.positions.set(e.id,i);const{mesh:s,glow:a,label:o}=this.createNodeMeshes(e,i,0);return s.scale.setScalar(.001),a.scale.set(.001,.001,1),a.material.opacity=0,o.material.opacity=0,n.isBirthRitual?(s.visible=!1,a.visible=!1,o.visible=!1,s.userData.birthRitualPending={totalFrames:30,targetScale:.5+e.retention*2}):this.materializingNodes.push({id:e.id,frame:0,totalFrames:30,mesh:s,glow:a,label:o,targetScale:.5+e.retention*2}),i}igniteNode(e){const t=this.meshMap.get(e),n=this.glowMap.get(e),i=this.labelSprites.get(e);if(!t||!n||!i)return;const s=t.userData.birthRitualPending;s&&(t.visible=!0,n.visible=!0,i.visible=!0,delete t.userData.birthRitualPending,this.materializingNodes.push({id:e,frame:0,totalFrames:s.totalFrames,mesh:t,glow:n,label:i,targetScale:s.targetScale}))}removeNode(e){const t=this.meshMap.get(e),n=this.glowMap.get(e),i=this.labelSprites.get(e);!t||!n||!i||(this.materializingNodes=this.materializingNodes.filter(s=>s.id!==e),this.dissolvingNodes.push({id:e,frame:0,totalFrames:60,mesh:t,glow:n,label:i,originalScale:t.scale.x}))}growNode(e,t){const n=this.meshMap.get(e);if(!n)return;const i=n.scale.x,s=.5+t*2;n.userData.retention=t,this.growingNodes.push({id:e,frame:0,totalFrames:30,startScale:i,targetScale:s})}createTextSprite(e,t){const n=document.createElement("canvas"),i=n.getContext("2d");if(!i){const m=new Et;return new ts(new rs({map:m,transparent:!0,opacity:0}))}n.width=512,n.height=64;const s=e.length>40?e.slice(0,37)+"...":e;i.clearRect(0,0,n.width,n.height),i.font='600 22px -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif';const o=i.measureText(s).width,c=Math.min(o+14*2,n.width-4),h=40,u=(n.width-c)/2,f=(n.height-h)/2,d=h/2;i.fillStyle="rgba(10, 16, 28, 0.82)",i.beginPath(),i.moveTo(u+d,f),i.lineTo(u+c-d,f),i.quadraticCurveTo(u+c,f,u+c,f+d),i.lineTo(u+c,f+h-d),i.quadraticCurveTo(u+c,f+h,u+c-d,f+h),i.lineTo(u+d,f+h),i.quadraticCurveTo(u,f+h,u,f+h-d),i.lineTo(u,f+d),i.quadraticCurveTo(u,f,u+d,f),i.closePath(),i.fill(),i.strokeStyle="rgba(148, 163, 184, 0.18)",i.lineWidth=1,i.stroke(),i.textAlign="center",i.textBaseline="middle",i.fillStyle=t,i.fillText(s,n.width/2,n.height/2+1);const p=new Dd(n);p.needsUpdate=!0;const _=new rs({map:p,transparent:!0,opacity:0,depthTest:!1,sizeAttenuation:!0}),g=new ts(_);return g.scale.set(9,1.2,1),g}updatePositions(){this.group.children.forEach(e=>{if(e.userData.nodeId){const t=this.positions.get(e.userData.nodeId);if(!t)return;e.userData.isGlow?e.position.copy(t):e.userData.isLabel?(e.position.copy(t),e.position.y+=e.userData.offset):e instanceof yt&&e.position.copy(t)}})}animate(e,t,n,i=1){var a,o;for(let l=this.materializingNodes.length-1;l>=0;l--){const c=this.materializingNodes[l];c.frame++;const h=Math.min(c.frame/c.totalFrames,1),u=rd(h);if(c.mesh.scale.setScalar(Math.max(.001,u)),c.frame>=5){const f=Math.min((c.frame-5)/5,1),d=c.glow.material;d.opacity=f*.4;const p=c.targetScale*6*u;c.glow.scale.set(p,p,1)}if(c.frame>=40){const f=Math.min((c.frame-40)/20,1);c.label.material.opacity=f*.9}c.frame>=60&&this.materializingNodes.splice(l,1)}for(let l=this.dissolvingNodes.length-1;l>=0;l--){const c=this.dissolvingNodes[l];c.frame++;const h=Math.min(c.frame/c.totalFrames,1),u=1-cM(h),f=Math.max(.001,c.originalScale*u);c.mesh.scale.setScalar(f);const d=f*6;c.glow.scale.set(d,d,1);const p=c.mesh.material;p.opacity*=.97,c.glow.material.opacity*=.95,c.label.material.opacity*=.93,c.frame>=c.totalFrames&&(this.group.remove(c.mesh),this.group.remove(c.glow),this.group.remove(c.label),c.mesh.geometry.dispose(),c.mesh.material.dispose(),(a=c.glow.material.map)==null||a.dispose(),c.glow.material.dispose(),(o=c.label.material.map)==null||o.dispose(),c.label.material.dispose(),this.meshMap.delete(c.id),this.glowMap.delete(c.id),this.labelSprites.delete(c.id),this.positions.delete(c.id),this.dissolvingNodes.splice(l,1))}for(let l=this.growingNodes.length-1;l>=0;l--){const c=this.growingNodes[l];c.frame++;const h=Math.min(c.frame/c.totalFrames,1),u=c.startScale+(c.targetScale-c.startScale)*rd(h),f=this.meshMap.get(c.id);f&&f.scale.setScalar(u);const d=this.glowMap.get(c.id);if(d){const p=u*6;d.scale.set(p,p,1)}c.frame>=c.totalFrames&&this.growingNodes.splice(l,1)}const s=new Set([...this.materializingNodes.map(l=>l.id),...this.dissolvingNodes.map(l=>l.id),...this.growingNodes.map(l=>l.id)]);this.meshMap.forEach((l,c)=>{if(s.has(c))return;const h=t.find(y=>y.id===c);if(!h)return;const u=1+Math.sin(e*1.5+t.indexOf(h)*.5)*.15*h.retention;l.scale.setScalar(u);const f=this.positions.get(c),d=f?n.position.distanceTo(f):0,p=1+Math.min(1.4,Math.max(0,(d-60)/100)),_=l.material;if(c===this.hoveredNode)_.emissiveIntensity=1*i;else if(c===this.selectedNode)_.emissiveIntensity=.8*i;else{const v=.3+h.retention*.5+Math.sin(e*(.8+h.retention*.7))*.1*h.retention;_.emissiveIntensity=v*i*p}const g=.3+h.retention*.7;_.opacity=Math.min(1,g*i*p);const m=this.glowMap.get(c);if(m){const y=m.material,v=.3+h.retention*.35;y.opacity=Math.min(.95,v*i*p)}}),this.labelSprites.forEach((l,c)=>{if(s.has(c))return;const h=this.positions.get(c);if(!h)return;const u=n.position.distanceTo(h),f=l.material,d=c===this.hoveredNode||c===this.selectedNode?1:u<40?.9:u<80?.9*(1-(u-40)/40):0;f.opacity+=(d-f.opacity)*.1})}getMeshes(){return Array.from(this.meshMap.values())}dispose(){this.group.traverse(e=>{var t,n,i,s,a;e instanceof yt?((t=e.geometry)==null||t.dispose(),(n=e.material)==null||n.dispose()):e instanceof ts&&((s=(i=e.material)==null?void 0:i.map)==null||s.dispose(),(a=e.material)==null||a.dispose())}),this.materializingNodes=[],this.dissolvingNodes=[],this.growingNodes=[]}}function uM(r){return 1-Math.pow(1-r,3)}class dM{constructor(){ke(this,"group");ke(this,"growingEdges",[]);ke(this,"dissolvingEdges",[]);this.group=new ns}createEdges(e,t){for(const n of e){const i=t.get(n.source),s=t.get(n.target);if(!i||!s)continue;const a=[i,s],o=new qe().setFromPoints(a),l=new qt({color:9133302,transparent:!0,opacity:Math.min(.25+n.weight*.5,.8),blending:Wt,depthWrite:!1}),c=new Vn(o,l);c.userData={source:n.source,target:n.target},this.group.add(c)}}addEdge(e,t){const n=t.get(e.source),i=t.get(e.target);if(!n||!i)return;const s=[n.clone(),n.clone()],a=new qe().setFromPoints(s),o=new qt({color:9133302,transparent:!0,opacity:0,blending:Wt,depthWrite:!1}),l=new Vn(a,o);l.userData={source:e.source,target:e.target},this.group.add(l),this.growingEdges.push({line:l,source:e.source,target:e.target,frame:0,totalFrames:45})}removeEdgesForNode(e){const t=[];this.group.children.forEach(n=>{const i=n;(i.userData.source===e||i.userData.target===e)&&t.push(i)});for(const n of t)this.growingEdges=this.growingEdges.filter(i=>i.line!==n),this.dissolvingEdges.push({line:n,frame:0,totalFrames:40})}animateEdges(e){for(let t=this.growingEdges.length-1;t>=0;t--){const n=this.growingEdges[t];n.frame++;const i=uM(Math.min(n.frame/n.totalFrames,1)),s=e.get(n.source),a=e.get(n.target);if(!s||!a)continue;const o=s.clone().lerp(a,i),l=n.line.geometry.attributes.position;l.setXYZ(0,s.x,s.y,s.z),l.setXYZ(1,o.x,o.y,o.z),l.needsUpdate=!0;const c=n.line.material;c.opacity=i*.65,n.frame>=n.totalFrames&&(c.opacity=.65,this.growingEdges.splice(t,1))}for(let t=this.dissolvingEdges.length-1;t>=0;t--){const n=this.dissolvingEdges[t];n.frame++;const i=n.frame/n.totalFrames,s=n.line.material;s.opacity=Math.max(0,.65*(1-i)),n.frame>=n.totalFrames&&(this.group.remove(n.line),n.line.geometry.dispose(),n.line.material.dispose(),this.dissolvingEdges.splice(t,1))}}updatePositions(e){this.group.children.forEach(t=>{const n=t;if(this.growingEdges.some(a=>a.line===n)||this.dissolvingEdges.some(a=>a.line===n))return;const i=e.get(n.userData.source),s=e.get(n.userData.target);if(i&&s){const a=n.geometry.attributes.position;a.setXYZ(0,i.x,i.y,i.z),a.setXYZ(1,s.x,s.y,s.z),a.needsUpdate=!0}})}dispose(){this.group.children.forEach(e=>{var n,i;const t=e;(n=t.geometry)==null||n.dispose(),(i=t.material)==null||i.dispose()}),this.growingEdges=[],this.dissolvingEdges=[]}}class fM{constructor(e){ke(this,"starField");ke(this,"neuralParticles");this.starField=this.createStarField(),this.neuralParticles=this.createNeuralParticles(),e.add(this.starField),e.add(this.neuralParticles)}createStarField(){const t=new qe,n=new Float32Array(3e3*3),i=new Float32Array(3e3);for(let a=0;a<3e3;a++)n[a*3]=(Math.random()-.5)*1e3,n[a*3+1]=(Math.random()-.5)*1e3,n[a*3+2]=(Math.random()-.5)*1e3,i[a]=Math.random()*1.5;t.setAttribute("position",new rt(n,3)),t.setAttribute("size",new rt(i,1));const s=new Ai({color:6514417,size:.5,transparent:!0,opacity:.4,sizeAttenuation:!0,blending:Wt});return new as(t,s)}createNeuralParticles(){const t=new qe,n=new Float32Array(500*3),i=new Float32Array(500*3);for(let a=0;a<500;a++)n[a*3]=(Math.random()-.5)*100,n[a*3+1]=(Math.random()-.5)*100,n[a*3+2]=(Math.random()-.5)*100,i[a*3]=.4+Math.random()*.3,i[a*3+1]=.3+Math.random()*.2,i[a*3+2]=.8+Math.random()*.2;t.setAttribute("position",new rt(n,3)),t.setAttribute("color",new rt(i,3));const s=new Ai({size:.3,vertexColors:!0,transparent:!0,opacity:.4,blending:Wt,sizeAttenuation:!0});return new as(t,s)}animate(e){this.starField.rotation.y+=1e-4,this.starField.rotation.x+=5e-5;const t=this.neuralParticles.geometry.attributes.position;for(let n=0;n<t.count;n++)t.setY(n,t.getY(n)+Math.sin(e+n*.1)*.02),t.setX(n,t.getX(n)+Math.cos(e+n*.05)*.01);t.needsUpdate=!0}dispose(){this.starField.geometry.dispose(),this.starField.material.dispose(),this.neuralParticles.geometry.dispose(),this.neuralParticles.material.dispose()}}class pM{constructor(e){ke(this,"pulseEffects",[]);ke(this,"spawnBursts",[]);ke(this,"rainbowBursts",[]);ke(this,"rippleWaves",[]);ke(this,"implosions",[]);ke(this,"shockwaves",[]);ke(this,"connectionFlashes",[]);ke(this,"birthOrbs",[]);ke(this,"scene");this.scene=e}addPulse(e,t,n,i){this.pulseEffects.push({nodeId:e,intensity:t,color:n,decay:i})}createSpawnBurst(e,t){const i=new qe,s=new Float32Array(180),a=new Float32Array(180);for(let c=0;c<60;c++){s[c*3]=e.x,s[c*3+1]=e.y,s[c*3+2]=e.z;const h=Math.random()*Math.PI*2,u=Math.acos(2*Math.random()-1),f=.3+Math.random()*.5;a[c*3]=Math.sin(u)*Math.cos(h)*f,a[c*3+1]=Math.sin(u)*Math.sin(h)*f,a[c*3+2]=Math.cos(u)*f}i.setAttribute("position",new rt(s,3)),i.setAttribute("velocity",new rt(a,3));const o=new Ai({color:t,size:.6,transparent:!0,opacity:1,blending:Wt,sizeAttenuation:!0}),l=new as(i,o);this.scene.add(l),this.spawnBursts.push({position:e.clone(),age:0,particles:l})}createShockwave(e,t,n){const i=new Io(.1,.5,64),s=new kn({color:t,transparent:!0,opacity:.8,side:Bn,blending:Wt}),a=new yt(i,s);a.position.copy(e),a.lookAt(n.position),this.scene.add(a),this.shockwaves.push({mesh:a,age:0,maxAge:60})}createRainbowBurst(e,t){const i=new qe,s=new Float32Array(360),a=new Float32Array(360),o=new Float32Array(120);for(let h=0;h<120;h++){s[h*3]=e.x,s[h*3+1]=e.y,s[h*3+2]=e.z;const u=Math.random()*Math.PI*2,f=Math.acos(2*Math.random()-1),d=.2+Math.random()*.6;a[h*3]=Math.sin(f)*Math.cos(u)*d,a[h*3+1]=Math.sin(f)*Math.sin(u)*d,a[h*3+2]=Math.cos(f)*d,o[h]=Math.random()}i.setAttribute("position",new rt(s,3)),i.setAttribute("velocity",new rt(a,3)),i.setAttribute("hueOffset",new rt(o,1));const l=new Ai({color:t,size:.8,transparent:!0,opacity:1,blending:Wt,sizeAttenuation:!0}),c=new as(i,l);this.scene.add(c),this.rainbowBursts.push({position:e.clone(),age:0,maxAge:180,particles:c,baseColor:t.clone()})}createRippleWave(e){this.rippleWaves.push({origin:e.clone(),radius:0,speed:1.2,age:0,maxAge:90,pulsedNodes:new Set})}createImplosion(e,t){const i=new qe,s=new Float32Array(120),a=new Float32Array(120),o=8;for(let h=0;h<40;h++){const u=Math.random()*Math.PI*2,f=Math.acos(2*Math.random()-1),d=o*(.5+Math.random()*.5);s[h*3]=e.x+Math.sin(f)*Math.cos(u)*d,s[h*3+1]=e.y+Math.sin(f)*Math.sin(u)*d,s[h*3+2]=e.z+Math.cos(f)*d,a[h*3]=(e.x-s[h*3])*.04,a[h*3+1]=(e.y-s[h*3+1])*.04,a[h*3+2]=(e.z-s[h*3+2])*.04}i.setAttribute("position",new rt(s,3)),i.setAttribute("velocity",new rt(a,3));const l=new Ai({color:t,size:.5,transparent:!0,opacity:1,blending:Wt,sizeAttenuation:!0}),c=new as(i,l);this.scene.add(c),this.implosions.push({position:e.clone(),age:0,maxAge:60,particles:c,flash:null})}createConnectionFlash(e,t,n){const i=[e.clone(),t.clone()],s=new qe().setFromPoints(i),a=new qt({color:n,transparent:!0,opacity:1,blending:Wt}),o=new Vn(s,a);this.scene.add(o),this.connectionFlashes.push({line:o,intensity:1})}createBirthOrb(e,t,n,i,s={}){var _;const a=s.gestationFrames??48,o=s.flightFrames??90,l=s.distanceFromCamera??40,c=new A(0,0,-l).applyQuaternion(e.quaternion).add(e.position),h=new rs({map:Sc(),color:t.clone(),transparent:!0,opacity:0,blending:Wt,depthWrite:!1,depthTest:!1}),u=new ts(h);u.position.copy(c),u.scale.set(.5,.5,1),u.renderOrder=999;const f=new rs({map:Sc(),color:new ne(16777215),transparent:!0,opacity:0,blending:Wt,depthWrite:!1,depthTest:!1}),d=new ts(f);d.position.copy(c),d.scale.set(.2,.2,1),d.renderOrder=1e3,this.scene.add(u),this.scene.add(d);const p=((_=n())==null?void 0:_.clone())??c.clone();this.birthOrbs.push({sprite:u,core:d,startPos:c,getTargetPos:n,color:t.clone(),age:0,gestationFrames:a,flightFrames:o,arriveFired:!1,onArrive:i,lastTargetPos:p,aborted:!1})}update(e,t,n){for(let i=this.pulseEffects.length-1;i>=0;i--){const s=this.pulseEffects[i];if(s.intensity-=s.decay,s.intensity<=0){this.pulseEffects.splice(i,1);continue}const a=e.get(s.nodeId);if(a){const o=a.material;o.emissive.lerp(s.color,s.intensity*.3),o.emissiveIntensity=Math.max(o.emissiveIntensity,s.intensity)}}for(let i=this.spawnBursts.length-1;i>=0;i--){const s=this.spawnBursts[i];if(s.age++,s.age>120){this.scene.remove(s.particles),s.particles.geometry.dispose(),s.particles.material.dispose(),this.spawnBursts.splice(i,1);continue}const a=s.particles.geometry.attributes.position,o=s.particles.geometry.attributes.velocity;for(let c=0;c<a.count;c++)a.setX(c,a.getX(c)+o.getX(c)),a.setY(c,a.getY(c)+o.getY(c)),a.setZ(c,a.getZ(c)+o.getZ(c)),o.setX(c,o.getX(c)*.97),o.setY(c,o.getY(c)*.97),o.setZ(c,o.getZ(c)*.97);a.needsUpdate=!0;const l=s.particles.material;l.opacity=Math.max(0,1-s.age/120),l.size=.6*(1-s.age/200)}for(let i=this.rainbowBursts.length-1;i>=0;i--){const s=this.rainbowBursts[i];if(s.age++,s.age>s.maxAge){this.scene.remove(s.particles),s.particles.geometry.dispose(),s.particles.material.dispose(),this.rainbowBursts.splice(i,1);continue}const a=s.particles.geometry.attributes.position,o=s.particles.geometry.attributes.velocity;for(let f=0;f<a.count;f++)a.setX(f,a.getX(f)+o.getX(f)),a.setY(f,a.getY(f)+o.getY(f)),a.setZ(f,a.getZ(f)+o.getZ(f)),o.setX(f,o.getX(f)*.98),o.setY(f,o.getY(f)*.98),o.setZ(f,o.getZ(f)*.98);a.needsUpdate=!0;const l=s.age/s.maxAge,c=s.particles.material,h=s.age*.02%1,u=new ne().setHSL(h,1,.6);c.color.copy(s.baseColor).lerp(u,.6),c.opacity=Math.max(0,1-l*l),c.size=.8*(1-l*.5)*(1+Math.sin(s.age*.3)*.2)}if(n)for(let i=this.rippleWaves.length-1;i>=0;i--){const s=this.rippleWaves[i];if(s.age++,s.radius+=s.speed,s.age>s.maxAge){this.rippleWaves.splice(i,1);continue}const a=s.radius,o=3;n.forEach((l,c)=>{if(s.pulsedNodes.has(c))return;const h=l.distanceTo(s.origin);h>=a-o&&h<=a+o&&(s.pulsedNodes.add(c),this.addPulse(c,.8,new ne(65489),.03))})}for(let i=this.implosions.length-1;i>=0;i--){const s=this.implosions[i];if(s.age++,s.age>s.maxAge+20){this.scene.remove(s.particles),s.particles.geometry.dispose(),s.particles.material.dispose(),s.flash&&(this.scene.remove(s.flash),s.flash.geometry.dispose(),s.flash.material.dispose()),this.implosions.splice(i,1);continue}if(s.age<=s.maxAge){const a=s.particles.geometry.attributes.position,o=s.particles.geometry.attributes.velocity,l=1+s.age*.02;for(let h=0;h<a.count;h++)a.setX(h,a.getX(h)+o.getX(h)*l),a.setY(h,a.getY(h)+o.getY(h)*l),a.setZ(h,a.getZ(h)+o.getZ(h)*l);a.needsUpdate=!0;const c=s.particles.material;c.opacity=Math.min(1,s.age/15),c.size=.5+s.age/s.maxAge*.3}if(s.age===s.maxAge&&!s.flash){const a=new cr(2,16,16),o=new kn({color:16777215,transparent:!0,opacity:1,blending:Wt});s.flash=new yt(a,o),s.flash.position.copy(s.position),this.scene.add(s.flash),s.particles.material.opacity=0}if(s.flash&&s.age>s.maxAge){const a=(s.age-s.maxAge)/20;s.flash.material.opacity=Math.max(0,1-a),s.flash.scale.setScalar(1+a*3)}}for(let i=this.shockwaves.length-1;i>=0;i--){const s=this.shockwaves[i];if(s.age++,s.age>s.maxAge){this.scene.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.shockwaves.splice(i,1);continue}const a=s.age/s.maxAge;s.mesh.scale.setScalar(1+a*20),s.mesh.material.opacity=.8*(1-a),s.mesh.lookAt(t.position)}for(let i=this.connectionFlashes.length-1;i>=0;i--){const s=this.connectionFlashes[i];if(s.intensity-=.015,s.intensity<=0){this.scene.remove(s.line),s.line.geometry.dispose(),s.line.material.dispose(),this.connectionFlashes.splice(i,1);continue}s.line.material.opacity=s.intensity}for(let i=this.birthOrbs.length-1;i>=0;i--){const s=this.birthOrbs[i];s.age++;const a=s.gestationFrames+s.flightFrames,o=s.sprite.material,l=s.core.material,c=s.getTargetPos();if(c)s.lastTargetPos.copy(c);else if(s.age>s.gestationFrames&&!s.aborted){s.aborted=!0;const h=s.sprite.position;o.color.setRGB(1,.15,.2),l.color.setRGB(1,.6,.6),this.createImplosion(h,new ne(16721203)),s.arriveFired=!0,s.age=a+1}if(s.age<=s.gestationFrames){const h=s.age/s.gestationFrames,u=1-Math.pow(1-h,3),f=.85+Math.sin(s.age*.35)*.15,d=.5+u*4.5*f,p=.2+u*1.8*f;s.sprite.scale.set(d,d,1),s.core.scale.set(p,p,1),o.opacity=u*.95,l.opacity=u,o.color.copy(s.color).multiplyScalar(.7+u*.3),s.sprite.position.copy(s.startPos),s.core.position.copy(s.startPos)}else if(s.age<=a){const h=(s.age-s.gestationFrames)/s.flightFrames,u=h<.5?2*h*h:1-Math.pow(-2*h+2,2)/2,f=s.startPos,d=s.lastTargetPos,p=d.x-f.x,_=d.y-f.y,g=d.z-f.z,m=Math.sqrt(p*p+_*_+g*g),y=(f.x+d.x)*.5,v=(f.y+d.y)*.5+30+m*.15,x=(f.z+d.z)*.5,w=1-u,T=w*w,C=2*w*u,P=u*u,S=T*f.x+C*y+P*d.x,M=T*f.y+C*v+P*d.y,D=T*f.z+C*x+P*d.z;s.sprite.position.set(S,M,D),s.core.position.set(S,M,D);const G=1-u*.35;s.sprite.scale.setScalar(5*G),s.core.scale.setScalar(2*G),o.opacity=.95,l.opacity=1,o.color.copy(s.color)}else if(s.arriveFired){const h=s.age-a,u=Math.max(0,1-h/8);o.opacity=.95*u,l.opacity=1*u,s.sprite.scale.setScalar(5*(1+(1-u)*2)),u<=0&&(this.scene.remove(s.sprite),this.scene.remove(s.core),o.dispose(),l.dispose(),this.birthOrbs.splice(i,1))}else{s.arriveFired=!0;try{s.onArrive()}catch(h){console.warn("[birth-orb] onArrive threw",h)}}}}dispose(){for(const e of this.spawnBursts)this.scene.remove(e.particles),e.particles.geometry.dispose(),e.particles.material.dispose();for(const e of this.rainbowBursts)this.scene.remove(e.particles),e.particles.geometry.dispose(),e.particles.material.dispose();for(const e of this.implosions)this.scene.remove(e.particles),e.particles.geometry.dispose(),e.particles.material.dispose(),e.flash&&(this.scene.remove(e.flash),e.flash.geometry.dispose(),e.flash.material.dispose());for(const e of this.shockwaves)this.scene.remove(e.mesh),e.mesh.geometry.dispose(),e.mesh.material.dispose();for(const e of this.connectionFlashes)this.scene.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(const e of this.birthOrbs)this.scene.remove(e.sprite),this.scene.remove(e.core),e.sprite.material.dispose(),e.core.material.dispose();this.pulseEffects=[],this.spawnBursts=[],this.rainbowBursts=[],this.rippleWaves=[],this.implosions=[],this.shockwaves=[],this.connectionFlashes=[],this.birthOrbs=[]}}const jn={bloomStrength:.8,rotateSpeed:.3,fogColor:328976,fogDensity:.008,nebulaIntensity:0,chromaticIntensity:.002,vignetteRadius:.9,breatheAmplitude:1},bi={bloomStrength:1.8,rotateSpeed:.08,fogColor:656672,fogDensity:.006,nebulaIntensity:1,chromaticIntensity:.005,vignetteRadius:.7,breatheAmplitude:2};class mM{constructor(){ke(this,"active",!1);ke(this,"transition",0);ke(this,"transitionSpeed",.008);ke(this,"current");ke(this,"auroraHue",0);this.current={...jn}}setActive(e){this.active=e}update(e,t,n,i,s){const a=this.active?1:0;this.transition+=(a-this.transition)*this.transitionSpeed*60*(1/60),this.transition=Math.max(0,Math.min(1,this.transition));const o=this.transition;this.current.bloomStrength=this.lerp(jn.bloomStrength,bi.bloomStrength,o),this.current.rotateSpeed=this.lerp(jn.rotateSpeed,bi.rotateSpeed,o),this.current.fogDensity=this.lerp(jn.fogDensity,bi.fogDensity,o),this.current.nebulaIntensity=this.lerp(jn.nebulaIntensity,bi.nebulaIntensity,o),this.current.chromaticIntensity=this.lerp(jn.chromaticIntensity,bi.chromaticIntensity,o),this.current.vignetteRadius=this.lerp(jn.vignetteRadius,bi.vignetteRadius,o),this.current.breatheAmplitude=this.lerp(jn.breatheAmplitude,bi.breatheAmplitude,o),t.strength=this.current.bloomStrength,n.autoRotateSpeed=this.current.rotateSpeed;const l=new ne(jn.fogColor),c=new ne(bi.fogColor),h=l.clone().lerp(c,o);if(e.fog=new Yr(h,this.current.fogDensity),o>.01){this.auroraHue=s*.1%1;const u=new ne().setHSL(.75+this.auroraHue*.15,.8,.5),f=new ne().setHSL(.55+this.auroraHue*.2,.7,.4);i.point1.color.lerp(u,o*.3),i.point2.color.lerp(f,o*.3)}else i.point1.color.set(6514417),i.point2.color.set(11032055)}lerp(e,t,n){return e+(t-e)*n}}const gM=50,Fr=[];function _M(r,e,t){const n=r.tags??[],i=r.type??"";let s=null,a=0;for(const o of e){let l=0;o.type===i&&(l+=2);for(const c of o.tags)n.includes(c)&&(l+=1);l>a&&(a=l,s=o.id)}if(s&&a>0){const o=t.get(s);if(o)return new A(o.x+(Math.random()-.5)*10,o.y+(Math.random()-.5)*10,o.z+(Math.random()-.5)*10)}return new A((Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40)}function vM(r,e){if(Fr.length<=gM)return;const t=Fr.shift();r.edgeManager.removeEdgesForNode(t),r.nodeManager.removeNode(t),r.forceSim.removeNode(t),r.onMutation({type:"edgesRemoved",nodeId:t}),r.onMutation({type:"nodeRemoved",nodeId:t});const n=e.findIndex(i=>i.id===t);n!==-1&&e.splice(n,1)}function xM(r,e,t){var u,f;const{effects:n,nodeManager:i,edgeManager:s,forceSim:a,camera:o,onMutation:l}=e,c=i.positions,h=i.meshMap;switch(r.type){case"MemoryCreated":{const d=r.data;if(!d.id)break;const p={id:d.id,label:(d.content??"").slice(0,60),type:d.node_type??"fact",retention:Math.max(0,Math.min(1,d.retention??.9)),tags:d.tags??[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),isCenter:!1},_=_M(p,t,c),g=i.addNode(p,_,{isBirthRitual:!0});a.addNode(d.id,g),Fr.push(d.id),vM(e,t);const m=new ne(Il[p.type]||"#00ffd1"),y=m.clone();y.offsetHSL(.15,0,0),n.createBirthOrb(o,m,()=>i.positions.get(p.id),()=>{i.igniteNode(p.id);const v=i.positions.get(p.id)??_,x=i.meshMap.get(p.id);x&&x.scale.multiplyScalar(1.8),n.createRainbowBurst(v,m),n.createShockwave(v,m,o),n.createShockwave(v,y,o),n.createRippleWave(v)}),l({type:"nodeAdded",node:p});break}case"ConnectionDiscovered":{const d=r.data;if(!d.source_id||!d.target_id)break;const p=c.get(d.source_id),_=c.get(d.target_id),g={source:d.source_id,target:d.target_id,weight:d.weight??.5,type:d.connection_type??"semantic"};s.addEdge(g,c),p&&_&&n.createConnectionFlash(p,_,new ne(54527)),d.source_id&&h.has(d.source_id)&&n.addPulse(d.source_id,1,new ne(54527),.02),d.target_id&&h.has(d.target_id)&&n.addPulse(d.target_id,1,new ne(54527),.02),l({type:"edgeAdded",edge:g});break}case"MemoryDeleted":{const d=r.data;if(!d.id)break;const p=c.get(d.id);if(p){const g=new ne(16729943);n.createImplosion(p,g)}s.removeEdgesForNode(d.id),i.removeNode(d.id),a.removeNode(d.id);const _=Fr.indexOf(d.id);_!==-1&&Fr.splice(_,1),l({type:"edgesRemoved",nodeId:d.id}),l({type:"nodeRemoved",nodeId:d.id});break}case"MemoryPromoted":{const d=r.data,p=d==null?void 0:d.id;if(!p)break;const _=d.new_retention??.95;if(h.has(p)){i.growNode(p,_),n.addPulse(p,1.2,new ne(65416),.01);const g=c.get(p);g&&(n.createShockwave(g,new ne(65416),o),n.createSpawnBurst(g,new ne(65416))),l({type:"nodeUpdated",nodeId:p,retention:_})}break}case"MemoryDemoted":{const d=r.data,p=d==null?void 0:d.id;if(!p)break;const _=d.new_retention??.3;h.has(p)&&(i.growNode(p,_),n.addPulse(p,.8,new ne(16729943),.03),l({type:"nodeUpdated",nodeId:p,retention:_}));break}case"MemoryUpdated":{const d=r.data,p=d==null?void 0:d.id;if(!p||!h.has(p))break;n.addPulse(p,.6,new ne(8490232),.02),d.retention!==void 0&&(i.growNode(p,d.retention),l({type:"nodeUpdated",nodeId:p,retention:d.retention}));break}case"SearchPerformed":{h.forEach((d,p)=>{n.addPulse(p,.6+Math.random()*.4,new ne(8490232),.02)});break}case"DreamStarted":{h.forEach((d,p)=>{n.addPulse(p,1,new ne(11032055),.005)});break}case"DreamProgress":{const d=(u=r.data)==null?void 0:u.memory_id;d&&h.has(d)&&n.addPulse(d,1.5,new ne(12616956),.01);break}case"DreamCompleted":{n.createSpawnBurst(new A(0,0,0),new ne(11032055)),n.createShockwave(new A(0,0,0),new ne(11032055),o);break}case"RetentionDecayed":{const d=(f=r.data)==null?void 0:f.id;d&&h.has(d)&&n.addPulse(d,.8,new ne(16729943),.03);break}case"ConsolidationCompleted":{h.forEach((d,p)=>{n.addPulse(p,.4+Math.random()*.3,new ne(16758784),.015)});break}case"ActivationSpread":{const d=r.data;if(d.source_id&&d.target_ids){const p=c.get(d.source_id);if(p)for(const _ of d.target_ids){const g=c.get(_);g&&n.createConnectionFlash(p,g,new ne(1370310))}}break}case"MemorySuppressed":{const d=r.data;if(!d.id)break;const p=c.get(d.id);if(p){n.createImplosion(p,new ne(11032055));const _=Math.max(1,d.suppression_count??1),g=Math.min(.4+_*.15,1);n.addPulse(d.id,g,new ne(11032055),.04)}break}case"MemoryUnsuppressed":{const d=r.data;if(!d.id)break;const p=c.get(d.id);p&&h.has(d.id)&&(n.createRainbowBurst(p,new ne(65416)),n.addPulse(d.id,1,new ne(65416),.02));break}case"Rac1CascadeSwept":{const p=r.data.neighbors_affected??0;if(p===0)break;const _=Array.from(h.keys()),g=Math.min(p,_.length,12);for(let m=0;m<g;m++){const y=Math.floor(Math.random()*_.length),v=_[y];n.addPulse(v,.5,new ne(11032055),.035)}break}case"Connected":{const d=h.keys().next().value;if(!d)break;const p=c.get(d);p&&n.createRippleWave(p);break}case"ConsolidationStarted":{const d=Array.from(h.keys()),p=Math.min(d.length,20);for(let _=0;_<p;_++){const g=Math.floor(Math.random()*d.length),m=d[g];n.addPulse(m,.45,new ne(16758784),.025)}break}case"ImportanceScored":{const d=r.data;if(!d.id)break;if(c.get(d.id)&&h.has(d.id)){const g=.3+Math.max(0,Math.min(1,d.composite_score??.5))*.7;n.addPulse(d.id,g,new ne(16727212),.03)}break}}}const yM=`
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = vec4(position, 1.0);
|
||
}
|
||
`,MM=`
|
||
precision highp float;
|
||
|
||
uniform float uTime;
|
||
uniform vec2 uResolution;
|
||
uniform float uDreamIntensity;
|
||
|
||
varying vec2 vUv;
|
||
|
||
// Simplex-style hash
|
||
vec3 hash33(vec3 p3) {
|
||
p3 = fract(p3 * vec3(0.1031, 0.1030, 0.0973));
|
||
p3 += dot(p3, p3.yxz + 33.33);
|
||
return fract((p3.xxy + p3.yxx) * p3.zyx);
|
||
}
|
||
|
||
// 3D value noise
|
||
float noise(vec3 p) {
|
||
vec3 i = floor(p);
|
||
vec3 f = fract(p);
|
||
f = f * f * (3.0 - 2.0 * f);
|
||
|
||
float n = i.x + i.y * 157.0 + 113.0 * i.z;
|
||
|
||
vec4 v1 = fract(sin(vec4(n + 0.0, n + 1.0, n + 157.0, n + 158.0)) * 43758.5453);
|
||
vec4 v2 = fract(sin(vec4(n + 113.0, n + 114.0, n + 270.0, n + 271.0)) * 43758.5453);
|
||
|
||
vec4 a = mix(v1, v2, f.z);
|
||
vec2 b = mix(a.xy, a.zw, f.y);
|
||
return mix(b.x, b.y, f.x);
|
||
}
|
||
|
||
// FBM with 5 octaves
|
||
float fbm(vec3 p) {
|
||
float value = 0.0;
|
||
float amplitude = 0.5;
|
||
float frequency = 1.0;
|
||
for (int i = 0; i < 5; i++) {
|
||
value += amplitude * noise(p * frequency);
|
||
frequency *= 2.0;
|
||
amplitude *= 0.5;
|
||
}
|
||
return value;
|
||
}
|
||
|
||
// IQ cosine palette
|
||
vec3 palette(float t, vec3 a, vec3 b, vec3 c, vec3 d) {
|
||
return a + b * cos(6.28318 * (c * t + d));
|
||
}
|
||
|
||
void main() {
|
||
vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.x, uResolution.y);
|
||
float t = uTime * 0.05;
|
||
|
||
// Domain warping: fbm(p + fbm(p + fbm(p)))
|
||
vec3 p = vec3(uv * 2.0, t);
|
||
|
||
float warp1 = fbm(p);
|
||
float warp2 = fbm(p + warp1 * 3.0 + vec3(1.7, 9.2, t * 0.3));
|
||
float warp3 = fbm(p + warp2 * 2.5 + vec3(8.3, 2.8, t * 0.2));
|
||
|
||
// Final noise value
|
||
float f = fbm(p + warp3 * 2.0);
|
||
|
||
// Color: cosmic palette that shifts during dream mode
|
||
vec3 normalA = vec3(0.02, 0.01, 0.05);
|
||
vec3 normalB = vec3(0.03, 0.02, 0.08);
|
||
vec3 normalC = vec3(1.0, 1.0, 1.0);
|
||
vec3 normalD = vec3(0.70, 0.55, 0.80);
|
||
|
||
vec3 dreamA = vec3(0.05, 0.01, 0.08);
|
||
vec3 dreamB = vec3(0.06, 0.03, 0.12);
|
||
vec3 dreamC = vec3(1.0, 0.8, 1.0);
|
||
vec3 dreamD = vec3(0.80, 0.40, 0.90);
|
||
|
||
vec3 a = mix(normalA, dreamA, uDreamIntensity);
|
||
vec3 b = mix(normalB, dreamB, uDreamIntensity);
|
||
vec3 c = mix(normalC, dreamC, uDreamIntensity);
|
||
vec3 d = mix(normalD, dreamD, uDreamIntensity);
|
||
|
||
vec3 color = palette(f + warp2 * 0.5, a, b, c, d);
|
||
|
||
// Add subtle star-like highlights
|
||
float stars = smoothstep(0.97, 1.0, noise(vec3(uv * 50.0, t * 0.1)));
|
||
color += stars * 0.15;
|
||
|
||
// Intensity modulation
|
||
float intensity = 0.15 + 0.1 * uDreamIntensity;
|
||
color *= intensity;
|
||
|
||
// Vignette
|
||
float dist = length(uv);
|
||
color *= smoothstep(1.5, 0.3, dist);
|
||
|
||
gl_FragColor = vec4(color, 1.0);
|
||
}
|
||
`;function bM(r){const e=new lr(2,2),t=new Xt({vertexShader:yM,fragmentShader:MM,uniforms:{uTime:{value:0},uResolution:{value:new j(window.innerWidth,window.innerHeight)},uDreamIntensity:{value:0}},depthWrite:!1,depthTest:!1,transparent:!1}),n=new yt(e,t);return n.frustumCulled=!1,n.renderOrder=-1e3,r.add(n),{mesh:n,material:t}}function SM(r,e,t,n,i){r.uniforms.uTime.value=e,r.uniforms.uDreamIntensity.value=t,r.uniforms.uResolution.value.set(n,i)}const wM={uniforms:{tDiffuse:{value:null},uIntensity:{value:.002}},vertexShader:`
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform sampler2D tDiffuse;
|
||
uniform float uIntensity;
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vec2 center = vec2(0.5);
|
||
vec2 dir = vUv - center;
|
||
float dist = length(dir);
|
||
|
||
float rOffset = uIntensity * dist;
|
||
float gOffset = 0.0;
|
||
float bOffset = -uIntensity * dist;
|
||
|
||
vec2 rUv = vUv + dir * rOffset;
|
||
vec2 gUv = vUv + dir * gOffset;
|
||
vec2 bUv = vUv + dir * bOffset;
|
||
|
||
float r = texture2D(tDiffuse, rUv).r;
|
||
float g = texture2D(tDiffuse, gUv).g;
|
||
float b = texture2D(tDiffuse, bUv).b;
|
||
|
||
gl_FragColor = vec4(r, g, b, 1.0);
|
||
}
|
||
`},EM={uniforms:{tDiffuse:{value:null},uTime:{value:0},uIntensity:{value:.04}},vertexShader:`
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform sampler2D tDiffuse;
|
||
uniform float uTime;
|
||
uniform float uIntensity;
|
||
varying vec2 vUv;
|
||
|
||
float rand(vec2 co) {
|
||
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
||
}
|
||
|
||
void main() {
|
||
vec4 color = texture2D(tDiffuse, vUv);
|
||
float grain = rand(vUv + vec2(uTime)) * 2.0 - 1.0;
|
||
color.rgb += grain * uIntensity;
|
||
gl_FragColor = color;
|
||
}
|
||
`},TM={uniforms:{tDiffuse:{value:null},uRadius:{value:.9},uSoftness:{value:.5}},vertexShader:`
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform sampler2D tDiffuse;
|
||
uniform float uRadius;
|
||
uniform float uSoftness;
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vec4 color = texture2D(tDiffuse, vUv);
|
||
vec2 center = vec2(0.5);
|
||
float dist = distance(vUv, center) * 1.414;
|
||
float vignette = smoothstep(uRadius, uRadius - uSoftness, dist);
|
||
color.rgb *= vignette;
|
||
gl_FragColor = color;
|
||
}
|
||
`};function AM(r){const e=new ja(wM),t=new ja(EM),n=new ja(TM);return r.addPass(e),r.addPass(t),r.addPass(n),{chromatic:e,grain:t,vignette:n}}function CM(r,e,t){r.chromatic.uniforms.uIntensity.value=.002+(.005-.002)*t,r.grain.uniforms.uTime.value=e,r.grain.uniforms.uIntensity.value=.04+t*.02;const s=.9,a=.7;r.vignette.uniforms.uRadius.value=s+(a-s)*t}const hf="vestige:graph:brightness",eo=1,wc=.5,Ec=2.5;function RM(){if(typeof localStorage>"u")return eo;const r=localStorage.getItem(hf);if(r===null)return eo;const e=Number(r);return Number.isFinite(e)?Math.min(Ec,Math.max(wc,e)):eo}const ji=IM();function IM(){let r=Qe(!1),e=Qe(Al(new Date)),t=Qe(!1),n=Qe(1),i=Qe(!1),s=Qe(Al(RM()));return{get temporalEnabled(){return L(r)},set temporalEnabled(a){le(r,a,!0)},get temporalDate(){return L(e)},set temporalDate(a){le(e,a,!0)},get temporalPlaying(){return L(t)},set temporalPlaying(a){le(t,a,!0)},get temporalSpeed(){return L(n)},set temporalSpeed(a){le(n,a,!0)},get dreamMode(){return L(i)},set dreamMode(a){le(i,a,!0)},get brightness(){return L(s)},set brightness(a){const o=Math.min(Ec,Math.max(wc,a));if(le(s,o,!0),typeof localStorage<"u")try{localStorage.setItem(hf,String(o))}catch{}},brightnessMin:wc,brightnessMax:Ec,brightnessDefault:eo}}var PM=ut('<div class="w-full h-full"></div>');function DM(r,e){var G;sr(e,!0);let t=Dr(e,"events",19,()=>[]),n=Dr(e,"isDreaming",3,!1),i=Dr(e,"colorMode",3,"type");Ga(()=>{u==null||u.setColorMode(i())});let s,a,o,l=typeof window<"u"&&((G=window.matchMedia)==null?void 0:G.call(window,"(prefers-reduced-motion: reduce)").matches),c=null;function h(F){l=F.matches,a!=null&&a.controls&&(a.controls.autoRotate=!l)}let u,f,d,p,_,g,m,y,v=null,x=[];od(()=>{var J;a=tM(s),l&&(a.controls.autoRotate=!1),typeof window<"u"&&window.matchMedia&&(c=window.matchMedia("(prefers-reduced-motion: reduce)"),(J=c.addEventListener)==null||J.call(c,"change",h)),m=bM(a.scene).material,y=AM(a.composer),d=new fM(a.scene),u=new hM,u.colorMode=i(),f=new dM,p=new pM(a.scene),g=new mM;const V=u.createNodes(e.nodes);f.createEdges(e.edges,V),_=new sM(V),x=[...e.nodes],a.scene.add(f.group),a.scene.add(u.group),T(),window.addEventListener("resize",P),s.addEventListener("pointermove",S),s.addEventListener("click",M)}),Ac(()=>{var F;cancelAnimationFrame(o),window.removeEventListener("resize",P),(F=c==null?void 0:c.removeEventListener)==null||F.call(c,"change",h),s==null||s.removeEventListener("pointermove",S),s==null||s.removeEventListener("click",M),p==null||p.dispose(),d==null||d.dispose(),u==null||u.dispose(),f==null||f.dispose(),a&&iM(a)});let w=0;function T(){o=requestAnimationFrame(T);const F=performance.now();w===0&&(w=F);const V=F-w;if(V<16)return;w=F-V%16;const J=F*.001;_.tick(e.edges),u.updatePositions(),f.updatePositions(u.positions),f.animateEdges(u.positions),d.animate(J),u.animate(J,x,a.camera,ji.brightness),g.setActive(n()),g.update(a.scene,a.bloomPass,a.controls,a.lights,J),SM(m,J,g.current.nebulaIntensity,s.clientWidth,s.clientHeight),CM(y,J,g.current.nebulaIntensity),C(),p.update(u.meshMap,a.camera,u.positions),a.controls.update(),a.composer.render()}function C(){if(!t()||t().length===0)return;const F=[];for(const J of t()){if(J===v)break;F.push(J)}if(F.length===0)return;if(F.length===t().length&&t().length>=200){console.warn("[vestige] Event horizon overflow: dropping visuals for",F.length,"events"),v=t()[0];return}v=t()[0];const V={effects:p,nodeManager:u,edgeManager:f,forceSim:_,camera:a.camera,onMutation:J=>{var q;J.type==="nodeAdded"?x=[...x,J.node]:J.type==="nodeRemoved"&&(x=x.filter(se=>se.id!==J.nodeId)),(q=e.onGraphMutation)==null||q.call(e,J)}};for(let J=F.length-1;J>=0;J--)xM(F[J],V,x)}function P(){!s||!a||nM(a,s)}function S(F){const V=s.getBoundingClientRect();a.mouse.x=(F.clientX-V.left)/V.width*2-1,a.mouse.y=-((F.clientY-V.top)/V.height)*2+1,a.raycaster.setFromCamera(a.mouse,a.camera);const J=a.raycaster.intersectObjects(u.getMeshes());J.length>0?(u.hoveredNode=J[0].object.userData.nodeId,s.style.cursor="pointer"):(u.hoveredNode=null,s.style.cursor="grab")}function M(){var F;if(u.hoveredNode){u.selectedNode=u.hoveredNode,(F=e.onSelect)==null||F.call(e,u.hoveredNode);const V=u.positions.get(u.hoveredNode);V&&a.controls.target.lerp(V.clone(),.5)}}var D=PM();Rl(D,F=>s=F,()=>s),ot(r,D),rr()}var LM=ut('<div class="flex items-center gap-1 text-[10px]"><span class="text-muted"> </span> <span> </span></div>'),UM=ut('<div class="space-y-2"><svg class="w-full"><line x1="4" stroke="#2a2a5e" stroke-width="0.5" stroke-dasharray="2,4"></line><line x1="4" stroke="#ef444430" stroke-width="0.5" stroke-dasharray="2,4"></line><path fill="none" stroke="#6366f1" stroke-width="2" stroke-linecap="round"></path><path fill="url(#curveGrad)" opacity="0.15"></path><circle cx="4" r="3"></circle><defs><linearGradient id="curveGrad" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#6366f1"></stop><stop offset="100%" stop-color="#6366f100"></stop></linearGradient></defs></svg> <div class="flex gap-2 flex-wrap"></div></div>');function NM(r,e){sr(e,!0);let t=Dr(e,"width",3,240),n=Dr(e,"height",3,80);function i(g){return e.stability<=0?0:Math.exp(-g/e.stability)}let s=ei(()=>{const g=[],m=Math.max(e.stability*3,30),y=4,v=t()-y*2,x=n()-y*2;for(let w=0;w<=50;w++){const T=w/50*m,C=i(T),P=y+w/50*v,S=y+(1-C)*x;g.push(`${w===0?"M":"L"}${P.toFixed(1)},${S.toFixed(1)}`)}return g.join(" ")}),a=ei(()=>[{label:"Now",days:0,value:e.retention},{label:"1d",days:1,value:i(1)},{label:"7d",days:7,value:i(7)},{label:"30d",days:30,value:i(30)}]);function o(g){return g>.7?"#10b981":g>.4?"#f59e0b":"#ef4444"}var l=UM(),c=xe(l),h=xe(c),u=Ee(h),f=Ee(u),d=Ee(f),p=Ee(d);Or(),fe(c);var _=Ee(c,2);Pr(_,21,()=>L(a),Wa,(g,m)=>{var y=LM(),v=xe(y),x=xe(v);fe(v);var w=Ee(v,2),T=xe(w);fe(w),fe(y),Pt((C,P)=>{ct(x,`${L(m).label??""}:`),zr(w,`color: ${C??""}`),ct(T,`${P??""}%`)},[()=>o(L(m).value),()=>(L(m).value*100).toFixed(0)]),ot(g,y)}),fe(_),fe(l),Pt(g=>{Rt(c,"width",t()),Rt(c,"height",n()),Rt(c,"viewBox",`0 0 ${t()??""} ${n()??""}`),Rt(h,"y1",4+(n()-8)*.5),Rt(h,"x2",t()-4),Rt(h,"y2",4+(n()-8)*.5),Rt(u,"y1",4+(n()-8)*.8),Rt(u,"x2",t()-4),Rt(u,"y2",4+(n()-8)*.8),Rt(f,"d",L(s)),Rt(d,"d",`${L(s)??""} L${t()-4},${n()-4} L4,${n()-4} Z`),Rt(p,"cy",4+(1-e.retention)*(n()-8)),Rt(p,"fill",g)},[()=>o(e.retention)]),ot(r,l),rr()}function ad(r,e,t){const n=t.getTime(),i=new Set,s=new Map,a=r.filter(l=>{const c=new Date(l.createdAt).getTime();if(c<=n){i.add(l.id);const h=n-c,u=1440*60*1e3,f=h<u?.3+.7*(h/u):1;return s.set(l.id,f),!0}return!1}),o=e.filter(l=>i.has(l.source)&&i.has(l.target));return{visibleNodes:a,visibleEdges:o,nodeOpacities:s}}function FM(r){if(r.length===0){const n=new Date;return{oldest:n,newest:n}}let e=1/0,t=-1/0;for(const n of r){const i=new Date(n.createdAt).getTime();i<e&&(e=i),i>t&&(t=i)}return{oldest:new Date(e),newest:new Date(t)}}var OM=ut(`<div class="absolute bottom-4 left-1/2 -translate-x-1/2 z-10 w-[90%] max-w-xl"><div class="glass-panel rounded-xl p-3 space-y-2"><div class="flex items-center justify-between"><div class="flex items-center gap-2"><button class="w-7 h-7 rounded-lg bg-synapse/20 border border-synapse/30 text-synapse-glow text-xs flex items-center justify-center hover:bg-synapse/30 transition"> </button> <select class="px-2 py-1 bg-white/[0.03] border border-synapse/10 rounded-lg text-[10px] text-dim focus:outline-none"><option>1x</option><option>7x</option><option>30x</option></select></div> <span class="text-xs text-bright font-medium"> </span> <button class="text-[10px] text-muted hover:text-text transition">Close</button></div> <input type="range" min="0" max="100" step="0.1" class="w-full h-1.5 appearance-none bg-white/[0.06] rounded-full cursor-pointer
|
||
[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
|
||
[&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-synapse-glow
|
||
[&::-webkit-slider-thumb]:shadow-[0_0_8px_rgba(129,140,248,0.4)]"/> <div class="flex justify-between text-[9px] text-muted"><span> </span> <span> </span></div></div></div>`),BM=ut('<button class="absolute bottom-4 right-4 z-10 px-3 py-2 glass rounded-xl text-dim text-xs hover:text-text transition flex items-center gap-1.5"><span>◷</span> <span>Timeline</span></button>');function zM(r,e){sr(e,!0);let t=Qe(!1),n=Qe(!1),i=Qe(1),s=Qe(100),a,o=0,l=ei(()=>FM(e.nodes)),c=ei(()=>{const v=L(l).oldest.getTime(),w=L(l).newest.getTime()-v||1;return new Date(v+L(s)/100*w)});function h(v){return v.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function u(){le(t,!L(t)),e.onToggle(L(t)),L(t)&&(le(s,100),e.onDateChange(L(c)))}function f(){le(n,!L(n)),L(n)?(le(s,0),o=performance.now(),d()):cancelAnimationFrame(a)}function d(){L(n)&&(a=requestAnimationFrame(v=>{const x=(v-o)/1e3;o=v;const w=L(l).oldest.getTime(),C=(L(l).newest.getTime()-w)/(1440*60*1e3)||1,P=L(i)/C*100;if(le(s,Math.min(100,L(s)+P*x),!0),e.onDateChange(L(c)),L(s)>=100){le(n,!1);return}d()}))}function p(){e.onDateChange(L(c))}Ac(()=>{le(n,!1),cancelAnimationFrame(a)});var _=mf(),g=no(_);{var m=v=>{var x=OM(),w=xe(x),T=xe(w),C=xe(T),P=xe(C),S=xe(P,!0);fe(P);var M=Ee(P,2),D=xe(M);D.value=D.__value=1;var G=Ee(D);G.value=G.__value=7;var F=Ee(G);F.value=F.__value=30,fe(M),fe(C);var V=Ee(C,2),J=xe(V,!0);fe(V);var q=Ee(V,2);fe(T);var se=Ee(T,2);Br(se);var Z=Ee(se,2),_e=xe(Z),be=xe(_e,!0);fe(_e);var Re=Ee(_e,2),Ge=xe(Re,!0);fe(Re),fe(Z),fe(w),fe(x),Pt((it,Q,ue)=>{ct(S,L(n)?"⏸":"▶"),ct(J,it),ct(be,Q),ct(Ge,ue)},[()=>h(L(c)),()=>h(L(l).oldest),()=>h(L(l).newest)]),Ut("click",P,f),Mf(M,()=>L(i),it=>le(i,it)),Ut("click",q,u),Ut("input",se,p),Cl(se,()=>L(s),it=>le(s,it)),ot(v,x)},y=v=>{var x=BM();Ut("click",x,u),ot(v,x)};It(g,v=>{L(t)?v(m):v(y,!1)})}ot(r,_),rr()}Cc(["click","input"]);var kM=ut('<div class="flex items-center gap-2"><span class="w-2.5 h-2.5 rounded-full flex-shrink-0"></span> <span class="text-text capitalize"> </span> <span class="text-muted text-[10px] ml-auto"> </span></div>'),VM=ut('<div class="pointer-events-auto glass-subtle rounded-xl px-3 py-2.5 text-xs space-y-1.5 backdrop-blur-md border border-synapse/10" role="group" aria-label="Memory state colour legend"><div class="text-[10px] uppercase tracking-wider text-muted font-semibold mb-1.5">FSRS accessibility</div> <!></div>');function HM(r,e){sr(e,!1);const t=["active","dormant","silent","unavailable"];bf();var n=VM(),i=Ee(xe(n),2);Pr(i,1,()=>t,s=>s,(s,a)=>{var o=kM(),l=xe(o),c=Ee(l,2),h=xe(c,!0);fe(c);var u=Ee(c,2),f=xe(u,!0);fe(u),fe(o),Pt(d=>{zr(l,`background: ${bc[L(a)]??""}; box-shadow: 0 0 6px ${bc[L(a)]??""}55;`),ct(h,L(a)),ct(f,d)},[()=>{var d;return((d=aM[L(a)].match(/\(([^)]+)\)/))==null?void 0:d[1])??""}]),ot(s,o)}),fe(n),ot(r,n),rr()}function uf(r){var t,n;const e={};for(const i of r)(e[t=i.source]??(e[t]=[])).push({edge:i,otherId:i.target}),(e[n=i.target]??(e[n]=[])).push({edge:i,otherId:i.source});for(const i of Object.keys(e))e[i].sort((s,a)=>(a.edge.weight??0)-(s.edge.weight??0));return e}function to(r){const e=(r.type??"").toLowerCase();return e.includes("contradict")||e.includes("conflict")||e.includes("supersede")}function Ws(r){const e=Date.parse(r.updatedAt||r.createdAt||"");return Number.isFinite(e)?e:0}function GM(r,e,t,n=7){var g;const i=new Map(r.map(m=>[m.id,m])),s={beats:[],centerId:t,pivoted:!1,flowEdges:[]};if(r.length===0)return s;const a=uf(e),o=i.has(t);let l=o?t:"";l||(l=((g=r.find(m=>m.isCenter))==null?void 0:g.id)??""),l||(l=r.map(m=>{var y;return{id:m.id,deg:((y=a[m.id])==null?void 0:y.length)??0}}).sort((m,y)=>y.deg-m.deg)[0].id);const c=i.get(l);if(!c)return s;const h=!o,u=new Set([l]),f=[{nodeId:l,node:c,viaEdge:null,kind:"origin",intensity:1}],d=[];let p=l,_=!1;for(;f.length<n;){const m=a[p]??[];let y;if(_||(y=m.find(x=>!u.has(x.otherId)&&to(x.edge)),y&&(_=!0)),y||(y=m.find(x=>!u.has(x.otherId))),!y){const x=r.filter(T=>!u.has(T.id)).sort((T,C)=>Ws(C)-Ws(T));if(x.length===0)break;const w=x[0];u.add(w.id),f.push({nodeId:w.id,node:w,viaEdge:null,kind:"bridge",intensity:.6}),p=w.id;continue}const v=i.get(y.otherId);if(!v){u.add(y.otherId);continue}u.add(v.id),d.push(y.edge),f.push({nodeId:v.id,node:v,viaEdge:y.edge,kind:to(y.edge)?"contradiction":"connection",intensity:to(y.edge)?1:Math.min(1,.55+(y.edge.weight??0)*.45)}),p=v.id}if(f.length<n){const m=f[f.length-1].nodeId,y=r.filter(v=>v.id!==m).sort((v,x)=>Ws(x)-Ws(v))[0];y&&!f.some(v=>v.nodeId===y.id)&&f.push({nodeId:y.id,node:y,viaEdge:null,kind:"recent",intensity:.8})}return{beats:f,centerId:l,pivoted:h,flowEdges:d}}const jt=new A,WM=new A(0,1,0),XM=new A(0,0,0);class qM{constructor(e,t,n,i,s={},a={}){ke(this,"camera");ke(this,"target");ke(this,"positions");ke(this,"path");ke(this,"cb");ke(this,"opts");ke(this,"phase","idle");ke(this,"beatIndex",0);ke(this,"phaseElapsed",0);ke(this,"fromPos",new A);ke(this,"toPos",new A);ke(this,"fromTarget",new A);ke(this,"toTarget",new A);this.camera=e,this.target=t,this.positions=n,this.path=i,this.cb=s,this.opts={flightSeconds:a.flightSeconds??2.4,dwellSeconds:a.dwellSeconds??3.2,standoff:a.standoff??26,reducedMotion:a.reducedMotion??!1,shots:a.shots??[],centerOnOrigin:a.centerOnOrigin??!1}}shotAt(e){return this.opts.shots[e]??null}flightSecondsAt(e){var t;return((t=this.shotAt(e))==null?void 0:t.flightSeconds)??this.opts.flightSeconds}dwellSecondsAt(e){var t;return((t=this.shotAt(e))==null?void 0:t.dwellSeconds)??this.opts.dwellSeconds}get totalBeats(){return this.path.beats.length}get isRunning(){return this.phase!=="idle"&&this.phase!=="done"}start(){var e,t;if(this.path.beats.length===0){this.phase="done",(t=(e=this.cb).onComplete)==null||t.call(e);return}this.beatIndex=0,this.beginFlightTo(0)}stop(){this.phase="done"}focalPoint(e){return this.opts.centerOnOrigin?XM:this.positions.get(e.nodeId)??null}framePosition(e,t,n){const i=this.focalPoint(e);if(!i)return n.copy(this.camera.position);const s=this.shotAt(t);jt.copy(this.camera.position).sub(i),jt.lengthSq()<1e-4&&jt.set(0,.4,1),jt.normalize();let a=.35;s&&(s.angle==="low"?a=-.45:s.angle==="high"&&(a=.7)),jt.addScaledVector(WM,a).normalize();let o=(s==null?void 0:s.standoff)??this.opts.standoff;return s&&(s.move==="push_in"?o*=.7:s.move==="pull_back"?o*=1.5:s.move==="crane"&&(o*=1.8)),this.opts.centerOnOrigin&&(o=Math.max(31,Math.min(43,o))),n.copy(i).addScaledVector(jt,o)}beginFlightTo(e){var a,o;const t=this.path.beats[e],n=this.focalPoint(t),i=this.shotAt(e);this.fromPos.copy(this.camera.position),this.fromTarget.copy(this.target),this.framePosition(t,e,this.toPos),this.toTarget.copy(n??this.target),this.phaseElapsed=0,this.opts.reducedMotion||(i==null?void 0:i.cut)==="hard_cut"||(i==null?void 0:i.cut)==="match_cut"?(this.camera.position.copy(this.toPos),this.target.copy(this.toTarget),this.phase="dwelling",(o=(a=this.cb).onBeat)==null||o.call(a,t,e,i)):this.phase="flying"}update(e){var o,l,c,h,u,f,d,p,_;if(this.phase==="idle"||this.phase==="done")return;const t=Math.max(0,Math.min(e,.05));this.phaseElapsed+=t;const n=this.flightSecondsAt(this.beatIndex),i=this.dwellSecondsAt(this.beatIndex);if(this.phase==="flying"){const g=Math.min(1,this.phaseElapsed/n),m=YM(g);this.camera.position.lerpVectors(this.fromPos,this.toPos,m),this.target.lerpVectors(this.fromTarget,this.toTarget,m),this.applyDutch(this.beatIndex,m),g>=1&&(this.phase="dwelling",this.phaseElapsed=0,(l=(o=this.cb).onBeat)==null||l.call(o,this.path.beats[this.beatIndex],this.beatIndex,this.shotAt(this.beatIndex)))}else if(this.phase==="dwelling"){if(!this.opts.reducedMotion){const g=this.focalPoint(this.path.beats[this.beatIndex]);g&&(this.target.lerp(g,.02),((c=this.shotAt(this.beatIndex))==null?void 0:c.move)==="orbit"&&this.orbitAround(g,t*.35))}if(this.phaseElapsed>=i){const g=this.beatIndex+1;if(g>=this.path.beats.length){this.phase="done",(u=(h=this.cb).onProgress)==null||u.call(h,1),(d=(f=this.cb).onComplete)==null||d.call(f);return}this.beatIndex=g,this.beginFlightTo(g)}}const s=this.path.beats.length>0?1/this.path.beats.length:0,a=this.phase==="flying"?Math.min(1,this.phaseElapsed/n)*.5:.5+Math.min(1,this.phaseElapsed/i)*.5;(_=(p=this.cb).onProgress)==null||_.call(p,Math.min(1,this.beatIndex*s+a*s))}orbitAround(e,t){jt.copy(this.camera.position).sub(e);const n=Math.cos(t),i=Math.sin(t),s=jt.x*n-jt.z*i,a=jt.x*i+jt.z*n;jt.x=s,jt.z=a,this.camera.position.copy(e).add(jt)}applyDutch(e,t){var s;const i=(((s=this.shotAt(e))==null?void 0:s.dutch)??0)*t;jt.set(0,0,-1).applyQuaternion(this.camera.quaternion),this.camera.up.set(0,1,0).applyAxisAngle(jt,i)}}function YM(r){return r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2}const Tc={origin:"Origin",connection:"Connection",contradiction:"Tension",recent:"Now",bridge:"Jump",surprise:"Surprise"};function ZM(r,e=90){const t=(r??"").replace(/\s+/g," ").trim();return t.length<=e?t:t.slice(0,e-1).trimEnd()+"…"}function Tl(r){const e=(r??"memory").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}function df(r){return{source:"local-captions",beats:r.beats.map((t,n)=>{var o,l;const i=t.node,s=ZM(i.label||`(${Tl(i.type)} memory)`);let a;switch(t.kind){case"origin":a=`We begin at a ${Tl(i.type).toLowerCase()} the graph is centered on — "${s}".`;break;case"contradiction":{a=`This is held in tension with the last memory through ${(o=t.viaEdge)!=null&&o.type?t.viaEdge.type.replace(/_/g," "):"a conflict"}: "${s}".`;break}case"recent":a=`And where the mind is now — a recent memory: "${s}".`;break;case"bridge":a=`Crossing to a separate cluster — "${s}".`;break;default:{const c=((l=t.viaEdge)==null?void 0:l.weight)??0;a=`${c>.66?"strongly":c>.33?"closely":"loosely"} connected from there: a ${Tl(i.type).toLowerCase()} — "${s}".`}}return i.tags&&i.tags.length>0&&n>0&&(a+=` [${i.tags.slice(0,3).join(", ")}]`),{nodeId:t.nodeId,text:a,chip:Tc[t.kind]}})}}async function JM(r,e){const t=df(r);if(!e)return t;let n;try{const i=await Promise.race([e(),new Promise(l=>{n=setTimeout(()=>l(null),6e3)})]),s=Array.isArray(i)?i.filter(l=>!!l&&typeof l.nodeId=="string"&&typeof l.text=="string"&&l.text.trim().length>0):[];if(s.length===0)return t;const a=new Map(s.map(l=>[l.nodeId,l]));return{source:"backend-llm",beats:r.beats.map((l,c)=>{const h=a.get(l.nodeId);if(h){const u=typeof h.chip=="string"&&h.chip.trim()?h.chip:Tc[l.kind];return{nodeId:l.nodeId,text:h.text,chip:u}}return t.beats[c]??{nodeId:l.nodeId,text:l.node.label||"(unlabeled memory)",chip:Tc[l.kind]}})}}catch{return t}finally{n&&clearTimeout(n)}}function KM(r){const e=(r.type??"").toLowerCase();return e.includes("merge")||e.includes("supersede")||e.includes("duplicate")}function $M(r,e){const t=new Map;for(const n of r)t.set(n,0);for(const n of r){const i=[],s=new Map,a=new Map,o=new Map;for(const u of r)s.set(u,[]),a.set(u,0),o.set(u,-1);a.set(n,1),o.set(n,0);const l=[n];let c=0;for(;c<l.length;){const u=l[c++];i.push(u);for(const{otherId:f}of e[u]??[])(o.get(f)??-1)<0&&(o.set(f,(o.get(u)??0)+1),l.push(f)),(o.get(f)??-1)===(o.get(u)??0)+1&&(a.set(f,(a.get(f)??0)+(a.get(u)??0)),s.get(f).push(u))}const h=new Map;for(const u of r)h.set(u,0);for(;i.length>0;){const u=i.pop();for(const f of s.get(u)??[]){const d=(a.get(f)??0)/(a.get(u)||1)*(1+(h.get(u)??0));h.set(f,(h.get(f)??0)+d)}u!==n&&t.set(u,(t.get(u)??0)+(h.get(u)??0))}}return t}function jM(r,e){const t=new Map;for(const l of r)t.set(l,l);const n=l=>{let c=l;for(;t.get(c)!==c;)c=t.get(c);let h=l;for(;t.get(h)!==c;){const u=t.get(h);t.set(h,c),h=u}return c},i=(l,c)=>{const h=n(l),u=n(c);h!==u&&t.set(h,u)};for(const l of e)t.has(l.source)&&t.has(l.target)&&i(l.source,l.target);const s=new Map,a=new Map;let o=0;for(const l of r){const c=n(l);s.has(c)||s.set(c,o++),a.set(l,s.get(c))}return{clusterOf:a,count:o}}function QM(r,e){var y;const t=r.map(v=>v.id),n=uf(e),i=[...r].sort((v,x)=>Ws(v)-Ws(x)),s=new Map;i.forEach((v,x)=>s.set(v.id,r.length>1?x/(r.length-1):1));const a=600;let o=t;t.length>a&&(o=[...t].sort((v,x)=>{var w,T;return(((w=n[x])==null?void 0:w.length)??0)-(((T=n[v])==null?void 0:T.length)??0)}).slice(0,a));const l=$M(o,n);let c=0;for(const v of l.values())c=Math.max(c,v);const{clusterOf:h,count:u}=jM(t,e),f=Math.max(1,...r.map(v=>v.suppression_count??0)),d=new Map;let p=t[0]??"",_=-1;for(const v of r){const x=c>0?(l.get(v.id)??0)/c:0;x>_&&(_=x,p=v.id),d.set(v.id,{nodeId:v.id,degree:((y=n[v.id])==null?void 0:y.length)??0,betweenness:x,clusterId:h.get(v.id)??0,recencyRank:s.get(v.id)??0,retention:Ha(v.retention??0),suppression:Ha((v.suppression_count??0)/f)})}const g=new Map;for(const v of t)g.set(v,new Set((n[v]??[]).map(x=>x.otherId)));const m=e.map(v=>{const x=g.get(v.source),w=g.get(v.target);let T=0;if(x&&w){const[M,D]=x.size<w.size?[x,w]:[w,x];for(const G of M)D.has(G)&&T++}const C=((x==null?void 0:x.size)??0)+((w==null?void 0:w.size)??0)-T||1,P=T/C,S=1-Ha(v.weight??0);return{source:v.source,target:v.target,isContradiction:to(v),isMergeSupersede:KM(v),surprise:Ha(P*S*2),weight:v.weight??0}});return{nodes:d,edges:m,clusterCount:u,peakBetweennessId:p}}function Ha(r){return Math.max(0,Math.min(1,Number.isFinite(r)?r:0))}const eb={move:"hold",angle:"eye",dutch:0,standoff:26,flightSeconds:2.4,dwellSeconds:3.2,halflife:.35,cut:"fly",stormMode:"connection",intensity:.7,tension:.3,act:"I",tone:"neutral",scoreCue:"motif"},tb=new Set(["push_in","pull_back","orbit","crane","whip_pan","rack_focus","hold"]),nb=new Set(["eye","low","high"]),ib=new Set(["fly","hard_cut","match_cut"]),sb=new Set(["anchor","connection","contradiction","surprise"]),rb=new Set(["curious","tense","resolved","awe","neutral"]),ab=new Set(["motif","minor_drop","major_resolve","silence"]),ob=new Set(["I","II","III"]);function Ji(r,e,t,n){const i=typeof r=="number"&&Number.isFinite(r)?r:NaN;return Number.isNaN(i)?n:Math.max(e,Math.min(t,i))}function Ki(r,e,t){return typeof r=="string"&&e.has(r)?r:t}function lb(r,e){const t=new Map;for(const s of(r==null?void 0:r.shots)??[])s&&typeof s.nodeId=="string"&&t.set(s.nodeId,s);const n=[];let i=null;for(const s of e.beats){const a=t.get(s.nodeId),o=i??{...eb,nodeId:s.nodeId,why:""},l={nodeId:s.nodeId,move:Ki(a==null?void 0:a.move,tb,o.move),angle:Ki(a==null?void 0:a.angle,nb,o.angle),dutch:Ji(a==null?void 0:a.dutch,0,.6,o.dutch),standoff:Ji(a==null?void 0:a.standoff,8,90,o.standoff),flightSeconds:Ji(a==null?void 0:a.flightSeconds,.4,6,o.flightSeconds),dwellSeconds:Ji(a==null?void 0:a.dwellSeconds,.6,8,o.dwellSeconds),halflife:Ji(a==null?void 0:a.halflife,0,1.5,o.halflife),cut:Ki(a==null?void 0:a.cut,ib,"fly"),stormMode:Ki(a==null?void 0:a.stormMode,sb,o.stormMode),intensity:Ji(a==null?void 0:a.intensity,0,1,o.intensity),tension:Ji(a==null?void 0:a.tension,0,1,o.tension),act:Ki(a==null?void 0:a.act,ob,o.act),tone:Ki(a==null?void 0:a.tone,rb,o.tone),scoreCue:Ki(a==null?void 0:a.scoreCue,ab,"motif"),why:typeof(a==null?void 0:a.why)=="string"&&a.why.trim()?a.why:o.why||"establishing shot",viaEdgeKey:typeof(a==null?void 0:a.viaEdgeKey)=="string"?a.viaEdgeKey:void 0};n.push(l),i=l}return n}function cb(r){return r<.34?"I":r<.72?"II":"III"}function hb(r,e){var o;const t=r.beats.length,n=r.beats.map((l,c)=>{const h=t>1?c/(t-1):0,u=cb(h),f=e.nodes.get(l.nodeId),d=l.nodeId===e.peakBetweennessId,p=c===t-1,_=c===0;let g={nodeId:l.nodeId,move:"push_in",angle:"eye",cut:"fly",stormMode:"connection",tone:"curious",scoreCue:"motif",act:u,intensity:.6,tension:.3,why:"a connected memory"};return _&&(g={...g,move:"push_in",tone:"curious",tension:.25,stormMode:"anchor",why:"opening on the focal memory"}),(d||f&&f.betweenness>.6)&&(g={...g,move:"orbit",angle:"low",stormMode:"anchor",intensity:.75,tension:.45,tone:"awe",why:"low-angle orbit — the most load-bearing memory in the graph"}),l.kind==="contradiction"&&(g={...g,move:"push_in",angle:"eye",dutch:.28,cut:"hard_cut",stormMode:"contradiction",intensity:1,tension:.95,tone:"tense",scoreCue:"minor_drop",viaEdgeKey:l.viaEdge?`${l.viaEdge.source}->${l.viaEdge.target}`:void 0,why:"two memories in tension — a Dutch two-shot collision"}),l.kind==="surprise"&&(g={...g,move:"orbit",stormMode:"surprise",intensity:.85,tension:.6,tone:"awe",scoreCue:"motif",why:"a surprising, distant-but-plausible connection"}),f&&(f.retention<.35||f.suppression>.5)&&(g={...g,angle:"high",move:"pull_back",tone:"neutral",intensity:.4,why:"a fading memory — high-angle drift"}),l.kind==="recent"&&(g={...g,move:"push_in",tone:"resolved",tension:.4,why:"where the memory is now"}),p&&(g={...g,move:"crane",cut:"fly",stormMode:"anchor",tone:"awe",tension:.5,scoreCue:"major_resolve",why:"crane pull-back over the whole cluster — resolution"}),g}),i=r.beats.some(l=>l.kind==="contradiction")?"man_in_hole":"rags_to_riches";return{source:"deterministic",logline:`A short film about ${((o=r.beats[0])==null?void 0:o.node.label)??"a memory"} — ${t} shots through the graph${i==="man_in_hole"?", through a contradiction and out the other side":""}.`,arc:i,shots:n}}var ub=ut('<button class="cinema-restore svelte-1uwqs3k" title="Show UI (H)">press H to show UI</button>'),db=ut('<span class="cinema-badge svelte-1uwqs3k" title="Who directed this film"> </span>'),fb=ut('<span class="cinema-badge svelte-1uwqs3k"> </span>'),pb=ut('<span class="cinema-badge cinema-badge-gpu svelte-1uwqs3k">WebGPU</span>'),mb=ut('<span class="cinema-act svelte-1uwqs3k"> </span>'),gb=ut(`<div class="cinema-plan-card glass-panel svelte-1uwqs3k"><div class="cinema-plan-kicker svelte-1uwqs3k">Director's plan</div> <p class="cinema-plan-logline svelte-1uwqs3k"> </p></div>`),_b=ut('<div class="cinema-chip svelte-1uwqs3k"> </div>'),vb=ut('<p class="cinema-note svelte-1uwqs3k" title="Why the director chose this shot"> </p>'),xb=ut('<span class="cinema-dream svelte-1uwqs3k">∞ dreaming</span>'),yb=ut('<button class="cinema-replay svelte-1uwqs3k">↻ Replay</button>'),Mb=ut('<div class="cinema-top glass-subtle svelte-1uwqs3k"><div class="flex items-center gap-2 text-xs text-dim svelte-1uwqs3k"><span></span> <span class="svelte-1uwqs3k"> </span> <!> <!> <!> <!></div> <div class="flex items-center gap-2 svelte-1uwqs3k"><label class="cinema-toggle svelte-1uwqs3k" title="Speak narration aloud"><input type="checkbox" class="svelte-1uwqs3k"/> Voice</label> <label class="cinema-toggle svelte-1uwqs3k" title="Use an on-device model for narration (downloads weights on first use)"><input type="checkbox" class="svelte-1uwqs3k"/> Local AI</label> <button class="cinema-close svelte-1uwqs3k" aria-label="Close Memory Cinema (Esc)">✕</button></div></div> <!> <div class="cinema-caption-wrap svelte-1uwqs3k"><!> <p class="cinema-caption svelte-1uwqs3k"> </p> <!> <div class="cinema-progress svelte-1uwqs3k" aria-hidden="true"><div class="cinema-progress-fill svelte-1uwqs3k"></div></div> <div class="cinema-beatcount text-dim text-xs svelte-1uwqs3k"><!> <!></div></div>',1),bb=ut('<div class="cinema-overlay svelte-1uwqs3k" role="dialog" aria-modal="true" aria-label="Memory Cinema" tabindex="-1"><div class="cinema-canvas svelte-1uwqs3k"></div> <!> <!></div>'),Sb=ut('<button class="cinema-launch glass rounded-full px-4 py-2 text-sm text-bright flex items-center gap-2 hover:scale-[1.03] transition svelte-1uwqs3k" aria-label="Start Memory Cinema — an AI-narrated flythrough of your memory"><span aria-hidden="true" class="svelte-1uwqs3k">🎬</span> Memory Cinema</button> <!>',1);function wb(r,e){sr(e,!0);let t=Qe(!1),n=Qe("idle"),i=Qe(""),s=Qe(""),a=Qe(0),o=Qe(0),l=Qe(0),c=Qe(null),h=Qe(!1),u=Qe(!1),f=Qe(!1),d=Qe(!0),p=Qe(""),_=Qe(""),g=Qe("I"),m=Qe(0),y=Qe(""),v=Qe(null),x=Qe(void 0),w=null,T=null,C=null,P=null,S=0,M=0,D=null,G=0,F=Qe(null);const V=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=(k,X,W,ce)=>k+(X-k)*(1-Math.exp(-W*ce)),q={x:0,y:0},se={yaw:0,pitch:0};let Z=0,_e=0,be=0;const Re=2500,Ge=.35,it=.22,Q=()=>{be=performance.now()},ue=14;function Ie(k){const X=new Map,W=k.beats.length;for(let ce=0;ce<W;ce++){const ge=1-(W>1?ce/(W-1):.5)*2,Be=Math.sqrt(Math.max(0,1-ge*ge)),$=ce*2.399963;X.set(k.beats[ce].nodeId,new A(Math.cos($)*Be*ue,ge*ue*.5,Math.sin($)*Be*ue))}return X}function pe(k){if(!(!L(u)||typeof speechSynthesis>"u"))try{speechSynthesis.cancel();const X=new SpeechSynthesisUtterance(k);X.rate=.98,X.pitch=1,speechSynthesis.speak(X)}catch{}}function Oe(k){if(D&&clearInterval(D),le(i,""),V){le(i,k,!0);return}let X=0;D=setInterval(()=>{le(i,k.slice(0,++X),!0),X>=k.length&&D&&(clearInterval(D),D=null)},18)}function We(k){return k==="surprise"?"connection":k}function ze(k,X,W){var oe,ge;le(o,X+1);const ce=((oe=P==null?void 0:P.beats[X])==null?void 0:oe.text)??k.node.label??"";if(le(s,((ge=P==null?void 0:P.beats[X])==null?void 0:ge.chip)??"",!0),Oe(ce),pe(ce),W&&(le(_,W.why,!0),le(g,W.act,!0),le(m,W.tension,!0)),w&&L(h)){const Be=Je==null?void 0:Je.get(k.nodeId);if(Be){const ve=(W==null?void 0:W.stormMode)??"connection";w.transitionTo(We(ve),Be,(W==null?void 0:W.act)??"I",X)}const $=(W==null?void 0:W.tension)??0;w.setFlythrough(V?0:$*.8)}}let Je=null;async function te(){var ge,Be;if(cancelAnimationFrame(S),De(),D&&clearInterval(D),T==null||T.stop(),w==null||w.dispose(),w=null,T=null,P=null,G=0,le(_,""),le(y,""),le(v,null),le(g,"I"),le(m,0),le(t,!0),le(n,"planning"),le(p,"Planning a path through your memory…"),le(i,""),le(s,""),le(a,0),le(o,0),C=GM(e.nodes,e.edges,e.centerId,7),le(l,C.beats.length,!0),L(l)===0){le(p,"Not enough memory to compose a tour yet."),le(n,"done");return}Je=Ie(C);const k=QM(e.nodes,e.edges);le(v,hb(C,k),!0),le(y,L(v).logline,!0);const X=lb(L(v),C);if(le(g,((ge=X[0])==null?void 0:ge.act)??"I",!0),le(m,((Be=X[0])==null?void 0:Be.tension)??0,!0),P=await JM(C,L(f)?Ve():e.fetchBackendNarration),le(c,P.source,!0),le(h,!1),L(x))try{const{CinemaSandbox:$,isWebGPUSupported:ve}=await Sf(async()=>{const{CinemaSandbox:Y,isWebGPUSupported:ie}=await import("./Ma4NfFrG.js");return{CinemaSandbox:Y,isWebGPUSupported:ie}},__vite__mapDeps([0,1]),import.meta.url);ve()&&(w=new $(L(x)),await w.boot(),le(h,!0))}catch($){console.warn("[cinema] WebGPU sandbox unavailable, camera-only mode:",$),w=null,le(h,!1)}const W=L(x)&&L(x).clientHeight>0?L(x).clientWidth/L(x).clientHeight:16/9,ce=(w==null?void 0:w.cameraRef)??new kt(60,W,.1,2e3),oe=(w==null?void 0:w.target)??new A;T=new qM(ce,oe,Je,C,{onBeat:ze,onProgress:$=>le(a,$,!0),onComplete:()=>{le(n,"done"),le(p,V||!L(h)?"End of tour.":"∞ Dreaming — endless generative figures",!0),I()}},{reducedMotion:V,shots:X,centerOnOrigin:L(h)}),le(n,"playing"),le(p,L(h)?"Rendering 150k-particle semantic storm on WebGPU…":"Cinematic flythrough (captions mode).",!0),M=performance.now(),T.start(),de()}async function de(){const k=performance.now(),X=Math.max(0,Math.min(.05,(k-M)/1e3));M=k;try{T==null||T.update(X)}catch(ce){console.warn("[cinema] director error:",ce)}if(!V&&w&&L(h)){const ce=w.cameraRef,oe=performance.now()-be>Re,ge=oe?0:q.x*Ge,Be=oe?0:q.y*it,$=oe?1.5:9;se.yaw=J(se.yaw,ge,$,X),se.pitch=J(se.pitch,Be,$,X),oe&&(Z=J(Z,0,1.2,X)),_e=J(_e,Z,8,X);const ve=ce.position.clone(),Y=new xc().setFromVector3(ve);Y.theta+=se.yaw,Y.phi=bd.clamp(Y.phi+se.pitch,.2,Math.PI-.2),Y.radius*=1-_e*.35,ve.setFromSpherical(Y),ce.position.copy(ve)}const W=w;if(W&&L(h))try{await W.render(X),G=0}catch(ce){++G>=3&&w===W&&(console.warn("[cinema] WebGPU render failing, dropping to camera-only:",ce),le(h,!1),W.dispose(),w=null)}S=requestAnimationFrame(de)}function I(){V||!w||!L(h)||(De(),V||w==null||w.setFlythrough(.6),w==null||w.dreamBeat(),le(i,""),le(s,"Dreaming"),le(F,setInterval(()=>{if(!w||!L(h)){De();return}w.dreamBeat()},5500),!0))}function De(){L(F)&&(clearInterval(L(F)),le(F,null))}function re(){var k;cancelAnimationFrame(S),De(),D&&clearInterval(D),typeof speechSynthesis<"u"&&speechSynthesis.cancel(),w&&((k=w.setFlythrough)==null||k.call(w,0)),se.yaw=se.pitch=0,Z=_e=0,T==null||T.stop(),w==null||w.dispose(),w=null,T=null,le(t,!1),le(n,"idle"),le(h,!1)}let Ae=Qe(void 0);function me(k){k.key==="Escape"?(k.preventDefault(),re()):(k.key==="h"||k.key==="H")&&(k.preventDefault(),le(d,!L(d)))}Ga(()=>{L(t)&&L(Ae)&&L(Ae).focus()}),Ga(()=>{if(!(typeof document>"u"))return document.body.classList.toggle("cinema-open",L(t)),()=>document.body.classList.remove("cinema-open")}),Ga(()=>{if(!L(t)||V||!L(x))return;const k=L(x),X=($,ve,Y)=>Math.min(Y,Math.max(ve,$));k.style.touchAction="none";const W=$=>{q.x=$.clientX/window.innerWidth*2-1,q.y=-($.clientY/window.innerHeight)*2+1,Q()},ce=$=>{$.preventDefault(),Z=X(Z+$.deltaY*8e-4,-1,1),Q()};let oe=null;const ge=$=>{if($.touches.length===2){const ve=$.touches[0].clientX-$.touches[1].clientX,Y=$.touches[0].clientY-$.touches[1].clientY,ie=Math.hypot(ve,Y);oe!==null&&(Z=X(Z+(ie-oe)*.002,-1,1)),oe=ie,Q()}},Be=()=>{oe=null};return k.addEventListener("pointermove",W,{passive:!0}),k.addEventListener("wheel",ce,{passive:!1}),k.addEventListener("touchmove",ge,{passive:!0}),k.addEventListener("touchend",Be),()=>{k.removeEventListener("pointermove",W),k.removeEventListener("wheel",ce),k.removeEventListener("touchmove",ge),k.removeEventListener("touchend",Be)}});function Ve(){return async()=>{var k,X;if(!C)return null;try{le(p,"Loading on-device model (first run downloads weights)…");const ce=await import("@huggingface/transformers").catch(()=>null);if(!(ce!=null&&ce.pipeline))return null;const oe=await ce.pipeline("text-generation","onnx-community/Qwen2.5-0.5B-Instruct",{device:"webgpu",dtype:"q4"}),ge=df(C);le(p,"Narrating with the on-device model…");const Be=[];for(const $ of ge.beats){const ve=`You are narrating a cinematic tour of an AI's memory graph. In one vivid sentence, narrate this beat: "${$.text}"`,Y=await oe(ve,{max_new_tokens:48,temperature:.7,do_sample:!0}),ie=(X=(k=Y==null?void 0:Y[0])==null?void 0:k.generated_text)==null?void 0:X.replace(ve,"").trim();Be.push({nodeId:$.nodeId,chip:$.chip,text:ie&&ie.length>4?ie:$.text})}return Be}catch(W){return console.warn("[cinema] on-device narration failed, using local captions:",W),null}}}Ac(re);var Se=Sb(),R=no(Se),b=Ee(R,2);{var H=k=>{var X=bb(),W=xe(X);Rl(W,$=>le(x,$),()=>L(x));var ce=Ee(W,2);{var oe=$=>{var ve=ub();Ut("click",ve,()=>le(d,!0)),ot($,ve)};It(ce,$=>{L(d)||$(oe)})}var ge=Ee(ce,2);{var Be=$=>{var ve=Mb(),Y=no(ve),ie=xe(Y),ae=xe(ie);let Ne;var Pe=Ee(ae,2),Ke=xe(Pe,!0);fe(Pe);var U=Ee(Pe,2);{var ye=N=>{var z=db(),O=xe(z,!0);fe(z),Pt(()=>ct(O,L(v).source==="deterministic"?"Auteur (local)":"Auteur (AI)")),ot(N,z)};It(U,N=>{L(v)&&N(ye)})}var K=Ee(U,2);{var ee=N=>{var z=fb(),O=xe(z,!0);fe(z),Pt(()=>ct(O,L(c)==="backend-llm"?"AI narration":"Live captions")),ot(N,z)};It(K,N=>{L(c)&&N(ee)})}var we=Ee(K,2);{var Me=N=>{var z=pb();ot(N,z)};It(we,N=>{L(h)&&N(Me)})}var Ye=Ee(we,2);{var Mt=N=>{var z=mb(),O=xe(z);fe(z),Pt(()=>ct(O,`Act ${L(g)??""}`)),ot(N,z)};It(Ye,N=>{L(n)==="playing"&&N(Mt)})}fe(ie);var St=Ee(ie,2),at=xe(St),Yt=xe(at);Br(Yt),Or(),fe(at);var Ht=Ee(at,2),Di=xe(Ht);Br(Di),Or(),fe(Ht);var ui=Ee(Ht,2);Rl(ui,N=>le(Ae,N),()=>L(Ae)),fe(St),fe(Y);var En=Ee(Y,2);{var di=N=>{var z=gb(),O=Ee(xe(z),2),he=xe(O,!0);fe(O),fe(z),Pt(()=>ct(he,L(y))),ot(N,z)};It(En,N=>{L(n)==="planning"&&L(y)&&N(di)})}var Li=Ee(En,2),Wn=xe(Li);{var Xn=N=>{var z=_b(),O=xe(z,!0);fe(z),Pt(()=>ct(O,L(s))),ot(N,z)};It(Wn,N=>{L(s)&&N(Xn)})}var fi=Ee(Wn,2),Fn=xe(fi,!0);fe(fi);var Ui=Ee(fi,2);{var Zt=N=>{var z=vb(),O=xe(z);fe(z),Pt(()=>ct(O,`▸ ${L(_)??""}`)),ot(N,z)};It(Ui,N=>{L(_)&&L(n)==="playing"&&N(Zt)})}var Nt=Ee(Ui,2),mn=xe(Nt);fe(Nt);var Tn=Ee(Nt,2),pi=xe(Tn);{var fr=N=>{var z=xb();ot(N,z)},ds=N=>{var z=gf();Pt(()=>ct(z,`Beat ${L(o)??""} / ${L(l)??""}`)),ot(N,z)};It(pi,N=>{L(n)==="done"&&L(F)?N(fr):L(l)>0&&N(ds,1)})}var E=Ee(pi,2);{var B=N=>{var z=yb();Ut("click",z,te),ot(N,z)};It(E,N=>{L(n)==="done"&&N(B)})}fe(Tn),fe(Li),Pt(()=>{Ne=Ns(ae,1,"cinema-dot svelte-1uwqs3k",null,Ne,{active:L(n)==="playing"}),ct(Ke,L(p)),ct(Fn,L(i)),zr(mn,`width:${L(a)*100}%; --tension:${L(m)??""}`)}),ph(Yt,()=>L(u),N=>le(u,N)),ph(Di,()=>L(f),N=>le(f,N)),Ut("click",ui,re),ot($,ve)};It(ge,$=>{L(d)&&$(Be)})}fe(X),Ut("keydown",X,me),ot(k,X)};It(b,k=>{L(t)&&k(H)})}Ut("click",R,te),ot(r,Se),rr()}Cc(["click","keydown"]);var Eb=ut('<div class="h-full flex items-center justify-center"><div class="text-center space-y-4"><div class="w-16 h-16 mx-auto rounded-full border-2 border-synapse/30 border-t-synapse animate-spin"></div> <p class="text-dim text-sm">Weaving your memory graph…</p></div></div>'),Tb=ut(`<div class="h-full flex items-center justify-center"><div class="text-center space-y-5 max-w-lg px-8 enter"><div class="mx-auto w-fit text-warning opacity-70 breathe"><!></div> <h2 class="text-xl text-bright text-aurora">MCP Backend Offline</h2> <p class="text-dim text-sm leading-relaxed">The Vestige MCP server isn't reachable on <code class="font-mono text-muted">:3927</code>.
|
||
The dashboard is running but has nothing to query.</p> <div class="glass-subtle rounded-xl p-4 text-left text-xs font-mono text-dim space-y-2"><div class="text-muted text-[10px] uppercase tracking-wider">Start the backend:</div> <code class="block whitespace-pre-wrap break-all text-text">nohup bash -c 'tail -f /dev/null | VESTIGE_DASHBOARD_ENABLED=true ~/.local/bin/vestige-mcp' > /tmp/vestige.log 2>&1 &
|
||
disown</code></div> <div class="flex gap-2 justify-center"><button class="px-4 py-2 bg-synapse/20 border border-synapse/40 text-synapse-glow text-xs rounded-xl hover:bg-synapse/30 transition">Retry</button> <a class="px-4 py-2 bg-dream/20 border border-dream/40 text-dream-glow text-xs rounded-xl hover:bg-dream/30 transition">Try demos (no backend needed)</a></div></div></div>`),Ab=ut('<div class="h-full flex items-center justify-center"><div class="text-center space-y-4 max-w-md px-8 enter"><div class="mx-auto w-fit text-synapse-glow opacity-50 breathe"><!></div> <h2 class="text-xl text-bright text-aurora">Your Mind Awaits</h2> <p class="text-dim text-sm">No memories yet — the moment Vestige starts remembering, your constellation will bloom here.</p></div></div>'),Cb=ut('<div class="h-full flex items-center justify-center"><div class="text-center space-y-4 max-w-md px-8 enter"><div class="mx-auto w-fit text-synapse-glow opacity-50 breathe"><!></div> <h2 class="text-xl text-bright text-aurora">Your Mind Awaits</h2> <p class="text-dim text-sm"> </p></div></div>'),Rb=ut('<span> </span> <span class="mx-2 text-subtle">·</span> <span> </span> <span class="mx-2 text-subtle">·</span> <span> </span>',1),Ib=ut('<div class="absolute bottom-4 right-4 z-10"><!></div>'),Pb=ut('<div class="flex items-center gap-2"><span class="w-2.5 h-2.5 rounded-full"></span> <span class="text-dim"> </span></div>'),Db=ut('<div class="absolute bottom-4 right-4 z-10 glass rounded-xl px-4 py-3 text-xs"><div class="text-bright font-semibold mb-2">AhaGraph</div> <div class="space-y-1.5"></div></div>'),Lb=ut('<span class="px-2 py-0.5 rounded-lg text-xs bg-white/[0.04] text-dim"> </span>'),Ub=ut('<div><div class="flex justify-between text-xs text-dim mb-0.5"><span> </span> <span> </span></div> <div class="h-1.5 bg-white/[0.04] rounded-full overflow-hidden"><div class="h-full rounded-full transition-all duration-500"></div></div></div>'),Nb=ut("<div> </div>"),Fb=ut(`<div class="absolute right-0 top-0 h-full w-96 glass-panel p-6 overflow-y-auto z-20
|
||
transition-transform duration-300"><div class="flex justify-between items-start mb-4"><h3 class="text-bright text-sm font-semibold">Memory Detail</h3> <button class="text-dim hover:text-text text-lg leading-none">×</button></div> <div class="space-y-4"><div class="flex gap-2 flex-wrap"><span class="px-2 py-0.5 rounded-lg text-xs bg-synapse/20 text-synapse-glow"> </span> <!></div> <div class="text-sm text-text leading-relaxed whitespace-pre-wrap max-h-64 overflow-y-auto"> </div> <div class="space-y-2"></div> <div><div class="text-xs text-dim mb-1 font-medium">Retention Forecast</div> <!></div> <div class="text-xs text-muted space-y-1"><div> </div> <div> </div> <!> <div> </div></div> <div class="flex gap-2 pt-2"><button class="flex-1 px-3 py-2 rounded-xl bg-recall/20 text-recall text-xs hover:bg-recall/30 transition">↑ Promote</button> <button class="flex-1 px-3 py-2 rounded-xl bg-decay/20 text-decay text-xs hover:bg-decay/30 transition">↓ Demote</button></div> <a class="flex items-center justify-center gap-2 px-3 py-2 rounded-xl bg-dream/10 text-dream-glow text-xs hover:bg-dream/20 transition border border-dream/20"><!> Explore Connections</a></div></div>`),Ob=ut(`<div class="h-full relative"><!> <div class="absolute top-0 left-0 right-0 z-10 flex flex-wrap items-center gap-2 px-3 pt-3 sm:top-4 sm:left-4 sm:right-4 sm:gap-3 sm:p-0
|
||
[padding-top:max(0.75rem,env(safe-area-inset-top))] [padding-left:max(0.75rem,env(safe-area-inset-left))] [padding-right:max(0.75rem,env(safe-area-inset-right))]
|
||
sm:[padding-top:0] sm:[padding-left:0] sm:[padding-right:0]"><div class="flex gap-2 w-full sm:flex-1 sm:w-auto sm:max-w-md"><input type="text" placeholder="Center graph on..." class="flex-1 min-w-0 px-3 py-2 glass rounded-xl text-text text-sm
|
||
placeholder:text-muted focus:outline-none focus:!border-synapse/40 transition"/> <button class="shrink-0 min-h-10 px-3 py-2 bg-synapse/20 border border-synapse/40 text-synapse-glow text-sm rounded-xl hover:bg-synapse/30 transition backdrop-blur-sm">Focus</button></div> <div class="flex flex-wrap gap-2 w-full sm:w-auto sm:ml-auto"><div class="flex shrink min-w-0 glass rounded-xl p-0.5 text-xs" role="radiogroup" aria-label="Colour mode"><button type="button" role="radio" title="Colour by node type (fact, concept, event, …)">Type</button> <button type="button" role="radio" title="Colour by FSRS memory state (active / dormant / silent / unavailable)">State</button> <button type="button" role="radio" title="Colour by AhaGraph tags (aha / confusion / failure)">AhaGraph</button></div> <!> <label class="flex shrink-0 items-center gap-2 min-h-10 px-3 py-2 glass rounded-xl text-dim text-xs select-none"><span class="text-synapse-glow">☀</span> <input type="range" step="0.1" class="w-20 accent-synapse cursor-pointer" aria-label="Graph brightness"/> <span class="font-mono text-[10px] text-muted w-8 text-right"> </span></label> <button><span><!></span> </button> <!> <button class="shrink-0 min-h-10 min-w-10 inline-flex items-center justify-center px-3 py-2 glass rounded-xl text-dim hover:text-text hover:rotate-180 transition-all duration-500" title="Reload graph" aria-label="Reload graph"><!></button></div></div> <div class="graph-stats-pill absolute bottom-4 left-4 z-10 text-xs text-dim glass rounded-xl px-3 py-2"><!></div> <!> <!> <!> <!></div>`);function Fw(r,e){sr(e,!0);const t=()=>yf(Ef,"$eventFeed",n),[n,i]=xf();let s=Qe(null),a=Qe(null),o=Qe(!0),l=Qe(""),c=Qe(!1),h=Qe(""),u=Qe(150);const f=[{value:"50",label:"50 nodes"},{value:"100",label:"100 nodes"},{value:"150",label:"150 nodes"},{value:"200",label:"200 nodes"}];let d=Qe("150");function p(Y){le(u,parseInt(Y,10),!0),S()}let _=Qe(!1),g=Qe(Al(new Date)),m=Qe("type");const y=Object.entries(Qa);let v=Qe(0),x=Qe(0),w=ei(()=>L(s)?L(_)?ad(L(s).nodes,L(s).edges,L(g)).visibleNodes:L(s).nodes:[]),T=ei(()=>L(s)?L(_)?ad(L(s).nodes,L(s).edges,L(g)).visibleEdges:L(s).edges:[]);function C(Y){if(L(s))switch(Y.type){case"nodeAdded":L(s).nodes=[...L(s).nodes,Y.node],L(s).nodeCount=L(s).nodes.length,le(v,L(s).nodeCount,!0);break;case"nodeRemoved":L(s).nodes=L(s).nodes.filter(ie=>ie.id!==Y.nodeId),L(s).nodeCount=L(s).nodes.length,le(v,L(s).nodeCount,!0);break;case"edgeAdded":L(s).edges=[...L(s).edges,Y.edge],L(s).edgeCount=L(s).edges.length,le(x,L(s).edgeCount,!0);break;case"edgesRemoved":L(s).edges=L(s).edges.filter(ie=>ie.source!==Y.nodeId&&ie.target!==Y.nodeId),L(s).edgeCount=L(s).edges.length,le(x,L(s).edgeCount,!0);break;case"nodeUpdated":{const ie=L(s).nodes.find(ae=>ae.id===Y.nodeId);ie&&(ie.retention=Y.retention);break}}}od(()=>{const Y=new URLSearchParams(window.location.search),ie=Y.get("colorMode");P(ie)&&le(m,ie,!0);const ae=Y.get("center");S(void 0,ae||void 0)});function P(Y){return Y==="type"||Y==="state"||Y==="ahagraph"}async function S(Y,ie){var ae;le(o,!0),le(l,"");try{const Ne=!Y&&!ie;if(le(s,await ms.graph({max_nodes:L(u),depth:3,query:Y||void 0,center_id:ie||void 0,sort:Ne?"recent":void 0}),!0),Ne&&L(s)&&L(s).nodeCount<=1&&L(s).edgeCount===0){const Pe=await ms.graph({max_nodes:L(u),depth:3,sort:"connected"});Pe&&Pe.nodeCount>L(s).nodeCount&&le(s,Pe,!0)}L(s)&&(le(v,L(s).nodeCount,!0),le(x,L(s).edgeCount,!0))}catch(Ne){const Pe=Ne instanceof Error?Ne.message:String(Ne),Ke=Pe.replace(/\/[\w./-]+\.(sqlite|rs|db|toml|lock)\b/g,"[path]").slice(0,200),U=Ne instanceof TypeError||/failed to fetch|NetworkError|load failed/i.test(Pe)||/^API 500:?\s*(Internal Server Error)?\s*$/i.test(Pe.trim()),ye=(((ae=L(s))==null?void 0:ae.nodeCount)??0)===0&&/not found|404|empty|no memor/i.test(Pe);U?le(l,"OFFLINE"):ye?le(l,"EMPTY"):le(l,`Failed to load graph: ${Ke}`)}finally{le(o,!1)}}async function M(){le(c,!0);try{await ms.dream(),await S()}catch{}finally{le(c,!1)}}async function D(Y){try{le(a,await ms.memories.get(Y),!0)}catch{le(a,null)}}function G(){L(h).trim()&&S(L(h))}var F=Ob(),V=xe(F);{var J=Y=>{var ie=Eb();ot(Y,ie)},q=Y=>{var ie=Tb(),ae=xe(ie),Ne=xe(ae),Pe=xe(Ne);ps(Pe,{name:"activation",size:52,strokeWidth:1.2}),fe(Ne);var Ke=Ee(Ne,8),U=xe(Ke),ye=Ee(U,2);fe(Ke),fe(ae),fe(ie),Pt(()=>Rt(ye,"href",`${mh??""}/settings`)),Ut("click",U,()=>S()),ot(Y,ie)},se=Y=>{var ie=Ab(),ae=xe(ie),Ne=xe(ae),Pe=xe(Ne);ps(Pe,{name:"graph",size:52,strokeWidth:1.2}),fe(Ne),Or(4),fe(ae),fe(ie),ot(Y,ie)},Z=Y=>{var ie=Cb(),ae=xe(ie),Ne=xe(ae),Pe=xe(Ne);ps(Pe,{name:"graph",size:52,strokeWidth:1.2}),fe(Ne);var Ke=Ee(Ne,4),U=xe(Ke,!0);fe(Ke),fe(ae),fe(ie),Pt(()=>ct(U,L(l))),ot(Y,ie)},_e=Y=>{DM(Y,{get nodes(){return L(w)},get edges(){return L(T)},get centerId(){return L(s).center_id},get events(){return t()},get isDreaming(){return L(c)},get colorMode(){return L(m)},onSelect:D,onGraphMutation:C})};It(V,Y=>{L(o)?Y(J):L(l)==="OFFLINE"?Y(q,1):L(l)==="EMPTY"?Y(se,2):L(l)?Y(Z,3):L(s)&&Y(_e,4)})}var be=Ee(V,2),Re=xe(be),Ge=xe(Re);Br(Ge);var it=Ee(Ge,2);fe(Re);var Q=Ee(Re,2),ue=xe(Q),Ie=xe(ue),pe=Ee(Ie,2),Oe=Ee(pe,2);fe(ue);var We=Ee(ue,2);wf(We,{get options(){return f},icon:"graph",class:"shrink-0",onChange:p,get value(){return L(d)},set value(Y){le(d,Y,!0)}});var ze=Ee(We,2),Je=Ee(xe(ze),2);Br(Je);var te=Ee(Je,2),de=xe(te);fe(te),fe(ze);var I=Ee(ze,2),De=xe(I),re=xe(De);ps(re,{name:"dreams",size:16}),fe(De);var Ae=Ee(De);fe(I);var me=Ee(I,2);{var Ve=Y=>{{let ie=ei(()=>{var ae;return((ae=L(s))==null?void 0:ae.center_id)??""});wb(Y,{get nodes(){return L(w)},get edges(){return L(T)},get centerId(){return L(ie)}})}};It(me,Y=>{L(w).length>0&&Y(Ve)})}var Se=Ee(me,2),R=xe(Se);ps(R,{name:"pulse",size:16}),fe(Se),fe(Q),fe(be);var b=Ee(be,2),H=xe(b);{var k=Y=>{var ie=Rb(),ae=no(ie),Ne=xe(ae);fe(ae);var Pe=Ee(ae,4),Ke=xe(Pe);fe(Pe);var U=Ee(Pe,4),ye=xe(U);fe(U),Pt(()=>{ct(Ne,`${L(v)??""} nodes`),ct(Ke,`${L(x)??""} edges`),ct(ye,`depth ${L(s).depth??""}`)}),ot(Y,ie)};It(H,Y=>{L(s)&&Y(k)})}fe(b);var X=Ee(b,2);{var W=Y=>{var ie=Ib(),ae=xe(ie);HM(ae,{}),fe(ie),ot(Y,ie)};It(X,Y=>{L(m)==="state"&&Y(W)})}var ce=Ee(X,2);{var oe=Y=>{var ie=Db(),ae=Ee(xe(ie),2);Pr(ae,21,()=>y,Wa,(Ne,Pe)=>{var Ke=ei(()=>_f(L(Pe),2));let U=()=>L(Ke)[0],ye=()=>L(Ke)[1];var K=Pb(),ee=xe(K),we=Ee(ee,2),Me=xe(we,!0);fe(we),fe(K),Pt(()=>{zr(ee,`background: ${ye()??""}`),ct(Me,oM[U()])}),ot(Ne,K)}),fe(ae),fe(ie),ot(Y,ie)};It(ce,Y=>{L(m)==="ahagraph"&&Y(oe)})}var ge=Ee(ce,2);{var Be=Y=>{zM(Y,{get nodes(){return L(s).nodes},onDateChange:ie=>{le(g,ie,!0)},onToggle:ie=>{le(_,ie,!0)}})};It(ge,Y=>{L(s)&&Y(Be)})}var $=Ee(ge,2);{var ve=Y=>{var ie=Fb(),ae=xe(ie),Ne=Ee(xe(ae),2);fe(ae);var Pe=Ee(ae,2),Ke=xe(Pe),U=xe(Ke),ye=xe(U,!0);fe(U);var K=Ee(U,2);Pr(K,17,()=>L(a).tags,Wa,(Zt,Nt)=>{var mn=Lb(),Tn=xe(mn,!0);fe(mn),Pt(()=>ct(Tn,L(Nt))),ot(Zt,mn)}),fe(Ke);var ee=Ee(Ke,2),we=xe(ee,!0);fe(ee);var Me=Ee(ee,2);Pr(Me,21,()=>[{label:"Retention",value:L(a).retentionStrength},{label:"Storage",value:L(a).storageStrength},{label:"Retrieval",value:L(a).retrievalStrength}],Wa,(Zt,Nt)=>{var mn=Ub(),Tn=xe(mn),pi=xe(Tn),fr=xe(pi,!0);fe(pi);var ds=Ee(pi,2),E=xe(ds);fe(ds),fe(Tn);var B=Ee(Tn,2),N=xe(B);fe(B),fe(mn),Pt(z=>{ct(fr,L(Nt).label),ct(E,`${z??""}%`),zr(N,`width: ${L(Nt).value*100}%; background: ${L(Nt).value>.7?"#10b981":L(Nt).value>.4?"#f59e0b":"#ef4444"}`)},[()=>(L(Nt).value*100).toFixed(1)]),ot(Zt,mn)}),fe(Me);var Ye=Ee(Me,2),Mt=Ee(xe(Ye),2);{let Zt=ei(()=>L(a).storageStrength*30);NM(Mt,{get retention(){return L(a).retentionStrength},get stability(){return L(Zt)}})}fe(Ye);var St=Ee(Ye,2),at=xe(St),Yt=xe(at);fe(at);var Ht=Ee(at,2),Di=xe(Ht);fe(Ht);var ui=Ee(Ht,2);{var En=Zt=>{var Nt=Nb(),mn=xe(Nt);fe(Nt),Pt(Tn=>ct(mn,`Accessed: ${Tn??""}`),[()=>new Date(L(a).lastAccessedAt).toLocaleString()]),ot(Zt,Nt)};It(ui,Zt=>{L(a).lastAccessedAt&&Zt(En)})}var di=Ee(ui,2),Li=xe(di);fe(di),fe(St);var Wn=Ee(St,2),Xn=xe(Wn),fi=Ee(Xn,2);fe(Wn);var Fn=Ee(Wn,2),Ui=xe(Fn);ps(Ui,{name:"explore",size:14}),Or(),fe(Fn),fe(Pe),fe(ie),Pt((Zt,Nt)=>{ct(ye,L(a).nodeType),ct(we,L(a).content),ct(Yt,`Created: ${Zt??""}`),ct(Di,`Updated: ${Nt??""}`),ct(Li,`Reviews: ${L(a).reviewCount??0??""}`),Rt(Fn,"href",`${mh??""}/explore`)},[()=>new Date(L(a).createdAt).toLocaleString(),()=>new Date(L(a).updatedAt).toLocaleString()]),Ut("click",Ne,()=>le(a,null)),Ut("click",Xn,()=>{L(a)&&ms.memories.promote(L(a).id)}),Ut("click",fi,()=>{L(a)&&ms.memories.demote(L(a).id)}),ot(Y,ie)};It($,Y=>{L(a)&&Y(ve)})}fe(F),Pt((Y,ie)=>{Rt(Ie,"aria-checked",L(m)==="type"),Ns(Ie,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${L(m)==="type"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),Rt(pe,"aria-checked",L(m)==="state"),Ns(pe,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${L(m)==="state"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),Rt(Oe,"aria-checked",L(m)==="ahagraph"),Ns(Oe,1,`min-h-9 px-3 py-1.5 rounded-lg transition ${L(m)==="ahagraph"?"bg-synapse/25 text-synapse-glow":"text-dim hover:text-text"}`),Rt(ze,"title",`Adjust graph brightness (${Y??""}x). Combines with auto distance compensation.`),Rt(Je,"min",ji.brightnessMin),Rt(Je,"max",ji.brightnessMax),ct(de,`${ie??""}x`),I.disabled=L(c),Ns(I,1,`shrink-0 inline-flex items-center gap-2 min-h-10 px-4 py-2 rounded-xl bg-dream/20 border border-dream/40 text-dream-glow text-sm
|
||
hover:bg-dream/30 transition-all backdrop-blur-sm disabled:opacity-50
|
||
${L(c)?"glow-dream animate-pulse-glow":""}`),Ns(De,1,vf(L(c)?"breathe":"")),ct(Ae,` ${L(c)?"Dreaming…":"Dream"}`)},[()=>ji.brightness.toFixed(1),()=>ji.brightness.toFixed(1)]),Ut("keydown",Ge,Y=>Y.key==="Enter"&&G()),Cl(Ge,()=>L(h),Y=>le(h,Y)),Ut("click",it,G),Ut("click",Ie,()=>le(m,"type")),Ut("click",pe,()=>le(m,"state")),Ut("click",Oe,()=>le(m,"ahagraph")),Cl(Je,()=>ji.brightness,Y=>ji.brightness=Y),Ut("click",I,M),Ut("click",Se,()=>S()),ot(r,F),rr(),i()}Cc(["click","keydown"]);export{cs as $,Wt as A,fn as B,ne as C,IS as D,ci as E,pt as F,ns as G,si as H,Pd as I,Pc as J,YS as K,rg as L,bd as M,ii as N,Rc as O,lr as P,wn as Q,zc as R,ho as S,Pi as T,Ii as U,A as V,uo as W,on as X,qs as Y,ch as Z,sw as _,tt as a,Nn as a$,op as a0,yt as a1,Lo as a2,kt as a3,or as a4,Et as a5,Ld as a6,Ti as a7,Qs as a8,Ze as a9,ld as aA,To as aB,Ci as aC,Bn as aD,Fs as aE,_c as aF,yg as aG,Mg as aH,Jd as aI,mg as aJ,Sg as aK,Jf as aL,Kf as aM,$f as aN,cd as aO,Qf as aP,ep as aQ,rS as aR,io as aS,so as aT,cr as aU,js as aV,Ys as aW,$s as aX,li as aY,Dp as aZ,ao as a_,wi as aa,Ic as ab,In as ac,cp as ad,Qn as ae,vd as af,$m as ag,rs as ah,rt as ai,JS as aj,Zf as ak,Yf as al,bo as am,wo as an,Mn as ao,tm as ap,Cd as aq,em as ar,qr as as,qe as at,dn as au,Fe as av,mt as aw,cS as ax,Si as ay,xn as az,j as b,Yl as b$,ro as b0,hd as b1,Qt as b2,dp as b3,up as b4,fp as b5,hp as b6,Md as b7,pp as b8,lp as b9,Ul as bA,Ll as bB,Dc as bC,Lc as bD,fd as bE,ud as bF,dd as bG,kr as bH,pd as bI,md as bJ,gd as bK,_d as bL,Uc as bM,So as bN,Nc as bO,Fc as bP,qa as bQ,Ya as bR,Za as bS,Ja as bT,kl as bU,Vl as bV,Hl as bW,Gl as bX,Wl as bY,Xl as bZ,ql as b_,Pf as ba,If as bb,Qi as bc,zf as bd,Vf as be,Dl as bf,Of as bg,Bf as bh,kf as bi,Hf as bj,Pl as bk,Ff as bl,Nf as bm,Uf as bn,Tf as bo,gh as bp,Af as bq,Rf as br,vh as bs,_h as bt,zl as bu,Bl as bv,Ol as bw,Fl as bx,Ks as by,Nl as bz,Wc as c,pn as c$,Zl as c0,Jl as c1,Kl as c2,$l as c3,jl as c4,Ql as c5,ec as c6,tc as c7,nc as c8,ic as c9,gs as cA,Lf as cB,Df as cC,Eo as cD,hS as cE,yd as cF,Vg as cG,yo as cH,QS as cI,dw as cJ,uw as cK,jS as cL,_m as cM,Ag as cN,Dw as cO,xh as cP,Rg as cQ,hw as cR,Kd as cS,lw as cT,aw as cU,Lw as cV,rp as cW,mm as cX,Id as cY,hr as cZ,xw as c_,sc as ca,rc as cb,ac as cc,Ka as cd,xd as ce,cc as cf,hc as cg,uc as ch,ai as ci,Td as cj,Ed as ck,CS as cl,AS as cm,RS as cn,ES as co,TS as cp,wS as cq,yh as cr,SS as cs,MS as ct,yS as cu,xS as cv,vS as cw,bS as cx,_S as cy,gS as cz,nr as d,Gn as d$,Iw as d0,Rw as d1,Eg as d2,Ei as d3,Hc as d4,Cw as d5,Dd as d6,Jc as d7,vm as d8,Kc as d9,Aw as dA,cg as dB,jc as dC,FS as dD,LS as dE,Rm as dF,Yc as dG,Qc as dH,Gc as dI,Yr as dJ,_w as dK,BS as dL,Mh as dM,Ew as dN,ww as dO,eh as dP,rw as dQ,Mo as dR,Op as dS,wg as dT,XS as dU,qS as dV,HS as dW,Po as dX,oo as dY,dc as dZ,Fo as d_,$d as da,Yd as db,KS as dc,$S as dd,qc as de,ew as df,$c as dg,Xf as dh,Gf as di,qg as dj,tw as dk,Ud as dl,Tm as dm,lg as dn,sS as dp,Hn as dq,Cm as dr,jf as ds,Zr as dt,vw as du,kc as dv,nw as dw,VS as dx,fg as dy,tp as dz,ht as e,Vs as e$,nm as e0,Ao as e1,Vc as e2,us as e3,Vn as e4,yw as e5,Nd as e6,Am as e7,gm as e8,hi as e9,cw as eA,ft as eB,Pg as eC,Fd as eD,Od as eE,rn as eF,Do as eG,hg as eH,ap as eI,pS as eJ,oc as eK,lc as eL,mS as eM,jm as eN,ar as eO,Wg as eP,fw as eQ,pw as eR,Io as eS,Xt as eT,Js as eU,th as eV,Uw as eW,oi as eX,Xc as eY,bw as eZ,sm as e_,qd as ea,lS as eb,co as ec,fu as ed,Zd as ee,np as ef,sp as eg,ip as eh,Xs as ei,Qd as ej,Hd as ek,Gd as el,oS as em,aS as en,Oc as eo,vo as ep,Ro as eq,qf as er,Wf as es,Cf as et,_o as eu,Pw as ev,Sw as ew,as as ex,Tw as ey,hs as ez,vt as f,an as f0,xc as f1,bg as f2,Bd as f3,Mw as f4,ts as f5,NS as f6,DS as f7,ow as f8,OS as f9,zs as fA,Fw as fB,PS as fa,US as fb,ur as fc,Os as fd,nh as fe,iw as ff,Nw as fg,ih as fh,sh as fi,yn as fj,fS as fk,dS as fl,uS as fm,rh as fn,GS as fo,WS as fp,jd as fq,mw as fr,xo as fs,ZS as ft,kS as fu,zS as fv,Sn as fw,Km as fx,lo as fy,Bs as fz,Ri as g,os as h,zn as i,_g as j,gw as k,Hr as l,Ai as m,qt as n,kn as o,ig as p,sg as q,ng as r,eg as s,Qm as t,ah as u,tg as v,Vt as w,Xa as x,Cr as y,ni as z};
|