pi-roundtable-web 0.26.2 → 0.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +16 -1
- package/dist/chunk-account-hck7mhf8.js +1 -0
- package/dist/{chunk-action-menu-ec9jqtxq.js → chunk-action-menu-beqh40k6.js} +1 -1
- package/dist/chunk-agent-znnth24t.js +1 -0
- package/dist/chunk-arranged-rooms-wfakrddk.js +1 -0
- package/dist/chunk-bulk-actions-c4tkvk9g.js +1 -0
- package/dist/chunk-character-creator-qwcsdytw.js +1 -0
- package/dist/{chunk-codeeditor-jm2sm333.js → chunk-codeeditor-6xavqntt.js} +2 -2
- package/dist/chunk-confirm-z95j9jt3.js +1 -0
- package/dist/{chunk-connectors-mhnw6d79.js → chunk-connectors-7xqsg5q5.js} +1 -1
- package/dist/{chunk-conversations-yjyq4g1y.js → chunk-conversations-zc4mv6vj.js} +1 -1
- package/dist/{chunk-drag-nyq52ck7.js → chunk-drag-0mefcvp3.js} +1 -1
- package/dist/{chunk-entry-red1597w.js → chunk-entry-hrt97qed.js} +1 -1
- package/dist/chunk-folder-list-nemtqbnc.js +1 -0
- package/dist/chunk-folds-xpg9qcwf.js +1 -0
- package/dist/chunk-gate-86r8a2vf.js +1 -0
- package/dist/chunk-group-scene-g24kxz6f.js +1 -0
- package/dist/chunk-group-table-851jm8ef.js +1 -0
- package/dist/chunk-host-icons-23zhqpmc.js +1 -0
- package/dist/chunk-host-picture-8tnh2wam.js +1 -0
- package/dist/chunk-host-state-j41sp065.js +1 -0
- package/dist/chunk-host-ui-cje7a9t9.js +1 -0
- package/dist/chunk-index-1fn8q4ps.js +2 -0
- package/dist/{chunk-index-kfv996qe.js → chunk-index-30vw4nhh.js} +35 -3
- package/dist/{chunk-index-tmx30r1w.js → chunk-index-3aa5czxj.js} +2 -2
- package/dist/chunk-index-3k7sdph2.js +1 -0
- package/dist/{chunk-index-7bbqtdce.js → chunk-index-3wbyq10m.js} +2 -2
- package/dist/{chunk-index-9nents16.js → chunk-index-47yspxa4.js} +2 -2
- package/dist/chunk-index-4s1qj9we.js +2 -0
- package/dist/chunk-index-5fz5e1ct.js +2 -0
- package/dist/{chunk-index-kw85ajap.js → chunk-index-67p2sc14.js} +3 -3
- package/dist/{chunk-index-0xj30mzw.js → chunk-index-6c8mewwy.js} +12 -12
- package/dist/{chunk-index-934zgd18.js → chunk-index-84wbc80d.js} +2 -2
- package/dist/{chunk-index-y00wke93.js → chunk-index-8eexybcx.js} +2 -2
- package/dist/{chunk-index-1f0j335v.js → chunk-index-agrvqf5b.js} +2 -2
- package/dist/chunk-index-azrnzgev.js +2 -0
- package/dist/chunk-index-c2ag3qw2.js +2 -0
- package/dist/chunk-index-e90kztkx.js +4 -0
- package/dist/chunk-index-efgm0066.js +2 -0
- package/dist/{chunk-index-b7jjca66.js → chunk-index-eh0wb6g0.js} +2 -2
- package/dist/{chunk-index-yrhbhmxz.js → chunk-index-eyc2rkq5.js} +2 -2
- package/dist/{chunk-index-datrrs6b.js → chunk-index-fe0m5mht.js} +2 -2
- package/dist/{chunk-index-f3b5nch2.js → chunk-index-gt42wjby.js} +3 -3
- package/dist/{chunk-index-6tpr6r6d.js → chunk-index-hc0dgmrs.js} +2 -2
- package/dist/{chunk-index-0n6ja7my.js → chunk-index-hczrjnky.js} +1 -1
- package/dist/chunk-index-hrtyanda.js +2 -0
- package/dist/chunk-index-j479p62w.js +2 -0
- package/dist/{chunk-index-cmxs5y22.js → chunk-index-jq970hsd.js} +3 -3
- package/dist/chunk-index-kankja6p.js +50 -0
- package/dist/chunk-index-kb44jp50.js +2 -0
- package/dist/{chunk-index-029209sy.js → chunk-index-m65cv329.js} +2 -2
- package/dist/chunk-index-mnwdbb4n.js +2 -0
- package/dist/chunk-index-n6zrc05a.js +2 -0
- package/dist/chunk-index-n93wqszt.js +8 -0
- package/dist/{chunk-index-43k1rjmx.js → chunk-index-nrexxkar.js} +2 -2
- package/dist/chunk-index-pgxgq61x.js +2 -0
- package/dist/chunk-index-q5vzjqr5.js +2 -0
- package/dist/chunk-index-qqwk157d.js +2 -0
- package/dist/{chunk-index-ewj52be9.js → chunk-index-r1v895tj.js} +2 -2
- package/dist/chunk-index-r3tqhew8.js +2 -0
- package/dist/chunk-index-raf772z6.js +2 -0
- package/dist/{chunk-index-smw1n2pt.js → chunk-index-rcxz5w5d.js} +5 -5
- package/dist/chunk-index-rg9vh59e.js +1 -0
- package/dist/chunk-index-sxq69p1f.js +2 -0
- package/dist/chunk-index-taq2psr6.js +2 -0
- package/dist/{chunk-index-frwa2fmc.js → chunk-index-tsxsy4qs.js} +2 -2
- package/dist/chunk-index-wc83vb0a.js +2 -0
- package/dist/chunk-index-xbs8q4kn.js +2 -0
- package/dist/chunk-index-xxbveevc.js +2 -0
- package/dist/chunk-index-zx6yka30.js +2 -0
- package/dist/chunk-lang-css-yrc25qk9.js +1 -0
- package/dist/{chunk-lang-dockerfile-46rk929v.js → chunk-lang-dockerfile-tjxsnhr9.js} +1 -1
- package/dist/{chunk-lang-go-qb0qdpg7.js → chunk-lang-go-drmfa25k.js} +3 -3
- package/dist/chunk-lang-html-rwe8epvf.js +1 -0
- package/dist/chunk-lang-javascript-d6x6qjtg.js +1 -0
- package/dist/{chunk-lang-json-1q4fp694.js → chunk-lang-json-790swysy.js} +1 -1
- package/dist/{chunk-lang-markdown-5w7t28wa.js → chunk-lang-markdown-483dkxcq.js} +5 -5
- package/dist/{chunk-lang-python-3dq0p4rf.js → chunk-lang-python-v9s40bzj.js} +2 -2
- package/dist/{chunk-lang-rust-70pa0agr.js → chunk-lang-rust-z4gry1bf.js} +1 -1
- package/dist/{chunk-lang-shell-4pxt7hf4.js → chunk-lang-shell-egsvk8rj.js} +1 -1
- package/dist/{chunk-lang-sql-kgcbh2a9.js → chunk-lang-sql-75j3denr.js} +2 -2
- package/dist/{chunk-lang-toml-99t95pab.js → chunk-lang-toml-7dbjvhex.js} +1 -1
- package/dist/chunk-lang-typescript-1rv9vdcz.js +1 -0
- package/dist/{chunk-lang-xml-mnbv9yfa.js → chunk-lang-xml-jg1sv4h2.js} +1 -1
- package/dist/{chunk-lang-yaml-2by9g1dy.js → chunk-lang-yaml-g3v7s5je.js} +1 -1
- package/dist/chunk-layout-actions-6assr93n.js +1 -0
- package/dist/chunk-menu-items-9szcza00.js +2 -0
- package/dist/chunk-mode-toggle-bzbq7ycq.js +1 -0
- package/dist/{chunk-note-row-72n6cqyk.js → chunk-note-row-g20h11pm.js} +2 -2
- package/dist/chunk-notes-gc8bssxn.js +1 -0
- package/dist/chunk-notice-bell-jehad6sx.js +1 -0
- package/dist/{chunk-notices-evny44be.js → chunk-notices-prqkv7ge.js} +1 -1
- package/dist/chunk-onboarding-mdtc2mb7.js +1 -0
- package/dist/{chunk-overview-42h45ehd.js → chunk-overview-2j1s6kqg.js} +1 -1
- package/dist/chunk-palette-4qt6ewem.js +1 -0
- package/dist/chunk-placement-items-2eect825.js +1 -0
- package/dist/{chunk-profile-bqcgkgk4.js → chunk-profile-pfzyc04p.js} +1 -1
- package/dist/chunk-prompt-history-2bcp2rky.js +1 -0
- package/dist/chunk-prompts-052mb05y.js +1 -0
- package/dist/chunk-room-confirms-asvmjh5s.js +1 -0
- package/dist/{chunk-room-menu-7s0feajw.js → chunk-room-menu-dm2r2hk6.js} +1 -1
- package/dist/chunk-rooms-menu-button-32hemzxc.js +1 -0
- package/dist/{chunk-schedules-zba7krac.js → chunk-schedules-64h9gfwn.js} +1 -1
- package/dist/{chunk-seat-menu-ca5p4e9q.js → chunk-seat-menu-vrpc40v9.js} +1 -1
- package/dist/chunk-sheet-hosts-jaqx490x.js +1 -0
- package/dist/chunk-shortcut-help-bdbkdcs9.js +26 -0
- package/dist/chunk-shortcuts-qft33r8t.js +1 -0
- package/dist/{chunk-skill-editor-n0y9pd90.js → chunk-skill-editor-z3dx2895.js} +2 -2
- package/dist/{chunk-skills-ea4vb2s4.js → chunk-skills-4jfcv39n.js} +1 -1
- package/dist/chunk-switcher-list-xysjd4tw.js +1 -0
- package/dist/{chunk-tab-dot-4tkpxqeh.js → chunk-tab-dot-1p68ybf8.js} +1 -1
- package/dist/chunk-table-0v4q4dx3.js +1 -0
- package/dist/{chunk-table-seats-qeytqe0m.js → chunk-table-seats-f683hx8k.js} +1 -1
- package/dist/{chunk-table2d-18y029k9.js → chunk-table2d-1a6atjhj.js} +1 -1
- package/dist/{chunk-table3d-q2s31ae0.js → chunk-table3d-k0ffeffj.js} +23 -23
- package/dist/chunk-thread-actions-4rpfg4fq.js +1 -0
- package/dist/chunk-thread-cards-t794fp4d.js +1 -0
- package/dist/chunk-thread-list-1pcygpka.js +1 -0
- package/dist/chunk-transcript-km4e3aey.js +1 -0
- package/dist/chunk-where-phjwqggy.js +1 -0
- package/dist/{chunk-workspace-h0p32ygy.js → chunk-workspace-d064v56e.js} +2 -2
- package/dist/chunk-zh-tw-qf18hcxc.js +1 -0
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/src/api-types.ts +22 -0
- package/src/app/routes.ts +105 -2
- package/src/app/threads.ts +11 -0
- package/src/host/host-app.ts +15 -1
- package/src/host/read-all.ts +80 -0
- package/src/host/reads.ts +67 -0
- package/src/i18n/zh-tw.ts +18 -4
- package/dist/chunk-account-nhpd9j90.js +0 -1
- package/dist/chunk-agent-d1xfrawq.js +0 -1
- package/dist/chunk-arranged-rooms-bga8yk2v.js +0 -1
- package/dist/chunk-character-creator-k67f77w5.js +0 -1
- package/dist/chunk-confirm-wc5xraev.js +0 -1
- package/dist/chunk-folder-list-x56y26yq.js +0 -1
- package/dist/chunk-folds-3p7s2nvx.js +0 -1
- package/dist/chunk-gate-h41bv4y9.js +0 -1
- package/dist/chunk-group-scene-7eb6jyev.js +0 -1
- package/dist/chunk-group-table-rca48kt0.js +0 -1
- package/dist/chunk-host-icons-x318gjqp.js +0 -1
- package/dist/chunk-host-picture-xswcakgy.js +0 -1
- package/dist/chunk-host-state-bpahvk54.js +0 -1
- package/dist/chunk-host-ui-tsbwwk38.js +0 -1
- package/dist/chunk-index-066vzexw.js +0 -2
- package/dist/chunk-index-0h4h76kw.js +0 -2
- package/dist/chunk-index-2f5nfekb.js +0 -8
- package/dist/chunk-index-31ays46f.js +0 -2
- package/dist/chunk-index-4gk88a0x.js +0 -4
- package/dist/chunk-index-4mf29sbx.js +0 -2
- package/dist/chunk-index-51n20yhb.js +0 -2
- package/dist/chunk-index-84v7j6vh.js +0 -50
- package/dist/chunk-index-8f9jer8r.js +0 -2
- package/dist/chunk-index-91z3g774.js +0 -1
- package/dist/chunk-index-9w0sar6s.js +0 -2
- package/dist/chunk-index-a768zmp6.js +0 -2
- package/dist/chunk-index-c5x70d9g.js +0 -2
- package/dist/chunk-index-cwc1vvpw.js +0 -2
- package/dist/chunk-index-d85x96q0.js +0 -2
- package/dist/chunk-index-dep2e3f3.js +0 -2
- package/dist/chunk-index-dtste2ed.js +0 -2
- package/dist/chunk-index-grkczq2c.js +0 -2
- package/dist/chunk-index-gzvkpe3e.js +0 -2
- package/dist/chunk-index-satam151.js +0 -2
- package/dist/chunk-index-th43f690.js +0 -2
- package/dist/chunk-index-ths2hxpe.js +0 -1
- package/dist/chunk-index-y4sqmenv.js +0 -2
- package/dist/chunk-index-zd76pr2k.js +0 -2
- package/dist/chunk-lang-css-fa7c0zfj.js +0 -1
- package/dist/chunk-lang-html-47mf2y0v.js +0 -1
- package/dist/chunk-lang-javascript-d32qrvxz.js +0 -1
- package/dist/chunk-lang-typescript-4k1d8z7s.js +0 -1
- package/dist/chunk-layout-actions-cgghzj1w.js +0 -1
- package/dist/chunk-menu-items-24cfwawa.js +0 -2
- package/dist/chunk-mode-toggle-v4baz3r1.js +0 -1
- package/dist/chunk-notes-83s3tsey.js +0 -1
- package/dist/chunk-notice-bell-a4ty5h1p.js +0 -1
- package/dist/chunk-onboarding-q1avjbrx.js +0 -1
- package/dist/chunk-palette-e44qepmh.js +0 -1
- package/dist/chunk-placement-items-v466t0sv.js +0 -1
- package/dist/chunk-prompt-history-hgbtcn4b.js +0 -1
- package/dist/chunk-prompts-czs8y6r1.js +0 -1
- package/dist/chunk-room-confirms-h8cdj3ng.js +0 -1
- package/dist/chunk-rooms-menu-button-gawqvpsr.js +0 -1
- package/dist/chunk-sheet-hosts-ssbz6hf2.js +0 -1
- package/dist/chunk-switcher-list-pj5csqr9.js +0 -1
- package/dist/chunk-table-j8nmtdnn.js +0 -1
- package/dist/chunk-thread-actions-w3eadnh7.js +0 -1
- package/dist/chunk-thread-cards-fbpky3c9.js +0 -1
- package/dist/chunk-thread-list-pghe84be.js +0 -1
- package/dist/chunk-transcript-eqzxgqys.js +0 -1
- package/dist/chunk-where-ygyr4jdj.js +0 -1
- package/dist/chunk-zh-tw-k6xx1hp2.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{gr}from"./chunk-index-84v7j6vh.js";import{wn,Tt,rs,Ut,Jt,yi,Vt,Pt,ar,ss,ht,os,kn,as,ls,bi,cs,us,lr,ds,fs,hs,ps,cr,en,tn,Qt,ms,Kn,vi,gs,xi,Os,ys}from"./chunk-index-datrrs6b.js";import{Mt,qt}from"./chunk-index-31ays46f.js";var pc="186";var mc=0,Za=1,gc=2;var Ys=1,_c=2,Es=3,As=0,Wt=1,cn=2,On=0,Cn=1,ei=2,Ja=3,$a=4,xc=5;var Cs=100,vc=101,yc=102,Sc=103,Mc=104,bc=200,Tc=201,wc=202,Ec=203,Ac=204,Cc=205,Rc=206,Ic=207,Pc=208,Lc=209,Nc=210,Dc=211,Uc=212,Fc=213,Oc=214,Bc=0,zc=1,kc=2,Ka=3,Gc=4,Hc=5,Vc=6,Wc=7,Xc=0,qc=1,Yc=2,Rn=0,Qa=1,ja=2,eo=3,to=4,no=5,io=6,so=7;var Rs=301,Ii=302,Hr=303,Vr=304,Zs=306,Js=1000,Bn=1001,Zc=1002,In=1003,Jc=1004;var $s=1005;var sn=1006,Wr=1007;var Pi=1008;var fn=1009,$c=1010,Kc=1011,Ks=1012,ro=1013,mi=1014,ti=1015,zn=1016,ao=1017,oo=1018,Is=1020,Qc=35902,jc=35899,eh=1021,th=1022,Gn=1023,Li=1026,Ni=1027,Xr=1028,lo=1029,Di=1030,co=1031;var ho=1033,qr=33776,Yr=33777,Zr=33778,Jr=33779,uo=35840,fo=35841,po=35842,mo=35843,go=36196,_o=37492,xo=37496,vo=37488,yo=37489,$r=37490,So=37491,Mo=37808,bo=37809,To=37810,wo=37811,Eo=37812,Ao=37813,Co=37814,Ro=37815,Io=37816,Po=37817,Lo=37818,No=37819,Do=37820,Uo=37821,Fo=36492,Oo=36494,Bo=36495,zo=36283,ko=36284,Kr=36285,Go=36286;var Ho=0,nh=1,Ui="",gi="srgb",Vo="srgb-linear",Wo="linear",_t="srgb";var ih=512,sh=513,rh=514,Qr=515,ah=516,oh=517,jr=518,lh=519;var Xo="300 es",qo=2000;function Pu(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Lu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ws(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ch(){let e=Ws("canvas");return e.style.display="block",e}var Vl={},ws=null;function Xs(...e){let t="THREE."+e.shift();if(ws)ws("log",t,...e);else console.log(t,...e)}function hh(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Oe(...e){e=hh(e);let t="THREE."+e.shift();if(ws)ws("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=hh(e);let t="THREE."+e.shift();if(ws)ws("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Ri(...e){let t=e.join(" ");if(t in Vl)return;Vl[t]=!0,Oe(...e)}function uh(e,t,n){return new Promise(function(i,s){function r(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:s();break;case e.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:i()}}setTimeout(r,n)})}var dh={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ni{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let s=i.indexOf(t);if(s!==-1)i.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,e);e.target=null}}}var 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"];var ba=Math.PI/180,Gr=180/Math.PI;function fi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(jt[e&255]+jt[e>>8&255]+jt[e>>16&255]+jt[e>>24&255]+"-"+jt[t&255]+jt[t>>8&255]+"-"+jt[t>>16&15|64]+jt[t>>24&255]+"-"+jt[n&63|128]+jt[n>>8&255]+"-"+jt[n>>16&255]+jt[n>>24&255]+jt[i&255]+jt[i>>8&255]+jt[i>>16&255]+jt[i>>24&255]).toLowerCase()}function tt(e,t,n){return Math.max(t,Math.min(n,e))}function Nu(e,t){return(e%t+t)%t}function Ta(e,t,n){return(1-n)*e+n*t}function Fn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function pt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}class ze{static{ze.prototype.isVector2=!0}constructor(e=0,t=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 Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: 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){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(tt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ii{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,r,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],d=s[r+0],h=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||o!==d||l!==h||c!==p){let T=o*d+l*h+c*p+u*v;if(T<0)d=-d,h=-h,p=-p,v=-v,T=-T;let m=1-a;if(T<0.9995){let f=Math.acos(T),E=Math.sin(f);m=Math.sin(m*f)/E,a=Math.sin(a*f)/E,o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a}else{o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a;let f=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=f,l*=f,c*=f,u*=f}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,r){let a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=s[r],d=s[r+1],h=s[r+2],p=s[r+3];return e[t]=a*p+c*u+o*h-l*d,e[t+1]=o*p+c*d+l*u-a*h,e[t+2]=l*p+c*h+a*d-o*u,e[t+3]=c*p-a*u-o*d-l*h,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){let{_x:n,_y:i,_z:s,_order:r}=e,{cos:a,sin:o}=Math,l=a(n/2),c=a(i/2),u=a(s/2),d=o(n/2),h=o(i/2),p=o(s/2);switch(r){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:Oe("Quaternion: .setFromEuler() encountered an unknown order: "+r)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],a=t[5],o=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(c-o)*h,this._y=(s-l)*h,this._z=(r-i)*h}else if(n>a&&n>u){let h=2*Math.sqrt(1+n-a-u);this._w=(c-o)/h,this._x=0.25*h,this._y=(i+r)/h,this._z=(s+l)/h}else if(a>u){let h=2*Math.sqrt(1+a-n-u);this._w=(s-l)/h,this._x=(i+r)/h,this._y=0.25*h,this._z=(o+c)/h}else{let h=2*Math.sqrt(1+u-n-a);this._w=(r-i)/h,this._x=(s+l)/h,this._y=(o+c)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(tt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:s,_w:r}=e,{_x:a,_y:o,_z:l,_w:c}=t;return this._x=n*c+r*a+i*l-s*o,this._y=i*c+r*o+s*a-n*l,this._z=s*c+r*l+n*o-i*a,this._w=r*c-n*a-i*o-s*l,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:s,_w:r}=e,a=this.dot(e);if(a<0)n=-n,i=-i,s=-s,r=-r,a=-a;let o=1-t;if(a<0.9995){let l=Math.acos(a),c=Math.sin(l);o=Math.sin(o*l)/c,t=Math.sin(t*l)/c,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+r*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let 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 O{static{O.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return 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 Error("THREE.Vector3: 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 Error("THREE.Vector3: 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(Wl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wl.setFromAxisAngle(e,t))}applyMatrix3(e){let 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){let t=this.x,n=this.y,i=this.z,s=e.elements,r=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])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:s,y:r,z:a,w:o}=e,l=2*(r*i-a*n),c=2*(a*t-s*i),u=2*(s*n-r*t);return this.x=t+o*l+r*u-a*c,this.y=n+o*c+a*l-s*u,this.z=i+o*u+s*c-r*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this.z=tt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this.z=tt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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){let{x:n,y:i,z:s}=e,{x:r,y:a,z:o}=t;return this.x=i*o-s*a,this.y=s*r-n*o,this.z=n*a-i*r,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return wa.copy(this).projectOnVector(e),this.sub(wa)}reflect(e){return this.sub(wa.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(tt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let 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(){let 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}}var wa=new O,Wl=new ii;class ke{static{ke.prototype.isMatrix3=!0}constructor(e,t,n,i,s,r,a,o,l){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,s,r,a,o,l)}set(e,t,n,i,s,r,a,o,l){let c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=o,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],v=i[0],T=i[3],m=i[6],f=i[1],E=i[4],C=i[7],y=i[2],b=i[5],w=i[8];return s[0]=r*v+a*f+o*y,s[3]=r*T+a*E+o*b,s[6]=r*m+a*C+o*w,s[1]=l*v+c*f+u*y,s[4]=l*T+c*E+u*b,s[7]=l*m+c*C+u*w,s[2]=d*v+h*f+p*y,s[5]=d*T+h*E+p*b,s[8]=d*m+h*C+p*w,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*r*c-t*a*l-n*s*c+n*a*o+i*s*l-i*r*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=c*r-a*l,d=a*o-c*s,h=l*s-r*o,p=t*u+n*d+i*h;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/p;return e[0]=u*v,e[1]=(i*l-c*n)*v,e[2]=(a*n-i*r)*v,e[3]=d*v,e[4]=(c*t-i*o)*v,e[5]=(i*s-a*t)*v,e[6]=h*v,e[7]=(n*o-l*t)*v,e[8]=(r*t-n*s)*v,this}transpose(){let e,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){let 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,r,a){let o=Math.cos(s),l=Math.sin(s);return this.set(n*o,n*l,-n*(o*r+l*a)+r+e,-i*l,i*o,-i*(-l*r+o*a)+a+t,0,0,1),this}scale(e,t){return Ri("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ea.makeScale(e,t)),this}rotate(e){return Ri("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ea.makeRotation(-e)),this}translate(e,t){return Ri("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ea.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let 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){let 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){let 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)}}var Ea=new ke,Xl=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),ql=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Du(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(s,r,a){if(this.enabled===!1||r===a||!r||!a)return s;if(this.spaces[r].transfer==="srgb")s.r=jn(s.r),s.g=jn(s.g),s.b=jn(s.b);if(this.spaces[r].primaries!==this.spaces[a].primaries)s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")s.r=Ts(s.r),s.g=Ts(s.g),s.b=Ts(s.b);return s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){if(s==="")return"linear";return this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ri("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ri("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(s,r)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Xl,fromXYZ:ql,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Xl,fromXYZ:ql,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Du();function jn(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Ts(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Yi;class Yo{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(Yi===void 0)Yi=Ws("canvas");Yi.width=e.width,Yi.height=e.height;let i=Yi.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Yi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Ws("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=jn(s[r]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(jn(t[n]/255)*255);else t[n]=jn(t[n]);return{data:t,width:e.width,height:e.height}}else return Oe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Uu=0;class Qs{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Uu++}),this.uuid=fi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,a=i.length;r<a;r++)if(i[r].isDataTexture)s.push(Aa(i[r].image));else s.push(Aa(i[r]))}else s=Aa(i);n.url=s}if(!t)e.images[this.uuid]=n;return n}}function Aa(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Yo.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Oe("Texture: Unable to serialize Texture."),{}}var Fu=0,Ca=new O;class Zt extends ni{constructor(e=Zt.DEFAULT_IMAGE,t=Zt.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=Zt.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Fu++}),this.uuid=fi(),this.name="",this.source=new Qs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ze(0,0),this.repeat=new ze(1,1),this.center=new ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ca).x}get height(){return this.source.getSize(Ca).y}get depth(){return this.source.getSize(Ca).z}get image(){return this.source.data}set image(e){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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.normalized=e.normalized,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.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Oe(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Zt.DEFAULT_IMAGE=null;Zt.DEFAULT_MAPPING=300;Zt.DEFAULT_ANISOTROPY=1;class Et{static{Et.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){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 Error("THREE.Vector4: 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 Error("THREE.Vector4: 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){let t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[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);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,r=0.01,a=0.1,o=e.elements,l=o[0],c=o[4],u=o[8],d=o[1],h=o[5],p=o[9],v=o[2],T=o[6],m=o[10];if(Math.abs(c-d)<0.01&&Math.abs(u-v)<0.01&&Math.abs(p-T)<0.01){if(Math.abs(c+d)<0.1&&Math.abs(u+v)<0.1&&Math.abs(p+T)<0.1&&Math.abs(l+h+m-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(l+1)/2,C=(h+1)/2,y=(m+1)/2,b=(c+d)/4,w=(u+v)/4,A=(p+T)/4;if(E>C&&E>y)if(E<0.01)n=0,i=0.707106781,s=0.707106781;else n=Math.sqrt(E),i=b/n,s=w/n;else if(C>y)if(C<0.01)n=0.707106781,i=0,s=0.707106781;else i=Math.sqrt(C),n=b/i,s=A/i;else if(y<0.01)n=0.707106781,i=0.707106781,s=0;else s=Math.sqrt(y),n=w/s,i=A/s;return this.set(n,i,s,t),this}let f=Math.sqrt((T-p)*(T-p)+(u-v)*(u-v)+(d-c)*(d-c));if(Math.abs(f)<0.001)f=1;return this.x=(T-p)/f,this.y=(u-v)/f,this.z=(d-c)/f,this.w=Math.acos((l+h+m-1)/2),this}setFromMatrixPosition(e){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this.z=tt(this.z,e.z,t.z),this.w=tt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this.z=tt(this.z,e,t),this.w=tt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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 Zo extends ni{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Et(0,0,e,t),this.scissorTest=!1,this.viewport=new Et(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},s=new Zt(i),r=n.count;for(let a=0;a<r;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===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++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;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 t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Qs(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class pn extends Zo{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class ea extends Zt{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Jo extends Zt{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class yt{static{yt.prototype.isMatrix4=!0}constructor(e,t,n,i,s,r,a,o,l,c,u,d,h,p,v,T){if(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,r,a,o,l,c,u,d,h,p,v,T)}set(e,t,n,i,s,r,a,o,l,c,u,d,h,p,v,T){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=r,m[9]=a,m[13]=o,m[2]=l,m[6]=c,m[10]=u,m[14]=d,m[3]=h,m[7]=p,m[11]=v,m[15]=T,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 yt().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;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){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Zi.setFromMatrixColumn(e,0).length(),s=1/Zi.setFromMatrixColumn(e,1).length(),r=1/Zi.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]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:s}=e,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let d=r*c,h=r*u,p=a*c,v=a*u;t[0]=o*c,t[4]=-o*u,t[8]=l,t[1]=h+p*l,t[5]=d-v*l,t[9]=-a*o,t[2]=v-d*l,t[6]=p+h*l,t[10]=r*o}else if(e.order==="YXZ"){let d=o*c,h=o*u,p=l*c,v=l*u;t[0]=d+v*a,t[4]=p*a-h,t[8]=r*l,t[1]=r*u,t[5]=r*c,t[9]=-a,t[2]=h*a-p,t[6]=v+d*a,t[10]=r*o}else if(e.order==="ZXY"){let d=o*c,h=o*u,p=l*c,v=l*u;t[0]=d-v*a,t[4]=-r*u,t[8]=p+h*a,t[1]=h+p*a,t[5]=r*c,t[9]=v-d*a,t[2]=-r*l,t[6]=a,t[10]=r*o}else if(e.order==="ZYX"){let d=r*c,h=r*u,p=a*c,v=a*u;t[0]=o*c,t[4]=p*l-h,t[8]=d*l+v,t[1]=o*u,t[5]=v*l+d,t[9]=h*l-p,t[2]=-l,t[6]=a*o,t[10]=r*o}else if(e.order==="YZX"){let d=r*o,h=r*l,p=a*o,v=a*l;t[0]=o*c,t[4]=v-d*u,t[8]=p*u+h,t[1]=u,t[5]=r*c,t[9]=-a*c,t[2]=-l*c,t[6]=h*u+p,t[10]=d-v*u}else if(e.order==="XZY"){let d=r*o,h=r*l,p=a*o,v=a*l;t[0]=o*c,t[4]=-u,t[8]=l*c,t[1]=d*u+v,t[5]=r*c,t[9]=h*u-p,t[2]=p*u-h,t[6]=a*c,t[10]=v*u+d}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(Ou,e,Bu)}lookAt(e,t,n){let i=this.elements;if(hn.subVectors(e,t),hn.lengthSq()===0)hn.z=1;if(hn.normalize(),li.crossVectors(n,hn),li.lengthSq()===0){if(Math.abs(n.z)===1)hn.x+=0.0001;else hn.z+=0.0001;hn.normalize(),li.crossVectors(n,hn)}return li.normalize(),vr.crossVectors(hn,li),i[0]=li.x,i[4]=vr.x,i[8]=hn.x,i[1]=li.y,i[5]=vr.y,i[9]=hn.y,i[2]=li.z,i[6]=vr.z,i[10]=hn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],v=n[6],T=n[10],m=n[14],f=n[3],E=n[7],C=n[11],y=n[15],b=i[0],w=i[4],A=i[8],_=i[12],M=i[1],B=i[5],R=i[9],U=i[13],W=i[2],P=i[6],H=i[10],j=i[14],G=i[3],re=i[7],q=i[11],te=i[15];return s[0]=r*b+a*M+o*W+l*G,s[4]=r*w+a*B+o*P+l*re,s[8]=r*A+a*R+o*H+l*q,s[12]=r*_+a*U+o*j+l*te,s[1]=c*b+u*M+d*W+h*G,s[5]=c*w+u*B+d*P+h*re,s[9]=c*A+u*R+d*H+h*q,s[13]=c*_+u*U+d*j+h*te,s[2]=p*b+v*M+T*W+m*G,s[6]=p*w+v*B+T*P+m*re,s[10]=p*A+v*R+T*H+m*q,s[14]=p*_+v*U+T*j+m*te,s[3]=f*b+E*M+C*W+y*G,s[7]=f*w+E*B+C*P+y*re,s[11]=f*A+E*R+C*H+y*q,s[15]=f*_+E*U+C*j+y*te,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],a=e[5],o=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14],p=e[3],v=e[7],T=e[11],m=e[15],f=o*h-l*d,E=a*h-l*u,C=a*d-o*u,y=r*h-l*c,b=r*d-o*c,w=r*u-a*c;return t*(v*f-T*E+m*C)-n*(p*f-T*y+m*b)+i*(p*E-v*y+m*w)-s*(p*C-v*b+T*w)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[1],r=e[5],a=e[9],o=e[2],l=e[6],c=e[10];return t*(r*c-a*l)-n*(s*c-a*o)+i*(s*l-r*o)}transpose(){let e=this.elements,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){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],v=e[13],T=e[14],m=e[15],f=t*a-n*r,E=t*o-i*r,C=t*l-s*r,y=n*o-i*a,b=n*l-s*a,w=i*l-s*o,A=c*v-u*p,_=c*T-d*p,M=c*m-h*p,B=u*T-d*v,R=u*m-h*v,U=d*m-h*T,W=f*U-E*R+C*B+y*M-b*_+w*A;if(W===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/W;return e[0]=(a*U-o*R+l*B)*P,e[1]=(i*R-n*U-s*B)*P,e[2]=(v*w-T*b+m*y)*P,e[3]=(d*b-u*w-h*y)*P,e[4]=(o*M-r*U-l*_)*P,e[5]=(t*U-i*M+s*_)*P,e[6]=(T*C-p*w-m*E)*P,e[7]=(c*w-d*C+h*E)*P,e[8]=(r*R-a*M+l*A)*P,e[9]=(n*M-t*R-s*A)*P,e[10]=(p*b-v*C+m*f)*P,e[11]=(u*C-c*b-h*f)*P,e[12]=(a*_-r*B-o*A)*P,e[13]=(t*B-n*_+i*A)*P,e[14]=(v*E-p*y-T*f)*P,e[15]=(c*y-u*E+d*f)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:s}=e;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(){let 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){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let 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){let 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){let 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){let n=Math.cos(t),i=Math.sin(t),s=1-n,{x:r,y:a,z:o}=e,l=s*r,c=s*a;return this.set(l*r+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*r,0,l*o-i*a,c*o+i*r,s*o*o+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,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:s,_y:r,_z:a,_w:o}=t,l=s+s,c=r+r,u=a+a,d=s*l,h=s*c,p=s*u,v=r*c,T=r*u,m=a*u,f=o*l,E=o*c,C=o*u,{x:y,y:b,z:w}=n;return i[0]=(1-(v+m))*y,i[1]=(h+C)*y,i[2]=(p-E)*y,i[3]=0,i[4]=(h-C)*b,i[5]=(1-(d+m))*b,i[6]=(T+f)*b,i[7]=0,i[8]=(p+E)*w,i[9]=(T-f)*w,i[10]=(1-(d+v))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let r=Zi.set(i[0],i[1],i[2]).length(),a=Zi.set(i[4],i[5],i[6]).length(),o=Zi.set(i[8],i[9],i[10]).length();if(s<0)r=-r;Tn.copy(this);let l=1/r,c=1/a,u=1/o;return Tn.elements[0]*=l,Tn.elements[1]*=l,Tn.elements[2]*=l,Tn.elements[4]*=c,Tn.elements[5]*=c,Tn.elements[6]*=c,Tn.elements[8]*=u,Tn.elements[9]*=u,Tn.elements[10]*=u,t.setFromRotationMatrix(Tn),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2*s/(t-e),u=2*s/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),p,v;if(o)p=s/(r-s),v=r*s/(r-s);else if(a===2000)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(a===2001)p=-r/(r-s),v=-r*s/(r-s);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),p,v;if(o)p=1/(r-s),v=r/(r-s);else if(a===2000)p=-2/(r-s),v=-(r+s)/(r-s);else if(a===2001)p=-1/(r-s),v=-s/(r-s);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=h,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let 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){let 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}}var Zi=new O,Tn=new yt,Ou=new O(0,0,0),Bu=new O(1,1,1),li=new O,vr=new O,hn=new O,Yl=new yt,Zl=new ii;class pi{constructor(e=0,t=0,n=0,i=pi.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){let i=e.elements,s=i[0],r=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(tt(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-c,h),this._z=Math.atan2(-r,s);else this._x=Math.atan2(d,l),this._z=0;break;case"YXZ":if(this._x=Math.asin(-tt(c,-1,1)),Math.abs(c)<0.9999999)this._y=Math.atan2(a,h),this._z=Math.atan2(o,l);else this._y=Math.atan2(-u,s),this._z=0;break;case"ZXY":if(this._x=Math.asin(tt(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-r,l);else this._y=0,this._z=Math.atan2(o,s);break;case"ZYX":if(this._y=Math.asin(-tt(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(o,s);else this._x=0,this._z=Math.atan2(-r,l);break;case"YZX":if(this._z=Math.asin(tt(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,s);else this._x=0,this._y=Math.atan2(a,h);break;case"XZY":if(this._z=Math.asin(-tt(r,-1,1)),Math.abs(r)<0.9999999)this._x=Math.atan2(d,l),this._y=Math.atan2(a,s);else this._x=Math.atan2(-c,h),this._y=0;break;default:Oe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Yl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zl.setFromEuler(this),this.setFromQuaternion(Zl,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}pi.DEFAULT_ORDER="XYZ";class js{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}}var zu=0,Jl=new O,Ji=new ii,Yn=new yt,yr=new O,Fs=new O,ku=new O,Gu=new ii,$l=new O(1,0,0),Kl=new O(0,1,0),Ql=new O(0,0,1),jl={type:"added"},Hu={type:"removed"},$i={type:"childadded",child:null},Ra={type:"childremoved",child:null};class Ht extends ni{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:zu++}),this.uuid=fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ht.DEFAULT_UP.clone();let e=new O,t=new pi,n=new ii,i=new O(1,1,1);function s(){n.setFromEuler(t,!1)}function r(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(r),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 yt},normalMatrix:{value:new ke}}),this.matrix=new yt,this.matrixWorld=new yt,this.matrixAutoUpdate=Ht.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new js,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(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 Ji.setFromAxisAngle(e,t),this.quaternion.multiply(Ji),this}rotateOnWorldAxis(e,t){return Ji.setFromAxisAngle(e,t),this.quaternion.premultiply(Ji),this}rotateX(e){return this.rotateOnAxis($l,e)}rotateY(e){return this.rotateOnAxis(Kl,e)}rotateZ(e){return this.rotateOnAxis(Ql,e)}translateOnAxis(e,t){return Jl.copy(e).applyQuaternion(this.quaternion),this.position.add(Jl.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($l,e)}translateY(e){return this.translateOnAxis(Kl,e)}translateZ(e){return this.translateOnAxis(Ql,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Yn.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)yr.copy(e);else yr.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Fs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Yn.lookAt(Fs,yr,this.up);else Yn.lookAt(yr,Fs,this.up);if(this.quaternion.setFromRotationMatrix(Yn),i)Yn.extractRotation(i.matrixWorld),Ji.setFromRotationMatrix(Yn),this.quaternion.premultiply(Ji.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(jl),$i.child=e,this.dispatchEvent($i),$i.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Hu),Ra.child=e,this.dispatchEvent(Ra),Ra.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Yn.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Yn.multiply(e.parent.matrixWorld);return e.applyMatrix4(Yn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(jl),$i.child=e,this.dispatchEvent($i),$i.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++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;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(Fs,e,ku),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fs,Gu,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let 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);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*i,s[13]+=n-s[1]*t-s[5]*n-s[9]*i,s[14]+=i-s[2]*t-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function s(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(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);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let l=0,c=o.length;l<c;l++){let u=o[l];s(e.shapes,u)}else s(e.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,l=this.material.length;o<l;o++)a.push(s(e.materials,this.material[o]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(s(e.animations,o))}}if(t){let a=r(e.geometries),o=r(e.materials),l=r(e.textures),c=r(e.images),u=r(e.shapes),d=r(e.skeletons),h=r(e.animations),p=r(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(l.length>0)n.textures=l;if(c.length>0)n.images=c;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(p.length>0)n.nodes=p}return n.object=i,n;function r(a){let o=[];for(let l in a){let c=a[l];delete c.metadata,o.push(c)}return o}}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.pivot=e.pivot!==null?e.pivot.clone():null,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}Ht.DEFAULT_UP=new O(0,1,0);Ht.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Yt extends Ht{constructor(){super();this.isGroup=!0,this.type="Group"}}var Vu={type:"move"};class er{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Yt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new Yt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new Yt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,s=null,r=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(let v of e.hand.values()){let T=t.getJointPose(v,n),m=this._getHandJoint(l,v);if(T!==null)m.matrix.fromArray(T.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=T.radius;m.visible=T!==null}let c=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=c.position.distanceTo(u.position),h=0.02,p=0.005;if(l.inputState.pinching&&d>h+p)l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!l.inputState.pinching&&d<=h-p)l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(s=t.getPose(e.gripSpace,n),s!==null){if(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity);else o.hasLinearVelocity=!1;if(s.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null)i=s;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(Vu)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=s!==null;if(l!==null)l.visible=r!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Yt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var fh={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},ci={h:0,s:0,l:0},Sr={h:0,s:0,l:0};function Ia(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class We{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){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(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="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=Nu(e,1),t=tt(t,0,1),n=tt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=0.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=Ia(r,s,e+0.3333333333333333),this.g=Ia(r,s,e),this.b=Ia(r,s,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(s){if(s===void 0)return;if(parseFloat(s)<1)Oe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Oe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);else if(r===6)return this.setHex(parseInt(s,16),t);else Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=fh[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Oe("Color: Unknown color "+e);return 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=jn(e.r),this.g=jn(e.g),this.b=jn(e.b),this}copyLinearToSRGB(e){return this.r=Ts(e.r),this.g=Ts(e.g),this.b=Ts(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(nn.copy(this),e),Math.round(tt(nn.r*255,0,255))*65536+Math.round(tt(nn.g*255,0,255))*256+Math.round(tt(nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(nn.copy(this),t);let{r:n,g:i,b:s}=nn,r=Math.max(n,i,s),a=Math.min(n,i,s),o,l,c=(a+r)/2;if(a===r)o=0,l=0;else{let u=r-a;switch(l=c<=0.5?u/(r+a):u/(2-r-a),r){case n:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-n)/u+2;break;case s:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=l,e.l=c,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(nn.copy(this),t),e.r=nn.r,e.g=nn.g,e.b=nn.b,e}getStyle(e="srgb"){je.workingToColorSpace(nn.copy(this),e);let{r:t,g:n,b:i}=nn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ci),this.setHSL(ci.h+e,ci.s+t,ci.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(ci),e.getHSL(Sr);let n=Ta(ci.h,Sr.h,t),i=Ta(ci.s,Sr.s,t),s=Ta(ci.l,Sr.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){let 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}}var nn=new We;We.NAMES=fh;class tr{constructor(e,t=1,n=1000){this.isFog=!0,this.name="",this.color=new We(e),this.near=t,this.far=n}clone(){return new tr(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ta extends Ht{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new pi,this.environmentIntensity=1,this.environmentRotation=new pi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(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();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var En=new O,Zn=new O,Pa=new O,Jn=new O,Ki=new O,Qi=new O,ec=new O,La=new O,Na=new O,Da=new O,Ua=new Et,Fa=new Et,Oa=new Et;class dn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),En.subVectors(e,t),i.cross(En);let s=i.lengthSq();if(s>0)return i.multiplyScalar(1/Math.sqrt(s));return i.set(0,0,0)}static getBarycoord(e,t,n,i,s){En.subVectors(i,t),Zn.subVectors(n,t),Pa.subVectors(e,t);let r=En.dot(En),a=En.dot(Zn),o=En.dot(Pa),l=Zn.dot(Zn),c=Zn.dot(Pa),u=r*l-a*a;if(u===0)return s.set(0,0,0),null;let d=1/u,h=(l*o-a*c)*d,p=(r*c-a*o)*d;return s.set(1-h-p,p,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Jn)===null)return!1;return Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(e,t,n,i,s,r,a,o){if(this.getBarycoord(e,t,n,i,Jn)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(s,Jn.x),o.addScaledVector(r,Jn.y),o.addScaledVector(a,Jn.z),o}static getInterpolatedAttribute(e,t,n,i,s,r){return Ua.setScalar(0),Fa.setScalar(0),Oa.setScalar(0),Ua.fromBufferAttribute(e,t),Fa.fromBufferAttribute(e,n),Oa.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(Ua,s.x),r.addScaledVector(Fa,s.y),r.addScaledVector(Oa,s.z),r}static isFrontFacing(e,t,n,i){return En.subVectors(n,t),Zn.subVectors(e,t),En.cross(Zn).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 En.subVectors(this.c,this.b),Zn.subVectors(this.a,this.b),En.cross(Zn).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return dn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return dn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return dn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,r,a;Ki.subVectors(i,n),Qi.subVectors(s,n),La.subVectors(e,n);let o=Ki.dot(La),l=Qi.dot(La);if(o<=0&&l<=0)return t.copy(n);Na.subVectors(e,i);let c=Ki.dot(Na),u=Qi.dot(Na);if(c>=0&&u<=c)return t.copy(i);let d=o*u-c*l;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),t.copy(n).addScaledVector(Ki,r);Da.subVectors(e,s);let h=Ki.dot(Da),p=Qi.dot(Da);if(p>=0&&h<=p)return t.copy(s);let v=h*l-o*p;if(v<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Qi,a);let T=c*p-h*u;if(T<=0&&u-c>=0&&h-p>=0)return ec.subVectors(s,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(ec,a);let m=1/(T+v+d);return r=v*m,a=d*m,t.copy(n).addScaledVector(Ki,r).addScaledVector(Qi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Fi{constructor(e=new O(1/0,1/0,1/0),t=new O(-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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(An.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){let n=An.copy(t).multiplyScalar(0.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(0.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);let n=e.geometry;if(n!==void 0){let s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let r=0,a=s.count;r<a;r++){if(e.isMesh===!0)e.getVertexPosition(r,An);else An.fromBufferAttribute(s,r);An.applyMatrix4(e.matrixWorld),this.expandByPoint(An)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Mr.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Mr.copy(n.boundingBox)}Mr.applyMatrix4(e.matrixWorld),this.union(Mr)}}let i=e.children;for(let s=0,r=i.length;s<r;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,An),An.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bs),br.subVectors(this.max,Bs),ji.subVectors(e.a,Bs),es.subVectors(e.b,Bs),ts.subVectors(e.c,Bs),hi.subVectors(es,ji),ui.subVectors(ts,es),wi.subVectors(ji,ts);let t=[0,-hi.z,hi.y,0,-ui.z,ui.y,0,-wi.z,wi.y,hi.z,0,-hi.x,ui.z,0,-ui.x,wi.z,0,-wi.x,-hi.y,hi.x,0,-ui.y,ui.x,0,-wi.y,wi.x,0];if(!Ba(t,ji,es,ts,br))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Ba(t,ji,es,ts,br))return!1;return Tr.crossVectors(hi,ui),t=[Tr.x,Tr.y,Tr.z],Ba(t,ji,es,ts,br)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(An).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return $n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($n),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var $n=[new O,new O,new O,new O,new O,new O,new O,new O],An=new O,Mr=new Fi,ji=new O,es=new O,ts=new O,hi=new O,ui=new O,wi=new O,Bs=new O,br=new O,Tr=new O,Ei=new O;function Ba(e,t,n,i,s){for(let r=0,a=e.length-3;r<=a;r+=3){Ei.fromArray(e,r);let o=s.x*Math.abs(Ei.x)+s.y*Math.abs(Ei.y)+s.z*Math.abs(Ei.z),l=t.dot(Ei),c=n.dot(Ei),u=i.dot(Ei);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}var Dt=new O,wr=new ze,Wu=0;class yn extends ni{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Wu++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(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++)wr.fromBufferAttribute(this,t),wr.applyMatrix3(e),this.setXY(t,wr.x,wr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix3(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix4(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyNormalMatrix(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.transformDirection(e),this.setXYZ(t,Dt.x,Dt.y,Dt.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];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=pt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Fn(t,this.array);return t}setX(e,t){if(this.normalized)t=pt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Fn(t,this.array);return t}setY(e,t){if(this.normalized)t=pt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Fn(t,this.array);return t}setZ(e,t){if(this.normalized)t=pt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Fn(t,this.array);return t}setW(e,t){if(this.normalized)t=pt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=pt(t,this.array),n=pt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=pt(t,this.array),n=pt(n,this.array),i=pt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){if(e*=this.itemSize,this.normalized)t=pt(t,this.array),n=pt(n,this.array),i=pt(i,this.array),s=pt(s,this.array);return 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(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class na extends yn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ia extends yn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $t extends yn{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Xu=new Fi,zs=new O,za=new O;class nr{constructor(e=new O,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){let n=this.center;if(t!==void 0)n.copy(t);else Xu.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;s<r;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){let 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){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;zs.subVectors(e,this.center);let t=zs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(zs,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else za.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zs.copy(e.center).add(za)),this.expandByPoint(zs.copy(e.center).sub(za));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var qu=0,vn=new yt,ka=new Ht,ns=new O,un=new Fi,ks=new Fi,Gt=new O;class mn extends ni{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qu++}),this.uuid=fi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((Pu(e))?ia:na)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,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){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let s=new ke().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return vn.makeRotationFromQuaternion(e),this.applyMatrix4(vn),this}rotateX(e){return vn.makeRotationX(e),this.applyMatrix4(vn),this}rotateY(e){return vn.makeRotationY(e),this.applyMatrix4(vn),this}rotateZ(e){return vn.makeRotationZ(e),this.applyMatrix4(vn),this}translate(e,t,n){return vn.makeTranslation(e,t,n),this.applyMatrix4(vn),this}scale(e,t,n){return vn.makeScale(e,t,n),this.applyMatrix4(vn),this}lookAt(e){return ka.lookAt(e),ka.updateMatrix(),this.applyMatrix4(ka.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ns).negate(),this.translate(ns.x,ns.y,ns.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,s=e.length;i<s;i++){let r=e[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new $t(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}if(e.length>t.count)Oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Fi;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(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++){let s=t[n];if(un.setFromBufferAttribute(s),this.morphTargetsRelative)Gt.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(Gt);else this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new nr;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(un.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){let a=t[s];if(ks.setFromBufferAttribute(a),this.morphTargetsRelative)Gt.addVectors(un.min,ks.min),un.expandByPoint(Gt),Gt.addVectors(un.max,ks.max),un.expandByPoint(Gt);else un.expandByPoint(ks.min),un.expandByPoint(ks.max)}un.getCenter(n);let i=0;for(let s=0,r=e.count;s<r;s++)Gt.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let s=0,r=t.length;s<r;s++){let a=t[s],o=this.morphTargetsRelative;for(let l=0,c=a.count;l<c;l++){if(Gt.fromBufferAttribute(a,l),o)ns.fromBufferAttribute(e,l),Gt.add(ns);i=Math.max(i,n.distanceToSquared(Gt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:s}=t,r=this.getAttribute("tangent");if(r===void 0||r.count!==n.count)r=new yn(new Float32Array(4*n.count),4),this.setAttribute("tangent",r);let a=[],o=[];for(let A=0;A<n.count;A++)a[A]=new O,o[A]=new O;let l=new O,c=new O,u=new O,d=new ze,h=new ze,p=new ze,v=new O,T=new O;function m(A,_,M){l.fromBufferAttribute(n,A),c.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,A),h.fromBufferAttribute(s,_),p.fromBufferAttribute(s,M),c.sub(l),u.sub(l),h.sub(d),p.sub(d);let B=1/(h.x*p.y-p.x*h.y);if(!isFinite(B))return;v.copy(c).multiplyScalar(p.y).addScaledVector(u,-h.y).multiplyScalar(B),T.copy(u).multiplyScalar(h.x).addScaledVector(c,-p.x).multiplyScalar(B),a[A].add(v),a[_].add(v),a[M].add(v),o[A].add(T),o[_].add(T),o[M].add(T)}let f=this.groups;if(f.length===0)f=[{start:0,count:e.count}];for(let A=0,_=f.length;A<_;++A){let M=f[A],{start:B,count:R}=M;for(let U=B,W=B+R;U<W;U+=3)m(e.getX(U+0),e.getX(U+1),e.getX(U+2))}let E=new O,C=new O,y=new O,b=new O;function w(A){y.fromBufferAttribute(i,A),b.copy(y);let _=a[A];E.copy(_),E.sub(y.multiplyScalar(y.dot(_))).normalize(),C.crossVectors(b,_);let B=C.dot(o[A])<0?-1:1;r.setXYZW(A,E.x,E.y,E.z,B)}for(let A=0,_=f.length;A<_;++A){let M=f[A],{start:B,count:R}=M;for(let U=B,W=B+R;U<W;U+=3)w(e.getX(U+0)),w(e.getX(U+1)),w(e.getX(U+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new yn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new O,s=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O;if(e)for(let d=0,h=e.count;d<h;d+=3){let p=e.getX(d+0),v=e.getX(d+1),T=e.getX(d+2);i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),r.fromBufferAttribute(t,T),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,T),a.add(c),o.add(c),l.add(c),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(T,l.x,l.y,l.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),r.fromBufferAttribute(t,d+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(a,o){let{array:l,itemSize:c,normalized:u}=a,d=new l.constructor(o.length*c),h=0,p=0;for(let v=0,T=o.length;v<T;v++){if(a.isInterleavedBufferAttribute)h=o[v]*a.data.stride+a.offset;else h=o[v]*c;for(let m=0;m<c;m++)d[p++]=l[h++]}return new yn(d,c,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new mn,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],l=e(o,n);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let o=[],l=s[a];for(let c=0,u=l.length;c<u;c++){let d=l[c],h=e(d,n);o.push(h)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let a=0,o=r.length;a<o;a++){let l=r[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let l in o)if(o[l]!==void 0)e[l]=o[l];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let l=n[o];e.data.attributes[o]=l.toJSON(e.data)}let i={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],c=[];for(let u=0,d=l.length;u<d;u++){let h=l[u];c.push(h.toJSON(e.data))}if(c.length>0)i[o]=c,s=!0}if(s)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;if(r.length>0)e.data.groups=JSON.parse(JSON.stringify(r));let a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.toJSON();return 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;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let l in i){let c=i[l];this.setAttribute(l,c.clone(t))}let s=e.morphAttributes;for(let l in s){let c=[],u=s[l];for(let d=0,h=u.length;d<h;d++)c.push(u[d].clone(t));this.morphAttributes[l]=c}this.morphTargetsRelative=e.morphTargetsRelative;let r=e.groups;for(let l=0,c=r.length;l<c;l++){let u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $o{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=fi()}onUploadCallback(){}set needsUpdate(e){if(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){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let 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){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var on=new O;class qs{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++)on.fromBufferAttribute(this,t),on.applyMatrix4(e),this.setXYZ(t,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)on.fromBufferAttribute(this,t),on.applyNormalMatrix(e),this.setXYZ(t,on.x,on.y,on.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)on.fromBufferAttribute(this,t),on.transformDirection(e),this.setXYZ(t,on.x,on.y,on.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=pt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=pt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=pt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=pt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=pt(t,this.array);return 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];if(this.normalized)t=Fn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Fn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Fn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Fn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=pt(t,this.array),n=pt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=pt(t,this.array),n=pt(n,this.array),i=pt(i,this.array);return 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){if(e=e*this.data.stride+this.offset,this.normalized)t=pt(t,this.array),n=pt(n,this.array),i=pt(i,this.array),s=pt(s,this.array);return 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){Xs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new yn(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new qs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Xs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let 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{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Ga=new O,Yu=new O,Zu=new ke;class Un{constructor(e=new O(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){let i=Ga.subVectors(n,t).cross(Yu.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let i=e.delta(Ga),s=this.normal.dot(i);if(s===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let r=-(e.start.dot(this.normal)+this.constant)/s;if(n===!0&&(r<0||r>1))return null;return t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){let 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){let n=t||Zu.getNormalMatrix(e),i=this.coplanarPoint(Ga).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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Ju=0;class _i extends ni{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ju++}),this.uuid=fi(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Oe(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((s)=>s.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(s){let r=[];for(let a in s){let o=s[a];delete o.metadata,r.push(o)}return r}if(t){let s=i(e.textures),r=i(e.images);if(s.length>0)n.textures=s;if(r.length>0)n.images=r}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new We().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Un().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new ze().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}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;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=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.allowOverride=e.allowOverride,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){if(e===!0)this.version++}}class Ps extends _i{constructor(e){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new We(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}}var is,Gs=new O,_s=new O,xs=new O,vs=new ze,Hs=new ze,ph=new yt,Er=new O,Vs=new O,Ar=new O,tc=new ze,Ha=new ze,nc=new ze;class ir extends Ht{constructor(e=new Ps){super();if(this.isSprite=!0,this.type="Sprite",is===void 0){is=new mn;let t=new Float32Array([-0.5,-0.5,0,0,0,0.5,-0.5,0,1,0,0.5,0.5,0,1,1,-0.5,0.5,0,0,1]),n=new $o(t,5);is.setIndex([0,1,2,0,2,3]),is.setAttribute("position",new qs(n,3,0,!1)),is.setAttribute("uv",new qs(n,2,3,!1))}this.geometry=is,this.material=e,this.center=new ze(0.5,0.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){if(e.camera===null)Ue('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(_s.setFromMatrixScale(this.matrixWorld),ph.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),xs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)_s.multiplyScalar(-xs.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;Cr(Er.set(-0.5,-0.5,0),xs,r,_s,i,s),Cr(Vs.set(0.5,-0.5,0),xs,r,_s,i,s),Cr(Ar.set(0.5,0.5,0),xs,r,_s,i,s),tc.set(0,0),Ha.set(1,0),nc.set(1,1);let a=e.ray.intersectTriangle(Er,Vs,Ar,!1,Gs);if(a===null){if(Cr(Vs.set(-0.5,0.5,0),xs,r,_s,i,s),Ha.set(0,1),a=e.ray.intersectTriangle(Er,Ar,Vs,!1,Gs),a===null)return}let o=e.ray.origin.distanceTo(Gs);if(o<e.near||o>e.far)return;t.push({distance:o,point:Gs.clone(),uv:dn.getInterpolation(Gs,Er,Vs,Ar,tc,Ha,nc,new ze),face:null,object:this})}copy(e,t){if(super.copy(e,t),e.center!==void 0)this.center.copy(e.center);return this.material=e.material,this}}function Cr(e,t,n,i,s,r){if(vs.subVectors(e,n).addScalar(0.5).multiply(i),s!==void 0)Hs.x=r*vs.x-s*vs.y,Hs.y=s*vs.x+r*vs.y;else Hs.copy(vs);e.copy(t),e.x+=Hs.x,e.y+=Hs.y,e.applyMatrix4(ph)}var Qn=new O,Va=new O,Rr=new O,Ir=new O;class sa{constructor(e=new O,t=new O(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,Qn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Qn.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Qn.copy(this.origin).addScaledVector(this.direction,t),Qn.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Va.copy(e).add(t).multiplyScalar(0.5),Rr.copy(t).sub(e).normalize(),Ir.copy(this.origin).sub(Va);let s=e.distanceTo(t)*0.5,r=-this.direction.dot(Rr),a=Ir.dot(this.direction),o=-Ir.dot(Rr),l=Ir.lengthSq(),c=Math.abs(1-r*r),u,d,h,p;if(c>0)if(u=r*o-a,d=r*a-o,p=s*c,u>=0)if(d>=-p)if(d<=p){let v=1/c;u*=v,d*=v,h=u*(u+r*d+2*a)+d*(r*u+d+2*o)+l}else d=s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else d=-s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else if(d<=-p)u=Math.max(0,-(-r*s+a)),d=u>0?-s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else if(d<=p)u=0,d=Math.min(Math.max(-s,-o),s),h=d*(d+2*o)+l;else u=Math.max(0,-(r*s+a)),d=u>0?s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else d=r>0?-s:s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Va).addScaledVector(Rr,d);return h}intersectSphere(e,t){if(e.radius<0)return null;Qn.subVectors(e.center,this.origin);let n=Qn.dot(this.direction),i=Qn.dot(Qn)-n*n,s=e.radius*e.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,o=n+r;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,s,r,a,o,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(l>=0)n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l;else n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l;if(c>=0)s=(e.min.y-d.y)*c,r=(e.max.y-d.y)*c;else s=(e.max.y-d.y)*c,r=(e.min.y-d.y)*c;if(n>r||s>i)return null;if(s>n||isNaN(n))n=s;if(r<i||isNaN(i))i=r;if(u>=0)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,n,i,s){let r=this.origin,a=this.direction,{x:o,y:l,z:c}=a,u=e.x-r.x,d=e.y-r.y,h=e.z-r.z,p=t.x-r.x,v=t.y-r.y,T=t.z-r.z,m=n.x-r.x,f=n.y-r.y,E=n.z-r.z,C=Math.abs(o),y=Math.abs(l),b=Math.abs(c),w,A,_,M,B,R,U,W,P,H,j,G;if(C>=y&&C>=b)if(_=o,R=u,P=p,G=m,o>=0)w=l,A=c,M=d,B=h,U=v,W=T,H=f,j=E;else w=c,A=l,M=h,B=d,U=T,W=v,H=E,j=f;else if(y>=b)if(_=l,R=d,P=v,G=f,l>=0)w=c,A=o,M=h,B=u,U=T,W=p,H=E,j=m;else w=o,A=c,M=u,B=h,U=p,W=T,H=m,j=E;else if(_=c,R=h,P=T,G=E,c>=0)w=o,A=l,M=u,B=d,U=p,W=v,H=m,j=f;else w=l,A=o,M=d,B=u,U=v,W=p,H=f,j=m;if(_===0)return null;let re=w/_,q=A/_,te=1/_,ee=M-re*R,me=B-q*R,we=U-re*P,He=W-q*P,Fe=H-re*G,Y=j-q*G,se=Fe*He-Y*we,ae=ee*Y-me*Fe,Re=we*me-He*ee;if(i){if(se<0||ae<0||Re<0)return null}else if((se<0||ae<0||Re<0)&&(se>0||ae>0||Re>0))return null;let Ie=se+ae+Re;if(Ie===0)return null;let De=te*(se*R+ae*P+Re*G);if(Ie>0?De<0:De>0)return null;return this.at(De/Ie,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 Ft extends _i{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 pi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.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}}var ic=new yt,Ai=new sa,Pr=new nr,sc=new O,Lr=new O,Nr=new O,Dr=new O,Wa=new O,Ur=new O,rc=new O,Fr=new O;class Ge extends Ht{constructor(e=new mn,t=new Ft){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,r=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(s&&a){Ur.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let c=a[o],u=s[o];if(c===0)continue;if(Wa.fromBufferAttribute(u,e),r)Ur.addScaledVector(Wa,c);else Ur.addScaledVector(Wa.sub(t),c)}t.add(Ur)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Pr.copy(n.boundingSphere),Pr.applyMatrix4(s),Ai.copy(e.ray).recast(e.near),Pr.containsPoint(Ai.origin)===!1){if(Ai.intersectSphere(Pr,sc)===null)return;if(Ai.origin.distanceToSquared(sc)>(e.far-e.near)**2)return}if(ic.copy(s).invert(),Ai.copy(e.ray).applyMatrix4(ic),n.boundingBox!==null){if(Ai.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ai)}_computeIntersections(e,t,n){let i,s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,{groups:d,drawRange:h}=s;if(a!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),E=Math.min(a.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=E;C<y;C+=3){let b=a.getX(C),w=a.getX(C+1),A=a.getX(C+2);if(i=Or(this,m,e,n,l,c,u,b,w,A),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,t.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(a.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=a.getX(T),E=a.getX(T+1),C=a.getX(T+2);if(i=Or(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),E=Math.min(o.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=E;C<y;C+=3){let b=C,w=C+1,A=C+2;if(i=Or(this,m,e,n,l,c,u,b,w,A),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,t.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(o.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=T,E=T+1,C=T+2;if(i=Or(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}}}function $u(e,t,n,i,s,r,a,o){let l;if(t.side===1)l=i.intersectTriangle(a,r,s,!0,o);else l=i.intersectTriangle(s,r,a,t.side===0,o);if(l===null)return null;Fr.copy(o),Fr.applyMatrix4(e.matrixWorld);let c=n.ray.origin.distanceTo(Fr);if(c<n.near||c>n.far)return null;return{distance:c,point:Fr.clone(),object:e}}function Or(e,t,n,i,s,r,a,o,l,c){e.getVertexPosition(o,Lr),e.getVertexPosition(l,Nr),e.getVertexPosition(c,Dr);let u=$u(e,t,n,i,Lr,Nr,Dr,rc);if(u){let d=new O;if(dn.getBarycoord(rc,Lr,Nr,Dr,d),s)u.uv=dn.getInterpolatedAttribute(s,o,l,c,d,new ze);if(r)u.uv1=dn.getInterpolatedAttribute(r,o,l,c,d,new ze);if(a){if(u.normal=dn.getInterpolatedAttribute(a,o,l,c,d,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a:o,b:l,c,normal:new O,materialIndex:0};dn.getNormal(Lr,Nr,Dr,h.normal),u.face=h,u.barycoord=d}return u}class sr extends Zt{constructor(e=null,t=1,n=1,i,s,r,a,o,l=1003,c=1003,u,d){super(null,r,a,o,l,c,i,s,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var Ci=new nr,Ku=new ze(0.5,0.5),Br=new O;class rr{constructor(e=new Un,t=new Un,n=new Un,i=new Un,s=new Un,r=new Un){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,s=e.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],u=s[5],d=s[6],h=s[7],p=s[8],v=s[9],T=s[10],m=s[11],f=s[12],E=s[13],C=s[14],y=s[15];if(i[0].setComponents(l-r,h-c,m-p,y-f).normalize(),i[1].setComponents(l+r,h+c,m+p,y+f).normalize(),i[2].setComponents(l+a,h+u,m+v,y+E).normalize(),i[3].setComponents(l-a,h-u,m-v,y-E).normalize(),n)i[4].setComponents(o,d,T,C).normalize(),i[5].setComponents(l-o,h-d,m-T,y-C).normalize();else if(i[4].setComponents(l-o,h-d,m-T,y-C).normalize(),t===2000)i[5].setComponents(l+o,h+d,m+T,y+C).normalize();else if(t===2001)i[5].setComponents(o,d,T,C).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Ci.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Ci.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ci)}intersectsSprite(e){Ci.center.set(0,0,0);let t=Ku.distanceTo(e.center);return Ci.radius=0.7071067811865476+t,Ci.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ci)}intersectsSphere(e){let 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){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Br.x=i.normal.x>0?e.max.x:e.min.x,Br.y=i.normal.y>0?e.max.y:e.min.y,Br.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Br)<0)return!1}return!0}containsPoint(e){let 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)}}class ra extends Zt{constructor(e=[],t=301,n,i,s,r,a,o,l,c){super(e,t,n,i,s,r,a,o,l,c);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Si extends Zt{constructor(e,t,n,i,s,r,a,o,l){super(e,t,n,i,s,r,a,o,l);this.isCanvasTexture=!0,this.needsUpdate=!0}}class Oi extends Zt{constructor(e,t,n=1014,i,s,r,a=1003,o=1003,l,c=1026,u=1){if(c!==1026&&c!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,s,r,a,o,c,n,l);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Qs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Ko extends Oi{constructor(e,t=1014,n=301,i,s,r=1003,a=1003,o,l=1026){let c={width:e,height:e,depth:1},u=[c,c,c,c,c,c];super(e,e,t,n,i,s,r,a,o,l);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class aa extends Zt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Hn extends mn{constructor(e=1,t=1,n=1,i=1,s=1,r=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};let a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);let o=[],l=[],c=[],u=[],d=0,h=0;p("z","y","x",-1,-1,n,t,e,r,s,0),p("z","y","x",1,-1,n,t,-e,r,s,1),p("x","z","y",1,1,e,n,t,i,r,2),p("x","z","y",1,-1,e,n,-t,i,r,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(o),this.setAttribute("position",new $t(l,3)),this.setAttribute("normal",new $t(c,3)),this.setAttribute("uv",new $t(u,2));function p(v,T,m,f,E,C,y,b,w,A,_){let M=C/w,B=y/A,R=C/2,U=y/2,W=b/2,P=w+1,H=A+1,j=0,G=0,re=new O;for(let q=0;q<H;q++){let te=q*B-U;for(let ee=0;ee<P;ee++){let me=ee*M-R;re[v]=me*f,re[T]=te*E,re[m]=W,l.push(re.x,re.y,re.z),re[v]=0,re[T]=0,re[m]=b>0?1:-1,c.push(re.x,re.y,re.z),u.push(ee/w),u.push(1-q/A),j+=1}}for(let q=0;q<A;q++)for(let te=0;te<w;te++){let ee=d+te+P*q,me=d+te+P*(q+1),we=d+(te+1)+P*(q+1),He=d+(te+1)+P*q;o.push(ee,me,He),o.push(me,we,He),G+=6}a.addGroup(h,G,_),h+=G,d+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Ls extends mn{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);let s=[],r=[],a=[],o=[],l=new O,c=new ze;r.push(0,0,0),a.push(0,0,1),o.push(0.5,0.5);for(let u=0,d=3;u<=t;u++,d+=3){let h=n+u/t*i;l.x=e*Math.cos(h),l.y=e*Math.sin(h),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[d]/e+1)/2,c.y=(r[d+1]/e+1)/2,o.push(c.x,c.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new $t(r,3)),this.setAttribute("normal",new $t(a,3)),this.setAttribute("uv",new $t(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ls(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class gn extends mn{constructor(e=1,t=1,n=1,i=32,s=1,r=!1,a=0,o=Math.PI*2){super();this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};let l=this;i=Math.floor(i),s=Math.floor(s);let c=[],u=[],d=[],h=[],p=0,v=[],T=n/2,m=0;if(f(),r===!1){if(e>0)E(!0);if(t>0)E(!1)}this.setIndex(c),this.setAttribute("position",new $t(u,3)),this.setAttribute("normal",new $t(d,3)),this.setAttribute("uv",new $t(h,2));function f(){let C=new O,y=new O,b=0,w=(t-e)/n;for(let A=0;A<=s;A++){let _=[],M=A/s,B=M*(t-e)+e;for(let R=0;R<=i;R++){let U=R/i,W=U*o+a,P=Math.sin(W),H=Math.cos(W);y.x=B*P,y.y=-M*n+T,y.z=B*H,u.push(y.x,y.y,y.z),C.set(P,w,H).normalize(),d.push(C.x,C.y,C.z),h.push(U,1-M),_.push(p++)}v.push(_)}for(let A=0;A<i;A++)for(let _=0;_<s;_++){let M=v[_][A],B=v[_+1][A],R=v[_+1][A+1],U=v[_][A+1];if(e>0||_!==0)c.push(M,B,U),b+=3;if(t>0||_!==s-1)c.push(B,R,U),b+=3}l.addGroup(m,b,0),m+=b}function E(C){let y=p,b=new ze,w=new O,A=0,_=C===!0?e:t,M=C===!0?1:-1;for(let R=1;R<=i;R++)u.push(0,T*M,0),d.push(0,M,0),h.push(0.5,0.5),p++;let B=p;for(let R=0;R<=i;R++){let W=R/i*o+a,P=Math.cos(W),H=Math.sin(W);w.x=_*H,w.y=T*M,w.z=_*P,u.push(w.x,w.y,w.z),d.push(0,M,0),b.x=P*0.5+0.5,b.y=H*0.5*M+0.5,h.push(b.x,b.y),p++}for(let R=0;R<i;R++){let U=y+R,W=B+R;if(C===!0)c.push(W,W+1,U);else c.push(W+1,W,U);A+=3}l.addGroup(m,A,C===!0?1:2),m+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class At extends mn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,r=t/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=e/a,d=t/o,h=[],p=[],v=[],T=[];for(let m=0;m<c;m++){let f=m*d-r;for(let E=0;E<l;E++){let C=E*u-s;p.push(C,-f,0),v.push(0,0,1),T.push(E/a),T.push(1-m/o)}}for(let m=0;m<o;m++)for(let f=0;f<a;f++){let E=f+l*m,C=f+l*(m+1),y=f+1+l*(m+1),b=f+1+l*m;h.push(E,C,b),h.push(C,y,b)}this.setIndex(h),this.setAttribute("position",new $t(p,3)),this.setAttribute("normal",new $t(v,3)),this.setAttribute("uv",new $t(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new At(e.width,e.height,e.widthSegments,e.heightSegments)}}function Bi(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let s=e[n][i];if(ac(s))if(s.isRenderTargetTexture)Oe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=s.clone();else if(Array.isArray(s))if(ac(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[n][i]=r}else t[n][i]=s.slice();else t[n][i]=s}}return t}function rn(e){let t={};for(let n=0;n<e.length;n++){let i=Bi(e[n]);for(let s in i)t[s]=i[s]}return t}function ac(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Qu(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Qo(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var mh={clone:Bi,merge:rn},ju=`void main() {
|
|
1
|
+
import{vr}from"./chunk-index-kankja6p.js";import{Qn,Mt,xo,Bt,rn,Qi,Ft,Rt,fr,So,mt,wo,Mn,ko,_o,Mi,To,Po,hr,Qo,Mo,Ro,Eo,pr,on,sn,Et,Co,ni,Ri,Ao,Ei,$o,No}from"./chunk-index-fe0m5mht.js";import{Ct,Gt}from"./chunk-index-pgxgq61x.js";var pc="186";var mc=0,Na=1,gc=2;var Ls=1,_c=2,ds=3,fs=0,qt=1,cn=2,On=0,Cn=1,jn=2,Da=3,Ua=4,xc=5;var ps=100,vc=101,yc=102,Sc=103,Mc=104,bc=200,Tc=201,wc=202,Ec=203,Ac=204,Cc=205,Rc=206,Ic=207,Pc=208,Lc=209,Nc=210,Dc=211,Uc=212,Fc=213,Oc=214,Bc=0,zc=1,kc=2,Fa=3,Gc=4,Hc=5,Vc=6,Wc=7,Xc=0,qc=1,Yc=2,Rn=0,Oa=1,Ba=2,za=3,ka=4,Ga=5,Ha=6,Va=7;var ms=301,Ci=302,Ar=303,Cr=304,Ns=306,Ds=1000,Bn=1001,Zc=1002,In=1003,Jc=1004;var Us=1005;var en=1006,Rr=1007;var Ii=1008;var fn=1009,$c=1010,Kc=1011,Fs=1012,Wa=1013,mi=1014,ei=1015,zn=1016,Xa=1017,qa=1018,gs=1020,Qc=35902,jc=35899,eh=1021,th=1022,kn=1023,Pi=1026,Li=1027,Ir=1028,Ya=1029,Ni=1030,Za=1031;var Ja=1033,Pr=33776,Lr=33777,Nr=33778,Dr=33779,$a=35840,Ka=35841,Qa=35842,ja=35843,eo=36196,to=37492,no=37496,io=37488,so=37489,Ur=37490,ro=37491,ao=37808,oo=37809,lo=37810,co=37811,ho=37812,uo=37813,fo=37814,po=37815,mo=37816,go=37817,vo=37818,yo=37819,bo=37820,Io=37821,Lo=36492,Do=36494,Uo=36495,Fo=36283,Oo=36284,Fr=36285,Bo=36286;var zo=0,nh=1,Di="",gi="srgb",Go="srgb-linear",Ho="linear",_t="srgb";var ih=512,sh=513,rh=514,Or=515,ah=516,oh=517,Br=518,lh=519;var Vo="300 es",Wo=2000;function Pu(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Lu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Rs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ch(){let e=Rs("canvas");return e.style.display="block",e}var Vl={},us=null;function Is(...e){let t="THREE."+e.shift();if(us)us("log",t,...e);else console.log(t,...e)}function hh(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Oe(...e){e=hh(e);let t="THREE."+e.shift();if(us)us("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=hh(e);let t="THREE."+e.shift();if(us)us("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Ai(...e){let t=e.join(" ");if(t in Vl)return;Vl[t]=!0,Oe(...e)}function uh(e,t,n){return new Promise(function(i,s){function r(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:s();break;case e.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:i()}}setTimeout(r,n)})}var dh={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ti{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let s=i.indexOf(t);if(s!==-1)i.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,e);e.target=null}}}var Qt=["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"];var la=Math.PI/180,Er=180/Math.PI;function fi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Qt[e&255]+Qt[e>>8&255]+Qt[e>>16&255]+Qt[e>>24&255]+"-"+Qt[t&255]+Qt[t>>8&255]+"-"+Qt[t>>16&15|64]+Qt[t>>24&255]+"-"+Qt[n&63|128]+Qt[n>>8&255]+"-"+Qt[n>>16&255]+Qt[n>>24&255]+Qt[i&255]+Qt[i>>8&255]+Qt[i>>16&255]+Qt[i>>24&255]).toLowerCase()}function tt(e,t,n){return Math.max(t,Math.min(n,e))}function Nu(e,t){return(e%t+t)%t}function ca(e,t,n){return(1-n)*e+n*t}function Fn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}class ze{static{ze.prototype.isVector2=!0}constructor(e=0,t=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 Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: 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){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(tt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ii{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,r,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],d=s[r+0],h=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||o!==d||l!==h||c!==p){let T=o*d+l*h+c*p+u*v;if(T<0)d=-d,h=-h,p=-p,v=-v,T=-T;let m=1-a;if(T<0.9995){let f=Math.acos(T),E=Math.sin(f);m=Math.sin(m*f)/E,a=Math.sin(a*f)/E,o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a}else{o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a;let f=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=f,l*=f,c*=f,u*=f}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,r){let a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=s[r],d=s[r+1],h=s[r+2],p=s[r+3];return e[t]=a*p+c*u+o*h-l*d,e[t+1]=o*p+c*d+l*u-a*h,e[t+2]=l*p+c*h+a*d-o*u,e[t+3]=c*p-a*u-o*d-l*h,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){let{_x:n,_y:i,_z:s,_order:r}=e,{cos:a,sin:o}=Math,l=a(n/2),c=a(i/2),u=a(s/2),d=o(n/2),h=o(i/2),p=o(s/2);switch(r){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:Oe("Quaternion: .setFromEuler() encountered an unknown order: "+r)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],a=t[5],o=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(c-o)*h,this._y=(s-l)*h,this._z=(r-i)*h}else if(n>a&&n>u){let h=2*Math.sqrt(1+n-a-u);this._w=(c-o)/h,this._x=0.25*h,this._y=(i+r)/h,this._z=(s+l)/h}else if(a>u){let h=2*Math.sqrt(1+a-n-u);this._w=(s-l)/h,this._x=(i+r)/h,this._y=0.25*h,this._z=(o+c)/h}else{let h=2*Math.sqrt(1+u-n-a);this._w=(r-i)/h,this._x=(s+l)/h,this._y=(o+c)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else 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;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(tt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:s,_w:r}=e,{_x:a,_y:o,_z:l,_w:c}=t;return this._x=n*c+r*a+i*l-s*o,this._y=i*c+r*o+s*a-n*l,this._z=s*c+r*l+n*o-i*a,this._w=r*c-n*a-i*o-s*l,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:s,_w:r}=e,a=this.dot(e);if(a<0)n=-n,i=-i,s=-s,r=-r,a=-a;let o=1-t;if(a<0.9995){let l=Math.acos(a),c=Math.sin(l);o=Math.sin(o*l)/c,t=Math.sin(t*l)/c,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+r*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let 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 O{static{O.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return 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 Error("THREE.Vector3: 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 Error("THREE.Vector3: 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(Wl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wl.setFromAxisAngle(e,t))}applyMatrix3(e){let 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){let t=this.x,n=this.y,i=this.z,s=e.elements,r=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])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:s,y:r,z:a,w:o}=e,l=2*(r*i-a*n),c=2*(a*t-s*i),u=2*(s*n-r*t);return this.x=t+o*l+r*u-a*c,this.y=n+o*c+a*l-s*u,this.z=i+o*u+s*c-r*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this.z=tt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this.z=tt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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){let{x:n,y:i,z:s}=e,{x:r,y:a,z:o}=t;return this.x=i*o-s*a,this.y=s*r-n*o,this.z=n*a-i*r,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ha.copy(this).projectOnVector(e),this.sub(ha)}reflect(e){return this.sub(ha.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(tt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let 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(){let 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}}var ha=new O,Wl=new ii;class ke{static{ke.prototype.isMatrix3=!0}constructor(e,t,n,i,s,r,a,o,l){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,s,r,a,o,l)}set(e,t,n,i,s,r,a,o,l){let c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=o,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],v=i[0],T=i[3],m=i[6],f=i[1],E=i[4],C=i[7],y=i[2],b=i[5],w=i[8];return s[0]=r*v+a*f+o*y,s[3]=r*T+a*E+o*b,s[6]=r*m+a*C+o*w,s[1]=l*v+c*f+u*y,s[4]=l*T+c*E+u*b,s[7]=l*m+c*C+u*w,s[2]=d*v+h*f+p*y,s[5]=d*T+h*E+p*b,s[8]=d*m+h*C+p*w,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*r*c-t*a*l-n*s*c+n*a*o+i*s*l-i*r*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=c*r-a*l,d=a*o-c*s,h=l*s-r*o,p=t*u+n*d+i*h;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/p;return e[0]=u*v,e[1]=(i*l-c*n)*v,e[2]=(a*n-i*r)*v,e[3]=d*v,e[4]=(c*t-i*o)*v,e[5]=(i*s-a*t)*v,e[6]=h*v,e[7]=(n*o-l*t)*v,e[8]=(r*t-n*s)*v,this}transpose(){let e,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){let 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,r,a){let o=Math.cos(s),l=Math.sin(s);return this.set(n*o,n*l,-n*(o*r+l*a)+r+e,-i*l,i*o,-i*(-l*r+o*a)+a+t,0,0,1),this}scale(e,t){return Ai("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ua.makeScale(e,t)),this}rotate(e){return Ai("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ua.makeRotation(-e)),this}translate(e,t){return Ai("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ua.makeTranslation(e,t)),this}makeTranslation(e,t){if(e.isVector2)this.set(1,0,e.x,0,1,e.y,0,0,1);else this.set(1,0,e,0,1,t,0,0,1);return this}makeRotation(e){let 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){let 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){let 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)}}var ua=new ke,Xl=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),ql=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Du(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(s,r,a){if(this.enabled===!1||r===a||!r||!a)return s;if(this.spaces[r].transfer==="srgb")s.r=Kn(s.r),s.g=Kn(s.g),s.b=Kn(s.b);if(this.spaces[r].primaries!==this.spaces[a].primaries)s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")s.r=hs(s.r),s.g=hs(s.g),s.b=hs(s.b);return s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){if(s==="")return"linear";return this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ai("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ai("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(s,r)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:Xl,fromXYZ:ql,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Xl,fromXYZ:ql,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Du();function Kn(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function hs(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var qi;class Xo{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(qi===void 0)qi=Rs("canvas");qi.width=e.width,qi.height=e.height;let i=qi.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=qi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Rs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=Kn(s[r]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Kn(t[n]/255)*255);else t[n]=Kn(t[n]);return{data:t,width:e.width,height:e.height}}else return Oe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Uu=0;class Os{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Uu++}),this.uuid=fi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,a=i.length;r<a;r++)if(i[r].isDataTexture)s.push(da(i[r].image));else s.push(da(i[r]))}else s=da(i);n.url=s}if(!t)e.images[this.uuid]=n;return n}}function da(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Xo.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Oe("Texture: Unable to serialize Texture."),{}}var Fu=0,fa=new O;class Jt extends ti{constructor(e=Jt.DEFAULT_IMAGE,t=Jt.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=Jt.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Fu++}),this.uuid=fi(),this.name="",this.source=new Os(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ze(0,0),this.repeat=new ze(1,1),this.center=new ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(fa).x}get height(){return this.source.getSize(fa).y}get depth(){return this.source.getSize(fa).z}get image(){return this.source.data}set image(e){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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.normalized=e.normalized,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.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Oe(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=300;Jt.DEFAULT_ANISOTROPY=1;class wt{static{wt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){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 Error("THREE.Vector4: 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 Error("THREE.Vector4: 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){let t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[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);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,r=0.01,a=0.1,o=e.elements,l=o[0],c=o[4],u=o[8],d=o[1],h=o[5],p=o[9],v=o[2],T=o[6],m=o[10];if(Math.abs(c-d)<0.01&&Math.abs(u-v)<0.01&&Math.abs(p-T)<0.01){if(Math.abs(c+d)<0.1&&Math.abs(u+v)<0.1&&Math.abs(p+T)<0.1&&Math.abs(l+h+m-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(l+1)/2,C=(h+1)/2,y=(m+1)/2,b=(c+d)/4,w=(u+v)/4,A=(p+T)/4;if(E>C&&E>y)if(E<0.01)n=0,i=0.707106781,s=0.707106781;else n=Math.sqrt(E),i=b/n,s=w/n;else if(C>y)if(C<0.01)n=0.707106781,i=0,s=0.707106781;else i=Math.sqrt(C),n=b/i,s=A/i;else if(y<0.01)n=0.707106781,i=0.707106781,s=0;else s=Math.sqrt(y),n=w/s,i=A/s;return this.set(n,i,s,t),this}let f=Math.sqrt((T-p)*(T-p)+(u-v)*(u-v)+(d-c)*(d-c));if(Math.abs(f)<0.001)f=1;return this.x=(T-p)/f,this.y=(u-v)/f,this.z=(d-c)/f,this.w=Math.acos((l+h+m-1)/2),this}setFromMatrixPosition(e){let 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=tt(this.x,e.x,t.x),this.y=tt(this.y,e.y,t.y),this.z=tt(this.z,e.z,t.z),this.w=tt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=tt(this.x,e,t),this.y=tt(this.y,e,t),this.z=tt(this.z,e,t),this.w=tt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(tt(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 qo extends ti{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},s=new Jt(i),r=n.count;for(let a=0;a<r;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===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++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;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 t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Os(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class pn extends qo{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class zr extends Jt{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Yo extends Jt{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=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class yt{static{yt.prototype.isMatrix4=!0}constructor(e,t,n,i,s,r,a,o,l,c,u,d,h,p,v,T){if(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,r,a,o,l,c,u,d,h,p,v,T)}set(e,t,n,i,s,r,a,o,l,c,u,d,h,p,v,T){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=r,m[9]=a,m[13]=o,m[2]=l,m[6]=c,m[10]=u,m[14]=d,m[3]=h,m[7]=p,m[11]=v,m[15]=T,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 yt().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;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){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Yi.setFromMatrixColumn(e,0).length(),s=1/Yi.setFromMatrixColumn(e,1).length(),r=1/Yi.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]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:s}=e,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let d=r*c,h=r*u,p=a*c,v=a*u;t[0]=o*c,t[4]=-o*u,t[8]=l,t[1]=h+p*l,t[5]=d-v*l,t[9]=-a*o,t[2]=v-d*l,t[6]=p+h*l,t[10]=r*o}else if(e.order==="YXZ"){let d=o*c,h=o*u,p=l*c,v=l*u;t[0]=d+v*a,t[4]=p*a-h,t[8]=r*l,t[1]=r*u,t[5]=r*c,t[9]=-a,t[2]=h*a-p,t[6]=v+d*a,t[10]=r*o}else if(e.order==="ZXY"){let d=o*c,h=o*u,p=l*c,v=l*u;t[0]=d-v*a,t[4]=-r*u,t[8]=p+h*a,t[1]=h+p*a,t[5]=r*c,t[9]=v-d*a,t[2]=-r*l,t[6]=a,t[10]=r*o}else if(e.order==="ZYX"){let d=r*c,h=r*u,p=a*c,v=a*u;t[0]=o*c,t[4]=p*l-h,t[8]=d*l+v,t[1]=o*u,t[5]=v*l+d,t[9]=h*l-p,t[2]=-l,t[6]=a*o,t[10]=r*o}else if(e.order==="YZX"){let d=r*o,h=r*l,p=a*o,v=a*l;t[0]=o*c,t[4]=v-d*u,t[8]=p*u+h,t[1]=u,t[5]=r*c,t[9]=-a*c,t[2]=-l*c,t[6]=h*u+p,t[10]=d-v*u}else if(e.order==="XZY"){let d=r*o,h=r*l,p=a*o,v=a*l;t[0]=o*c,t[4]=-u,t[8]=l*c,t[1]=d*u+v,t[5]=r*c,t[9]=h*u-p,t[2]=p*u-h,t[6]=a*c,t[10]=v*u+d}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(Ou,e,Bu)}lookAt(e,t,n){let i=this.elements;if(hn.subVectors(e,t),hn.lengthSq()===0)hn.z=1;if(hn.normalize(),li.crossVectors(n,hn),li.lengthSq()===0){if(Math.abs(n.z)===1)hn.x+=0.0001;else hn.z+=0.0001;hn.normalize(),li.crossVectors(n,hn)}return li.normalize(),er.crossVectors(hn,li),i[0]=li.x,i[4]=er.x,i[8]=hn.x,i[1]=li.y,i[5]=er.y,i[9]=hn.y,i[2]=li.z,i[6]=er.z,i[10]=hn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],v=n[6],T=n[10],m=n[14],f=n[3],E=n[7],C=n[11],y=n[15],b=i[0],w=i[4],A=i[8],_=i[12],M=i[1],B=i[5],R=i[9],U=i[13],W=i[2],P=i[6],H=i[10],j=i[14],G=i[3],re=i[7],q=i[11],te=i[15];return s[0]=r*b+a*M+o*W+l*G,s[4]=r*w+a*B+o*P+l*re,s[8]=r*A+a*R+o*H+l*q,s[12]=r*_+a*U+o*j+l*te,s[1]=c*b+u*M+d*W+h*G,s[5]=c*w+u*B+d*P+h*re,s[9]=c*A+u*R+d*H+h*q,s[13]=c*_+u*U+d*j+h*te,s[2]=p*b+v*M+T*W+m*G,s[6]=p*w+v*B+T*P+m*re,s[10]=p*A+v*R+T*H+m*q,s[14]=p*_+v*U+T*j+m*te,s[3]=f*b+E*M+C*W+y*G,s[7]=f*w+E*B+C*P+y*re,s[11]=f*A+E*R+C*H+y*q,s[15]=f*_+E*U+C*j+y*te,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],a=e[5],o=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14],p=e[3],v=e[7],T=e[11],m=e[15],f=o*h-l*d,E=a*h-l*u,C=a*d-o*u,y=r*h-l*c,b=r*d-o*c,w=r*u-a*c;return t*(v*f-T*E+m*C)-n*(p*f-T*y+m*b)+i*(p*E-v*y+m*w)-s*(p*C-v*b+T*w)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[1],r=e[5],a=e[9],o=e[2],l=e[6],c=e[10];return t*(r*c-a*l)-n*(s*c-a*o)+i*(s*l-r*o)}transpose(){let e=this.elements,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){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],o=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],v=e[13],T=e[14],m=e[15],f=t*a-n*r,E=t*o-i*r,C=t*l-s*r,y=n*o-i*a,b=n*l-s*a,w=i*l-s*o,A=c*v-u*p,_=c*T-d*p,M=c*m-h*p,B=u*T-d*v,R=u*m-h*v,U=d*m-h*T,W=f*U-E*R+C*B+y*M-b*_+w*A;if(W===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let P=1/W;return e[0]=(a*U-o*R+l*B)*P,e[1]=(i*R-n*U-s*B)*P,e[2]=(v*w-T*b+m*y)*P,e[3]=(d*b-u*w-h*y)*P,e[4]=(o*M-r*U-l*_)*P,e[5]=(t*U-i*M+s*_)*P,e[6]=(T*C-p*w-m*E)*P,e[7]=(c*w-d*C+h*E)*P,e[8]=(r*R-a*M+l*A)*P,e[9]=(n*M-t*R-s*A)*P,e[10]=(p*b-v*C+m*f)*P,e[11]=(u*C-c*b-h*f)*P,e[12]=(a*_-r*B-o*A)*P,e[13]=(t*B-n*_+i*A)*P,e[14]=(v*E-p*y-T*f)*P,e[15]=(c*y-u*E+d*f)*P,this}scale(e){let t=this.elements,{x:n,y:i,z:s}=e;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(){let 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){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let 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){let 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){let 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){let n=Math.cos(t),i=Math.sin(t),s=1-n,{x:r,y:a,z:o}=e,l=s*r,c=s*a;return this.set(l*r+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*r,0,l*o-i*a,c*o+i*r,s*o*o+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,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:s,_y:r,_z:a,_w:o}=t,l=s+s,c=r+r,u=a+a,d=s*l,h=s*c,p=s*u,v=r*c,T=r*u,m=a*u,f=o*l,E=o*c,C=o*u,{x:y,y:b,z:w}=n;return i[0]=(1-(v+m))*y,i[1]=(h+C)*y,i[2]=(p-E)*y,i[3]=0,i[4]=(h-C)*b,i[5]=(1-(d+m))*b,i[6]=(T+f)*b,i[7]=0,i[8]=(p+E)*w,i[9]=(T-f)*w,i[10]=(1-(d+v))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let r=Yi.set(i[0],i[1],i[2]).length(),a=Yi.set(i[4],i[5],i[6]).length(),o=Yi.set(i[8],i[9],i[10]).length();if(s<0)r=-r;wn.copy(this);let l=1/r,c=1/a,u=1/o;return wn.elements[0]*=l,wn.elements[1]*=l,wn.elements[2]*=l,wn.elements[4]*=c,wn.elements[5]*=c,wn.elements[6]*=c,wn.elements[8]*=u,wn.elements[9]*=u,wn.elements[10]*=u,t.setFromRotationMatrix(wn),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2*s/(t-e),u=2*s/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),p,v;if(o)p=s/(r-s),v=r*s/(r-s);else if(a===2000)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(a===2001)p=-r/(r-s),v=-r*s/(r-s);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),p,v;if(o)p=1/(r-s),v=r/(r-s);else if(a===2000)p=-2/(r-s),v=-(r+s)/(r-s);else if(a===2001)p=-1/(r-s),v=-s/(r-s);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=h,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let 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){let 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}}var Yi=new O,wn=new yt,Ou=new O(0,0,0),Bu=new O(1,1,1),li=new O,er=new O,hn=new O,Yl=new yt,Zl=new ii;class pi{constructor(e=0,t=0,n=0,i=pi.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){let i=e.elements,s=i[0],r=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(tt(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-c,h),this._z=Math.atan2(-r,s);else this._x=Math.atan2(d,l),this._z=0;break;case"YXZ":if(this._x=Math.asin(-tt(c,-1,1)),Math.abs(c)<0.9999999)this._y=Math.atan2(a,h),this._z=Math.atan2(o,l);else this._y=Math.atan2(-u,s),this._z=0;break;case"ZXY":if(this._x=Math.asin(tt(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-r,l);else this._y=0,this._z=Math.atan2(o,s);break;case"ZYX":if(this._y=Math.asin(-tt(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(o,s);else this._x=0,this._z=Math.atan2(-r,l);break;case"YZX":if(this._z=Math.asin(tt(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,s);else this._x=0,this._y=Math.atan2(a,h);break;case"XZY":if(this._z=Math.asin(-tt(r,-1,1)),Math.abs(r)<0.9999999)this._x=Math.atan2(d,l),this._y=Math.atan2(a,s);else this._x=Math.atan2(-c,h),this._y=0;break;default:Oe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Yl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zl.setFromEuler(this),this.setFromQuaternion(Zl,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return 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}}pi.DEFAULT_ORDER="XYZ";class Bs{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}}var zu=0,Jl=new O,Zi=new ii,qn=new yt,tr=new O,Ms=new O,ku=new O,Gu=new ii,$l=new O(1,0,0),Kl=new O(0,1,0),Ql=new O(0,0,1),jl={type:"added"},Hu={type:"removed"},Ji={type:"childadded",child:null},pa={type:"childremoved",child:null};class Xt extends ti{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:zu++}),this.uuid=fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xt.DEFAULT_UP.clone();let e=new O,t=new pi,n=new ii,i=new O(1,1,1);function s(){n.setFromEuler(t,!1)}function r(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(r),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 yt},normalMatrix:{value:new ke}}),this.matrix=new yt,this.matrixWorld=new yt,this.matrixAutoUpdate=Xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(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 Zi.setFromAxisAngle(e,t),this.quaternion.multiply(Zi),this}rotateOnWorldAxis(e,t){return Zi.setFromAxisAngle(e,t),this.quaternion.premultiply(Zi),this}rotateX(e){return this.rotateOnAxis($l,e)}rotateY(e){return this.rotateOnAxis(Kl,e)}rotateZ(e){return this.rotateOnAxis(Ql,e)}translateOnAxis(e,t){return Jl.copy(e).applyQuaternion(this.quaternion),this.position.add(Jl.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($l,e)}translateY(e){return this.translateOnAxis(Kl,e)}translateZ(e){return this.translateOnAxis(Ql,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qn.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)tr.copy(e);else tr.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ms.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)qn.lookAt(Ms,tr,this.up);else qn.lookAt(tr,Ms,this.up);if(this.quaternion.setFromRotationMatrix(qn),i)qn.extractRotation(i.matrixWorld),Zi.setFromRotationMatrix(qn),this.quaternion.premultiply(Zi.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(jl),Ji.child=e,this.dispatchEvent(Ji),Ji.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Hu),pa.child=e,this.dispatchEvent(pa),pa.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),qn.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),qn.multiply(e.parent.matrixWorld);return e.applyMatrix4(qn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(jl),Ji.child=e,this.dispatchEvent(Ji),Ji.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++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;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(Ms,e,ku),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ms,Gu,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let 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);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*i,s[13]+=n-s[1]*t-s[5]*n-s[9]*i,s[14]+=i-s[2]*t-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function s(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(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);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let l=0,c=o.length;l<c;l++){let u=o[l];s(e.shapes,u)}else s(e.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,l=this.material.length;o<l;o++)a.push(s(e.materials,this.material[o]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(s(e.animations,o))}}if(t){let a=r(e.geometries),o=r(e.materials),l=r(e.textures),c=r(e.images),u=r(e.shapes),d=r(e.skeletons),h=r(e.animations),p=r(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(l.length>0)n.textures=l;if(c.length>0)n.images=c;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(p.length>0)n.nodes=p}return n.object=i,n;function r(a){let o=[];for(let l in a){let c=a[l];delete c.metadata,o.push(c)}return o}}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.pivot=e.pivot!==null?e.pivot.clone():null,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}Xt.DEFAULT_UP=new O(0,1,0);Xt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Zt extends Xt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Vu={type:"move"};class zs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Zt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new Zt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new Zt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,s=null,r=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(let v of e.hand.values()){let T=t.getJointPose(v,n),m=this._getHandJoint(l,v);if(T!==null)m.matrix.fromArray(T.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=T.radius;m.visible=T!==null}let c=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=c.position.distanceTo(u.position),h=0.02,p=0.005;if(l.inputState.pinching&&d>h+p)l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!l.inputState.pinching&&d<=h-p)l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(s=t.getPose(e.gripSpace,n),s!==null){if(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity);else o.hasLinearVelocity=!1;if(s.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null)i=s;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(Vu)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=s!==null;if(l!==null)l.visible=r!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Zt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var fh={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},ci={h:0,s:0,l:0},nr={h:0,s:0,l:0};function ma(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class We{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){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(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="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=Nu(e,1),t=tt(t,0,1),n=tt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=0.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=ma(r,s,e+0.3333333333333333),this.g=ma(r,s,e),this.b=ma(r,s,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(s){if(s===void 0)return;if(parseFloat(s)<1)Oe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Oe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);else if(r===6)return this.setHex(parseInt(s,16),t);else Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=fh[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Oe("Color: Unknown color "+e);return 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=Kn(e.r),this.g=Kn(e.g),this.b=Kn(e.b),this}copyLinearToSRGB(e){return this.r=hs(e.r),this.g=hs(e.g),this.b=hs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(jt.copy(this),e),Math.round(tt(jt.r*255,0,255))*65536+Math.round(tt(jt.g*255,0,255))*256+Math.round(tt(jt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(jt.copy(this),t);let{r:n,g:i,b:s}=jt,r=Math.max(n,i,s),a=Math.min(n,i,s),o,l,c=(a+r)/2;if(a===r)o=0,l=0;else{let u=r-a;switch(l=c<=0.5?u/(r+a):u/(2-r-a),r){case n:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-n)/u+2;break;case s:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=l,e.l=c,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(jt.copy(this),t),e.r=jt.r,e.g=jt.g,e.b=jt.b,e}getStyle(e="srgb"){je.workingToColorSpace(jt.copy(this),e);let{r:t,g:n,b:i}=jt;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ci),this.setHSL(ci.h+e,ci.s+t,ci.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(ci),e.getHSL(nr);let n=ca(ci.h,nr.h,t),i=ca(ci.s,nr.s,t),s=ca(ci.l,nr.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){let 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}}var jt=new We;We.NAMES=fh;class ks{constructor(e,t=1,n=1000){this.isFog=!0,this.name="",this.color=new We(e),this.near=t,this.far=n}clone(){return new ks(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class kr extends Xt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new pi,this.environmentIntensity=1,this.environmentRotation=new pi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(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();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var En=new O,Yn=new O,ga=new O,Zn=new O,$i=new O,Ki=new O,ec=new O,_a=new O,xa=new O,va=new O,ya=new wt,Sa=new wt,Ma=new wt;class dn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),En.subVectors(e,t),i.cross(En);let s=i.lengthSq();if(s>0)return i.multiplyScalar(1/Math.sqrt(s));return i.set(0,0,0)}static getBarycoord(e,t,n,i,s){En.subVectors(i,t),Yn.subVectors(n,t),ga.subVectors(e,t);let r=En.dot(En),a=En.dot(Yn),o=En.dot(ga),l=Yn.dot(Yn),c=Yn.dot(ga),u=r*l-a*a;if(u===0)return s.set(0,0,0),null;let d=1/u,h=(l*o-a*c)*d,p=(r*c-a*o)*d;return s.set(1-h-p,p,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Zn)===null)return!1;return Zn.x>=0&&Zn.y>=0&&Zn.x+Zn.y<=1}static getInterpolation(e,t,n,i,s,r,a,o){if(this.getBarycoord(e,t,n,i,Zn)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(s,Zn.x),o.addScaledVector(r,Zn.y),o.addScaledVector(a,Zn.z),o}static getInterpolatedAttribute(e,t,n,i,s,r){return ya.setScalar(0),Sa.setScalar(0),Ma.setScalar(0),ya.fromBufferAttribute(e,t),Sa.fromBufferAttribute(e,n),Ma.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(ya,s.x),r.addScaledVector(Sa,s.y),r.addScaledVector(Ma,s.z),r}static isFrontFacing(e,t,n,i){return En.subVectors(n,t),Yn.subVectors(e,t),En.cross(Yn).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 En.subVectors(this.c,this.b),Yn.subVectors(this.a,this.b),En.cross(Yn).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return dn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return dn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return dn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,r,a;$i.subVectors(i,n),Ki.subVectors(s,n),_a.subVectors(e,n);let o=$i.dot(_a),l=Ki.dot(_a);if(o<=0&&l<=0)return t.copy(n);xa.subVectors(e,i);let c=$i.dot(xa),u=Ki.dot(xa);if(c>=0&&u<=c)return t.copy(i);let d=o*u-c*l;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),t.copy(n).addScaledVector($i,r);va.subVectors(e,s);let h=$i.dot(va),p=Ki.dot(va);if(p>=0&&h<=p)return t.copy(s);let v=h*l-o*p;if(v<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Ki,a);let T=c*p-h*u;if(T<=0&&u-c>=0&&h-p>=0)return ec.subVectors(s,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(ec,a);let m=1/(T+v+d);return r=v*m,a=d*m,t.copy(n).addScaledVector($i,r).addScaledVector(Ki,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ui{constructor(e=new O(1/0,1/0,1/0),t=new O(-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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(An.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){let n=An.copy(t).multiplyScalar(0.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(0.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);let n=e.geometry;if(n!==void 0){let s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let r=0,a=s.count;r<a;r++){if(e.isMesh===!0)e.getVertexPosition(r,An);else An.fromBufferAttribute(s,r);An.applyMatrix4(e.matrixWorld),this.expandByPoint(An)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();ir.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();ir.copy(n.boundingBox)}ir.applyMatrix4(e.matrixWorld),this.union(ir)}}let i=e.children;for(let s=0,r=i.length;s<r;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,An),An.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(bs),sr.subVectors(this.max,bs),ji.subVectors(e.a,bs),es.subVectors(e.b,bs),ts.subVectors(e.c,bs),hi.subVectors(es,ji),ui.subVectors(ts,es),Si.subVectors(ji,ts);let t=[0,-hi.z,hi.y,0,-ui.z,ui.y,0,-Si.z,Si.y,hi.z,0,-hi.x,ui.z,0,-ui.x,Si.z,0,-Si.x,-hi.y,hi.x,0,-ui.y,ui.x,0,-Si.y,Si.x,0];if(!ba(t,ji,es,ts,sr))return!1;if(t=[1,0,0,0,1,0,0,0,1],!ba(t,ji,es,ts,sr))return!1;return rr.crossVectors(hi,ui),t=[rr.x,rr.y,rr.z],ba(t,ji,es,ts,sr)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(An).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jn),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var Jn=[new O,new O,new O,new O,new O,new O,new O,new O],An=new O,ir=new Ui,ji=new O,es=new O,ts=new O,hi=new O,ui=new O,Si=new O,bs=new O,sr=new O,rr=new O,bi=new O;function ba(e,t,n,i,s){for(let r=0,a=e.length-3;r<=a;r+=3){bi.fromArray(e,r);let o=s.x*Math.abs(bi.x)+s.y*Math.abs(bi.y)+s.z*Math.abs(bi.z),l=t.dot(bi),c=n.dot(bi),u=i.dot(bi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}var Ut=new O,ar=new ze,Wu=0;class yn extends ti{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Wu++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){if(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++)ar.fromBufferAttribute(this,t),ar.applyMatrix3(e),this.setXY(t,ar.x,ar.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ut.fromBufferAttribute(this,t),Ut.applyMatrix3(e),this.setXYZ(t,Ut.x,Ut.y,Ut.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ut.fromBufferAttribute(this,t),Ut.applyMatrix4(e),this.setXYZ(t,Ut.x,Ut.y,Ut.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ut.fromBufferAttribute(this,t),Ut.applyNormalMatrix(e),this.setXYZ(t,Ut.x,Ut.y,Ut.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ut.fromBufferAttribute(this,t),Ut.transformDirection(e),this.setXYZ(t,Ut.x,Ut.y,Ut.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];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Fn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Fn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Fn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Fn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),s=ft(s,this.array);return 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(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class Gr extends yn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Hr extends yn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $t extends yn{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Xu=new Ui,Ts=new O,Ta=new O;class Gs{constructor(e=new O,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){let n=this.center;if(t!==void 0)n.copy(t);else Xu.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;s<r;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){let 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){let n=this.center.distanceToSquared(e);if(t.copy(e),n>this.radius*this.radius)t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center);return t}getBoundingBox(e){if(this.isEmpty())return e.makeEmpty(),e;return 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;Ts.subVectors(e,this.center);let t=Ts.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ts,i/n),this.radius+=i}return this}union(e){if(e.isEmpty())return this;if(this.isEmpty())return this.copy(e),this;if(this.center.equals(e.center)===!0)this.radius=Math.max(this.radius,e.radius);else Ta.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ts.copy(e.center).add(Ta)),this.expandByPoint(Ts.copy(e.center).sub(Ta));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}var qu=0,vn=new yt,wa=new Xt,ns=new O,un=new Ui,ws=new Ui,Wt=new O;class mn extends ti{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qu++}),this.uuid=fi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((Pu(e))?Hr:Gr)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,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){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let s=new ke().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return vn.makeRotationFromQuaternion(e),this.applyMatrix4(vn),this}rotateX(e){return vn.makeRotationX(e),this.applyMatrix4(vn),this}rotateY(e){return vn.makeRotationY(e),this.applyMatrix4(vn),this}rotateZ(e){return vn.makeRotationZ(e),this.applyMatrix4(vn),this}translate(e,t,n){return vn.makeTranslation(e,t,n),this.applyMatrix4(vn),this}scale(e,t,n){return vn.makeScale(e,t,n),this.applyMatrix4(vn),this}lookAt(e){return wa.lookAt(e),wa.updateMatrix(),this.applyMatrix4(wa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ns).negate(),this.translate(ns.x,ns.y,ns.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,s=e.length;i<s;i++){let r=e[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new $t(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}if(e.length>t.count)Oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ui;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(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++){let s=t[n];if(un.setFromBufferAttribute(s),this.morphTargetsRelative)Wt.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(Wt),Wt.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(Wt);else this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new Gs;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if(un.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){let a=t[s];if(ws.setFromBufferAttribute(a),this.morphTargetsRelative)Wt.addVectors(un.min,ws.min),un.expandByPoint(Wt),Wt.addVectors(un.max,ws.max),un.expandByPoint(Wt);else un.expandByPoint(ws.min),un.expandByPoint(ws.max)}un.getCenter(n);let i=0;for(let s=0,r=e.count;s<r;s++)Wt.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Wt));if(t)for(let s=0,r=t.length;s<r;s++){let a=t[s],o=this.morphTargetsRelative;for(let l=0,c=a.count;l<c;l++){if(Wt.fromBufferAttribute(a,l),o)ns.fromBufferAttribute(e,l),Wt.add(ns);i=Math.max(i,n.distanceToSquared(Wt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:s}=t,r=this.getAttribute("tangent");if(r===void 0||r.count!==n.count)r=new yn(new Float32Array(4*n.count),4),this.setAttribute("tangent",r);let a=[],o=[];for(let A=0;A<n.count;A++)a[A]=new O,o[A]=new O;let l=new O,c=new O,u=new O,d=new ze,h=new ze,p=new ze,v=new O,T=new O;function m(A,_,M){l.fromBufferAttribute(n,A),c.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,A),h.fromBufferAttribute(s,_),p.fromBufferAttribute(s,M),c.sub(l),u.sub(l),h.sub(d),p.sub(d);let B=1/(h.x*p.y-p.x*h.y);if(!isFinite(B))return;v.copy(c).multiplyScalar(p.y).addScaledVector(u,-h.y).multiplyScalar(B),T.copy(u).multiplyScalar(h.x).addScaledVector(c,-p.x).multiplyScalar(B),a[A].add(v),a[_].add(v),a[M].add(v),o[A].add(T),o[_].add(T),o[M].add(T)}let f=this.groups;if(f.length===0)f=[{start:0,count:e.count}];for(let A=0,_=f.length;A<_;++A){let M=f[A],{start:B,count:R}=M;for(let U=B,W=B+R;U<W;U+=3)m(e.getX(U+0),e.getX(U+1),e.getX(U+2))}let E=new O,C=new O,y=new O,b=new O;function w(A){y.fromBufferAttribute(i,A),b.copy(y);let _=a[A];E.copy(_),E.sub(y.multiplyScalar(y.dot(_))).normalize(),C.crossVectors(b,_);let B=C.dot(o[A])<0?-1:1;r.setXYZW(A,E.x,E.y,E.z,B)}for(let A=0,_=f.length;A<_;++A){let M=f[A],{start:B,count:R}=M;for(let U=B,W=B+R;U<W;U+=3)w(e.getX(U+0)),w(e.getX(U+1)),w(e.getX(U+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new yn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new O,s=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O;if(e)for(let d=0,h=e.count;d<h;d+=3){let p=e.getX(d+0),v=e.getX(d+1),T=e.getX(d+2);i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),r.fromBufferAttribute(t,T),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,T),a.add(c),o.add(c),l.add(c),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(T,l.x,l.y,l.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),r.fromBufferAttribute(t,d+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Wt.fromBufferAttribute(e,t),Wt.normalize(),e.setXYZ(t,Wt.x,Wt.y,Wt.z)}toNonIndexed(){function e(a,o){let{array:l,itemSize:c,normalized:u}=a,d=new l.constructor(o.length*c),h=0,p=0;for(let v=0,T=o.length;v<T;v++){if(a.isInterleavedBufferAttribute)h=o[v]*a.data.stride+a.offset;else h=o[v]*c;for(let m=0;m<c;m++)d[p++]=l[h++]}return new yn(d,c,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new mn,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],l=e(o,n);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let o=[],l=s[a];for(let c=0,u=l.length;c<u;c++){let d=l[c],h=e(d,n);o.push(h)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let a=0,o=r.length;a<o;a++){let l=r[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let l in o)if(o[l]!==void 0)e[l]=o[l];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let l=n[o];e.data.attributes[o]=l.toJSON(e.data)}let i={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],c=[];for(let u=0,d=l.length;u<d;u++){let h=l[u];c.push(h.toJSON(e.data))}if(c.length>0)i[o]=c,s=!0}if(s)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;if(r.length>0)e.data.groups=JSON.parse(JSON.stringify(r));let a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.toJSON();return 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;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let l in i){let c=i[l];this.setAttribute(l,c.clone(t))}let s=e.morphAttributes;for(let l in s){let c=[],u=s[l];for(let d=0,h=u.length;d<h;d++)c.push(u[d].clone(t));this.morphAttributes[l]=c}this.morphTargetsRelative=e.morphTargetsRelative;let r=e.groups;for(let l=0,c=r.length;l<c;l++){let u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=fi()}onUploadCallback(){}set needsUpdate(e){if(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){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let 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){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var an=new O;class Ps{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++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return 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];if(this.normalized)t=Fn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Fn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Fn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Fn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return 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){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),s=ft(s,this.array);return 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){Is("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new yn(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Ps(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Is("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let 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{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Ea=new O,Yu=new O,Zu=new ke;class Un{constructor(e=new O(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){let i=Ea.subVectors(n,t).cross(Yu.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let i=e.delta(Ea),s=this.normal.dot(i);if(s===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let r=-(e.start.dot(this.normal)+this.constant)/s;if(n===!0&&(r<0||r>1))return null;return t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){let 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){let n=t||Zu.getNormalMatrix(e),i=this.coplanarPoint(Ea).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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var Ju=0;class _i extends ti{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ju++}),this.uuid=fi(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Oe(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((s)=>s.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(s){let r=[];for(let a in s){let o=s[a];delete o.metadata,r.push(o)}return r}if(t){let s=i(e.textures),r=i(e.images);if(s.length>0)n.textures=s;if(r.length>0)n.images=r}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new We().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Un().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new ze().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}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;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=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.allowOverride=e.allowOverride,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){if(e===!0)this.version++}}class _s extends _i{constructor(e){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new We(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}}var is,Es=new O,ss=new O,rs=new O,as=new ze,As=new ze,ph=new yt,or=new O,Cs=new O,lr=new O,tc=new ze,Aa=new ze,nc=new ze;class Hs extends Xt{constructor(e=new _s){super();if(this.isSprite=!0,this.type="Sprite",is===void 0){is=new mn;let t=new Float32Array([-0.5,-0.5,0,0,0,0.5,-0.5,0,1,0,0.5,0.5,0,1,1,-0.5,0.5,0,0,1]),n=new Zo(t,5);is.setIndex([0,1,2,0,2,3]),is.setAttribute("position",new Ps(n,3,0,!1)),is.setAttribute("uv",new Ps(n,2,3,!1))}this.geometry=is,this.material=e,this.center=new ze(0.5,0.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){if(e.camera===null)Ue('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(ss.setFromMatrixScale(this.matrixWorld),ph.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),rs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)ss.multiplyScalar(-rs.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;cr(or.set(-0.5,-0.5,0),rs,r,ss,i,s),cr(Cs.set(0.5,-0.5,0),rs,r,ss,i,s),cr(lr.set(0.5,0.5,0),rs,r,ss,i,s),tc.set(0,0),Aa.set(1,0),nc.set(1,1);let a=e.ray.intersectTriangle(or,Cs,lr,!1,Es);if(a===null){if(cr(Cs.set(-0.5,0.5,0),rs,r,ss,i,s),Aa.set(0,1),a=e.ray.intersectTriangle(or,lr,Cs,!1,Es),a===null)return}let o=e.ray.origin.distanceTo(Es);if(o<e.near||o>e.far)return;t.push({distance:o,point:Es.clone(),uv:dn.getInterpolation(Es,or,Cs,lr,tc,Aa,nc,new ze),face:null,object:this})}copy(e,t){if(super.copy(e,t),e.center!==void 0)this.center.copy(e.center);return this.material=e.material,this}}function cr(e,t,n,i,s,r){if(as.subVectors(e,n).addScalar(0.5).multiply(i),s!==void 0)As.x=r*as.x-s*as.y,As.y=s*as.x+r*as.y;else As.copy(as);e.copy(t),e.x+=As.x,e.y+=As.y,e.applyMatrix4(ph)}var $n=new O,Ca=new O,ur=new O,dr=new O;class Vr{constructor(e=new O,t=new O(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,$n)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=$n.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return $n.copy(this.origin).addScaledVector(this.direction,t),$n.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Ca.copy(e).add(t).multiplyScalar(0.5),ur.copy(t).sub(e).normalize(),dr.copy(this.origin).sub(Ca);let s=e.distanceTo(t)*0.5,r=-this.direction.dot(ur),a=dr.dot(this.direction),o=-dr.dot(ur),l=dr.lengthSq(),c=Math.abs(1-r*r),u,d,h,p;if(c>0)if(u=r*o-a,d=r*a-o,p=s*c,u>=0)if(d>=-p)if(d<=p){let v=1/c;u*=v,d*=v,h=u*(u+r*d+2*a)+d*(r*u+d+2*o)+l}else d=s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else d=-s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else if(d<=-p)u=Math.max(0,-(-r*s+a)),d=u>0?-s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else if(d<=p)u=0,d=Math.min(Math.max(-s,-o),s),h=d*(d+2*o)+l;else u=Math.max(0,-(r*s+a)),d=u>0?s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else d=r>0?-s:s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Ca).addScaledVector(ur,d);return h}intersectSphere(e,t){if(e.radius<0)return null;$n.subVectors(e.center,this.origin);let n=$n.dot(this.direction),i=$n.dot($n)-n*n,s=e.radius*e.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,o=n+r;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,s,r,a,o,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(l>=0)n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l;else n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l;if(c>=0)s=(e.min.y-d.y)*c,r=(e.max.y-d.y)*c;else s=(e.max.y-d.y)*c,r=(e.min.y-d.y)*c;if(n>r||s>i)return null;if(s>n||isNaN(n))n=s;if(r<i||isNaN(i))i=r;if(u>=0)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,$n)!==null}intersectTriangle(e,t,n,i,s){let r=this.origin,a=this.direction,{x:o,y:l,z:c}=a,u=e.x-r.x,d=e.y-r.y,h=e.z-r.z,p=t.x-r.x,v=t.y-r.y,T=t.z-r.z,m=n.x-r.x,f=n.y-r.y,E=n.z-r.z,C=Math.abs(o),y=Math.abs(l),b=Math.abs(c),w,A,_,M,B,R,U,W,P,H,j,G;if(C>=y&&C>=b)if(_=o,R=u,P=p,G=m,o>=0)w=l,A=c,M=d,B=h,U=v,W=T,H=f,j=E;else w=c,A=l,M=h,B=d,U=T,W=v,H=E,j=f;else if(y>=b)if(_=l,R=d,P=v,G=f,l>=0)w=c,A=o,M=h,B=u,U=T,W=p,H=E,j=m;else w=o,A=c,M=u,B=h,U=p,W=T,H=m,j=E;else if(_=c,R=h,P=T,G=E,c>=0)w=o,A=l,M=u,B=d,U=p,W=v,H=m,j=f;else w=l,A=o,M=d,B=u,U=v,W=p,H=f,j=m;if(_===0)return null;let re=w/_,q=A/_,te=1/_,ee=M-re*R,me=B-q*R,we=U-re*P,He=W-q*P,Fe=H-re*G,Y=j-q*G,se=Fe*He-Y*we,ae=ee*Y-me*Fe,Re=we*me-He*ee;if(i){if(se<0||ae<0||Re<0)return null}else if((se<0||ae<0||Re<0)&&(se>0||ae>0||Re>0))return null;let Ie=se+ae+Re;if(Ie===0)return null;let De=te*(se*R+ae*P+Re*G);if(Ie>0?De<0:De>0)return null;return this.at(De/Ie,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 Ot extends _i{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 pi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.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}}var ic=new yt,Ti=new Vr,mr=new Gs,sc=new O,gr=new O,_r=new O,xr=new O,Ra=new O,yr=new O,rc=new O,Sr=new O;class Ge extends Xt{constructor(e=new mn,t=new Ot){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,r=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(s&&a){yr.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let c=a[o],u=s[o];if(c===0)continue;if(Ra.fromBufferAttribute(u,e),r)yr.addScaledVector(Ra,c);else yr.addScaledVector(Ra.sub(t),c)}t.add(yr)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(mr.copy(n.boundingSphere),mr.applyMatrix4(s),Ti.copy(e.ray).recast(e.near),mr.containsPoint(Ti.origin)===!1){if(Ti.intersectSphere(mr,sc)===null)return;if(Ti.origin.distanceToSquared(sc)>(e.far-e.near)**2)return}if(ic.copy(s).invert(),Ti.copy(e.ray).applyMatrix4(ic),n.boundingBox!==null){if(Ti.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ti)}_computeIntersections(e,t,n){let i,s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,{groups:d,drawRange:h}=s;if(a!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),E=Math.min(a.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=E;C<y;C+=3){let b=a.getX(C),w=a.getX(C+1),A=a.getX(C+2);if(i=Mr(this,m,e,n,l,c,u,b,w,A),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,t.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(a.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=a.getX(T),E=a.getX(T+1),C=a.getX(T+2);if(i=Mr(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),E=Math.min(o.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=E;C<y;C+=3){let b=C,w=C+1,A=C+2;if(i=Mr(this,m,e,n,l,c,u,b,w,A),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,t.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(o.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=T,E=T+1,C=T+2;if(i=Mr(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}}}function $u(e,t,n,i,s,r,a,o){let l;if(t.side===1)l=i.intersectTriangle(a,r,s,!0,o);else l=i.intersectTriangle(s,r,a,t.side===0,o);if(l===null)return null;Sr.copy(o),Sr.applyMatrix4(e.matrixWorld);let c=n.ray.origin.distanceTo(Sr);if(c<n.near||c>n.far)return null;return{distance:c,point:Sr.clone(),object:e}}function Mr(e,t,n,i,s,r,a,o,l,c){e.getVertexPosition(o,gr),e.getVertexPosition(l,_r),e.getVertexPosition(c,xr);let u=$u(e,t,n,i,gr,_r,xr,rc);if(u){let d=new O;if(dn.getBarycoord(rc,gr,_r,xr,d),s)u.uv=dn.getInterpolatedAttribute(s,o,l,c,d,new ze);if(r)u.uv1=dn.getInterpolatedAttribute(r,o,l,c,d,new ze);if(a){if(u.normal=dn.getInterpolatedAttribute(a,o,l,c,d,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a:o,b:l,c,normal:new O,materialIndex:0};dn.getNormal(gr,_r,xr,h.normal),u.face=h,u.barycoord=d}return u}class Vs extends Jt{constructor(e=null,t=1,n=1,i,s,r,a,o,l=1003,c=1003,u,d){super(null,r,a,o,l,c,i,s,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var wi=new Gs,Ku=new ze(0.5,0.5),br=new O;class Ws{constructor(e=new Un,t=new Un,n=new Un,i=new Un,s=new Un,r=new Un){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,s=e.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],u=s[5],d=s[6],h=s[7],p=s[8],v=s[9],T=s[10],m=s[11],f=s[12],E=s[13],C=s[14],y=s[15];if(i[0].setComponents(l-r,h-c,m-p,y-f).normalize(),i[1].setComponents(l+r,h+c,m+p,y+f).normalize(),i[2].setComponents(l+a,h+u,m+v,y+E).normalize(),i[3].setComponents(l-a,h-u,m-v,y-E).normalize(),n)i[4].setComponents(o,d,T,C).normalize(),i[5].setComponents(l-o,h-d,m-T,y-C).normalize();else if(i[4].setComponents(l-o,h-d,m-T,y-C).normalize(),t===2000)i[5].setComponents(l+o,h+d,m+T,y+C).normalize();else if(t===2001)i[5].setComponents(o,d,T,C).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();wi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(wi)}intersectsSprite(e){wi.center.set(0,0,0);let t=Ku.distanceTo(e.center);return wi.radius=0.7071067811865476+t,wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(wi)}intersectsSphere(e){let 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){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(br.x=i.normal.x>0?e.max.x:e.min.x,br.y=i.normal.y>0?e.max.y:e.min.y,br.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(br)<0)return!1}return!0}containsPoint(e){let 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)}}class Wr extends Jt{constructor(e=[],t=301,n,i,s,r,a,o,l,c){super(e,t,n,i,s,r,a,o,l,c);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class xi extends Jt{constructor(e,t,n,i,s,r,a,o,l){super(e,t,n,i,s,r,a,o,l);this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fi extends Jt{constructor(e,t,n=1014,i,s,r,a=1003,o=1003,l,c=1026,u=1){if(c!==1026&&c!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,s,r,a,o,c,n,l);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Os(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Jo extends Fi{constructor(e,t=1014,n=301,i,s,r=1003,a=1003,o,l=1026){let c={width:e,height:e,depth:1},u=[c,c,c,c,c,c];super(e,e,t,n,i,s,r,a,o,l);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Xr extends Jt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gn extends mn{constructor(e=1,t=1,n=1,i=1,s=1,r=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};let a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);let o=[],l=[],c=[],u=[],d=0,h=0;p("z","y","x",-1,-1,n,t,e,r,s,0),p("z","y","x",1,-1,n,t,-e,r,s,1),p("x","z","y",1,1,e,n,t,i,r,2),p("x","z","y",1,-1,e,n,-t,i,r,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(o),this.setAttribute("position",new $t(l,3)),this.setAttribute("normal",new $t(c,3)),this.setAttribute("uv",new $t(u,2));function p(v,T,m,f,E,C,y,b,w,A,_){let M=C/w,B=y/A,R=C/2,U=y/2,W=b/2,P=w+1,H=A+1,j=0,G=0,re=new O;for(let q=0;q<H;q++){let te=q*B-U;for(let ee=0;ee<P;ee++){let me=ee*M-R;re[v]=me*f,re[T]=te*E,re[m]=W,l.push(re.x,re.y,re.z),re[v]=0,re[T]=0,re[m]=b>0?1:-1,c.push(re.x,re.y,re.z),u.push(ee/w),u.push(1-q/A),j+=1}}for(let q=0;q<A;q++)for(let te=0;te<w;te++){let ee=d+te+P*q,me=d+te+P*(q+1),we=d+(te+1)+P*(q+1),He=d+(te+1)+P*q;o.push(ee,me,He),o.push(me,we,He),G+=6}a.addGroup(h,G,_),h+=G,d+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class xs extends mn{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);let s=[],r=[],a=[],o=[],l=new O,c=new ze;r.push(0,0,0),a.push(0,0,1),o.push(0.5,0.5);for(let u=0,d=3;u<=t;u++,d+=3){let h=n+u/t*i;l.x=e*Math.cos(h),l.y=e*Math.sin(h),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[d]/e+1)/2,c.y=(r[d+1]/e+1)/2,o.push(c.x,c.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new $t(r,3)),this.setAttribute("normal",new $t(a,3)),this.setAttribute("uv",new $t(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xs(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class gn extends mn{constructor(e=1,t=1,n=1,i=32,s=1,r=!1,a=0,o=Math.PI*2){super();this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};let l=this;i=Math.floor(i),s=Math.floor(s);let c=[],u=[],d=[],h=[],p=0,v=[],T=n/2,m=0;if(f(),r===!1){if(e>0)E(!0);if(t>0)E(!1)}this.setIndex(c),this.setAttribute("position",new $t(u,3)),this.setAttribute("normal",new $t(d,3)),this.setAttribute("uv",new $t(h,2));function f(){let C=new O,y=new O,b=0,w=(t-e)/n;for(let A=0;A<=s;A++){let _=[],M=A/s,B=M*(t-e)+e;for(let R=0;R<=i;R++){let U=R/i,W=U*o+a,P=Math.sin(W),H=Math.cos(W);y.x=B*P,y.y=-M*n+T,y.z=B*H,u.push(y.x,y.y,y.z),C.set(P,w,H).normalize(),d.push(C.x,C.y,C.z),h.push(U,1-M),_.push(p++)}v.push(_)}for(let A=0;A<i;A++)for(let _=0;_<s;_++){let M=v[_][A],B=v[_+1][A],R=v[_+1][A+1],U=v[_][A+1];if(e>0||_!==0)c.push(M,B,U),b+=3;if(t>0||_!==s-1)c.push(B,R,U),b+=3}l.addGroup(m,b,0),m+=b}function E(C){let y=p,b=new ze,w=new O,A=0,_=C===!0?e:t,M=C===!0?1:-1;for(let R=1;R<=i;R++)u.push(0,T*M,0),d.push(0,M,0),h.push(0.5,0.5),p++;let B=p;for(let R=0;R<=i;R++){let W=R/i*o+a,P=Math.cos(W),H=Math.sin(W);w.x=_*H,w.y=T*M,w.z=_*P,u.push(w.x,w.y,w.z),d.push(0,M,0),b.x=P*0.5+0.5,b.y=H*0.5*M+0.5,h.push(b.x,b.y),p++}for(let R=0;R<i;R++){let U=y+R,W=B+R;if(C===!0)c.push(W,W+1,U);else c.push(W+1,W,U);A+=3}l.addGroup(m,A,C===!0?1:2),m+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class At extends mn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,r=t/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=e/a,d=t/o,h=[],p=[],v=[],T=[];for(let m=0;m<c;m++){let f=m*d-r;for(let E=0;E<l;E++){let C=E*u-s;p.push(C,-f,0),v.push(0,0,1),T.push(E/a),T.push(1-m/o)}}for(let m=0;m<o;m++)for(let f=0;f<a;f++){let E=f+l*m,C=f+l*(m+1),y=f+1+l*(m+1),b=f+1+l*m;h.push(E,C,b),h.push(C,y,b)}this.setIndex(h),this.setAttribute("position",new $t(p,3)),this.setAttribute("normal",new $t(v,3)),this.setAttribute("uv",new $t(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new At(e.width,e.height,e.widthSegments,e.heightSegments)}}function Oi(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let s=e[n][i];if(ac(s))if(s.isRenderTargetTexture)Oe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=s.clone();else if(Array.isArray(s))if(ac(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[n][i]=r}else t[n][i]=s.slice();else t[n][i]=s}}return t}function tn(e){let t={};for(let n=0;n<e.length;n++){let i=Oi(e[n]);for(let s in i)t[s]=i[s]}return t}function ac(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Qu(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Ko(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var mh={clone:Oi,merge:tn},ju=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,ed=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`;class Sn extends _i{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ju,this.fragmentShader=ed,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=Bi(e.uniforms),this.uniformsGroups=Qu(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let r=this.uniforms[i].value;if(r&&r.isTexture)t.uniforms[i]={type:"t",value:r.toJSON(e).uuid};else if(r&&r.isColor)t.uniforms[i]={type:"c",value:r.getHex()};else if(r&&r.isVector2)t.uniforms[i]={type:"v2",value:r.toArray()};else if(r&&r.isVector3)t.uniforms[i]={type:"v3",value:r.toArray()};else if(r&&r.isVector4)t.uniforms[i]={type:"v4",value:r.toArray()};else if(r&&r.isMatrix3)t.uniforms[i]={type:"m3",value:r.toArray()};else if(r&&r.isMatrix4)t.uniforms[i]={type:"m4",value:r.toArray()};else t.uniforms[i]={value:r}}if(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;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new We().setHex(i.value);break;case"v2":this.uniforms[n].value=new ze().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Et().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ke().fromArray(i.value);break;case"m4":this.uniforms[n].value=new yt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class jo extends Sn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class si extends _i{constructor(e){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new We(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ze(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 el extends _i{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 tl extends _i{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}}function Ss(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Xa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}class zi{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){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let r;t:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}r=t.length;break t}if(!(e>=s)){let a=t[1];if(e<a)n=2,s=a;for(let o=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=s,s=t[--n-1],e>=s)break e}r=n,n=0;break t}break n}while(n<r){let a=n+r>>>1;if(e<t[a])r=a;else n=a+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){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let r=0;r!==i;++r)t[r]=n[s+r];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class nl extends zi{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:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,r=e+1,a=i[s],o=i[r];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:s=e,a=2*t-n;break;case 2402:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:r=e,o=2*n-t;break;case 2402:r=1,o=n+i[1]-i[0];break;default:r=e-1,o=t}let l=(n-t)*0.5,c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(i-t),v=p*p,T=v*p,m=-d*T+2*d*v-d*p,f=(1+d)*T+(-1.5-2*d)*v+(-0.5+d)*p+1,E=(-1-h)*T+(1.5+h)*v+0.5*p,C=h*T-h*v;for(let y=0;y!==a;++y)s[y]=m*r[c+y]+f*r[l+y]+E*r[o+y]+C*r[u+y];return s}}class il extends zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=(n-t)/(i-t),u=1-c;for(let d=0;d!==a;++d)s[d]=r[l+d]*u+r[o+d]*c;return s}}class sl extends zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class rl extends zi{interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this.inTangents,u=this.outTangents;if(!c||!u){let p=(n-t)/(i-t),v=1-p;for(let T=0;T!==a;++T)s[T]=r[l+T]*v+r[o+T]*p;return s}let d=a*2,h=e-1;for(let p=0;p!==a;++p){let v=r[l+p],T=r[o+p],m=h*d+p*2,f=u[m],E=u[m+1],C=e*d+p*2,y=c[C],b=c[C+1],w=nd(n,t,f,y,i);s[p]=gh(w,v,E,b,T)}return s}}function gh(e,t,n,i,s){let r=1-e;return r*r*r*t+3*r*r*e*n+3*r*e*e*i+e*e*e*s}function td(e,t,n,i,s){let r=1-e;return 3*r*r*(n-t)+6*r*e*(i-n)+3*e*e*(s-i)}function nd(e,t,n,i,s){let r=(e-t)/(s-t);for(let a=0;a<8;a++){let o=gh(r,t,n,i,s)-e;if(Math.abs(o)<0.0000000001)break;let l=td(r,t,n,i,s);if(Math.abs(l)<0.0000000001)break;r=Math.max(0,Math.min(1,r-o/l))}return r}class Mn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ss(t,this.TimeBufferType),this.values=Ss(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ss(e.times,Array),values:Ss(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Xa(e.settings))n.settings={inTangents:Ss(e.settings.inTangents,Array),outTangents:Ss(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new sl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new il(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new nl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new rl(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let 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 Error(n);return Oe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Xa(this.settings))oc(this.settings.inTangents,e),oc(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,s=0,r=i-1;while(s!==i&&n[s]<e)++s;while(r!==-1&&n[r]>t)--r;if(++r,s!==0||r!==i){if(s>=r)r=Math.max(r,1),s=r-1;let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let r=null;for(let a=0;a!==s;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ue("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(r!==null&&r>o){Ue("KeyframeTrack: Out of order keys.",this,a,o,r),e=!1;break}r=o}if(i!==void 0){if(Lu(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Ue("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,s=e.length-1,r=1;for(let a=1;a<s;++a){let o=!1,l=e[a],c=e[a+1];if(l!==c&&(a!==1||l!==e[0]))if(!i){let u=a*n,d=u-n,h=u+n;for(let p=0;p!==n;++p){let v=t[u+p];if(v!==t[d+p]||v!==t[h+p]){o=!0;break}}}else o=!0;if(o){if(a!==r){e[r]=e[a];let u=a*n,d=r*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++r}}if(s>0){e[r]=e[s];for(let a=s*n,o=r*n,l=0;l!==n;++l)t[o+l]=t[a+l];++r}if(r!==e.length)this.times=e.slice(0,r),this.values=t.slice(0,r*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Xa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function oc(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Mn.prototype.ValueTypeName="";Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=2301;class ki extends Mn{constructor(e,t,n){super(e,t,n)}}ki.prototype.ValueTypeName="bool";ki.prototype.ValueBufferType=Array;ki.prototype.DefaultInterpolation=2300;ki.prototype.InterpolantFactoryMethodLinear=void 0;ki.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="color";class ol extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}ol.prototype.ValueTypeName="number";class ll extends zi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),l=e*a;for(let c=l+a;l!==c;l+=4)ii.slerpFlat(s,0,r,l-a,r,l,o);return s}}class oa extends Mn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new ll(this.times,this.values,this.getValueSize(),e)}}oa.prototype.ValueTypeName="quaternion";oa.prototype.InterpolantFactoryMethodSmooth=void 0;class Gi extends Mn{constructor(e,t,n){super(e,t,n)}}Gi.prototype.ValueTypeName="string";Gi.prototype.ValueBufferType=Array;Gi.prototype.DefaultInterpolation=2300;Gi.prototype.InterpolantFactoryMethodLinear=void 0;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;class cl extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}cl.prototype.ValueTypeName="vector";class hl{constructor(e,t,n){let i=this,s=!1,r=0,a=0,o=void 0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(c){if(a++,s===!1){if(i.onStart!==void 0)i.onStart(c,r,a)}s=!0},this.itemEnd=function(c){if(r++,i.onProgress!==void 0)i.onProgress(c,r,a);if(r===a){if(s=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(c){if(i.onError!==void 0)i.onError(c)},this.resolveURL=function(c){if(c=c.normalize("NFC"),o)return o(c);return c},this.setURLModifier=function(c){return o=c,this},this.addHandler=function(c,u){return l.push(c,u),this},this.removeHandler=function(c){let u=l.indexOf(c);if(u!==-1)l.splice(u,2);return this},this.getHandler=function(c){for(let u=0,d=l.length;u<d;u+=2){let h=l[u],p=l[u+1];if(h.global)h.lastIndex=0;if(h.test(c))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var _h=new hl;class ul{constructor(e){if(this.manager=e!==void 0?e:_h,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let 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}abort(){return this}}ul.DEFAULT_MATERIAL_NAME="__DEFAULT";class la extends Ht{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new We(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}var qa=new yt,lc=new O,cc=new O;class dl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ze(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new yt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rr,this._frameExtents=new ze(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;lc.setFromMatrixPosition(e.matrixWorld),t.position.copy(lc),cc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){qa.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(qa,e.coordinateSystem,e.reversedDepth);let s=this._frameExtents,r=i?i.z/s.x:1,a=i?i.w/s.y:1,o=i?i.x/s.x:0,l=i?i.y/s.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,1,0,0,0,0,1);else t.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,0.5,0.5,0,0,0,1);t.multiply(qa)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(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.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var zr=new O,kr=new ii,Dn=new O;class ca extends Ht{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yt,this.projectionMatrix=new yt,this.projectionMatrixInverse=new yt,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(zr,kr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(zr,kr,Dn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(zr,kr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(zr,kr,Dn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var di=new O,hc=new ze,uc=new ze;class ln extends ca{constructor(e=50,t=1,n=0.1,i=2000){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){let t=0.5*this.getFilmHeight()/e;this.fov=Gr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ba*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Gr*2*Math.atan(Math.tan(ba*0.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){di.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(di.x,di.y).multiplyScalar(-e/di.z),di.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(di.x,di.y).multiplyScalar(-e/di.z)}getViewSize(e,t){return this.getViewBounds(e,hc,uc),t.subVectors(uc,hc)}setViewOffset(e,t,n,i,s,r){if(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=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ba*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-0.5*i,r=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:l}=r;s+=r.offsetX*i/o,t-=r.offsetY*n/l,i*=r.width/o,n*=r.height/l}let a=this.filmOffset;if(a!==0)s+=e*a/this.getFilmWidth();this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class or extends ca{constructor(e=-1,t=1,n=1,i=-1,s=0.1,r=2000){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=r,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,r){if(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=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let 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,s=n-e,r=n+e,a=i+t,o=i-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,a-=c*this.view.offsetY,o=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class xh extends dl{constructor(){super(new or(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ha extends la{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ht.DEFAULT_UP),this.updateMatrix(),this.target=new Ht,this.shadow=new xh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class ua extends la{constructor(e,t){super(e,t);this.isAmbientLight=!0,this.type="AmbientLight"}}var Ms=-90,bs=1;class fl extends Ht{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new ln(Ms,bs,e,t);i.layers=this.layers,this.add(i);let s=new ln(Ms,bs,e,t);s.layers=this.layers,this.add(s);let r=new ln(Ms,bs,e,t);r.layers=this.layers,this.add(r);let a=new ln(Ms,bs,e,t);a.layers=this.layers,this.add(a);let o=new ln(Ms,bs,e,t);o.layers=this.layers,this.add(o);let l=new ln(Ms,bs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,s,r,a,o]=t;for(let l of t)this.remove(l);if(e===2000)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),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===2001)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),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[s,r,a,o,l,c]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let T=!1;if(e.isWebGLRenderer===!0)T=e.state.buffers.depth.getReversed();else T=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,1,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,2,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),T&&e.autoClear===!1)e.clearDepth();e.render(t,c),e.setRenderTarget(u,d,h),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class pl extends ln{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}var ml="\\[\\]\\.:\\/",id=new RegExp("["+ml+"]","g"),gl="[^"+ml+"]",sd="[^"+ml.replace("\\.","")+"]",rd=/((?:WC+[\/:])*)/.source.replace("WC",gl),ad=/(WCOD+)?/.source.replace("WCOD",sd),od=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gl),ld=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gl),cd=new RegExp("^"+rd+ad+od+ld+"$"),hd=["material","materials","bones","map"];class vh{constructor(e,t,n){let i=n||ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ut{constructor(e,t,n){this.path=t,this.parsedPath=n||ut.parseTrackName(t),this.node=ut.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ut(e,t,n);else return new ut.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(id,"")}static parseTrackName(e){let t=cd.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let 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){let s=n.nodeName.substring(i+1);if(hd.indexOf(s)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=s}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let r=0;r<s.length;r++){let a=s[r];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}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){let 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){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let 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){let 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,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:s}=t;if(!e)e=ut.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Oe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("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){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===l){l=c;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("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){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let r=e[i];if(r===void 0){let l=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[s]!==void 0)s=e.morphTargetDictionary[s]}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else if(r.fromArray!==void 0&&r.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=r;else if(Array.isArray(r))o=this.BindingType.EntireArray,this.resolvedProperty=r;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ut.Composite=vh;ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ut.prototype.GetterByBindingType=[ut.prototype._getValue_direct,ut.prototype._getValue_array,ut.prototype._getValue_arrayElement,ut.prototype._getValue_toArray];ut.prototype.SetterByBindingTypeAndVersioning=[[ut.prototype._setValue_direct,ut.prototype._setValue_direct_setNeedsUpdate,ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_array,ut.prototype._setValue_array_setNeedsUpdate,ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_arrayElement,ut.prototype._setValue_arrayElement_setNeedsUpdate,ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_fromArray,ut.prototype._setValue_fromArray_setNeedsUpdate,ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var b0=new Float32Array(1);var dc=new yt;class da{constructor(e,t,n=0,i=1/0){this.ray=new sa(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new js,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){if(t.isPerspectiveCamera)this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,0.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t;else if(t.isOrthographicCamera)this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t;else Ue("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return dc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(dc),this}intersectObject(e,t=!0,n=[]){return Ya(e,this,n,t),n.sort(fc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Ya(e[i],this,n,t);return n.sort(fc),n}}function fc(e,t){return e.distance-t.distance}function Ya(e,t,n,i){let s=!0;if(e.layers.test(t.layers)){if(e.raycast(t,n)===!1)s=!1}if(s===!0&&i===!0){let r=e.children;for(let a=0,o=r.length;a<o;a++)Ya(r[a],t,n,!0)}}class _l{static{_l.prototype.isMatrix2=!0}constructor(e,t,n,i){if(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){let s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=i,this}}function xl(e,t,n,i){let s=ud(i);switch(n){case 1021:return e*t;case 1028:return e*t/s.components*s.byteLength;case 1029:return e*t/s.components*s.byteLength;case 1030:return e*t*2/s.components*s.byteLength;case 1031:return e*t*2/s.components*s.byteLength;case 1022:return e*t*3/s.components*s.byteLength;case 1023:return e*t*4/s.components*s.byteLength;case 1033:return e*t*4/s.components*s.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function ud(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Oe("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Gh(){let e=null,t=!1,n=null,i=null;function s(r,a){i=e.requestAnimationFrame(s),n(r,a)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(s),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(r){n=r},setContext:function(r){e=r}}}function dd(e){let t=new WeakMap;function n(o,l){let{array:c,usage:u}=o,d=c.byteLength,h=e.createBuffer();e.bindBuffer(l,h),e.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=e.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=e.HALF_FLOAT;else if(c instanceof Uint16Array)if(o.isFloat16BufferAttribute)p=e.HALF_FLOAT;else p=e.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=e.SHORT;else if(c instanceof Uint32Array)p=e.UNSIGNED_INT;else if(c instanceof Int32Array)p=e.INT;else if(c instanceof Int8Array)p=e.BYTE;else if(c instanceof Uint8Array)p=e.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){let{array:u,updateRanges:d}=l;if(e.bindBuffer(c,o),d.length===0)e.bufferSubData(c,0,u);else{d.sort((p,v)=>p.start-v.start);let h=0;for(let p=1;p<d.length;p++){let v=d[h],T=d[p];if(T.start<=v.start+v.count+1)v.count=Math.max(v.count,T.start+T.count-v.start);else++h,d[h]=T}d.length=h+1;for(let p=0,v=d.length;p<v;p++){let T=d[p];e.bufferSubData(c,T.start*u.BYTES_PER_ELEMENT,u,T.start,T.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;let l=t.get(o);if(l)e.deleteBuffer(l.buffer),t.delete(o)}function a(o,l){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=t.get(o);if(c===void 0)t.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var fd=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`;class Sn extends _i{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ju,this.fragmentShader=ed,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=Oi(e.uniforms),this.uniformsGroups=Qu(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let r=this.uniforms[i].value;if(r&&r.isTexture)t.uniforms[i]={type:"t",value:r.toJSON(e).uuid};else if(r&&r.isColor)t.uniforms[i]={type:"c",value:r.getHex()};else if(r&&r.isVector2)t.uniforms[i]={type:"v2",value:r.toArray()};else if(r&&r.isVector3)t.uniforms[i]={type:"v3",value:r.toArray()};else if(r&&r.isVector4)t.uniforms[i]={type:"v4",value:r.toArray()};else if(r&&r.isMatrix3)t.uniforms[i]={type:"m3",value:r.toArray()};else if(r&&r.isMatrix4)t.uniforms[i]={type:"m4",value:r.toArray()};else t.uniforms[i]={value:r}}if(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;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new We().setHex(i.value);break;case"v2":this.uniforms[n].value=new ze().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new wt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ke().fromArray(i.value);break;case"m4":this.uniforms[n].value=new yt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class jo extends Sn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class si extends _i{constructor(e){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new We(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ze(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 el extends _i{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 tl extends _i{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}}function os(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function Ia(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}class Bi{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){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let r;t:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}r=t.length;break t}if(!(e>=s)){let a=t[1];if(e<a)n=2,s=a;for(let o=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=s,s=t[--n-1],e>=s)break e}r=n,n=0;break t}break n}while(n<r){let a=n+r>>>1;if(e<t[a])r=a;else n=a+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){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let r=0;r!==i;++r)t[r]=n[s+r];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class nl extends Bi{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:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,r=e+1,a=i[s],o=i[r];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:s=e,a=2*t-n;break;case 2402:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:r=e,o=2*n-t;break;case 2402:r=1,o=n+i[1]-i[0];break;default:r=e-1,o=t}let l=(n-t)*0.5,c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(i-t),v=p*p,T=v*p,m=-d*T+2*d*v-d*p,f=(1+d)*T+(-1.5-2*d)*v+(-0.5+d)*p+1,E=(-1-h)*T+(1.5+h)*v+0.5*p,C=h*T-h*v;for(let y=0;y!==a;++y)s[y]=m*r[c+y]+f*r[l+y]+E*r[o+y]+C*r[u+y];return s}}class il extends Bi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=(n-t)/(i-t),u=1-c;for(let d=0;d!==a;++d)s[d]=r[l+d]*u+r[o+d]*c;return s}}class sl extends Bi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class rl extends Bi{interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,c=this.inTangents,u=this.outTangents;if(!c||!u){let p=(n-t)/(i-t),v=1-p;for(let T=0;T!==a;++T)s[T]=r[l+T]*v+r[o+T]*p;return s}let d=a*2,h=e-1;for(let p=0;p!==a;++p){let v=r[l+p],T=r[o+p],m=h*d+p*2,f=u[m],E=u[m+1],C=e*d+p*2,y=c[C],b=c[C+1],w=nd(n,t,f,y,i);s[p]=gh(w,v,E,b,T)}return s}}function gh(e,t,n,i,s){let r=1-e;return r*r*r*t+3*r*r*e*n+3*r*e*e*i+e*e*e*s}function td(e,t,n,i,s){let r=1-e;return 3*r*r*(n-t)+6*r*e*(i-n)+3*e*e*(s-i)}function nd(e,t,n,i,s){let r=(e-t)/(s-t);for(let a=0;a<8;a++){let o=gh(r,t,n,i,s)-e;if(Math.abs(o)<0.0000000001)break;let l=td(r,t,n,i,s);if(Math.abs(l)<0.0000000001)break;r=Math.max(0,Math.min(1,r-o/l))}return r}class bn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=os(t,this.TimeBufferType),this.values=os(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:os(e.times,Array),values:os(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Ia(e.settings))n.settings={inTangents:os(e.settings.inTangents,Array),outTangents:os(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new sl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new il(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new nl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new rl(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let 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 Error(n);return Oe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(Ia(this.settings))oc(this.settings.inTangents,e),oc(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,s=0,r=i-1;while(s!==i&&n[s]<e)++s;while(r!==-1&&n[r]>t)--r;if(++r,s!==0||r!==i){if(s>=r)r=Math.max(r,1),s=r-1;let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let r=null;for(let a=0;a!==s;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ue("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(r!==null&&r>o){Ue("KeyframeTrack: Out of order keys.",this,a,o,r),e=!1;break}r=o}if(i!==void 0){if(Lu(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Ue("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,s=e.length-1,r=1;for(let a=1;a<s;++a){let o=!1,l=e[a],c=e[a+1];if(l!==c&&(a!==1||l!==e[0]))if(!i){let u=a*n,d=u-n,h=u+n;for(let p=0;p!==n;++p){let v=t[u+p];if(v!==t[d+p]||v!==t[h+p]){o=!0;break}}}else o=!0;if(o){if(a!==r){e[r]=e[a];let u=a*n,d=r*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++r}}if(s>0){e[r]=e[s];for(let a=s*n,o=r*n,l=0;l!==n;++l)t[o+l]=t[a+l];++r}if(r!==e.length)this.times=e.slice(0,r),this.values=t.slice(0,r*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Ia(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function oc(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}bn.prototype.ValueTypeName="";bn.prototype.TimeBufferType=Float32Array;bn.prototype.ValueBufferType=Float32Array;bn.prototype.DefaultInterpolation=2301;class zi extends bn{constructor(e,t,n){super(e,t,n)}}zi.prototype.ValueTypeName="bool";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=2300;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends bn{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="color";class ol extends bn{constructor(e,t,n,i){super(e,t,n,i)}}ol.prototype.ValueTypeName="number";class ll extends Bi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),l=e*a;for(let c=l+a;l!==c;l+=4)ii.slerpFlat(s,0,r,l-a,r,l,o);return s}}class qr extends bn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new ll(this.times,this.values,this.getValueSize(),e)}}qr.prototype.ValueTypeName="quaternion";qr.prototype.InterpolantFactoryMethodSmooth=void 0;class ki extends bn{constructor(e,t,n){super(e,t,n)}}ki.prototype.ValueTypeName="string";ki.prototype.ValueBufferType=Array;ki.prototype.DefaultInterpolation=2300;ki.prototype.InterpolantFactoryMethodLinear=void 0;ki.prototype.InterpolantFactoryMethodSmooth=void 0;class cl extends bn{constructor(e,t,n,i){super(e,t,n,i)}}cl.prototype.ValueTypeName="vector";class hl{constructor(e,t,n){let i=this,s=!1,r=0,a=0,o=void 0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(c){if(a++,s===!1){if(i.onStart!==void 0)i.onStart(c,r,a)}s=!0},this.itemEnd=function(c){if(r++,i.onProgress!==void 0)i.onProgress(c,r,a);if(r===a){if(s=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(c){if(i.onError!==void 0)i.onError(c)},this.resolveURL=function(c){if(c=c.normalize("NFC"),o)return o(c);return c},this.setURLModifier=function(c){return o=c,this},this.addHandler=function(c,u){return l.push(c,u),this},this.removeHandler=function(c){let u=l.indexOf(c);if(u!==-1)l.splice(u,2);return this},this.getHandler=function(c){for(let u=0,d=l.length;u<d;u+=2){let h=l[u],p=l[u+1];if(h.global)h.lastIndex=0;if(h.test(c))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var _h=new hl;class ul{constructor(e){if(this.manager=e!==void 0?e:_h,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let 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}abort(){return this}}ul.DEFAULT_MATERIAL_NAME="__DEFAULT";class Yr extends Xt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new We(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}var Pa=new yt,lc=new O,cc=new O;class dl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ze(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new yt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ws,this._frameExtents=new ze(1,1),this._viewportCount=1,this._viewports=[new wt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;lc.setFromMatrixPosition(e.matrixWorld),t.position.copy(lc),cc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Pa.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Pa,e.coordinateSystem,e.reversedDepth);let s=this._frameExtents,r=i?i.z/s.x:1,a=i?i.w/s.y:1,o=i?i.x/s.x:0,l=i?i.y/s.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,1,0,0,0,0,1);else t.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,0.5,0.5,0,0,0,1);t.multiply(Pa)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(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.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}var Tr=new O,wr=new ii,Dn=new O;class Zr extends Xt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yt,this.projectionMatrix=new yt,this.projectionMatrixInverse=new yt,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Tr,wr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Tr,wr,Dn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Tr,wr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Tr,wr,Dn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var di=new O,hc=new ze,uc=new ze;class ln extends Zr{constructor(e=50,t=1,n=0.1,i=2000){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){let t=0.5*this.getFilmHeight()/e;this.fov=Er*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(la*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Er*2*Math.atan(Math.tan(la*0.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){di.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(di.x,di.y).multiplyScalar(-e/di.z),di.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(di.x,di.y).multiplyScalar(-e/di.z)}getViewSize(e,t){return this.getViewBounds(e,hc,uc),t.subVectors(uc,hc)}setViewOffset(e,t,n,i,s,r){if(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=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(la*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-0.5*i,r=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:l}=r;s+=r.offsetX*i/o,t-=r.offsetY*n/l,i*=r.width/o,n*=r.height/l}let a=this.filmOffset;if(a!==0)s+=e*a/this.getFilmWidth();this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Xs extends Zr{constructor(e=-1,t=1,n=1,i=-1,s=0.1,r=2000){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=r,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,r){if(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=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let 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,s=n-e,r=n+e,a=i+t,o=i-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,a-=c*this.view.offsetY,o=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(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);return t}}class xh extends dl{constructor(){super(new Xs(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Jr extends Yr{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Xt.DEFAULT_UP),this.updateMatrix(),this.target=new Xt,this.shadow=new xh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class $r extends Yr{constructor(e,t){super(e,t);this.isAmbientLight=!0,this.type="AmbientLight"}}var ls=-90,cs=1;class fl extends Xt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new ln(ls,cs,e,t);i.layers=this.layers,this.add(i);let s=new ln(ls,cs,e,t);s.layers=this.layers,this.add(s);let r=new ln(ls,cs,e,t);r.layers=this.layers,this.add(r);let a=new ln(ls,cs,e,t);a.layers=this.layers,this.add(a);let o=new ln(ls,cs,e,t);o.layers=this.layers,this.add(o);let l=new ln(ls,cs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,s,r,a,o]=t;for(let l of t)this.remove(l);if(e===2000)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),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===2001)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),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[s,r,a,o,l,c]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let T=!1;if(e.isWebGLRenderer===!0)T=e.state.buffers.depth.getReversed();else T=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,1,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,2,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),T&&e.autoClear===!1)e.clearDepth();if(e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),T&&e.autoClear===!1)e.clearDepth();e.render(t,c),e.setRenderTarget(u,d,h),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class pl extends ln{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}var ml="\\[\\]\\.:\\/",id=new RegExp("["+ml+"]","g"),gl="[^"+ml+"]",sd="[^"+ml.replace("\\.","")+"]",rd=/((?:WC+[\/:])*)/.source.replace("WC",gl),ad=/(WCOD+)?/.source.replace("WCOD",sd),od=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gl),ld=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gl),cd=new RegExp("^"+rd+ad+od+ld+"$"),hd=["material","materials","bones","map"];class vh{constructor(e,t,n){let i=n||ht.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ht{constructor(e,t,n){this.path=t,this.parsedPath=n||ht.parseTrackName(t),this.node=ht.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ht(e,t,n);else return new ht.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(id,"")}static parseTrackName(e){let t=cd.exec(e);if(t===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let 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){let s=n.nodeName.substring(i+1);if(hd.indexOf(s)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=s}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let r=0;r<s.length;r++){let a=s[r];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}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){let 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){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let 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){let 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,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:s}=t;if(!e)e=ht.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Oe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("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){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===l){l=c;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("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){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let r=e[i];if(r===void 0){let l=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[s]!==void 0)s=e.morphTargetDictionary[s]}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else if(r.fromArray!==void 0&&r.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=r;else if(Array.isArray(r))o=this.BindingType.EntireArray,this.resolvedProperty=r;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ht.Composite=vh;ht.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ht.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ht.prototype.GetterByBindingType=[ht.prototype._getValue_direct,ht.prototype._getValue_array,ht.prototype._getValue_arrayElement,ht.prototype._getValue_toArray];ht.prototype.SetterByBindingTypeAndVersioning=[[ht.prototype._setValue_direct,ht.prototype._setValue_direct_setNeedsUpdate,ht.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_array,ht.prototype._setValue_array_setNeedsUpdate,ht.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_arrayElement,ht.prototype._setValue_arrayElement_setNeedsUpdate,ht.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_fromArray,ht.prototype._setValue_fromArray_setNeedsUpdate,ht.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var b0=new Float32Array(1);var dc=new yt;class Kr{constructor(e,t,n=0,i=1/0){this.ray=new Vr(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Bs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){if(t.isPerspectiveCamera)this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,0.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t;else if(t.isOrthographicCamera)this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t;else Ue("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return dc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(dc),this}intersectObject(e,t=!0,n=[]){return La(e,this,n,t),n.sort(fc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)La(e[i],this,n,t);return n.sort(fc),n}}function fc(e,t){return e.distance-t.distance}function La(e,t,n,i){let s=!0;if(e.layers.test(t.layers)){if(e.raycast(t,n)===!1)s=!1}if(s===!0&&i===!0){let r=e.children;for(let a=0,o=r.length;a<o;a++)La(r[a],t,n,!0)}}class _l{static{_l.prototype.isMatrix2=!0}constructor(e,t,n,i){if(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){let s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=i,this}}function xl(e,t,n,i){let s=ud(i);switch(n){case 1021:return e*t;case 1028:return e*t/s.components*s.byteLength;case 1029:return e*t/s.components*s.byteLength;case 1030:return e*t*2/s.components*s.byteLength;case 1031:return e*t*2/s.components*s.byteLength;case 1022:return e*t*3/s.components*s.byteLength;case 1023:return e*t*4/s.components*s.byteLength;case 1033:return e*t*4/s.components*s.byteLength;case 33776:case 33777:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8;case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function ud(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Oe("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Gh(){let e=null,t=!1,n=null,i=null;function s(r,a){i=e.requestAnimationFrame(s),n(r,a)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(s),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(r){n=r},setContext:function(r){e=r}}}function dd(e){let t=new WeakMap;function n(o,l){let{array:c,usage:u}=o,d=c.byteLength,h=e.createBuffer();e.bindBuffer(l,h),e.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=e.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=e.HALF_FLOAT;else if(c instanceof Uint16Array)if(o.isFloat16BufferAttribute)p=e.HALF_FLOAT;else p=e.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=e.SHORT;else if(c instanceof Uint32Array)p=e.UNSIGNED_INT;else if(c instanceof Int32Array)p=e.INT;else if(c instanceof Int8Array)p=e.BYTE;else if(c instanceof Uint8Array)p=e.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){let{array:u,updateRanges:d}=l;if(e.bindBuffer(c,o),d.length===0)e.bufferSubData(c,0,u);else{d.sort((p,v)=>p.start-v.start);let h=0;for(let p=1;p<d.length;p++){let v=d[h],T=d[p];if(T.start<=v.start+v.count+1)v.count=Math.max(v.count,T.start+T.count-v.start);else++h,d[h]=T}d.length=h+1;for(let p=0,v=d.length;p<v;p++){let T=d[p];e.bufferSubData(c,T.start*u.BYTES_PER_ELEMENT,u,T.start,T.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;let l=t.get(o);if(l)e.deleteBuffer(l.buffer),t.delete(o)}function a(o,l){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=t.get(o);if(c===void 0)t.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var fd=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
7
|
#endif`,pd=`#ifdef USE_ALPHAHASH
|
|
8
8
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3820,7 +3820,7 @@ void main() {
|
|
|
3820
3820
|
#include <tonemapping_fragment>
|
|
3821
3821
|
#include <colorspace_fragment>
|
|
3822
3822
|
#include <fog_fragment>
|
|
3823
|
-
}`,qe={alphahash_fragment:fd,alphahash_pars_fragment:pd,alphamap_fragment:md,alphamap_pars_fragment:gd,alphatest_fragment:_d,alphatest_pars_fragment:xd,aomap_fragment:vd,aomap_pars_fragment:yd,batching_pars_vertex:Sd,batching_vertex:Md,begin_vertex:bd,beginnormal_vertex:Td,bsdfs:wd,iridescence_fragment:Ed,bumpmap_pars_fragment:Ad,clipping_planes_fragment:Cd,clipping_planes_pars_fragment:Rd,clipping_planes_pars_vertex:Id,clipping_planes_vertex:Pd,color_fragment:Ld,color_pars_fragment:Nd,color_pars_vertex:Dd,color_vertex:Ud,common:Fd,cube_uv_reflection_fragment:Od,defaultnormal_vertex:Bd,displacementmap_pars_vertex:zd,displacementmap_vertex:kd,emissivemap_fragment:Gd,emissivemap_pars_fragment:Hd,colorspace_fragment:Vd,colorspace_pars_fragment:Wd,envmap_fragment:Xd,envmap_common_pars_fragment:qd,envmap_pars_fragment:Yd,envmap_pars_vertex:Zd,envmap_physical_pars_fragment:af,envmap_vertex:Jd,fog_vertex:$d,fog_pars_vertex:Kd,fog_fragment:Qd,fog_pars_fragment:jd,gradientmap_pars_fragment:ef,lightmap_pars_fragment:tf,lights_lambert_fragment:nf,lights_lambert_pars_fragment:sf,lights_pars_begin:rf,lights_toon_fragment:of,lights_toon_pars_fragment:lf,lights_phong_fragment:cf,lights_phong_pars_fragment:hf,lights_physical_fragment:uf,lights_physical_pars_fragment:df,lights_fragment_begin:ff,lights_fragment_maps:pf,lights_fragment_end:mf,lightprobes_pars_fragment:gf,logdepthbuf_fragment:_f,logdepthbuf_pars_fragment:xf,logdepthbuf_pars_vertex:vf,logdepthbuf_vertex:yf,map_fragment:Sf,map_pars_fragment:Mf,map_particle_fragment:bf,map_particle_pars_fragment:Tf,metalnessmap_fragment:wf,metalnessmap_pars_fragment:Ef,morphinstance_vertex:Af,morphcolor_vertex:Cf,morphnormal_vertex:Rf,morphtarget_pars_vertex:If,morphtarget_vertex:Pf,normal_fragment_begin:Lf,normal_fragment_maps:Nf,normal_pars_fragment:Df,normal_pars_vertex:Uf,normal_vertex:Ff,normalmap_pars_fragment:Of,clearcoat_normal_fragment_begin:Bf,clearcoat_normal_fragment_maps:zf,clearcoat_pars_fragment:kf,iridescence_pars_fragment:Gf,opaque_fragment:Hf,packing:Vf,premultiplied_alpha_fragment:Wf,project_vertex:Xf,dithering_fragment:qf,dithering_pars_fragment:Yf,roughnessmap_fragment:Zf,roughnessmap_pars_fragment:Jf,shadowmap_pars_fragment:$f,shadowmap_pars_vertex:Kf,shadowmap_vertex:Qf,shadowmask_pars_fragment:jf,skinbase_vertex:ep,skinning_pars_vertex:tp,skinning_vertex:np,skinnormal_vertex:ip,specularmap_fragment:sp,specularmap_pars_fragment:rp,tonemapping_fragment:ap,tonemapping_pars_fragment:op,transmission_fragment:lp,transmission_pars_fragment:cp,uv_pars_fragment:hp,uv_pars_vertex:up,uv_vertex:dp,worldpos_vertex:fp,background_vert:pp,background_frag:mp,backgroundCube_vert:gp,backgroundCube_frag:_p,cube_vert:xp,cube_frag:vp,depth_vert:yp,depth_frag:Sp,distance_vert:Mp,distance_frag:bp,equirect_vert:Tp,equirect_frag:wp,linedashed_vert:Ep,linedashed_frag:Ap,meshbasic_vert:Cp,meshbasic_frag:Rp,meshlambert_vert:Ip,meshlambert_frag:Pp,meshmatcap_vert:Lp,meshmatcap_frag:Np,meshnormal_vert:Dp,meshnormal_frag:Up,meshphong_vert:Fp,meshphong_frag:Op,meshphysical_vert:Bp,meshphysical_frag:zp,meshtoon_vert:kp,meshtoon_frag:Gp,points_vert:Hp,points_frag:Vp,shadow_vert:Wp,shadow_frag:Xp,sprite_vert:qp,sprite_frag:Yp},_e={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new ze(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},Wn={basic:{uniforms:rn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:qe.meshbasic_vert,fragmentShader:qe.meshbasic_frag},lambert:{uniforms:rn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new We(0)},envMapIntensity:{value:1}}]),vertexShader:qe.meshlambert_vert,fragmentShader:qe.meshlambert_frag},phong:{uniforms:rn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:qe.meshphong_vert,fragmentShader:qe.meshphong_frag},standard:{uniforms:rn([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:qe.meshphysical_vert,fragmentShader:qe.meshphysical_frag},toon:{uniforms:rn([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new We(0)}}]),vertexShader:qe.meshtoon_vert,fragmentShader:qe.meshtoon_frag},matcap:{uniforms:rn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:qe.meshmatcap_vert,fragmentShader:qe.meshmatcap_frag},points:{uniforms:rn([_e.points,_e.fog]),vertexShader:qe.points_vert,fragmentShader:qe.points_frag},dashed:{uniforms:rn([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:qe.linedashed_vert,fragmentShader:qe.linedashed_frag},depth:{uniforms:rn([_e.common,_e.displacementmap]),vertexShader:qe.depth_vert,fragmentShader:qe.depth_frag},normal:{uniforms:rn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:qe.meshnormal_vert,fragmentShader:qe.meshnormal_frag},sprite:{uniforms:rn([_e.sprite,_e.fog]),vertexShader:qe.sprite_vert,fragmentShader:qe.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:qe.background_vert,fragmentShader:qe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:qe.backgroundCube_vert,fragmentShader:qe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:qe.cube_vert,fragmentShader:qe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:qe.equirect_vert,fragmentShader:qe.equirect_frag},distance:{uniforms:rn([_e.common,_e.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:qe.distance_vert,fragmentShader:qe.distance_frag},shadow:{uniforms:rn([_e.lights,_e.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:qe.shadow_vert,fragmentShader:qe.shadow_frag}};Wn.physical={uniforms:rn([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:qe.meshphysical_vert,fragmentShader:qe.meshphysical_frag};var fa={r:0,b:0,g:0},Zp=new yt,Hh=new ke;Hh.set(-1,0,0,0,1,0,0,0,1);function Jp(e,t,n,i,s,r){let a=new We(0),o=s===!0?0:1,l,c,u=null,d=0,h=null;function p(E){let C=E.isScene===!0?E.background:null;if(C&&C.isTexture){let y=E.backgroundBlurriness>0;C=t.get(C,y)}return C}function v(E){let C=!1,y=p(E);if(y===null)m(a,o);else if(y&&y.isColor)m(y,1),C=!0;let b=e.xr.getEnvironmentBlendMode();if(b==="additive")n.buffers.color.setClear(0,0,0,1,r);else if(b==="alpha-blend")n.buffers.color.setClear(0,0,0,0,r);if(e.autoClear||C)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function T(E,C){let y=p(C);if(y&&(y.isCubeTexture||y.mapping===Zs)){if(c===void 0)c=new Ge(new Hn(1,1,1),new Sn({name:"BackgroundCubeMaterial",uniforms:Bi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Wt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,w,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c);if(c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Zp.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(Hh);if(c.material.toneMapped=je.getTransfer(y.colorSpace)!==_t,u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}else if(y&&y.isTexture){if(l===void 0)l=new Ge(new At(2,2),new Sn({name:"BackgroundMaterial",uniforms:Bi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:As,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l);if(l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.toneMapped=je.getTransfer(y.colorSpace)!==_t,y.matrixAutoUpdate===!0)y.updateMatrix();if(l.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}}function m(E,C){E.getRGB(fa,Qo(e)),n.buffers.color.setClear(fa.r,fa.g,fa.b,C,r)}function f(){if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0;if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0}return{getClearColor:function(){return a},setClearColor:function(E,C=1){a.set(E),o=C,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(E){o=E,m(a,o)},render:v,addToRenderList:T,dispose:f}}function $p(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(R,U,W,P,H){let j=!1,G=d(R,P,W,U);if(r!==G)r=G,c(r.object);if(j=p(R,P,W,H),j)v(R,P,W,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(j||a){if(a=!1,y(R,U,W,P),H!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(H).buffer)}}function l(){return e.createVertexArray()}function c(R){return e.bindVertexArray(R)}function u(R){return e.deleteVertexArray(R)}function d(R,U,W,P){let H=P.wireframe===!0,j=i[U.id];if(j===void 0)j={},i[U.id]=j;let G=R.isInstancedMesh===!0?R.id:0,re=j[G];if(re===void 0)re={},j[G]=re;let q=re[W.id];if(q===void 0)q={},re[W.id]=q;let te=q[H];if(te===void 0)te=h(l()),q[H]=te;return te}function h(R){let U=[],W=[],P=[];for(let H=0;H<n;H++)U[H]=0,W[H]=0,P[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:P,object:R,attributes:{},index:null}}function p(R,U,W,P){let H=r.attributes,j=U.attributes,G=0,re=W.getAttributes();for(let q in re)if(re[q].location>=0){let ee=H[q],me=j[q];if(me===void 0){if(q==="instanceMatrix"&&R.instanceMatrix)me=R.instanceMatrix;if(q==="instanceColor"&&R.instanceColor)me=R.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==me)return!0;if(me&&ee.data!==me.data)return!0;G++}if(r.attributesNum!==G)return!0;if(r.index!==P)return!0;return!1}function v(R,U,W,P){let H={},j=U.attributes,G=0,re=W.getAttributes();for(let q in re)if(re[q].location>=0){let ee=j[q];if(ee===void 0){if(q==="instanceMatrix"&&R.instanceMatrix)ee=R.instanceMatrix;if(q==="instanceColor"&&R.instanceColor)ee=R.instanceColor}let me={};if(me.attribute=ee,ee&&ee.data)me.data=ee.data;H[q]=me,G++}r.attributes=H,r.attributesNum=G,r.index=P}function T(){let R=r.newAttributes;for(let U=0,W=R.length;U<W;U++)R[U]=0}function m(R){f(R,0)}function f(R,U){let W=r.newAttributes,P=r.enabledAttributes,H=r.attributeDivisors;if(W[R]=1,P[R]===0)e.enableVertexAttribArray(R),P[R]=1;if(H[R]!==U)e.vertexAttribDivisor(R,U),H[R]=U}function E(){let R=r.newAttributes,U=r.enabledAttributes;for(let W=0,P=U.length;W<P;W++)if(U[W]!==R[W])e.disableVertexAttribArray(W),U[W]=0}function C(R,U,W,P,H,j,G){if(G===!0)e.vertexAttribIPointer(R,U,W,H,j);else e.vertexAttribPointer(R,U,W,P,H,j)}function y(R,U,W,P){T();let H=P.attributes,j=W.getAttributes(),G=U.defaultAttributeValues;for(let re in j){let q=j[re];if(q.location>=0){let te=H[re];if(te===void 0){if(re==="instanceMatrix"&&R.instanceMatrix)te=R.instanceMatrix;if(re==="instanceColor"&&R.instanceColor)te=R.instanceColor}if(te!==void 0){let ee=te.normalized,me=te.itemSize,we=t.get(te);if(we===void 0)continue;let{buffer:He,type:Fe,bytesPerElement:Y}=we,se=Fe===e.INT||Fe===e.UNSIGNED_INT||te.gpuType===ro;if(te.isInterleavedBufferAttribute){let ae=te.data,Re=ae.stride,Ie=te.offset;if(ae.isInstancedInterleavedBuffer){for(let De=0;De<q.locationSize;De++)f(q.location+De,ae.meshPerAttribute);if(R.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=ae.meshPerAttribute*ae.count}else for(let De=0;De<q.locationSize;De++)m(q.location+De);e.bindBuffer(e.ARRAY_BUFFER,He);for(let De=0;De<q.locationSize;De++)C(q.location+De,me/q.locationSize,Fe,ee,Re*Y,(Ie+me/q.locationSize*De)*Y,se)}else{if(te.isInstancedBufferAttribute){for(let ae=0;ae<q.locationSize;ae++)f(q.location+ae,te.meshPerAttribute);if(R.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=te.meshPerAttribute*te.count}else for(let ae=0;ae<q.locationSize;ae++)m(q.location+ae);e.bindBuffer(e.ARRAY_BUFFER,He);for(let ae=0;ae<q.locationSize;ae++)C(q.location+ae,me/q.locationSize,Fe,ee,me*Y,me/q.locationSize*ae*Y,se)}}else if(G!==void 0){let ee=G[re];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(q.location,ee);break;case 3:e.vertexAttrib3fv(q.location,ee);break;case 4:e.vertexAttrib4fv(q.location,ee);break;default:e.vertexAttrib1fv(q.location,ee)}}}}E()}function b(){M();for(let R in i){let U=i[R];for(let W in U){let P=U[W];for(let H in P){let j=P[H];for(let G in j)u(j[G].object),delete j[G];delete P[H]}}delete i[R]}}function w(R){if(i[R.id]===void 0)return;let U=i[R.id];for(let W in U){let P=U[W];for(let H in P){let j=P[H];for(let G in j)u(j[G].object),delete j[G];delete P[H]}}delete i[R.id]}function A(R){for(let U in i){let W=i[U];for(let P in W){let H=W[P];if(H[R.id]===void 0)continue;let j=H[R.id];for(let G in j)u(j[G].object),delete j[G];delete H[R.id]}}}function _(R){for(let U in i){let W=i[U],P=R.isInstancedMesh===!0?R.id:0,H=W[P];if(H===void 0)continue;for(let j in H){let G=H[j];for(let re in G)u(G[re].object),delete G[re];delete H[j]}if(delete W[P],Object.keys(W).length===0)delete i[U]}}function M(){if(B(),a=!0,r===s)return;r=s,c(r.object)}function B(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:M,resetDefaultState:B,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:T,enableAttribute:m,disableUnusedAttributes:E}}function Kp(e,t,n){let i;function s(l){i=l}function r(l,c){e.drawArrays(i,l,c),n.update(c,i,1)}function a(l,c,u){if(u===0)return;e.drawArraysInstanced(i,l,c,u),n.update(c,i,u)}function o(l,c,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,u);let h=0;for(let p=0;p<u;p++)h+=c[p];n.update(h,i,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Qp(e,t,n,i){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");s=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){if(A!==Gn&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(A){let _=A===zn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==fn&&A!==ti&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function l(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let c=n.precision!==void 0?n.precision:"highp",u=l(c);if(u!==c)Oe("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),v=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),C=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),w=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:v,maxTextureSize:T,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:E,maxVaryings:C,maxFragmentUniforms:y,maxSamples:b,samples:w}}function jp(e){let t=this,n=null,i=0,s=!1,r=!1,a=new Un,o=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let p=d.length!==0||h||i!==0||s;return s=h,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,p){let{clippingPlanes:v,clipIntersection:T,clipShadows:m}=d,f=e.get(d);if(!s||v===null||v.length===0||r&&!m)if(r)u(null);else c();else{let E=r?0:i,C=E*4,y=f.clippingState||null;l.value=y,y=u(v,h,C,p);for(let b=0;b!==C;++b)y[b]=n[b];f.clippingState=y,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=E}};function c(){if(l.value!==n)l.value=n,l.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,p,v){let T=d!==null?d.length:0,m=null;if(T!==0){if(m=l.value,v!==!0||m===null){let f=p+T*4,E=h.matrixWorldInverse;if(o.getNormalMatrix(E),m===null||m.length<f)m=new Float32Array(f);for(let C=0,y=p;C!==T;++C,y+=4)a.copy(d[C]).applyMatrix4(E,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=T,t.numIntersection=0,m}}var Ds=4,em=6,tm=20,nm=256,hr=new or,yh=new We,vl=null,yl=0,Sl=0,Ml=!1,im=new O,Hi=new O;class wl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,s={}){let{size:r=256,position:a=im}=s;vl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Sl=this._renderer.getActiveMipmapLevel(),Ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=bh(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Mh(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(vl,yl,Sl),this._renderer.xr.enabled=Ml,e.scissorTest=!1,Ns(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Rs||e.mapping===Ii)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);vl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Sl=this._renderer.getActiveMipmapLevel(),Ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:sn,minFilter:sn,generateMipmaps:!1,type:zn,format:Gn,colorSpace:Vo,depthBuffer:!1},i=Sh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Sh(e,t,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=sm(s)),this._blurMaterial=am(s,e,t),this._ggxMaterial=rm(s,e,t)}return i}_compileMaterial(e){let t=new Ge(new mn,e);this._renderer.compile(t,hr)}_sceneToCubeUV(e,t,n,i,s){let o=new ln(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(yh),u.toneMapping=Rn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Ge(new Hn,new Ft({name:"PMREM.Background",side:Wt,depthWrite:!1,depthTest:!1}));let v=this._backgroundBox,T=v.material,m=!1,f=e.background;if(f){if(f.isColor)T.color.copy(f),e.background=null,m=!0}else T.color.copy(yh),m=!0;for(let E=0;E<6;E++){let C=E%3;if(C===0)o.up.set(0,l[E],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+c[E],s.y,s.z);else if(C===1)o.up.set(0,0,l[E]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+c[E],s.z);else o.up.set(0,l[E],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+c[E]);let y=this._cubeSize;if(Ns(i,C*y,E>2?y:0,y,y),u.setRenderTarget(i),m)u.render(v,o);u.render(e,o)}u.toneMapping=h,u.autoClear=d,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Rs||e.mapping===Ii;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=bh();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Mh();let s=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;let a=s.uniforms;a.envMap.value=e;let o=this._cubeSize;Ns(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(r,hr)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[n];a.material=r;let o=r.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c),d=l*1.25,h=u*d,{_lodMax:p}=this,v=this._sizeLods[n],T=3*v*(n>p-Ds?n-p+Ds:0),m=4*(this._cubeSize-v);o.envMap.value=e.texture,o.roughness.value=h,o.mipInt.value=p-t,Ns(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,hr),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,Ns(e,T,m,3*v,2*v),i.setRenderTarget(e),i.render(a,hr)}_blur(e,t,n,i){let s=this._pingPongRenderTarget,r=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,s,t,n,r),this._blurPass(s,e,n,n,r)}_blurPass(e,t,n,i,s){let r=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let l=a.uniforms;l.envMap.value=e.texture,l.sigma.value=s,l.mipInt.value=this._lodMax-n;let c=this._sizeLods[i],u=3*c*(i>this._lodMax-Ds?i-this._lodMax+Ds:0),d=4*(this._cubeSize-c);Ns(t,u,d,3*c,2*c),r.setRenderTarget(t),r.render(o,hr)}}function sm(e){let t=[],n=[],i=e,s=e-Ds+1+em;for(let r=0;r<s;r++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),l=-o,c=1+o,u=[l,l,c,l,c,c,l,l,c,c,l,c],d=6,h=6,p=3,v=new Float32Array(p*h*d),T=new Float32Array(p*h*d);for(let f=0;f<d;f++){let E=f%3*2/3-1,C=f>2?0:-1,y=[E,C,0,E+0.6666666666666666,C,0,E+0.6666666666666666,C+1,0,E,C,0,E+0.6666666666666666,C+1,0,E,C+1,0];v.set(y,p*h*f);for(let b=0;b<h;b++){let w=u[b*2]*2-1,A=u[b*2+1]*2-1;if(f===0)Hi.set(1,A,w);else if(f===1)Hi.set(-w,1,-A);else if(f===2)Hi.set(-w,A,1);else if(f===3)Hi.set(-1,A,-w);else if(f===4)Hi.set(-w,-1,A);else Hi.set(w,A,-1);Hi.toArray(T,(f*h+b)*p)}}let m=new mn;if(m.setAttribute("position",new yn(v,p)),m.setAttribute("outputDirection",new yn(T,p)),n.push(new Ge(m,null)),i>Ds)i--}return{lodMeshes:n,sizeLods:t}}function Sh(e,t,n){let i=new pn(e,t,n);return i.texture.mapping=Zs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ns(e,t,n,i,s){e.viewport.set(t,n,i,s),e.scissor.set(t,n,i,s)}function rm(e,t,n){return new Sn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nm,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ma(),fragmentShader:`
|
|
3823
|
+
}`,qe={alphahash_fragment:fd,alphahash_pars_fragment:pd,alphamap_fragment:md,alphamap_pars_fragment:gd,alphatest_fragment:_d,alphatest_pars_fragment:xd,aomap_fragment:vd,aomap_pars_fragment:yd,batching_pars_vertex:Sd,batching_vertex:Md,begin_vertex:bd,beginnormal_vertex:Td,bsdfs:wd,iridescence_fragment:Ed,bumpmap_pars_fragment:Ad,clipping_planes_fragment:Cd,clipping_planes_pars_fragment:Rd,clipping_planes_pars_vertex:Id,clipping_planes_vertex:Pd,color_fragment:Ld,color_pars_fragment:Nd,color_pars_vertex:Dd,color_vertex:Ud,common:Fd,cube_uv_reflection_fragment:Od,defaultnormal_vertex:Bd,displacementmap_pars_vertex:zd,displacementmap_vertex:kd,emissivemap_fragment:Gd,emissivemap_pars_fragment:Hd,colorspace_fragment:Vd,colorspace_pars_fragment:Wd,envmap_fragment:Xd,envmap_common_pars_fragment:qd,envmap_pars_fragment:Yd,envmap_pars_vertex:Zd,envmap_physical_pars_fragment:af,envmap_vertex:Jd,fog_vertex:$d,fog_pars_vertex:Kd,fog_fragment:Qd,fog_pars_fragment:jd,gradientmap_pars_fragment:ef,lightmap_pars_fragment:tf,lights_lambert_fragment:nf,lights_lambert_pars_fragment:sf,lights_pars_begin:rf,lights_toon_fragment:of,lights_toon_pars_fragment:lf,lights_phong_fragment:cf,lights_phong_pars_fragment:hf,lights_physical_fragment:uf,lights_physical_pars_fragment:df,lights_fragment_begin:ff,lights_fragment_maps:pf,lights_fragment_end:mf,lightprobes_pars_fragment:gf,logdepthbuf_fragment:_f,logdepthbuf_pars_fragment:xf,logdepthbuf_pars_vertex:vf,logdepthbuf_vertex:yf,map_fragment:Sf,map_pars_fragment:Mf,map_particle_fragment:bf,map_particle_pars_fragment:Tf,metalnessmap_fragment:wf,metalnessmap_pars_fragment:Ef,morphinstance_vertex:Af,morphcolor_vertex:Cf,morphnormal_vertex:Rf,morphtarget_pars_vertex:If,morphtarget_vertex:Pf,normal_fragment_begin:Lf,normal_fragment_maps:Nf,normal_pars_fragment:Df,normal_pars_vertex:Uf,normal_vertex:Ff,normalmap_pars_fragment:Of,clearcoat_normal_fragment_begin:Bf,clearcoat_normal_fragment_maps:zf,clearcoat_pars_fragment:kf,iridescence_pars_fragment:Gf,opaque_fragment:Hf,packing:Vf,premultiplied_alpha_fragment:Wf,project_vertex:Xf,dithering_fragment:qf,dithering_pars_fragment:Yf,roughnessmap_fragment:Zf,roughnessmap_pars_fragment:Jf,shadowmap_pars_fragment:$f,shadowmap_pars_vertex:Kf,shadowmap_vertex:Qf,shadowmask_pars_fragment:jf,skinbase_vertex:ep,skinning_pars_vertex:tp,skinning_vertex:np,skinnormal_vertex:ip,specularmap_fragment:sp,specularmap_pars_fragment:rp,tonemapping_fragment:ap,tonemapping_pars_fragment:op,transmission_fragment:lp,transmission_pars_fragment:cp,uv_pars_fragment:hp,uv_pars_vertex:up,uv_vertex:dp,worldpos_vertex:fp,background_vert:pp,background_frag:mp,backgroundCube_vert:gp,backgroundCube_frag:_p,cube_vert:xp,cube_frag:vp,depth_vert:yp,depth_frag:Sp,distance_vert:Mp,distance_frag:bp,equirect_vert:Tp,equirect_frag:wp,linedashed_vert:Ep,linedashed_frag:Ap,meshbasic_vert:Cp,meshbasic_frag:Rp,meshlambert_vert:Ip,meshlambert_frag:Pp,meshmatcap_vert:Lp,meshmatcap_frag:Np,meshnormal_vert:Dp,meshnormal_frag:Up,meshphong_vert:Fp,meshphong_frag:Op,meshphysical_vert:Bp,meshphysical_frag:zp,meshtoon_vert:kp,meshtoon_frag:Gp,points_vert:Hp,points_frag:Vp,shadow_vert:Wp,shadow_frag:Xp,sprite_vert:qp,sprite_frag:Yp},_e={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new ze(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},Vn={basic:{uniforms:tn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:qe.meshbasic_vert,fragmentShader:qe.meshbasic_frag},lambert:{uniforms:tn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new We(0)},envMapIntensity:{value:1}}]),vertexShader:qe.meshlambert_vert,fragmentShader:qe.meshlambert_frag},phong:{uniforms:tn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:qe.meshphong_vert,fragmentShader:qe.meshphong_frag},standard:{uniforms:tn([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:qe.meshphysical_vert,fragmentShader:qe.meshphysical_frag},toon:{uniforms:tn([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new We(0)}}]),vertexShader:qe.meshtoon_vert,fragmentShader:qe.meshtoon_frag},matcap:{uniforms:tn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:qe.meshmatcap_vert,fragmentShader:qe.meshmatcap_frag},points:{uniforms:tn([_e.points,_e.fog]),vertexShader:qe.points_vert,fragmentShader:qe.points_frag},dashed:{uniforms:tn([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:qe.linedashed_vert,fragmentShader:qe.linedashed_frag},depth:{uniforms:tn([_e.common,_e.displacementmap]),vertexShader:qe.depth_vert,fragmentShader:qe.depth_frag},normal:{uniforms:tn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:qe.meshnormal_vert,fragmentShader:qe.meshnormal_frag},sprite:{uniforms:tn([_e.sprite,_e.fog]),vertexShader:qe.sprite_vert,fragmentShader:qe.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:qe.background_vert,fragmentShader:qe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:qe.backgroundCube_vert,fragmentShader:qe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:qe.cube_vert,fragmentShader:qe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:qe.equirect_vert,fragmentShader:qe.equirect_frag},distance:{uniforms:tn([_e.common,_e.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:qe.distance_vert,fragmentShader:qe.distance_frag},shadow:{uniforms:tn([_e.lights,_e.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:qe.shadow_vert,fragmentShader:qe.shadow_frag}};Vn.physical={uniforms:tn([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:qe.meshphysical_vert,fragmentShader:qe.meshphysical_frag};var Qr={r:0,b:0,g:0},Zp=new yt,Hh=new ke;Hh.set(-1,0,0,0,1,0,0,0,1);function Jp(e,t,n,i,s,r){let a=new We(0),o=s===!0?0:1,l,c,u=null,d=0,h=null;function p(E){let C=E.isScene===!0?E.background:null;if(C&&C.isTexture){let y=E.backgroundBlurriness>0;C=t.get(C,y)}return C}function v(E){let C=!1,y=p(E);if(y===null)m(a,o);else if(y&&y.isColor)m(y,1),C=!0;let b=e.xr.getEnvironmentBlendMode();if(b==="additive")n.buffers.color.setClear(0,0,0,1,r);else if(b==="alpha-blend")n.buffers.color.setClear(0,0,0,0,r);if(e.autoClear||C)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function T(E,C){let y=p(C);if(y&&(y.isCubeTexture||y.mapping===Ns)){if(c===void 0)c=new Ge(new Gn(1,1,1),new Sn({name:"BackgroundCubeMaterial",uniforms:Oi(Vn.backgroundCube.uniforms),vertexShader:Vn.backgroundCube.vertexShader,fragmentShader:Vn.backgroundCube.fragmentShader,side:qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,w,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c);if(c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Zp.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(Hh);if(c.material.toneMapped=je.getTransfer(y.colorSpace)!==_t,u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}else if(y&&y.isTexture){if(l===void 0)l=new Ge(new At(2,2),new Sn({name:"BackgroundMaterial",uniforms:Oi(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l);if(l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.toneMapped=je.getTransfer(y.colorSpace)!==_t,y.matrixAutoUpdate===!0)y.updateMatrix();if(l.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}}function m(E,C){E.getRGB(Qr,Ko(e)),n.buffers.color.setClear(Qr.r,Qr.g,Qr.b,C,r)}function f(){if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0;if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0}return{getClearColor:function(){return a},setClearColor:function(E,C=1){a.set(E),o=C,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(E){o=E,m(a,o)},render:v,addToRenderList:T,dispose:f}}function $p(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(R,U,W,P,H){let j=!1,G=d(R,P,W,U);if(r!==G)r=G,c(r.object);if(j=p(R,P,W,H),j)v(R,P,W,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(j||a){if(a=!1,y(R,U,W,P),H!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(H).buffer)}}function l(){return e.createVertexArray()}function c(R){return e.bindVertexArray(R)}function u(R){return e.deleteVertexArray(R)}function d(R,U,W,P){let H=P.wireframe===!0,j=i[U.id];if(j===void 0)j={},i[U.id]=j;let G=R.isInstancedMesh===!0?R.id:0,re=j[G];if(re===void 0)re={},j[G]=re;let q=re[W.id];if(q===void 0)q={},re[W.id]=q;let te=q[H];if(te===void 0)te=h(l()),q[H]=te;return te}function h(R){let U=[],W=[],P=[];for(let H=0;H<n;H++)U[H]=0,W[H]=0,P[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:P,object:R,attributes:{},index:null}}function p(R,U,W,P){let H=r.attributes,j=U.attributes,G=0,re=W.getAttributes();for(let q in re)if(re[q].location>=0){let ee=H[q],me=j[q];if(me===void 0){if(q==="instanceMatrix"&&R.instanceMatrix)me=R.instanceMatrix;if(q==="instanceColor"&&R.instanceColor)me=R.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==me)return!0;if(me&&ee.data!==me.data)return!0;G++}if(r.attributesNum!==G)return!0;if(r.index!==P)return!0;return!1}function v(R,U,W,P){let H={},j=U.attributes,G=0,re=W.getAttributes();for(let q in re)if(re[q].location>=0){let ee=j[q];if(ee===void 0){if(q==="instanceMatrix"&&R.instanceMatrix)ee=R.instanceMatrix;if(q==="instanceColor"&&R.instanceColor)ee=R.instanceColor}let me={};if(me.attribute=ee,ee&&ee.data)me.data=ee.data;H[q]=me,G++}r.attributes=H,r.attributesNum=G,r.index=P}function T(){let R=r.newAttributes;for(let U=0,W=R.length;U<W;U++)R[U]=0}function m(R){f(R,0)}function f(R,U){let W=r.newAttributes,P=r.enabledAttributes,H=r.attributeDivisors;if(W[R]=1,P[R]===0)e.enableVertexAttribArray(R),P[R]=1;if(H[R]!==U)e.vertexAttribDivisor(R,U),H[R]=U}function E(){let R=r.newAttributes,U=r.enabledAttributes;for(let W=0,P=U.length;W<P;W++)if(U[W]!==R[W])e.disableVertexAttribArray(W),U[W]=0}function C(R,U,W,P,H,j,G){if(G===!0)e.vertexAttribIPointer(R,U,W,H,j);else e.vertexAttribPointer(R,U,W,P,H,j)}function y(R,U,W,P){T();let H=P.attributes,j=W.getAttributes(),G=U.defaultAttributeValues;for(let re in j){let q=j[re];if(q.location>=0){let te=H[re];if(te===void 0){if(re==="instanceMatrix"&&R.instanceMatrix)te=R.instanceMatrix;if(re==="instanceColor"&&R.instanceColor)te=R.instanceColor}if(te!==void 0){let ee=te.normalized,me=te.itemSize,we=t.get(te);if(we===void 0)continue;let{buffer:He,type:Fe,bytesPerElement:Y}=we,se=Fe===e.INT||Fe===e.UNSIGNED_INT||te.gpuType===Wa;if(te.isInterleavedBufferAttribute){let ae=te.data,Re=ae.stride,Ie=te.offset;if(ae.isInstancedInterleavedBuffer){for(let De=0;De<q.locationSize;De++)f(q.location+De,ae.meshPerAttribute);if(R.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=ae.meshPerAttribute*ae.count}else for(let De=0;De<q.locationSize;De++)m(q.location+De);e.bindBuffer(e.ARRAY_BUFFER,He);for(let De=0;De<q.locationSize;De++)C(q.location+De,me/q.locationSize,Fe,ee,Re*Y,(Ie+me/q.locationSize*De)*Y,se)}else{if(te.isInstancedBufferAttribute){for(let ae=0;ae<q.locationSize;ae++)f(q.location+ae,te.meshPerAttribute);if(R.isInstancedMesh!==!0&&P._maxInstanceCount===void 0)P._maxInstanceCount=te.meshPerAttribute*te.count}else for(let ae=0;ae<q.locationSize;ae++)m(q.location+ae);e.bindBuffer(e.ARRAY_BUFFER,He);for(let ae=0;ae<q.locationSize;ae++)C(q.location+ae,me/q.locationSize,Fe,ee,me*Y,me/q.locationSize*ae*Y,se)}}else if(G!==void 0){let ee=G[re];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(q.location,ee);break;case 3:e.vertexAttrib3fv(q.location,ee);break;case 4:e.vertexAttrib4fv(q.location,ee);break;default:e.vertexAttrib1fv(q.location,ee)}}}}E()}function b(){M();for(let R in i){let U=i[R];for(let W in U){let P=U[W];for(let H in P){let j=P[H];for(let G in j)u(j[G].object),delete j[G];delete P[H]}}delete i[R]}}function w(R){if(i[R.id]===void 0)return;let U=i[R.id];for(let W in U){let P=U[W];for(let H in P){let j=P[H];for(let G in j)u(j[G].object),delete j[G];delete P[H]}}delete i[R.id]}function A(R){for(let U in i){let W=i[U];for(let P in W){let H=W[P];if(H[R.id]===void 0)continue;let j=H[R.id];for(let G in j)u(j[G].object),delete j[G];delete H[R.id]}}}function _(R){for(let U in i){let W=i[U],P=R.isInstancedMesh===!0?R.id:0,H=W[P];if(H===void 0)continue;for(let j in H){let G=H[j];for(let re in G)u(G[re].object),delete G[re];delete H[j]}if(delete W[P],Object.keys(W).length===0)delete i[U]}}function M(){if(B(),a=!0,r===s)return;r=s,c(r.object)}function B(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:M,resetDefaultState:B,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:T,enableAttribute:m,disableUnusedAttributes:E}}function Kp(e,t,n){let i;function s(l){i=l}function r(l,c){e.drawArrays(i,l,c),n.update(c,i,1)}function a(l,c,u){if(u===0)return;e.drawArraysInstanced(i,l,c,u),n.update(c,i,u)}function o(l,c,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,u);let h=0;for(let p=0;p<u;p++)h+=c[p];n.update(h,i,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Qp(e,t,n,i){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");s=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){if(A!==kn&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(A){let _=A===zn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==fn&&A!==ei&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function l(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let c=n.precision!==void 0?n.precision:"highp",u=l(c);if(u!==c)Oe("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),v=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),C=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),w=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:v,maxTextureSize:T,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:E,maxVaryings:C,maxFragmentUniforms:y,maxSamples:b,samples:w}}function jp(e){let t=this,n=null,i=0,s=!1,r=!1,a=new Un,o=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let p=d.length!==0||h||i!==0||s;return s=h,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,p){let{clippingPlanes:v,clipIntersection:T,clipShadows:m}=d,f=e.get(d);if(!s||v===null||v.length===0||r&&!m)if(r)u(null);else c();else{let E=r?0:i,C=E*4,y=f.clippingState||null;l.value=y,y=u(v,h,C,p);for(let b=0;b!==C;++b)y[b]=n[b];f.clippingState=y,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=E}};function c(){if(l.value!==n)l.value=n,l.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,p,v){let T=d!==null?d.length:0,m=null;if(T!==0){if(m=l.value,v!==!0||m===null){let f=p+T*4,E=h.matrixWorldInverse;if(o.getNormalMatrix(E),m===null||m.length<f)m=new Float32Array(f);for(let C=0,y=p;C!==T;++C,y+=4)a.copy(d[C]).applyMatrix4(E,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=T,t.numIntersection=0,m}}var ys=4,em=6,tm=20,nm=256,qs=new Xs,yh=new We,vl=null,yl=0,Sl=0,Ml=!1,im=new O,Gi=new O;class wl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,s={}){let{size:r=256,position:a=im}=s;vl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Sl=this._renderer.getActiveMipmapLevel(),Ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=bh(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Mh(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(vl,yl,Sl),this._renderer.xr.enabled=Ml,e.scissorTest=!1,vs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ms||e.mapping===Ci)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);vl=this._renderer.getRenderTarget(),yl=this._renderer.getActiveCubeFace(),Sl=this._renderer.getActiveMipmapLevel(),Ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:en,minFilter:en,generateMipmaps:!1,type:zn,format:kn,colorSpace:Go,depthBuffer:!1},i=Sh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Sh(e,t,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=sm(s)),this._blurMaterial=am(s,e,t),this._ggxMaterial=rm(s,e,t)}return i}_compileMaterial(e){let t=new Ge(new mn,e);this._renderer.compile(t,qs)}_sceneToCubeUV(e,t,n,i,s){let o=new ln(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(yh),u.toneMapping=Rn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Ge(new Gn,new Ot({name:"PMREM.Background",side:qt,depthWrite:!1,depthTest:!1}));let v=this._backgroundBox,T=v.material,m=!1,f=e.background;if(f){if(f.isColor)T.color.copy(f),e.background=null,m=!0}else T.color.copy(yh),m=!0;for(let E=0;E<6;E++){let C=E%3;if(C===0)o.up.set(0,l[E],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+c[E],s.y,s.z);else if(C===1)o.up.set(0,0,l[E]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+c[E],s.z);else o.up.set(0,l[E],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+c[E]);let y=this._cubeSize;if(vs(i,C*y,E>2?y:0,y,y),u.setRenderTarget(i),m)u.render(v,o);u.render(e,o)}u.toneMapping=h,u.autoClear=d,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ms||e.mapping===Ci;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=bh();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Mh();let s=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;let a=s.uniforms;a.envMap.value=e;let o=this._cubeSize;vs(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(r,qs)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[n];a.material=r;let o=r.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c),d=l*1.25,h=u*d,{_lodMax:p}=this,v=this._sizeLods[n],T=3*v*(n>p-ys?n-p+ys:0),m=4*(this._cubeSize-v);o.envMap.value=e.texture,o.roughness.value=h,o.mipInt.value=p-t,vs(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,qs),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,vs(e,T,m,3*v,2*v),i.setRenderTarget(e),i.render(a,qs)}_blur(e,t,n,i){let s=this._pingPongRenderTarget,r=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,s,t,n,r),this._blurPass(s,e,n,n,r)}_blurPass(e,t,n,i,s){let r=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let l=a.uniforms;l.envMap.value=e.texture,l.sigma.value=s,l.mipInt.value=this._lodMax-n;let c=this._sizeLods[i],u=3*c*(i>this._lodMax-ys?i-this._lodMax+ys:0),d=4*(this._cubeSize-c);vs(t,u,d,3*c,2*c),r.setRenderTarget(t),r.render(o,qs)}}function sm(e){let t=[],n=[],i=e,s=e-ys+1+em;for(let r=0;r<s;r++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),l=-o,c=1+o,u=[l,l,c,l,c,c,l,l,c,c,l,c],d=6,h=6,p=3,v=new Float32Array(p*h*d),T=new Float32Array(p*h*d);for(let f=0;f<d;f++){let E=f%3*2/3-1,C=f>2?0:-1,y=[E,C,0,E+0.6666666666666666,C,0,E+0.6666666666666666,C+1,0,E,C,0,E+0.6666666666666666,C+1,0,E,C+1,0];v.set(y,p*h*f);for(let b=0;b<h;b++){let w=u[b*2]*2-1,A=u[b*2+1]*2-1;if(f===0)Gi.set(1,A,w);else if(f===1)Gi.set(-w,1,-A);else if(f===2)Gi.set(-w,A,1);else if(f===3)Gi.set(-1,A,-w);else if(f===4)Gi.set(-w,-1,A);else Gi.set(w,A,-1);Gi.toArray(T,(f*h+b)*p)}}let m=new mn;if(m.setAttribute("position",new yn(v,p)),m.setAttribute("outputDirection",new yn(T,p)),n.push(new Ge(m,null)),i>ys)i--}return{lodMeshes:n,sizeLods:t}}function Sh(e,t,n){let i=new pn(e,t,n);return i.texture.mapping=Ns,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function vs(e,t,n,i,s){e.viewport.set(t,n,i,s),e.scissor.set(t,n,i,s)}function rm(e,t,n){return new Sn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nm,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ea(),fragmentShader:`
|
|
3824
3824
|
|
|
3825
3825
|
precision highp float;
|
|
3826
3826
|
precision highp int;
|
|
@@ -3924,7 +3924,7 @@ void main() {
|
|
|
3924
3924
|
|
|
3925
3925
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3926
3926
|
}
|
|
3927
|
-
`,blending:On,depthTest:!1,depthWrite:!1})}function am(e,t,n){return new Sn({name:"SphericalGaussianBlur",defines:{SAMPLES:tm,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:
|
|
3927
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function am(e,t,n){return new Sn({name:"SphericalGaussianBlur",defines:{SAMPLES:tm,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:ea(),fragmentShader:`
|
|
3928
3928
|
|
|
3929
3929
|
precision highp float;
|
|
3930
3930
|
precision highp int;
|
|
@@ -3984,7 +3984,7 @@ void main() {
|
|
|
3984
3984
|
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
|
|
3985
3985
|
|
|
3986
3986
|
}
|
|
3987
|
-
`,blending:On,depthTest:!1,depthWrite:!1})}function Mh(){return new Sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:
|
|
3987
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function Mh(){return new Sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ea(),fragmentShader:`
|
|
3988
3988
|
|
|
3989
3989
|
precision mediump float;
|
|
3990
3990
|
precision mediump int;
|
|
@@ -4003,7 +4003,7 @@ void main() {
|
|
|
4003
4003
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4004
4004
|
|
|
4005
4005
|
}
|
|
4006
|
-
`,blending:On,depthTest:!1,depthWrite:!1})}function bh(){return new Sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:
|
|
4006
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function bh(){return new Sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ea(),fragmentShader:`
|
|
4007
4007
|
|
|
4008
4008
|
precision mediump float;
|
|
4009
4009
|
precision mediump int;
|
|
@@ -4019,7 +4019,7 @@ void main() {
|
|
|
4019
4019
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4020
4020
|
|
|
4021
4021
|
}
|
|
4022
|
-
`,blending:On,depthTest:!1,depthWrite:!1})}function
|
|
4022
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function ea(){return`
|
|
4023
4023
|
|
|
4024
4024
|
precision mediump float;
|
|
4025
4025
|
precision mediump int;
|
|
@@ -4034,7 +4034,7 @@ void main() {
|
|
|
4034
4034
|
gl_Position = vec4( position, 1.0 );
|
|
4035
4035
|
|
|
4036
4036
|
}
|
|
4037
|
-
`}class Cl extends pn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new
|
|
4037
|
+
`}class Cl extends pn{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Wr(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4038
4038
|
|
|
4039
4039
|
varying vec3 vWorldDirection;
|
|
4040
4040
|
|
|
@@ -4069,7 +4069,7 @@ void main() {
|
|
|
4069
4069
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4070
4070
|
|
|
4071
4071
|
}
|
|
4072
|
-
`},i=new
|
|
4072
|
+
`},i=new Gn(5,5,5),s=new Sn({name:"CubemapFromEquirect",uniforms:Oi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:qt,blending:On});s.uniforms.tEquirect.value=t;let r=new Ge(i,s),a=t.minFilter;if(t.minFilter===Ii)t.minFilter=en;return new fl(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(s)}}function om(e){let t=new WeakMap,n=new WeakMap,i=null;function s(h,p=!1){if(h===null||h===void 0)return null;if(p)return a(h);return r(h)}function r(h){if(h&&h.isTexture){let p=h.mapping;if(p===Ar||p===Cr)if(t.has(h)){let v=t.get(h).texture;return o(v,h.mapping)}else{let v=h.image;if(v&&v.height>0){let T=new Cl(v.height);return T.fromEquirectangularTexture(e,h),t.set(h,T),h.addEventListener("dispose",c),o(T.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){let p=h.mapping,v=p===Ar||p===Cr,T=p===ms||p===Ci;if(v||T){let m=n.get(h),f=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f){if(i===null)i=new wl(e);return m=v?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),m.texture}else if(m!==void 0)return m.texture;else{let E=h.image;if(v&&E&&E.height>0||T&&E&&l(E)){if(i===null)i=new wl(e);return m=v?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),h.addEventListener("dispose",u),m.texture}else return null}}}return h}function o(h,p){if(p===Ar)h.mapping=ms;else if(p===Cr)h.mapping=Ci;return h}function l(h){let p=0,v=6;for(let T=0;T<v;T++)if(h[T]!==void 0)p++;return p===v}function c(h){let p=h.target;p.removeEventListener("dispose",c);let v=t.get(p);if(v!==void 0)t.delete(p),v.dispose()}function u(h){let p=h.target;p.removeEventListener("dispose",u);let v=n.get(p);if(v!==void 0)n.delete(p),v.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:s,dispose:d}}function lm(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let s=e.getExtension(i);return t[i]=s,s}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let s=n(i);if(s===null)Ai("WebGLRenderer: "+i+" extension not supported.");return s}}}function cm(e,t,n,i){let s={},r=new WeakMap;function a(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let v in h.attributes)t.remove(h.attributes[v]);h.removeEventListener("dispose",a),delete s[h.id];let p=r.get(h);if(p)t.remove(p),r.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function o(d,h){if(s[h.id]===!0)return h;return h.addEventListener("dispose",a),s[h.id]=!0,n.memory.geometries++,h}function l(d){let h=d.attributes;for(let p in h)t.update(h[p],e.ARRAY_BUFFER)}function c(d){let h=[],p=d.index,v=d.attributes.position,T=0;if(v===void 0)return;if(p!==null){let E=p.array;T=p.version;for(let C=0,y=E.length;C<y;C+=3){let b=E[C+0],w=E[C+1],A=E[C+2];h.push(b,w,w,A,A,b)}}else{let E=v.array;T=v.version;for(let C=0,y=E.length/3-1;C<y;C+=3){let b=C+0,w=C+1,A=C+2;h.push(b,w,w,A,A,b)}}let m=new(v.count>=65535?Hr:Gr)(h,1);m.version=T;let f=r.get(d);if(f)t.remove(f);r.set(d,m)}function u(d){let h=r.get(d);if(h){let p=d.index;if(p!==null){if(h.version<p.version)c(d)}}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:u}}function hm(e,t,n){let i;function s(d){i=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,h){e.drawElements(i,h,r,d*a),n.update(h,i,1)}function c(d,h,p){if(p===0)return;e.drawElementsInstanced(i,h,r,d*a,p),n.update(h,i,p)}function u(d,h,p){if(p===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,r,d,0,p);let T=0;for(let m=0;m<p;m++)T+=h[m];n.update(T,i,1)}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function um(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=o*(r/3);break;case e.LINES:n.lines+=o*(r/2);break;case e.LINE_STRIP:n.lines+=o*(r-1);break;case e.LINE_LOOP:n.lines+=o*r;break;case e.POINTS:n.points+=o*r;break;default:Ue("WebGLInfo: Unknown draw mode:",a);break}}function s(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:s,update:i}}function dm(e,t,n){let i=new WeakMap,s=new wt;function r(a,o,l){let c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(o);if(h===void 0||h.count!==d){let M=function(){A.dispose(),i.delete(o),o.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let p=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,T=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],E=o.morphAttributes.color||[],C=0;if(p===!0)C=1;if(v===!0)C=2;if(T===!0)C=3;let y=o.attributes.position.count*C,b=1;if(y>t.maxTextureSize)b=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let w=new Float32Array(y*b*4*d),A=new zr(w,y,b,d);A.type=ei,A.needsUpdate=!0;let _=C*4;for(let B=0;B<d;B++){let R=m[B],U=f[B],W=E[B],P=y*b*4*B;for(let H=0;H<R.count;H++){let j=H*_;if(p===!0)s.fromBufferAttribute(R,H),w[P+j+0]=s.x,w[P+j+1]=s.y,w[P+j+2]=s.z,w[P+j+3]=0;if(v===!0)s.fromBufferAttribute(U,H),w[P+j+4]=s.x,w[P+j+5]=s.y,w[P+j+6]=s.z,w[P+j+7]=0;if(T===!0)s.fromBufferAttribute(W,H),w[P+j+8]=s.x,w[P+j+9]=s.y,w[P+j+10]=s.z,w[P+j+11]=W.itemSize===4?s.w:1}}h={count:d,texture:A,size:new ze(y,b)},i.set(o,h),o.addEventListener("dispose",M)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let p=0;for(let T=0;T<c.length;T++)p+=c[T];let v=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(e,"morphTargetBaseInfluence",v),l.getUniforms().setValue(e,"morphTargetInfluences",c)}l.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),l.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:r}}function fm(e,t,n,i,s){let r=new WeakMap;function a(c){let u=s.render.frame,d=c.geometry,h=t.get(c,d);if(r.get(h)!==u)t.update(h),r.set(h,u);if(c.isInstancedMesh){if(c.hasEventListener("dispose",l)===!1)c.addEventListener("dispose",l);if(r.get(c)!==u){if(n.update(c.instanceMatrix,e.ARRAY_BUFFER),c.instanceColor!==null)n.update(c.instanceColor,e.ARRAY_BUFFER);r.set(c,u)}}if(c.isSkinnedMesh){let p=c.skeleton;if(r.get(p)!==u)p.update(),r.set(p,u)}return h}function o(){r=new WeakMap}function l(c){let u=c.target;if(u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}var pm={[Oa]:"LINEAR_TONE_MAPPING",[Ba]:"REINHARD_TONE_MAPPING",[za]:"CINEON_TONE_MAPPING",[ka]:"ACES_FILMIC_TONE_MAPPING",[Ha]:"AGX_TONE_MAPPING",[Va]:"NEUTRAL_TONE_MAPPING",[Ga]:"CUSTOM_TONE_MAPPING"};function mm(e,t,n,i,s,r){let a=new pn(t,n,{type:e,depthBuffer:s,stencilBuffer:r,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,l=null,c=new mn;c.setAttribute("position",new $t([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new $t([0,2,0,0,2,0],2));let u=new jo({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4073
4073
|
precision highp float;
|
|
4074
4074
|
|
|
4075
4075
|
uniform mat4 modelViewMatrix;
|
|
@@ -4115,17 +4115,17 @@ void main() {
|
|
|
4115
4115
|
#ifdef SRGB_TRANSFER
|
|
4116
4116
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4117
4117
|
#endif
|
|
4118
|
-
}`,depthTest:!1,depthWrite:!1}),d=new Ge(c,u),h=new
|
|
4118
|
+
}`,depthTest:!1,depthWrite:!1}),d=new Ge(c,u),h=new Xs(-1,1,1,-1,0,1),p=null,v=null,T=!1,m,f=null,E=[],C=!1;this.setSize=function(y,b){if(a.setSize(y,b),o!==null)o.setSize(y,b);if(l!==null)l.setSize(y,b);for(let w=0;w<E.length;w++){let A=E[w];if(A.setSize)A.setSize(y,b)}},this.setEffects=function(y){E=y,C=E.length>0&&E[0].isRenderPass===!0;let{width:b,height:w}=a;if(E.length>0&&o===null)o=new pn(b,w,{type:zn,depthBuffer:!1,stencilBuffer:!1}),l=new pn(b,w,{type:zn,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(b,w)}},this.begin=function(y,b){if(T)return!1;if(y.toneMapping===Rn&&E.length===0)return!1;if(f=b,b!==null){let{width:w,height:A}=b;if(a.width!==w||a.height!==A)this.setSize(w,A)}if(C===!1)y.setRenderTarget(a);return m=y.toneMapping,y.toneMapping=Rn,!0},this.hasRenderPass=function(){return C},this.end=function(y,b){y.toneMapping=m,T=!0;let w=a,A=o;for(let _=0;_<E.length;_++){let M=E[_];if(M.enabled===!1)continue;if(M.render(y,A,w,b),M.needsSwap!==!1)w=A,A=A===o?l:o}if(p!==y.outputColorSpace||v!==y.toneMapping){if(p=y.outputColorSpace,v=y.toneMapping,u.defines={},je.getTransfer(p)===_t)u.defines.SRGB_TRANSFER="";let _=pm[v];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=w.texture,y.setRenderTarget(f),y.render(d,h),f=null,T=!1},this.isCompositing=function(){return T},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(l!==null)l.dispose();c.dispose(),u.dispose()}}var Vh=new Jt,El=new Fi(1,1),Wh=new zr,Xh=new Yo,qh=new Wr,Th=[],wh=[],Eh=new Float32Array(16),Ah=new Float32Array(9),Ch=new Float32Array(4);function Ss(e,t,n){let i=e[0];if(i<=0||i>0)return e;let s=t*n,r=Th[s];if(r===void 0)r=new Float32Array(s),Th[s]=r;if(t!==0){i.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=n,e[a].toArray(r,o)}return r}function kt(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Ht(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function ta(e,t){let n=wh[t];if(n===void 0)n=new Int32Array(t),wh[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function gm(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function _m(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(kt(n,t))return;e.uniform2fv(this.addr,t),Ht(n,t)}}function xm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(kt(n,t))return;e.uniform3fv(this.addr,t),Ht(n,t)}}function vm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(kt(n,t))return;e.uniform4fv(this.addr,t),Ht(n,t)}}function ym(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(kt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ht(n,t)}else{if(kt(n,i))return;Ch.set(i),e.uniformMatrix2fv(this.addr,!1,Ch),Ht(n,i)}}function Sm(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(kt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ht(n,t)}else{if(kt(n,i))return;Ah.set(i),e.uniformMatrix3fv(this.addr,!1,Ah),Ht(n,i)}}function Mm(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(kt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ht(n,t)}else{if(kt(n,i))return;Eh.set(i),e.uniformMatrix4fv(this.addr,!1,Eh),Ht(n,i)}}function bm(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Tm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(kt(n,t))return;e.uniform2iv(this.addr,t),Ht(n,t)}}function wm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(kt(n,t))return;e.uniform3iv(this.addr,t),Ht(n,t)}}function Em(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(kt(n,t))return;e.uniform4iv(this.addr,t),Ht(n,t)}}function Am(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function Cm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(kt(n,t))return;e.uniform2uiv(this.addr,t),Ht(n,t)}}function Rm(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(kt(n,t))return;e.uniform3uiv(this.addr,t),Ht(n,t)}}function Im(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(kt(n,t))return;e.uniform4uiv(this.addr,t),Ht(n,t)}}function Pm(e,t,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)e.uniform1i(this.addr,s),i[0]=s;let r;if(this.type===e.SAMPLER_2D_SHADOW)El.compareFunction=n.isReversedDepthBuffer()?Br:Or,r=El;else r=Vh;n.setTexture2D(t||r,s)}function Lm(e,t,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)e.uniform1i(this.addr,s),i[0]=s;n.setTexture3D(t||Xh,s)}function Nm(e,t,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)e.uniform1i(this.addr,s),i[0]=s;n.setTextureCube(t||qh,s)}function Dm(e,t,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)e.uniform1i(this.addr,s),i[0]=s;n.setTexture2DArray(t||Wh,s)}function Um(e){switch(e){case 5126:return gm;case 35664:return _m;case 35665:return xm;case 35666:return vm;case 35674:return ym;case 35675:return Sm;case 35676:return Mm;case 5124:case 35670:return bm;case 35667:case 35671:return Tm;case 35668:case 35672:return wm;case 35669:case 35673:return Em;case 5125:return Am;case 36294:return Cm;case 36295:return Rm;case 36296:return Im;case 35678:case 36198:case 36298:case 36306:case 35682:return Pm;case 35679:case 36299:case 36307:return Lm;case 35680:case 36300:case 36308:case 36293:return Nm;case 36289:case 36303:case 36311:case 36292:return Dm}}function Fm(e,t){e.uniform1fv(this.addr,t)}function Om(e,t){let n=Ss(t,this.size,2);e.uniform2fv(this.addr,n)}function Bm(e,t){let n=Ss(t,this.size,3);e.uniform3fv(this.addr,n)}function zm(e,t){let n=Ss(t,this.size,4);e.uniform4fv(this.addr,n)}function km(e,t){let n=Ss(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Gm(e,t){let n=Ss(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Hm(e,t){let n=Ss(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Vm(e,t){e.uniform1iv(this.addr,t)}function Wm(e,t){e.uniform2iv(this.addr,t)}function Xm(e,t){e.uniform3iv(this.addr,t)}function qm(e,t){e.uniform4iv(this.addr,t)}function Ym(e,t){e.uniform1uiv(this.addr,t)}function Zm(e,t){e.uniform2uiv(this.addr,t)}function Jm(e,t){e.uniform3uiv(this.addr,t)}function $m(e,t){e.uniform4uiv(this.addr,t)}function Km(e,t,n){let i=this.cache,s=t.length,r=ta(n,s);if(!kt(i,r))e.uniform1iv(this.addr,r),Ht(i,r);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=El;else a=Vh;for(let o=0;o!==s;++o)n.setTexture2D(t[o]||a,r[o])}function Qm(e,t,n){let i=this.cache,s=t.length,r=ta(n,s);if(!kt(i,r))e.uniform1iv(this.addr,r),Ht(i,r);for(let a=0;a!==s;++a)n.setTexture3D(t[a]||Xh,r[a])}function jm(e,t,n){let i=this.cache,s=t.length,r=ta(n,s);if(!kt(i,r))e.uniform1iv(this.addr,r),Ht(i,r);for(let a=0;a!==s;++a)n.setTextureCube(t[a]||qh,r[a])}function eg(e,t,n){let i=this.cache,s=t.length,r=ta(n,s);if(!kt(i,r))e.uniform1iv(this.addr,r),Ht(i,r);for(let a=0;a!==s;++a)n.setTexture2DArray(t[a]||Wh,r[a])}function tg(e){switch(e){case 5126:return Fm;case 35664:return Om;case 35665:return Bm;case 35666:return zm;case 35674:return km;case 35675:return Gm;case 35676:return Hm;case 5124:case 35670:return Vm;case 35667:case 35671:return Wm;case 35668:case 35672:return Xm;case 35669:case 35673:return qm;case 5125:return Ym;case 36294:return Zm;case 36295:return Jm;case 36296:return $m;case 35678:case 36198:case 36298:case 36306:case 35682:return Km;case 35679:case 36299:case 36307:return Qm;case 35680:case 36300:case 36308:case 36293:return jm;case 36289:case 36303:case 36311:case 36292:return eg}}class Yh{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Um(t.type)}}class Zh{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=tg(t.type)}}class Jh{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,r=i.length;s!==r;++s){let a=i[s];a.setValue(e,t[a.id],n)}}}var bl=/(\w+)(\])?(\[|\.)?/g;function Rh(e,t){e.seq.push(t),e.map[t.id]=t}function ng(e,t,n){let i=e.name,s=i.length;bl.lastIndex=0;while(!0){let r=bl.exec(i),a=bl.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l)o=o|0;if(c===void 0||c==="["&&a+2===s){Rh(n,c===void 0?new Yh(o,e,t):new Zh(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new Jh(o),Rh(n,d);n=d}}}class Js{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let a=e.getActiveUniform(t,r),o=e.getUniformLocation(t,a.name);ng(a,o,this)}let i=[],s=[];for(let r of this.seq)if(r.type===e.SAMPLER_2D_SHADOW||r.type===e.SAMPLER_CUBE_SHADOW||r.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(r);else s.push(r);if(i.length>0)this.seq=i.concat(s)}setValue(e,t,n,i){let s=this.map[t];if(s!==void 0)s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,r=t.length;s!==r;++s){let a=t[s],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let r=e[i];if(r.id in t)n.push(r)}return n}}function Ih(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var ig=37297,sg=0;function rg(e,t){let n=e.split(`
|
|
4119
4119
|
`),i=[],s=Math.max(t-6,0),r=Math.min(t+6,n.length);for(let a=s;a<r;a++){let o=a+1;i.push(`${o===t?">":" "} ${o}: ${n[a]}`)}return i.join(`
|
|
4120
|
-
`)}var Ph=new ke;function ag(e){je._getMatrix(Ph,je.workingColorSpace,e);let t=`mat3( ${Ph.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case
|
|
4120
|
+
`)}var Ph=new ke;function ag(e){je._getMatrix(Ph,je.workingColorSpace,e);let t=`mat3( ${Ph.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Ho:return[t,"LinearTransferOETF"];case _t:return[t,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Lh(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`
|
|
4121
4121
|
|
|
4122
4122
|
`+r+`
|
|
4123
4123
|
|
|
4124
4124
|
`+rg(e.getShaderSource(t),o)}else return r}function og(e,t){let n=ag(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
|
|
4125
|
-
`)}var lg={[
|
|
4126
|
-
`)}function ug(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(
|
|
4125
|
+
`)}var lg={[Oa]:"Linear",[Ba]:"Reinhard",[za]:"Cineon",[ka]:"ACESFilmic",[Ha]:"AgX",[Va]:"Neutral",[Ga]:"Custom"};function cg(e,t){let n=lg[t];if(n===void 0)return Oe("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var jr=new O;function hg(){je.getLuminanceCoefficients(jr);let e=jr.x.toFixed(4),t=jr.y.toFixed(4),n=jr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
|
|
4126
|
+
`)}function ug(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zs).join(`
|
|
4127
4127
|
`)}function dg(e){let t=[];for(let n in e){let i=e[n];if(i===!1)continue;t.push("#define "+n+" "+i)}return t.join(`
|
|
4128
|
-
`)}function fg(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){let r=e.getActiveAttrib(t,s),a=r.name,o=1;if(r.type===e.FLOAT_MAT2)o=2;if(r.type===e.FLOAT_MAT3)o=3;if(r.type===e.FLOAT_MAT4)o=4;n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function
|
|
4128
|
+
`)}function fg(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){let r=e.getActiveAttrib(t,s),a=r.name,o=1;if(r.type===e.FLOAT_MAT2)o=2;if(r.type===e.FLOAT_MAT3)o=3;if(r.type===e.FLOAT_MAT4)o=4;n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function Zs(e){return e!==""}function Nh(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dh(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var pg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Al(e){return e.replace(pg,gg)}var mg=new Map;function gg(e,t){let n=qe[t];if(n===void 0){let i=mg.get(t);if(i!==void 0)n=qe[i],Oe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Al(n)}var _g=/#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 Uh(e){return e.replace(_g,xg)}function xg(e,t,n,i){let s="";for(let r=parseInt(t);r<parseInt(n);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Fh(e){let t=`precision ${e.precision} float;
|
|
4129
4129
|
precision ${e.precision} int;
|
|
4130
4130
|
precision ${e.precision} sampler2D;
|
|
4131
4131
|
precision ${e.precision} samplerCube;
|
|
@@ -4145,19 +4145,19 @@ void main() {
|
|
|
4145
4145
|
`;if(e.precision==="highp")t+=`
|
|
4146
4146
|
#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
|
|
4147
4147
|
#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
|
|
4148
|
-
#define LOW_PRECISION`;return t}var vg={[
|
|
4149
|
-
`:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(
|
|
4148
|
+
#define LOW_PRECISION`;return t}var vg={[Ls]:"SHADOWMAP_TYPE_PCF",[ds]:"SHADOWMAP_TYPE_VSM"};function yg(e){return vg[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Sg={[ms]:"ENVMAP_TYPE_CUBE",[Ci]:"ENVMAP_TYPE_CUBE",[Ns]:"ENVMAP_TYPE_CUBE_UV"};function Mg(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return Sg[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var bg={[Ci]:"ENVMAP_MODE_REFRACTION"};function Tg(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return bg[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var wg={[Xc]:"ENVMAP_BLENDING_MULTIPLY",[qc]:"ENVMAP_BLENDING_MIX",[Yc]:"ENVMAP_BLENDING_ADD"};function Eg(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return wg[e.combine]||"ENVMAP_BLENDING_NONE"}function Ag(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function Cg(e,t,n,i){let s=e.getContext(),{defines:r,vertexShader:a,fragmentShader:o}=n,l=yg(n),c=Mg(n),u=Tg(n),d=Eg(n),h=Ag(n),p=ug(n),v=dg(r),T=s.createProgram(),m,f,E=n.glslVersion?"#version "+n.glslVersion+`
|
|
4149
|
+
`:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(Zs).join(`
|
|
4150
4150
|
`),m.length>0)m+=`
|
|
4151
|
-
`;if(f=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(
|
|
4151
|
+
`;if(f=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(Zs).join(`
|
|
4152
4152
|
`),f.length>0)f+=`
|
|
4153
4153
|
`}else m=[Fh(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
|
|
4154
|
-
`].filter(
|
|
4154
|
+
`].filter(Zs).join(`
|
|
4155
4155
|
`),f=[Fh(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Rn?"#define TONE_MAPPING":"",n.toneMapping!==Rn?qe.tonemapping_pars_fragment:"",n.toneMapping!==Rn?cg("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",qe.colorspace_pars_fragment,og("linearToOutputTexel",n.outputColorSpace),hg(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
|
|
4156
|
-
`].filter(
|
|
4156
|
+
`].filter(Zs).join(`
|
|
4157
4157
|
`);if(a=Al(a),a=Nh(a,n),a=Dh(a,n),o=Al(o),o=Nh(o,n),o=Dh(o,n),a=Uh(a),o=Uh(o),n.isRawShaderMaterial!==!0)E=`#version 300 es
|
|
4158
4158
|
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4159
4159
|
`)+`
|
|
4160
|
-
`+m,f=["#define varying in",n.glslVersion===
|
|
4160
|
+
`+m,f=["#define varying in",n.glslVersion===Vo?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Vo?"":"#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(`
|
|
4161
4161
|
`)+`
|
|
4162
4162
|
`+f;let C=E+m+a,y=E+f+o,b=Ih(s,s.VERTEX_SHADER,C),w=Ih(s,s.FRAGMENT_SHADER,y);if(s.attachShader(T,b),s.attachShader(T,w),n.index0AttributeName!==void 0)s.bindAttribLocation(T,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)s.bindAttribLocation(T,0,"position");s.linkProgram(T);function A(R){if(e.debug.checkShaderErrors){let U=s.getProgramInfoLog(T)||"",W=s.getShaderInfoLog(b)||"",P=s.getShaderInfoLog(w)||"",H=U.trim(),j=W.trim(),G=P.trim(),re=!0,q=!0;if(s.getProgramParameter(T,s.LINK_STATUS)===!1)if(re=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(s,T,b,w);else{let te=Lh(s,b,"vertex"),ee=Lh(s,w,"fragment");Ue("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(T,s.VALIDATE_STATUS)+`
|
|
4163
4163
|
|
|
@@ -4166,7 +4166,7 @@ Material Type: `+R.type+`
|
|
|
4166
4166
|
|
|
4167
4167
|
Program Info Log: `+H+`
|
|
4168
4168
|
`+te+`
|
|
4169
|
-
`+ee)}else if(H!=="")Oe("WebGLProgram: Program Info Log:",H);else if(j===""||G==="")q=!1;if(q)R.diagnostics={runnable:re,programLog:H,vertexShader:{log:j,prefix:m},fragmentShader:{log:G,prefix:f}}}s.deleteShader(b),s.deleteShader(w),_=new fr(s,T),M=fg(s,T)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let B=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(B===!1)B=s.getProgramParameter(T,ig);return B},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(T),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=sg++,this.cacheKey=t,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=w,this}var Rg=0;class $h{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Kh(e),t.set(e,n);return n}}class Kh{constructor(e){this.id=Rg++,this.code=e,this.usedTimes=0}}function Ig(e){return e===Di||e===$r||e===Kr}function Pg(e,t,n,i,s,r){let a=new js,o=new $h,l=new Set,c=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 v(_){if(l.add(_),_===0)return"uv";return`uv${_}`}function T(_,M,B,R,U,W){let P=R.fog,H=U.geometry,j=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,re=t.get(_.envMap||j,G),q=!!re&&re.mapping===Zs?re.image.height:null,te=p[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Oe("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,me=ee!==void 0?ee.length:0,we=0;if(H.morphAttributes.position!==void 0)we=1;if(H.morphAttributes.normal!==void 0)we=2;if(H.morphAttributes.color!==void 0)we=3;let He,Fe,Y,se;if(te){let ct=Wn[te];He=ct.vertexShader,Fe=ct.fragmentShader}else{He=_.vertexShader,Fe=_.fragmentShader;let ct=o.getVertexShaderStage(_),nt=o.getFragmentShaderStage(_);o.update(_,ct,nt),Y=ct.id,se=nt.id}let ae=e.getRenderTarget(),Re=e.state.buffers.depth.getReversed(),Ie=U.isInstancedMesh===!0,De=U.isBatchedMesh===!0,Rt=!!_.map,Ye=!!_.matcap,Ze=!!re,st=!!_.aoMap,Qe=!!_.lightMap,Ot=!!_.bumpMap&&_.wireframe===!1,dt=!!_.normalMap,Lt=!!_.displacementMap,bt=!!_.emissiveMap,wt=!!_.metalnessMap,L=!!_.roughnessMap,kt=_.anisotropy>0,et=_.clearcoat>0,xt=_.dispersion>0,S=_.retroreflectivity>0,g=_.iridescence>0,I=_.sheen>0,V=_.transmission>0,ie=kt&&!!_.anisotropyMap,le=et&&!!_.clearcoatMap,de=et&&!!_.clearcoatNormalMap,Z=et&&!!_.clearcoatRoughnessMap,Q=g&&!!_.iridescenceMap,fe=g&&!!_.iridescenceThicknessMap,Pe=I&&!!_.sheenColorMap,pe=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Te=!!_.specularColorMap,Le=!!_.specularIntensityMap,$e=V&&!!_.transmissionMap,N=V&&!!_.thicknessMap,he=!!_.gradientMap,J=!!_.alphaMap,ue=_.alphaTest>0,Se=!!_.alphaHash,ne=!!_.extensions,ge=Rn;if(_.toneMapped){if(ae===null||ae.isXRRenderTarget===!0)ge=e.toneMapping}let Be={shaderID:te,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:Fe,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:se,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:De,batchingColor:De&&U._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&U.instanceColor!==null,instancingMorph:Ie&&U.morphTexture!==null,outputColorSpace:ae===null?e.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Rt,matcap:Ye,envMap:Ze,envMapMode:Ze&&re.mapping,envMapCubeUVHeight:q,aoMap:st,lightMap:Qe,bumpMap:Ot,normalMap:dt,displacementMap:Lt,emissiveMap:bt,normalMapObjectSpace:dt&&_.normalMapType===nh,normalMapTangentSpace:dt&&_.normalMapType===Ho,packedNormalMap:dt&&_.normalMapType===Ho&&Ig(_.normalMap.format),metalnessMap:wt,roughnessMap:L,anisotropy:kt,anisotropyMap:ie,clearcoat:et,clearcoatMap:le,clearcoatNormalMap:de,clearcoatRoughnessMap:Z,dispersion:xt,retroreflection:S,iridescence:g,iridescenceMap:Q,iridescenceThicknessMap:fe,sheen:I,sheenColorMap:Pe,sheenRoughnessMap:pe,specularMap:oe,specularColorMap:Te,specularIntensityMap:Le,transmission:V,transmissionMap:$e,thicknessMap:N,gradientMap:he,opaque:_.transparent===!1&&_.blending===Cn&&_.alphaToCoverage===!1,alphaMap:J,alphaTest:ue,alphaHash:Se,combine:_.combine,mapUv:Rt&&v(_.map.channel),aoMapUv:st&&v(_.aoMap.channel),lightMapUv:Qe&&v(_.lightMap.channel),bumpMapUv:Ot&&v(_.bumpMap.channel),normalMapUv:dt&&v(_.normalMap.channel),displacementMapUv:Lt&&v(_.displacementMap.channel),emissiveMapUv:bt&&v(_.emissiveMap.channel),metalnessMapUv:wt&&v(_.metalnessMap.channel),roughnessMapUv:L&&v(_.roughnessMap.channel),anisotropyMapUv:ie&&v(_.anisotropyMap.channel),clearcoatMapUv:le&&v(_.clearcoatMap.channel),clearcoatNormalMapUv:de&&v(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Z&&v(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&v(_.iridescenceMap.channel),iridescenceThicknessMapUv:fe&&v(_.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&v(_.sheenColorMap.channel),sheenRoughnessMapUv:pe&&v(_.sheenRoughnessMap.channel),specularMapUv:oe&&v(_.specularMap.channel),specularColorMapUv:Te&&v(_.specularColorMap.channel),specularIntensityMapUv:Le&&v(_.specularIntensityMap.channel),transmissionMapUv:$e&&v(_.transmissionMap.channel),thicknessMapUv:N&&v(_.thicknessMap.channel),alphaMapUv:J&&v(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(dt||kt),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!H.attributes.uv&&(Rt||J),fog:!!P,useFog:_.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&dt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Re,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:we,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&B.length>0,shadowMapType:e.shadowMap.type,toneMapping:ge,decodeVideoTexture:Rt&&_.map.isVideoTexture===!0&&je.getTransfer(_.map.colorSpace)===_t,decodeVideoTextureEmissive:bt&&_.emissiveMap.isVideoTexture===!0&&je.getTransfer(_.emissiveMap.colorSpace)===_t,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===cn,flipSided:_.side===Wt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||De)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=l.has(1),Be.vertexUv2s=l.has(2),Be.vertexUv3s=l.has(3),l.clear(),Be}function m(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let B in _.defines)M.push(B),M.push(_.defines[B]);if(_.isRawShaderMaterial===!1)f(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function f(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,M){if(a.disableAll(),M.instancing)a.enable(0);if(M.instancingColor)a.enable(1);if(M.instancingMorph)a.enable(2);if(M.matcap)a.enable(3);if(M.envMap)a.enable(4);if(M.normalMapObjectSpace)a.enable(5);if(M.normalMapTangentSpace)a.enable(6);if(M.clearcoat)a.enable(7);if(M.iridescence)a.enable(8);if(M.alphaTest)a.enable(9);if(M.vertexColors)a.enable(10);if(M.vertexAlphas)a.enable(11);if(M.vertexUv1s)a.enable(12);if(M.vertexUv2s)a.enable(13);if(M.vertexUv3s)a.enable(14);if(M.vertexTangents)a.enable(15);if(M.anisotropy)a.enable(16);if(M.alphaHash)a.enable(17);if(M.batching)a.enable(18);if(M.dispersion)a.enable(19);if(M.retroreflection)a.enable(24);if(M.batchingColor)a.enable(20);if(M.gradientMap)a.enable(21);if(M.packedNormalMap)a.enable(22);if(M.vertexNormals)a.enable(23);if(_.push(a.mask),a.disableAll(),M.fog)a.enable(0);if(M.useFog)a.enable(1);if(M.flatShading)a.enable(2);if(M.logarithmicDepthBuffer)a.enable(3);if(M.reversedDepthBuffer)a.enable(4);if(M.skinning)a.enable(5);if(M.morphTargets)a.enable(6);if(M.morphNormals)a.enable(7);if(M.morphColors)a.enable(8);if(M.premultipliedAlpha)a.enable(9);if(M.shadowMapEnabled)a.enable(10);if(M.doubleSided)a.enable(11);if(M.flipSided)a.enable(12);if(M.useDepthPacking)a.enable(13);if(M.dithering)a.enable(14);if(M.transmission)a.enable(15);if(M.sheen)a.enable(16);if(M.opaque)a.enable(17);if(M.pointsUvs)a.enable(18);if(M.decodeVideoTexture)a.enable(19);if(M.decodeVideoTextureEmissive)a.enable(20);if(M.alphaToCoverage)a.enable(21);if(M.numLightProbeGrids>0)a.enable(22);if(M.hasPositionAttribute)a.enable(23);_.push(a.mask)}function C(_){let M=p[_.type],B;if(M){let R=Wn[M];B=mh.clone(R.uniforms)}else B=_.uniforms;return B}function y(_,M){let B=u.get(M);if(B!==void 0)++B.usedTimes;else B=new Cg(e,M,_,s),c.push(B),u.set(M,B);return B}function b(_){if(--_.usedTimes===0){let M=c.indexOf(_);c[M]=c[c.length-1],c.pop(),u.delete(_.cacheKey),_.destroy()}}function w(_){o.remove(_)}function A(){o.dispose()}return{getParameters:T,getProgramCacheKey:m,getUniforms:C,acquireProgram:y,releaseProgram:b,releaseShaderCache:w,programs:c,dispose:A}}function Lg(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function s(a,o,l){e.get(a)[o]=l}function r(){e=new WeakMap}return{has:t,get:n,remove:i,update:s,dispose:r}}function Ng(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Oh(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Bh(){let e=[],t=0,n=[],i=[],s=[];function r(){t=0,n.length=0,i.length=0,s.length=0}function a(h){let p=0;if(h.isInstancedMesh)p+=2;if(h.isSkinnedMesh)p+=1;return p}function o(h,p,v,T,m,f){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:p,material:v,materialVariant:a(h),groupOrder:T,renderOrder:h.renderOrder,z:m,group:f},e[t]=E;else E.id=h.id,E.object=h,E.geometry=p,E.material=v,E.materialVariant=a(h),E.groupOrder=T,E.renderOrder=h.renderOrder,E.z=m,E.group=f;return t++,E}function l(h,p,v,T,m,f,E){if(E.reversedDepth===!0)m=-m;let C=o(h,p,v,T,m,f);if(v.transmission>0)i.push(C);else if(v.transparent===!0)s.push(C);else n.push(C)}function c(h,p,v,T,m,f){let E=o(h,p,v,T,m,f);if(v.transmission>0)i.unshift(E);else if(v.transparent===!0)s.unshift(E);else n.unshift(E)}function u(h,p){if(n.length>1)n.sort(h||Ng);if(i.length>1)i.sort(p||Oh);if(s.length>1)s.sort(p||Oh)}function d(){for(let h=t,p=e.length;h<p;h++){let v=e[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:n,transmissive:i,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function Dg(){let e=new WeakMap;function t(i,s){let r=e.get(i),a;if(r===void 0)a=new Bh,e.set(i,[a]);else if(s>=r.length)a=new Bh,r.push(a);else a=r[s];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ug(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new We};break;case"SpotLight":n={position:new O,direction:new O,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new We,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new We,groundColor:new We};break;case"RectAreaLight":n={color:new We,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function Fg(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var Og=0;function Bg(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function zg(e){let t=new Ug,n=Fg(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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++)i.probe.push(new O);let s=new O,r=new yt,a=new yt;function o(c){let u=0,d=0,h=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let p=0,v=0,T=0,m=0,f=0,E=0,C=0,y=0,b=0,w=0,A=0,_=0,M=0,B=0;c.sort(Bg);for(let U=0,W=c.length;U<W;U++){let P=c[U],{color:H,intensity:j,distance:G}=P,re=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===Di)re=P.shadow.map.texture;else re=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=H.r*j,d+=H.g*j,h+=H.b*j;else if(P.isLightProbe){for(let q=0;q<9;q++)i.probe[q].addScaledVector(P.sh.coefficients[q],j);B++}else if(P.isSunLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize.copy(te.mapSize).multiply(te.getFrameExtents()),i.sunShadow[v]=ee,i.sunShadowMap[v]=re;let me=te.getViewportCount();for(let we=0;we<me;we++)i.sunShadowMatrix[T+we]=te.getMatrix(we),i.sunShadowCascade[T+we]=te._cascadeData[we];T+=me,v++}i.sun[p]=q,p++}else if(P.isDirectionalLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.directionalShadow[m]=ee,i.directionalShadowMap[m]=re,i.directionalShadowMatrix[m]=P.shadow.matrix,b++}i.directional[m]=q,m++}else if(P.isSpotLight){let q=t.get(P);q.position.setFromMatrixPosition(P.matrixWorld),q.color.copy(H).multiplyScalar(j),q.distance=G,q.coneCos=Math.cos(P.angle),q.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),q.decay=P.decay,i.spot[E]=q;let te=P.shadow;if(P.map){if(i.spotLightMap[_]=P.map,_++,te.updateMatrices(P),P.castShadow)M++}if(i.spotLightMatrix[E]=te.matrix,P.castShadow){let ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=re,A++}E++}else if(P.isRectAreaLight){let q=t.get(P);q.color.copy(H).multiplyScalar(j),q.halfWidth.set(P.width*0.5,0,0),q.halfHeight.set(0,P.height*0.5,0),i.rectArea[C]=q,C++}else if(P.isPointLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),q.distance=P.distance,q.decay=P.decay,P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,ee.shadowCameraNear=te.camera.near,ee.shadowCameraFar=te.camera.far,i.pointShadow[f]=ee,i.pointShadowMap[f]=re,i.pointShadowMatrix[f]=P.shadow.matrix,w++}i.point[f]=q,f++}else if(P.isHemisphereLight){let q=t.get(P);q.skyColor.copy(P.color).multiplyScalar(j),q.groundColor.copy(P.groundColor).multiplyScalar(j),i.hemi[y]=q,y++}}if(C>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=_e.LTC_FLOAT_1,i.rectAreaLTC2=_e.LTC_FLOAT_2;else i.rectAreaLTC1=_e.LTC_HALF_1,i.rectAreaLTC2=_e.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let R=i.hash;if(R.sunLength!==p||R.directionalLength!==m||R.pointLength!==f||R.spotLength!==E||R.rectAreaLength!==C||R.hemiLength!==y||R.numSunShadows!==v||R.numDirectionalShadows!==b||R.numPointShadows!==w||R.numSpotShadows!==A||R.numSpotMaps!==_||R.numLightProbes!==B)i.sun.length=p,i.directional.length=m,i.spot.length=E,i.rectArea.length=C,i.point.length=f,i.hemi.length=y,i.sunShadow.length=v,i.sunShadowMap.length=v,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=w,i.pointShadowMap.length=w,i.pointShadowMatrix.length=w,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=B,R.sunLength=p,R.directionalLength=m,R.pointLength=f,R.spotLength=E,R.rectAreaLength=C,R.hemiLength=y,R.numSunShadows=v,R.numDirectionalShadows=b,R.numPointShadows=w,R.numSpotShadows=A,R.numSpotMaps=_,R.numLightProbes=B,i.version=Og++}function l(c,u){let d=0,h=0,p=0,v=0,T=0,m=0,f=u.matrixWorldInverse;for(let E=0,C=c.length;E<C;E++){let y=c[E];if(y.isSunLight){let b=i.sun[d];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),d++}else if(y.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),h++}else if(y.isSpotLight){let b=i.spot[v];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),v++}else if(y.isRectAreaLight){let b=i.rectArea[T];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),a.identity(),r.copy(y.matrixWorld),r.premultiply(f),a.extractRotation(r),b.halfWidth.set(y.width*0.5,0,0),b.halfHeight.set(0,y.height*0.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),T++}else if(y.isPointLight){let b=i.point[p];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),p++}else if(y.isHemisphereLight){let b=i.hemi[m];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),m++}}}return{setup:o,setupView:l,state:i}}function zh(e){let t=new zg(e),n=[],i=[],s=[];function r(h){d.camera=h,n.length=0,i.length=0,s.length=0}function a(h){n.push(h)}function o(h){i.push(h)}function l(h){s.push(h)}function c(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function kg(e){let t=new WeakMap;function n(s,r=0){let a=t.get(s),o;if(a===void 0)o=new zh(e),t.set(s,[o]);else if(r>=a.length)o=new zh(e),a.push(o);else o=a[r];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}var Gg=`void main() {
|
|
4169
|
+
`+ee)}else if(H!=="")Oe("WebGLProgram: Program Info Log:",H);else if(j===""||G==="")q=!1;if(q)R.diagnostics={runnable:re,programLog:H,vertexShader:{log:j,prefix:m},fragmentShader:{log:G,prefix:f}}}s.deleteShader(b),s.deleteShader(w),_=new Js(s,T),M=fg(s,T)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let B=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(B===!1)B=s.getProgramParameter(T,ig);return B},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(T),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=sg++,this.cacheKey=t,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=w,this}var Rg=0;class $h{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new Kh(e),t.set(e,n);return n}}class Kh{constructor(e){this.id=Rg++,this.code=e,this.usedTimes=0}}function Ig(e){return e===Ni||e===Ur||e===Fr}function Pg(e,t,n,i,s,r){let a=new Bs,o=new $h,l=new Set,c=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 v(_){if(l.add(_),_===0)return"uv";return`uv${_}`}function T(_,M,B,R,U,W){let P=R.fog,H=U.geometry,j=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,re=t.get(_.envMap||j,G),q=!!re&&re.mapping===Ns?re.image.height:null,te=p[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Oe("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,me=ee!==void 0?ee.length:0,we=0;if(H.morphAttributes.position!==void 0)we=1;if(H.morphAttributes.normal!==void 0)we=2;if(H.morphAttributes.color!==void 0)we=3;let He,Fe,Y,se;if(te){let ct=Vn[te];He=ct.vertexShader,Fe=ct.fragmentShader}else{He=_.vertexShader,Fe=_.fragmentShader;let ct=o.getVertexShaderStage(_),nt=o.getFragmentShaderStage(_);o.update(_,ct,nt),Y=ct.id,se=nt.id}let ae=e.getRenderTarget(),Re=e.state.buffers.depth.getReversed(),Ie=U.isInstancedMesh===!0,De=U.isBatchedMesh===!0,Pt=!!_.map,Ye=!!_.matcap,Ze=!!re,st=!!_.aoMap,Qe=!!_.lightMap,zt=!!_.bumpMap&&_.wireframe===!1,ut=!!_.normalMap,Nt=!!_.displacementMap,bt=!!_.emissiveMap,Tt=!!_.metalnessMap,L=!!_.roughnessMap,Vt=_.anisotropy>0,et=_.clearcoat>0,xt=_.dispersion>0,S=_.retroreflectivity>0,g=_.iridescence>0,I=_.sheen>0,V=_.transmission>0,ie=Vt&&!!_.anisotropyMap,le=et&&!!_.clearcoatMap,de=et&&!!_.clearcoatNormalMap,Z=et&&!!_.clearcoatRoughnessMap,Q=g&&!!_.iridescenceMap,fe=g&&!!_.iridescenceThicknessMap,Pe=I&&!!_.sheenColorMap,pe=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Te=!!_.specularColorMap,Le=!!_.specularIntensityMap,$e=V&&!!_.transmissionMap,N=V&&!!_.thicknessMap,he=!!_.gradientMap,J=!!_.alphaMap,ue=_.alphaTest>0,Se=!!_.alphaHash,ne=!!_.extensions,ge=Rn;if(_.toneMapped){if(ae===null||ae.isXRRenderTarget===!0)ge=e.toneMapping}let Be={shaderID:te,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:Fe,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:se,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:De,batchingColor:De&&U._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&U.instanceColor!==null,instancingMorph:Ie&&U.morphTexture!==null,outputColorSpace:ae===null?e.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Pt,matcap:Ye,envMap:Ze,envMapMode:Ze&&re.mapping,envMapCubeUVHeight:q,aoMap:st,lightMap:Qe,bumpMap:zt,normalMap:ut,displacementMap:Nt,emissiveMap:bt,normalMapObjectSpace:ut&&_.normalMapType===nh,normalMapTangentSpace:ut&&_.normalMapType===zo,packedNormalMap:ut&&_.normalMapType===zo&&Ig(_.normalMap.format),metalnessMap:Tt,roughnessMap:L,anisotropy:Vt,anisotropyMap:ie,clearcoat:et,clearcoatMap:le,clearcoatNormalMap:de,clearcoatRoughnessMap:Z,dispersion:xt,retroreflection:S,iridescence:g,iridescenceMap:Q,iridescenceThicknessMap:fe,sheen:I,sheenColorMap:Pe,sheenRoughnessMap:pe,specularMap:oe,specularColorMap:Te,specularIntensityMap:Le,transmission:V,transmissionMap:$e,thicknessMap:N,gradientMap:he,opaque:_.transparent===!1&&_.blending===Cn&&_.alphaToCoverage===!1,alphaMap:J,alphaTest:ue,alphaHash:Se,combine:_.combine,mapUv:Pt&&v(_.map.channel),aoMapUv:st&&v(_.aoMap.channel),lightMapUv:Qe&&v(_.lightMap.channel),bumpMapUv:zt&&v(_.bumpMap.channel),normalMapUv:ut&&v(_.normalMap.channel),displacementMapUv:Nt&&v(_.displacementMap.channel),emissiveMapUv:bt&&v(_.emissiveMap.channel),metalnessMapUv:Tt&&v(_.metalnessMap.channel),roughnessMapUv:L&&v(_.roughnessMap.channel),anisotropyMapUv:ie&&v(_.anisotropyMap.channel),clearcoatMapUv:le&&v(_.clearcoatMap.channel),clearcoatNormalMapUv:de&&v(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Z&&v(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&v(_.iridescenceMap.channel),iridescenceThicknessMapUv:fe&&v(_.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&v(_.sheenColorMap.channel),sheenRoughnessMapUv:pe&&v(_.sheenRoughnessMap.channel),specularMapUv:oe&&v(_.specularMap.channel),specularColorMapUv:Te&&v(_.specularColorMap.channel),specularIntensityMapUv:Le&&v(_.specularIntensityMap.channel),transmissionMapUv:$e&&v(_.transmissionMap.channel),thicknessMapUv:N&&v(_.thicknessMap.channel),alphaMapUv:J&&v(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ut||Vt),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!H.attributes.uv&&(Pt||J),fog:!!P,useFog:_.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&ut===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Re,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:we,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&B.length>0,shadowMapType:e.shadowMap.type,toneMapping:ge,decodeVideoTexture:Pt&&_.map.isVideoTexture===!0&&je.getTransfer(_.map.colorSpace)===_t,decodeVideoTextureEmissive:bt&&_.emissiveMap.isVideoTexture===!0&&je.getTransfer(_.emissiveMap.colorSpace)===_t,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===cn,flipSided:_.side===qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||De)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=l.has(1),Be.vertexUv2s=l.has(2),Be.vertexUv3s=l.has(3),l.clear(),Be}function m(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let B in _.defines)M.push(B),M.push(_.defines[B]);if(_.isRawShaderMaterial===!1)f(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function f(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,M){if(a.disableAll(),M.instancing)a.enable(0);if(M.instancingColor)a.enable(1);if(M.instancingMorph)a.enable(2);if(M.matcap)a.enable(3);if(M.envMap)a.enable(4);if(M.normalMapObjectSpace)a.enable(5);if(M.normalMapTangentSpace)a.enable(6);if(M.clearcoat)a.enable(7);if(M.iridescence)a.enable(8);if(M.alphaTest)a.enable(9);if(M.vertexColors)a.enable(10);if(M.vertexAlphas)a.enable(11);if(M.vertexUv1s)a.enable(12);if(M.vertexUv2s)a.enable(13);if(M.vertexUv3s)a.enable(14);if(M.vertexTangents)a.enable(15);if(M.anisotropy)a.enable(16);if(M.alphaHash)a.enable(17);if(M.batching)a.enable(18);if(M.dispersion)a.enable(19);if(M.retroreflection)a.enable(24);if(M.batchingColor)a.enable(20);if(M.gradientMap)a.enable(21);if(M.packedNormalMap)a.enable(22);if(M.vertexNormals)a.enable(23);if(_.push(a.mask),a.disableAll(),M.fog)a.enable(0);if(M.useFog)a.enable(1);if(M.flatShading)a.enable(2);if(M.logarithmicDepthBuffer)a.enable(3);if(M.reversedDepthBuffer)a.enable(4);if(M.skinning)a.enable(5);if(M.morphTargets)a.enable(6);if(M.morphNormals)a.enable(7);if(M.morphColors)a.enable(8);if(M.premultipliedAlpha)a.enable(9);if(M.shadowMapEnabled)a.enable(10);if(M.doubleSided)a.enable(11);if(M.flipSided)a.enable(12);if(M.useDepthPacking)a.enable(13);if(M.dithering)a.enable(14);if(M.transmission)a.enable(15);if(M.sheen)a.enable(16);if(M.opaque)a.enable(17);if(M.pointsUvs)a.enable(18);if(M.decodeVideoTexture)a.enable(19);if(M.decodeVideoTextureEmissive)a.enable(20);if(M.alphaToCoverage)a.enable(21);if(M.numLightProbeGrids>0)a.enable(22);if(M.hasPositionAttribute)a.enable(23);_.push(a.mask)}function C(_){let M=p[_.type],B;if(M){let R=Vn[M];B=mh.clone(R.uniforms)}else B=_.uniforms;return B}function y(_,M){let B=u.get(M);if(B!==void 0)++B.usedTimes;else B=new Cg(e,M,_,s),c.push(B),u.set(M,B);return B}function b(_){if(--_.usedTimes===0){let M=c.indexOf(_);c[M]=c[c.length-1],c.pop(),u.delete(_.cacheKey),_.destroy()}}function w(_){o.remove(_)}function A(){o.dispose()}return{getParameters:T,getProgramCacheKey:m,getUniforms:C,acquireProgram:y,releaseProgram:b,releaseShaderCache:w,programs:c,dispose:A}}function Lg(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function s(a,o,l){e.get(a)[o]=l}function r(){e=new WeakMap}return{has:t,get:n,remove:i,update:s,dispose:r}}function Ng(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.material.id!==t.material.id)return e.material.id-t.material.id;else if(e.materialVariant!==t.materialVariant)return e.materialVariant-t.materialVariant;else if(e.z!==t.z)return e.z-t.z;else return e.id-t.id}function Oh(e,t){if(e.groupOrder!==t.groupOrder)return e.groupOrder-t.groupOrder;else if(e.renderOrder!==t.renderOrder)return e.renderOrder-t.renderOrder;else if(e.z!==t.z)return t.z-e.z;else return e.id-t.id}function Bh(){let e=[],t=0,n=[],i=[],s=[];function r(){t=0,n.length=0,i.length=0,s.length=0}function a(h){let p=0;if(h.isInstancedMesh)p+=2;if(h.isSkinnedMesh)p+=1;return p}function o(h,p,v,T,m,f){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:p,material:v,materialVariant:a(h),groupOrder:T,renderOrder:h.renderOrder,z:m,group:f},e[t]=E;else E.id=h.id,E.object=h,E.geometry=p,E.material=v,E.materialVariant=a(h),E.groupOrder=T,E.renderOrder=h.renderOrder,E.z=m,E.group=f;return t++,E}function l(h,p,v,T,m,f,E){if(E.reversedDepth===!0)m=-m;let C=o(h,p,v,T,m,f);if(v.transmission>0)i.push(C);else if(v.transparent===!0)s.push(C);else n.push(C)}function c(h,p,v,T,m,f){let E=o(h,p,v,T,m,f);if(v.transmission>0)i.unshift(E);else if(v.transparent===!0)s.unshift(E);else n.unshift(E)}function u(h,p){if(n.length>1)n.sort(h||Ng);if(i.length>1)i.sort(p||Oh);if(s.length>1)s.sort(p||Oh)}function d(){for(let h=t,p=e.length;h<p;h++){let v=e[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:n,transmissive:i,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function Dg(){let e=new WeakMap;function t(i,s){let r=e.get(i),a;if(r===void 0)a=new Bh,e.set(i,[a]);else if(s>=r.length)a=new Bh,r.push(a);else a=r[s];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ug(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new We};break;case"SpotLight":n={position:new O,direction:new O,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new We,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new We,groundColor:new We};break;case"RectAreaLight":n={color:new We,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function Fg(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var Og=0;function Bg(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function zg(e){let t=new Ug,n=Fg(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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++)i.probe.push(new O);let s=new O,r=new yt,a=new yt;function o(c){let u=0,d=0,h=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let p=0,v=0,T=0,m=0,f=0,E=0,C=0,y=0,b=0,w=0,A=0,_=0,M=0,B=0;c.sort(Bg);for(let U=0,W=c.length;U<W;U++){let P=c[U],{color:H,intensity:j,distance:G}=P,re=null;if(P.shadow&&P.shadow.map)if(P.shadow.map.texture.format===Ni)re=P.shadow.map.texture;else re=P.shadow.map.depthTexture||P.shadow.map.texture;if(P.isAmbientLight)u+=H.r*j,d+=H.g*j,h+=H.b*j;else if(P.isLightProbe){for(let q=0;q<9;q++)i.probe[q].addScaledVector(P.sh.coefficients[q],j);B++}else if(P.isSunLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize.copy(te.mapSize).multiply(te.getFrameExtents()),i.sunShadow[v]=ee,i.sunShadowMap[v]=re;let me=te.getViewportCount();for(let we=0;we<me;we++)i.sunShadowMatrix[T+we]=te.getMatrix(we),i.sunShadowCascade[T+we]=te._cascadeData[we];T+=me,v++}i.sun[p]=q,p++}else if(P.isDirectionalLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.directionalShadow[m]=ee,i.directionalShadowMap[m]=re,i.directionalShadowMatrix[m]=P.shadow.matrix,b++}i.directional[m]=q,m++}else if(P.isSpotLight){let q=t.get(P);q.position.setFromMatrixPosition(P.matrixWorld),q.color.copy(H).multiplyScalar(j),q.distance=G,q.coneCos=Math.cos(P.angle),q.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),q.decay=P.decay,i.spot[E]=q;let te=P.shadow;if(P.map){if(i.spotLightMap[_]=P.map,_++,te.updateMatrices(P),P.castShadow)M++}if(i.spotLightMatrix[E]=te.matrix,P.castShadow){let ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=re,A++}E++}else if(P.isRectAreaLight){let q=t.get(P);q.color.copy(H).multiplyScalar(j),q.halfWidth.set(P.width*0.5,0,0),q.halfHeight.set(0,P.height*0.5,0),i.rectArea[C]=q,C++}else if(P.isPointLight){let q=t.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),q.distance=P.distance,q.decay=P.decay,P.castShadow){let te=P.shadow,ee=n.get(P);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,ee.shadowCameraNear=te.camera.near,ee.shadowCameraFar=te.camera.far,i.pointShadow[f]=ee,i.pointShadowMap[f]=re,i.pointShadowMatrix[f]=P.shadow.matrix,w++}i.point[f]=q,f++}else if(P.isHemisphereLight){let q=t.get(P);q.skyColor.copy(P.color).multiplyScalar(j),q.groundColor.copy(P.groundColor).multiplyScalar(j),i.hemi[y]=q,y++}}if(C>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=_e.LTC_FLOAT_1,i.rectAreaLTC2=_e.LTC_FLOAT_2;else i.rectAreaLTC1=_e.LTC_HALF_1,i.rectAreaLTC2=_e.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let R=i.hash;if(R.sunLength!==p||R.directionalLength!==m||R.pointLength!==f||R.spotLength!==E||R.rectAreaLength!==C||R.hemiLength!==y||R.numSunShadows!==v||R.numDirectionalShadows!==b||R.numPointShadows!==w||R.numSpotShadows!==A||R.numSpotMaps!==_||R.numLightProbes!==B)i.sun.length=p,i.directional.length=m,i.spot.length=E,i.rectArea.length=C,i.point.length=f,i.hemi.length=y,i.sunShadow.length=v,i.sunShadowMap.length=v,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=w,i.pointShadowMap.length=w,i.pointShadowMatrix.length=w,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=B,R.sunLength=p,R.directionalLength=m,R.pointLength=f,R.spotLength=E,R.rectAreaLength=C,R.hemiLength=y,R.numSunShadows=v,R.numDirectionalShadows=b,R.numPointShadows=w,R.numSpotShadows=A,R.numSpotMaps=_,R.numLightProbes=B,i.version=Og++}function l(c,u){let d=0,h=0,p=0,v=0,T=0,m=0,f=u.matrixWorldInverse;for(let E=0,C=c.length;E<C;E++){let y=c[E];if(y.isSunLight){let b=i.sun[d];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),d++}else if(y.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),h++}else if(y.isSpotLight){let b=i.spot[v];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),v++}else if(y.isRectAreaLight){let b=i.rectArea[T];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),a.identity(),r.copy(y.matrixWorld),r.premultiply(f),a.extractRotation(r),b.halfWidth.set(y.width*0.5,0,0),b.halfHeight.set(0,y.height*0.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),T++}else if(y.isPointLight){let b=i.point[p];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),p++}else if(y.isHemisphereLight){let b=i.hemi[m];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),m++}}}return{setup:o,setupView:l,state:i}}function zh(e){let t=new zg(e),n=[],i=[],s=[];function r(h){d.camera=h,n.length=0,i.length=0,s.length=0}function a(h){n.push(h)}function o(h){i.push(h)}function l(h){s.push(h)}function c(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function kg(e){let t=new WeakMap;function n(s,r=0){let a=t.get(s),o;if(a===void 0)o=new zh(e),t.set(s,[o]);else if(r>=a.length)o=new zh(e),a.push(o);else o=a[r];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}var Gg=`void main() {
|
|
4170
4170
|
gl_Position = vec4( position, 1.0 );
|
|
4171
4171
|
}`,Hg=`uniform sampler2D shadow_pass;
|
|
4172
4172
|
uniform vec2 resolution;
|
|
@@ -4193,7 +4193,7 @@ void main() {
|
|
|
4193
4193
|
squared_mean = squared_mean / samples;
|
|
4194
4194
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4195
4195
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4196
|
-
}`,Vg=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],Wg=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],kh=new yt,ur=new O,Tl=new O;function Xg(e,t,n){let i=new rr,s=new ze,r=new ze,a=new Et,o=new el,l=new tl,c={},u=n.maxTextureSize,d={[As]:Wt,[Wt]:As,[cn]:cn},h=new Sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:Gg,fragmentShader:Hg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new mn;v.setAttribute("position",new yn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let T=new Ge(v,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ys;let f=this.type;this.render=function(w,A,_){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(w.length===0)return;if(this.type===_c)Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ys;let M=e.getRenderTarget(),B=e.getActiveCubeFace(),R=e.getActiveMipmapLevel(),U=e.state;if(U.setBlending(On),U.buffers.depth.getReversed()===!0)U.buffers.color.setClear(0,0,0,0);else U.buffers.color.setClear(1,1,1,1);U.buffers.depth.setTest(!0),U.setScissorTest(!1);let W=f!==this.type;if(W)A.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((H)=>H.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,H=w.length;P<H;P++){let j=w[P],G=j.shadow;if(G===void 0){Oe("WebGLShadowMap:",j,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let re=G.getFrameExtents();if(s.multiply(re),r.copy(G.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/re.x),s.x=r.x*re.x,G.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/re.y),s.y=r.y*re.y,G.mapSize.y=r.y}let q=e.state.buffers.depth.getReversed();if(G.camera._reversedDepth=q,G.map===null||W===!0){if(G.map!==null){if(G.map.depthTexture!==null)G.map.depthTexture.dispose(),G.map.depthTexture=null;G.map.dispose()}if(this.type===Es){if(j.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new pn(s.x,s.y,{format:Di,type:zn,minFilter:sn,magFilter:sn,generateMipmaps:!1}),G.map.texture.name=j.name+".shadowMap",G.map.depthTexture=new Oi(s.x,s.y,ti),G.map.depthTexture.name=j.name+".shadowMapDepth",G.map.depthTexture.format=Li,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=In,G.map.depthTexture.magFilter=In}else{if(j.isPointLight)G.map=new Cl(s.x),G.map.depthTexture=new Ko(s.x,mi);else G.map=new pn(s.x,s.y),G.map.depthTexture=new Oi(s.x,s.y,mi);if(G.map.depthTexture.name=j.name+".shadowMap",G.map.depthTexture.format=Li,this.type===Ys)G.map.depthTexture.compareFunction=q?jr:Qr,G.map.depthTexture.minFilter=sn,G.map.depthTexture.magFilter=sn;else G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=In,G.map.depthTexture.magFilter=In}G.camera.updateProjectionMatrix()}if(G.map.isWebGLCubeRenderTarget!==!0&&(G.map.width!==s.x||G.map.height!==s.y))G.map.setSize(s.x,s.y);let te=G.map.isWebGLCubeRenderTarget?6:G.getViewportCount();if(j.isPointLight!==!0)G.updateMatrices(j,_);for(let ee=0;ee<te;ee++){let me=G.getCamera(ee);if(j.isPointLight){let{camera:we,matrix:He}=G,Fe=j.distance||we.far;if(Fe!==we.far)we.far=Fe,we.updateProjectionMatrix();ur.setFromMatrixPosition(j.matrixWorld),we.position.copy(ur),Tl.copy(we.position),Tl.add(Vg[ee]),we.up.copy(Wg[ee]),we.lookAt(Tl),we.updateMatrixWorld(),He.makeTranslation(-ur.x,-ur.y,-ur.z),kh.multiplyMatrices(we.projectionMatrix,we.matrixWorldInverse),G._frustum.setFromProjectionMatrix(kh,we.coordinateSystem,we.reversedDepth)}if(G.map.isWebGLCubeRenderTarget)e.setRenderTarget(G.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(G.map),e.clear();let we=G.getViewport(ee);a.set(r.x*we.x,r.y*we.y,r.x*we.z,r.y*we.w),U.viewport(a)}i=G.getFrustum(ee),y(A,_,me,j,this.type)}if(G.isPointLightShadow!==!0&&this.type===Es)E(G,_);G.needsUpdate=!1}f=this.type,m.needsUpdate=!1,e.setRenderTarget(M,B,R)};function E(w,A){let _=t.update(T);if(h.defines.VSM_SAMPLES!==w.blurSamples)h.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0;if(w.mapPass===null)w.mapPass=new pn(s.x,s.y,{format:Di,type:zn});else if(w.mapPass.width!==w.map.width||w.mapPass.height!==w.map.height)w.mapPass.setSize(w.map.width,w.map.height);h.uniforms.shadow_pass.value=w.map.depthTexture,h.uniforms.resolution.value.set(w.map.width,w.map.height),h.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,T,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value.set(w.map.width,w.map.height),p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(A,null,_,p,T,null)}function C(w,A,_,M){let B=null,R=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)B=R;else if(B=_.isPointLight===!0?l:o,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=B.uuid,W=A.uuid,P=c[U];if(P===void 0)P={},c[U]=P;let H=P[W];if(H===void 0)H=B.clone(),P[W]=H,A.addEventListener("dispose",b);B=H}if(B.visible=A.visible,B.wireframe=A.wireframe,M===Es)B.side=A.shadowSide!==null?A.shadowSide:A.side;else B.side=A.shadowSide!==null?A.shadowSide:d[A.side];if(B.alphaMap=A.alphaMap,B.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,B.map=A.map,B.clipShadows=A.clipShadows,B.clippingPlanes=A.clippingPlanes,B.clipIntersection=A.clipIntersection,B.displacementMap=A.displacementMap,B.displacementScale=A.displacementScale,B.displacementBias=A.displacementBias,B.wireframeLinewidth=A.wireframeLinewidth,B.linewidth=A.linewidth,_.isPointLight===!0&&B.isMeshDistanceMaterial===!0){let U=e.properties.get(B);U.light=_}return B}function y(w,A,_,M,B){if(w.visible===!1)return;if(w.layers.test(A.layers)&&(w.isMesh||w.isLine||w.isPoints)){if((w.castShadow||w.receiveShadow&&B===Es)&&(!w.frustumCulled||w.intersectsFrustum(i))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let W=t.update(w),P=w.material;if(Array.isArray(P)){let H=W.groups;for(let j=0,G=H.length;j<G;j++){let re=H[j],q=P[re.materialIndex];if(q&&q.visible){let te=C(w,q,M,B);w.onBeforeShadow(e,w,A,_,W,te,re),e.renderBufferDirect(_,null,W,te,w,re),w.onAfterShadow(e,w,A,_,W,te,re)}}}else if(P.visible){let H=C(w,P,M,B);w.onBeforeShadow(e,w,A,_,W,H,null),e.renderBufferDirect(_,null,W,H,w,null),w.onAfterShadow(e,w,A,_,W,H,null)}}}let U=w.children;for(let W=0,P=U.length;W<P;W++)y(U[W],A,_,M,B)}function b(w){w.target.removeEventListener("dispose",b);for(let _ in c){let M=c[_],B=w.target.uuid;if(B in M)M[B].dispose(),delete M[B]}}}function qg(e,t){function n(){let N=!1,he=new Et,J=null,ue=new Et(0,0,0,0);return{setMask:function(Se){if(J!==Se&&!N)e.colorMask(Se,Se,Se,Se),J=Se},setLocked:function(Se){N=Se},setClear:function(Se,ne,ge,Be,ct){if(ct===!0)Se*=Be,ne*=Be,ge*=Be;if(he.set(Se,ne,ge,Be),ue.equals(he)===!1)e.clearColor(Se,ne,ge,Be),ue.copy(he)},reset:function(){N=!1,J=null,ue.set(-1,0,0,0)}}}function i(){let N=!1,he=!1,J=null,ue=null,Se=null;return{setReversed:function(ne){if(he!==ne){let ge=t.get("EXT_clip_control");if(ne)ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.ZERO_TO_ONE_EXT);else ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.NEGATIVE_ONE_TO_ONE_EXT);he=ne;let Be=Se;Se=null,this.setClear(Be)}},getReversed:function(){return he},setTest:function(ne){if(ne)ae(e.DEPTH_TEST);else Re(e.DEPTH_TEST)},setMask:function(ne){if(J!==ne&&!N)e.depthMask(ne),J=ne},setFunc:function(ne){if(he)ne=dh[ne];if(ue!==ne){switch(ne){case Bc:e.depthFunc(e.NEVER);break;case zc:e.depthFunc(e.ALWAYS);break;case kc:e.depthFunc(e.LESS);break;case Ka:e.depthFunc(e.LEQUAL);break;case Gc:e.depthFunc(e.EQUAL);break;case Hc:e.depthFunc(e.GEQUAL);break;case Vc:e.depthFunc(e.GREATER);break;case Wc:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ue=ne}},setLocked:function(ne){N=ne},setClear:function(ne){if(Se!==ne){if(Se=ne,he)ne=1-ne;e.clearDepth(ne)}},reset:function(){N=!1,J=null,ue=null,Se=null,he=!1}}}function s(){let N=!1,he=null,J=null,ue=null,Se=null,ne=null,ge=null,Be=null,ct=null;return{setTest:function(nt){if(!N)if(nt)ae(e.STENCIL_TEST);else Re(e.STENCIL_TEST)},setMask:function(nt){if(he!==nt&&!N)e.stencilMask(nt),he=nt},setFunc:function(nt,_n,F){if(J!==nt||ue!==_n||Se!==F)e.stencilFunc(nt,_n,F),J=nt,ue=_n,Se=F},setOp:function(nt,_n,F){if(ne!==nt||ge!==_n||Be!==F)e.stencilOp(nt,_n,F),ne=nt,ge=_n,Be=F},setLocked:function(nt){N=nt},setClear:function(nt){if(ct!==nt)e.clearStencil(nt),ct=nt},reset:function(){N=!1,he=null,J=null,ue=null,Se=null,ne=null,ge=null,Be=null,ct=null}}}let r=new n,a=new i,o=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new We(0,0,0),M=0,B=!1,R=null,U=null,W=null,P=null,H=null,j=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),G=!1,re=0,q=e.getParameter(e.VERSION);if(q.indexOf("WebGL")!==-1)re=parseFloat(/^WebGL (\d)/.exec(q)[1]),G=re>=1;else if(q.indexOf("OpenGL ES")!==-1)re=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),G=re>=2;let te=null,ee={},me=e.getParameter(e.SCISSOR_BOX),we=e.getParameter(e.VIEWPORT),He=new Et().fromArray(me),Fe=new Et().fromArray(we);function Y(N,he,J,ue){let Se=new Uint8Array(4),ne=e.createTexture();e.bindTexture(N,ne),e.texParameteri(N,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(N,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let ge=0;ge<J;ge++)if(N===e.TEXTURE_3D||N===e.TEXTURE_2D_ARRAY)e.texImage3D(he,0,e.RGBA,1,1,ue,0,e.RGBA,e.UNSIGNED_BYTE,Se);else e.texImage2D(he+ge,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Se);return ne}let se={};se[e.TEXTURE_2D]=Y(e.TEXTURE_2D,e.TEXTURE_2D,1),se[e.TEXTURE_CUBE_MAP]=Y(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[e.TEXTURE_2D_ARRAY]=Y(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),se[e.TEXTURE_3D]=Y(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(e.DEPTH_TEST),a.setFunc(Ka),Ot(!1),dt(Za),ae(e.CULL_FACE),st(On);function ae(N){if(u[N]!==!0)e.enable(N),u[N]=!0}function Re(N){if(u[N]!==!1)e.disable(N),u[N]=!1}function Ie(N,he){if(h[N]!==he){if(e.bindFramebuffer(N,he),h[N]=he,N===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=he;if(N===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=he;return!0}return!1}function De(N,he){let J=v,ue=!1;if(N){if(J=p.get(he),J===void 0)J=[],p.set(he,J);let Se=N.textures;if(J.length!==Se.length||J[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,ge=Se.length;ne<ge;ne++)J[ne]=e.COLOR_ATTACHMENT0+ne;J.length=Se.length,ue=!0}}else if(J[0]!==e.BACK)J[0]=e.BACK,ue=!0;if(ue)e.drawBuffers(J)}function Rt(N){if(T!==N)return e.useProgram(N),T=N,!0;return!1}let Ye={[Cs]:e.FUNC_ADD,[vc]:e.FUNC_SUBTRACT,[yc]:e.FUNC_REVERSE_SUBTRACT};Ye[Sc]=e.MIN,Ye[Mc]=e.MAX;let Ze={[bc]:e.ZERO,[Tc]:e.ONE,[wc]:e.SRC_COLOR,[Ac]:e.SRC_ALPHA,[Nc]:e.SRC_ALPHA_SATURATE,[Pc]:e.DST_COLOR,[Rc]:e.DST_ALPHA,[Ec]:e.ONE_MINUS_SRC_COLOR,[Cc]:e.ONE_MINUS_SRC_ALPHA,[Lc]:e.ONE_MINUS_DST_COLOR,[Ic]:e.ONE_MINUS_DST_ALPHA,[Dc]:e.CONSTANT_COLOR,[Uc]:e.ONE_MINUS_CONSTANT_COLOR,[Fc]:e.CONSTANT_ALPHA,[Oc]:e.ONE_MINUS_CONSTANT_ALPHA};function st(N,he,J,ue,Se,ne,ge,Be,ct,nt){if(N===On){if(m===!0)Re(e.BLEND),m=!1;return}if(m===!1)ae(e.BLEND),m=!0;if(N!==xc){if(N!==f||nt!==B){if(E!==Cs||b!==Cs)e.blendEquation(e.FUNC_ADD),E=Cs,b=Cs;if(nt)switch(N){case Cn:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ei:e.blendFunc(e.ONE,e.ONE);break;case Ja:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case $a:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",N);break}else switch(N){case Cn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ei:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Ja:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $a:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",N);break}C=null,y=null,w=null,A=null,_.set(0,0,0),M=0,f=N,B=nt}return}if(Se=Se||he,ne=ne||J,ge=ge||ue,he!==E||Se!==b)e.blendEquationSeparate(Ye[he],Ye[Se]),E=he,b=Se;if(J!==C||ue!==y||ne!==w||ge!==A)e.blendFuncSeparate(Ze[J],Ze[ue],Ze[ne],Ze[ge]),C=J,y=ue,w=ne,A=ge;if(Be.equals(_)===!1||ct!==M)e.blendColor(Be.r,Be.g,Be.b,ct),_.copy(Be),M=ct;f=N,B=!1}function Qe(N,he){N.side===cn?Re(e.CULL_FACE):ae(e.CULL_FACE);let J=N.side===Wt;if(he)J=!J;Ot(J),N.blending===Cn&&N.transparent===!1?st(On):st(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),r.setMask(N.colorWrite);let ue=N.stencilWrite;if(o.setTest(ue),ue)o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass);bt(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?ae(e.SAMPLE_ALPHA_TO_COVERAGE):Re(e.SAMPLE_ALPHA_TO_COVERAGE)}function Ot(N){if(R!==N){if(N)e.frontFace(e.CW);else e.frontFace(e.CCW);R=N}}function dt(N){if(N!==mc){if(ae(e.CULL_FACE),N!==U)if(N===Za)e.cullFace(e.BACK);else if(N===gc)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Re(e.CULL_FACE);U=N}function Lt(N){if(N!==W){if(G)e.lineWidth(N);W=N}}function bt(N,he,J){if(N){if(ae(e.POLYGON_OFFSET_FILL),P!==he||H!==J){if(P=he,H=J,a.getReversed())he=-he;e.polygonOffset(he,J)}}else Re(e.POLYGON_OFFSET_FILL)}function wt(N){if(N)ae(e.SCISSOR_TEST);else Re(e.SCISSOR_TEST)}function L(N){if(N===void 0)N=e.TEXTURE0+j-1;if(te!==N)e.activeTexture(N),te=N}function kt(N,he,J){if(J===void 0)if(te===null)J=e.TEXTURE0+j-1;else J=te;let ue=ee[J];if(ue===void 0)ue={type:void 0,texture:void 0},ee[J]=ue;if(ue.type!==N||ue.texture!==he){if(te!==J)e.activeTexture(J),te=J;e.bindTexture(N,he||se[N]),ue.type=N,ue.texture=he}}function et(){let N=ee[te];if(N!==void 0&&N.type!==void 0)e.bindTexture(N.type,null),N.type=void 0,N.texture=void 0}function xt(){try{e.compressedTexImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function S(){try{e.compressedTexImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function g(){try{e.texSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function I(){try{e.texSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function le(){try{e.texStorage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function de(){try{e.texStorage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Z(){try{e.texImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Q(){try{e.texImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function fe(N){if(d[N]!==void 0)return d[N];else return e.getParameter(N)}function Pe(N,he){if(d[N]!==he)e.pixelStorei(N,he),d[N]=he}function pe(N){if(He.equals(N)===!1)e.scissor(N.x,N.y,N.z,N.w),He.copy(N)}function oe(N){if(Fe.equals(N)===!1)e.viewport(N.x,N.y,N.z,N.w),Fe.copy(N)}function Te(N,he){let J=c.get(he);if(J===void 0)J=new WeakMap,c.set(he,J);let ue=J.get(N);if(ue===void 0)ue=e.getUniformBlockIndex(he,N.name),J.set(N,ue)}function Le(N,he){let ue=c.get(he).get(N);if(l.get(he)!==ue)e.uniformBlockBinding(he,ue,N.__bindingPointIndex),l.set(he,ue)}function $e(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),a.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},te=null,ee={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new We(0,0,0),M=0,B=!1,R=null,U=null,W=null,P=null,H=null,He.set(0,0,e.canvas.width,e.canvas.height),Fe.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ae,disable:Re,bindFramebuffer:Ie,drawBuffers:De,useProgram:Rt,setBlending:st,setMaterial:Qe,setFlipSided:Ot,setCullFace:dt,setLineWidth:Lt,setPolygonOffset:bt,setScissorTest:wt,activeTexture:L,bindTexture:kt,unbindTexture:et,compressedTexImage2D:xt,compressedTexImage3D:S,texImage2D:Z,texImage3D:Q,pixelStorei:Pe,getParameter:fe,updateUBOMapping:Te,uniformBlockBinding:Le,texStorage2D:le,texStorage3D:de,texSubImage2D:g,texSubImage3D:I,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:pe,viewport:oe,reset:$e}}function Yg(e,t,n,i,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ze,u=new WeakMap,d=new Set,h,p=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(S){}function T(S,g){return v?new OffscreenCanvas(S,g):Ws("canvas")}function m(S,g,I){let V=1,ie=xt(S);if(ie.width>I||ie.height>I)V=I/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){let le=Math.floor(V*ie.width),de=Math.floor(V*ie.height);if(h===void 0)h=T(le,de);let Z=g?T(le,de):h;return Z.width=le,Z.height=de,Z.getContext("2d").drawImage(S,0,0,le,de),Oe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+le+"x"+de+")."),Z}else{if("data"in S)Oe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return S}return S}function f(S){return S.generateMipmaps}function E(S){e.generateMipmap(S)}function C(S){if(S.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(S.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(S,g,I,V,ie,le=!1){if(S!==null){if(e[S]!==void 0)return e[S];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let de;if(V){if(de=t.get("EXT_texture_norm16"),!de)Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Z=g;if(g===e.RED){if(I===e.FLOAT)Z=e.R32F;if(I===e.HALF_FLOAT)Z=e.R16F;if(I===e.UNSIGNED_BYTE)Z=e.R8;if(I===e.UNSIGNED_SHORT&&de)Z=de.R16_EXT;if(I===e.SHORT&&de)Z=de.R16_SNORM_EXT}if(g===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.R8UI;if(I===e.UNSIGNED_SHORT)Z=e.R16UI;if(I===e.UNSIGNED_INT)Z=e.R32UI;if(I===e.BYTE)Z=e.R8I;if(I===e.SHORT)Z=e.R16I;if(I===e.INT)Z=e.R32I}if(g===e.RG){if(I===e.FLOAT)Z=e.RG32F;if(I===e.HALF_FLOAT)Z=e.RG16F;if(I===e.UNSIGNED_BYTE)Z=e.RG8;if(I===e.UNSIGNED_SHORT&&de)Z=de.RG16_EXT;if(I===e.SHORT&&de)Z=de.RG16_SNORM_EXT}if(g===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RG8UI;if(I===e.UNSIGNED_SHORT)Z=e.RG16UI;if(I===e.UNSIGNED_INT)Z=e.RG32UI;if(I===e.BYTE)Z=e.RG8I;if(I===e.SHORT)Z=e.RG16I;if(I===e.INT)Z=e.RG32I}if(g===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RGB8UI;if(I===e.UNSIGNED_SHORT)Z=e.RGB16UI;if(I===e.UNSIGNED_INT)Z=e.RGB32UI;if(I===e.BYTE)Z=e.RGB8I;if(I===e.SHORT)Z=e.RGB16I;if(I===e.INT)Z=e.RGB32I}if(g===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)Z=e.RGBA16UI;if(I===e.UNSIGNED_INT)Z=e.RGBA32UI;if(I===e.BYTE)Z=e.RGBA8I;if(I===e.SHORT)Z=e.RGBA16I;if(I===e.INT)Z=e.RGBA32I}if(g===e.RGB){if(I===e.UNSIGNED_SHORT&&de)Z=de.RGB16_EXT;if(I===e.SHORT&&de)Z=de.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)Z=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)Z=e.R11F_G11F_B10F}if(g===e.RGBA){let Q=le?Wo:je.getTransfer(ie);if(I===e.FLOAT)Z=e.RGBA32F;if(I===e.HALF_FLOAT)Z=e.RGBA16F;if(I===e.UNSIGNED_BYTE)Z=Q===_t?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&de)Z=de.RGBA16_EXT;if(I===e.SHORT&&de)Z=de.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)Z=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)Z=e.RGB5_A1}if(Z===e.R16F||Z===e.R32F||Z===e.RG16F||Z===e.RG32F||Z===e.RGBA16F||Z===e.RGBA32F)t.get("EXT_color_buffer_float");return Z}function b(S,g){let I;if(S){if(g===null||g===mi||g===Is)I=e.DEPTH24_STENCIL8;else if(g===ti)I=e.DEPTH32F_STENCIL8;else if(g===Ks)I=e.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(g===null||g===mi||g===Is)I=e.DEPTH_COMPONENT24;else if(g===ti)I=e.DEPTH_COMPONENT32F;else if(g===Ks)I=e.DEPTH_COMPONENT16;return I}function w(S,g){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==In&&S.minFilter!==sn)return Math.log2(Math.max(g.width,g.height))+1;else if(S.mipmaps!==void 0&&S.mipmaps.length>0)return S.mipmaps.length;else if(S.isCompressedTexture&&Array.isArray(S.image))return g.mipmaps.length;else return 1}function A(S){let g=S.target;if(g.removeEventListener("dispose",A),M(g),g.isVideoTexture)u.delete(g);if(g.isHTMLTexture)d.delete(g)}function _(S){let g=S.target;g.removeEventListener("dispose",_),R(g)}function M(S){let g=i.get(S);if(g.__webglInit===void 0)return;let I=S.source,V=p.get(I);if(V){let ie=V[g.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)B(S);if(Object.keys(V).length===0)p.delete(I)}i.remove(S)}function B(S){let g=i.get(S);e.deleteTexture(g.__webglTexture);let I=S.source,V=p.get(I);delete V[g.__cacheKey],a.memory.textures--}function R(S){let g=i.get(S);if(S.depthTexture)S.depthTexture.dispose(),i.remove(S.depthTexture);if(S.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(g.__webglFramebuffer[V]))for(let ie=0;ie<g.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(g.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(g.__webglFramebuffer[V]);if(g.__webglDepthbuffer)e.deleteRenderbuffer(g.__webglDepthbuffer[V])}else{if(Array.isArray(g.__webglFramebuffer))for(let V=0;V<g.__webglFramebuffer.length;V++)e.deleteFramebuffer(g.__webglFramebuffer[V]);else e.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer)e.deleteRenderbuffer(g.__webglDepthbuffer);if(g.__webglMultisampledFramebuffer)e.deleteFramebuffer(g.__webglMultisampledFramebuffer);if(g.__webglColorRenderbuffer){for(let V=0;V<g.__webglColorRenderbuffer.length;V++)if(g.__webglColorRenderbuffer[V])e.deleteRenderbuffer(g.__webglColorRenderbuffer[V])}if(g.__webglDepthRenderbuffer)e.deleteRenderbuffer(g.__webglDepthRenderbuffer)}let I=S.textures;for(let V=0,ie=I.length;V<ie;V++){let le=i.get(I[V]);if(le.__webglTexture)e.deleteTexture(le.__webglTexture),a.memory.textures--;i.remove(I[V])}i.remove(S)}let U=0;function W(){U=0}function P(){return U}function H(S){U=S}function j(){let S=U;if(S>=s.maxTextures)Oe("WebGLTextures: Trying to use "+(S+1)+" texture units while this GPU supports only "+s.maxTextures);return U+=1,S}function G(S){let g=[];return g.push(S.wrapS),g.push(S.wrapT),g.push(S.wrapR||0),g.push(S.magFilter),g.push(S.minFilter),g.push(S.anisotropy),g.push(S.internalFormat),g.push(S.format),g.push(S.type),g.push(S.generateMipmaps),g.push(S.premultiplyAlpha),g.push(S.flipY),g.push(S.unpackAlignment),g.push(S.colorSpace),g.join()}function re(S,g){let I=i.get(S);if(S.isVideoTexture)kt(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&I.__version!==S.version){let V=S.image;if(V===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{Re(I,S,g);return}}else if(S.isExternalTexture)I.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+g)}function q(S,g){let I=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&I.__version!==S.version){Re(I,S,g);return}else if(S.isExternalTexture)I.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+g)}function te(S,g){let I=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&I.__version!==S.version){Re(I,S,g);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+g)}function ee(S,g){let I=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&I.__version!==S.version){Ie(I,S,g);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+g)}let me={[Js]:e.REPEAT,[Bn]:e.CLAMP_TO_EDGE,[Zc]:e.MIRRORED_REPEAT},we={[In]:e.NEAREST,[Jc]:e.NEAREST_MIPMAP_NEAREST,[$s]:e.NEAREST_MIPMAP_LINEAR,[sn]:e.LINEAR,[Wr]:e.LINEAR_MIPMAP_NEAREST,[Pi]:e.LINEAR_MIPMAP_LINEAR},He={[ih]:e.NEVER,[lh]:e.ALWAYS,[sh]:e.LESS,[Qr]:e.LEQUAL,[rh]:e.EQUAL,[jr]:e.GEQUAL,[ah]:e.GREATER,[oh]:e.NOTEQUAL};function Fe(S,g){if(g.type===ti&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===sn||g.magFilter===Wr||g.magFilter===$s||g.magFilter===Pi||g.minFilter===sn||g.minFilter===Wr||g.minFilter===$s||g.minFilter===Pi))Oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(S,e.TEXTURE_WRAP_S,me[g.wrapS]),e.texParameteri(S,e.TEXTURE_WRAP_T,me[g.wrapT]),S===e.TEXTURE_3D||S===e.TEXTURE_2D_ARRAY)e.texParameteri(S,e.TEXTURE_WRAP_R,me[g.wrapR]);if(e.texParameteri(S,e.TEXTURE_MAG_FILTER,we[g.magFilter]),e.texParameteri(S,e.TEXTURE_MIN_FILTER,we[g.minFilter]),g.compareFunction)e.texParameteri(S,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(S,e.TEXTURE_COMPARE_FUNC,He[g.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===In)return;if(g.minFilter!==$s&&g.minFilter!==Pi)return;if(g.type===ti&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||i.get(g).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(S,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),i.get(g).__currentAnisotropy=g.anisotropy}}}function Y(S,g){let I=!1;if(S.__webglInit===void 0)S.__webglInit=!0,g.addEventListener("dispose",A);let V=g.source,ie=p.get(V);if(ie===void 0)ie={},p.set(V,ie);let le=G(g);if(le!==S.__cacheKey){if(ie[le]===void 0)ie[le]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,I=!0;ie[le].usedTimes++;let de=ie[S.__cacheKey];if(de!==void 0){if(ie[S.__cacheKey].usedTimes--,de.usedTimes===0)B(g)}S.__cacheKey=le,S.__webglTexture=ie[le].texture}return I}function se(S,g,I){return Math.floor(Math.floor(S/I)/g)}function ae(S,g,I,V){let le=S.updateRanges;if(le.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,g.width,g.height,I,V,g.data);else{le.sort((Pe,pe)=>Pe.start-pe.start);let de=0;for(let Pe=1;Pe<le.length;Pe++){let pe=le[de],oe=le[Pe],Te=pe.start+pe.count,Le=se(oe.start,g.width,4),$e=se(pe.start,g.width,4);if(oe.start<=Te+1&&Le===$e&&se(oe.start+oe.count-1,g.width,4)===Le)pe.count=Math.max(pe.count,oe.start+oe.count-pe.start);else++de,le[de]=oe}le.length=de+1;let Z=n.getParameter(e.UNPACK_ROW_LENGTH),Q=n.getParameter(e.UNPACK_SKIP_PIXELS),fe=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,g.width);for(let Pe=0,pe=le.length;Pe<pe;Pe++){let oe=le[Pe],Te=Math.floor(oe.start/4),Le=Math.ceil(oe.count/4),$e=Te%g.width,N=Math.floor(Te/g.width),he=Le,J=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,$e),n.pixelStorei(e.UNPACK_SKIP_ROWS,N),n.texSubImage2D(e.TEXTURE_2D,0,$e,N,he,1,I,V,g.data)}S.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Z),n.pixelStorei(e.UNPACK_SKIP_PIXELS,Q),n.pixelStorei(e.UNPACK_SKIP_ROWS,fe)}}function Re(S,g,I){let V=e.TEXTURE_2D;if(g.isDataArrayTexture||g.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(g.isData3DTexture)V=e.TEXTURE_3D;let ie=Y(S,g),le=g.source;n.bindTexture(V,S.__webglTexture,e.TEXTURE0+I);let de=i.get(le);if(le.version!==de.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){let J=je.getPrimaries(je.workingColorSpace),ue=g.colorSpace===Ui?null:je.getPrimaries(g.colorSpace),Se=g.colorSpace===Ui||J===ue?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,g.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se)}n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment);let Q=m(g.image,!1,s.maxTextureSize);Q=et(g,Q);let fe=r.convert(g.format,g.colorSpace),Pe=r.convert(g.type),pe=y(g.internalFormat,fe,Pe,g.normalized,g.colorSpace,g.isVideoTexture);Fe(V,g);let oe,Te=g.mipmaps,Le=g.isVideoTexture!==!0,$e=de.__version===void 0||ie===!0,N=le.dataReady,he=w(g,Q);if(g.isDepthTexture){if(pe=b(g.format===Ni,g.type),$e)if(Le)n.texStorage2D(e.TEXTURE_2D,1,pe,Q.width,Q.height);else n.texImage2D(e.TEXTURE_2D,0,pe,Q.width,Q.height,0,fe,Pe,null)}else if(g.isDataTexture)if(Te.length>0){if(Le&&$e)n.texStorage2D(e.TEXTURE_2D,he,pe,Te[0].width,Te[0].height);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,fe,Pe,oe.data);g.generateMipmaps=!1}else if(Le){if($e)n.texStorage2D(e.TEXTURE_2D,he,pe,Q.width,Q.height);if(N)ae(g,Q,fe,Pe)}else n.texImage2D(e.TEXTURE_2D,0,pe,Q.width,Q.height,0,fe,Pe,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){if(Le&&$e)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,pe,Te[0].width,Te[0].height,Q.depth);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],g.format!==Gn)if(fe!==null)if(Le){if(N)if(g.layerUpdates.size>0){let Se=xl(oe.width,oe.height,g.format,g.type);for(let ne of g.layerUpdates){let ge=oe.data.subarray(ne*Se/oe.data.BYTES_PER_ELEMENT,(ne+1)*Se/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,ne,oe.width,oe.height,1,fe,ge)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,Q.depth,fe,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,J,pe,oe.width,oe.height,Q.depth,0,oe.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Le){if(N)n.texSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,Q.depth,fe,Pe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,J,pe,oe.width,oe.height,Q.depth,0,fe,Pe,oe.data);if(g.layerUpdates.size>0)g.clearLayerUpdates()}else{if(Le&&$e)n.texStorage2D(e.TEXTURE_2D,he,pe,Te[0].width,Te[0].height);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],g.format!==Gn)if(fe!==null)if(Le){if(N)n.compressedTexSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,oe.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,fe,Pe,oe.data)}else if(g.isDataArrayTexture)if(Le){if($e)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,pe,Q.width,Q.height,Q.depth);if(N)if(g.layerUpdates.size>0){let J=xl(Q.width,Q.height,g.format,g.type);for(let ue of g.layerUpdates){let Se=Q.data.subarray(ue*J/Q.data.BYTES_PER_ELEMENT,(ue+1)*J/Q.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ue,Q.width,Q.height,1,fe,Pe,Se)}g.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,fe,Pe,Q.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,pe,Q.width,Q.height,Q.depth,0,fe,Pe,Q.data);else if(g.isData3DTexture)if(Le){if($e)n.texStorage3D(e.TEXTURE_3D,he,pe,Q.width,Q.height,Q.depth);if(N)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,fe,Pe,Q.data)}else n.texImage3D(e.TEXTURE_3D,0,pe,Q.width,Q.height,Q.depth,0,fe,Pe,Q.data);else if(g.isFramebufferTexture){if($e)if(Le)n.texStorage2D(e.TEXTURE_2D,he,pe,Q.width,Q.height);else{let J=Q.width,ue=Q.height;for(let Se=0;Se<he;Se++)n.texImage2D(e.TEXTURE_2D,Se,pe,J,ue,0,fe,Pe,null),J>>=1,ue>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in e){let J=e.canvas;if(!J.hasAttribute("layoutsubtree"))J.setAttribute("layoutsubtree","true");if(Q.parentNode!==J){J.appendChild(Q),d.add(g),J.onpaint=(ue)=>{let Se=ue.changedElements;for(let ne of d)if(Se.includes(ne.image))ne.needsUpdate=!0},J.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,Q);else{let{RGBA:Se,RGBA:ne,UNSIGNED_BYTE:ge}=e;e.texElementImage2D(e.TEXTURE_2D,0,Se,ne,ge,Q)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Te.length>0){if(Le&&$e){let J=xt(Te[0]);n.texStorage2D(e.TEXTURE_2D,he,pe,J.width,J.height)}for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,fe,Pe,oe)}else n.texImage2D(e.TEXTURE_2D,J,pe,fe,Pe,oe);g.generateMipmaps=!1}else if(Le){if($e){let J=xt(Q);n.texStorage2D(e.TEXTURE_2D,he,pe,J.width,J.height)}if(N)n.texSubImage2D(e.TEXTURE_2D,0,0,0,fe,Pe,Q)}else n.texImage2D(e.TEXTURE_2D,0,pe,fe,Pe,Q);if(f(g))E(V);if(de.__version=le.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Ie(S,g,I){if(g.image.length!==6)return;let V=Y(S,g),ie=g.source;n.bindTexture(e.TEXTURE_CUBE_MAP,S.__webglTexture,e.TEXTURE0+I);let le=i.get(ie);if(ie.version!==le.__version||V===!0){n.activeTexture(e.TEXTURE0+I);let de=je.getPrimaries(je.workingColorSpace),Z=g.colorSpace===Ui?null:je.getPrimaries(g.colorSpace),Q=g.colorSpace===Ui||de===Z?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,g.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);let fe=g.isCompressedTexture||g.image[0].isCompressedTexture,Pe=g.image[0]&&g.image[0].isDataTexture,pe=[];for(let ne=0;ne<6;ne++){if(!fe&&!Pe)pe[ne]=m(g.image[ne],!0,s.maxCubemapSize);else pe[ne]=Pe?g.image[ne].image:g.image[ne];pe[ne]=et(g,pe[ne])}let oe=pe[0],Te=r.convert(g.format,g.colorSpace),Le=r.convert(g.type),$e=y(g.internalFormat,Te,Le,g.normalized,g.colorSpace),N=g.isVideoTexture!==!0,he=le.__version===void 0||V===!0,J=ie.dataReady,ue=w(g,oe);Fe(e.TEXTURE_CUBE_MAP,g);let Se;if(fe){if(N&&he)n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,$e,oe.width,oe.height);for(let ne=0;ne<6;ne++){Se=pe[ne].mipmaps;for(let ge=0;ge<Se.length;ge++){let Be=Se[ge];if(g.format!==Gn)if(Te!==null)if(N){if(J)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,0,0,Be.width,Be.height,Te,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,$e,Be.width,Be.height,0,Be.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,0,0,Be.width,Be.height,Te,Le,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,$e,Be.width,Be.height,0,Te,Le,Be.data)}}}else{if(Se=g.mipmaps,N&&he){if(Se.length>0)ue++;let ne=xt(pe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,$e,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Pe){if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,pe[ne].width,pe[ne].height,Te,Le,pe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,pe[ne].width,pe[ne].height,0,Te,Le,pe[ne].data);for(let ge=0;ge<Se.length;ge++){let ct=Se[ge].image[ne].image;if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,0,0,ct.width,ct.height,Te,Le,ct.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,$e,ct.width,ct.height,0,Te,Le,ct.data)}}else{if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Te,Le,pe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,Te,Le,pe[ne]);for(let ge=0;ge<Se.length;ge++){let Be=Se[ge];if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,0,0,Te,Le,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,$e,Te,Le,Be.image[ne])}}}if(f(g))E(e.TEXTURE_CUBE_MAP);if(le.__version=ie.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function De(S,g,I,V,ie,le){let de=r.convert(I.format,I.colorSpace),Z=r.convert(I.type),Q=y(I.internalFormat,de,Z,I.normalized,I.colorSpace),fe=i.get(g),Pe=i.get(I);if(Pe.__renderTarget=g,!fe.__hasExternalTextures){let pe=Math.max(1,g.width>>le),oe=Math.max(1,g.height>>le);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,le,Q,pe,oe,g.depth,0,de,Z,null);else n.texImage2D(ie,le,Q,pe,oe,0,de,Z,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,S),L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,0,wt(g));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,le);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Rt(S,g,I){if(e.bindRenderbuffer(e.RENDERBUFFER,S),g.depthBuffer){let V=g.depthTexture,ie=V&&V.isDepthTexture?V.type:null,le=b(g.stencilBuffer,ie),de=g.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,wt(g),le,g.width,g.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,wt(g),le,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,le,g.width,g.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,de,e.RENDERBUFFER,S)}else{let V=g.textures;for(let ie=0;ie<V.length;ie++){let le=V[ie],de=r.convert(le.format,le.colorSpace),Z=r.convert(le.type),Q=y(le.internalFormat,de,Z,le.normalized,le.colorSpace);if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,wt(g),Q,g.width,g.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,wt(g),Q,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,Q,g.width,g.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ye(S,g,I){let V=g.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,S),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(g.depthTexture);if(ie.__renderTarget=g,!ie.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0;if(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,g.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Fe(e.TEXTURE_CUBE_MAP,g.depthTexture);let fe=r.convert(g.depthTexture.format),Pe=r.convert(g.depthTexture.type),pe;if(g.depthTexture.format===Li)pe=e.DEPTH_COMPONENT24;else if(g.depthTexture.format===Ni)pe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,pe,g.width,g.height,0,fe,Pe,null)}}else re(g.depthTexture,0);let le=ie.__webglTexture,de=wt(g),Z=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,Q=g.depthTexture.format===Ni?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(g.depthTexture.format===Li)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,de);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else if(g.depthTexture.format===Ni)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,de);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(S){let g=i.get(S),I=S.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(g.__depthDisposeCallback)g.__depthDisposeCallback();if(V){let ie=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),g.__depthDisposeCallback=ie}g.__boundDepthTexture=V}if(S.depthTexture&&!g.__autoAllocateDepthBuffer)if(I)for(let V=0;V<6;V++)Ye(g.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)Ye(g.__webglFramebuffer[0],S,0);else Ye(g.__webglFramebuffer,S,0)}else if(I){g.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer[V]),g.__webglDepthbuffer[V]===void 0)g.__webglDepthbuffer[V]=e.createRenderbuffer(),Rt(g.__webglDepthbuffer[V],S,!1);else{let ie=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,le)}}else{let V=S.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer);if(g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=e.createRenderbuffer(),Rt(g.__webglDepthbuffer,S,!1);else{let ie=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,le)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(S,g,I){let V=i.get(S);if(g!==void 0)De(V.__webglFramebuffer,S,S.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(S)}function Qe(S){let g=S.texture,I=i.get(S),V=i.get(g);S.addEventListener("dispose",_);let ie=S.textures,le=S.isWebGLCubeRenderTarget===!0,de=ie.length>1;if(!de){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=g.version,a.memory.textures++}if(le){I.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0){I.__webglFramebuffer[Z]=[];for(let Q=0;Q<g.mipmaps.length;Q++)I.__webglFramebuffer[Z][Q]=e.createFramebuffer()}else I.__webglFramebuffer[Z]=e.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){I.__webglFramebuffer=[];for(let Z=0;Z<g.mipmaps.length;Z++)I.__webglFramebuffer[Z]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(de)for(let Z=0,Q=ie.length;Z<Q;Z++){let fe=i.get(ie[Z]);if(fe.__webglTexture===void 0)fe.__webglTexture=e.createTexture(),a.memory.textures++}if(S.samples>0&&L(S)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let Z=0;Z<ie.length;Z++){let Q=ie[Z];I.__webglColorRenderbuffer[Z]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[Z]);let fe=r.convert(Q.format,Q.colorSpace),Pe=r.convert(Q.type),pe=y(Q.internalFormat,fe,Pe,Q.normalized,Q.colorSpace,S.isXRRenderTarget===!0),oe=wt(S);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,pe,S.width,S.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Z,e.RENDERBUFFER,I.__webglColorRenderbuffer[Z])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),S.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),Rt(I.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(le){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Fe(e.TEXTURE_CUBE_MAP,g);for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)De(I.__webglFramebuffer[Z][Q],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else De(I.__webglFramebuffer[Z],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);if(f(g))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(de){for(let Z=0,Q=ie.length;Z<Q;Z++){let fe=ie[Z],Pe=i.get(fe),pe=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)pe=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(pe,Pe.__webglTexture),Fe(pe,fe),De(I.__webglFramebuffer,S,fe,e.COLOR_ATTACHMENT0+Z,pe,0),f(fe))E(pe)}n.unbindTexture()}else{let Z=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)Z=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Z,V.__webglTexture),Fe(Z,g),g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)De(I.__webglFramebuffer[Q],S,g,e.COLOR_ATTACHMENT0,Z,Q);else De(I.__webglFramebuffer,S,g,e.COLOR_ATTACHMENT0,Z,0);if(f(g))E(Z);n.unbindTexture()}if(S.depthBuffer)Ze(S)}function Ot(S){let g=S.textures;for(let I=0,V=g.length;I<V;I++){let ie=g[I];if(f(ie)){let le=C(S),de=i.get(ie).__webglTexture;n.bindTexture(le,de),E(le),n.unbindTexture()}}}let dt=[],Lt=[];function bt(S){if(S.samples>0){if(L(S)===!1){let{textures:g,width:I,height:V}=S,ie=e.COLOR_BUFFER_BIT,le=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,de=i.get(S),Z=g.length>1;if(Z)for(let fe=0;fe<g.length;fe++)n.bindFramebuffer(e.FRAMEBUFFER,de.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,de.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,de.__webglMultisampledFramebuffer);let Q=S.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglFramebuffer);for(let fe=0;fe<g.length;fe++){if(S.resolveDepthBuffer){if(S.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Z){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,de.__webglColorRenderbuffer[fe]);let Pe=i.get(g[fe]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Pe,0)}if(e.blitFramebuffer(0,0,I,V,0,0,I,V,ie,e.NEAREST),l===!0){if(dt.length=0,Lt.length=0,dt.push(e.COLOR_ATTACHMENT0+fe),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)dt.push(le),Lt.push(le),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Lt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,dt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Z)for(let fe=0;fe<g.length;fe++){n.bindFramebuffer(e.FRAMEBUFFER,de.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.RENDERBUFFER,de.__webglColorRenderbuffer[fe]);let Pe=i.get(g[fe]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,de.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.TEXTURE_2D,Pe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&l){let g=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[g])}}}function wt(S){return Math.min(s.maxSamples,S.samples)}function L(S){let g=i.get(S);return S.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function kt(S){let g=a.render.frame;if(u.get(S)!==g)u.set(S,g),S.update()}function et(S,g){let{colorSpace:I,format:V,type:ie}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return g;if(I!==Vo&&I!==Ui)if(je.getTransfer(I)===_t){if(V!==Gn||ie!==fn)Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",I);return g}function xt(S){if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement)c.width=S.naturalWidth||S.width,c.height=S.naturalHeight||S.height;else if(typeof VideoFrame<"u"&&S instanceof VideoFrame)c.width=S.displayWidth,c.height=S.displayHeight;else c.width=S.width,c.height=S.height;return c}this.allocateTextureUnit=j,this.resetTextureUnits=W,this.getTextureUnits=P,this.setTextureUnits=H,this.setTexture2D=re,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=ee,this.rebindTextures=st,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=Ot,this.updateMultisampleRenderTarget=bt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=De,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Zg(e,t){function n(i,s=Ui){let r,a=je.getTransfer(s);if(i===fn)return e.UNSIGNED_BYTE;if(i===ao)return e.UNSIGNED_SHORT_4_4_4_4;if(i===oo)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Qc)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jc)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===$c)return e.BYTE;if(i===Kc)return e.SHORT;if(i===Ks)return e.UNSIGNED_SHORT;if(i===ro)return e.INT;if(i===mi)return e.UNSIGNED_INT;if(i===ti)return e.FLOAT;if(i===zn)return e.HALF_FLOAT;if(i===eh)return e.ALPHA;if(i===th)return e.RGB;if(i===Gn)return e.RGBA;if(i===Li)return e.DEPTH_COMPONENT;if(i===Ni)return e.DEPTH_STENCIL;if(i===Xr)return e.RED;if(i===lo)return e.RED_INTEGER;if(i===Di)return e.RG;if(i===co)return e.RG_INTEGER;if(i===ho)return e.RGBA_INTEGER;if(i===qr||i===Yr||i===Zr||i===Jr)if(a===_t)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===qr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Zr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Jr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===qr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Zr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Jr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===uo||i===fo||i===po||i===mo)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===uo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===po)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===mo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===go||i===_o||i===xo||i===vo||i===yo||i===$r||i===So)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(i===go||i===_o)return a===_t?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===xo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===vo)return r.COMPRESSED_R11_EAC;if(i===yo)return r.COMPRESSED_SIGNED_R11_EAC;if(i===$r)return r.COMPRESSED_RG11_EAC;if(i===So)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Mo||i===bo||i===To||i===wo||i===Eo||i===Ao||i===Co||i===Ro||i===Io||i===Po||i===Lo||i===No||i===Do||i===Uo)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Mo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===bo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===To)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===wo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Eo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Ao)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Co)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ro)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Io)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Po)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Lo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===No)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Do)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Uo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fo||i===Oo||i===Bo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(i===Fo)return a===_t?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Oo)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Bo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===zo||i===ko||i===Kr||i===Go)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(i===zo)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ko)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Kr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Go)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Is)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Jg=`
|
|
4196
|
+
}`,Vg=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],Wg=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],kh=new yt,Ys=new O,Tl=new O;function Xg(e,t,n){let i=new Ws,s=new ze,r=new ze,a=new wt,o=new el,l=new tl,c={},u=n.maxTextureSize,d={[fs]:qt,[qt]:fs,[cn]:cn},h=new Sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:Gg,fragmentShader:Hg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new mn;v.setAttribute("position",new yn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let T=new Ge(v,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ls;let f=this.type;this.render=function(w,A,_){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(w.length===0)return;if(this.type===_c)Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ls;let M=e.getRenderTarget(),B=e.getActiveCubeFace(),R=e.getActiveMipmapLevel(),U=e.state;if(U.setBlending(On),U.buffers.depth.getReversed()===!0)U.buffers.color.setClear(0,0,0,0);else U.buffers.color.setClear(1,1,1,1);U.buffers.depth.setTest(!0),U.setScissorTest(!1);let W=f!==this.type;if(W)A.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((H)=>H.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,H=w.length;P<H;P++){let j=w[P],G=j.shadow;if(G===void 0){Oe("WebGLShadowMap:",j,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let re=G.getFrameExtents();if(s.multiply(re),r.copy(G.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/re.x),s.x=r.x*re.x,G.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/re.y),s.y=r.y*re.y,G.mapSize.y=r.y}let q=e.state.buffers.depth.getReversed();if(G.camera._reversedDepth=q,G.map===null||W===!0){if(G.map!==null){if(G.map.depthTexture!==null)G.map.depthTexture.dispose(),G.map.depthTexture=null;G.map.dispose()}if(this.type===ds){if(j.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new pn(s.x,s.y,{format:Ni,type:zn,minFilter:en,magFilter:en,generateMipmaps:!1}),G.map.texture.name=j.name+".shadowMap",G.map.depthTexture=new Fi(s.x,s.y,ei),G.map.depthTexture.name=j.name+".shadowMapDepth",G.map.depthTexture.format=Pi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=In,G.map.depthTexture.magFilter=In}else{if(j.isPointLight)G.map=new Cl(s.x),G.map.depthTexture=new Jo(s.x,mi);else G.map=new pn(s.x,s.y),G.map.depthTexture=new Fi(s.x,s.y,mi);if(G.map.depthTexture.name=j.name+".shadowMap",G.map.depthTexture.format=Pi,this.type===Ls)G.map.depthTexture.compareFunction=q?Br:Or,G.map.depthTexture.minFilter=en,G.map.depthTexture.magFilter=en;else G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=In,G.map.depthTexture.magFilter=In}G.camera.updateProjectionMatrix()}if(G.map.isWebGLCubeRenderTarget!==!0&&(G.map.width!==s.x||G.map.height!==s.y))G.map.setSize(s.x,s.y);let te=G.map.isWebGLCubeRenderTarget?6:G.getViewportCount();if(j.isPointLight!==!0)G.updateMatrices(j,_);for(let ee=0;ee<te;ee++){let me=G.getCamera(ee);if(j.isPointLight){let{camera:we,matrix:He}=G,Fe=j.distance||we.far;if(Fe!==we.far)we.far=Fe,we.updateProjectionMatrix();Ys.setFromMatrixPosition(j.matrixWorld),we.position.copy(Ys),Tl.copy(we.position),Tl.add(Vg[ee]),we.up.copy(Wg[ee]),we.lookAt(Tl),we.updateMatrixWorld(),He.makeTranslation(-Ys.x,-Ys.y,-Ys.z),kh.multiplyMatrices(we.projectionMatrix,we.matrixWorldInverse),G._frustum.setFromProjectionMatrix(kh,we.coordinateSystem,we.reversedDepth)}if(G.map.isWebGLCubeRenderTarget)e.setRenderTarget(G.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(G.map),e.clear();let we=G.getViewport(ee);a.set(r.x*we.x,r.y*we.y,r.x*we.z,r.y*we.w),U.viewport(a)}i=G.getFrustum(ee),y(A,_,me,j,this.type)}if(G.isPointLightShadow!==!0&&this.type===ds)E(G,_);G.needsUpdate=!1}f=this.type,m.needsUpdate=!1,e.setRenderTarget(M,B,R)};function E(w,A){let _=t.update(T);if(h.defines.VSM_SAMPLES!==w.blurSamples)h.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0;if(w.mapPass===null)w.mapPass=new pn(s.x,s.y,{format:Ni,type:zn});else if(w.mapPass.width!==w.map.width||w.mapPass.height!==w.map.height)w.mapPass.setSize(w.map.width,w.map.height);h.uniforms.shadow_pass.value=w.map.depthTexture,h.uniforms.resolution.value.set(w.map.width,w.map.height),h.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,T,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value.set(w.map.width,w.map.height),p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(A,null,_,p,T,null)}function C(w,A,_,M){let B=null,R=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)B=R;else if(B=_.isPointLight===!0?l:o,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=B.uuid,W=A.uuid,P=c[U];if(P===void 0)P={},c[U]=P;let H=P[W];if(H===void 0)H=B.clone(),P[W]=H,A.addEventListener("dispose",b);B=H}if(B.visible=A.visible,B.wireframe=A.wireframe,M===ds)B.side=A.shadowSide!==null?A.shadowSide:A.side;else B.side=A.shadowSide!==null?A.shadowSide:d[A.side];if(B.alphaMap=A.alphaMap,B.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,B.map=A.map,B.clipShadows=A.clipShadows,B.clippingPlanes=A.clippingPlanes,B.clipIntersection=A.clipIntersection,B.displacementMap=A.displacementMap,B.displacementScale=A.displacementScale,B.displacementBias=A.displacementBias,B.wireframeLinewidth=A.wireframeLinewidth,B.linewidth=A.linewidth,_.isPointLight===!0&&B.isMeshDistanceMaterial===!0){let U=e.properties.get(B);U.light=_}return B}function y(w,A,_,M,B){if(w.visible===!1)return;if(w.layers.test(A.layers)&&(w.isMesh||w.isLine||w.isPoints)){if((w.castShadow||w.receiveShadow&&B===ds)&&(!w.frustumCulled||w.intersectsFrustum(i))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let W=t.update(w),P=w.material;if(Array.isArray(P)){let H=W.groups;for(let j=0,G=H.length;j<G;j++){let re=H[j],q=P[re.materialIndex];if(q&&q.visible){let te=C(w,q,M,B);w.onBeforeShadow(e,w,A,_,W,te,re),e.renderBufferDirect(_,null,W,te,w,re),w.onAfterShadow(e,w,A,_,W,te,re)}}}else if(P.visible){let H=C(w,P,M,B);w.onBeforeShadow(e,w,A,_,W,H,null),e.renderBufferDirect(_,null,W,H,w,null),w.onAfterShadow(e,w,A,_,W,H,null)}}}let U=w.children;for(let W=0,P=U.length;W<P;W++)y(U[W],A,_,M,B)}function b(w){w.target.removeEventListener("dispose",b);for(let _ in c){let M=c[_],B=w.target.uuid;if(B in M)M[B].dispose(),delete M[B]}}}function qg(e,t){function n(){let N=!1,he=new wt,J=null,ue=new wt(0,0,0,0);return{setMask:function(Se){if(J!==Se&&!N)e.colorMask(Se,Se,Se,Se),J=Se},setLocked:function(Se){N=Se},setClear:function(Se,ne,ge,Be,ct){if(ct===!0)Se*=Be,ne*=Be,ge*=Be;if(he.set(Se,ne,ge,Be),ue.equals(he)===!1)e.clearColor(Se,ne,ge,Be),ue.copy(he)},reset:function(){N=!1,J=null,ue.set(-1,0,0,0)}}}function i(){let N=!1,he=!1,J=null,ue=null,Se=null;return{setReversed:function(ne){if(he!==ne){let ge=t.get("EXT_clip_control");if(ne)ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.ZERO_TO_ONE_EXT);else ge.clipControlEXT(ge.LOWER_LEFT_EXT,ge.NEGATIVE_ONE_TO_ONE_EXT);he=ne;let Be=Se;Se=null,this.setClear(Be)}},getReversed:function(){return he},setTest:function(ne){if(ne)ae(e.DEPTH_TEST);else Re(e.DEPTH_TEST)},setMask:function(ne){if(J!==ne&&!N)e.depthMask(ne),J=ne},setFunc:function(ne){if(he)ne=dh[ne];if(ue!==ne){switch(ne){case Bc:e.depthFunc(e.NEVER);break;case zc:e.depthFunc(e.ALWAYS);break;case kc:e.depthFunc(e.LESS);break;case Fa:e.depthFunc(e.LEQUAL);break;case Gc:e.depthFunc(e.EQUAL);break;case Hc:e.depthFunc(e.GEQUAL);break;case Vc:e.depthFunc(e.GREATER);break;case Wc:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ue=ne}},setLocked:function(ne){N=ne},setClear:function(ne){if(Se!==ne){if(Se=ne,he)ne=1-ne;e.clearDepth(ne)}},reset:function(){N=!1,J=null,ue=null,Se=null,he=!1}}}function s(){let N=!1,he=null,J=null,ue=null,Se=null,ne=null,ge=null,Be=null,ct=null;return{setTest:function(nt){if(!N)if(nt)ae(e.STENCIL_TEST);else Re(e.STENCIL_TEST)},setMask:function(nt){if(he!==nt&&!N)e.stencilMask(nt),he=nt},setFunc:function(nt,_n,F){if(J!==nt||ue!==_n||Se!==F)e.stencilFunc(nt,_n,F),J=nt,ue=_n,Se=F},setOp:function(nt,_n,F){if(ne!==nt||ge!==_n||Be!==F)e.stencilOp(nt,_n,F),ne=nt,ge=_n,Be=F},setLocked:function(nt){N=nt},setClear:function(nt){if(ct!==nt)e.clearStencil(nt),ct=nt},reset:function(){N=!1,he=null,J=null,ue=null,Se=null,ne=null,ge=null,Be=null,ct=null}}}let r=new n,a=new i,o=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new We(0,0,0),M=0,B=!1,R=null,U=null,W=null,P=null,H=null,j=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),G=!1,re=0,q=e.getParameter(e.VERSION);if(q.indexOf("WebGL")!==-1)re=parseFloat(/^WebGL (\d)/.exec(q)[1]),G=re>=1;else if(q.indexOf("OpenGL ES")!==-1)re=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),G=re>=2;let te=null,ee={},me=e.getParameter(e.SCISSOR_BOX),we=e.getParameter(e.VIEWPORT),He=new wt().fromArray(me),Fe=new wt().fromArray(we);function Y(N,he,J,ue){let Se=new Uint8Array(4),ne=e.createTexture();e.bindTexture(N,ne),e.texParameteri(N,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(N,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let ge=0;ge<J;ge++)if(N===e.TEXTURE_3D||N===e.TEXTURE_2D_ARRAY)e.texImage3D(he,0,e.RGBA,1,1,ue,0,e.RGBA,e.UNSIGNED_BYTE,Se);else e.texImage2D(he+ge,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Se);return ne}let se={};se[e.TEXTURE_2D]=Y(e.TEXTURE_2D,e.TEXTURE_2D,1),se[e.TEXTURE_CUBE_MAP]=Y(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[e.TEXTURE_2D_ARRAY]=Y(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),se[e.TEXTURE_3D]=Y(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(e.DEPTH_TEST),a.setFunc(Fa),zt(!1),ut(Na),ae(e.CULL_FACE),st(On);function ae(N){if(u[N]!==!0)e.enable(N),u[N]=!0}function Re(N){if(u[N]!==!1)e.disable(N),u[N]=!1}function Ie(N,he){if(h[N]!==he){if(e.bindFramebuffer(N,he),h[N]=he,N===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=he;if(N===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=he;return!0}return!1}function De(N,he){let J=v,ue=!1;if(N){if(J=p.get(he),J===void 0)J=[],p.set(he,J);let Se=N.textures;if(J.length!==Se.length||J[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,ge=Se.length;ne<ge;ne++)J[ne]=e.COLOR_ATTACHMENT0+ne;J.length=Se.length,ue=!0}}else if(J[0]!==e.BACK)J[0]=e.BACK,ue=!0;if(ue)e.drawBuffers(J)}function Pt(N){if(T!==N)return e.useProgram(N),T=N,!0;return!1}let Ye={[ps]:e.FUNC_ADD,[vc]:e.FUNC_SUBTRACT,[yc]:e.FUNC_REVERSE_SUBTRACT};Ye[Sc]=e.MIN,Ye[Mc]=e.MAX;let Ze={[bc]:e.ZERO,[Tc]:e.ONE,[wc]:e.SRC_COLOR,[Ac]:e.SRC_ALPHA,[Nc]:e.SRC_ALPHA_SATURATE,[Pc]:e.DST_COLOR,[Rc]:e.DST_ALPHA,[Ec]:e.ONE_MINUS_SRC_COLOR,[Cc]:e.ONE_MINUS_SRC_ALPHA,[Lc]:e.ONE_MINUS_DST_COLOR,[Ic]:e.ONE_MINUS_DST_ALPHA,[Dc]:e.CONSTANT_COLOR,[Uc]:e.ONE_MINUS_CONSTANT_COLOR,[Fc]:e.CONSTANT_ALPHA,[Oc]:e.ONE_MINUS_CONSTANT_ALPHA};function st(N,he,J,ue,Se,ne,ge,Be,ct,nt){if(N===On){if(m===!0)Re(e.BLEND),m=!1;return}if(m===!1)ae(e.BLEND),m=!0;if(N!==xc){if(N!==f||nt!==B){if(E!==ps||b!==ps)e.blendEquation(e.FUNC_ADD),E=ps,b=ps;if(nt)switch(N){case Cn:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case jn:e.blendFunc(e.ONE,e.ONE);break;case Da:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Ua:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",N);break}else switch(N){case Cn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case jn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Da:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ua:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",N);break}C=null,y=null,w=null,A=null,_.set(0,0,0),M=0,f=N,B=nt}return}if(Se=Se||he,ne=ne||J,ge=ge||ue,he!==E||Se!==b)e.blendEquationSeparate(Ye[he],Ye[Se]),E=he,b=Se;if(J!==C||ue!==y||ne!==w||ge!==A)e.blendFuncSeparate(Ze[J],Ze[ue],Ze[ne],Ze[ge]),C=J,y=ue,w=ne,A=ge;if(Be.equals(_)===!1||ct!==M)e.blendColor(Be.r,Be.g,Be.b,ct),_.copy(Be),M=ct;f=N,B=!1}function Qe(N,he){N.side===cn?Re(e.CULL_FACE):ae(e.CULL_FACE);let J=N.side===qt;if(he)J=!J;zt(J),N.blending===Cn&&N.transparent===!1?st(On):st(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),r.setMask(N.colorWrite);let ue=N.stencilWrite;if(o.setTest(ue),ue)o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass);bt(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?ae(e.SAMPLE_ALPHA_TO_COVERAGE):Re(e.SAMPLE_ALPHA_TO_COVERAGE)}function zt(N){if(R!==N){if(N)e.frontFace(e.CW);else e.frontFace(e.CCW);R=N}}function ut(N){if(N!==mc){if(ae(e.CULL_FACE),N!==U)if(N===Na)e.cullFace(e.BACK);else if(N===gc)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Re(e.CULL_FACE);U=N}function Nt(N){if(N!==W){if(G)e.lineWidth(N);W=N}}function bt(N,he,J){if(N){if(ae(e.POLYGON_OFFSET_FILL),P!==he||H!==J){if(P=he,H=J,a.getReversed())he=-he;e.polygonOffset(he,J)}}else Re(e.POLYGON_OFFSET_FILL)}function Tt(N){if(N)ae(e.SCISSOR_TEST);else Re(e.SCISSOR_TEST)}function L(N){if(N===void 0)N=e.TEXTURE0+j-1;if(te!==N)e.activeTexture(N),te=N}function Vt(N,he,J){if(J===void 0)if(te===null)J=e.TEXTURE0+j-1;else J=te;let ue=ee[J];if(ue===void 0)ue={type:void 0,texture:void 0},ee[J]=ue;if(ue.type!==N||ue.texture!==he){if(te!==J)e.activeTexture(J),te=J;e.bindTexture(N,he||se[N]),ue.type=N,ue.texture=he}}function et(){let N=ee[te];if(N!==void 0&&N.type!==void 0)e.bindTexture(N.type,null),N.type=void 0,N.texture=void 0}function xt(){try{e.compressedTexImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function S(){try{e.compressedTexImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function g(){try{e.texSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function I(){try{e.texSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function le(){try{e.texStorage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function de(){try{e.texStorage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Z(){try{e.texImage2D(...arguments)}catch(N){Ue("WebGLState:",N)}}function Q(){try{e.texImage3D(...arguments)}catch(N){Ue("WebGLState:",N)}}function fe(N){if(d[N]!==void 0)return d[N];else return e.getParameter(N)}function Pe(N,he){if(d[N]!==he)e.pixelStorei(N,he),d[N]=he}function pe(N){if(He.equals(N)===!1)e.scissor(N.x,N.y,N.z,N.w),He.copy(N)}function oe(N){if(Fe.equals(N)===!1)e.viewport(N.x,N.y,N.z,N.w),Fe.copy(N)}function Te(N,he){let J=c.get(he);if(J===void 0)J=new WeakMap,c.set(he,J);let ue=J.get(N);if(ue===void 0)ue=e.getUniformBlockIndex(he,N.name),J.set(N,ue)}function Le(N,he){let ue=c.get(he).get(N);if(l.get(he)!==ue)e.uniformBlockBinding(he,ue,N.__bindingPointIndex),l.set(he,ue)}function $e(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),a.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},te=null,ee={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new We(0,0,0),M=0,B=!1,R=null,U=null,W=null,P=null,H=null,He.set(0,0,e.canvas.width,e.canvas.height),Fe.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ae,disable:Re,bindFramebuffer:Ie,drawBuffers:De,useProgram:Pt,setBlending:st,setMaterial:Qe,setFlipSided:zt,setCullFace:ut,setLineWidth:Nt,setPolygonOffset:bt,setScissorTest:Tt,activeTexture:L,bindTexture:Vt,unbindTexture:et,compressedTexImage2D:xt,compressedTexImage3D:S,texImage2D:Z,texImage3D:Q,pixelStorei:Pe,getParameter:fe,updateUBOMapping:Te,uniformBlockBinding:Le,texStorage2D:le,texStorage3D:de,texSubImage2D:g,texSubImage3D:I,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:pe,viewport:oe,reset:$e}}function Yg(e,t,n,i,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ze,u=new WeakMap,d=new Set,h,p=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(S){}function T(S,g){return v?new OffscreenCanvas(S,g):Rs("canvas")}function m(S,g,I){let V=1,ie=xt(S);if(ie.width>I||ie.height>I)V=I/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){let le=Math.floor(V*ie.width),de=Math.floor(V*ie.height);if(h===void 0)h=T(le,de);let Z=g?T(le,de):h;return Z.width=le,Z.height=de,Z.getContext("2d").drawImage(S,0,0,le,de),Oe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+le+"x"+de+")."),Z}else{if("data"in S)Oe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return S}return S}function f(S){return S.generateMipmaps}function E(S){e.generateMipmap(S)}function C(S){if(S.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(S.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(S,g,I,V,ie,le=!1){if(S!==null){if(e[S]!==void 0)return e[S];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let de;if(V){if(de=t.get("EXT_texture_norm16"),!de)Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Z=g;if(g===e.RED){if(I===e.FLOAT)Z=e.R32F;if(I===e.HALF_FLOAT)Z=e.R16F;if(I===e.UNSIGNED_BYTE)Z=e.R8;if(I===e.UNSIGNED_SHORT&&de)Z=de.R16_EXT;if(I===e.SHORT&&de)Z=de.R16_SNORM_EXT}if(g===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.R8UI;if(I===e.UNSIGNED_SHORT)Z=e.R16UI;if(I===e.UNSIGNED_INT)Z=e.R32UI;if(I===e.BYTE)Z=e.R8I;if(I===e.SHORT)Z=e.R16I;if(I===e.INT)Z=e.R32I}if(g===e.RG){if(I===e.FLOAT)Z=e.RG32F;if(I===e.HALF_FLOAT)Z=e.RG16F;if(I===e.UNSIGNED_BYTE)Z=e.RG8;if(I===e.UNSIGNED_SHORT&&de)Z=de.RG16_EXT;if(I===e.SHORT&&de)Z=de.RG16_SNORM_EXT}if(g===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RG8UI;if(I===e.UNSIGNED_SHORT)Z=e.RG16UI;if(I===e.UNSIGNED_INT)Z=e.RG32UI;if(I===e.BYTE)Z=e.RG8I;if(I===e.SHORT)Z=e.RG16I;if(I===e.INT)Z=e.RG32I}if(g===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RGB8UI;if(I===e.UNSIGNED_SHORT)Z=e.RGB16UI;if(I===e.UNSIGNED_INT)Z=e.RGB32UI;if(I===e.BYTE)Z=e.RGB8I;if(I===e.SHORT)Z=e.RGB16I;if(I===e.INT)Z=e.RGB32I}if(g===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)Z=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)Z=e.RGBA16UI;if(I===e.UNSIGNED_INT)Z=e.RGBA32UI;if(I===e.BYTE)Z=e.RGBA8I;if(I===e.SHORT)Z=e.RGBA16I;if(I===e.INT)Z=e.RGBA32I}if(g===e.RGB){if(I===e.UNSIGNED_SHORT&&de)Z=de.RGB16_EXT;if(I===e.SHORT&&de)Z=de.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)Z=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)Z=e.R11F_G11F_B10F}if(g===e.RGBA){let Q=le?Ho:je.getTransfer(ie);if(I===e.FLOAT)Z=e.RGBA32F;if(I===e.HALF_FLOAT)Z=e.RGBA16F;if(I===e.UNSIGNED_BYTE)Z=Q===_t?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&de)Z=de.RGBA16_EXT;if(I===e.SHORT&&de)Z=de.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)Z=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)Z=e.RGB5_A1}if(Z===e.R16F||Z===e.R32F||Z===e.RG16F||Z===e.RG32F||Z===e.RGBA16F||Z===e.RGBA32F)t.get("EXT_color_buffer_float");return Z}function b(S,g){let I;if(S){if(g===null||g===mi||g===gs)I=e.DEPTH24_STENCIL8;else if(g===ei)I=e.DEPTH32F_STENCIL8;else if(g===Fs)I=e.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(g===null||g===mi||g===gs)I=e.DEPTH_COMPONENT24;else if(g===ei)I=e.DEPTH_COMPONENT32F;else if(g===Fs)I=e.DEPTH_COMPONENT16;return I}function w(S,g){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==In&&S.minFilter!==en)return Math.log2(Math.max(g.width,g.height))+1;else if(S.mipmaps!==void 0&&S.mipmaps.length>0)return S.mipmaps.length;else if(S.isCompressedTexture&&Array.isArray(S.image))return g.mipmaps.length;else return 1}function A(S){let g=S.target;if(g.removeEventListener("dispose",A),M(g),g.isVideoTexture)u.delete(g);if(g.isHTMLTexture)d.delete(g)}function _(S){let g=S.target;g.removeEventListener("dispose",_),R(g)}function M(S){let g=i.get(S);if(g.__webglInit===void 0)return;let I=S.source,V=p.get(I);if(V){let ie=V[g.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)B(S);if(Object.keys(V).length===0)p.delete(I)}i.remove(S)}function B(S){let g=i.get(S);e.deleteTexture(g.__webglTexture);let I=S.source,V=p.get(I);delete V[g.__cacheKey],a.memory.textures--}function R(S){let g=i.get(S);if(S.depthTexture)S.depthTexture.dispose(),i.remove(S.depthTexture);if(S.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(g.__webglFramebuffer[V]))for(let ie=0;ie<g.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(g.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(g.__webglFramebuffer[V]);if(g.__webglDepthbuffer)e.deleteRenderbuffer(g.__webglDepthbuffer[V])}else{if(Array.isArray(g.__webglFramebuffer))for(let V=0;V<g.__webglFramebuffer.length;V++)e.deleteFramebuffer(g.__webglFramebuffer[V]);else e.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer)e.deleteRenderbuffer(g.__webglDepthbuffer);if(g.__webglMultisampledFramebuffer)e.deleteFramebuffer(g.__webglMultisampledFramebuffer);if(g.__webglColorRenderbuffer){for(let V=0;V<g.__webglColorRenderbuffer.length;V++)if(g.__webglColorRenderbuffer[V])e.deleteRenderbuffer(g.__webglColorRenderbuffer[V])}if(g.__webglDepthRenderbuffer)e.deleteRenderbuffer(g.__webglDepthRenderbuffer)}let I=S.textures;for(let V=0,ie=I.length;V<ie;V++){let le=i.get(I[V]);if(le.__webglTexture)e.deleteTexture(le.__webglTexture),a.memory.textures--;i.remove(I[V])}i.remove(S)}let U=0;function W(){U=0}function P(){return U}function H(S){U=S}function j(){let S=U;if(S>=s.maxTextures)Oe("WebGLTextures: Trying to use "+(S+1)+" texture units while this GPU supports only "+s.maxTextures);return U+=1,S}function G(S){let g=[];return g.push(S.wrapS),g.push(S.wrapT),g.push(S.wrapR||0),g.push(S.magFilter),g.push(S.minFilter),g.push(S.anisotropy),g.push(S.internalFormat),g.push(S.format),g.push(S.type),g.push(S.generateMipmaps),g.push(S.premultiplyAlpha),g.push(S.flipY),g.push(S.unpackAlignment),g.push(S.colorSpace),g.join()}function re(S,g){let I=i.get(S);if(S.isVideoTexture)Vt(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&I.__version!==S.version){let V=S.image;if(V===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{Re(I,S,g);return}}else if(S.isExternalTexture)I.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+g)}function q(S,g){let I=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&I.__version!==S.version){Re(I,S,g);return}else if(S.isExternalTexture)I.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+g)}function te(S,g){let I=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&I.__version!==S.version){Re(I,S,g);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+g)}function ee(S,g){let I=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&I.__version!==S.version){Ie(I,S,g);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+g)}let me={[Ds]:e.REPEAT,[Bn]:e.CLAMP_TO_EDGE,[Zc]:e.MIRRORED_REPEAT},we={[In]:e.NEAREST,[Jc]:e.NEAREST_MIPMAP_NEAREST,[Us]:e.NEAREST_MIPMAP_LINEAR,[en]:e.LINEAR,[Rr]:e.LINEAR_MIPMAP_NEAREST,[Ii]:e.LINEAR_MIPMAP_LINEAR},He={[ih]:e.NEVER,[lh]:e.ALWAYS,[sh]:e.LESS,[Or]:e.LEQUAL,[rh]:e.EQUAL,[Br]:e.GEQUAL,[ah]:e.GREATER,[oh]:e.NOTEQUAL};function Fe(S,g){if(g.type===ei&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===en||g.magFilter===Rr||g.magFilter===Us||g.magFilter===Ii||g.minFilter===en||g.minFilter===Rr||g.minFilter===Us||g.minFilter===Ii))Oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(S,e.TEXTURE_WRAP_S,me[g.wrapS]),e.texParameteri(S,e.TEXTURE_WRAP_T,me[g.wrapT]),S===e.TEXTURE_3D||S===e.TEXTURE_2D_ARRAY)e.texParameteri(S,e.TEXTURE_WRAP_R,me[g.wrapR]);if(e.texParameteri(S,e.TEXTURE_MAG_FILTER,we[g.magFilter]),e.texParameteri(S,e.TEXTURE_MIN_FILTER,we[g.minFilter]),g.compareFunction)e.texParameteri(S,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(S,e.TEXTURE_COMPARE_FUNC,He[g.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===In)return;if(g.minFilter!==Us&&g.minFilter!==Ii)return;if(g.type===ei&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||i.get(g).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(S,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),i.get(g).__currentAnisotropy=g.anisotropy}}}function Y(S,g){let I=!1;if(S.__webglInit===void 0)S.__webglInit=!0,g.addEventListener("dispose",A);let V=g.source,ie=p.get(V);if(ie===void 0)ie={},p.set(V,ie);let le=G(g);if(le!==S.__cacheKey){if(ie[le]===void 0)ie[le]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,I=!0;ie[le].usedTimes++;let de=ie[S.__cacheKey];if(de!==void 0){if(ie[S.__cacheKey].usedTimes--,de.usedTimes===0)B(g)}S.__cacheKey=le,S.__webglTexture=ie[le].texture}return I}function se(S,g,I){return Math.floor(Math.floor(S/I)/g)}function ae(S,g,I,V){let le=S.updateRanges;if(le.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,g.width,g.height,I,V,g.data);else{le.sort((Pe,pe)=>Pe.start-pe.start);let de=0;for(let Pe=1;Pe<le.length;Pe++){let pe=le[de],oe=le[Pe],Te=pe.start+pe.count,Le=se(oe.start,g.width,4),$e=se(pe.start,g.width,4);if(oe.start<=Te+1&&Le===$e&&se(oe.start+oe.count-1,g.width,4)===Le)pe.count=Math.max(pe.count,oe.start+oe.count-pe.start);else++de,le[de]=oe}le.length=de+1;let Z=n.getParameter(e.UNPACK_ROW_LENGTH),Q=n.getParameter(e.UNPACK_SKIP_PIXELS),fe=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,g.width);for(let Pe=0,pe=le.length;Pe<pe;Pe++){let oe=le[Pe],Te=Math.floor(oe.start/4),Le=Math.ceil(oe.count/4),$e=Te%g.width,N=Math.floor(Te/g.width),he=Le,J=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,$e),n.pixelStorei(e.UNPACK_SKIP_ROWS,N),n.texSubImage2D(e.TEXTURE_2D,0,$e,N,he,1,I,V,g.data)}S.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Z),n.pixelStorei(e.UNPACK_SKIP_PIXELS,Q),n.pixelStorei(e.UNPACK_SKIP_ROWS,fe)}}function Re(S,g,I){let V=e.TEXTURE_2D;if(g.isDataArrayTexture||g.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(g.isData3DTexture)V=e.TEXTURE_3D;let ie=Y(S,g),le=g.source;n.bindTexture(V,S.__webglTexture,e.TEXTURE0+I);let de=i.get(le);if(le.version!==de.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){let J=je.getPrimaries(je.workingColorSpace),ue=g.colorSpace===Di?null:je.getPrimaries(g.colorSpace),Se=g.colorSpace===Di||J===ue?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,g.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se)}n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment);let Q=m(g.image,!1,s.maxTextureSize);Q=et(g,Q);let fe=r.convert(g.format,g.colorSpace),Pe=r.convert(g.type),pe=y(g.internalFormat,fe,Pe,g.normalized,g.colorSpace,g.isVideoTexture);Fe(V,g);let oe,Te=g.mipmaps,Le=g.isVideoTexture!==!0,$e=de.__version===void 0||ie===!0,N=le.dataReady,he=w(g,Q);if(g.isDepthTexture){if(pe=b(g.format===Li,g.type),$e)if(Le)n.texStorage2D(e.TEXTURE_2D,1,pe,Q.width,Q.height);else n.texImage2D(e.TEXTURE_2D,0,pe,Q.width,Q.height,0,fe,Pe,null)}else if(g.isDataTexture)if(Te.length>0){if(Le&&$e)n.texStorage2D(e.TEXTURE_2D,he,pe,Te[0].width,Te[0].height);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,fe,Pe,oe.data);g.generateMipmaps=!1}else if(Le){if($e)n.texStorage2D(e.TEXTURE_2D,he,pe,Q.width,Q.height);if(N)ae(g,Q,fe,Pe)}else n.texImage2D(e.TEXTURE_2D,0,pe,Q.width,Q.height,0,fe,Pe,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){if(Le&&$e)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,pe,Te[0].width,Te[0].height,Q.depth);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],g.format!==kn)if(fe!==null)if(Le){if(N)if(g.layerUpdates.size>0){let Se=xl(oe.width,oe.height,g.format,g.type);for(let ne of g.layerUpdates){let ge=oe.data.subarray(ne*Se/oe.data.BYTES_PER_ELEMENT,(ne+1)*Se/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,ne,oe.width,oe.height,1,fe,ge)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,Q.depth,fe,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,J,pe,oe.width,oe.height,Q.depth,0,oe.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Le){if(N)n.texSubImage3D(e.TEXTURE_2D_ARRAY,J,0,0,0,oe.width,oe.height,Q.depth,fe,Pe,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,J,pe,oe.width,oe.height,Q.depth,0,fe,Pe,oe.data);if(g.layerUpdates.size>0)g.clearLayerUpdates()}else{if(Le&&$e)n.texStorage2D(e.TEXTURE_2D,he,pe,Te[0].width,Te[0].height);for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],g.format!==kn)if(fe!==null)if(Le){if(N)n.compressedTexSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,oe.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,oe.width,oe.height,fe,Pe,oe.data)}else n.texImage2D(e.TEXTURE_2D,J,pe,oe.width,oe.height,0,fe,Pe,oe.data)}else if(g.isDataArrayTexture)if(Le){if($e)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,pe,Q.width,Q.height,Q.depth);if(N)if(g.layerUpdates.size>0){let J=xl(Q.width,Q.height,g.format,g.type);for(let ue of g.layerUpdates){let Se=Q.data.subarray(ue*J/Q.data.BYTES_PER_ELEMENT,(ue+1)*J/Q.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ue,Q.width,Q.height,1,fe,Pe,Se)}g.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,fe,Pe,Q.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,pe,Q.width,Q.height,Q.depth,0,fe,Pe,Q.data);else if(g.isData3DTexture)if(Le){if($e)n.texStorage3D(e.TEXTURE_3D,he,pe,Q.width,Q.height,Q.depth);if(N)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,fe,Pe,Q.data)}else n.texImage3D(e.TEXTURE_3D,0,pe,Q.width,Q.height,Q.depth,0,fe,Pe,Q.data);else if(g.isFramebufferTexture){if($e)if(Le)n.texStorage2D(e.TEXTURE_2D,he,pe,Q.width,Q.height);else{let J=Q.width,ue=Q.height;for(let Se=0;Se<he;Se++)n.texImage2D(e.TEXTURE_2D,Se,pe,J,ue,0,fe,Pe,null),J>>=1,ue>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in e){let J=e.canvas;if(!J.hasAttribute("layoutsubtree"))J.setAttribute("layoutsubtree","true");if(Q.parentNode!==J){J.appendChild(Q),d.add(g),J.onpaint=(ue)=>{let Se=ue.changedElements;for(let ne of d)if(Se.includes(ne.image))ne.needsUpdate=!0},J.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,Q);else{let{RGBA:Se,RGBA:ne,UNSIGNED_BYTE:ge}=e;e.texElementImage2D(e.TEXTURE_2D,0,Se,ne,ge,Q)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Te.length>0){if(Le&&$e){let J=xt(Te[0]);n.texStorage2D(e.TEXTURE_2D,he,pe,J.width,J.height)}for(let J=0,ue=Te.length;J<ue;J++)if(oe=Te[J],Le){if(N)n.texSubImage2D(e.TEXTURE_2D,J,0,0,fe,Pe,oe)}else n.texImage2D(e.TEXTURE_2D,J,pe,fe,Pe,oe);g.generateMipmaps=!1}else if(Le){if($e){let J=xt(Q);n.texStorage2D(e.TEXTURE_2D,he,pe,J.width,J.height)}if(N)n.texSubImage2D(e.TEXTURE_2D,0,0,0,fe,Pe,Q)}else n.texImage2D(e.TEXTURE_2D,0,pe,fe,Pe,Q);if(f(g))E(V);if(de.__version=le.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Ie(S,g,I){if(g.image.length!==6)return;let V=Y(S,g),ie=g.source;n.bindTexture(e.TEXTURE_CUBE_MAP,S.__webglTexture,e.TEXTURE0+I);let le=i.get(ie);if(ie.version!==le.__version||V===!0){n.activeTexture(e.TEXTURE0+I);let de=je.getPrimaries(je.workingColorSpace),Z=g.colorSpace===Di?null:je.getPrimaries(g.colorSpace),Q=g.colorSpace===Di||de===Z?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,g.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);let fe=g.isCompressedTexture||g.image[0].isCompressedTexture,Pe=g.image[0]&&g.image[0].isDataTexture,pe=[];for(let ne=0;ne<6;ne++){if(!fe&&!Pe)pe[ne]=m(g.image[ne],!0,s.maxCubemapSize);else pe[ne]=Pe?g.image[ne].image:g.image[ne];pe[ne]=et(g,pe[ne])}let oe=pe[0],Te=r.convert(g.format,g.colorSpace),Le=r.convert(g.type),$e=y(g.internalFormat,Te,Le,g.normalized,g.colorSpace),N=g.isVideoTexture!==!0,he=le.__version===void 0||V===!0,J=ie.dataReady,ue=w(g,oe);Fe(e.TEXTURE_CUBE_MAP,g);let Se;if(fe){if(N&&he)n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,$e,oe.width,oe.height);for(let ne=0;ne<6;ne++){Se=pe[ne].mipmaps;for(let ge=0;ge<Se.length;ge++){let Be=Se[ge];if(g.format!==kn)if(Te!==null)if(N){if(J)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,0,0,Be.width,Be.height,Te,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,$e,Be.width,Be.height,0,Be.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,0,0,Be.width,Be.height,Te,Le,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge,$e,Be.width,Be.height,0,Te,Le,Be.data)}}}else{if(Se=g.mipmaps,N&&he){if(Se.length>0)ue++;let ne=xt(pe[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ue,$e,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Pe){if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,pe[ne].width,pe[ne].height,Te,Le,pe[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,pe[ne].width,pe[ne].height,0,Te,Le,pe[ne].data);for(let ge=0;ge<Se.length;ge++){let ct=Se[ge].image[ne].image;if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,0,0,ct.width,ct.height,Te,Le,ct.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,$e,ct.width,ct.height,0,Te,Le,ct.data)}}else{if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Te,Le,pe[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,Te,Le,pe[ne]);for(let ge=0;ge<Se.length;ge++){let Be=Se[ge];if(N){if(J)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,0,0,Te,Le,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ge+1,$e,Te,Le,Be.image[ne])}}}if(f(g))E(e.TEXTURE_CUBE_MAP);if(le.__version=ie.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function De(S,g,I,V,ie,le){let de=r.convert(I.format,I.colorSpace),Z=r.convert(I.type),Q=y(I.internalFormat,de,Z,I.normalized,I.colorSpace),fe=i.get(g),Pe=i.get(I);if(Pe.__renderTarget=g,!fe.__hasExternalTextures){let pe=Math.max(1,g.width>>le),oe=Math.max(1,g.height>>le);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,le,Q,pe,oe,g.depth,0,de,Z,null);else n.texImage2D(ie,le,Q,pe,oe,0,de,Z,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,S),L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,0,Tt(g));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ie,Pe.__webglTexture,le);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Pt(S,g,I){if(e.bindRenderbuffer(e.RENDERBUFFER,S),g.depthBuffer){let V=g.depthTexture,ie=V&&V.isDepthTexture?V.type:null,le=b(g.stencilBuffer,ie),de=g.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Tt(g),le,g.width,g.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Tt(g),le,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,le,g.width,g.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,de,e.RENDERBUFFER,S)}else{let V=g.textures;for(let ie=0;ie<V.length;ie++){let le=V[ie],de=r.convert(le.format,le.colorSpace),Z=r.convert(le.type),Q=y(le.internalFormat,de,Z,le.normalized,le.colorSpace);if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Tt(g),Q,g.width,g.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,Tt(g),Q,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,Q,g.width,g.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ye(S,g,I){let V=g.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,S),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(g.depthTexture);if(ie.__renderTarget=g,!ie.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0;if(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,g.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Fe(e.TEXTURE_CUBE_MAP,g.depthTexture);let fe=r.convert(g.depthTexture.format),Pe=r.convert(g.depthTexture.type),pe;if(g.depthTexture.format===Pi)pe=e.DEPTH_COMPONENT24;else if(g.depthTexture.format===Li)pe=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,pe,g.width,g.height,0,fe,Pe,null)}}else re(g.depthTexture,0);let le=ie.__webglTexture,de=Tt(g),Z=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,Q=g.depthTexture.format===Li?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(g.depthTexture.format===Pi)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,de);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else if(g.depthTexture.format===Li)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,de);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(S){let g=i.get(S),I=S.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(g.__depthDisposeCallback)g.__depthDisposeCallback();if(V){let ie=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),g.__depthDisposeCallback=ie}g.__boundDepthTexture=V}if(S.depthTexture&&!g.__autoAllocateDepthBuffer)if(I)for(let V=0;V<6;V++)Ye(g.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)Ye(g.__webglFramebuffer[0],S,0);else Ye(g.__webglFramebuffer,S,0)}else if(I){g.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer[V]),g.__webglDepthbuffer[V]===void 0)g.__webglDepthbuffer[V]=e.createRenderbuffer(),Pt(g.__webglDepthbuffer[V],S,!1);else{let ie=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,le)}}else{let V=S.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,g.__webglFramebuffer);if(g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=e.createRenderbuffer(),Pt(g.__webglDepthbuffer,S,!1);else{let ie=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,le)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(S,g,I){let V=i.get(S);if(g!==void 0)De(V.__webglFramebuffer,S,S.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(S)}function Qe(S){let g=S.texture,I=i.get(S),V=i.get(g);S.addEventListener("dispose",_);let ie=S.textures,le=S.isWebGLCubeRenderTarget===!0,de=ie.length>1;if(!de){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=g.version,a.memory.textures++}if(le){I.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0){I.__webglFramebuffer[Z]=[];for(let Q=0;Q<g.mipmaps.length;Q++)I.__webglFramebuffer[Z][Q]=e.createFramebuffer()}else I.__webglFramebuffer[Z]=e.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){I.__webglFramebuffer=[];for(let Z=0;Z<g.mipmaps.length;Z++)I.__webglFramebuffer[Z]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(de)for(let Z=0,Q=ie.length;Z<Q;Z++){let fe=i.get(ie[Z]);if(fe.__webglTexture===void 0)fe.__webglTexture=e.createTexture(),a.memory.textures++}if(S.samples>0&&L(S)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let Z=0;Z<ie.length;Z++){let Q=ie[Z];I.__webglColorRenderbuffer[Z]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[Z]);let fe=r.convert(Q.format,Q.colorSpace),Pe=r.convert(Q.type),pe=y(Q.internalFormat,fe,Pe,Q.normalized,Q.colorSpace,S.isXRRenderTarget===!0),oe=Tt(S);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,pe,S.width,S.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Z,e.RENDERBUFFER,I.__webglColorRenderbuffer[Z])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),S.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),Pt(I.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(le){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Fe(e.TEXTURE_CUBE_MAP,g);for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)De(I.__webglFramebuffer[Z][Q],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else De(I.__webglFramebuffer[Z],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);if(f(g))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(de){for(let Z=0,Q=ie.length;Z<Q;Z++){let fe=ie[Z],Pe=i.get(fe),pe=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)pe=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(pe,Pe.__webglTexture),Fe(pe,fe),De(I.__webglFramebuffer,S,fe,e.COLOR_ATTACHMENT0+Z,pe,0),f(fe))E(pe)}n.unbindTexture()}else{let Z=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)Z=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Z,V.__webglTexture),Fe(Z,g),g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)De(I.__webglFramebuffer[Q],S,g,e.COLOR_ATTACHMENT0,Z,Q);else De(I.__webglFramebuffer,S,g,e.COLOR_ATTACHMENT0,Z,0);if(f(g))E(Z);n.unbindTexture()}if(S.depthBuffer)Ze(S)}function zt(S){let g=S.textures;for(let I=0,V=g.length;I<V;I++){let ie=g[I];if(f(ie)){let le=C(S),de=i.get(ie).__webglTexture;n.bindTexture(le,de),E(le),n.unbindTexture()}}}let ut=[],Nt=[];function bt(S){if(S.samples>0){if(L(S)===!1){let{textures:g,width:I,height:V}=S,ie=e.COLOR_BUFFER_BIT,le=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,de=i.get(S),Z=g.length>1;if(Z)for(let fe=0;fe<g.length;fe++)n.bindFramebuffer(e.FRAMEBUFFER,de.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,de.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,de.__webglMultisampledFramebuffer);let Q=S.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglFramebuffer);for(let fe=0;fe<g.length;fe++){if(S.resolveDepthBuffer){if(S.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Z){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,de.__webglColorRenderbuffer[fe]);let Pe=i.get(g[fe]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Pe,0)}if(e.blitFramebuffer(0,0,I,V,0,0,I,V,ie,e.NEAREST),l===!0){if(ut.length=0,Nt.length=0,ut.push(e.COLOR_ATTACHMENT0+fe),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)ut.push(le),Nt.push(le),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Nt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,ut)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Z)for(let fe=0;fe<g.length;fe++){n.bindFramebuffer(e.FRAMEBUFFER,de.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.RENDERBUFFER,de.__webglColorRenderbuffer[fe]);let Pe=i.get(g[fe]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,de.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+fe,e.TEXTURE_2D,Pe,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,de.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&l){let g=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[g])}}}function Tt(S){return Math.min(s.maxSamples,S.samples)}function L(S){let g=i.get(S);return S.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function Vt(S){let g=a.render.frame;if(u.get(S)!==g)u.set(S,g),S.update()}function et(S,g){let{colorSpace:I,format:V,type:ie}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return g;if(I!==Go&&I!==Di)if(je.getTransfer(I)===_t){if(V!==kn||ie!==fn)Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",I);return g}function xt(S){if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement)c.width=S.naturalWidth||S.width,c.height=S.naturalHeight||S.height;else if(typeof VideoFrame<"u"&&S instanceof VideoFrame)c.width=S.displayWidth,c.height=S.displayHeight;else c.width=S.width,c.height=S.height;return c}this.allocateTextureUnit=j,this.resetTextureUnits=W,this.getTextureUnits=P,this.setTextureUnits=H,this.setTexture2D=re,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=ee,this.rebindTextures=st,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=zt,this.updateMultisampleRenderTarget=bt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=De,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Zg(e,t){function n(i,s=Di){let r,a=je.getTransfer(s);if(i===fn)return e.UNSIGNED_BYTE;if(i===Xa)return e.UNSIGNED_SHORT_4_4_4_4;if(i===qa)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Qc)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jc)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===$c)return e.BYTE;if(i===Kc)return e.SHORT;if(i===Fs)return e.UNSIGNED_SHORT;if(i===Wa)return e.INT;if(i===mi)return e.UNSIGNED_INT;if(i===ei)return e.FLOAT;if(i===zn)return e.HALF_FLOAT;if(i===eh)return e.ALPHA;if(i===th)return e.RGB;if(i===kn)return e.RGBA;if(i===Pi)return e.DEPTH_COMPONENT;if(i===Li)return e.DEPTH_STENCIL;if(i===Ir)return e.RED;if(i===Ya)return e.RED_INTEGER;if(i===Ni)return e.RG;if(i===Za)return e.RG_INTEGER;if(i===Ja)return e.RGBA_INTEGER;if(i===Pr||i===Lr||i===Nr||i===Dr)if(a===_t)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Pr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Lr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Dr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Pr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Lr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Nr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Dr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===$a||i===Ka||i===Qa||i===ja)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===$a)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ka)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Qa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ja)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===eo||i===to||i===no||i===io||i===so||i===Ur||i===ro)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(i===eo||i===to)return a===_t?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===no)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===io)return r.COMPRESSED_R11_EAC;if(i===so)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ur)return r.COMPRESSED_RG11_EAC;if(i===ro)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===ao||i===oo||i===lo||i===co||i===ho||i===uo||i===fo||i===po||i===mo||i===go||i===vo||i===yo||i===bo||i===Io)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(i===ao)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===oo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===lo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===co)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ho)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===uo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===fo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===po)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===mo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===go)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===vo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===yo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===bo)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Io)return a===_t?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Lo||i===Do||i===Uo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(i===Lo)return a===_t?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Do)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Uo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Fo||i===Oo||i===Fr||i===Bo)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(i===Fo)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Oo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Fr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Bo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===gs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Jg=`
|
|
4197
4197
|
void main() {
|
|
4198
4198
|
|
|
4199
4199
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -4217,4 +4217,4 @@ void main() {
|
|
|
4217
4217
|
|
|
4218
4218
|
}
|
|
4219
4219
|
|
|
4220
|
-
}`;class Qh{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new aa(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Sn({vertexShader:Jg,fragmentShader:$g,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ge(new At(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class jh extends ni{constructor(e,t){super();let n=this,i=null,s=1,r=null,a="local-floor",o=1,l=null,c=null,u=null,d=null,h=null,p=null,v=typeof XRWebGLBinding<"u",T=new Qh,m={},f=t.getContextAttributes(),E=null,C=null,y=[],b=[],w=new ze,A=null,_=null,M=new ln;M.viewport=new Et;let B=new ln;B.viewport=new Et;let R=[M,B],U=new pl,W=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let se=y[Y];if(se===void 0)se=new er,y[Y]=se;return se.getTargetRaySpace()},this.getControllerGrip=function(Y){let se=y[Y];if(se===void 0)se=new er,y[Y]=se;return se.getGripSpace()},this.getHand=function(Y){let se=y[Y];if(se===void 0)se=new er,y[Y]=se;return se.getHandSpace()};function H(Y){let se=b.indexOf(Y.inputSource);if(se===-1)return;let ae=y[se];if(ae!==void 0)ae.update(Y.inputSource,Y.frame,l||r),ae.dispatchEvent({type:Y.type,data:Y.inputSource})}function j(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",j),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<y.length;Y++){let se=b[Y];if(se===null)continue;b[Y]=null,y[Y].disconnect(se)}W=null,P=null,T.reset();for(let Y in m)delete m[Y];if(e.setRenderTarget(E),h=null,d=null,u=null,i=null,C=null,Fe.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(w.width,w.height,!1),_!==null){let Y=_.camera;Y.fov=_.fov,Y.zoom=_.zoom,Y.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){if(s=Y,n.isPresenting===!0)Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){if(a=Y,n.isPresenting===!0)Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&v)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",j),i.addEventListener("inputsourceschange",G),f.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(w),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let ae={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,t,ae),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new pn(h.framebufferWidth,h.framebufferHeight,{format:Gn,type:fn,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let ae=null,Re=null,Ie=null;if(f.depth)Ie=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=f.stencil?Ni:Li,Re=f.stencil?Is:mi;let De={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(De),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),C=new pn(d.textureWidth,d.textureHeight,{format:Gn,type:fn,depthTexture:new Oi(d.textureWidth,d.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await i.requestReferenceSpace(a),Fe.setContext(i),Fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function G(Y){for(let se=0;se<Y.removed.length;se++){let ae=Y.removed[se],Re=b.indexOf(ae);if(Re>=0)b[Re]=null,y[Re].disconnect(ae)}for(let se=0;se<Y.added.length;se++){let ae=Y.added[se],Re=b.indexOf(ae);if(Re===-1){for(let De=0;De<y.length;De++)if(De>=b.length){b.push(ae),Re=De;break}else if(b[De]===null){b[De]=ae,Re=De;break}if(Re===-1)break}let Ie=y[Re];if(Ie)Ie.connect(ae)}}let re=new O,q=new O;function te(Y,se,ae){re.setFromMatrixPosition(se.matrixWorld),q.setFromMatrixPosition(ae.matrixWorld);let Re=re.distanceTo(q),Ie=se.projectionMatrix.elements,De=ae.projectionMatrix.elements,Rt=Ie[14]/(Ie[10]-1),Ye=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],st=(Ie[9]-1)/Ie[5],Qe=(Ie[8]-1)/Ie[0],Ot=(De[8]+1)/De[0],dt=Rt*Qe,Lt=Rt*Ot,bt=Re/(-Qe+Ot),wt=bt*-Qe;if(se.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(wt),Y.translateZ(bt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ie[10]===-1)Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{let L=Rt+bt,kt=Ye+bt,et=dt-wt,xt=Lt+(Re-wt),S=Ze*Ye/kt*L,g=st*Ye/kt*L;Y.projectionMatrix.makePerspective(et,xt,S,g,L,kt),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ee(Y,se){if(se===null)Y.matrixWorld.copy(Y.matrix);else Y.matrixWorld.multiplyMatrices(se.matrixWorld,Y.matrix);Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let{near:se,far:ae}=Y;if(T.texture!==null){if(T.depthNear>0)se=T.depthNear;if(T.depthFar>0)ae=T.depthFar}if(U.near=B.near=M.near=se,U.far=B.far=M.far=ae,W!==U.near||P!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,P=U.far;U.layers.mask=Y.layers.mask|6,M.layers.mask=U.layers.mask&-5,B.layers.mask=U.layers.mask&-3;let Re=Y.parent,Ie=U.cameras;ee(U,Re);for(let De=0;De<Ie.length;De++)ee(Ie[De],Re);if(Ie.length===2)te(U,M,B);else U.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Y.isPerspectiveCamera)_={camera:Y,fov:Y.fov,zoom:Y.zoom};me(Y,U,Re)};function me(Y,se,ae){if(ae===null)Y.matrix.copy(se.matrixWorld);else Y.matrix.copy(ae.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(se.matrixWorld);if(Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse),Y.isPerspectiveCamera)Y.fov=Gr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(Y){if(o=Y,d!==null)d.fixedFoveation=Y;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Y},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)},this.getCameraTexture=function(Y){return m[Y]};let we=null;function He(Y,se){if(c=se.getViewerPose(l||r),p=se,c!==null){let ae=c.views;if(h!==null)e.setRenderTargetFramebuffer(C,h.framebuffer),e.setRenderTarget(C);let Re=!1;if(ae.length!==U.cameras.length)U.cameras.length=0,Re=!0;for(let Ye=0;Ye<ae.length;Ye++){let Ze=ae[Ye],st=null;if(h!==null)st=h.getViewport(Ze);else{let Ot=u.getViewSubImage(d,Ze);if(st=Ot.viewport,Ye===0)e.setRenderTargetTextures(C,Ot.colorTexture,Ot.depthStencilTexture),e.setRenderTarget(C)}let Qe=R[Ye];if(Qe===void 0)Qe=new ln,Qe.layers.enable(Ye),Qe.viewport=new Et,R[Ye]=Qe;if(Qe.matrix.fromArray(Ze.transform.matrix),Qe.matrix.decompose(Qe.position,Qe.quaternion,Qe.scale),Qe.projectionMatrix.fromArray(Ze.projectionMatrix),Qe.projectionMatrixInverse.copy(Qe.projectionMatrix).invert(),Qe.viewport.set(st.x,st.y,st.width,st.height),Ye===0)U.matrix.copy(Qe.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Re===!0)U.cameras.push(Qe)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let Ye=u.getDepthInformation(ae[0]);if(Ye&&Ye.isValid&&Ye.texture)T.init(Ye,i.renderState)}if(Ie&&Ie.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let Ye=0;Ye<ae.length;Ye++){let Ze=ae[Ye].camera;if(Ze){let st=m[Ze];if(!st)st=new aa,m[Ze]=st;let Qe=u.getCameraImage(Ze);st.sourceTexture=Qe}}}}for(let ae=0;ae<y.length;ae++){let Re=b[ae],Ie=y[ae];if(Re!==null&&Ie!==void 0)Ie.update(Re,se,l||r)}if(we)we(Y,se);if(se.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:se});p=null}let Fe=new Gh;Fe.setAnimationLoop(He),this.setAnimationLoop=function(Y){we=Y},this.dispose=function(){}}}var Kg=new yt,eu=new ke;eu.set(-1,0,0,0,1,0,0,0,1);function Qg(e,t){function n(m,f){if(m.matrixAutoUpdate===!0)m.updateMatrix();f.value.copy(m.matrix)}function i(m,f){if(f.color.getRGB(m.fogColor.value,Qo(e)),f.isFog)m.fogNear.value=f.near,m.fogFar.value=f.far;else if(f.isFogExp2)m.fogDensity.value=f.density}function s(m,f,E,C,y){if(f.isNodeMaterial)f.uniformsNeedUpdate=!1;else if(f.isMeshBasicMaterial)r(m,f);else if(f.isMeshLambertMaterial){if(r(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshToonMaterial)r(m,f),d(m,f);else if(f.isMeshPhongMaterial){if(r(m,f),u(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshStandardMaterial){if(r(m,f),h(m,f),f.isMeshPhysicalMaterial)p(m,f,y)}else if(f.isMeshMatcapMaterial)r(m,f),v(m,f);else if(f.isMeshDepthMaterial)r(m,f);else if(f.isMeshDistanceMaterial)r(m,f),T(m,f);else if(f.isMeshNormalMaterial)r(m,f);else if(f.isLineBasicMaterial){if(a(m,f),f.isLineDashedMaterial)o(m,f)}else if(f.isPointsMaterial)l(m,f,E,C);else if(f.isSpriteMaterial)c(m,f);else if(f.isShadowMaterial)m.color.value.copy(f.color),m.opacity.value=f.opacity;else if(f.isShaderMaterial)f.uniformsNeedUpdate=!1}function r(m,f){if(m.opacity.value=f.opacity,f.color)m.diffuse.value.copy(f.color);if(f.emissive)m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity);if(f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.bumpMap){if(m.bumpMap.value=f.bumpMap,n(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Wt)m.bumpScale.value*=-1}if(f.normalMap){if(m.normalMap.value=f.normalMap,n(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Wt)m.normalScale.value.negate()}if(f.displacementMap)m.displacementMap.value=f.displacementMap,n(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias;if(f.emissiveMap)m.emissiveMap.value=f.emissiveMap,n(f.emissiveMap,m.emissiveMapTransform);if(f.specularMap)m.specularMap.value=f.specularMap,n(f.specularMap,m.specularMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest;let E=t.get(f),{envMap:C,envMapRotation:y}=E;if(C){if(m.envMap.value=C,m.envMapRotation.value.setFromMatrix4(Kg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(eu);m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio}if(f.lightMap)m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,n(f.lightMap,m.lightMapTransform);if(f.aoMap)m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,n(f.aoMap,m.aoMapTransform)}function a(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map)m.map.value=f.map,n(f.map,m.mapTransform)}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,E,C){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*E,m.scale.value=C*0.5,f.map)m.map.value=f.map,n(f.map,m.uvTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function c(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,0.0001)}function d(m,f){if(f.gradientMap)m.gradientMap.value=f.gradientMap}function h(m,f){if(m.metalness.value=f.metalness,f.metalnessMap)m.metalnessMap.value=f.metalnessMap,n(f.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=f.roughness,f.roughnessMap)m.roughnessMap.value=f.roughnessMap,n(f.roughnessMap,m.roughnessMapTransform);if(f.envMap)m.envMapIntensity.value=f.envMapIntensity}function p(m,f,E){if(m.ior.value=f.ior,f.sheen>0){if(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap)m.sheenColorMap.value=f.sheenColorMap,n(f.sheenColorMap,m.sheenColorMapTransform);if(f.sheenRoughnessMap)m.sheenRoughnessMap.value=f.sheenRoughnessMap,n(f.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(f.clearcoat>0){if(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap)m.clearcoatMap.value=f.clearcoatMap,n(f.clearcoatMap,m.clearcoatMapTransform);if(f.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,n(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(f.clearcoatNormalMap){if(m.clearcoatNormalMap.value=f.clearcoatNormalMap,n(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Wt)m.clearcoatNormalScale.value.negate()}}if(f.dispersion>0)m.dispersion.value=f.dispersion;if(f.retroreflectivity>0)m.retroreflectivity.value=f.retroreflectivity;if(f.iridescence>0){if(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap)m.iridescenceMap.value=f.iridescenceMap,n(f.iridescenceMap,m.iridescenceMapTransform);if(f.iridescenceThicknessMap)m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,n(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(f.transmission>0){if(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=E.texture,m.transmissionSamplerSize.value.set(E.width,E.height),f.transmissionMap)m.transmissionMap.value=f.transmissionMap,n(f.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=f.thickness,f.thicknessMap)m.thicknessMap.value=f.thicknessMap,n(f.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)}if(f.anisotropy>0){if(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap)m.anisotropyMap.value=f.anisotropyMap,n(f.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap)m.specularColorMap.value=f.specularColorMap,n(f.specularColorMap,m.specularColorMapTransform);if(f.specularIntensityMap)m.specularIntensityMap.value=f.specularIntensityMap,n(f.specularIntensityMap,m.specularIntensityMapTransform)}function v(m,f){if(f.matcap)m.matcap.value=f.matcap}function T(m,f){let E=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function jg(e,t,n,i){let s={},r={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,b){let w=b.program;i.uniformBlockBinding(y,w)}function c(y,b){let w=s[y.id];if(w===void 0)m(y),w=u(y),s[y.id]=w,y.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(y,A);let _=t.render.frame;if(r[y.id]!==_)h(y),r[y.id]=_}function u(y){let b=d();y.__bindingPointIndex=b;let w=e.createBuffer(),{__size:A,usage:_}=y;return e.bindBuffer(e.UNIFORM_BUFFER,w),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,w),w}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let b=s[y.id],{uniforms:w,__cache:A}=y;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=w.length;_<M;_++){let B=w[_];if(Array.isArray(B))for(let R=0,U=B.length;R<U;R++)p(B[R],_,R,A);else p(B,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(y,b,w,A){if(T(y,b,w,A)===!0){let{__offset:_,value:M}=y;if(Array.isArray(M)){let B=0;for(let R=0;R<M.length;R++){let U=M[R],W=f(U);if(v(U,y.__data,B),typeof U!=="number"&&typeof U!=="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U))B+=W.storage/Float32Array.BYTES_PER_ELEMENT}}else v(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,y.__data)}}function v(y,b,w){if(typeof y==="number"||typeof y==="boolean")b[0]=y;else if(y.isMatrix3)b[0]=y.elements[0],b[1]=y.elements[1],b[2]=y.elements[2],b[3]=0,b[4]=y.elements[3],b[5]=y.elements[4],b[6]=y.elements[5],b[7]=0,b[8]=y.elements[6],b[9]=y.elements[7],b[10]=y.elements[8],b[11]=0;else if(ArrayBuffer.isView(y))b.set(new y.constructor(y.buffer,y.byteOffset,b.length));else y.toArray(b,w)}function T(y,b,w,A){let _=y.value,M=b+"_"+w;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let B=A[M];if(typeof _==="number"||typeof _==="boolean"){if(B!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(B.equals(_)===!1)return B.copy(_),!0}return!1}function m(y){let b=y.uniforms,w=0,A=16;for(let M=0,B=b.length;M<B;M++){let R=Array.isArray(b[M])?b[M]:[b[M]];for(let U=0,W=R.length;U<W;U++){let P=R[U],H=Array.isArray(P.value)?P.value:[P.value];for(let j=0,G=H.length;j<G;j++){let re=H[j],q=f(re),te=w%A,ee=te%q.boundary,me=te+ee;if(w+=ee,me!==0&&A-me<q.storage)w+=A-me;P.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=w,w+=q.storage}}}let _=w%A;if(_>0)w+=A-_;return y.__size=w,y.__cache={},this}function f(y){let b={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")b.boundary=4,b.storage=4;else if(y.isVector2)b.boundary=8,b.storage=8;else if(y.isVector3||y.isColor)b.boundary=16,b.storage=12;else if(y.isVector4)b.boundary=16,b.storage=16;else if(y.isMatrix3)b.boundary=48,b.storage=48;else if(y.isMatrix4)b.boundary=64,b.storage=64;else if(y.isTexture)Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))b.boundary=16,b.storage=y.byteLength;else Oe("WebGLRenderer: Unsupported uniform value type.",y);return b}function E(y){let b=y.target;b.removeEventListener("dispose",E);let w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function C(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:C}}var e0=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Vn=null;function t0(){if(Vn===null)Vn=new sr(e0,16,16,Di,zn),Vn.name="DFG_LUT",Vn.minFilter=sn,Vn.magFilter=sn,Vn.wrapS=Bn,Vn.wrapT=Bn,Vn.generateMipmaps=!1,Vn.needsUpdate=!0;return Vn}class Rl{constructor(e={}){let{canvas:t=ch(),context:n=null,depth:i=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=fn}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=r;let v=h,T=new Set([ho,co,lo]),m=new Set([fn,mi,Ks,Is,ao,oo]),f=new Uint32Array(4),E=new Int32Array(4),C=new O,y=null,b=null,w=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Rn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,B=!1,R=null,U=null,W=null,P=null;this._outputColorSpace=gi;let H=0,j=0,G=null,re=-1,q=null,te=new Et,ee=new Et,me=null,we=new We(0),He=0,{width:Fe,height:Y}=t,se=1,ae=null,Re=null,Ie=new Et(0,0,Fe,Y),De=new Et(0,0,Fe,Y),Rt=!1,Ye=new rr,Ze=!1,st=!1,Qe=new yt,Ot=new O,dt=new Et,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},bt=!1;function wt(){return G===null?se:1}let L=n;function kt(x,D){return t.getContext(x,D)}let et,xt,S,g,I,V,ie,le,de,Z,Q,fe,Pe,pe,oe,Te,Le,$e,N,he,J,ue,Se;try{let x={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${pc}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",nt,!1),L===null){if(L=kt("webgl2",x),L===null)if(kt("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(x){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Ue("WebGLRenderer: "+x.message),x}function ne(){if(et=new lm(L),et.init(),J=new Zg(L,et),xt=new Qp(L,et,e,J),S=new qg(L,et),xt.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);U=L.createFramebuffer(),W=L.createFramebuffer(),P=L.createFramebuffer(),g=new um(L),I=new Lg,V=new Yg(L,et,S,I,xt,J,g),ie=new om(M),le=new dd(L),ue=new $p(L,le),de=new cm(L,le,g,ue),Z=new fm(L,de,le,ue,g),$e=new dm(L,xt,V),oe=new jp(I),Q=new Pg(M,ie,et,xt,ue,oe),fe=new Qg(M,I),Pe=new Dg,pe=new kg(et),Le=new Jp(M,ie,S,Z,p,o),Te=new Xg(M,Z,xt),Se=new jg(L,g,xt,S),N=new Kp(L,et,g),he=new hm(L,et,g),g.programs=Q.programs,M.capabilities=xt,M.extensions=et,M.properties=I,M.renderLists=Pe,M.shadowMap=Te,M.state=S,M.info=g}if(v!==fn)_=new mm(v,t.width,t.height,a,i,s);let ge=new jh(M,L);this.xr=ge,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let x=et.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=et.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(x){if(x===void 0)return;se=x,this.setSize(Fe,Y,!1)},this.getSize=function(x){return x.set(Fe,Y)},this.setSize=function(x,D,X=!0){if(ge.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Fe=x,Y=D,t.width=Math.floor(x*se),t.height=Math.floor(D*se),X===!0)t.style.width=x+"px",t.style.height=D+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,x,D)},this.getDrawingBufferSize=function(x){return x.set(Fe*se,Y*se).floor()},this.setDrawingBufferSize=function(x,D,X){Fe=x,Y=D,se=X,t.width=Math.floor(x*X),t.height=Math.floor(D*X),this.setViewport(0,0,x,D)},this.setEffects=function(x){if(v===fn){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let D=0;D<x.length;D++)if(x[D].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(te)},this.getViewport=function(x){return x.copy(Ie)},this.setViewport=function(x,D,X,z){if(x.isVector4)Ie.set(x.x,x.y,x.z,x.w);else Ie.set(x,D,X,z);S.viewport(te.copy(Ie).multiplyScalar(se).round())},this.getScissor=function(x){return x.copy(De)},this.setScissor=function(x,D,X,z){if(x.isVector4)De.set(x.x,x.y,x.z,x.w);else De.set(x,D,X,z);S.scissor(ee.copy(De).multiplyScalar(se).round())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(x){S.setScissorTest(Rt=x)},this.setOpaqueSort=function(x){ae=x},this.setTransparentSort=function(x){Re=x},this.getClearColor=function(x){return x.copy(Le.getClearColor())},this.setClearColor=function(){Le.setClearColor(...arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,X=!0){let z=0;if(x){let k=!1;if(G!==null){let ve=G.texture.format;k=T.has(ve)}if(k){let ve=G.texture.type,be=m.has(ve),xe=Le.getClearColor(),Ae=Le.getClearAlpha(),{r:Ne,g:Xe,b:Ke}=xe;if(be)f[0]=Ne,f[1]=Xe,f[2]=Ke,f[3]=Ae,L.clearBufferuiv(L.COLOR,0,f);else E[0]=Ne,E[1]=Xe,E[2]=Ke,E[3]=Ae,L.clearBufferiv(L.COLOR,0,E)}else z|=L.COLOR_BUFFER_BIT}if(D)z|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(X)z|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(z!==0)L.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.setNodesHandler=function(x){x.setRenderer(this),R=x},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Le.dispose(),Pe.dispose(),pe.dispose(),I.dispose(),ie.dispose(),Z.dispose(),ue.dispose(),Se.dispose(),Q.dispose(),ge.dispose(),ge.removeEventListener("sessionstart",Ve),ge.removeEventListener("sessionend",rt),at.stop()};function Be(x){x.preventDefault(),Xs("WebGLRenderer: Context Lost."),B=!0}function ct(){Xs("WebGLRenderer: Context Restored."),B=!1;let x=g.autoReset,D=Te.enabled,X=Te.autoUpdate,z=Te.needsUpdate,k=Te.type;ne(),g.autoReset=x,Te.enabled=D,Te.autoUpdate=X,Te.needsUpdate=z,Te.type=k}function nt(x){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function _n(x){let D=x.target;D.removeEventListener("dispose",_n),F(D)}function F(x){K(x),I.remove(x)}function K(x){let D=I.get(x).programs;if(D!==void 0){if(D.forEach(function(X){Q.releaseProgram(X)}),x.isShaderMaterial)Q.releaseShaderCache(x)}}this.renderBufferDirect=function(x,D,X,z,k,ve){if(D===null)D=Lt;let be=k.isMesh&&k.matrixWorld.determinantAffine()<0,xe=Cu(x,D,X,z,k);S.setMaterial(z,be);let Ae=X.index,Ne=1;if(z.wireframe===!0){if(Ae=de.getWireframeAttribute(X),Ae===void 0)return;Ne=2}let Xe=X.drawRange,Ke=X.attributes.position,Ce=Xe.start*Ne,lt=(Xe.start+Xe.count)*Ne;if(ve!==null)Ce=Math.max(Ce,ve.start*Ne),lt=Math.min(lt,(ve.start+ve.count)*Ne);if(Ae!==null)Ce=Math.max(Ce,0),lt=Math.min(lt,Ae.count);else if(Ke!==void 0&&Ke!==null)Ce=Math.max(Ce,0),lt=Math.min(lt,Ke.count);let Nt=lt-Ce;if(Nt<0||Nt===1/0)return;ue.setup(k,z,xe,X,Ae);let St,gt=N;if(Ae!==null)St=le.get(Ae),gt=he,gt.setIndex(St);if(k.isMesh)if(z.wireframe===!0)S.setLineWidth(z.wireframeLinewidth*wt()),gt.setMode(L.LINES);else gt.setMode(L.TRIANGLES);else if(k.isLine){let Kt=z.linewidth;if(Kt===void 0)Kt=1;if(S.setLineWidth(Kt*wt()),k.isLineSegments)gt.setMode(L.LINES);else if(k.isLineLoop)gt.setMode(L.LINE_LOOP);else gt.setMode(L.LINE_STRIP)}else if(k.isPoints)gt.setMode(L.POINTS);else if(k.isSprite)gt.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(!et.get("WEBGL_multi_draw")){let{_multiDrawStarts:Kt,_multiDrawCounts:Me,_multiDrawCount:an}=k,it=Ae?le.get(Ae).bytesPerElement:1,xn=I.get(z).currentProgram.getUniforms();for(let Nn=0;Nn<an;Nn++)xn.setValue(L,"_gl_DrawID",Nn),gt.render(Kt[Nn]/it,Me[Nn])}else gt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else if(k.isInstancedMesh)gt.renderInstances(Ce,Nt,k.count);else if(X.isInstancedBufferGeometry){let Kt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Me=Math.min(X.instanceCount,Kt);gt.renderInstances(Ce,Nt,Me)}else gt.render(Ce,Nt)};function ce(x,D,X,z){if(R!==null&&x.isNodeMaterial)R.setObject(z,x);if(Ze===!0)oe.setState(x,X,!1);if(x.transparent===!0&&x.side===cn&&x.forceSinglePass===!1)x.side=Wt,x.needsUpdate=!0,ot(x,D,z),x.side=As,x.needsUpdate=!0,ot(x,D,z),x.side=cn;else ot(x,D,z)}this.compile=function(x,D,X=null){if(X===null)X=x;if(R!==null)R.renderStart(x,D,X);if(b=pe.get(X),b.init(D),A.push(b),X.traverseVisible(function(k){if(k.isLight&&k.layers.test(D.layers)){if(b.pushLight(k),k.castShadow)b.pushShadow(k)}}),x!==X)x.traverseVisible(function(k){if(k.isLight&&k.layers.test(D.layers)){if(b.pushLight(k),k.castShadow)b.pushShadow(k)}});if(b.setupLights(),R!==null)R.updateLights(b.state.lightsArray);if(st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),Ze===!0)oe.setGlobalState(this.clippingPlanes,D);if(R!==null)Te.render(b.state.shadowsArray,X,D);let z=new Set;if(x.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;let ve=k.material;if(ve)if(Array.isArray(ve))for(let be=0;be<ve.length;be++){let xe=ve[be];ce(xe,X,D,k),z.add(xe)}else ce(ve,X,D,k),z.add(ve)}),b=A.pop(),R!==null)R.renderEnd();return z},this.compileAsync=function(x,D,X=null){let z=this.compile(x,D,X);return new Promise((k)=>{function ve(){if(z.forEach(function(be){let Ae=I.get(be).currentProgram;if(Ae===void 0||Ae.isReady())z.delete(be)}),z.size===0){k(x);return}setTimeout(ve,10)}if(et.get("KHR_parallel_shader_compile")!==null)ve();else setTimeout(ve,10)})};let ye=null;function Ee(x){if(ye)ye(x)}function Ve(){at.stop()}function rt(){at.start()}let at=new Gh;if(at.setAnimationLoop(Ee),typeof self<"u")at.setContext(self);this.setAnimationLoop=function(x){ye=x,ge.setAnimationLoop(x),x===null?at.stop():at.start()},ge.addEventListener("sessionstart",Ve),ge.addEventListener("sessionend",rt),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(R!==null)R.renderStart(x,D);let X=ge.enabled===!0&&ge.isPresenting===!0,z=_!==null&&(G===null||X)&&_.begin(M,G);if(x.matrixWorldAutoUpdate===!0)x.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(ge.enabled===!0&&ge.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(ge.cameraAutoUpdate===!0)ge.updateCamera(D);D=ge.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,G);if(b=pe.get(x,A.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),A.push(b),Qe.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),Ye.setFromProjectionMatrix(Qe,qo,D.reversedDepth),st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),y=Pe.get(x,w.length),y.init(),w.push(y),ge.enabled===!0&&ge.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)Je(be,D,-1/0,M.sortObjects)}if(Je(x,D,0,M.sortObjects),y.finish(),R!==null)R.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(ae,Re);if(bt=ge.enabled===!1||ge.isPresenting===!1||ge.hasDepthSensing()===!1,bt)Le.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let k=b.state.shadowsArray;if(Te.render(k,x,D),Ze===!0)oe.endShadows();if((z&&_.hasRenderPass())===!1){let be=y.opaque,xe=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Ae=D.cameras;if(xe.length>0)for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne];bn(be,xe,x,Ke)}if(bt)Le.render(x);for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne];Pn(y,x,Ke,Ke.viewport)}}else{if(xe.length>0)bn(be,xe,x,D);if(bt)Le.render(x);Pn(y,x,D)}}if(G!==null&&j===0)V.updateMultisampleRenderTarget(G),V.updateRenderTargetMipmap(G);if(z)_.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(ue.resetDefaultState(),re=-1,q=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Ze===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(w.pop(),w.length>0)y=w[w.length-1];else y=null;if(R!==null)R.renderEnd()};function Je(x,D,X,z){if(x.visible===!1)return;if(x.layers.test(D.layers)){if(x.isGroup)X=x.renderOrder;else if(x.isLOD){if(x.autoUpdate===!0)x.update(D)}else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight){if(b.pushLight(x),x.castShadow)b.pushShadow(x)}else if(x.isSprite){if(!x.frustumCulled||x.intersectsFrustum(Ye)){if(z)dt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Qe);let be=Z.update(x),xe=x.material;if(xe.visible)y.push(x,be,xe,X,dt.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum(Ye)){let be=Z.update(x),xe=x.material;if(z){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();dt.copy(x.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();dt.copy(be.boundingSphere.center)}dt.applyMatrix4(x.matrixWorld).applyMatrix4(Qe)}if(Array.isArray(xe)){let Ae=be.groups;for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne],Ce=xe[Ke.materialIndex];if(Ce&&Ce.visible)y.push(x,be,Ce,X,dt.z,Ke,D)}}else if(xe.visible)y.push(x,be,xe,X,dt.z,null,D)}}}let ve=x.children;for(let be=0,xe=ve.length;be<xe;be++)Je(ve[be],D,X,z)}function Pn(x,D,X,z){let{opaque:k,transmissive:ve,transparent:be}=x;if(b.setupLightsView(X),Ze===!0)oe.setGlobalState(M.clippingPlanes,X);if(z)S.viewport(te.copy(z));if(k.length>0)Ln(k,D,X);if(ve.length>0)Ln(ve,D,X);if(be.length>0)Ln(be,D,X);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function bn(x,D,X,z){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){let Ce=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new pn(1,1,{generateMipmaps:!0,type:Ce?zn:fn,minFilter:Pi,samples:Math.max(4,xt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ve=b.state.transmissionRenderTarget[z.id],be=z.viewport||te;ve.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let xe=M.getRenderTarget(),Ae=M.getActiveCubeFace(),Ne=M.getActiveMipmapLevel();if(M.setRenderTarget(ve),M.getClearColor(we),He=M.getClearAlpha(),He<1)M.setClearColor(16777215,0.5);if(M.clear(),bt)Le.render(X);let Xe=M.toneMapping;M.toneMapping=Rn;let Ke=z.viewport;if(z.viewport!==void 0)z.viewport=void 0;if(b.setupLightsView(z),Ze===!0)oe.setGlobalState(M.clippingPlanes,z);if(Ln(x,X,z),V.updateMultisampleRenderTarget(ve),V.updateRenderTargetMipmap(ve),et.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let lt=0,Nt=D.length;lt<Nt;lt++){let St=D[lt],{object:gt,geometry:Kt,material:Me,group:an}=St;if(Me.side===cn&>.layers.test(z.layers)){let it=Me.side;Me.side=Wt,Me.needsUpdate=!0,mt(gt,X,z,Kt,Me,an),Me.side=it,Me.needsUpdate=!0,Ce=!0}}if(Ce===!0)V.updateMultisampleRenderTarget(ve),V.updateRenderTargetMipmap(ve)}if(M.setRenderTarget(xe,Ae,Ne),M.setClearColor(we,He),Ke!==void 0)z.viewport=Ke;M.toneMapping=Xe}function Ln(x,D,X){let z=D.isScene===!0?D.overrideMaterial:null;for(let k=0,ve=x.length;k<ve;k++){let be=x[k],{object:xe,geometry:Ae,group:Ne}=be,Xe=be.material;if(Xe.allowOverride===!0&&z!==null)Xe=z;if(xe.layers.test(X.layers))mt(xe,D,X,Ae,Xe,Ne)}}function mt(x,D,X,z,k,ve){if(R!==null&&k.isNodeMaterial)R.setObject(x,k);if(x.onBeforeRender(M,D,X,z,k,ve),x.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),k.onBeforeRender(M,D,X,z,x,ve),k.transparent===!0&&k.side===cn&&k.forceSinglePass===!1)k.side=Wt,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,ve),k.side=As,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,ve),k.side=cn;else M.renderBufferDirect(X,D,z,k,x,ve);x.onAfterRender(M,D,X,z,k,ve)}function ot(x,D,X){if(D.isScene!==!0)D=Lt;let z=I.get(x),k=b.state.lights,ve=b.state.shadowsArray,be=k.state.version,xe=Q.getParameters(x,k.state,ve,D,X,b.state.lightProbeGridArray),Ae=Q.getProgramCacheKey(xe),Ne=z.programs;z.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,z.fog=D.fog;let Xe=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(z.envMap=ie.get(x.envMap||z.environment,Xe),z.envMapRotation=z.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Ne===void 0)x.addEventListener("dispose",_n),Ne=new Map,z.programs=Ne;let Ke=Ne.get(Ae);if(Ke!==void 0){if(z.currentProgram===Ke&&z.lightsStateVersion===be)return Xt(x,xe),Ke}else{if(xe.uniforms=Q.getUniforms(x),R!==null&&x.isNodeMaterial)R.build(x,X,xe);x.onBeforeCompile(xe,M),Ke=Q.acquireProgram(xe,Ae),Ne.set(Ae,Ke),z.uniforms=xe.uniforms}let Ce=z.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Ce.clippingPlanes=oe.uniform;if(Xt(x,xe),z.needsLights=Iu(x),z.lightsStateVersion=be,z.needsLights)Ce.ambientLightColor.value=k.state.ambient,Ce.lightProbe.value=k.state.probe,Ce.sunLights.value=k.state.sun,Ce.sunLightShadows.value=k.state.sunShadow,Ce.directionalLights.value=k.state.directional,Ce.directionalLightShadows.value=k.state.directionalShadow,Ce.spotLights.value=k.state.spot,Ce.spotLightShadows.value=k.state.spotShadow,Ce.rectAreaLights.value=k.state.rectArea,Ce.ltc_1.value=k.state.rectAreaLTC1,Ce.ltc_2.value=k.state.rectAreaLTC2,Ce.pointLights.value=k.state.point,Ce.pointLightShadows.value=k.state.pointShadow,Ce.hemisphereLights.value=k.state.hemi,Ce.sunShadowMatrix.value=k.state.sunShadowMatrix,Ce.sunShadowCascade.value=k.state.sunShadowCascade,Ce.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ce.spotLightMatrix.value=k.state.spotLightMatrix,Ce.spotLightMap.value=k.state.spotLightMap,Ce.pointShadowMatrix.value=k.state.pointShadowMatrix;return z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=Ke,z.uniformsList=null,Ke}function Xn(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=fr.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function Xt(x,D){let X=I.get(x);X.outputColorSpace=D.outputColorSpace,X.batching=D.batching,X.batchingColor=D.batchingColor,X.instancing=D.instancing,X.instancingColor=D.instancingColor,X.instancingMorph=D.instancingMorph,X.skinning=D.skinning,X.morphTargets=D.morphTargets,X.morphNormals=D.morphNormals,X.morphColors=D.morphColors,X.morphTargetsCount=D.morphTargetsCount,X.numClippingPlanes=D.numClippingPlanes,X.numIntersection=D.numClipIntersection,X.vertexAlphas=D.vertexAlphas,X.vertexTangents=D.vertexTangents,X.toneMapping=D.toneMapping}function qn(x,D){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;C.setFromMatrixPosition(D.matrixWorld);for(let X=0,z=x.length;X<z;X++){let k=x[X];if(k.texture!==null&&k.boundingBox.containsPoint(C))return k}return null}function Cu(x,D,X,z,k){if(D.isScene!==!0)D=Lt;V.resetTextureUnits();let ve=D.fog,be=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?D.environment:null,xe=G===null?M.outputColorSpace:G.isXRRenderTarget===!0?G.texture.colorSpace:je.workingColorSpace,Ae=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Ne=ie.get(z.envMap||be,Ae),Xe=z.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ke=!!X.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Ce=!!X.morphAttributes.position,lt=!!X.morphAttributes.normal,Nt=!!X.morphAttributes.color,St=Rn;if(z.toneMapped){if(G===null||G.isXRRenderTarget===!0)St=M.toneMapping}let gt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Kt=gt!==void 0?gt.length:0,Me=I.get(z),an=b.state.lights;if(Ze===!0){if(st===!0||x!==q){let vt=x===q&&z.id===re;oe.setState(z,x,vt)}}let it=!1;if(z.version===Me.__version){if(Me.needsLights&&Me.lightsStateVersion!==an.state.version)it=!0;else if(Me.outputColorSpace!==xe)it=!0;else if(k.isBatchedMesh&&Me.batching===!1)it=!0;else if(!k.isBatchedMesh&&Me.batching===!0)it=!0;else if(k.isBatchedMesh&&Me.batchingColor===!0&&k._colorsTexture===null)it=!0;else if(k.isBatchedMesh&&Me.batchingColor===!1&&k._colorsTexture!==null)it=!0;else if(k.isInstancedMesh&&Me.instancing===!1)it=!0;else if(!k.isInstancedMesh&&Me.instancing===!0)it=!0;else if(k.isSkinnedMesh&&Me.skinning===!1)it=!0;else if(!k.isSkinnedMesh&&Me.skinning===!0)it=!0;else if(k.isInstancedMesh&&Me.instancingColor===!0&&k.instanceColor===null)it=!0;else if(k.isInstancedMesh&&Me.instancingColor===!1&&k.instanceColor!==null)it=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!0&&k.morphTexture===null)it=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!1&&k.morphTexture!==null)it=!0;else if(Me.envMap!==Ne)it=!0;else if(z.fog===!0&&Me.fog!==ve)it=!0;else if(Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==oe.numPlanes||Me.numIntersection!==oe.numIntersection))it=!0;else if(Me.vertexAlphas!==Xe)it=!0;else if(Me.vertexTangents!==Ke)it=!0;else if(Me.morphTargets!==Ce)it=!0;else if(Me.morphNormals!==lt)it=!0;else if(Me.morphColors!==Nt)it=!0;else if(Me.toneMapping!==St)it=!0;else if(Me.morphTargetsCount!==Kt)it=!0;else if(!!Me.lightProbeGrid!==b.state.lightProbeGridArray.length>0)it=!0}else it=!0,Me.__version=z.version;let xn=Me.currentProgram;if(it===!0){if(xn=ot(z,D,k),R&&z.isNodeMaterial)R.onUpdateProgram(z,xn,Me)}let Nn=!1,ri=!1,Xi=!1,ft=xn.getUniforms(),It=Me.uniforms;if(S.useProgram(xn.program))Nn=!0,ri=!0,Xi=!0;if(z.id!==re)re=z.id,ri=!0;if(Me.needsLights){let vt=qn(b.state.lightProbeGridArray,k);if(Me.lightProbeGrid!==vt)Me.lightProbeGrid=vt,ri=!0}if(Nn||q!==x){if(S.buffers.depth.getReversed()&&x.reversedDepth!==!0)x._reversedDepth=!0,x.updateProjectionMatrix();ft.setValue(L,"projectionMatrix",x.projectionMatrix),ft.setValue(L,"viewMatrix",x.matrixWorldInverse);let oi=ft.map.cameraPosition;if(oi!==void 0)oi.setValue(L,Ot.setFromMatrixPosition(x.matrixWorld));if(xt.logarithmicDepthBuffer)ft.setValue(L,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2));if(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)ft.setValue(L,"isOrthographic",x.isOrthographicCamera===!0);if(q!==x)q=x,ri=!0,Xi=!0}if(Me.needsLights){if(an.state.sunShadowMap.length>0)ft.setValue(L,"sunShadowMap",an.state.sunShadowMap,V);if(an.state.directionalShadowMap.length>0)ft.setValue(L,"directionalShadowMap",an.state.directionalShadowMap,V);if(an.state.spotShadowMap.length>0)ft.setValue(L,"spotShadowMap",an.state.spotShadowMap,V);if(an.state.pointShadowMap.length>0)ft.setValue(L,"pointShadowMap",an.state.pointShadowMap,V)}if(k.isSkinnedMesh){ft.setOptional(L,k,"bindMatrix"),ft.setOptional(L,k,"bindMatrixInverse");let vt=k.skeleton;if(vt){if(vt.boneTexture===null)vt.computeBoneTexture();ft.setValue(L,"boneTexture",vt.boneTexture,V)}}if(k.isBatchedMesh){if(ft.setOptional(L,k,"batchingTexture"),ft.setValue(L,"batchingTexture",k._matricesTexture,V),ft.setOptional(L,k,"batchingIdTexture"),ft.setValue(L,"batchingIdTexture",k._indirectTexture,V),ft.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null)ft.setValue(L,"batchingColorTexture",k._colorsTexture,V)}let ai=X.morphAttributes;if(ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)$e.update(k,X,xn);if(ri||Me.receiveShadow!==k.receiveShadow)Me.receiveShadow=k.receiveShadow,ft.setValue(L,"receiveShadow",k.receiveShadow);if((z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&D.environment!==null)It.envMapIntensity.value=D.environmentIntensity;if(It.dfgLUT!==void 0)It.dfgLUT.value=t0();if(ri){if(ft.setValue(L,"toneMappingExposure",M.toneMappingExposure),Me.needsLights)Ru(It,Xi);if(ve&&z.fog===!0)fe.refreshFogUniforms(It,ve);if(fe.refreshMaterialUniforms(It,z,se,Y,b.state.transmissionRenderTarget[x.id]),Me.needsLights&&Me.lightProbeGrid){let vt=Me.lightProbeGrid;It.probesSH.value=vt.texture,It.probesMin.value.copy(vt.boundingBox.min),It.probesMax.value.copy(vt.boundingBox.max),It.probesResolution.value.copy(vt.resolution)}fr.upload(L,Xn(Me),It,V)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0)fr.upload(L,Xn(Me),It,V),z.uniformsNeedUpdate=!1;if(z.isSpriteMaterial)ft.setValue(L,"center",k.center);if(ft.setValue(L,"modelViewMatrix",k.modelViewMatrix),ft.setValue(L,"normalMatrix",k.normalMatrix),ft.setValue(L,"modelMatrix",k.matrixWorld),z.uniformsGroups!==void 0){let vt=z.uniformsGroups;for(let oi=0,qi=vt.length;oi<qi;oi++){let Hl=vt[oi];Se.update(Hl,xn),Se.bind(Hl,xn)}}return xn}function Ru(x,D){x.ambientLightColor.needsUpdate=D,x.lightProbe.needsUpdate=D,x.sunLights.needsUpdate=D,x.sunLightShadows.needsUpdate=D,x.directionalLights.needsUpdate=D,x.directionalLightShadows.needsUpdate=D,x.pointLights.needsUpdate=D,x.pointLightShadows.needsUpdate=D,x.spotLights.needsUpdate=D,x.spotLightShadows.needsUpdate=D,x.rectAreaLights.needsUpdate=D,x.hemisphereLights.needsUpdate=D}function Iu(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return G},this.setRenderTargetTextures=function(x,D,X){let z=I.get(x);if(z.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1)z.__useRenderToTexture=!1;I.get(x.texture).__webglTexture=D,I.get(x.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:X,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let X=I.get(x);X.__webglFramebuffer=D,X.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,X=0){G=x,H=D,j=X;let z=null,k=!1,ve=!1;if(x){let xe=I.get(x);if(xe.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(L.FRAMEBUFFER,xe.__webglFramebuffer),te.copy(x.viewport),ee.copy(x.scissor),me=x.scissorTest,S.viewport(te),S.scissor(ee),S.setScissorTest(me),re=-1;return}else if(xe.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(xe.__hasExternalTextures)V.rebindTextures(x,I.get(x.texture).__webglTexture,I.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let Xe=x.depthTexture;if(xe.__boundDepthTexture!==Xe){if(Xe!==null&&I.has(Xe)&&(x.width!==Xe.image.width||x.height!==Xe.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Ae=x.texture;if(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)ve=!0;let Ne=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Ne[D]))z=Ne[D][X];else z=Ne[D];k=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)z=I.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))z=Ne[X];else z=Ne;te.copy(x.viewport),ee.copy(x.scissor),me=x.scissorTest}else te.copy(Ie).multiplyScalar(se).floor(),ee.copy(De).multiplyScalar(se).floor(),me=Rt;if(X!==0)z=U;if(S.bindFramebuffer(L.FRAMEBUFFER,z))S.drawBuffers(x,z);if(S.viewport(te),S.scissor(ee),S.setScissorTest(me),k){let xe=I.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+D,xe.__webglTexture,X)}else if(ve){let xe=D;for(let Ae=0;Ae<x.textures.length;Ae++){let Ne=I.get(x.textures[Ae]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Ae,Ne.__webglTexture,X,xe)}}else if(x!==null&&X!==0){let xe=I.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,xe.__webglTexture,X)}re=-1};function Gl(x){let D=I.get(x);if(D.__readFormat!==x.format||D.__readType!==x.type)D.__readFormat=x.format,D.__readType=x.type,D.__formatReadable=xt.textureFormatReadable(x.format),D.__typeReadable=xt.textureTypeReadable(x.type);return D}if(this.readRenderTargetPixels=function(x,D,X,z,k,ve,be,xe=0){if(!(x&&x.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ae=Ae[be];if(Ae){S.bindFramebuffer(L.FRAMEBUFFER,Ae);try{let Ne=x.textures[xe],{format:Xe,type:Ke}=Ne;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+xe);let Ce=Gl(Ne);if(Ce.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ce.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k))L.readPixels(D,X,z,k,J.convert(Xe),J.convert(Ke),ve)}finally{let Ne=G!==null?I.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(x,D,X,z,k,ve,be,xe=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ae=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ae=Ae[be];if(Ae)if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k)){S.bindFramebuffer(L.FRAMEBUFFER,Ae);let Ne=x.textures[xe],{format:Xe,type:Ke}=Ne;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+xe);let Ce=Gl(Ne);if(Ce.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ce.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let lt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,lt),L.bufferData(L.PIXEL_PACK_BUFFER,ve.byteLength,L.STREAM_READ),L.readPixels(D,X,z,k,J.convert(Xe),J.convert(Ke),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Nt=G!==null?I.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Nt);let St=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await uh(L,St,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,lt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ve),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(lt),L.deleteSync(St),ve}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,D=null,X=0){let z=Math.pow(2,-X),k=Math.floor(x.image.width*z),ve=Math.floor(x.image.height*z),be=D!==null?D.x:0,xe=D!==null?D.y:0;V.setTexture2D(x,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,be,xe,k,ve),S.unbindTexture()},this.copyTextureToTexture=function(x,D,X=null,z=null,k=0,ve=0){let be,xe,Ae,Ne,Xe,Ke,Ce,lt,Nt,St=x.isCompressedTexture?x.mipmaps[ve]:x.image;if(X!==null)be=X.max.x-X.min.x,xe=X.max.y-X.min.y,Ae=X.isBox3?X.max.z-X.min.z:1,Ne=X.min.x,Xe=X.min.y,Ke=X.isBox3?X.min.z:0;else{let It=Math.pow(2,-k);if(be=Math.floor(St.width*It),xe=Math.floor(St.height*It),x.isDataArrayTexture)Ae=St.depth;else if(x.isData3DTexture)Ae=Math.floor(St.depth*It);else Ae=1;Ne=0,Xe=0,Ke=0}if(z!==null)Ce=z.x,lt=z.y,Nt=z.z;else Ce=0,lt=0,Nt=0;let gt=J.convert(D.format),Kt=J.convert(D.type),Me;if(D.isData3DTexture)V.setTexture3D(D,0),Me=L.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),Me=L.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),Me=L.TEXTURE_2D;S.activeTexture(L.TEXTURE0),S.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,D.flipY),S.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),S.pixelStorei(L.UNPACK_ALIGNMENT,D.unpackAlignment);let an=S.getParameter(L.UNPACK_ROW_LENGTH),it=S.getParameter(L.UNPACK_IMAGE_HEIGHT),xn=S.getParameter(L.UNPACK_SKIP_PIXELS),Nn=S.getParameter(L.UNPACK_SKIP_ROWS),ri=S.getParameter(L.UNPACK_SKIP_IMAGES);S.pixelStorei(L.UNPACK_ROW_LENGTH,St.width),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,St.height),S.pixelStorei(L.UNPACK_SKIP_PIXELS,Ne),S.pixelStorei(L.UNPACK_SKIP_ROWS,Xe),S.pixelStorei(L.UNPACK_SKIP_IMAGES,Ke);let Xi=x.isDataArrayTexture||x.isData3DTexture,ft=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let It=I.get(x),ai=I.get(D),vt=I.get(It.__renderTarget),oi=I.get(ai.__renderTarget);S.bindFramebuffer(L.READ_FRAMEBUFFER,vt.__webglFramebuffer),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,oi.__webglFramebuffer);for(let qi=0;qi<Ae;qi++){if(Xi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(x).__webglTexture,k,Ke+qi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(D).__webglTexture,ve,Nt+qi);L.blitFramebuffer(Ne,Xe,be,xe,Ce,lt,be,xe,L.DEPTH_BUFFER_BIT,L.NEAREST)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||x.isRenderTargetTexture||I.has(x)){let It=I.get(x),ai=I.get(D);S.bindFramebuffer(L.READ_FRAMEBUFFER,W),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,P);for(let vt=0;vt<Ae;vt++){if(Xi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,It.__webglTexture,k,Ke+vt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,It.__webglTexture,k);if(ft)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,ai.__webglTexture,ve,Nt+vt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ai.__webglTexture,ve);if(k!==0)L.blitFramebuffer(Ne,Xe,be,xe,Ce,lt,be,xe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ft)L.copyTexSubImage3D(Me,ve,Ce,lt,Nt+vt,Ne,Xe,be,xe);else L.copyTexSubImage2D(Me,ve,Ce,lt,Ne,Xe,be,xe)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ft)if(x.isDataTexture||x.isData3DTexture)L.texSubImage3D(Me,ve,Ce,lt,Nt,be,xe,Ae,gt,Kt,St.data);else if(D.isCompressedArrayTexture)L.compressedTexSubImage3D(Me,ve,Ce,lt,Nt,be,xe,Ae,gt,St.data);else L.texSubImage3D(Me,ve,Ce,lt,Nt,be,xe,Ae,gt,Kt,St);else if(x.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,ve,Ce,lt,be,xe,gt,Kt,St.data);else if(x.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,ve,Ce,lt,St.width,St.height,gt,St.data);else L.texSubImage2D(L.TEXTURE_2D,ve,Ce,lt,be,xe,gt,Kt,St);if(S.pixelStorei(L.UNPACK_ROW_LENGTH,an),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,it),S.pixelStorei(L.UNPACK_SKIP_PIXELS,xn),S.pixelStorei(L.UNPACK_SKIP_ROWS,Nn),S.pixelStorei(L.UNPACK_SKIP_IMAGES,ri),ve===0&&D.generateMipmaps)L.generateMipmap(Me);S.unbindTexture()},this.initRenderTarget=function(x){if(I.get(x).__webglFramebuffer===void 0)V.setupRenderTarget(x)},this.initTexture=function(x){if(x.isCubeTexture)V.setTextureCube(x,0);else if(x.isData3DTexture)V.setTexture3D(x,0);else if(x.isDataArrayTexture||x.isCompressedArrayTexture)V.setTexture2DArray(x,0);else V.setTexture2D(x,0);S.unbindTexture()},this.resetState=function(){H=0,j=0,G=null,S.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}function Ct(e,t){let n=document.createElement("canvas");n.width=e,n.height=t;let i=n.getContext("2d");if(!i)throw Error("a canvas has no 2D context");return[n,i]}var Il=(e)=>{let t=e;return()=>{t+=1831565813;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}},tu=(e,t)=>t>0.7?e.glassLight:t<0.3?e.glassDark:e.glass,Vi=(e,t,n)=>{e.strokeStyle=t,e.lineWidth=n,e.lineJoin="round",e.lineCap="round",e.stroke()};function nu(e,t,n,i,s){let r=n+i*0.9;e.beginPath(),e.moveTo(t,n+s),e.lineTo(t,r),e.bezierCurveTo(t,n+i*0.35,t+i*0.38,n+i*0.12,t+i/2,n),e.bezierCurveTo(t+i*0.62,n+i*0.12,t+i,n+i*0.35,t+i,r),e.lineTo(t+i,n+s),e.closePath()}function Mi(e,t,n,i,s=0.32){e.beginPath();for(let r=0;r<8;r+=1){let a=Math.PI/4*r-Math.PI/2,o=r%2===0?i:i*s;e.lineTo(t+Math.cos(a)*o,n+Math.sin(a)*o)}e.closePath()}function iu(e){let[t,n]=Ct(512,512),i=Il(11);n.fillStyle=e.floor,n.fillRect(0,0,512,512);let s=4,r=512/s;for(let a=0;a<s;a+=1)for(let o=0;o<s;o+=1)if((a+o)%2===0||i()>0.7)n.fillStyle=e.stoneShade,n.globalAlpha=0.28,n.fillRect(o*r,a*r,r,r),n.globalAlpha=1;n.strokeStyle=e.floorJoint,n.lineWidth=6;for(let a=0;a<=s;a+=1)n.beginPath(),n.moveTo(a*r,0),n.lineTo(a*r,512),n.moveTo(0,a*r),n.lineTo(512,a*r),n.stroke();return t}function su(e){let[t,n]=Ct(512,512),i=Il(23);n.fillStyle=e.stone,n.fillRect(0,0,512,512);let s=8,r=512/s;for(let a=0;a<s;a+=1){let o=a%2===0?4:5,l=512/(a%2===0?4:4),c=a%2===0?0:-l/2;for(let u=0;u<=o;u+=1){let d=c+u*l;if(i()>0.55)n.fillStyle=e.stoneShade,n.globalAlpha=0.45,n.fillRect(d,a*r,l,r),n.globalAlpha=1;n.fillStyle=e.stoneJoint,n.fillRect(d-3,a*r,6,r)}n.fillStyle=e.stoneJoint,n.fillRect(0,a*r-3,512,6)}return t}function _a(e){let[n,i]=Ct(1024,1024),s=512;i.translate(512,512),i.strokeStyle=e.rune,i.fillStyle=e.rune,i.lineCap="round",i.lineJoin="round",i.shadowColor=e.rune,i.shadowBlur=26;let r=(a,o)=>{i.lineWidth=o,i.beginPath(),i.arc(0,0,a,0,Math.PI*2),i.stroke()};r(480,14),r(452,4),r(330,10),r(300,4),r(150,8);for(let a=0;a<16;a+=1){if(i.save(),i.rotate(Math.PI*2*a/16),i.translate(0,-391),a%2===0)Mi(i,0,0,34,0.3),i.fill();else i.beginPath(),i.arc(0,0,22,0.55*Math.PI,2.45*Math.PI),i.arc(9,-2,18,2.45*Math.PI,0.55*Math.PI,!0),i.closePath(),i.fill();i.restore()}i.lineWidth=7;for(let a=0;a<8;a+=1)i.save(),i.rotate(Math.PI*2*a/8),i.beginPath(),i.moveTo(0,-150),i.lineTo(0,-300),i.stroke(),i.restore();return Mi(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=e.bg,i.globalAlpha=0.55,Mi(i,0,0,52,0.4),i.fill(),n}function Pl(e,t){let n=Il(t==="rose"?5:9);if(t==="lancet"){let[l,c]=Ct(256,512);nu(c,14,10,228,492),c.save(),c.clip(),c.fillStyle=e.glass,c.fillRect(0,0,256,512);let u=3,d=8,h=228/u,p=492/d;for(let v=0;v<d;v+=1)for(let T=0;T<u;T+=1)c.fillStyle=tu(e,n()),c.fillRect(14+T*h,10+v*p,h,p);if(e.night){c.fillStyle=e.sky;for(let v=0;v<6;v+=1)Mi(c,40+n()*176,60+n()*380,5+n()*4,0.3),c.fill()}c.restore(),c.strokeStyle=e.stoneJoint,c.lineWidth=9;for(let v=1;v<u;v+=1)c.beginPath(),c.moveTo(14+v*h,10),c.lineTo(14+v*h,502),c.stroke();for(let v=1;v<d;v+=1)c.beginPath(),c.moveTo(14,10+v*p),c.lineTo(242,10+v*p),c.stroke();return nu(c,14,10,228,492),Vi(c,e.ink,12),l}let i=512,[s,r]=Ct(i,i),a=i/2;r.beginPath(),r.arc(a,a,236,0,Math.PI*2),r.save(),r.clip(),r.fillStyle=e.glass,r.fillRect(0,0,i,i);let o=i/8;for(let l=0;l<8;l+=1)for(let c=0;c<8;c+=1)r.fillStyle=tu(e,n()),r.fillRect(c*o,l*o,o,o);if(r.fillStyle=e.sky,r.beginPath(),r.arc(a,a-8,98,0,Math.PI*2),r.fill(),e.night){r.fillStyle=e.glass,r.beginPath(),r.arc(a+52,a-34,88,0,Math.PI*2),r.fill(),r.fillStyle=e.sky;for(let[l,c,u]of[[150,120,12],[380,150,9],[120,340,8],[400,360,12],[310,90,7]])Mi(r,l,c,u,0.3),r.fill()}else{r.strokeStyle=e.sky,r.lineWidth=12;for(let l=0;l<12;l+=1){let c=Math.PI*2*l/12;r.beginPath(),r.moveTo(a+Math.cos(c)*120,a-8+Math.sin(c)*120),r.lineTo(a+Math.cos(c)*190,a-8+Math.sin(c)*190),r.stroke()}}r.restore(),r.strokeStyle=e.stoneJoint,r.lineWidth=12;for(let l=1;l<8;l+=1)r.beginPath(),r.moveTo(l*o,0),r.lineTo(l*o,i),r.moveTo(0,l*o),r.lineTo(i,l*o),r.stroke();return r.beginPath(),r.arc(a,a,236,0,Math.PI*2),Vi(r,e.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Vi(r,e.stoneShade,14),s}function ru(e,t){let[n,i]=Ct(256,512),s=()=>{i.beginPath(),i.moveTo(24,10),i.lineTo(232,10),i.lineTo(232,470),i.lineTo(128,400),i.lineTo(24,470),i.closePath()};if(s(),i.fillStyle=e.banner,i.fill(),i.save(),s(),i.clip(),i.fillStyle=e.ink,i.globalAlpha=0.18,i.fillRect(128,0,128,512),i.restore(),s(),Vi(i,e.bannerEdge,14),s(),Vi(i,e.ink,5),i.strokeStyle=e.bannerEdge,i.fillStyle=e.bannerEdge,i.lineWidth=9,i.lineCap="round",i.beginPath(),i.moveTo(40,56),i.lineTo(216,56),i.stroke(),t==="star")Mi(i,128,220,84,0.22),i.fill(),i.beginPath(),i.arc(128,220,14,0,Math.PI*2),i.fillStyle=e.banner,i.fill();else if(t==="moon")i.beginPath(),i.arc(128,215,74,0,Math.PI*2),i.fill(),i.fillStyle=e.banner,i.beginPath(),i.arc(158,196,66,0,Math.PI*2),i.fill(),i.fillStyle=e.bannerEdge,Mi(i,170,266,24,0.3),i.fill();else i.beginPath(),i.moveTo(128,120),i.lineTo(190,215),i.lineTo(128,320),i.lineTo(66,215),i.closePath(),i.lineWidth=11,i.stroke(),Mi(i,128,215,34,0.3),i.fill();return n}function au(e){let[t,n]=Ct(256,320);return n.fillStyle=e.woodDark,n.fillRect(8,8,240,304),n.fillStyle=e.woodLight,n.fillRect(24,24,208,272),n.fillStyle=e.wood,n.beginPath(),n.moveTo(24,296),n.lineTo(232,296),n.lineTo(232,24),n.lineTo(212,44),n.lineTo(212,276),n.lineTo(44,276),n.closePath(),n.fill(),n.fillStyle=e.woodDark,n.fillRect(44,44,168,232),n.strokeStyle=e.goldDark,n.lineWidth=8,n.strokeRect(44,44,168,232),n.strokeStyle=e.gold,n.lineWidth=4,n.strokeRect(56,56,144,208),n.fillStyle=e.gold,n.beginPath(),n.moveTo(128,84),n.lineTo(172,160),n.lineTo(128,238),n.lineTo(84,160),n.closePath(),n.fill(),n.fillStyle=e.woodDark,n.beginPath(),n.moveTo(128,122),n.lineTo(148,160),n.lineTo(128,202),n.lineTo(108,160),n.closePath(),n.fill(),n.strokeStyle=e.ink,n.lineWidth=5,n.strokeRect(8,8,240,304),t}function ou(e){let[t,n]=Ct(128,192),i=(s,r,a,o)=>{n.beginPath(),n.moveTo(s,r),n.bezierCurveTo(s+o*0.2,r+(a-r)*0.3,s+o,r+(a-r)*0.5,s+o,a-o*0.9),n.arc(s,a-o*0.9,o,0,Math.PI,!1),n.bezierCurveTo(s-o,r+(a-r)*0.5,s-o*0.2,r+(a-r)*0.3,s,r),n.closePath()};return i(64,10,182,44),n.fillStyle=e.flame,n.fill(),Vi(n,e.ink,7),i(64,74,176,24),n.fillStyle=e.flameCore,n.fill(),t}function lu(e){let[t,n]=Ct(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Vi(n,e.ink,8)};i(0,e.paper),n.fillStyle=e.ink;for(let s of[-26,0,26])n.beginPath(),n.arc(64+s,70,9,0,Math.PI*2),n.fill();return i(1,e.gold),n.fillStyle=e.ink,n.beginPath(),n.moveTo(180,26),n.lineTo(204,26),n.lineTo(199,74),n.lineTo(185,74),n.closePath(),n.fill(),n.beginPath(),n.arc(192,94,8,0,Math.PI*2),n.fill(),i(2,"#58c878"),n.strokeStyle=e.paper,n.lineWidth=14,n.lineCap="round",n.lineJoin="round",n.beginPath(),n.moveTo(294,66),n.lineTo(312,84),n.lineTo(348,44),n.stroke(),i(3,"#ee4b4b"),n.strokeStyle=e.paper,n.beginPath(),n.moveTo(428,44),n.lineTo(468,84),n.moveTo(468,44),n.lineTo(428,84),n.stroke(),t}function xa(){let[e,t]=Ct(128,128),n=t.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(0.35,"rgba(255,255,255,.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),e}function cu(){let[e,t]=Ct(256,512),n=[[20,60,0.55],[96,40,0.8],[150,70,0.45],[220,30,0.7]];for(let[i,s,r]of n)t.fillStyle=`rgba(255,255,255,${r})`,t.beginPath(),t.moveTo(i,0),t.lineTo(i+s,0),t.lineTo(i+s+90,512),t.lineTo(i+90,512),t.closePath(),t.fill();return e}function hu(e){let[t,n]=Ct(256,256);n.lineCap="round";let i=[[Math.PI*1.1,78,128],[Math.PI*1.32,84,138],[Math.PI*1.54,76,124]],s=196,r=204;for(let[a,o]of[[e.ink,34],[e.gold,20]]){n.strokeStyle=a,n.lineWidth=o;for(let[l,c,u]of i)n.beginPath(),n.moveTo(s+Math.cos(l)*c,r+Math.sin(l)*c),n.lineTo(s+Math.cos(l)*u,r+Math.sin(l)*u),n.stroke()}return t}var va=0.034,Ll=0.02,Nl=0.024,n0=(e)=>{let t=new Image;return t.decoding="async",t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,t.decode().then(()=>t)};function Dl(e,t,n,i){let[s,r]=Ct(t,n);return r.drawImage(e,0,0,t,n),r.globalCompositeOperation="source-in",r.fillStyle=i,r.fillRect(0,0,t,n),s}function Ul(e,t=48){return Array.from({length:t},(n,i)=>{let s=Math.PI*2*i/t;return[Math.cos(s)*e,Math.sin(s)*e]})}async function uu(e,t,n){let{rim:i,ink:s,edge:r}=n,a=await n0(e),o=(a.naturalHeight||a.height||t)/(a.naturalWidth||a.width||t),l=Math.round(t),c=Math.round(t*o),u=Math.ceil(t*(va+Ll+Nl))+2,[d,h]=Ct(l+u*2,c+u*2),p=Dl(a,l,c,s),v=Dl(a,l,c,i),T=Dl(a,l,c,r);for(let[m,f]of Ul(t*(va+Ll)))h.drawImage(T,u+m+t*Nl*0.5,u+f+t*Nl);for(let[m,f]of Ul(t*(va+Ll)))h.drawImage(p,u+m,u+f);for(let[m,f]of Ul(t*va))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function ya(e,t,n){let i=(r,a)=>Number.parseInt(r.slice(1+a*2,3+a*2),16),s=(r)=>Math.round(i(e,r)+(i(t,r)-i(e,r))*n).toString(16).padStart(2,"0");return`#${s(0)}${s(1)}${s(2)}`}var pr=Math.PI*2,Sa=(e,t=0,n=1)=>Math.min(n,Math.max(t,e));function i0(e){let[t,n]=Ct(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=e.paper,r=ya(e.paper,e.ink,e.night?0.42:0.28);n.fillStyle=e.ink;for(let[a,o,l]of i)n.beginPath(),n.arc(a,o,l+5,0,pr),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,pr);n.clip(),n.fillStyle=r,n.fillRect(0,0,128,128),n.fillStyle=s;for(let[a,o,l]of i)n.beginPath(),n.arc(a-7,o-8,l,0,pr),n.fill();return n.restore(),t}function s0(e){let[t,n]=Ct(64,64);n.translate(32,32),n.beginPath();for(let i=0;i<8;i+=1){let s=Math.PI/4*i-Math.PI/2,r=i%2===0?27:8;n.lineTo(Math.cos(s)*r,Math.sin(s)*r)}return n.closePath(),n.lineJoin="round",n.lineWidth=7,n.strokeStyle=e.ink,n.stroke(),n.fillStyle=e.gold,n.fill(),t}function r0(){let[e,t]=Ct(64,256),n=t.createLinearGradient(0,0,64,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(0.5,"rgba(255,255,255,1)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,64,256),t.globalCompositeOperation="destination-in";let i=t.createLinearGradient(0,256,0,0);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(0.55,"rgba(255,255,255,.45)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,64,256),e}class Fl{hall;group=new Yt;runs=[];textures=new Map;planes=new Map;constructor(e){this.hall=e}texture(e,t){let n=this.textures.get(e);if(n)return n;let i=new Si(t());return i.colorSpace=gi,this.textures.set(e,i),i}plane(e,t,n){let i=this.planes.get(e);if(i)return i;let s=new At(t,n);return this.planes.set(e,s),s}get glow(){return this.hall.additive?ei:Cn}puff(e,t){let n=this.hall,i=this.texture("cloud",()=>i0(n)),s=this.texture("sparkle",()=>s0(n)),r=Array.from({length:7},(o,l)=>{let c=pr*l/7+l%2*0.4,u=new ir(new Ps({map:i,transparent:!0,depthWrite:!1,fog:!1}));return u.renderOrder=8,this.group.add(u),{sprite:u,angle:c,reach:0.55+l%3*0.22,size:1.5+l*5%4*0.28,lift:-0.9+l%4*0.75,turn:(l%2?1:-1)*(0.25+l%3*0.1)}}),a=Array.from({length:4},(o,l)=>{let c=new ir(new Ps({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:pr*l/4+0.7}});this.runs.push({start:t,update:(o)=>{let l=Sa(o/en),c=vi(l/0.35),u=1-(1-l)**2,d=1-Sa((l-0.55)/0.45);for(let h of r)h.sprite.position.set(e.x+Math.cos(h.angle)*h.reach*(0.5+u*1.3),e.y+h.lift*(0.6+u*0.5)+l*1.2,e.z+Math.sin(h.angle)*h.reach*(0.5+u*1.3)),h.sprite.scale.setScalar(Math.max(h.size*c,0.01)),h.sprite.material.rotation=h.angle*0.3+h.turn*l,h.sprite.material.opacity=d;for(let h of a){let p=0.9+u*1.6;h.sprite.position.set(e.x+Math.cos(h.angle)*p,e.y+0.5+u*1.4,e.z+Math.sin(h.angle)*p),h.sprite.scale.setScalar(0.5*vi(Sa((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-Sa((l-0.5)/0.4)}return l<1},end:()=>{for(let o of r)this.group.remove(o.sprite),o.sprite.material.dispose();for(let o of a)this.group.remove(o.sprite),o.sprite.material.dispose()}})}circle(e,t){let n=this.hall,i=this.texture("rune",()=>{let[d,h]=Ct(256,256);return h.drawImage(_a(n),0,0,256,256),d}),s=this.texture("column",r0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Yt;o.position.set(e.x,e.y+0.03,e.z);let l=new Ge(r,new Ft({map:i,transparent:!0,depthWrite:!1,blending:this.glow,opacity:0,fog:!1}));l.rotation.x=-Math.PI/2,l.renderOrder=4,o.add(l);let c=new Yt;c.position.set(e.x,e.y+0.1,e.z);let u=new Ft({map:s,color:n.rune,transparent:!0,depthWrite:!1,blending:this.glow,side:cn,opacity:0,fog:!1});for(let d of[0,Math.PI/2]){let h=new Ge(a,u);h.position.y=2.5,h.rotation.y=d,h.renderOrder=6,c.add(h)}this.group.add(o,c),this.runs.push({start:t,update:(d)=>{let h=xi(d);return l.material.opacity=h.circle*(n.night?1:0.9),o.rotation.y=h.spin,u.opacity=h.light*0.75,c.scale.set(1,0.4+h.light*0.6,1),d<tn},end:()=>{this.group.remove(o,c),l.material.dispose(),u.dispose()}})}step(e){for(let t=this.runs.length-1;t>=0;t-=1){let n=this.runs[t];if(!n)continue;let i=e-n.start;if(i<0)continue;if(!n.update(i))n.end(),this.runs.splice(t,1)}return this.runs.length>0}dispose(){for(let e of this.runs)e.end();this.runs.length=0;for(let e of this.textures.values())e.dispose();for(let e of this.planes.values())e.dispose();this.textures.clear(),this.planes.clear(),this.group.removeFromParent()}}function du(e,t=0.0001){t=Math.max(t,Number.EPSILON);let n={},i=e.getIndex(),s=e.getAttribute("position"),r=i?i.count:s.count,a=0,o=Object.keys(e.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let E=0,C=o.length;E<C;E++){let y=o[E],b=e.attributes[y];l[y]=new b.constructor(new b.array.constructor(b.count*b.itemSize),b.itemSize,b.normalized);let w=e.morphAttributes[y];if(w){if(!c[y])c[y]=[];w.forEach((A,_)=>{let M=new A.array.constructor(A.count*A.itemSize);c[y][_]=new A.constructor(M,A.itemSize,A.normalized)})}}let p=t*0.5,v=Math.log10(1/t),T=Math.pow(10,v),m=p*T;for(let E=0;E<r;E++){let C=i?i.getX(E):E,y="";for(let b=0,w=o.length;b<w;b++){let A=o[b],_=e.getAttribute(A),M=_.itemSize;for(let B=0;B<M;B++)y+=`${Math.trunc(_[d[B]](C)*T+m)},`}if(y in n)u.push(n[y]);else{for(let b=0,w=o.length;b<w;b++){let A=o[b],_=e.getAttribute(A),M=e.morphAttributes[A],B=_.itemSize,R=l[A],U=c[A];for(let W=0;W<B;W++){let P=d[W],H=h[W];if(R[H](a,_[P](C)),M)for(let j=0,G=M.length;j<G;j++)U[j][H](a,M[j][P](C))}}n[y]=a,u.push(a),a++}}let f=e.clone();for(let E in e.attributes){let C=l[E];if(f.setAttribute(E,new C.constructor(C.array.slice(0,a*C.itemSize),C.itemSize,C.normalized)),!(E in c))continue;for(let y=0;y<c[E].length;y++){let b=c[E][y];f.morphAttributes[E][y]=new b.constructor(b.array.slice(0,a*b.itemSize),b.itemSize,b.normalized)}}return f.setIndex(u),f}function a0(){let e=new Uint8Array([125,195,255]),t=new sr(e,3,1,Xr,fn);return t.minFilter=In,t.magFilter=In,t.generateMipmaps=!1,t.needsUpdate=!0,t}class Ol{steps=a0();lit=new Map;flat=new Map;ink=new We("#000000");hullMaterial=new Ft({color:this.ink,side:Wt,fog:!1});toon(e,t){let n=this.lit.get(e);if(!n)n=new si({color:t,gradientMap:this.steps}),this.lit.set(e,n);else n.color.set(t);return n}basic(e,t){let n=this.flat.get(e);if(!n)n=new Ft({color:t,fog:!1}),this.flat.set(e,n);else n.color.set(t);return n}setInk(e){this.ink.set(e),this.hullMaterial.color.copy(this.ink)}dispose(){this.steps.dispose(),this.hullMaterial.dispose();for(let e of this.lit.values())e.dispose();for(let e of this.flat.values())e.dispose()}}function o0(e,t){let n=e.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=du(n,0.0001);i.computeVertexNormals();let s=i.getAttribute("position"),r=i.getAttribute("normal"),a=new O;for(let o=0;o<s.count;o+=1)a.fromBufferAttribute(r,o).multiplyScalar(t),s.setXYZ(o,s.getX(o)+a.x,s.getY(o)+a.y,s.getZ(o)+a.z);return s.needsUpdate=!0,i}function Ti(e,t,n,i){let s=i.get(e.geometry);if(!s)s=o0(e.geometry,n),i.set(e.geometry,s);let r=new Ge(s,t.hullMaterial);return r.renderOrder=e.renderOrder,r.userData.hull=!0,e.add(r),e}var Wi=12,mr=12,l0=["moon","star","crest"];class fu{textures=[];geometries=[];materials=[];texture(e,t){let n=new Si(e);if(n.colorSpace=gi,t)n.wrapS=Js,n.wrapT=Js,n.repeat.set(t[0],t[1]);else n.wrapS=Bn,n.wrapT=Bn;return n.anisotropy=4,this.textures.push(n),n}geometry(e){return this.geometries.push(e),e}material(e){return this.materials.push(e),e}dispose(){for(let e of this.textures)e.dispose();for(let e of this.geometries)e.dispose();for(let e of this.materials)e.dispose()}}function pu(e,t,n){let i=new fu,s=new Yt,r=new Map,a=Pt(t),o=a+9.5,l=(ee,me={})=>i.material(new Ft({map:ee,transparent:!0,depthWrite:!1,fog:!1,...me})),c=e.additive?ei:Cn,u=i.texture(iu(e),[o/2.2,o/2.2]),d=new Ge(i.geometry(new Ls(o+1,72)),i.material(new si({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Ge(i.geometry(new gn(a+1.9,a+2.15,0.2,72)),n.toon("dais",e.stoneShade));h.position.y=0.1,Ti(h,n,0.07,r),s.add(h);let p=new Ge(i.geometry(new At((a-0.7)*2,(a-0.7)*2)),l(i.texture(_a(e)),{blending:c,opacity:e.night?e.runeGlow:1}));p.rotation.x=-Math.PI/2,p.position.y=0.215,s.add(p);let v=i.material(new si({color:"#ffffff",map:i.texture(su(e),[o*Ut/7,Wi/5]),gradientMap:n.steps,side:Wt})),T=new Ge(i.geometry(new gn(o,o,Wi,72,1,!0)),v);T.position.y=Wi/2,s.add(T);let m=new Ge(i.geometry(new Ls(o+1,48)),i.material(new Ft({color:e.bg,side:cn})));m.rotation.x=Math.PI/2,m.position.y=Wi,s.add(m);let f=i.geometry(new gn(0.6,0.66,Wi,14)),E=i.geometry(new gn(0.88,0.7,0.5,14)),C=i.geometry(new gn(0.78,0.9,0.6,14)),y=i.geometry(new At(2.2,4.4)),b=i.geometry(new gn(0.34,0.2,0.36,10)),w=i.geometry(new gn(0.06,0.06,0.7,6)),A=i.geometry(new At(0.62,0.93)),_=i.geometry(new At(2.6,2.6)),M=l(i.texture(ou(e)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),B=l(i.texture(xa()),{color:e.flame,blending:c,opacity:e.night?0.55:0.28}),R=l0.map((ee)=>i.material(new Ft({map:i.texture(ru(e,ee)),transparent:!0,alphaTest:0.4,fog:!1}))),U=[],W=(ee,me,we,He)=>(He.position.set(Math.sin(ee)*me,we,Math.cos(ee)*me),He.rotation.y=ee+Math.PI,s.add(He),He);for(let ee=0;ee<mr;ee+=1){let me=Ut*(ee+0.5)/mr,we=new Ge(f,n.toon("pillar",e.stone));W(me,o-0.7,Wi/2,we),Ti(we,n,0.06,r);let He=new Ge(E,n.toon("pillar",e.stone));W(me,o-0.7,Wi-0.55,He);let Fe=new Ge(C,n.toon("pillar",e.stone));W(me,o-0.7,0.3,Fe);let Y=new Ge(y,R[ee%R.length]??R[0]);W(me,o-1.34,6.8,Y);let se=new Ge(w,n.toon("iron",e.woodDark));W(me,o-1.4,2.8,se),se.rotation.x=Math.PI/2;let ae=new Ge(b,n.toon("iron",e.woodDark));W(me,o-1.75,2.95,ae),Ti(ae,n,0.04,r);let Re=new Ge(A,M);Re.position.set(Math.sin(me)*(o-1.75),3.5,Math.cos(me)*(o-1.75)),Re.renderOrder=3,s.add(Re);let Ie=new Ge(_,B);Ie.position.copy(Re.position),Ie.renderOrder=2,s.add(Ie),U.push({body:Re,halo:Ie,phase:ee*1.7,base:1})}let P=i.geometry(new At(2.6,5.2)),H=i.geometry(new At(4.6,4.6)),j=l(i.texture(Pl(e,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),G=l(i.texture(Pl(e,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),re=i.geometry(new At(3.4,10)),q=l(i.texture(cu()),{color:e.beam,opacity:e.beamAlpha,blending:c,side:cn}),te=[];for(let ee=0;ee<mr;ee+=1){let me=Ut*ee/mr,we=ee===mr/2,He=new Ge(we?H:P,we?G:j);W(me,o-0.12,we?7.1:6.2,He);let Fe=new Ge(re,q),Y=o-4.4;Fe.position.set(Math.sin(me)*Y,4.4,Math.cos(me)*Y),Fe.rotation.set(0,me+Math.PI,0),Fe.rotateX(-0.62),Fe.renderOrder=1,s.add(Fe),te.push(Fe)}return{group:s,flames:U,beams:te,wallRadius:o,dispose(){for(let ee of r.values())ee.dispose();i.dispose()}}}function mu(e,t,n){for(let i of e){let s=n?1:1+0.09*Math.sin(t*9+i.phase)+0.05*Math.sin(t*17+i.phase*2);i.body.scale.set(s*0.96,s*(1.02+(n?0:0.06*Math.sin(t*11+i.phase))),1),i.halo.scale.setScalar(n?1:0.95+0.1*Math.sin(t*7+i.phase))}}function gu(e){let t=()=>{let p=e.idleMs??80;return typeof p==="function"?p():p},{host:n}=e,i=!0,s,r=0,a=!1,o=Number.NEGATIVE_INFINITY,l=!1,c=()=>l||!i||n.hidden(),u=()=>{if(s===void 0)return;n.cancel(s),s=void 0},d=(p)=>{if(s=void 0,c())return;if(a||p-o>=t()){let v=r===0?16:Math.min(p-r,100);r=p,o=p,a=e.frame(p,v)}if(a||t()>0)s=n.request(d)},h=()=>{if(s!==void 0||c())return;r=0,s=n.request(d)};return{get state(){if(c())return"paused";return a?"live":"idle"},wake(){a=!0,h()},setVisible(p){if(i=p,c())u();else h()},sync(){if(c())u();else h()},dispose(){l=!0,u()}}}var xu=2;var vu=(e,t)=>Math.abs(e.x-t.x)<(e.w+t.w)/2+2&&Math.abs(e.y-t.y)<(e.h+t.h)/2+2,c0=(e,t,n)=>n<t?(t+n)/2:Math.min(n,Math.max(t,e));function _u(e,t,n,i){let s=e.w/2+2,r=i.width-e.w/2-2,a=e.h/2,o=i.height-e.h/2,l=[...t,...n],c=[e.x,...e.above?[e.above.x]:[],...l.flatMap((p)=>[p.x-(p.w+e.w)/2-2,p.x+(p.w+e.w)/2+2])].map((p)=>c0(p,s,r)),u=[e.y,...e.above?[e.above.y]:[],...l.flatMap((p)=>[p.y-(p.h+e.h)/2-2,p.y+(p.h+e.h)/2+2])].filter((p)=>p>=a&&p<=o),d,h=Number.POSITIVE_INFINITY;for(let p of c)for(let v of u){let T=e.above,m=Math.min(Math.hypot(p-e.x,(v-e.y)*1.5),T?Math.hypot(p-T.x,(v-T.y)*1.5)+40:Number.POSITIVE_INFINITY);if(m>=h)continue;let f={x:p,y:v,w:e.w,h:e.h};if(l.some((E)=>vu(f,E)))continue;d=f,h=m}return d}function yu(e,t,n=[]){let i=e.map(({x:l,y:c})=>({x:l,y:c})),s=[],r=!0,a=0,o=e.map((l,c)=>c).sort((l,c)=>(e[c]?.y??0)-(e[l]?.y??0)||(e[l]?.x??0)-(e[c]?.x??0)||l-c);for(let l of o){let c=e[l];if(!c)continue;let u=_u(c,s,n,t);if(!u){if(u=_u(c,s,[],t),u&&n.some((h)=>vu(u,h)))a+=1}if(!u)r=!1;let d=u??c;s.push(d),i[l]={x:d.x,y:d.y}}return{spots:i,clear:r,covering:a}}var h0=1.06,u0=0.68,Su=12,d0=16;class Bl{labels;click;root=document.createElement("div");items=new Map;point=new O;local=new O;constructor(e,t,n){this.labels=t;this.click=n;this.root.className="rt-names",e.appendChild(this.root)}paint(e){let t=this.root.style;t.setProperty("--rt-gold",e.gold),t.setProperty("--rt-gold-dark",e.goldDark),t.setProperty("--rt-plate-ink",e.plateInk),t.setProperty("--rt-ink",e.ink),t.setProperty("--rt-font",Tt)}set(e,t){for(let n of this.items.values())n.el.remove();this.items.clear();for(let n of e){if(n.init.kind==="owner")continue;let i=document.createElement("button");if(i.type="button",i.className="rt-name",i.textContent=n.init.name,i.setAttribute("aria-label",n.init.kind==="agent"?this.labels.seat(n.init.name,t(n)):n.init.name),n.init.id)i.dataset.seat=n.init.id;i.addEventListener("click",(s)=>this.click(n,Mt(s,i))),this.root.appendChild(i),this.items.set(n,{el:i,x:0,y:0,shown:!1})}}relabel(e,t){let n=this.items.get(e);if(n&&e.init.kind==="agent")n.el.setAttribute("aria-label",this.labels.seat(e.init.name,t))}size(e){this.root.style.setProperty("--rt-name-size",`${Math.max(Su,Math.min(d0,e*0.0125)).toFixed(1)}px`)}place(e,t,n,i,s){e.updateMatrixWorld();let r=[];for(let[l,c]of this.items){this.local.copy(t),l.group.worldToLocal(this.local);let u=this.local.z>=0?1:-1;this.point.set(0,h0,u*u0),l.group.localToWorld(this.point),this.point.project(e);let d=(this.point.x*0.5+0.5)*n,h=(-this.point.y*0.5+0.5)*i,v=this.point.z<1&&d>-n*0.05&&d<n*1.05&&h>-i*0.05&&h<i*1.05&&l!==s&&l.group.visible&&!l.labelHidden;if(v!==c.shown)c.shown=v,c.el.style.visibility=v?"visible":"hidden";if(!v)continue;r.push({item:c,podium:l,x:d,y:h,w:c.el.offsetWidth,h:c.el.offsetHeight||Su*1.8})}let a=this.faces(e,t,n,i);for(let l of r){let c=a.get(l.podium);if(c)l.above={x:c.x,y:c.y-c.h/2-l.h/2-xu}}let o=yu(r,{width:n,height:i},[...a.values()]);return r.forEach(({item:l},c)=>{let u=o.spots[c];if(!u)return;if(Math.abs(u.x-l.x)>0.25||Math.abs(u.y-l.y)>0.25)l.x=u.x,l.y=u.y,l.el.style.transform=`translate(${u.x.toFixed(1)}px, ${u.y.toFixed(1)}px) translate(-50%, -50%)`}),o.clear}faces(e,t,n,i){let s=new Map,r=[t.x,t.y,t.z];for(let a of this.items.keys()){if(a.init.kind!=="agent")continue;if(!a.group.visible||!a.board.visible)continue;a.board.getWorldPosition(this.point);let o=[this.point.x,this.point.y,this.point.z],{POSITIVE_INFINITY:l,NEGATIVE_INFINITY:c,POSITIVE_INFINITY:u,NEGATIVE_INFINITY:d}=Number,h=!1;for(let[p,v,T]of os(o,a.board.scale.y,r)){if(this.point.set(p,v,T).project(e),this.point.z>=1)h=!0;let m=(this.point.x*0.5+0.5)*n,f=(-this.point.y*0.5+0.5)*i;l=Math.min(l,m),c=Math.max(c,m),u=Math.min(u,f),d=Math.max(d,f)}if(h)continue;s.set(a,{x:(l+c)/2,y:(u+d)/2,w:c-l,h:d-u})}return s}dispose(){this.root.remove(),this.items.clear()}}var Mu=0.62;function f0(e,t){let n=Math.atan2(e,t),i=(s)=>Math.max(-Mu,Math.min(Mu,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(Jt(n-Math.PI))}var _r=1.3,p0=1.24,m0=0.31,g0=[512,128],Ma={waiting:0,alert:1,done:2,error:3};function bu(e){switch(e){case"thinking":case"working":return"waiting";case"waiting":return"alert";case"done":return"done";case"error":return"error";default:return null}}class zl{hall;geometries=[];textures=[];hulls=new Map;plinth=this.own(new Hn(1.84,0.2,1.4));body;slab=this.own(new Hn(1.98,0.14,1.5));trim=this.own(new Hn(2.01,0.04,1.53));panelPlane=this.own(new At(0.84,1.05));platePlane=this.own(new At(p0,m0));glowPlane=this.own(new At(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new At(1.25,1.25));constructor(e){this.hall=e;let t=new gn(0.82*Math.SQRT2,0.72*Math.SQRT2,1,4,1);t.rotateY(Math.PI/4),this.body=this.own(t),this.panelTexture=this.texture(au(e)),this.glowTexture=this.texture(xa()),this.badgeTexture=this.texture(lu(e)),this.marksTexture=this.texture(hu(e));let n=(i)=>{let s=new At(0.56,0.56),r=s.getAttribute("uv");for(let a=0;a<r.count;a+=1)r.setX(a,(i+r.getX(a))/4);return this.own(s)};this.badgePlanes={waiting:n(Ma.waiting),alert:n(Ma.alert),done:n(Ma.done),error:n(Ma.error)}}own(e){return this.geometries.push(e),e}texture(e){let t=new Si(e);return t.colorSpace=gi,t.wrapS=Bn,t.wrapT=Bn,t.anisotropy=4,t.minFilter=sn,this.textures.push(t),t}dispose(){for(let e of this.geometries)e.dispose();for(let e of this.hulls.values())e.dispose();for(let e of this.textures)e.dispose()}}class xr{init;kit;group=new Yt;rig=new Yt;board;boardMaterial;glow;glowMaterial;badge;badgeMaterial;marks;marksMaterial;marksSince=0;marksOn=!1;hits=[];plateTexture;plateMaterial;panelMaterial;shown=null;plateText={text:"",px:0};speak=0;bob=0;boardY=0;labelHidden=!1;phase=Math.random()*6;constructor(e,t,n){this.init=e;this.kit=t;let{hall:i}=t,s=(E)=>(E.userData.seat=e.id??null,E.userData.kind=e.kind,this.hits.push(E),E),r=new Ge(t.plinth,n.toon("woodDark",i.woodDark));r.position.y=0.1,Ti(r,n,0.045,t.hulls);let a=new Ge(t.body,n.toon("wood",i.wood));a.scale.set(1,1,0.756);let o=e.kind==="owner";a.scale.y=o?0.3:1,a.position.y=o?0.35:0.7,Ti(a,n,0.045,t.hulls);let l=new Ge(t.slab,n.toon("woodLight",i.woodLight));l.position.y=o?0.58:1.27,Ti(l,n,0.045,t.hulls);let c=new Ge(t.trim,n.toon("gold",i.gold));c.position.y=o?0.51:1.2,this.group.add(r,s(a),s(l),c),this.panelMaterial=new si({map:t.panelTexture,transparent:!0,gradientMap:n.steps});let u=new Ge(t.panelPlane,this.panelMaterial);u.position.set(0,0.68,0.64),u.visible=!o,this.group.add(u);let[d,h]=g0,[p,v]=Ct(d,h);this.plateTexture=t.texture(p),this.plateText=rs(v,e.name,d,h,i),this.plateMaterial=new Ft({map:this.plateTexture,fog:!1});let T=new Ge(t.platePlane,this.plateMaterial);T.position.set(0,o?0.36:1.06,0.68),T.rotation.x=-0.16;let m=new Ge(t.platePlane,this.plateMaterial);m.position.set(0,o?0.36:1.06,-0.68),m.rotation.y=Math.PI,m.rotation.x=-0.16,this.group.add(s(T),s(m));let f=new Ft({transparent:!0,alphaTest:0.4,fog:!1});if(this.boardMaterial=f,this.board=new Ge(new At(ht,ht),f),this.board.visible=!1,this.board.position.y=_r+ht/2,s(this.board),this.glowMaterial=new Ft({map:t.glowTexture,color:e.accent,transparent:!0,opacity:0,depthWrite:!1,fog:!1,blending:i.additive?ei:Cn}),this.glow=new Ge(t.glowPlane,this.glowMaterial),this.glow.position.set(0,_r+ht/2,-0.5),this.glow.visible=!1,this.badgeMaterial=new Ft({map:t.badgeTexture,transparent:!0,alphaTest:0.2,fog:!1}),this.badge=new Ge(t.badgePlanes.waiting,this.badgeMaterial),this.badge.position.set(1.05,_r+ht,0.05),this.badge.visible=!1,this.badge.renderOrder=5,this.marksMaterial=new Ft({map:t.marksTexture,transparent:!0,alphaTest:0.2,depthTest:!1,depthWrite:!1,fog:!1}),this.marks=new Ge(t.marksPlane,this.marksMaterial),this.marks.position.set(-1,_r+ht*0.76,0.2),this.marks.visible=!1,this.marks.renderOrder=5,e.kind==="agent")this.rig.position.set(0,0,-0.08),this.rig.add(this.glow,this.board,this.badge,this.marks),this.group.add(this.rig)}setSticker(e){let t=this.boardMaterial.map,n=this.kit.texture(e);this.boardMaterial.map=n,this.boardMaterial.needsUpdate=!0;let i=e.height/e.width;this.board.scale.set(1,i,1),this.boardY=_r+ht*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+ht*i/2+0.02,this.board.visible=!0,t?.dispose()}markFrame(e,t,n){let i=e&&!n;if(i&&!this.marksOn)this.marksSince=t;if(this.marksOn=i,!i)return this.marks.visible=!1,!1;let s=Math.min((t-this.marksSince)/0.4,1),r=1.70158,a=1+(r+1)*(s-1)**3+r*(s-1)**2;return this.marks.visible=!0,this.marks.scale.setScalar(Math.max(a,0.01)),s<1}setBadge(e){if(e===this.shown)return;if(this.shown=e,this.badge.visible=e!==null,e)this.badge.geometry=this.kit.badgePlanes[e]}setDim(e){this.boardMaterial.color.set(e?"#7a7f8f":"#ffffff")}face(e){let t=this.group.worldToLocal(e.clone());this.rig.rotation.y=f0(t.x,t.z)}dispose(){this.plateTexture.dispose(),this.plateMaterial.dispose(),this.panelMaterial.dispose(),this.boardMaterial.map?.dispose(),this.boardMaterial.dispose(),this.board.geometry.dispose(),this.glowMaterial.dispose(),this.badgeMaterial.dispose(),this.marksMaterial.dispose()}}function Tu(e,t){let n=document.createElement("div");n.className="rt-speed",n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;inset:0;pointer-events:none;opacity:0;background:repeating-conic-gradient(from 3deg at 50% 52%,rgba(255,255,255,.85) 0 .55deg,transparent .55deg 5.2deg);-webkit-mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);",e.appendChild(n);let i;return{play(){if(t())return!1;if(n.dataset.playing="",typeof n.animate==="function")n.animate([{opacity:0,transform:"scale(1.18)"},{opacity:0.9,transform:"scale(1.04)",offset:0.3},{opacity:0,transform:"scale(1)"}],{duration:400,easing:"ease-out"});else n.style.opacity="0.9";if(i!==void 0)clearTimeout(i);return i=setTimeout(()=>{delete n.dataset.playing,n.style.opacity="0"},400),!0},dispose(){if(i!==void 0)clearTimeout(i);n.remove()}}}var _0=2,x0=1.5,v0=60,wu=8,y0=1.22,S0=0.82,Eu=(e,t,n,i)=>e+(t-e)*(1-Math.exp(-n*i)),kl=0.2,M0=2,Au=(e)=>e.init.id??e.init.kind;function aS(e,t,n){let i=window.matchMedia("(prefers-reduced-motion: reduce)"),s=t.reducedMotion==="auto"||t.reducedMotion===void 0?i.matches:t.reducedMotion,r=window.matchMedia("(pointer: coarse)").matches,a=t.lowPower==="auto"||t.lowPower===void 0?r||Math.min(e.clientWidth||innerWidth,innerWidth)<700||(navigator.hardwareConcurrency||8)<=4:t.lowPower,o=a?x0:_0,l=new Rl({antialias:!a,alpha:!1,powerPreference:a?"default":"high-performance"});l.setPixelRatio(Math.min(window.devicePixelRatio||1,o));let c=l.domElement;if(c.style.cssText="display:block;width:100%;height:100%;touch-action:none;outline:none;cursor:grab",c.setAttribute("aria-hidden","true"),getComputedStyle(e).position==="static")e.style.position="relative";e.appendChild(c);let u=t.labels??qt,d=new Bl(e,u,(F,K)=>{if(F.init.kind==="agent"&&F.init.id)t.onSeatClick({id:F.init.id,name:F.init.name,at:K});else if(F.init.kind==="more")t.onMore?.()}),h=Tu(e,()=>s),p=new ta,v=new ln(42,1,0.1,90),T=new ua,m=new ha;m.position.set(-6,12,7),p.add(T,m);let{theme:f,scheme:E}=t,C=[],y=new Map,b=new Map,w,A=0,_=new Map,M=()=>`${f}/${E}`,B,R=null,U=0,W=kn(0,1),P=W,H=W,j=0,G=0,re=!1,q,te=!1,ee=()=>w?.slots??yi(C.length),me=()=>ee().count,we=(F)=>{let K=w?.slotOf.get(F);return K===void 0?void 0:Vt(K,me())},He=()=>{let F=R?we(R):void 0;return F===void 0?kn(U,me(),v.aspect,c.clientWidth||void 0):as(F,me())},Fe=()=>{let{position:F,target:K}=lr(W);v.position.set(...F),v.lookAt(K[0],K[1],K[2]),v.rotateZ(W.roll);let ce=cr(W.fov,v.aspect);if(Math.abs(v.fov-ce)>0.001)v.fov=ce,v.updateProjectionMatrix()},Y=(F,K,ce=!1)=>{let ye=us(W,F,s||K,ce);if(re=ye.dive===!0,ye.cut)W=F,G=0;else P=W,H=F,j=performance.now(),G=ye.ms;return I.wake(),ye},se=()=>{if(!w)return;p.remove(w.group);for(let F of w.podiums)F.dispose();w.kit.dispose(),w.built.dispose(),w.toon.dispose(),w=void 0},ae=async(F,K)=>{let ce=b.get(F),ye=w;if(!ce||!ye)return;let Ee=ye.slotOf.get(F),Ve=Ee===void 0?void 0:ye.podiums[Ee];if(Ve?.init.kind!=="agent")return;try{let rt=await uu(ce,320,{rim:ye.hall.paper,ink:ye.hall.ink,edge:ya(C.find((at)=>at.id===F)?.color??ye.hall.gold,ye.hall.ink,0.35)});if(K!==A||w!==ye)return;_.set(F,{svg:ce,tone:M(),canvas:rt.canvas}),Ve.setSticker(rt.canvas),I.wake()}catch{}},Re=(F,K)=>{F.setBadge(bu(K))},Ie=(F)=>{let K=++A;se();let ce=wn(f,E),ye=yi(C.length),Ee=new Ol;Ee.setInk(ce.ink);let Ve=new zl(ce),rt=pu(ce,ye.count,Ee),at=new Yt;at.add(rt.group);let Je=new Map,Pn=[],bn=[],Ln=(mt,ot,Xn=0)=>{let Xt=ds(mt,ye.count),qn=1+Xn/Pt(ye.count);ot.group.position.set(Xt.x*qn,0.2,Xt.z*qn),ot.group.rotation.y=Xt.yaw,bn[mt]=ot,at.add(ot.group)};if(Ln(0,new xr({id:void 0,name:t.ownerName??"You",kind:"owner",accent:ce.gold},Ve,Ee),1.2),C.slice(0,ye.seated).forEach((mt,ot)=>{let Xn=ot+1;Je.set(mt.id,Xn),Pn.push(mt.id);let Xt=new xr({id:mt.id,name:mt.name,kind:"agent",accent:mt.color},Ve,Ee);Xt.setDim(mt.dim===!0),Re(Xt,y.get(mt.id)??mt.state??"idle"),Ln(Xn,Xt);let qn=_.get(mt.id);if(qn&&qn.svg===b.get(mt.id)&&qn.tone===M())Xt.setSticker(qn.canvas)}),ye.more>0)Ln(ye.count-1,new xr({id:void 0,name:`+${ye.more}`,kind:"more",accent:ce.gold},Ve,Ee));if(w={hall:ce,toon:Ee,kit:Ve,built:rt,group:at,slots:ye,podiums:bn,slotOf:Je,order:Pn},F&&B){let mt=new Set;for(let ot of bn){let Xn={x:ot.group.position.x,z:ot.group.position.z,yaw:ot.group.rotation.y},Xt=F.from.get(Au(ot));if(Xt)B.slides.push({podium:ot,from:Xt,to:Xn}),ot.group.position.x=Xt.x,ot.group.position.z=Xt.z,ot.group.rotation.y=Xt.yaw;if(ot.init.id&&F.joining.has(ot.init.id))ot.group.visible=!1,ot.labelHidden=!0,mt.add(ot)}B.risers=[...mt]}p.add(at),at.updateMatrixWorld(!0),p.background=new We(ce.bg),p.fog=new tr(ce.bg,17,46),T.color.set(ce.ambient),T.intensity=ce.ambientI,m.color.set(ce.key),m.intensity=ce.keyI;for(let mt of C.slice(0,ye.seated)){let ot=_.get(mt.id);if(ot&&ot.svg===b.get(mt.id)&&ot.tone===M())continue;ae(mt.id,K)}if(R&&!Je.has(R))R=null;Y(He(),F===void 0),d.paint(ce),d.set(bn,(mt)=>y.get(mt.init.id??"")??"idle"),I.wake()},De=(F)=>F.slice(0,yi(F.length).seated).map((K)=>K.id),Rt=()=>{let F=new Map;for(let K of w?.podiums??[])F.set(Au(K),{x:K.group.position.x,z:K.group.position.z,yaw:K.group.rotation.y});return F},Ye=(F)=>{F.swapped=!0;let K=Rt();C=F.next,F.slides=[],Ie({from:K,joining:new Set(F.plan.joining)});for(let ce of F.risers)F.fx?.circle({x:ce.group.position.x,y:kl,z:ce.group.position.z},F.plan.riseAt)},Ze=(F)=>{for(let K of F.timers)clearTimeout(K);for(let K of F.slides)K.podium.group.position.x=K.to.x,K.podium.group.position.z=K.to.z,K.podium.group.rotation.y=K.to.yaw;for(let K of F.risers)K.group.visible=!0,K.group.position.y=kl,K.labelHidden=!1;if(F.fx?.dispose(),c.style.transition="",c.style.opacity="",d.root.style.transition="",d.root.style.opacity="",B===F)B=void 0;I.wake()},st=()=>{let F=B;if(!F)return;if(!F.swapped)F.swapped=!0,C=F.next,Ie();Ze(F)},Qe=(F,K)=>{let ce={plan:K,start:performance.now(),next:F,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(B=ce,K.mode==="fade"){for(let Ve of[c,d.root])Ve.style.transition=`opacity ${Qt}ms linear`,Ve.style.opacity="0";ce.timers.push(setTimeout(()=>{ce.swapped=!0,C=F,Ie();for(let Ve of[c,d.root])Ve.style.opacity="1"},Qt),setTimeout(()=>Ze(ce),Qt*2));return}let ye=w;if(!ye)return;let Ee=new Fl(ye.hall);ce.fx=Ee,p.add(Ee.group);for(let Ve of K.leaving){let rt=ye.slotOf.get(Ve),at=rt===void 0?void 0:ye.podiums[rt];if(!at)continue;ce.leavers.push(at),Ee.puff({x:at.group.position.x,y:M0,z:at.group.position.z},0)}if(K.swapAt===0)Ye(ce);I.wake()},Ot=(F)=>{let K=B;if(!K||K.plan.mode!=="play")return K!==void 0;let ce=Math.max(0,F-K.start);if(!K.swapped){let Ee=gs(ce);for(let Ve of K.leavers)if(Ve.group.scale.set(Ee.scaleX,Ee.scaleY,Ee.scaleX),Ee.gone)Ve.group.visible=!1;if(ce>=K.plan.swapAt)Ye(K)}if(K.swapped){let Ee=Os(ce-K.plan.swapAt);for(let{podium:rt,from:at,to:Je}of K.slides)rt.group.position.x=at.x+(Je.x-at.x)*Ee,rt.group.position.z=at.z+(Je.z-at.z)*Ee,rt.group.rotation.y=ys(at.yaw,Je.yaw,Ee);let Ve=xi(ce-K.plan.riseAt);for(let rt of K.risers)rt.group.visible=Ve.shown,rt.group.position.y=kl-Ve.depth*ms,rt.labelHidden=!Ve.named}let ye=K.fx?.step(ce)??!1;if(ce>=K.plan.total&&!ye)return Ze(K),!1;return!0},dt,Lt=new O,bt=0,wt=0,L=0,kt=0,et=0,xt=0,S=performance.now(),I=gu({frame:(F,K)=>{let ce=performance.now();bt+=K/1000;let ye=!1;if(Ot(F))ye=!0;if(G>0){let rt=(F-j)/G;if(rt>=1)W=H,G=0;else W=ls(P,H,re?cs(rt):bi(rt)),ye=!0}else if(q)ye=!0;Fe(),v.getWorldPosition(Lt);let Ee=w;if(Ee){let rt=R===null?void 0:Ee.slotOf.get(R);for(let Je of Ee.podiums)Je.group.updateMatrixWorld(!0);let at=d.place(v,Lt,e.clientWidth,e.clientHeight,rt===void 0?void 0:Ee.podiums[rt]);if(R===null&&at!==dt)dt=at,t.onNames?.(at);mu(Ee.built.flames,bt,s);for(let Je of Ee.built.flames)Je.body.lookAt(Lt.x,Je.body.position.y,Lt.z);for(let Je of Ee.podiums){if(Je.init.kind!=="agent")continue;let Pn=y.get(Je.init.id??"")??"idle",bn=Pn==="speaking"?1:0,Ln=Pn==="thinking"||Pn==="working"?1:0,mt=Je.speak;Je.speak=s?bn:Eu(Je.speak,bn,7,K/1000),Je.bob=s?0:Eu(Je.bob,Ln,5,K/1000);let ot=Je.speak>0.02;if(Je.glow.visible=ot&&Je.board.visible,Je.glowMaterial.opacity=0.85*Je.speak,Je.board.position.y=Je.boardY+Math.sin(bt*3.1+Je.phase)*0.035*Je.bob,Je.face(Lt),Je.markFrame(Pn==="speaking",bt,s))ye=!0;if(Math.abs(Je.speak-bn)>0.01||Math.abs(mt-Je.speak)>0.001||Je.bob>0.02)ye=!0}}l.render(p,v),L+=1,wt+=1;let Ve=performance.now()-ce;if(kt+=Ve,et=Math.max(et,Ve),F-S>=1000)xt=wt*1000/(F-S),V={...V,fps:xt,frameMs:kt/Math.max(wt,1),frameMsMax:et},wt=0,kt=0,et=0,S=F;return ye},host:{request:(F)=>requestAnimationFrame(F),cancel:(F)=>cancelAnimationFrame(F),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),V={kind:"webgl",fps:0,frameMs:0,frameMsMax:0,drawCalls:0,triangles:0,textures:0,geometries:0,dpr:l.getPixelRatio(),lowPower:a,reduced:s,loop:"idle",seats:0,renders:0},ie=()=>{let{clientWidth:F,clientHeight:K}=e;if(F<=0||K<=0)return;if(l.setSize(F,K,!1),v.aspect=F/K,v.updateProjectionMatrix(),R===null&&!q&&w)if(G===0)W=He();else H=He();d.size(F),I.wake()},le=new ResizeObserver(ie);le.observe(e);let de=new IntersectionObserver((F)=>{for(let K of F)I.setVisible(K.isIntersecting)});de.observe(e);let Z=()=>I.sync();document.addEventListener("visibilitychange",Z);let Q=(F)=>{F.preventDefault(),n?.()};c.addEventListener("webglcontextlost",Q);let fe=(F,K,ce)=>{let ye=F!==null&&w?.slotOf.has(F)?F:null;if(ye===R)return;let Ee=ye!==null&&R===null;R=ye;let Ve=Y(He(),K,Ee);if(ye!==null&&te&&!Ve.cut)h.play();if(ce)t.onFocus?.(ye)},Pe=new ze,pe=new da,oe=(F,K)=>{let ce=w;if(!ce)return;let ye=c.getBoundingClientRect();return Pe.set((F-ye.left)/ye.width*2-1,-((K-ye.top)/ye.height)*2+1),pe.setFromCamera(Pe,v),pe.intersectObjects(ce.podiums.filter((Ve)=>Ve.group.visible).flatMap((Ve)=>Ve.hits).filter((Ve)=>Ve.visible),!1)[0]?.object.userData},Te=new Map,Le,$e=0,N=!1,he=()=>{let[F,K]=[...Te.values()];return F&&K?Math.hypot(F.x-K.x,F.y-K.y):0},J=(F)=>{if(Te.set(F.pointerId,{x:F.clientX,y:F.clientY}),Te.size===2){$e=he(),N=!1,Le=void 0,q=void 0;return}let K=c.getBoundingClientRect(),ce=!hs(F.clientX,F.clientY,K,{width:innerWidth,height:innerHeight});if(Le={x:F.clientX,y:F.clientY,az:U,ok:ce,at:performance.now(),hold:F.pointerType!=="mouse"&&t.onSeatMenu!==void 0},ce)c.setPointerCapture?.(F.pointerId);c.style.cursor="grabbing"},ue=(F)=>{if(Te.has(F.pointerId))Te.set(F.pointerId,{x:F.clientX,y:F.clientY});if(Te.size===2&&$e>0&&!N){let ye=he()/$e,Ee=ye>y0?"in":ye<S0?"out":"none";if(Ee!=="none")N=!0,Be(Ee==="in"?-1:1);return}if(!Le){if(F.buttons===0)c.style.cursor=oe(F.clientX,F.clientY)?"pointer":"grab";return}if(!Le.ok||R!==null)return;let K=F.clientX-Le.x;if(Math.abs(K)<wu&&!q)return;let ce=Le.az+fs(K,c.clientWidth);q={az:ce},W=kn(ce,me(),v.aspect,c.clientWidth||void 0),G=0,I.wake()},Se=(F)=>{if(Te.delete(F.pointerId),Te.size<2)$e=0;c.style.cursor="grab";let K=Le;if(Le=void 0,!K||N){if(Te.size===0)N=!1;return}let ce=F.clientX-K.x,ye=F.clientY-K.y;if(q){U=ar(q.az,me()),q=void 0,Y(kn(U,me(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ce,ye)<wu){if(K.hold&&performance.now()-K.at>=gr)return;let Ee=oe(F.clientX,F.clientY);if(!Ee)return;if(Ee.kind==="agent"&&Ee.seat){let Ve=C.find((rt)=>rt.id===Ee.seat);if(Ve)t.onSeatClick({id:Ve.id,name:Ve.name,at:{x:F.clientX,y:F.clientY}})}else if(Ee.kind==="more")t.onMore?.();else if(Ee.kind==="owner"&&R!==null)fe(null,!1,!0);return}if(K.ok&&R!==null&&Math.abs(ce)>=v0&&Math.abs(ce)>Math.abs(ye))ge(ce<0?1:-1)},ne=(F)=>{if(Te.delete(F.pointerId),Le=void 0,q)U=ar(q.az,me()),q=void 0,Y(kn(U,me(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ge=(F)=>{let K=w;if(!K||R===null||K.order.length<2)return;let ce=K.order.indexOf(R),ye=K.order[(ce+F+K.order.length)%K.order.length];if(ye)fe(ye,!1,!0)},Be=(F)=>{let K=w;if(!K)return;let ce=ps(F,R!==null);if(ce==="in"){let ye=ss(U,K.slots),Ee=ye===void 0?void 0:K.order[ye-1];if(Ee)fe(Ee,!1,!0)}else if(ce==="out")fe(null,!1,!0)},ct=0,nt=(F)=>{F.preventDefault();let K=performance.now();if(K-ct<450||Math.abs(F.deltaY)<4)return;ct=K,Be(F.deltaY)};c.addEventListener("pointerdown",J),c.addEventListener("pointermove",ue),c.addEventListener("pointerup",Se),c.addEventListener("pointercancel",ne),c.addEventListener("wheel",nt,{passive:!1});let _n=(F)=>F.length===C.length&&F.every((K,ce)=>K.id===C[ce]?.id&&K.name===C[ce]?.name&&K.color===C[ce]?.color);C=t.seats.map((F)=>({...F}));for(let F of C){if(F.state)y.set(F.id,F.state);if(F.avatarSvg)b.set(F.id,F.avatarSvg)}if(t.focus&&C.some((F)=>F.id===t.focus))R=t.focus;return Ie(),W=He(),ie(),te=!0,{kind:"webgl",setTheme(F,K){if(F===f&&K===E)return;st(),f=F,E=K,Ie()},setSeats(F){st();let K=!_n(F),ce=F.map((Ee)=>({...Ee})),ye=K&&te&&w?Kn(De(C),De(ce),s):void 0;for(let Ee of ce){if(Ee.state)y.set(Ee.id,Ee.state);if(Ee.avatarSvg&&Ee.avatarSvg!==b.get(Ee.id))b.set(Ee.id,Ee.avatarSvg)}if(ye&&ye.mode!=="cut"){Qe(ce,ye);return}if(C=ce,K)Ie();else{let Ee=w;for(let Ve of C){let rt=Ee?.slotOf.get(Ve.id);(rt===void 0?void 0:Ee?.podiums[rt])?.setDim(Ve.dim===!0),ae(Ve.id,A)}}I.wake()},setState(F,K){y.set(F,K);let ce=w?.slotOf.get(F),ye=ce===void 0?void 0:w?.podiums[ce];if(ye)Re(ye,K),d.relabel(ye,K);I.wake()},async setAvatar(F,K){b.set(F,K),await ae(F,A)},setReducedMotion(F){if(s=F,V.reduced=F,F)Y(He(),!0);I.wake()},resetCamera(){U=0,fe(null,!1,!0),Y(He(),!1)},focus(F,K){fe(F,K?.cut===!0,!1)},focused:()=>R,seatAt(F,K){let ce=oe(F,K);return ce?.kind==="agent"?ce.seat:null},getStats(){let F=l.info;return{...V,drawCalls:F.render.calls,triangles:F.render.triangles,textures:F.memory.textures,geometries:F.memory.geometries,loop:I.state,seats:C.length,renders:L,reduced:s}},dispose(){if(B){for(let F of B.timers)clearTimeout(F);B.fx?.dispose(),B=void 0}I.dispose(),le.disconnect(),de.disconnect(),document.removeEventListener("visibilitychange",Z),c.removeEventListener("webglcontextlost",Q),c.removeEventListener("pointerdown",J),c.removeEventListener("pointermove",ue),c.removeEventListener("pointerup",Se),c.removeEventListener("pointercancel",ne),c.removeEventListener("wheel",nt),h.dispose(),d.dispose(),se(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{aS as createTable3D};
|
|
4220
|
+
}`;class Qh{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Xr(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Sn({vertexShader:Jg,fragmentShader:$g,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ge(new At(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class jh extends ti{constructor(e,t){super();let n=this,i=null,s=1,r=null,a="local-floor",o=1,l=null,c=null,u=null,d=null,h=null,p=null,v=typeof XRWebGLBinding<"u",T=new Qh,m={},f=t.getContextAttributes(),E=null,C=null,y=[],b=[],w=new ze,A=null,_=null,M=new ln;M.viewport=new wt;let B=new ln;B.viewport=new wt;let R=[M,B],U=new pl,W=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let se=y[Y];if(se===void 0)se=new zs,y[Y]=se;return se.getTargetRaySpace()},this.getControllerGrip=function(Y){let se=y[Y];if(se===void 0)se=new zs,y[Y]=se;return se.getGripSpace()},this.getHand=function(Y){let se=y[Y];if(se===void 0)se=new zs,y[Y]=se;return se.getHandSpace()};function H(Y){let se=b.indexOf(Y.inputSource);if(se===-1)return;let ae=y[se];if(ae!==void 0)ae.update(Y.inputSource,Y.frame,l||r),ae.dispatchEvent({type:Y.type,data:Y.inputSource})}function j(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",j),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<y.length;Y++){let se=b[Y];if(se===null)continue;b[Y]=null,y[Y].disconnect(se)}W=null,P=null,T.reset();for(let Y in m)delete m[Y];if(e.setRenderTarget(E),h=null,d=null,u=null,i=null,C=null,Fe.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(w.width,w.height,!1),_!==null){let Y=_.camera;Y.fov=_.fov,Y.zoom=_.zoom,Y.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){if(s=Y,n.isPresenting===!0)Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){if(a=Y,n.isPresenting===!0)Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&v)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",j),i.addEventListener("inputsourceschange",G),f.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(w),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let ae={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,t,ae),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new pn(h.framebufferWidth,h.framebufferHeight,{format:kn,type:fn,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let ae=null,Re=null,Ie=null;if(f.depth)Ie=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=f.stencil?Li:Pi,Re=f.stencil?gs:mi;let De={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(De),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),C=new pn(d.textureWidth,d.textureHeight,{format:kn,type:fn,depthTexture:new Fi(d.textureWidth,d.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await i.requestReferenceSpace(a),Fe.setContext(i),Fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function G(Y){for(let se=0;se<Y.removed.length;se++){let ae=Y.removed[se],Re=b.indexOf(ae);if(Re>=0)b[Re]=null,y[Re].disconnect(ae)}for(let se=0;se<Y.added.length;se++){let ae=Y.added[se],Re=b.indexOf(ae);if(Re===-1){for(let De=0;De<y.length;De++)if(De>=b.length){b.push(ae),Re=De;break}else if(b[De]===null){b[De]=ae,Re=De;break}if(Re===-1)break}let Ie=y[Re];if(Ie)Ie.connect(ae)}}let re=new O,q=new O;function te(Y,se,ae){re.setFromMatrixPosition(se.matrixWorld),q.setFromMatrixPosition(ae.matrixWorld);let Re=re.distanceTo(q),Ie=se.projectionMatrix.elements,De=ae.projectionMatrix.elements,Pt=Ie[14]/(Ie[10]-1),Ye=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],st=(Ie[9]-1)/Ie[5],Qe=(Ie[8]-1)/Ie[0],zt=(De[8]+1)/De[0],ut=Pt*Qe,Nt=Pt*zt,bt=Re/(-Qe+zt),Tt=bt*-Qe;if(se.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Tt),Y.translateZ(bt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ie[10]===-1)Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{let L=Pt+bt,Vt=Ye+bt,et=ut-Tt,xt=Nt+(Re-Tt),S=Ze*Ye/Vt*L,g=st*Ye/Vt*L;Y.projectionMatrix.makePerspective(et,xt,S,g,L,Vt),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ee(Y,se){if(se===null)Y.matrixWorld.copy(Y.matrix);else Y.matrixWorld.multiplyMatrices(se.matrixWorld,Y.matrix);Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let{near:se,far:ae}=Y;if(T.texture!==null){if(T.depthNear>0)se=T.depthNear;if(T.depthFar>0)ae=T.depthFar}if(U.near=B.near=M.near=se,U.far=B.far=M.far=ae,W!==U.near||P!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,P=U.far;U.layers.mask=Y.layers.mask|6,M.layers.mask=U.layers.mask&-5,B.layers.mask=U.layers.mask&-3;let Re=Y.parent,Ie=U.cameras;ee(U,Re);for(let De=0;De<Ie.length;De++)ee(Ie[De],Re);if(Ie.length===2)te(U,M,B);else U.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Y.isPerspectiveCamera)_={camera:Y,fov:Y.fov,zoom:Y.zoom};me(Y,U,Re)};function me(Y,se,ae){if(ae===null)Y.matrix.copy(se.matrixWorld);else Y.matrix.copy(ae.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(se.matrixWorld);if(Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse),Y.isPerspectiveCamera)Y.fov=Er*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(Y){if(o=Y,d!==null)d.fixedFoveation=Y;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Y},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)},this.getCameraTexture=function(Y){return m[Y]};let we=null;function He(Y,se){if(c=se.getViewerPose(l||r),p=se,c!==null){let ae=c.views;if(h!==null)e.setRenderTargetFramebuffer(C,h.framebuffer),e.setRenderTarget(C);let Re=!1;if(ae.length!==U.cameras.length)U.cameras.length=0,Re=!0;for(let Ye=0;Ye<ae.length;Ye++){let Ze=ae[Ye],st=null;if(h!==null)st=h.getViewport(Ze);else{let zt=u.getViewSubImage(d,Ze);if(st=zt.viewport,Ye===0)e.setRenderTargetTextures(C,zt.colorTexture,zt.depthStencilTexture),e.setRenderTarget(C)}let Qe=R[Ye];if(Qe===void 0)Qe=new ln,Qe.layers.enable(Ye),Qe.viewport=new wt,R[Ye]=Qe;if(Qe.matrix.fromArray(Ze.transform.matrix),Qe.matrix.decompose(Qe.position,Qe.quaternion,Qe.scale),Qe.projectionMatrix.fromArray(Ze.projectionMatrix),Qe.projectionMatrixInverse.copy(Qe.projectionMatrix).invert(),Qe.viewport.set(st.x,st.y,st.width,st.height),Ye===0)U.matrix.copy(Qe.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Re===!0)U.cameras.push(Qe)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let Ye=u.getDepthInformation(ae[0]);if(Ye&&Ye.isValid&&Ye.texture)T.init(Ye,i.renderState)}if(Ie&&Ie.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let Ye=0;Ye<ae.length;Ye++){let Ze=ae[Ye].camera;if(Ze){let st=m[Ze];if(!st)st=new Xr,m[Ze]=st;let Qe=u.getCameraImage(Ze);st.sourceTexture=Qe}}}}for(let ae=0;ae<y.length;ae++){let Re=b[ae],Ie=y[ae];if(Re!==null&&Ie!==void 0)Ie.update(Re,se,l||r)}if(we)we(Y,se);if(se.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:se});p=null}let Fe=new Gh;Fe.setAnimationLoop(He),this.setAnimationLoop=function(Y){we=Y},this.dispose=function(){}}}var Kg=new yt,eu=new ke;eu.set(-1,0,0,0,1,0,0,0,1);function Qg(e,t){function n(m,f){if(m.matrixAutoUpdate===!0)m.updateMatrix();f.value.copy(m.matrix)}function i(m,f){if(f.color.getRGB(m.fogColor.value,Ko(e)),f.isFog)m.fogNear.value=f.near,m.fogFar.value=f.far;else if(f.isFogExp2)m.fogDensity.value=f.density}function s(m,f,E,C,y){if(f.isNodeMaterial)f.uniformsNeedUpdate=!1;else if(f.isMeshBasicMaterial)r(m,f);else if(f.isMeshLambertMaterial){if(r(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshToonMaterial)r(m,f),d(m,f);else if(f.isMeshPhongMaterial){if(r(m,f),u(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshStandardMaterial){if(r(m,f),h(m,f),f.isMeshPhysicalMaterial)p(m,f,y)}else if(f.isMeshMatcapMaterial)r(m,f),v(m,f);else if(f.isMeshDepthMaterial)r(m,f);else if(f.isMeshDistanceMaterial)r(m,f),T(m,f);else if(f.isMeshNormalMaterial)r(m,f);else if(f.isLineBasicMaterial){if(a(m,f),f.isLineDashedMaterial)o(m,f)}else if(f.isPointsMaterial)l(m,f,E,C);else if(f.isSpriteMaterial)c(m,f);else if(f.isShadowMaterial)m.color.value.copy(f.color),m.opacity.value=f.opacity;else if(f.isShaderMaterial)f.uniformsNeedUpdate=!1}function r(m,f){if(m.opacity.value=f.opacity,f.color)m.diffuse.value.copy(f.color);if(f.emissive)m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity);if(f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.bumpMap){if(m.bumpMap.value=f.bumpMap,n(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===qt)m.bumpScale.value*=-1}if(f.normalMap){if(m.normalMap.value=f.normalMap,n(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===qt)m.normalScale.value.negate()}if(f.displacementMap)m.displacementMap.value=f.displacementMap,n(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias;if(f.emissiveMap)m.emissiveMap.value=f.emissiveMap,n(f.emissiveMap,m.emissiveMapTransform);if(f.specularMap)m.specularMap.value=f.specularMap,n(f.specularMap,m.specularMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest;let E=t.get(f),{envMap:C,envMapRotation:y}=E;if(C){if(m.envMap.value=C,m.envMapRotation.value.setFromMatrix4(Kg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(eu);m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio}if(f.lightMap)m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,n(f.lightMap,m.lightMapTransform);if(f.aoMap)m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,n(f.aoMap,m.aoMapTransform)}function a(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map)m.map.value=f.map,n(f.map,m.mapTransform)}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,E,C){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*E,m.scale.value=C*0.5,f.map)m.map.value=f.map,n(f.map,m.uvTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function c(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,0.0001)}function d(m,f){if(f.gradientMap)m.gradientMap.value=f.gradientMap}function h(m,f){if(m.metalness.value=f.metalness,f.metalnessMap)m.metalnessMap.value=f.metalnessMap,n(f.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=f.roughness,f.roughnessMap)m.roughnessMap.value=f.roughnessMap,n(f.roughnessMap,m.roughnessMapTransform);if(f.envMap)m.envMapIntensity.value=f.envMapIntensity}function p(m,f,E){if(m.ior.value=f.ior,f.sheen>0){if(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap)m.sheenColorMap.value=f.sheenColorMap,n(f.sheenColorMap,m.sheenColorMapTransform);if(f.sheenRoughnessMap)m.sheenRoughnessMap.value=f.sheenRoughnessMap,n(f.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(f.clearcoat>0){if(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap)m.clearcoatMap.value=f.clearcoatMap,n(f.clearcoatMap,m.clearcoatMapTransform);if(f.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,n(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(f.clearcoatNormalMap){if(m.clearcoatNormalMap.value=f.clearcoatNormalMap,n(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===qt)m.clearcoatNormalScale.value.negate()}}if(f.dispersion>0)m.dispersion.value=f.dispersion;if(f.retroreflectivity>0)m.retroreflectivity.value=f.retroreflectivity;if(f.iridescence>0){if(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap)m.iridescenceMap.value=f.iridescenceMap,n(f.iridescenceMap,m.iridescenceMapTransform);if(f.iridescenceThicknessMap)m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,n(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(f.transmission>0){if(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=E.texture,m.transmissionSamplerSize.value.set(E.width,E.height),f.transmissionMap)m.transmissionMap.value=f.transmissionMap,n(f.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=f.thickness,f.thicknessMap)m.thicknessMap.value=f.thicknessMap,n(f.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)}if(f.anisotropy>0){if(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap)m.anisotropyMap.value=f.anisotropyMap,n(f.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap)m.specularColorMap.value=f.specularColorMap,n(f.specularColorMap,m.specularColorMapTransform);if(f.specularIntensityMap)m.specularIntensityMap.value=f.specularIntensityMap,n(f.specularIntensityMap,m.specularIntensityMapTransform)}function v(m,f){if(f.matcap)m.matcap.value=f.matcap}function T(m,f){let E=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function jg(e,t,n,i){let s={},r={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,b){let w=b.program;i.uniformBlockBinding(y,w)}function c(y,b){let w=s[y.id];if(w===void 0)m(y),w=u(y),s[y.id]=w,y.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(y,A);let _=t.render.frame;if(r[y.id]!==_)h(y),r[y.id]=_}function u(y){let b=d();y.__bindingPointIndex=b;let w=e.createBuffer(),{__size:A,usage:_}=y;return e.bindBuffer(e.UNIFORM_BUFFER,w),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,w),w}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let b=s[y.id],{uniforms:w,__cache:A}=y;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=w.length;_<M;_++){let B=w[_];if(Array.isArray(B))for(let R=0,U=B.length;R<U;R++)p(B[R],_,R,A);else p(B,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(y,b,w,A){if(T(y,b,w,A)===!0){let{__offset:_,value:M}=y;if(Array.isArray(M)){let B=0;for(let R=0;R<M.length;R++){let U=M[R],W=f(U);if(v(U,y.__data,B),typeof U!=="number"&&typeof U!=="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U))B+=W.storage/Float32Array.BYTES_PER_ELEMENT}}else v(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,y.__data)}}function v(y,b,w){if(typeof y==="number"||typeof y==="boolean")b[0]=y;else if(y.isMatrix3)b[0]=y.elements[0],b[1]=y.elements[1],b[2]=y.elements[2],b[3]=0,b[4]=y.elements[3],b[5]=y.elements[4],b[6]=y.elements[5],b[7]=0,b[8]=y.elements[6],b[9]=y.elements[7],b[10]=y.elements[8],b[11]=0;else if(ArrayBuffer.isView(y))b.set(new y.constructor(y.buffer,y.byteOffset,b.length));else y.toArray(b,w)}function T(y,b,w,A){let _=y.value,M=b+"_"+w;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let B=A[M];if(typeof _==="number"||typeof _==="boolean"){if(B!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(B.equals(_)===!1)return B.copy(_),!0}return!1}function m(y){let b=y.uniforms,w=0,A=16;for(let M=0,B=b.length;M<B;M++){let R=Array.isArray(b[M])?b[M]:[b[M]];for(let U=0,W=R.length;U<W;U++){let P=R[U],H=Array.isArray(P.value)?P.value:[P.value];for(let j=0,G=H.length;j<G;j++){let re=H[j],q=f(re),te=w%A,ee=te%q.boundary,me=te+ee;if(w+=ee,me!==0&&A-me<q.storage)w+=A-me;P.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=w,w+=q.storage}}}let _=w%A;if(_>0)w+=A-_;return y.__size=w,y.__cache={},this}function f(y){let b={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")b.boundary=4,b.storage=4;else if(y.isVector2)b.boundary=8,b.storage=8;else if(y.isVector3||y.isColor)b.boundary=16,b.storage=12;else if(y.isVector4)b.boundary=16,b.storage=16;else if(y.isMatrix3)b.boundary=48,b.storage=48;else if(y.isMatrix4)b.boundary=64,b.storage=64;else if(y.isTexture)Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))b.boundary=16,b.storage=y.byteLength;else Oe("WebGLRenderer: Unsupported uniform value type.",y);return b}function E(y){let b=y.target;b.removeEventListener("dispose",E);let w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function C(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:C}}var e0=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Hn=null;function t0(){if(Hn===null)Hn=new Vs(e0,16,16,Ni,zn),Hn.name="DFG_LUT",Hn.minFilter=en,Hn.magFilter=en,Hn.wrapS=Bn,Hn.wrapT=Bn,Hn.generateMipmaps=!1,Hn.needsUpdate=!0;return Hn}class Rl{constructor(e={}){let{canvas:t=ch(),context:n=null,depth:i=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=fn}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=r;let v=h,T=new Set([Ja,Za,Ya]),m=new Set([fn,mi,Fs,gs,Xa,qa]),f=new Uint32Array(4),E=new Int32Array(4),C=new O,y=null,b=null,w=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Rn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,B=!1,R=null,U=null,W=null,P=null;this._outputColorSpace=gi;let H=0,j=0,G=null,re=-1,q=null,te=new wt,ee=new wt,me=null,we=new We(0),He=0,{width:Fe,height:Y}=t,se=1,ae=null,Re=null,Ie=new wt(0,0,Fe,Y),De=new wt(0,0,Fe,Y),Pt=!1,Ye=new Ws,Ze=!1,st=!1,Qe=new yt,zt=new O,ut=new wt,Nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},bt=!1;function Tt(){return G===null?se:1}let L=n;function Vt(x,D){return t.getContext(x,D)}let et,xt,S,g,I,V,ie,le,de,Z,Q,fe,Pe,pe,oe,Te,Le,$e,N,he,J,ue,Se;try{let x={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${pc}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",nt,!1),L===null){if(L=Vt("webgl2",x),L===null)if(Vt("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(x){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Ue("WebGLRenderer: "+x.message),x}function ne(){if(et=new lm(L),et.init(),J=new Zg(L,et),xt=new Qp(L,et,e,J),S=new qg(L,et),xt.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);U=L.createFramebuffer(),W=L.createFramebuffer(),P=L.createFramebuffer(),g=new um(L),I=new Lg,V=new Yg(L,et,S,I,xt,J,g),ie=new om(M),le=new dd(L),ue=new $p(L,le),de=new cm(L,le,g,ue),Z=new fm(L,de,le,ue,g),$e=new dm(L,xt,V),oe=new jp(I),Q=new Pg(M,ie,et,xt,ue,oe),fe=new Qg(M,I),Pe=new Dg,pe=new kg(et),Le=new Jp(M,ie,S,Z,p,o),Te=new Xg(M,Z,xt),Se=new jg(L,g,xt,S),N=new Kp(L,et,g),he=new hm(L,et,g),g.programs=Q.programs,M.capabilities=xt,M.extensions=et,M.properties=I,M.renderLists=Pe,M.shadowMap=Te,M.state=S,M.info=g}if(v!==fn)_=new mm(v,t.width,t.height,a,i,s);let ge=new jh(M,L);this.xr=ge,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let x=et.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=et.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(x){if(x===void 0)return;se=x,this.setSize(Fe,Y,!1)},this.getSize=function(x){return x.set(Fe,Y)},this.setSize=function(x,D,X=!0){if(ge.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Fe=x,Y=D,t.width=Math.floor(x*se),t.height=Math.floor(D*se),X===!0)t.style.width=x+"px",t.style.height=D+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,x,D)},this.getDrawingBufferSize=function(x){return x.set(Fe*se,Y*se).floor()},this.setDrawingBufferSize=function(x,D,X){Fe=x,Y=D,se=X,t.width=Math.floor(x*X),t.height=Math.floor(D*X),this.setViewport(0,0,x,D)},this.setEffects=function(x){if(v===fn){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let D=0;D<x.length;D++)if(x[D].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(te)},this.getViewport=function(x){return x.copy(Ie)},this.setViewport=function(x,D,X,z){if(x.isVector4)Ie.set(x.x,x.y,x.z,x.w);else Ie.set(x,D,X,z);S.viewport(te.copy(Ie).multiplyScalar(se).round())},this.getScissor=function(x){return x.copy(De)},this.setScissor=function(x,D,X,z){if(x.isVector4)De.set(x.x,x.y,x.z,x.w);else De.set(x,D,X,z);S.scissor(ee.copy(De).multiplyScalar(se).round())},this.getScissorTest=function(){return Pt},this.setScissorTest=function(x){S.setScissorTest(Pt=x)},this.setOpaqueSort=function(x){ae=x},this.setTransparentSort=function(x){Re=x},this.getClearColor=function(x){return x.copy(Le.getClearColor())},this.setClearColor=function(){Le.setClearColor(...arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,X=!0){let z=0;if(x){let k=!1;if(G!==null){let ve=G.texture.format;k=T.has(ve)}if(k){let ve=G.texture.type,be=m.has(ve),xe=Le.getClearColor(),Ae=Le.getClearAlpha(),{r:Ne,g:Xe,b:Ke}=xe;if(be)f[0]=Ne,f[1]=Xe,f[2]=Ke,f[3]=Ae,L.clearBufferuiv(L.COLOR,0,f);else E[0]=Ne,E[1]=Xe,E[2]=Ke,E[3]=Ae,L.clearBufferiv(L.COLOR,0,E)}else z|=L.COLOR_BUFFER_BIT}if(D)z|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(X)z|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(z!==0)L.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.setNodesHandler=function(x){x.setRenderer(this),R=x},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Le.dispose(),Pe.dispose(),pe.dispose(),I.dispose(),ie.dispose(),Z.dispose(),ue.dispose(),Se.dispose(),Q.dispose(),ge.dispose(),ge.removeEventListener("sessionstart",Ve),ge.removeEventListener("sessionend",rt),at.stop()};function Be(x){x.preventDefault(),Is("WebGLRenderer: Context Lost."),B=!0}function ct(){Is("WebGLRenderer: Context Restored."),B=!1;let x=g.autoReset,D=Te.enabled,X=Te.autoUpdate,z=Te.needsUpdate,k=Te.type;ne(),g.autoReset=x,Te.enabled=D,Te.autoUpdate=X,Te.needsUpdate=z,Te.type=k}function nt(x){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function _n(x){let D=x.target;D.removeEventListener("dispose",_n),F(D)}function F(x){K(x),I.remove(x)}function K(x){let D=I.get(x).programs;if(D!==void 0){if(D.forEach(function(X){Q.releaseProgram(X)}),x.isShaderMaterial)Q.releaseShaderCache(x)}}this.renderBufferDirect=function(x,D,X,z,k,ve){if(D===null)D=Nt;let be=k.isMesh&&k.matrixWorld.determinantAffine()<0,xe=Cu(x,D,X,z,k);S.setMaterial(z,be);let Ae=X.index,Ne=1;if(z.wireframe===!0){if(Ae=de.getWireframeAttribute(X),Ae===void 0)return;Ne=2}let Xe=X.drawRange,Ke=X.attributes.position,Ce=Xe.start*Ne,lt=(Xe.start+Xe.count)*Ne;if(ve!==null)Ce=Math.max(Ce,ve.start*Ne),lt=Math.min(lt,(ve.start+ve.count)*Ne);if(Ae!==null)Ce=Math.max(Ce,0),lt=Math.min(lt,Ae.count);else if(Ke!==void 0&&Ke!==null)Ce=Math.max(Ce,0),lt=Math.min(lt,Ke.count);let Dt=lt-Ce;if(Dt<0||Dt===1/0)return;ue.setup(k,z,xe,X,Ae);let St,gt=N;if(Ae!==null)St=le.get(Ae),gt=he,gt.setIndex(St);if(k.isMesh)if(z.wireframe===!0)S.setLineWidth(z.wireframeLinewidth*Tt()),gt.setMode(L.LINES);else gt.setMode(L.TRIANGLES);else if(k.isLine){let Kt=z.linewidth;if(Kt===void 0)Kt=1;if(S.setLineWidth(Kt*Tt()),k.isLineSegments)gt.setMode(L.LINES);else if(k.isLineLoop)gt.setMode(L.LINE_LOOP);else gt.setMode(L.LINE_STRIP)}else if(k.isPoints)gt.setMode(L.POINTS);else if(k.isSprite)gt.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(!et.get("WEBGL_multi_draw")){let{_multiDrawStarts:Kt,_multiDrawCounts:Me,_multiDrawCount:nn}=k,it=Ae?le.get(Ae).bytesPerElement:1,xn=I.get(z).currentProgram.getUniforms();for(let Nn=0;Nn<nn;Nn++)xn.setValue(L,"_gl_DrawID",Nn),gt.render(Kt[Nn]/it,Me[Nn])}else gt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else if(k.isInstancedMesh)gt.renderInstances(Ce,Dt,k.count);else if(X.isInstancedBufferGeometry){let Kt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Me=Math.min(X.instanceCount,Kt);gt.renderInstances(Ce,Dt,Me)}else gt.render(Ce,Dt)};function ce(x,D,X,z){if(R!==null&&x.isNodeMaterial)R.setObject(z,x);if(Ze===!0)oe.setState(x,X,!1);if(x.transparent===!0&&x.side===cn&&x.forceSinglePass===!1)x.side=qt,x.needsUpdate=!0,ot(x,D,z),x.side=fs,x.needsUpdate=!0,ot(x,D,z),x.side=cn;else ot(x,D,z)}this.compile=function(x,D,X=null){if(X===null)X=x;if(R!==null)R.renderStart(x,D,X);if(b=pe.get(X),b.init(D),A.push(b),X.traverseVisible(function(k){if(k.isLight&&k.layers.test(D.layers)){if(b.pushLight(k),k.castShadow)b.pushShadow(k)}}),x!==X)x.traverseVisible(function(k){if(k.isLight&&k.layers.test(D.layers)){if(b.pushLight(k),k.castShadow)b.pushShadow(k)}});if(b.setupLights(),R!==null)R.updateLights(b.state.lightsArray);if(st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),Ze===!0)oe.setGlobalState(this.clippingPlanes,D);if(R!==null)Te.render(b.state.shadowsArray,X,D);let z=new Set;if(x.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;let ve=k.material;if(ve)if(Array.isArray(ve))for(let be=0;be<ve.length;be++){let xe=ve[be];ce(xe,X,D,k),z.add(xe)}else ce(ve,X,D,k),z.add(ve)}),b=A.pop(),R!==null)R.renderEnd();return z},this.compileAsync=function(x,D,X=null){let z=this.compile(x,D,X);return new Promise((k)=>{function ve(){if(z.forEach(function(be){let Ae=I.get(be).currentProgram;if(Ae===void 0||Ae.isReady())z.delete(be)}),z.size===0){k(x);return}setTimeout(ve,10)}if(et.get("KHR_parallel_shader_compile")!==null)ve();else setTimeout(ve,10)})};let ye=null;function Ee(x){if(ye)ye(x)}function Ve(){at.stop()}function rt(){at.start()}let at=new Gh;if(at.setAnimationLoop(Ee),typeof self<"u")at.setContext(self);this.setAnimationLoop=function(x){ye=x,ge.setAnimationLoop(x),x===null?at.stop():at.start()},ge.addEventListener("sessionstart",Ve),ge.addEventListener("sessionend",rt),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(R!==null)R.renderStart(x,D);let X=ge.enabled===!0&&ge.isPresenting===!0,z=_!==null&&(G===null||X)&&_.begin(M,G);if(x.matrixWorldAutoUpdate===!0)x.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(ge.enabled===!0&&ge.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(ge.cameraAutoUpdate===!0)ge.updateCamera(D);D=ge.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,G);if(b=pe.get(x,A.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),A.push(b),Qe.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),Ye.setFromProjectionMatrix(Qe,Wo,D.reversedDepth),st=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,st),y=Pe.get(x,w.length),y.init(),w.push(y),ge.enabled===!0&&ge.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)Je(be,D,-1/0,M.sortObjects)}if(Je(x,D,0,M.sortObjects),y.finish(),R!==null)R.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(ae,Re);if(bt=ge.enabled===!1||ge.isPresenting===!1||ge.hasDepthSensing()===!1,bt)Le.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let k=b.state.shadowsArray;if(Te.render(k,x,D),Ze===!0)oe.endShadows();if((z&&_.hasRenderPass())===!1){let be=y.opaque,xe=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Ae=D.cameras;if(xe.length>0)for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne];Tn(be,xe,x,Ke)}if(bt)Le.render(x);for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne];Pn(y,x,Ke,Ke.viewport)}}else{if(xe.length>0)Tn(be,xe,x,D);if(bt)Le.render(x);Pn(y,x,D)}}if(G!==null&&j===0)V.updateMultisampleRenderTarget(G),V.updateRenderTargetMipmap(G);if(z)_.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(ue.resetDefaultState(),re=-1,q=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Ze===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(w.pop(),w.length>0)y=w[w.length-1];else y=null;if(R!==null)R.renderEnd()};function Je(x,D,X,z){if(x.visible===!1)return;if(x.layers.test(D.layers)){if(x.isGroup)X=x.renderOrder;else if(x.isLOD){if(x.autoUpdate===!0)x.update(D)}else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight){if(b.pushLight(x),x.castShadow)b.pushShadow(x)}else if(x.isSprite){if(!x.frustumCulled||x.intersectsFrustum(Ye)){if(z)ut.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Qe);let be=Z.update(x),xe=x.material;if(xe.visible)y.push(x,be,xe,X,ut.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum(Ye)){let be=Z.update(x),xe=x.material;if(z){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();ut.copy(x.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();ut.copy(be.boundingSphere.center)}ut.applyMatrix4(x.matrixWorld).applyMatrix4(Qe)}if(Array.isArray(xe)){let Ae=be.groups;for(let Ne=0,Xe=Ae.length;Ne<Xe;Ne++){let Ke=Ae[Ne],Ce=xe[Ke.materialIndex];if(Ce&&Ce.visible)y.push(x,be,Ce,X,ut.z,Ke,D)}}else if(xe.visible)y.push(x,be,xe,X,ut.z,null,D)}}}let ve=x.children;for(let be=0,xe=ve.length;be<xe;be++)Je(ve[be],D,X,z)}function Pn(x,D,X,z){let{opaque:k,transmissive:ve,transparent:be}=x;if(b.setupLightsView(X),Ze===!0)oe.setGlobalState(M.clippingPlanes,X);if(z)S.viewport(te.copy(z));if(k.length>0)Ln(k,D,X);if(ve.length>0)Ln(ve,D,X);if(be.length>0)Ln(be,D,X);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function Tn(x,D,X,z){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){let Ce=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new pn(1,1,{generateMipmaps:!0,type:Ce?zn:fn,minFilter:Ii,samples:Math.max(4,xt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ve=b.state.transmissionRenderTarget[z.id],be=z.viewport||te;ve.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let xe=M.getRenderTarget(),Ae=M.getActiveCubeFace(),Ne=M.getActiveMipmapLevel();if(M.setRenderTarget(ve),M.getClearColor(we),He=M.getClearAlpha(),He<1)M.setClearColor(16777215,0.5);if(M.clear(),bt)Le.render(X);let Xe=M.toneMapping;M.toneMapping=Rn;let Ke=z.viewport;if(z.viewport!==void 0)z.viewport=void 0;if(b.setupLightsView(z),Ze===!0)oe.setGlobalState(M.clippingPlanes,z);if(Ln(x,X,z),V.updateMultisampleRenderTarget(ve),V.updateRenderTargetMipmap(ve),et.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let lt=0,Dt=D.length;lt<Dt;lt++){let St=D[lt],{object:gt,geometry:Kt,material:Me,group:nn}=St;if(Me.side===cn&>.layers.test(z.layers)){let it=Me.side;Me.side=qt,Me.needsUpdate=!0,pt(gt,X,z,Kt,Me,nn),Me.side=it,Me.needsUpdate=!0,Ce=!0}}if(Ce===!0)V.updateMultisampleRenderTarget(ve),V.updateRenderTargetMipmap(ve)}if(M.setRenderTarget(xe,Ae,Ne),M.setClearColor(we,He),Ke!==void 0)z.viewport=Ke;M.toneMapping=Xe}function Ln(x,D,X){let z=D.isScene===!0?D.overrideMaterial:null;for(let k=0,ve=x.length;k<ve;k++){let be=x[k],{object:xe,geometry:Ae,group:Ne}=be,Xe=be.material;if(Xe.allowOverride===!0&&z!==null)Xe=z;if(xe.layers.test(X.layers))pt(xe,D,X,Ae,Xe,Ne)}}function pt(x,D,X,z,k,ve){if(R!==null&&k.isNodeMaterial)R.setObject(x,k);if(x.onBeforeRender(M,D,X,z,k,ve),x.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),k.onBeforeRender(M,D,X,z,x,ve),k.transparent===!0&&k.side===cn&&k.forceSinglePass===!1)k.side=qt,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,ve),k.side=fs,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,ve),k.side=cn;else M.renderBufferDirect(X,D,z,k,x,ve);x.onAfterRender(M,D,X,z,k,ve)}function ot(x,D,X){if(D.isScene!==!0)D=Nt;let z=I.get(x),k=b.state.lights,ve=b.state.shadowsArray,be=k.state.version,xe=Q.getParameters(x,k.state,ve,D,X,b.state.lightProbeGridArray),Ae=Q.getProgramCacheKey(xe),Ne=z.programs;z.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,z.fog=D.fog;let Xe=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(z.envMap=ie.get(x.envMap||z.environment,Xe),z.envMapRotation=z.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Ne===void 0)x.addEventListener("dispose",_n),Ne=new Map,z.programs=Ne;let Ke=Ne.get(Ae);if(Ke!==void 0){if(z.currentProgram===Ke&&z.lightsStateVersion===be)return Yt(x,xe),Ke}else{if(xe.uniforms=Q.getUniforms(x),R!==null&&x.isNodeMaterial)R.build(x,X,xe);x.onBeforeCompile(xe,M),Ke=Q.acquireProgram(xe,Ae),Ne.set(Ae,Ke),z.uniforms=xe.uniforms}let Ce=z.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Ce.clippingPlanes=oe.uniform;if(Yt(x,xe),z.needsLights=Iu(x),z.lightsStateVersion=be,z.needsLights)Ce.ambientLightColor.value=k.state.ambient,Ce.lightProbe.value=k.state.probe,Ce.sunLights.value=k.state.sun,Ce.sunLightShadows.value=k.state.sunShadow,Ce.directionalLights.value=k.state.directional,Ce.directionalLightShadows.value=k.state.directionalShadow,Ce.spotLights.value=k.state.spot,Ce.spotLightShadows.value=k.state.spotShadow,Ce.rectAreaLights.value=k.state.rectArea,Ce.ltc_1.value=k.state.rectAreaLTC1,Ce.ltc_2.value=k.state.rectAreaLTC2,Ce.pointLights.value=k.state.point,Ce.pointLightShadows.value=k.state.pointShadow,Ce.hemisphereLights.value=k.state.hemi,Ce.sunShadowMatrix.value=k.state.sunShadowMatrix,Ce.sunShadowCascade.value=k.state.sunShadowCascade,Ce.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ce.spotLightMatrix.value=k.state.spotLightMatrix,Ce.spotLightMap.value=k.state.spotLightMap,Ce.pointShadowMatrix.value=k.state.pointShadowMatrix;return z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=Ke,z.uniformsList=null,Ke}function Wn(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=Js.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function Yt(x,D){let X=I.get(x);X.outputColorSpace=D.outputColorSpace,X.batching=D.batching,X.batchingColor=D.batchingColor,X.instancing=D.instancing,X.instancingColor=D.instancingColor,X.instancingMorph=D.instancingMorph,X.skinning=D.skinning,X.morphTargets=D.morphTargets,X.morphNormals=D.morphNormals,X.morphColors=D.morphColors,X.morphTargetsCount=D.morphTargetsCount,X.numClippingPlanes=D.numClippingPlanes,X.numIntersection=D.numClipIntersection,X.vertexAlphas=D.vertexAlphas,X.vertexTangents=D.vertexTangents,X.toneMapping=D.toneMapping}function Xn(x,D){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;C.setFromMatrixPosition(D.matrixWorld);for(let X=0,z=x.length;X<z;X++){let k=x[X];if(k.texture!==null&&k.boundingBox.containsPoint(C))return k}return null}function Cu(x,D,X,z,k){if(D.isScene!==!0)D=Nt;V.resetTextureUnits();let ve=D.fog,be=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?D.environment:null,xe=G===null?M.outputColorSpace:G.isXRRenderTarget===!0?G.texture.colorSpace:je.workingColorSpace,Ae=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Ne=ie.get(z.envMap||be,Ae),Xe=z.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ke=!!X.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Ce=!!X.morphAttributes.position,lt=!!X.morphAttributes.normal,Dt=!!X.morphAttributes.color,St=Rn;if(z.toneMapped){if(G===null||G.isXRRenderTarget===!0)St=M.toneMapping}let gt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Kt=gt!==void 0?gt.length:0,Me=I.get(z),nn=b.state.lights;if(Ze===!0){if(st===!0||x!==q){let vt=x===q&&z.id===re;oe.setState(z,x,vt)}}let it=!1;if(z.version===Me.__version){if(Me.needsLights&&Me.lightsStateVersion!==nn.state.version)it=!0;else if(Me.outputColorSpace!==xe)it=!0;else if(k.isBatchedMesh&&Me.batching===!1)it=!0;else if(!k.isBatchedMesh&&Me.batching===!0)it=!0;else if(k.isBatchedMesh&&Me.batchingColor===!0&&k._colorsTexture===null)it=!0;else if(k.isBatchedMesh&&Me.batchingColor===!1&&k._colorsTexture!==null)it=!0;else if(k.isInstancedMesh&&Me.instancing===!1)it=!0;else if(!k.isInstancedMesh&&Me.instancing===!0)it=!0;else if(k.isSkinnedMesh&&Me.skinning===!1)it=!0;else if(!k.isSkinnedMesh&&Me.skinning===!0)it=!0;else if(k.isInstancedMesh&&Me.instancingColor===!0&&k.instanceColor===null)it=!0;else if(k.isInstancedMesh&&Me.instancingColor===!1&&k.instanceColor!==null)it=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!0&&k.morphTexture===null)it=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!1&&k.morphTexture!==null)it=!0;else if(Me.envMap!==Ne)it=!0;else if(z.fog===!0&&Me.fog!==ve)it=!0;else if(Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==oe.numPlanes||Me.numIntersection!==oe.numIntersection))it=!0;else if(Me.vertexAlphas!==Xe)it=!0;else if(Me.vertexTangents!==Ke)it=!0;else if(Me.morphTargets!==Ce)it=!0;else if(Me.morphNormals!==lt)it=!0;else if(Me.morphColors!==Dt)it=!0;else if(Me.toneMapping!==St)it=!0;else if(Me.morphTargetsCount!==Kt)it=!0;else if(!!Me.lightProbeGrid!==b.state.lightProbeGridArray.length>0)it=!0}else it=!0,Me.__version=z.version;let xn=Me.currentProgram;if(it===!0){if(xn=ot(z,D,k),R&&z.isNodeMaterial)R.onUpdateProgram(z,xn,Me)}let Nn=!1,ri=!1,Wi=!1,dt=xn.getUniforms(),Lt=Me.uniforms;if(S.useProgram(xn.program))Nn=!0,ri=!0,Wi=!0;if(z.id!==re)re=z.id,ri=!0;if(Me.needsLights){let vt=Xn(b.state.lightProbeGridArray,k);if(Me.lightProbeGrid!==vt)Me.lightProbeGrid=vt,ri=!0}if(Nn||q!==x){if(S.buffers.depth.getReversed()&&x.reversedDepth!==!0)x._reversedDepth=!0,x.updateProjectionMatrix();dt.setValue(L,"projectionMatrix",x.projectionMatrix),dt.setValue(L,"viewMatrix",x.matrixWorldInverse);let oi=dt.map.cameraPosition;if(oi!==void 0)oi.setValue(L,zt.setFromMatrixPosition(x.matrixWorld));if(xt.logarithmicDepthBuffer)dt.setValue(L,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2));if(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)dt.setValue(L,"isOrthographic",x.isOrthographicCamera===!0);if(q!==x)q=x,ri=!0,Wi=!0}if(Me.needsLights){if(nn.state.sunShadowMap.length>0)dt.setValue(L,"sunShadowMap",nn.state.sunShadowMap,V);if(nn.state.directionalShadowMap.length>0)dt.setValue(L,"directionalShadowMap",nn.state.directionalShadowMap,V);if(nn.state.spotShadowMap.length>0)dt.setValue(L,"spotShadowMap",nn.state.spotShadowMap,V);if(nn.state.pointShadowMap.length>0)dt.setValue(L,"pointShadowMap",nn.state.pointShadowMap,V)}if(k.isSkinnedMesh){dt.setOptional(L,k,"bindMatrix"),dt.setOptional(L,k,"bindMatrixInverse");let vt=k.skeleton;if(vt){if(vt.boneTexture===null)vt.computeBoneTexture();dt.setValue(L,"boneTexture",vt.boneTexture,V)}}if(k.isBatchedMesh){if(dt.setOptional(L,k,"batchingTexture"),dt.setValue(L,"batchingTexture",k._matricesTexture,V),dt.setOptional(L,k,"batchingIdTexture"),dt.setValue(L,"batchingIdTexture",k._indirectTexture,V),dt.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null)dt.setValue(L,"batchingColorTexture",k._colorsTexture,V)}let ai=X.morphAttributes;if(ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)$e.update(k,X,xn);if(ri||Me.receiveShadow!==k.receiveShadow)Me.receiveShadow=k.receiveShadow,dt.setValue(L,"receiveShadow",k.receiveShadow);if((z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&D.environment!==null)Lt.envMapIntensity.value=D.environmentIntensity;if(Lt.dfgLUT!==void 0)Lt.dfgLUT.value=t0();if(ri){if(dt.setValue(L,"toneMappingExposure",M.toneMappingExposure),Me.needsLights)Ru(Lt,Wi);if(ve&&z.fog===!0)fe.refreshFogUniforms(Lt,ve);if(fe.refreshMaterialUniforms(Lt,z,se,Y,b.state.transmissionRenderTarget[x.id]),Me.needsLights&&Me.lightProbeGrid){let vt=Me.lightProbeGrid;Lt.probesSH.value=vt.texture,Lt.probesMin.value.copy(vt.boundingBox.min),Lt.probesMax.value.copy(vt.boundingBox.max),Lt.probesResolution.value.copy(vt.resolution)}Js.upload(L,Wn(Me),Lt,V)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0)Js.upload(L,Wn(Me),Lt,V),z.uniformsNeedUpdate=!1;if(z.isSpriteMaterial)dt.setValue(L,"center",k.center);if(dt.setValue(L,"modelViewMatrix",k.modelViewMatrix),dt.setValue(L,"normalMatrix",k.normalMatrix),dt.setValue(L,"modelMatrix",k.matrixWorld),z.uniformsGroups!==void 0){let vt=z.uniformsGroups;for(let oi=0,Xi=vt.length;oi<Xi;oi++){let Hl=vt[oi];Se.update(Hl,xn),Se.bind(Hl,xn)}}return xn}function Ru(x,D){x.ambientLightColor.needsUpdate=D,x.lightProbe.needsUpdate=D,x.sunLights.needsUpdate=D,x.sunLightShadows.needsUpdate=D,x.directionalLights.needsUpdate=D,x.directionalLightShadows.needsUpdate=D,x.pointLights.needsUpdate=D,x.pointLightShadows.needsUpdate=D,x.spotLights.needsUpdate=D,x.spotLightShadows.needsUpdate=D,x.rectAreaLights.needsUpdate=D,x.hemisphereLights.needsUpdate=D}function Iu(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return G},this.setRenderTargetTextures=function(x,D,X){let z=I.get(x);if(z.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1)z.__useRenderToTexture=!1;I.get(x.texture).__webglTexture=D,I.get(x.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:X,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let X=I.get(x);X.__webglFramebuffer=D,X.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,X=0){G=x,H=D,j=X;let z=null,k=!1,ve=!1;if(x){let xe=I.get(x);if(xe.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(L.FRAMEBUFFER,xe.__webglFramebuffer),te.copy(x.viewport),ee.copy(x.scissor),me=x.scissorTest,S.viewport(te),S.scissor(ee),S.setScissorTest(me),re=-1;return}else if(xe.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(xe.__hasExternalTextures)V.rebindTextures(x,I.get(x.texture).__webglTexture,I.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let Xe=x.depthTexture;if(xe.__boundDepthTexture!==Xe){if(Xe!==null&&I.has(Xe)&&(x.width!==Xe.image.width||x.height!==Xe.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Ae=x.texture;if(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)ve=!0;let Ne=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Ne[D]))z=Ne[D][X];else z=Ne[D];k=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)z=I.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Ne))z=Ne[X];else z=Ne;te.copy(x.viewport),ee.copy(x.scissor),me=x.scissorTest}else te.copy(Ie).multiplyScalar(se).floor(),ee.copy(De).multiplyScalar(se).floor(),me=Pt;if(X!==0)z=U;if(S.bindFramebuffer(L.FRAMEBUFFER,z))S.drawBuffers(x,z);if(S.viewport(te),S.scissor(ee),S.setScissorTest(me),k){let xe=I.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+D,xe.__webglTexture,X)}else if(ve){let xe=D;for(let Ae=0;Ae<x.textures.length;Ae++){let Ne=I.get(x.textures[Ae]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Ae,Ne.__webglTexture,X,xe)}}else if(x!==null&&X!==0){let xe=I.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,xe.__webglTexture,X)}re=-1};function Gl(x){let D=I.get(x);if(D.__readFormat!==x.format||D.__readType!==x.type)D.__readFormat=x.format,D.__readType=x.type,D.__formatReadable=xt.textureFormatReadable(x.format),D.__typeReadable=xt.textureTypeReadable(x.type);return D}if(this.readRenderTargetPixels=function(x,D,X,z,k,ve,be,xe=0){if(!(x&&x.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ae=Ae[be];if(Ae){S.bindFramebuffer(L.FRAMEBUFFER,Ae);try{let Ne=x.textures[xe],{format:Xe,type:Ke}=Ne;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+xe);let Ce=Gl(Ne);if(Ce.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ce.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k))L.readPixels(D,X,z,k,J.convert(Xe),J.convert(Ke),ve)}finally{let Ne=G!==null?I.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(x,D,X,z,k,ve,be,xe=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ae=I.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ae=Ae[be];if(Ae)if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k)){S.bindFramebuffer(L.FRAMEBUFFER,Ae);let Ne=x.textures[xe],{format:Xe,type:Ke}=Ne;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+xe);let Ce=Gl(Ne);if(Ce.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ce.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let lt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,lt),L.bufferData(L.PIXEL_PACK_BUFFER,ve.byteLength,L.STREAM_READ),L.readPixels(D,X,z,k,J.convert(Xe),J.convert(Ke),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Dt=G!==null?I.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Dt);let St=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await uh(L,St,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,lt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ve),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(lt),L.deleteSync(St),ve}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,D=null,X=0){let z=Math.pow(2,-X),k=Math.floor(x.image.width*z),ve=Math.floor(x.image.height*z),be=D!==null?D.x:0,xe=D!==null?D.y:0;V.setTexture2D(x,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,be,xe,k,ve),S.unbindTexture()},this.copyTextureToTexture=function(x,D,X=null,z=null,k=0,ve=0){let be,xe,Ae,Ne,Xe,Ke,Ce,lt,Dt,St=x.isCompressedTexture?x.mipmaps[ve]:x.image;if(X!==null)be=X.max.x-X.min.x,xe=X.max.y-X.min.y,Ae=X.isBox3?X.max.z-X.min.z:1,Ne=X.min.x,Xe=X.min.y,Ke=X.isBox3?X.min.z:0;else{let Lt=Math.pow(2,-k);if(be=Math.floor(St.width*Lt),xe=Math.floor(St.height*Lt),x.isDataArrayTexture)Ae=St.depth;else if(x.isData3DTexture)Ae=Math.floor(St.depth*Lt);else Ae=1;Ne=0,Xe=0,Ke=0}if(z!==null)Ce=z.x,lt=z.y,Dt=z.z;else Ce=0,lt=0,Dt=0;let gt=J.convert(D.format),Kt=J.convert(D.type),Me;if(D.isData3DTexture)V.setTexture3D(D,0),Me=L.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),Me=L.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),Me=L.TEXTURE_2D;S.activeTexture(L.TEXTURE0),S.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,D.flipY),S.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),S.pixelStorei(L.UNPACK_ALIGNMENT,D.unpackAlignment);let nn=S.getParameter(L.UNPACK_ROW_LENGTH),it=S.getParameter(L.UNPACK_IMAGE_HEIGHT),xn=S.getParameter(L.UNPACK_SKIP_PIXELS),Nn=S.getParameter(L.UNPACK_SKIP_ROWS),ri=S.getParameter(L.UNPACK_SKIP_IMAGES);S.pixelStorei(L.UNPACK_ROW_LENGTH,St.width),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,St.height),S.pixelStorei(L.UNPACK_SKIP_PIXELS,Ne),S.pixelStorei(L.UNPACK_SKIP_ROWS,Xe),S.pixelStorei(L.UNPACK_SKIP_IMAGES,Ke);let Wi=x.isDataArrayTexture||x.isData3DTexture,dt=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let Lt=I.get(x),ai=I.get(D),vt=I.get(Lt.__renderTarget),oi=I.get(ai.__renderTarget);S.bindFramebuffer(L.READ_FRAMEBUFFER,vt.__webglFramebuffer),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,oi.__webglFramebuffer);for(let Xi=0;Xi<Ae;Xi++){if(Wi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(x).__webglTexture,k,Ke+Xi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(D).__webglTexture,ve,Dt+Xi);L.blitFramebuffer(Ne,Xe,be,xe,Ce,lt,be,xe,L.DEPTH_BUFFER_BIT,L.NEAREST)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||x.isRenderTargetTexture||I.has(x)){let Lt=I.get(x),ai=I.get(D);S.bindFramebuffer(L.READ_FRAMEBUFFER,W),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,P);for(let vt=0;vt<Ae;vt++){if(Wi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Lt.__webglTexture,k,Ke+vt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Lt.__webglTexture,k);if(dt)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,ai.__webglTexture,ve,Dt+vt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ai.__webglTexture,ve);if(k!==0)L.blitFramebuffer(Ne,Xe,be,xe,Ce,lt,be,xe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(dt)L.copyTexSubImage3D(Me,ve,Ce,lt,Dt+vt,Ne,Xe,be,xe);else L.copyTexSubImage2D(Me,ve,Ce,lt,Ne,Xe,be,xe)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(dt)if(x.isDataTexture||x.isData3DTexture)L.texSubImage3D(Me,ve,Ce,lt,Dt,be,xe,Ae,gt,Kt,St.data);else if(D.isCompressedArrayTexture)L.compressedTexSubImage3D(Me,ve,Ce,lt,Dt,be,xe,Ae,gt,St.data);else L.texSubImage3D(Me,ve,Ce,lt,Dt,be,xe,Ae,gt,Kt,St);else if(x.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,ve,Ce,lt,be,xe,gt,Kt,St.data);else if(x.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,ve,Ce,lt,St.width,St.height,gt,St.data);else L.texSubImage2D(L.TEXTURE_2D,ve,Ce,lt,be,xe,gt,Kt,St);if(S.pixelStorei(L.UNPACK_ROW_LENGTH,nn),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,it),S.pixelStorei(L.UNPACK_SKIP_PIXELS,xn),S.pixelStorei(L.UNPACK_SKIP_ROWS,Nn),S.pixelStorei(L.UNPACK_SKIP_IMAGES,ri),ve===0&&D.generateMipmaps)L.generateMipmap(Me);S.unbindTexture()},this.initRenderTarget=function(x){if(I.get(x).__webglFramebuffer===void 0)V.setupRenderTarget(x)},this.initTexture=function(x){if(x.isCubeTexture)V.setTextureCube(x,0);else if(x.isData3DTexture)V.setTexture3D(x,0);else if(x.isDataArrayTexture||x.isCompressedArrayTexture)V.setTexture2DArray(x,0);else V.setTexture2D(x,0);S.unbindTexture()},this.resetState=function(){H=0,j=0,G=null,S.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}function It(e,t){let n=document.createElement("canvas");n.width=e,n.height=t;let i=n.getContext("2d");if(!i)throw Error("a canvas has no 2D context");return[n,i]}var Il=(e)=>{let t=e;return()=>{t+=1831565813;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}},tu=(e,t)=>t>0.7?e.glassLight:t<0.3?e.glassDark:e.glass,Hi=(e,t,n)=>{e.strokeStyle=t,e.lineWidth=n,e.lineJoin="round",e.lineCap="round",e.stroke()};function nu(e,t,n,i,s){let r=n+i*0.9;e.beginPath(),e.moveTo(t,n+s),e.lineTo(t,r),e.bezierCurveTo(t,n+i*0.35,t+i*0.38,n+i*0.12,t+i/2,n),e.bezierCurveTo(t+i*0.62,n+i*0.12,t+i,n+i*0.35,t+i,r),e.lineTo(t+i,n+s),e.closePath()}function vi(e,t,n,i,s=0.32){e.beginPath();for(let r=0;r<8;r+=1){let a=Math.PI/4*r-Math.PI/2,o=r%2===0?i:i*s;e.lineTo(t+Math.cos(a)*o,n+Math.sin(a)*o)}e.closePath()}function iu(e){let[t,n]=It(512,512),i=Il(11);n.fillStyle=e.floor,n.fillRect(0,0,512,512);let s=4,r=512/s;for(let a=0;a<s;a+=1)for(let o=0;o<s;o+=1)if((a+o)%2===0||i()>0.7)n.fillStyle=e.stoneShade,n.globalAlpha=0.28,n.fillRect(o*r,a*r,r,r),n.globalAlpha=1;n.strokeStyle=e.floorJoint,n.lineWidth=6;for(let a=0;a<=s;a+=1)n.beginPath(),n.moveTo(a*r,0),n.lineTo(a*r,512),n.moveTo(0,a*r),n.lineTo(512,a*r),n.stroke();return t}function su(e){let[t,n]=It(512,512),i=Il(23);n.fillStyle=e.stone,n.fillRect(0,0,512,512);let s=8,r=512/s;for(let a=0;a<s;a+=1){let o=a%2===0?4:5,l=512/(a%2===0?4:4),c=a%2===0?0:-l/2;for(let u=0;u<=o;u+=1){let d=c+u*l;if(i()>0.55)n.fillStyle=e.stoneShade,n.globalAlpha=0.45,n.fillRect(d,a*r,l,r),n.globalAlpha=1;n.fillStyle=e.stoneJoint,n.fillRect(d-3,a*r,6,r)}n.fillStyle=e.stoneJoint,n.fillRect(0,a*r-3,512,6)}return t}function na(e){let[n,i]=It(1024,1024),s=512;i.translate(512,512),i.strokeStyle=e.rune,i.fillStyle=e.rune,i.lineCap="round",i.lineJoin="round",i.shadowColor=e.rune,i.shadowBlur=26;let r=(a,o)=>{i.lineWidth=o,i.beginPath(),i.arc(0,0,a,0,Math.PI*2),i.stroke()};r(480,14),r(452,4),r(330,10),r(300,4),r(150,8);for(let a=0;a<16;a+=1){if(i.save(),i.rotate(Math.PI*2*a/16),i.translate(0,-391),a%2===0)vi(i,0,0,34,0.3),i.fill();else i.beginPath(),i.arc(0,0,22,0.55*Math.PI,2.45*Math.PI),i.arc(9,-2,18,2.45*Math.PI,0.55*Math.PI,!0),i.closePath(),i.fill();i.restore()}i.lineWidth=7;for(let a=0;a<8;a+=1)i.save(),i.rotate(Math.PI*2*a/8),i.beginPath(),i.moveTo(0,-150),i.lineTo(0,-300),i.stroke(),i.restore();return vi(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=e.bg,i.globalAlpha=0.55,vi(i,0,0,52,0.4),i.fill(),n}function Pl(e,t){let n=Il(t==="rose"?5:9);if(t==="lancet"){let[l,c]=It(256,512);nu(c,14,10,228,492),c.save(),c.clip(),c.fillStyle=e.glass,c.fillRect(0,0,256,512);let u=3,d=8,h=228/u,p=492/d;for(let v=0;v<d;v+=1)for(let T=0;T<u;T+=1)c.fillStyle=tu(e,n()),c.fillRect(14+T*h,10+v*p,h,p);if(e.night){c.fillStyle=e.sky;for(let v=0;v<6;v+=1)vi(c,40+n()*176,60+n()*380,5+n()*4,0.3),c.fill()}c.restore(),c.strokeStyle=e.stoneJoint,c.lineWidth=9;for(let v=1;v<u;v+=1)c.beginPath(),c.moveTo(14+v*h,10),c.lineTo(14+v*h,502),c.stroke();for(let v=1;v<d;v+=1)c.beginPath(),c.moveTo(14,10+v*p),c.lineTo(242,10+v*p),c.stroke();return nu(c,14,10,228,492),Hi(c,e.ink,12),l}let i=512,[s,r]=It(i,i),a=i/2;r.beginPath(),r.arc(a,a,236,0,Math.PI*2),r.save(),r.clip(),r.fillStyle=e.glass,r.fillRect(0,0,i,i);let o=i/8;for(let l=0;l<8;l+=1)for(let c=0;c<8;c+=1)r.fillStyle=tu(e,n()),r.fillRect(c*o,l*o,o,o);if(r.fillStyle=e.sky,r.beginPath(),r.arc(a,a-8,98,0,Math.PI*2),r.fill(),e.night){r.fillStyle=e.glass,r.beginPath(),r.arc(a+52,a-34,88,0,Math.PI*2),r.fill(),r.fillStyle=e.sky;for(let[l,c,u]of[[150,120,12],[380,150,9],[120,340,8],[400,360,12],[310,90,7]])vi(r,l,c,u,0.3),r.fill()}else{r.strokeStyle=e.sky,r.lineWidth=12;for(let l=0;l<12;l+=1){let c=Math.PI*2*l/12;r.beginPath(),r.moveTo(a+Math.cos(c)*120,a-8+Math.sin(c)*120),r.lineTo(a+Math.cos(c)*190,a-8+Math.sin(c)*190),r.stroke()}}r.restore(),r.strokeStyle=e.stoneJoint,r.lineWidth=12;for(let l=1;l<8;l+=1)r.beginPath(),r.moveTo(l*o,0),r.lineTo(l*o,i),r.moveTo(0,l*o),r.lineTo(i,l*o),r.stroke();return r.beginPath(),r.arc(a,a,236,0,Math.PI*2),Hi(r,e.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Hi(r,e.stoneShade,14),s}function ru(e,t){let[n,i]=It(256,512),s=()=>{i.beginPath(),i.moveTo(24,10),i.lineTo(232,10),i.lineTo(232,470),i.lineTo(128,400),i.lineTo(24,470),i.closePath()};if(s(),i.fillStyle=e.banner,i.fill(),i.save(),s(),i.clip(),i.fillStyle=e.ink,i.globalAlpha=0.18,i.fillRect(128,0,128,512),i.restore(),s(),Hi(i,e.bannerEdge,14),s(),Hi(i,e.ink,5),i.strokeStyle=e.bannerEdge,i.fillStyle=e.bannerEdge,i.lineWidth=9,i.lineCap="round",i.beginPath(),i.moveTo(40,56),i.lineTo(216,56),i.stroke(),t==="star")vi(i,128,220,84,0.22),i.fill(),i.beginPath(),i.arc(128,220,14,0,Math.PI*2),i.fillStyle=e.banner,i.fill();else if(t==="moon")i.beginPath(),i.arc(128,215,74,0,Math.PI*2),i.fill(),i.fillStyle=e.banner,i.beginPath(),i.arc(158,196,66,0,Math.PI*2),i.fill(),i.fillStyle=e.bannerEdge,vi(i,170,266,24,0.3),i.fill();else i.beginPath(),i.moveTo(128,120),i.lineTo(190,215),i.lineTo(128,320),i.lineTo(66,215),i.closePath(),i.lineWidth=11,i.stroke(),vi(i,128,215,34,0.3),i.fill();return n}function au(e){let[t,n]=It(256,320);return n.fillStyle=e.woodDark,n.fillRect(8,8,240,304),n.fillStyle=e.woodLight,n.fillRect(24,24,208,272),n.fillStyle=e.wood,n.beginPath(),n.moveTo(24,296),n.lineTo(232,296),n.lineTo(232,24),n.lineTo(212,44),n.lineTo(212,276),n.lineTo(44,276),n.closePath(),n.fill(),n.fillStyle=e.woodDark,n.fillRect(44,44,168,232),n.strokeStyle=e.goldDark,n.lineWidth=8,n.strokeRect(44,44,168,232),n.strokeStyle=e.gold,n.lineWidth=4,n.strokeRect(56,56,144,208),n.fillStyle=e.gold,n.beginPath(),n.moveTo(128,84),n.lineTo(172,160),n.lineTo(128,238),n.lineTo(84,160),n.closePath(),n.fill(),n.fillStyle=e.woodDark,n.beginPath(),n.moveTo(128,122),n.lineTo(148,160),n.lineTo(128,202),n.lineTo(108,160),n.closePath(),n.fill(),n.strokeStyle=e.ink,n.lineWidth=5,n.strokeRect(8,8,240,304),t}function ou(e){let[t,n]=It(128,192),i=(s,r,a,o)=>{n.beginPath(),n.moveTo(s,r),n.bezierCurveTo(s+o*0.2,r+(a-r)*0.3,s+o,r+(a-r)*0.5,s+o,a-o*0.9),n.arc(s,a-o*0.9,o,0,Math.PI,!1),n.bezierCurveTo(s-o,r+(a-r)*0.5,s-o*0.2,r+(a-r)*0.3,s,r),n.closePath()};return i(64,10,182,44),n.fillStyle=e.flame,n.fill(),Hi(n,e.ink,7),i(64,74,176,24),n.fillStyle=e.flameCore,n.fill(),t}function lu(e){let[t,n]=It(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Hi(n,e.ink,8)};i(0,e.paper),n.fillStyle=e.ink;for(let s of[-26,0,26])n.beginPath(),n.arc(64+s,70,9,0,Math.PI*2),n.fill();return i(1,e.gold),n.fillStyle=e.ink,n.beginPath(),n.moveTo(180,26),n.lineTo(204,26),n.lineTo(199,74),n.lineTo(185,74),n.closePath(),n.fill(),n.beginPath(),n.arc(192,94,8,0,Math.PI*2),n.fill(),i(2,"#58c878"),n.strokeStyle=e.paper,n.lineWidth=14,n.lineCap="round",n.lineJoin="round",n.beginPath(),n.moveTo(294,66),n.lineTo(312,84),n.lineTo(348,44),n.stroke(),i(3,"#ee4b4b"),n.strokeStyle=e.paper,n.beginPath(),n.moveTo(428,44),n.lineTo(468,84),n.moveTo(468,44),n.lineTo(428,84),n.stroke(),t}function ia(){let[e,t]=It(128,128),n=t.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(0.35,"rgba(255,255,255,.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),e}function cu(){let[e,t]=It(256,512),n=[[20,60,0.55],[96,40,0.8],[150,70,0.45],[220,30,0.7]];for(let[i,s,r]of n)t.fillStyle=`rgba(255,255,255,${r})`,t.beginPath(),t.moveTo(i,0),t.lineTo(i+s,0),t.lineTo(i+s+90,512),t.lineTo(i+90,512),t.closePath(),t.fill();return e}function hu(e){let[t,n]=It(256,256);n.lineCap="round";let i=[[Math.PI*1.1,78,128],[Math.PI*1.32,84,138],[Math.PI*1.54,76,124]],s=196,r=204;for(let[a,o]of[[e.ink,34],[e.gold,20]]){n.strokeStyle=a,n.lineWidth=o;for(let[l,c,u]of i)n.beginPath(),n.moveTo(s+Math.cos(l)*c,r+Math.sin(l)*c),n.lineTo(s+Math.cos(l)*u,r+Math.sin(l)*u),n.stroke()}return t}var sa=0.034,Ll=0.02,Nl=0.024,n0=(e)=>{let t=new Image;return t.decoding="async",t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,t.decode().then(()=>t)};function Dl(e,t,n,i){let[s,r]=It(t,n);return r.drawImage(e,0,0,t,n),r.globalCompositeOperation="source-in",r.fillStyle=i,r.fillRect(0,0,t,n),s}function Ul(e,t=48){return Array.from({length:t},(n,i)=>{let s=Math.PI*2*i/t;return[Math.cos(s)*e,Math.sin(s)*e]})}async function uu(e,t,n){let{rim:i,ink:s,edge:r}=n,a=await n0(e),o=(a.naturalHeight||a.height||t)/(a.naturalWidth||a.width||t),l=Math.round(t),c=Math.round(t*o),u=Math.ceil(t*(sa+Ll+Nl))+2,[d,h]=It(l+u*2,c+u*2),p=Dl(a,l,c,s),v=Dl(a,l,c,i),T=Dl(a,l,c,r);for(let[m,f]of Ul(t*(sa+Ll)))h.drawImage(T,u+m+t*Nl*0.5,u+f+t*Nl);for(let[m,f]of Ul(t*(sa+Ll)))h.drawImage(p,u+m,u+f);for(let[m,f]of Ul(t*sa))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function ra(e,t,n){let i=(r,a)=>Number.parseInt(r.slice(1+a*2,3+a*2),16),s=(r)=>Math.round(i(e,r)+(i(t,r)-i(e,r))*n).toString(16).padStart(2,"0");return`#${s(0)}${s(1)}${s(2)}`}var $s=Math.PI*2,aa=(e,t=0,n=1)=>Math.min(n,Math.max(t,e));function i0(e){let[t,n]=It(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=e.paper,r=ra(e.paper,e.ink,e.night?0.42:0.28);n.fillStyle=e.ink;for(let[a,o,l]of i)n.beginPath(),n.arc(a,o,l+5,0,$s),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,$s);n.clip(),n.fillStyle=r,n.fillRect(0,0,128,128),n.fillStyle=s;for(let[a,o,l]of i)n.beginPath(),n.arc(a-7,o-8,l,0,$s),n.fill();return n.restore(),t}function s0(e){let[t,n]=It(64,64);n.translate(32,32),n.beginPath();for(let i=0;i<8;i+=1){let s=Math.PI/4*i-Math.PI/2,r=i%2===0?27:8;n.lineTo(Math.cos(s)*r,Math.sin(s)*r)}return n.closePath(),n.lineJoin="round",n.lineWidth=7,n.strokeStyle=e.ink,n.stroke(),n.fillStyle=e.gold,n.fill(),t}function r0(){let[e,t]=It(64,256),n=t.createLinearGradient(0,0,64,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(0.5,"rgba(255,255,255,1)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,64,256),t.globalCompositeOperation="destination-in";let i=t.createLinearGradient(0,256,0,0);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(0.55,"rgba(255,255,255,.45)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,64,256),e}class Fl{hall;group=new Zt;runs=[];textures=new Map;planes=new Map;constructor(e){this.hall=e}texture(e,t){let n=this.textures.get(e);if(n)return n;let i=new xi(t());return i.colorSpace=gi,this.textures.set(e,i),i}plane(e,t,n){let i=this.planes.get(e);if(i)return i;let s=new At(t,n);return this.planes.set(e,s),s}get glow(){return this.hall.additive?jn:Cn}puff(e,t){let n=this.hall,i=this.texture("cloud",()=>i0(n)),s=this.texture("sparkle",()=>s0(n)),r=Array.from({length:7},(o,l)=>{let c=$s*l/7+l%2*0.4,u=new Hs(new _s({map:i,transparent:!0,depthWrite:!1,fog:!1}));return u.renderOrder=8,this.group.add(u),{sprite:u,angle:c,reach:0.55+l%3*0.22,size:1.5+l*5%4*0.28,lift:-0.9+l%4*0.75,turn:(l%2?1:-1)*(0.25+l%3*0.1)}}),a=Array.from({length:4},(o,l)=>{let c=new Hs(new _s({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:$s*l/4+0.7}});this.runs.push({start:t,update:(o)=>{let l=aa(o/on),c=Ri(l/0.35),u=1-(1-l)**2,d=1-aa((l-0.55)/0.45);for(let h of r)h.sprite.position.set(e.x+Math.cos(h.angle)*h.reach*(0.5+u*1.3),e.y+h.lift*(0.6+u*0.5)+l*1.2,e.z+Math.sin(h.angle)*h.reach*(0.5+u*1.3)),h.sprite.scale.setScalar(Math.max(h.size*c,0.01)),h.sprite.material.rotation=h.angle*0.3+h.turn*l,h.sprite.material.opacity=d;for(let h of a){let p=0.9+u*1.6;h.sprite.position.set(e.x+Math.cos(h.angle)*p,e.y+0.5+u*1.4,e.z+Math.sin(h.angle)*p),h.sprite.scale.setScalar(0.5*Ri(aa((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-aa((l-0.5)/0.4)}return l<1},end:()=>{for(let o of r)this.group.remove(o.sprite),o.sprite.material.dispose();for(let o of a)this.group.remove(o.sprite),o.sprite.material.dispose()}})}circle(e,t){let n=this.hall,i=this.texture("rune",()=>{let[d,h]=It(256,256);return h.drawImage(na(n),0,0,256,256),d}),s=this.texture("column",r0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Zt;o.position.set(e.x,e.y+0.03,e.z);let l=new Ge(r,new Ot({map:i,transparent:!0,depthWrite:!1,blending:this.glow,opacity:0,fog:!1}));l.rotation.x=-Math.PI/2,l.renderOrder=4,o.add(l);let c=new Zt;c.position.set(e.x,e.y+0.1,e.z);let u=new Ot({map:s,color:n.rune,transparent:!0,depthWrite:!1,blending:this.glow,side:cn,opacity:0,fog:!1});for(let d of[0,Math.PI/2]){let h=new Ge(a,u);h.position.y=2.5,h.rotation.y=d,h.renderOrder=6,c.add(h)}this.group.add(o,c),this.runs.push({start:t,update:(d)=>{let h=Ei(d);return l.material.opacity=h.circle*(n.night?1:0.9),o.rotation.y=h.spin,u.opacity=h.light*0.75,c.scale.set(1,0.4+h.light*0.6,1),d<sn},end:()=>{this.group.remove(o,c),l.material.dispose(),u.dispose()}})}step(e){for(let t=this.runs.length-1;t>=0;t-=1){let n=this.runs[t];if(!n)continue;let i=e-n.start;if(i<0)continue;if(!n.update(i))n.end(),this.runs.splice(t,1)}return this.runs.length>0}dispose(){for(let e of this.runs)e.end();this.runs.length=0;for(let e of this.textures.values())e.dispose();for(let e of this.planes.values())e.dispose();this.textures.clear(),this.planes.clear(),this.group.removeFromParent()}}function du(e,t=0.0001){t=Math.max(t,Number.EPSILON);let n={},i=e.getIndex(),s=e.getAttribute("position"),r=i?i.count:s.count,a=0,o=Object.keys(e.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let E=0,C=o.length;E<C;E++){let y=o[E],b=e.attributes[y];l[y]=new b.constructor(new b.array.constructor(b.count*b.itemSize),b.itemSize,b.normalized);let w=e.morphAttributes[y];if(w){if(!c[y])c[y]=[];w.forEach((A,_)=>{let M=new A.array.constructor(A.count*A.itemSize);c[y][_]=new A.constructor(M,A.itemSize,A.normalized)})}}let p=t*0.5,v=Math.log10(1/t),T=Math.pow(10,v),m=p*T;for(let E=0;E<r;E++){let C=i?i.getX(E):E,y="";for(let b=0,w=o.length;b<w;b++){let A=o[b],_=e.getAttribute(A),M=_.itemSize;for(let B=0;B<M;B++)y+=`${Math.trunc(_[d[B]](C)*T+m)},`}if(y in n)u.push(n[y]);else{for(let b=0,w=o.length;b<w;b++){let A=o[b],_=e.getAttribute(A),M=e.morphAttributes[A],B=_.itemSize,R=l[A],U=c[A];for(let W=0;W<B;W++){let P=d[W],H=h[W];if(R[H](a,_[P](C)),M)for(let j=0,G=M.length;j<G;j++)U[j][H](a,M[j][P](C))}}n[y]=a,u.push(a),a++}}let f=e.clone();for(let E in e.attributes){let C=l[E];if(f.setAttribute(E,new C.constructor(C.array.slice(0,a*C.itemSize),C.itemSize,C.normalized)),!(E in c))continue;for(let y=0;y<c[E].length;y++){let b=c[E][y];f.morphAttributes[E][y]=new b.constructor(b.array.slice(0,a*b.itemSize),b.itemSize,b.normalized)}}return f.setIndex(u),f}function a0(){let e=new Uint8Array([125,195,255]),t=new Vs(e,3,1,Ir,fn);return t.minFilter=In,t.magFilter=In,t.generateMipmaps=!1,t.needsUpdate=!0,t}class Ol{steps=a0();lit=new Map;flat=new Map;ink=new We("#000000");hullMaterial=new Ot({color:this.ink,side:qt,fog:!1});toon(e,t){let n=this.lit.get(e);if(!n)n=new si({color:t,gradientMap:this.steps}),this.lit.set(e,n);else n.color.set(t);return n}basic(e,t){let n=this.flat.get(e);if(!n)n=new Ot({color:t,fog:!1}),this.flat.set(e,n);else n.color.set(t);return n}setInk(e){this.ink.set(e),this.hullMaterial.color.copy(this.ink)}dispose(){this.steps.dispose(),this.hullMaterial.dispose();for(let e of this.lit.values())e.dispose();for(let e of this.flat.values())e.dispose()}}function o0(e,t){let n=e.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=du(n,0.0001);i.computeVertexNormals();let s=i.getAttribute("position"),r=i.getAttribute("normal"),a=new O;for(let o=0;o<s.count;o+=1)a.fromBufferAttribute(r,o).multiplyScalar(t),s.setXYZ(o,s.getX(o)+a.x,s.getY(o)+a.y,s.getZ(o)+a.z);return s.needsUpdate=!0,i}function yi(e,t,n,i){let s=i.get(e.geometry);if(!s)s=o0(e.geometry,n),i.set(e.geometry,s);let r=new Ge(s,t.hullMaterial);return r.renderOrder=e.renderOrder,r.userData.hull=!0,e.add(r),e}var Vi=12,Ks=12,l0=["moon","star","crest"];class fu{textures=[];geometries=[];materials=[];texture(e,t){let n=new xi(e);if(n.colorSpace=gi,t)n.wrapS=Ds,n.wrapT=Ds,n.repeat.set(t[0],t[1]);else n.wrapS=Bn,n.wrapT=Bn;return n.anisotropy=4,this.textures.push(n),n}geometry(e){return this.geometries.push(e),e}material(e){return this.materials.push(e),e}dispose(){for(let e of this.textures)e.dispose();for(let e of this.geometries)e.dispose();for(let e of this.materials)e.dispose()}}function pu(e,t,n){let i=new fu,s=new Zt,r=new Map,a=Rt(t),o=a+9.5,l=(ee,me={})=>i.material(new Ot({map:ee,transparent:!0,depthWrite:!1,fog:!1,...me})),c=e.additive?jn:Cn,u=i.texture(iu(e),[o/2.2,o/2.2]),d=new Ge(i.geometry(new xs(o+1,72)),i.material(new si({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Ge(i.geometry(new gn(a+1.9,a+2.15,0.2,72)),n.toon("dais",e.stoneShade));h.position.y=0.1,yi(h,n,0.07,r),s.add(h);let p=new Ge(i.geometry(new At((a-0.7)*2,(a-0.7)*2)),l(i.texture(na(e)),{blending:c,opacity:e.night?e.runeGlow:1}));p.rotation.x=-Math.PI/2,p.position.y=0.215,s.add(p);let v=i.material(new si({color:"#ffffff",map:i.texture(su(e),[o*Bt/7,Vi/5]),gradientMap:n.steps,side:qt})),T=new Ge(i.geometry(new gn(o,o,Vi,72,1,!0)),v);T.position.y=Vi/2,s.add(T);let m=new Ge(i.geometry(new xs(o+1,48)),i.material(new Ot({color:e.bg,side:cn})));m.rotation.x=Math.PI/2,m.position.y=Vi,s.add(m);let f=i.geometry(new gn(0.6,0.66,Vi,14)),E=i.geometry(new gn(0.88,0.7,0.5,14)),C=i.geometry(new gn(0.78,0.9,0.6,14)),y=i.geometry(new At(2.2,4.4)),b=i.geometry(new gn(0.34,0.2,0.36,10)),w=i.geometry(new gn(0.06,0.06,0.7,6)),A=i.geometry(new At(0.62,0.93)),_=i.geometry(new At(2.6,2.6)),M=l(i.texture(ou(e)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),B=l(i.texture(ia()),{color:e.flame,blending:c,opacity:e.night?0.55:0.28}),R=l0.map((ee)=>i.material(new Ot({map:i.texture(ru(e,ee)),transparent:!0,alphaTest:0.4,fog:!1}))),U=[],W=(ee,me,we,He)=>(He.position.set(Math.sin(ee)*me,we,Math.cos(ee)*me),He.rotation.y=ee+Math.PI,s.add(He),He);for(let ee=0;ee<Ks;ee+=1){let me=Bt*(ee+0.5)/Ks,we=new Ge(f,n.toon("pillar",e.stone));W(me,o-0.7,Vi/2,we),yi(we,n,0.06,r);let He=new Ge(E,n.toon("pillar",e.stone));W(me,o-0.7,Vi-0.55,He);let Fe=new Ge(C,n.toon("pillar",e.stone));W(me,o-0.7,0.3,Fe);let Y=new Ge(y,R[ee%R.length]??R[0]);W(me,o-1.34,6.8,Y);let se=new Ge(w,n.toon("iron",e.woodDark));W(me,o-1.4,2.8,se),se.rotation.x=Math.PI/2;let ae=new Ge(b,n.toon("iron",e.woodDark));W(me,o-1.75,2.95,ae),yi(ae,n,0.04,r);let Re=new Ge(A,M);Re.position.set(Math.sin(me)*(o-1.75),3.5,Math.cos(me)*(o-1.75)),Re.renderOrder=3,s.add(Re);let Ie=new Ge(_,B);Ie.position.copy(Re.position),Ie.renderOrder=2,s.add(Ie),U.push({body:Re,halo:Ie,phase:ee*1.7,base:1})}let P=i.geometry(new At(2.6,5.2)),H=i.geometry(new At(4.6,4.6)),j=l(i.texture(Pl(e,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),G=l(i.texture(Pl(e,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),re=i.geometry(new At(3.4,10)),q=l(i.texture(cu()),{color:e.beam,opacity:e.beamAlpha,blending:c,side:cn}),te=[];for(let ee=0;ee<Ks;ee+=1){let me=Bt*ee/Ks,we=ee===Ks/2,He=new Ge(we?H:P,we?G:j);W(me,o-0.12,we?7.1:6.2,He);let Fe=new Ge(re,q),Y=o-4.4;Fe.position.set(Math.sin(me)*Y,4.4,Math.cos(me)*Y),Fe.rotation.set(0,me+Math.PI,0),Fe.rotateX(-0.62),Fe.renderOrder=1,s.add(Fe),te.push(Fe)}return{group:s,flames:U,beams:te,wallRadius:o,dispose(){for(let ee of r.values())ee.dispose();i.dispose()}}}function mu(e,t,n){for(let i of e){let s=n?1:1+0.09*Math.sin(t*9+i.phase)+0.05*Math.sin(t*17+i.phase*2);i.body.scale.set(s*0.96,s*(1.02+(n?0:0.06*Math.sin(t*11+i.phase))),1),i.halo.scale.setScalar(n?1:0.95+0.1*Math.sin(t*7+i.phase))}}function gu(e){let t=()=>{let p=e.idleMs??80;return typeof p==="function"?p():p},{host:n}=e,i=!0,s,r=0,a=!1,o=Number.NEGATIVE_INFINITY,l=!1,c=()=>l||!i||n.hidden(),u=()=>{if(s===void 0)return;n.cancel(s),s=void 0},d=(p)=>{if(s=void 0,c())return;if(a||p-o>=t()){let v=r===0?16:Math.min(p-r,100);r=p,o=p,a=e.frame(p,v)}if(a||t()>0)s=n.request(d)},h=()=>{if(s!==void 0||c())return;r=0,s=n.request(d)};return{get state(){if(c())return"paused";return a?"live":"idle"},wake(){a=!0,h()},setVisible(p){if(i=p,c())u();else h()},sync(){if(c())u();else h()},dispose(){l=!0,u()}}}var xu=2;var vu=(e,t)=>Math.abs(e.x-t.x)<(e.w+t.w)/2+2&&Math.abs(e.y-t.y)<(e.h+t.h)/2+2,c0=(e,t,n)=>n<t?(t+n)/2:Math.min(n,Math.max(t,e));function _u(e,t,n,i){let s=e.w/2+2,r=i.width-e.w/2-2,a=e.h/2,o=i.height-e.h/2,l=[...t,...n],c=[e.x,...e.above?[e.above.x]:[],...l.flatMap((p)=>[p.x-(p.w+e.w)/2-2,p.x+(p.w+e.w)/2+2])].map((p)=>c0(p,s,r)),u=[e.y,...e.above?[e.above.y]:[],...l.flatMap((p)=>[p.y-(p.h+e.h)/2-2,p.y+(p.h+e.h)/2+2])].filter((p)=>p>=a&&p<=o),d,h=Number.POSITIVE_INFINITY;for(let p of c)for(let v of u){let T=e.above,m=Math.min(Math.hypot(p-e.x,(v-e.y)*1.5),T?Math.hypot(p-T.x,(v-T.y)*1.5)+40:Number.POSITIVE_INFINITY);if(m>=h)continue;let f={x:p,y:v,w:e.w,h:e.h};if(l.some((E)=>vu(f,E)))continue;d=f,h=m}return d}function yu(e,t,n=[]){let i=e.map(({x:l,y:c})=>({x:l,y:c})),s=[],r=!0,a=0,o=e.map((l,c)=>c).sort((l,c)=>(e[c]?.y??0)-(e[l]?.y??0)||(e[l]?.x??0)-(e[c]?.x??0)||l-c);for(let l of o){let c=e[l];if(!c)continue;let u=_u(c,s,n,t);if(!u){if(u=_u(c,s,[],t),u&&n.some((h)=>vu(u,h)))a+=1}if(!u)r=!1;let d=u??c;s.push(d),i[l]={x:d.x,y:d.y}}return{spots:i,clear:r,covering:a}}var h0=1.06,u0=0.68,Su=12,d0=16;class Bl{labels;click;root=document.createElement("div");items=new Map;point=new O;local=new O;constructor(e,t,n){this.labels=t;this.click=n;this.root.className="rt-names",e.appendChild(this.root)}paint(e){let t=this.root.style;t.setProperty("--rt-gold",e.gold),t.setProperty("--rt-gold-dark",e.goldDark),t.setProperty("--rt-plate-ink",e.plateInk),t.setProperty("--rt-ink",e.ink),t.setProperty("--rt-font",Mt)}set(e,t){for(let n of this.items.values())n.el.remove();this.items.clear();for(let n of e){if(n.init.kind==="owner")continue;let i=document.createElement("button");if(i.type="button",i.className="rt-name",i.textContent=n.init.name,i.setAttribute("aria-label",n.init.kind==="agent"?this.labels.seat(n.init.name,t(n)):n.init.name),n.init.id)i.dataset.seat=n.init.id;i.addEventListener("click",(s)=>this.click(n,Ct(s,i))),this.root.appendChild(i),this.items.set(n,{el:i,x:0,y:0,shown:!1})}}relabel(e,t){let n=this.items.get(e);if(n&&e.init.kind==="agent")n.el.setAttribute("aria-label",this.labels.seat(e.init.name,t))}size(e){this.root.style.setProperty("--rt-name-size",`${Math.max(Su,Math.min(d0,e*0.0125)).toFixed(1)}px`)}place(e,t,n,i,s){e.updateMatrixWorld();let r=[];for(let[l,c]of this.items){this.local.copy(t),l.group.worldToLocal(this.local);let u=this.local.z>=0?1:-1;this.point.set(0,h0,u*u0),l.group.localToWorld(this.point),this.point.project(e);let d=(this.point.x*0.5+0.5)*n,h=(-this.point.y*0.5+0.5)*i,v=this.point.z<1&&d>-n*0.05&&d<n*1.05&&h>-i*0.05&&h<i*1.05&&l!==s&&l.group.visible&&!l.labelHidden;if(v!==c.shown)c.shown=v,c.el.style.visibility=v?"visible":"hidden";if(!v)continue;r.push({item:c,podium:l,x:d,y:h,w:c.el.offsetWidth,h:c.el.offsetHeight||Su*1.8})}let a=this.faces(e,t,n,i);for(let l of r){let c=a.get(l.podium);if(c)l.above={x:c.x,y:c.y-c.h/2-l.h/2-xu}}let o=yu(r,{width:n,height:i},[...a.values()]);return r.forEach(({item:l},c)=>{let u=o.spots[c];if(!u)return;if(Math.abs(u.x-l.x)>0.25||Math.abs(u.y-l.y)>0.25)l.x=u.x,l.y=u.y,l.el.style.transform=`translate(${u.x.toFixed(1)}px, ${u.y.toFixed(1)}px) translate(-50%, -50%)`}),o.clear}faces(e,t,n,i){let s=new Map,r=[t.x,t.y,t.z];for(let a of this.items.keys()){if(a.init.kind!=="agent")continue;if(!a.group.visible||!a.board.visible)continue;a.board.getWorldPosition(this.point);let o=[this.point.x,this.point.y,this.point.z],{POSITIVE_INFINITY:l,NEGATIVE_INFINITY:c,POSITIVE_INFINITY:u,NEGATIVE_INFINITY:d}=Number,h=!1;for(let[p,v,T]of wo(o,a.board.scale.y,r)){if(this.point.set(p,v,T).project(e),this.point.z>=1)h=!0;let m=(this.point.x*0.5+0.5)*n,f=(-this.point.y*0.5+0.5)*i;l=Math.min(l,m),c=Math.max(c,m),u=Math.min(u,f),d=Math.max(d,f)}if(h)continue;s.set(a,{x:(l+c)/2,y:(u+d)/2,w:c-l,h:d-u})}return s}dispose(){this.root.remove(),this.items.clear()}}var Mu=0.62;function f0(e,t){let n=Math.atan2(e,t),i=(s)=>Math.max(-Mu,Math.min(Mu,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(rn(n-Math.PI))}var Qs=1.3,p0=1.24,m0=0.31,g0=[512,128],oa={waiting:0,alert:1,done:2,error:3};function bu(e){switch(e){case"thinking":case"working":return"waiting";case"waiting":return"alert";case"done":return"done";case"error":return"error";default:return null}}class zl{hall;geometries=[];textures=[];hulls=new Map;plinth=this.own(new Gn(1.84,0.2,1.4));body;slab=this.own(new Gn(1.98,0.14,1.5));trim=this.own(new Gn(2.01,0.04,1.53));panelPlane=this.own(new At(0.84,1.05));platePlane=this.own(new At(p0,m0));glowPlane=this.own(new At(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new At(1.25,1.25));constructor(e){this.hall=e;let t=new gn(0.82*Math.SQRT2,0.72*Math.SQRT2,1,4,1);t.rotateY(Math.PI/4),this.body=this.own(t),this.panelTexture=this.texture(au(e)),this.glowTexture=this.texture(ia()),this.badgeTexture=this.texture(lu(e)),this.marksTexture=this.texture(hu(e));let n=(i)=>{let s=new At(0.56,0.56),r=s.getAttribute("uv");for(let a=0;a<r.count;a+=1)r.setX(a,(i+r.getX(a))/4);return this.own(s)};this.badgePlanes={waiting:n(oa.waiting),alert:n(oa.alert),done:n(oa.done),error:n(oa.error)}}own(e){return this.geometries.push(e),e}texture(e){let t=new xi(e);return t.colorSpace=gi,t.wrapS=Bn,t.wrapT=Bn,t.anisotropy=4,t.minFilter=en,this.textures.push(t),t}dispose(){for(let e of this.geometries)e.dispose();for(let e of this.hulls.values())e.dispose();for(let e of this.textures)e.dispose()}}class js{init;kit;group=new Zt;rig=new Zt;board;boardMaterial;glow;glowMaterial;badge;badgeMaterial;marks;marksMaterial;marksSince=0;marksOn=!1;hits=[];plateTexture;plateMaterial;panelMaterial;shown=null;plateText={text:"",px:0};speak=0;bob=0;boardY=0;labelHidden=!1;phase=Math.random()*6;constructor(e,t,n){this.init=e;this.kit=t;let{hall:i}=t,s=(E)=>(E.userData.seat=e.id??null,E.userData.kind=e.kind,this.hits.push(E),E),r=new Ge(t.plinth,n.toon("woodDark",i.woodDark));r.position.y=0.1,yi(r,n,0.045,t.hulls);let a=new Ge(t.body,n.toon("wood",i.wood));a.scale.set(1,1,0.756);let o=e.kind==="owner";a.scale.y=o?0.3:1,a.position.y=o?0.35:0.7,yi(a,n,0.045,t.hulls);let l=new Ge(t.slab,n.toon("woodLight",i.woodLight));l.position.y=o?0.58:1.27,yi(l,n,0.045,t.hulls);let c=new Ge(t.trim,n.toon("gold",i.gold));c.position.y=o?0.51:1.2,this.group.add(r,s(a),s(l),c),this.panelMaterial=new si({map:t.panelTexture,transparent:!0,gradientMap:n.steps});let u=new Ge(t.panelPlane,this.panelMaterial);u.position.set(0,0.68,0.64),u.visible=!o,this.group.add(u);let[d,h]=g0,[p,v]=It(d,h);this.plateTexture=t.texture(p),this.plateText=xo(v,e.name,d,h,i),this.plateMaterial=new Ot({map:this.plateTexture,fog:!1});let T=new Ge(t.platePlane,this.plateMaterial);T.position.set(0,o?0.36:1.06,0.68),T.rotation.x=-0.16;let m=new Ge(t.platePlane,this.plateMaterial);m.position.set(0,o?0.36:1.06,-0.68),m.rotation.y=Math.PI,m.rotation.x=-0.16,this.group.add(s(T),s(m));let f=new Ot({transparent:!0,alphaTest:0.4,fog:!1});if(this.boardMaterial=f,this.board=new Ge(new At(mt,mt),f),this.board.visible=!1,this.board.position.y=Qs+mt/2,s(this.board),this.glowMaterial=new Ot({map:t.glowTexture,color:e.accent,transparent:!0,opacity:0,depthWrite:!1,fog:!1,blending:i.additive?jn:Cn}),this.glow=new Ge(t.glowPlane,this.glowMaterial),this.glow.position.set(0,Qs+mt/2,-0.5),this.glow.visible=!1,this.badgeMaterial=new Ot({map:t.badgeTexture,transparent:!0,alphaTest:0.2,fog:!1}),this.badge=new Ge(t.badgePlanes.waiting,this.badgeMaterial),this.badge.position.set(1.05,Qs+mt,0.05),this.badge.visible=!1,this.badge.renderOrder=5,this.marksMaterial=new Ot({map:t.marksTexture,transparent:!0,alphaTest:0.2,depthTest:!1,depthWrite:!1,fog:!1}),this.marks=new Ge(t.marksPlane,this.marksMaterial),this.marks.position.set(-1,Qs+mt*0.76,0.2),this.marks.visible=!1,this.marks.renderOrder=5,e.kind==="agent")this.rig.position.set(0,0,-0.08),this.rig.add(this.glow,this.board,this.badge,this.marks),this.group.add(this.rig)}setSticker(e){let t=this.boardMaterial.map,n=this.kit.texture(e);this.boardMaterial.map=n,this.boardMaterial.needsUpdate=!0;let i=e.height/e.width;this.board.scale.set(1,i,1),this.boardY=Qs+mt*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+mt*i/2+0.02,this.board.visible=!0,t?.dispose()}markFrame(e,t,n){let i=e&&!n;if(i&&!this.marksOn)this.marksSince=t;if(this.marksOn=i,!i)return this.marks.visible=!1,!1;let s=Math.min((t-this.marksSince)/0.4,1),r=1.70158,a=1+(r+1)*(s-1)**3+r*(s-1)**2;return this.marks.visible=!0,this.marks.scale.setScalar(Math.max(a,0.01)),s<1}setBadge(e){if(e===this.shown)return;if(this.shown=e,this.badge.visible=e!==null,e)this.badge.geometry=this.kit.badgePlanes[e]}setDim(e){this.boardMaterial.color.set(e?"#7a7f8f":"#ffffff")}face(e){let t=this.group.worldToLocal(e.clone());this.rig.rotation.y=f0(t.x,t.z)}dispose(){this.plateTexture.dispose(),this.plateMaterial.dispose(),this.panelMaterial.dispose(),this.boardMaterial.map?.dispose(),this.boardMaterial.dispose(),this.board.geometry.dispose(),this.glowMaterial.dispose(),this.badgeMaterial.dispose(),this.marksMaterial.dispose()}}function Tu(e,t){let n=document.createElement("div");n.className="rt-speed",n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;inset:0;pointer-events:none;opacity:0;background:repeating-conic-gradient(from 3deg at 50% 52%,rgba(255,255,255,.85) 0 .55deg,transparent .55deg 5.2deg);-webkit-mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);",e.appendChild(n);let i;return{play(){if(t())return!1;if(n.dataset.playing="",typeof n.animate==="function")n.animate([{opacity:0,transform:"scale(1.18)"},{opacity:0.9,transform:"scale(1.04)",offset:0.3},{opacity:0,transform:"scale(1)"}],{duration:400,easing:"ease-out"});else n.style.opacity="0.9";if(i!==void 0)clearTimeout(i);return i=setTimeout(()=>{delete n.dataset.playing,n.style.opacity="0"},400),!0},dispose(){if(i!==void 0)clearTimeout(i);n.remove()}}}var _0=2,x0=1.5,v0=60,wu=8,y0=1.22,S0=0.82,Eu=(e,t,n,i)=>e+(t-e)*(1-Math.exp(-n*i)),kl=0.2,M0=2,Au=(e)=>e.init.id??e.init.kind;function aS(e,t,n){let i=window.matchMedia("(prefers-reduced-motion: reduce)"),s=t.reducedMotion==="auto"||t.reducedMotion===void 0?i.matches:t.reducedMotion,r=window.matchMedia("(pointer: coarse)").matches,a=t.lowPower==="auto"||t.lowPower===void 0?r||Math.min(e.clientWidth||innerWidth,innerWidth)<700||(navigator.hardwareConcurrency||8)<=4:t.lowPower,o=a?x0:_0,l=new Rl({antialias:!a,alpha:!1,powerPreference:a?"default":"high-performance"});l.setPixelRatio(Math.min(window.devicePixelRatio||1,o));let c=l.domElement;if(c.style.cssText="display:block;width:100%;height:100%;touch-action:none;outline:none;cursor:grab",c.setAttribute("aria-hidden","true"),getComputedStyle(e).position==="static")e.style.position="relative";e.appendChild(c);let u=t.labels??Gt,d=new Bl(e,u,(F,K)=>{if(F.init.kind==="agent"&&F.init.id)t.onSeatClick({id:F.init.id,name:F.init.name,at:K});else if(F.init.kind==="more")t.onMore?.()}),h=Tu(e,()=>s),p=new kr,v=new ln(42,1,0.1,90),T=new $r,m=new Jr;m.position.set(-6,12,7),p.add(T,m);let{theme:f,scheme:E}=t,C=[],y=new Map,b=new Map,w,A=0,_=new Map,M=()=>`${f}/${E}`,B,R=null,U=0,W=Mn(0,1),P=W,H=W,j=0,G=0,re=!1,q,te=!1,ee=()=>w?.slots??Qi(C.length),me=()=>ee().count,we=(F)=>{let K=w?.slotOf.get(F);return K===void 0?void 0:Ft(K,me())},He=()=>{let F=R?we(R):void 0;return F===void 0?Mn(U,me(),v.aspect,c.clientWidth||void 0):ko(F,me())},Fe=()=>{let{position:F,target:K}=hr(W);v.position.set(...F),v.lookAt(K[0],K[1],K[2]),v.rotateZ(W.roll);let ce=pr(W.fov,v.aspect);if(Math.abs(v.fov-ce)>0.001)v.fov=ce,v.updateProjectionMatrix()},Y=(F,K,ce=!1)=>{let ye=Po(W,F,s||K,ce);if(re=ye.dive===!0,ye.cut)W=F,G=0;else P=W,H=F,j=performance.now(),G=ye.ms;return I.wake(),ye},se=()=>{if(!w)return;p.remove(w.group);for(let F of w.podiums)F.dispose();w.kit.dispose(),w.built.dispose(),w.toon.dispose(),w=void 0},ae=async(F,K)=>{let ce=b.get(F),ye=w;if(!ce||!ye)return;let Ee=ye.slotOf.get(F),Ve=Ee===void 0?void 0:ye.podiums[Ee];if(Ve?.init.kind!=="agent")return;try{let rt=await uu(ce,320,{rim:ye.hall.paper,ink:ye.hall.ink,edge:ra(C.find((at)=>at.id===F)?.color??ye.hall.gold,ye.hall.ink,0.35)});if(K!==A||w!==ye)return;_.set(F,{svg:ce,tone:M(),canvas:rt.canvas}),Ve.setSticker(rt.canvas),I.wake()}catch{}},Re=(F,K)=>{F.setBadge(bu(K))},Ie=(F)=>{let K=++A;se();let ce=Qn(f,E),ye=Qi(C.length),Ee=new Ol;Ee.setInk(ce.ink);let Ve=new zl(ce),rt=pu(ce,ye.count,Ee),at=new Zt;at.add(rt.group);let Je=new Map,Pn=[],Tn=[],Ln=(pt,ot,Wn=0)=>{let Yt=Qo(pt,ye.count),Xn=1+Wn/Rt(ye.count);ot.group.position.set(Yt.x*Xn,0.2,Yt.z*Xn),ot.group.rotation.y=Yt.yaw,Tn[pt]=ot,at.add(ot.group)};if(Ln(0,new js({id:void 0,name:t.ownerName??"You",kind:"owner",accent:ce.gold},Ve,Ee),1.2),C.slice(0,ye.seated).forEach((pt,ot)=>{let Wn=ot+1;Je.set(pt.id,Wn),Pn.push(pt.id);let Yt=new js({id:pt.id,name:pt.name,kind:"agent",accent:pt.color},Ve,Ee);Yt.setDim(pt.dim===!0),Re(Yt,y.get(pt.id)??pt.state??"idle"),Ln(Wn,Yt);let Xn=_.get(pt.id);if(Xn&&Xn.svg===b.get(pt.id)&&Xn.tone===M())Yt.setSticker(Xn.canvas)}),ye.more>0)Ln(ye.count-1,new js({id:void 0,name:`+${ye.more}`,kind:"more",accent:ce.gold},Ve,Ee));if(w={hall:ce,toon:Ee,kit:Ve,built:rt,group:at,slots:ye,podiums:Tn,slotOf:Je,order:Pn},F&&B){let pt=new Set;for(let ot of Tn){let Wn={x:ot.group.position.x,z:ot.group.position.z,yaw:ot.group.rotation.y},Yt=F.from.get(Au(ot));if(Yt)B.slides.push({podium:ot,from:Yt,to:Wn}),ot.group.position.x=Yt.x,ot.group.position.z=Yt.z,ot.group.rotation.y=Yt.yaw;if(ot.init.id&&F.joining.has(ot.init.id))ot.group.visible=!1,ot.labelHidden=!0,pt.add(ot)}B.risers=[...pt]}p.add(at),at.updateMatrixWorld(!0),p.background=new We(ce.bg),p.fog=new ks(ce.bg,17,46),T.color.set(ce.ambient),T.intensity=ce.ambientI,m.color.set(ce.key),m.intensity=ce.keyI;for(let pt of C.slice(0,ye.seated)){let ot=_.get(pt.id);if(ot&&ot.svg===b.get(pt.id)&&ot.tone===M())continue;ae(pt.id,K)}if(R&&!Je.has(R))R=null;Y(He(),F===void 0),d.paint(ce),d.set(Tn,(pt)=>y.get(pt.init.id??"")??"idle"),I.wake()},De=(F)=>F.slice(0,Qi(F.length).seated).map((K)=>K.id),Pt=()=>{let F=new Map;for(let K of w?.podiums??[])F.set(Au(K),{x:K.group.position.x,z:K.group.position.z,yaw:K.group.rotation.y});return F},Ye=(F)=>{F.swapped=!0;let K=Pt();C=F.next,F.slides=[],Ie({from:K,joining:new Set(F.plan.joining)});for(let ce of F.risers)F.fx?.circle({x:ce.group.position.x,y:kl,z:ce.group.position.z},F.plan.riseAt)},Ze=(F)=>{for(let K of F.timers)clearTimeout(K);for(let K of F.slides)K.podium.group.position.x=K.to.x,K.podium.group.position.z=K.to.z,K.podium.group.rotation.y=K.to.yaw;for(let K of F.risers)K.group.visible=!0,K.group.position.y=kl,K.labelHidden=!1;if(F.fx?.dispose(),c.style.transition="",c.style.opacity="",d.root.style.transition="",d.root.style.opacity="",B===F)B=void 0;I.wake()},st=()=>{let F=B;if(!F)return;if(!F.swapped)F.swapped=!0,C=F.next,Ie();Ze(F)},Qe=(F,K)=>{let ce={plan:K,start:performance.now(),next:F,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(B=ce,K.mode==="fade"){for(let Ve of[c,d.root])Ve.style.transition=`opacity ${Et}ms linear`,Ve.style.opacity="0";ce.timers.push(setTimeout(()=>{ce.swapped=!0,C=F,Ie();for(let Ve of[c,d.root])Ve.style.opacity="1"},Et),setTimeout(()=>Ze(ce),Et*2));return}let ye=w;if(!ye)return;let Ee=new Fl(ye.hall);ce.fx=Ee,p.add(Ee.group);for(let Ve of K.leaving){let rt=ye.slotOf.get(Ve),at=rt===void 0?void 0:ye.podiums[rt];if(!at)continue;ce.leavers.push(at),Ee.puff({x:at.group.position.x,y:M0,z:at.group.position.z},0)}if(K.swapAt===0)Ye(ce);I.wake()},zt=(F)=>{let K=B;if(!K||K.plan.mode!=="play")return K!==void 0;let ce=Math.max(0,F-K.start);if(!K.swapped){let Ee=Ao(ce);for(let Ve of K.leavers)if(Ve.group.scale.set(Ee.scaleX,Ee.scaleY,Ee.scaleX),Ee.gone)Ve.group.visible=!1;if(ce>=K.plan.swapAt)Ye(K)}if(K.swapped){let Ee=$o(ce-K.plan.swapAt);for(let{podium:rt,from:at,to:Je}of K.slides)rt.group.position.x=at.x+(Je.x-at.x)*Ee,rt.group.position.z=at.z+(Je.z-at.z)*Ee,rt.group.rotation.y=No(at.yaw,Je.yaw,Ee);let Ve=Ei(ce-K.plan.riseAt);for(let rt of K.risers)rt.group.visible=Ve.shown,rt.group.position.y=kl-Ve.depth*Co,rt.labelHidden=!Ve.named}let ye=K.fx?.step(ce)??!1;if(ce>=K.plan.total&&!ye)return Ze(K),!1;return!0},ut,Nt=new O,bt=0,Tt=0,L=0,Vt=0,et=0,xt=0,S=performance.now(),I=gu({frame:(F,K)=>{let ce=performance.now();bt+=K/1000;let ye=!1;if(zt(F))ye=!0;if(G>0){let rt=(F-j)/G;if(rt>=1)W=H,G=0;else W=_o(P,H,re?To(rt):Mi(rt)),ye=!0}else if(q)ye=!0;Fe(),v.getWorldPosition(Nt);let Ee=w;if(Ee){let rt=R===null?void 0:Ee.slotOf.get(R);for(let Je of Ee.podiums)Je.group.updateMatrixWorld(!0);let at=d.place(v,Nt,e.clientWidth,e.clientHeight,rt===void 0?void 0:Ee.podiums[rt]);if(R===null&&at!==ut)ut=at,t.onNames?.(at);mu(Ee.built.flames,bt,s);for(let Je of Ee.built.flames)Je.body.lookAt(Nt.x,Je.body.position.y,Nt.z);for(let Je of Ee.podiums){if(Je.init.kind!=="agent")continue;let Pn=y.get(Je.init.id??"")??"idle",Tn=Pn==="speaking"?1:0,Ln=Pn==="thinking"||Pn==="working"?1:0,pt=Je.speak;Je.speak=s?Tn:Eu(Je.speak,Tn,7,K/1000),Je.bob=s?0:Eu(Je.bob,Ln,5,K/1000);let ot=Je.speak>0.02;if(Je.glow.visible=ot&&Je.board.visible,Je.glowMaterial.opacity=0.85*Je.speak,Je.board.position.y=Je.boardY+Math.sin(bt*3.1+Je.phase)*0.035*Je.bob,Je.face(Nt),Je.markFrame(Pn==="speaking",bt,s))ye=!0;if(Math.abs(Je.speak-Tn)>0.01||Math.abs(pt-Je.speak)>0.001||Je.bob>0.02)ye=!0}}l.render(p,v),L+=1,Tt+=1;let Ve=performance.now()-ce;if(Vt+=Ve,et=Math.max(et,Ve),F-S>=1000)xt=Tt*1000/(F-S),V={...V,fps:xt,frameMs:Vt/Math.max(Tt,1),frameMsMax:et},Tt=0,Vt=0,et=0,S=F;return ye},host:{request:(F)=>requestAnimationFrame(F),cancel:(F)=>cancelAnimationFrame(F),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),V={kind:"webgl",fps:0,frameMs:0,frameMsMax:0,drawCalls:0,triangles:0,textures:0,geometries:0,dpr:l.getPixelRatio(),lowPower:a,reduced:s,loop:"idle",seats:0,renders:0},ie=()=>{let{clientWidth:F,clientHeight:K}=e;if(F<=0||K<=0)return;if(l.setSize(F,K,!1),v.aspect=F/K,v.updateProjectionMatrix(),R===null&&!q&&w)if(G===0)W=He();else H=He();d.size(F),I.wake()},le=new ResizeObserver(ie);le.observe(e);let de=new IntersectionObserver((F)=>{for(let K of F)I.setVisible(K.isIntersecting)});de.observe(e);let Z=()=>I.sync();document.addEventListener("visibilitychange",Z);let Q=(F)=>{F.preventDefault(),n?.()};c.addEventListener("webglcontextlost",Q);let fe=(F,K,ce)=>{let ye=F!==null&&w?.slotOf.has(F)?F:null;if(ye===R)return;let Ee=ye!==null&&R===null;R=ye;let Ve=Y(He(),K,Ee);if(ye!==null&&te&&!Ve.cut)h.play();if(ce)t.onFocus?.(ye)},Pe=new ze,pe=new Kr,oe=(F,K)=>{let ce=w;if(!ce)return;let ye=c.getBoundingClientRect();return Pe.set((F-ye.left)/ye.width*2-1,-((K-ye.top)/ye.height)*2+1),pe.setFromCamera(Pe,v),pe.intersectObjects(ce.podiums.filter((Ve)=>Ve.group.visible).flatMap((Ve)=>Ve.hits).filter((Ve)=>Ve.visible),!1)[0]?.object.userData},Te=new Map,Le,$e=0,N=!1,he=()=>{let[F,K]=[...Te.values()];return F&&K?Math.hypot(F.x-K.x,F.y-K.y):0},J=(F)=>{if(Te.set(F.pointerId,{x:F.clientX,y:F.clientY}),Te.size===2){$e=he(),N=!1,Le=void 0,q=void 0;return}let K=c.getBoundingClientRect(),ce=!Ro(F.clientX,F.clientY,K,{width:innerWidth,height:innerHeight});if(Le={x:F.clientX,y:F.clientY,az:U,ok:ce,at:performance.now(),hold:F.pointerType!=="mouse"&&t.onSeatMenu!==void 0},ce)c.setPointerCapture?.(F.pointerId);c.style.cursor="grabbing"},ue=(F)=>{if(Te.has(F.pointerId))Te.set(F.pointerId,{x:F.clientX,y:F.clientY});if(Te.size===2&&$e>0&&!N){let ye=he()/$e,Ee=ye>y0?"in":ye<S0?"out":"none";if(Ee!=="none")N=!0,Be(Ee==="in"?-1:1);return}if(!Le){if(F.buttons===0)c.style.cursor=oe(F.clientX,F.clientY)?"pointer":"grab";return}if(!Le.ok||R!==null)return;let K=F.clientX-Le.x;if(Math.abs(K)<wu&&!q)return;let ce=Le.az+Mo(K,c.clientWidth);q={az:ce},W=Mn(ce,me(),v.aspect,c.clientWidth||void 0),G=0,I.wake()},Se=(F)=>{if(Te.delete(F.pointerId),Te.size<2)$e=0;c.style.cursor="grab";let K=Le;if(Le=void 0,!K||N){if(Te.size===0)N=!1;return}let ce=F.clientX-K.x,ye=F.clientY-K.y;if(q){U=fr(q.az,me()),q=void 0,Y(Mn(U,me(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ce,ye)<wu){if(K.hold&&performance.now()-K.at>=vr)return;let Ee=oe(F.clientX,F.clientY);if(!Ee)return;if(Ee.kind==="agent"&&Ee.seat){let Ve=C.find((rt)=>rt.id===Ee.seat);if(Ve)t.onSeatClick({id:Ve.id,name:Ve.name,at:{x:F.clientX,y:F.clientY}})}else if(Ee.kind==="more")t.onMore?.();else if(Ee.kind==="owner"&&R!==null)fe(null,!1,!0);return}if(K.ok&&R!==null&&Math.abs(ce)>=v0&&Math.abs(ce)>Math.abs(ye))ge(ce<0?1:-1)},ne=(F)=>{if(Te.delete(F.pointerId),Le=void 0,q)U=fr(q.az,me()),q=void 0,Y(Mn(U,me(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ge=(F)=>{let K=w;if(!K||R===null||K.order.length<2)return;let ce=K.order.indexOf(R),ye=K.order[(ce+F+K.order.length)%K.order.length];if(ye)fe(ye,!1,!0)},Be=(F)=>{let K=w;if(!K)return;let ce=Eo(F,R!==null);if(ce==="in"){let ye=So(U,K.slots),Ee=ye===void 0?void 0:K.order[ye-1];if(Ee)fe(Ee,!1,!0)}else if(ce==="out")fe(null,!1,!0)},ct=0,nt=(F)=>{F.preventDefault();let K=performance.now();if(K-ct<450||Math.abs(F.deltaY)<4)return;ct=K,Be(F.deltaY)};c.addEventListener("pointerdown",J),c.addEventListener("pointermove",ue),c.addEventListener("pointerup",Se),c.addEventListener("pointercancel",ne),c.addEventListener("wheel",nt,{passive:!1});let _n=(F)=>F.length===C.length&&F.every((K,ce)=>K.id===C[ce]?.id&&K.name===C[ce]?.name&&K.color===C[ce]?.color);C=t.seats.map((F)=>({...F}));for(let F of C){if(F.state)y.set(F.id,F.state);if(F.avatarSvg)b.set(F.id,F.avatarSvg)}if(t.focus&&C.some((F)=>F.id===t.focus))R=t.focus;return Ie(),W=He(),ie(),te=!0,{kind:"webgl",setTheme(F,K){if(F===f&&K===E)return;st(),f=F,E=K,Ie()},setSeats(F){st();let K=!_n(F),ce=F.map((Ee)=>({...Ee})),ye=K&&te&&w?ni(De(C),De(ce),s):void 0;for(let Ee of ce){if(Ee.state)y.set(Ee.id,Ee.state);if(Ee.avatarSvg&&Ee.avatarSvg!==b.get(Ee.id))b.set(Ee.id,Ee.avatarSvg)}if(ye&&ye.mode!=="cut"){Qe(ce,ye);return}if(C=ce,K)Ie();else{let Ee=w;for(let Ve of C){let rt=Ee?.slotOf.get(Ve.id);(rt===void 0?void 0:Ee?.podiums[rt])?.setDim(Ve.dim===!0),ae(Ve.id,A)}}I.wake()},setState(F,K){y.set(F,K);let ce=w?.slotOf.get(F),ye=ce===void 0?void 0:w?.podiums[ce];if(ye)Re(ye,K),d.relabel(ye,K);I.wake()},async setAvatar(F,K){b.set(F,K),await ae(F,A)},setReducedMotion(F){if(s=F,V.reduced=F,F)Y(He(),!0);I.wake()},resetCamera(){U=0,fe(null,!1,!0),Y(He(),!1)},focus(F,K){fe(F,K?.cut===!0,!1)},focused:()=>R,seatAt(F,K){let ce=oe(F,K);return ce?.kind==="agent"?ce.seat:null},getStats(){let F=l.info;return{...V,drawCalls:F.render.calls,triangles:F.render.triangles,textures:F.memory.textures,geometries:F.memory.geometries,loop:I.state,seats:C.length,renders:L,reduced:s}},dispose(){if(B){for(let F of B.timers)clearTimeout(F);B.fx?.dispose(),B=void 0}I.dispose(),le.disconnect(),de.disconnect(),document.removeEventListener("visibilitychange",Z),c.removeEventListener("webglcontextlost",Q),c.removeEventListener("pointerdown",J),c.removeEventListener("pointermove",ue),c.removeEventListener("pointerup",Se),c.removeEventListener("pointercancel",ne),c.removeEventListener("wheel",nt),h.dispose(),d.dispose(),se(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{aS as createTable3D};
|