pi-roundtable-web 0.25.0 → 0.26.1
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 +54 -0
- package/README.md +165 -12
- package/dist/account-zk4efb87.css +102 -0
- package/dist/chunk-account-ghq105t4.js +1 -0
- package/dist/chunk-action-menu-me0g9qsc.js +1 -0
- package/dist/{chunk-agent-0pm9p3nn.js → chunk-agent-rdv7ekrt.js} +1 -1
- package/dist/chunk-arranged-rooms-81rqhx9x.js +1 -0
- package/dist/chunk-character-creator-bd426yjw.js +1 -0
- package/dist/chunk-codeeditor-ajhgd33t.js +2 -0
- package/dist/chunk-confirm-p3mts8mx.js +1 -0
- package/dist/{chunk-connectors-anhghy3k.js → chunk-connectors-bkv3xn83.js} +1 -1
- package/dist/chunk-conversations-0e0vbxwr.js +1 -0
- package/dist/{chunk-drag-q4fx9b22.js → chunk-drag-peyb8t0k.js} +1 -1
- package/dist/{chunk-entry-he1embgp.js → chunk-entry-mv7q8br0.js} +1 -1
- package/dist/chunk-folder-list-era3tksh.js +1 -0
- package/dist/chunk-folds-hvws0bd5.js +1 -0
- package/dist/chunk-gate-hc7dd0fx.js +1 -0
- package/dist/chunk-group-scene-dkbpmbh5.js +1 -0
- package/dist/chunk-group-table-fqmxgdfw.js +1 -0
- package/dist/chunk-host-icons-4xde9ntk.js +1 -0
- package/dist/chunk-host-picture-014yzk20.js +1 -0
- package/dist/chunk-host-state-t56e5sdy.js +1 -0
- package/dist/chunk-host-ui-p1zy9nmp.js +1 -0
- package/dist/chunk-index-0fmmvgee.js +2 -0
- package/dist/chunk-index-0q15ysrb.js +1 -0
- package/dist/chunk-index-0xh24y25.js +2 -0
- package/dist/chunk-index-2yebd9tb.js +426 -0
- package/dist/chunk-index-4t0r3t3b.js +2 -0
- package/dist/chunk-index-5yzfrf7b.js +138 -0
- package/dist/{chunk-index-d5abvq7v.js → chunk-index-6twb7ccd.js} +2 -2
- package/dist/chunk-index-73gh7kgr.js +920 -0
- package/dist/chunk-index-7xffskfa.js +8 -0
- package/dist/chunk-index-aqw7cy5j.js +1 -0
- package/dist/chunk-index-b6ca02e8.js +2 -0
- package/dist/chunk-index-b8nvhcx5.js +2 -0
- package/dist/{chunk-index-bvfqjh77.js → chunk-index-cvbdf2ca.js} +2 -2
- package/dist/chunk-index-czdketze.js +2 -0
- package/dist/{chunk-index-9jqcskb4.js → chunk-index-dt9775ka.js} +5 -5
- package/dist/chunk-index-eg55mqqe.js +1 -0
- package/dist/chunk-index-gr6e0hse.js +2 -0
- package/dist/chunk-index-gyary7np.js +13 -0
- package/dist/chunk-index-j214tczc.js +1 -0
- package/dist/chunk-index-jd6632ef.js +2 -0
- package/dist/chunk-index-jw7dtshr.js +2 -0
- package/dist/{chunk-index-krtk6nn2.js → chunk-index-k7t14rwa.js} +2 -2
- package/dist/chunk-index-kwcx62wb.js +4 -0
- package/dist/chunk-index-m7fvw92f.js +2 -0
- package/dist/chunk-index-mmg788a1.js +2 -0
- package/dist/chunk-index-mq0dacwr.js +2 -0
- package/dist/chunk-index-p53ak25v.js +2 -0
- package/dist/{chunk-index-27qca4mr.js → chunk-index-pk1yxkv4.js} +2 -2
- package/dist/{chunk-index-9b1kt7qw.css → chunk-index-rbcz9jd4.css} +1 -1
- package/dist/{chunk-index-s681nny9.js → chunk-index-rmxbdmn2.js} +2 -2
- package/dist/chunk-index-rnxj3z8k.js +2 -0
- package/dist/chunk-index-snzzfhk3.js +2 -0
- package/dist/chunk-index-v3bmr0nw.js +2 -0
- package/dist/chunk-index-vcyzwtk2.js +2 -0
- package/dist/{chunk-index-zfd00hwb.js → chunk-index-w2j3njb6.js} +2 -2
- package/dist/chunk-index-w31c4yjv.js +2 -0
- package/dist/chunk-index-wrm8w165.js +2 -0
- package/dist/chunk-index-xh0mg9cw.js +2 -0
- package/dist/chunk-index-ybtvvx85.js +2 -0
- package/dist/chunk-index-yzsgsvnp.js +2 -0
- package/dist/{chunk-index-18gxy79n.js → chunk-index-z9x4cnzf.js} +2 -2
- package/dist/chunk-index-zrvg23jd.js +2 -0
- package/dist/chunk-index-zynq0b0w.js +50 -0
- package/dist/chunk-lang-css-88v3hp3d.js +1 -0
- package/dist/{chunk-lang-dockerfile-d5mzxs60.js → chunk-lang-dockerfile-k728ewsf.js} +1 -1
- package/dist/{chunk-lang-go-830fmhba.js → chunk-lang-go-wjwgay4v.js} +3 -3
- package/dist/chunk-lang-html-07d47es4.js +1 -0
- package/dist/chunk-lang-javascript-fmhhgzwd.js +1 -0
- package/dist/{chunk-lang-json-5eaarz7j.js → chunk-lang-json-7gd89mvs.js} +1 -1
- package/dist/chunk-lang-markdown-b6qbe8bt.js +6 -0
- package/dist/{chunk-lang-python-fjw84w10.js → chunk-lang-python-3v56y31b.js} +2 -2
- package/dist/{chunk-lang-rust-5rbp2zdk.js → chunk-lang-rust-kh0z74d1.js} +1 -1
- package/dist/{chunk-lang-shell-vzagpym3.js → chunk-lang-shell-9zv0zvbx.js} +1 -1
- package/dist/{chunk-lang-sql-0c2w9c2y.js → chunk-lang-sql-yw6bf3t7.js} +2 -2
- package/dist/{chunk-lang-toml-yr9fv6eb.js → chunk-lang-toml-tg1r96nq.js} +1 -1
- package/dist/chunk-lang-typescript-etjjvr2g.js +1 -0
- package/dist/{chunk-lang-xml-eze08p42.js → chunk-lang-xml-ev1mndd4.js} +1 -1
- package/dist/{chunk-lang-yaml-c4b6ft3y.js → chunk-lang-yaml-fz5qpb3r.js} +1 -1
- package/dist/chunk-layout-actions-48ecgtkg.js +1 -0
- package/dist/{chunk-menu-items-jrwxycr1.js → chunk-menu-items-1epy3h0t.js} +2 -2
- package/dist/chunk-mode-toggle-fxmfxsa4.js +1 -0
- package/dist/chunk-note-row-kd0fy7ee.js +75 -0
- package/dist/chunk-notes-yb8f057c.js +1 -0
- package/dist/chunk-notice-bell-wr4f1rph.js +1 -0
- package/dist/chunk-notices-x07da5bb.js +1 -0
- package/dist/chunk-onboarding-csrkbh9z.js +1 -0
- package/dist/chunk-overview-avc2d30t.js +1 -0
- package/dist/chunk-palette-9nhp95bz.js +1 -0
- package/dist/chunk-placement-items-q694dpgk.js +1 -0
- package/dist/chunk-profile-6qemf3m7.js +1 -0
- package/dist/chunk-prompt-history-7enzp2p3.js +1 -0
- package/dist/chunk-prompts-nv6mrn0q.js +1 -0
- package/dist/chunk-room-confirms-zz7n61y7.js +1 -0
- package/dist/chunk-room-menu-rr6nzap1.js +1 -0
- package/dist/chunk-rooms-menu-button-zbtwj47d.js +1 -0
- package/dist/chunk-schedules-rw57nr0m.js +1 -0
- package/dist/{chunk-seat-menu-jv4s7hmj.js → chunk-seat-menu-ys5v9abz.js} +1 -1
- package/dist/chunk-sheet-hosts-jhvaacst.js +1 -0
- package/dist/chunk-skill-editor-sz8an8qr.js +8 -0
- package/dist/chunk-skills-tnr1h16h.js +1 -0
- package/dist/chunk-switcher-list-17enhrse.js +1 -0
- package/dist/chunk-tab-dot-r6brdbmw.js +1 -0
- package/dist/chunk-table-r12cja6p.js +1 -0
- package/dist/chunk-table-seats-g3t392zz.js +1 -0
- package/dist/{chunk-table2d-4sje1fr0.js → chunk-table2d-p3ezsdcj.js} +1 -1
- package/dist/{chunk-table3d-h64skazp.js → chunk-table3d-4x2n2b00.js} +23 -23
- package/dist/chunk-thread-actions-qc6ezkha.js +1 -0
- package/dist/chunk-transcript-n2s6dher.js +1 -0
- package/dist/chunk-where-f3scdydc.js +1 -0
- package/dist/chunk-workspace-xs023bxm.js +1 -0
- package/dist/chunk-zh-tw-efvmk3fd.js +1 -0
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +5 -4
- package/src/api-types.ts +356 -4
- package/src/app/app.ts +201 -32
- package/src/app/desk.ts +47 -22
- package/src/app/files.ts +73 -7
- package/src/app/presence.ts +2 -2
- package/src/app/protocol.ts +63 -1
- package/src/app/room-log.ts +153 -14
- package/src/app/rooms.ts +39 -0
- package/src/app/routes.ts +168 -28
- package/src/app/socket.ts +349 -81
- package/src/app/sockets.ts +108 -20
- package/src/app/surface.ts +72 -36
- package/src/app/threads.ts +31 -2
- package/src/app/uploads.ts +33 -7
- package/src/auth/authenticator.ts +77 -8
- package/src/auth/login-page.ts +4 -2
- package/src/auth/next.ts +52 -0
- package/src/auth/oidc-pages.ts +62 -0
- package/src/auth/oidc.ts +649 -0
- package/src/auth/sessions.ts +193 -0
- package/src/authz.ts +173 -0
- package/src/console-api.ts +122 -25
- package/src/console-server.ts +102 -12
- package/src/gate.ts +90 -0
- package/src/host/access.ts +161 -0
- package/src/host/cards.ts +112 -0
- package/src/host/context.ts +188 -0
- package/src/host/forms.ts +240 -0
- package/src/host/frames.ts +349 -0
- package/src/host/host-app.ts +178 -0
- package/src/host/host-context.ts +49 -0
- package/src/host/host-routes.ts +396 -0
- package/src/host/pages.ts +266 -0
- package/src/host/reads.ts +155 -0
- package/src/host/retention.ts +41 -0
- package/src/host/room-views.ts +137 -0
- package/src/host/rooms-service.ts +429 -0
- package/src/host/stored-json.ts +13 -0
- package/src/host/views.ts +106 -0
- package/src/i18n/zh-tw.ts +139 -0
- package/src/index.ts +15 -1
- package/src/notices/api.ts +43 -0
- package/src/notices/mount.ts +292 -0
- package/src/notices/service.ts +294 -0
- package/src/notices/store.ts +298 -0
- package/src/notices/urls.ts +38 -0
- package/src/onboarding/api.ts +32 -0
- package/src/onboarding/service.ts +149 -0
- package/src/onboarding/steps.ts +75 -0
- package/src/onboarding/waivers.ts +40 -0
- package/src/options.ts +534 -34
- package/src/page-presentation.ts +47 -2
- package/src/profile/api.ts +175 -0
- package/src/profile/links.ts +162 -0
- package/src/push/api.ts +189 -52
- package/src/push/dispatch.ts +156 -0
- package/src/push/drain.ts +139 -0
- package/src/push/outbox.ts +218 -0
- package/src/push/prefs.ts +118 -0
- package/src/push/sender.ts +7 -2
- package/src/push/triggers.ts +56 -5
- package/src/push/vapid.ts +19 -0
- package/src/push/web-push-transport.ts +106 -0
- package/src/push-sender/index.ts +14 -0
- package/src/push-sender/run.ts +118 -0
- package/src/push-sender/session.ts +54 -0
- package/src/pwa.ts +32 -4
- package/src/visitors.ts +94 -6
- package/src/web-app.ts +718 -0
- package/src/web-plugin.ts +279 -26
- package/dist/chunk-action-menu-qe839g4b.js +0 -1
- package/dist/chunk-arranged-rooms-enpfswmg.js +0 -1
- package/dist/chunk-character-creator-6yf29xwx.js +0 -1
- package/dist/chunk-codeeditor-gdbdg7rp.js +0 -2
- package/dist/chunk-confirm-xrw7d732.js +0 -1
- package/dist/chunk-conversations-ry228aes.js +0 -1
- package/dist/chunk-folder-list-5cp8stna.js +0 -1
- package/dist/chunk-folds-hff104tk.js +0 -1
- package/dist/chunk-group-scene-h228jdat.js +0 -1
- package/dist/chunk-index-0p5h2kdz.js +0 -2
- package/dist/chunk-index-0pt08yd9.js +0 -1
- package/dist/chunk-index-12bw9yj8.js +0 -2
- package/dist/chunk-index-2ad17eh4.js +0 -2
- package/dist/chunk-index-31wh5twj.js +0 -52
- package/dist/chunk-index-4dy94pbz.js +0 -2
- package/dist/chunk-index-4ecjtdy8.js +0 -13
- package/dist/chunk-index-4v1b7ks9.js +0 -2
- package/dist/chunk-index-5d8yjj4m.js +0 -2
- package/dist/chunk-index-89ajmxh7.js +0 -2
- package/dist/chunk-index-b9ny4623.js +0 -2
- package/dist/chunk-index-e1dr6g10.js +0 -2
- package/dist/chunk-index-gpkzhq1g.js +0 -2
- package/dist/chunk-index-hk3xyy20.js +0 -2
- package/dist/chunk-index-jm23vn03.js +0 -4
- package/dist/chunk-index-k7gh0jvz.js +0 -2
- package/dist/chunk-index-ky42ev0b.js +0 -2
- package/dist/chunk-index-pa2yyqh0.js +0 -2
- package/dist/chunk-index-pcvt668q.js +0 -2
- package/dist/chunk-index-pqw27eye.js +0 -1
- package/dist/chunk-index-wmbmmrd4.js +0 -302
- package/dist/chunk-index-ymbjrsp6.js +0 -2
- package/dist/chunk-lang-css-t85r8rz0.js +0 -1
- package/dist/chunk-lang-html-n6jparge.js +0 -1
- package/dist/chunk-lang-javascript-xj00cp97.js +0 -1
- package/dist/chunk-lang-markdown-zxx8eke8.js +0 -6
- package/dist/chunk-lang-typescript-8f6yywt3.js +0 -1
- package/dist/chunk-layout-actions-bv0chj41.js +0 -1
- package/dist/chunk-notes-9b7pgqfe.js +0 -1
- package/dist/chunk-overview-8yw71esz.js +0 -1
- package/dist/chunk-palette-frms7axe.js +0 -1
- package/dist/chunk-placement-items-fvfy9m0y.js +0 -1
- package/dist/chunk-prompt-history-yrqehads.js +0 -1
- package/dist/chunk-prompts-g6609tqx.js +0 -1
- package/dist/chunk-room-confirms-0a2y0925.js +0 -1
- package/dist/chunk-room-menu-g11q97br.js +0 -1
- package/dist/chunk-rooms-menu-button-h9qge48n.js +0 -1
- package/dist/chunk-schedules-ezmacrbj.js +0 -1
- package/dist/chunk-sheet-hosts-b0azyfhb.js +0 -1
- package/dist/chunk-skill-editor-h6k6whwg.js +0 -8
- package/dist/chunk-skills-gqcfhq56.js +0 -1
- package/dist/chunk-switcher-list-mcpamqnj.js +0 -1
- package/dist/chunk-table-s8cde1xz.js +0 -1
- package/dist/chunk-table-seats-wqkjn8bc.js +0 -1
- package/dist/chunk-transcript-c59c6mpm.js +0 -1
- package/dist/chunk-workspace-0cyspkk4.js +0 -1
- package/dist/chunk-zh-tw-nc93jm10.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{gi}from"./chunk-index-31wh5twj.js";import{tn,ft,fr,Pt,Bt,jn,Qt,pt,Qi,pr,Je,mr,nn,Or,gr,Kn,yr,Mi,br,vr,xr,Sr,Ri,qt,Ft,mt,wr,Rn,Jn,_r,ei,kr,Tr}from"./chunk-index-d5abvq7v.js";import{Mt}from"./chunk-index-2ad17eh4.js";var uc="186";var dc=0,Xa=1,fc=2;var Ds=1,pc=2,ps=3,ms=0,Yt=1,hn=2,Bn=0,In=1,ti=2,qa=3,Ya=4,mc=5;var gs=100,gc=101,_c=102,xc=103,vc=104,yc=200,Sc=201,Mc=202,bc=203,Tc=204,wc=205,Ec=206,Ac=207,Cc=208,Rc=209,Ic=210,Pc=211,Lc=212,Nc=213,Dc=214,Uc=0,Fc=1,Oc=2,Za=3,Bc=4,zc=5,kc=6,Gc=7,Hc=0,Vc=1,Wc=2,Pn=0,Ja=1,$a=2,Ka=3,Qa=4,ja=5,eo=6,to=7;var _s=301,Pi=302,Br=303,zr=304,Us=306,Fs=1000,zn=1001,Xc=1002,Ln=1003,qc=1004;var Os=1005;var rn=1006,Gr=1007;var Li=1008;var pn=1009,Yc=1010,Zc=1011,Bs=1012,no=1013,xi=1014,ni=1015,kn=1016,io=1017,so=1018,xs=1020,Jc=35902,$c=35899,Kc=1021,Qc=1022,Gn=1023,Ni=1026,Di=1027,Hr=1028,ro=1029,Ui=1030,ao=1031;var oo=1033,Vr=33776,Wr=33777,Xr=33778,qr=33779,lo=35840,co=35841,ho=35842,uo=35843,fo=36196,po=37492,mo=37496,go=37488,_o=37489,Yr=37490,xo=37491,vo=37808,yo=37809,So=37810,Mo=37811,bo=37812,To=37813,wo=37814,Eo=37815,Ao=37816,Co=37817,Ro=37818,Io=37819,Po=37820,Lo=37821,No=36492,Do=36494,Uo=36495,Fo=36283,Oo=36284,Zr=36285,Bo=36286;var zo=0,jc=1,Fi="",vi="srgb",ko="srgb-linear",Go="linear",yt="srgb";var eh=512,th=513,nh=514,Jr=515,ih=516,sh=517,$r=518,rh=519;var Ho="300 es",Vo=2000;function Ru(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Iu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ps(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ah(){let e=Ps("canvas");return e.style.display="block",e}var kl={},fs=null;function Ls(...e){let t="THREE."+e.shift();if(fs)fs("log",t,...e);else console.log(t,...e)}function oh(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=oh(e);let t="THREE."+e.shift();if(fs)fs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Fe(...e){e=oh(e);let t="THREE."+e.shift();if(fs)fs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Ii(...e){let t=e.join(" ");if(t in kl)return;kl[t]=!0,Oe(...e)}function lh(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 ch={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ii{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 en=["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 ya=Math.PI/180,Fr=180/Math.PI;function mi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(en[e&255]+en[e>>8&255]+en[e>>16&255]+en[e>>24&255]+"-"+en[t&255]+en[t>>8&255]+"-"+en[t>>16&15|64]+en[t>>24&255]+"-"+en[n&63|128]+en[n>>8&255]+"-"+en[n>>16&255]+en[n>>24&255]+en[i&255]+en[i>>8&255]+en[i>>16&255]+en[i>>24&255]).toLowerCase()}function tt(e,t,n){return Math.max(t,Math.min(n,e))}function Pu(e,t){return(e%t+t)%t}function Sa(e,t,n){return(1-n)*e+n*t}function On(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 _t(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 si{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(Gl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Gl.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 Ma.copy(this).projectOnVector(e),this.sub(Ma)}reflect(e){return this.sub(Ma.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 Ma=new O,Gl=new si;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 Ii("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ba.makeScale(e,t)),this}rotate(e){return Ii("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ba.makeRotation(-e)),this}translate(e,t){return Ii("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ba.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 ba=new ke,Hl=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Vl=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Lu(){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=Qn(s.r),s.g=Qn(s.g),s.b=Qn(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=ds(s.r),s.g=ds(s.g),s.b=ds(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 Ii("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ii("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:Hl,fromXYZ:Vl,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Hl,fromXYZ:Vl,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var et=Lu();function Qn(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ds(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Zi;class Wo{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(Zi===void 0)Zi=Ps("canvas");Zi.width=e.width,Zi.height=e.height;let i=Zi.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Zi}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=Ps("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]=Qn(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(Qn(t[n]/255)*255);else t[n]=Qn(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 Nu=0;class zs{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Nu++}),this.uuid=mi(),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(Ta(i[r].image));else s.push(Ta(i[r]))}else s=Ta(i);n.url=s}if(!t)e.images[this.uuid]=n;return n}}function Ta(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Wo.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 Du=0,wa=new O;class $t extends ii{constructor(e=$t.DEFAULT_IMAGE,t=$t.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=$t.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Du++}),this.uuid=mi(),this.name="",this.source=new zs(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(wa).x}get height(){return this.source.getSize(wa).y}get depth(){return this.source.getSize(wa).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++}}$t.DEFAULT_IMAGE=null;$t.DEFAULT_MAPPING=300;$t.DEFAULT_ANISOTROPY=1;class At{static{At.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 Xo extends ii{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 At(0,0,e,t),this.scissorTest=!1,this.viewport=new At(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},s=new $t(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 zs(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 mn extends Xo{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Kr extends $t{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 qo extends $t{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 Tt{static{Tt.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 Tt().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/Ji.setFromMatrixColumn(e,0).length(),s=1/Ji.setFromMatrixColumn(e,1).length(),r=1/Ji.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(Uu,e,Fu)}lookAt(e,t,n){let i=this.elements;if(un.subVectors(e,t),un.lengthSq()===0)un.z=1;if(un.normalize(),hi.crossVectors(n,un),hi.lengthSq()===0){if(Math.abs(n.z)===1)un.x+=0.0001;else un.z+=0.0001;un.normalize(),hi.crossVectors(n,un)}return hi.normalize(),nr.crossVectors(un,hi),i[0]=hi.x,i[4]=nr.x,i[8]=un.x,i[1]=hi.y,i[5]=nr.y,i[9]=un.y,i[2]=hi.z,i[6]=nr.z,i[10]=un.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],I=i[6],H=i[10],ee=i[14],G=i[3],se=i[7],Y=i[11],te=i[15];return s[0]=r*b+a*M+o*W+l*G,s[4]=r*w+a*B+o*I+l*se,s[8]=r*A+a*R+o*H+l*Y,s[12]=r*_+a*U+o*ee+l*te,s[1]=c*b+u*M+d*W+h*G,s[5]=c*w+u*B+d*I+h*se,s[9]=c*A+u*R+d*H+h*Y,s[13]=c*_+u*U+d*ee+h*te,s[2]=p*b+v*M+T*W+m*G,s[6]=p*w+v*B+T*I+m*se,s[10]=p*A+v*R+T*H+m*Y,s[14]=p*_+v*U+T*ee+m*te,s[3]=f*b+E*M+C*W+y*G,s[7]=f*w+E*B+C*I+y*se,s[11]=f*A+E*R+C*H+y*Y,s[15]=f*_+E*U+C*ee+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 I=1/W;return e[0]=(a*U-o*R+l*B)*I,e[1]=(i*R-n*U-s*B)*I,e[2]=(v*w-T*b+m*y)*I,e[3]=(d*b-u*w-h*y)*I,e[4]=(o*M-r*U-l*_)*I,e[5]=(t*U-i*M+s*_)*I,e[6]=(T*C-p*w-m*E)*I,e[7]=(c*w-d*C+h*E)*I,e[8]=(r*R-a*M+l*A)*I,e[9]=(n*M-t*R-s*A)*I,e[10]=(p*b-v*C+m*f)*I,e[11]=(u*C-c*b-h*f)*I,e[12]=(a*_-r*B-o*A)*I,e[13]=(t*B-n*_+i*A)*I,e[14]=(v*E-p*y-T*f)*I,e[15]=(c*y-u*E+d*f)*I,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=Ji.set(i[0],i[1],i[2]).length(),a=Ji.set(i[4],i[5],i[6]).length(),o=Ji.set(i[8],i[9],i[10]).length();if(s<0)r=-r;En.copy(this);let l=1/r,c=1/a,u=1/o;return En.elements[0]*=l,En.elements[1]*=l,En.elements[2]*=l,En.elements[4]*=c,En.elements[5]*=c,En.elements[6]*=c,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),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 Ji=new O,En=new Tt,Uu=new O(0,0,0),Fu=new O(1,1,1),hi=new O,nr=new O,un=new O,Wl=new Tt,Xl=new si;class _i{constructor(e=0,t=0,n=0,i=_i.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 Wl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Wl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Xl.setFromEuler(this),this.setFromQuaternion(Xl,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}}_i.DEFAULT_ORDER="XYZ";class ks{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 Ou=0,ql=new O,$i=new si,Xn=new Tt,ir=new O,Ts=new O,Bu=new O,zu=new si,Yl=new O(1,0,0),Zl=new O(0,1,0),Jl=new O(0,0,1),$l={type:"added"},ku={type:"removed"},Ki={type:"childadded",child:null},Ea={type:"childremoved",child:null};class Xt extends ii{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ou++}),this.uuid=mi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xt.DEFAULT_UP.clone();let e=new O,t=new _i,n=new si,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 Tt},normalMatrix:{value:new ke}}),this.matrix=new Tt,this.matrixWorld=new Tt,this.matrixAutoUpdate=Xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ks,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 $i.setFromAxisAngle(e,t),this.quaternion.multiply($i),this}rotateOnWorldAxis(e,t){return $i.setFromAxisAngle(e,t),this.quaternion.premultiply($i),this}rotateX(e){return this.rotateOnAxis(Yl,e)}rotateY(e){return this.rotateOnAxis(Zl,e)}rotateZ(e){return this.rotateOnAxis(Jl,e)}translateOnAxis(e,t){return ql.copy(e).applyQuaternion(this.quaternion),this.position.add(ql.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yl,e)}translateY(e){return this.translateOnAxis(Zl,e)}translateZ(e){return this.translateOnAxis(Jl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xn.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)ir.copy(e);else ir.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ts.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Xn.lookAt(Ts,ir,this.up);else Xn.lookAt(ir,Ts,this.up);if(this.quaternion.setFromRotationMatrix(Xn),i)Xn.extractRotation(i.matrixWorld),$i.setFromRotationMatrix(Xn),this.quaternion.premultiply($i.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 Fe("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($l),Ki.child=e,this.dispatchEvent(Ki),Ki.child=null;else Fe("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(ku),Ea.child=e,this.dispatchEvent(Ea),Ea.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),Xn.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Xn.multiply(e.parent.matrixWorld);return e.applyMatrix4(Xn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent($l),Ki.child=e,this.dispatchEvent(Ki),Ki.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(Ts,e,Bu),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ts,zu,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 Jt extends Xt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Gu={type:"move"};class Gs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Jt,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 Jt,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 Jt,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(Gu)}}}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 Jt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var hh={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},ui={h:0,s:0,l:0},sr={h:0,s:0,l:0};function Aa(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 Ve{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,et.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=et.workingColorSpace){return this.r=e,this.g=t,this.b=n,et.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=et.workingColorSpace){if(e=Pu(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=Aa(r,s,e+0.3333333333333333),this.g=Aa(r,s,e),this.b=Aa(r,s,e-0.3333333333333333)}return et.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=hh[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=Qn(e.r),this.g=Qn(e.g),this.b=Qn(e.b),this}copyLinearToSRGB(e){return this.r=ds(e.r),this.g=ds(e.g),this.b=ds(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return et.workingToColorSpace(sn.copy(this),e),Math.round(tt(sn.r*255,0,255))*65536+Math.round(tt(sn.g*255,0,255))*256+Math.round(tt(sn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(sn.copy(this),t);let{r:n,g:i,b:s}=sn,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=et.workingColorSpace){return et.workingToColorSpace(sn.copy(this),t),e.r=sn.r,e.g=sn.g,e.b=sn.b,e}getStyle(e="srgb"){et.workingToColorSpace(sn.copy(this),e);let{r:t,g:n,b:i}=sn;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(ui),this.setHSL(ui.h+e,ui.s+t,ui.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(ui),e.getHSL(sr);let n=Sa(ui.h,sr.h,t),i=Sa(ui.s,sr.s,t),s=Sa(ui.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 sn=new Ve;Ve.NAMES=hh;class Hs{constructor(e,t=1,n=1000){this.isFog=!0,this.name="",this.color=new Ve(e),this.near=t,this.far=n}clone(){return new Hs(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Qr 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 _i,this.environmentIntensity=1,this.environmentRotation=new _i,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 An=new O,qn=new O,Ca=new O,Yn=new O,ji=new O,es=new O,Kl=new O,Ra=new O,Ia=new O,Pa=new O,La=new At,Na=new At,Da=new At;class fn{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),An.subVectors(e,t),i.cross(An);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){An.subVectors(i,t),qn.subVectors(n,t),Ca.subVectors(e,t);let r=An.dot(An),a=An.dot(qn),o=An.dot(Ca),l=qn.dot(qn),c=qn.dot(Ca),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,Yn)===null)return!1;return Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,n,i,s,r,a,o){if(this.getBarycoord(e,t,n,i,Yn)===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,Yn.x),o.addScaledVector(r,Yn.y),o.addScaledVector(a,Yn.z),o}static getInterpolatedAttribute(e,t,n,i,s,r){return La.setScalar(0),Na.setScalar(0),Da.setScalar(0),La.fromBufferAttribute(e,t),Na.fromBufferAttribute(e,n),Da.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(La,s.x),r.addScaledVector(Na,s.y),r.addScaledVector(Da,s.z),r}static isFrontFacing(e,t,n,i){return An.subVectors(n,t),qn.subVectors(e,t),An.cross(qn).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 An.subVectors(this.c,this.b),qn.subVectors(this.a,this.b),An.cross(qn).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return fn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return fn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return fn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return fn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fn.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;ji.subVectors(i,n),es.subVectors(s,n),Ra.subVectors(e,n);let o=ji.dot(Ra),l=es.dot(Ra);if(o<=0&&l<=0)return t.copy(n);Ia.subVectors(e,i);let c=ji.dot(Ia),u=es.dot(Ia);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(ji,r);Pa.subVectors(e,s);let h=ji.dot(Pa),p=es.dot(Pa);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(es,a);let T=c*p-h*u;if(T<=0&&u-c>=0&&h-p>=0)return Kl.subVectors(s,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(Kl,a);let m=1/(T+v+d);return r=v*m,a=d*m,t.copy(n).addScaledVector(ji,r).addScaledVector(es,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Oi{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(Cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Cn.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=Cn.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,Cn);else Cn.fromBufferAttribute(s,r);Cn.applyMatrix4(e.matrixWorld),this.expandByPoint(Cn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();rr.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();rr.copy(n.boundingBox)}rr.applyMatrix4(e.matrixWorld),this.union(rr)}}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,Cn),Cn.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(ws),ar.subVectors(this.max,ws),ts.subVectors(e.a,ws),ns.subVectors(e.b,ws),is.subVectors(e.c,ws),di.subVectors(ns,ts),fi.subVectors(is,ns),wi.subVectors(ts,is);let t=[0,-di.z,di.y,0,-fi.z,fi.y,0,-wi.z,wi.y,di.z,0,-di.x,fi.z,0,-fi.x,wi.z,0,-wi.x,-di.y,di.x,0,-fi.y,fi.x,0,-wi.y,wi.x,0];if(!Ua(t,ts,ns,is,ar))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Ua(t,ts,ns,is,ar))return!1;return or.crossVectors(di,fi),t=[or.x,or.y,or.z],Ua(t,ts,ns,is,ar)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Cn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Cn).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 Zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zn),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 Zn=[new O,new O,new O,new O,new O,new O,new O,new O],Cn=new O,rr=new Oi,ts=new O,ns=new O,is=new O,di=new O,fi=new O,wi=new O,ws=new O,ar=new O,or=new O,Ei=new O;function Ua(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 Ot=new O,lr=new ze,Hu=0;class yn extends ii{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:Hu++}),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++)lr.fromBufferAttribute(this,t),lr.applyMatrix3(e),this.setXY(t,lr.x,lr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ot.fromBufferAttribute(this,t),Ot.applyMatrix3(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ot.fromBufferAttribute(this,t),Ot.applyMatrix4(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ot.fromBufferAttribute(this,t),Ot.applyNormalMatrix(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ot.fromBufferAttribute(this,t),Ot.transformDirection(e),this.setXYZ(t,Ot.x,Ot.y,Ot.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=On(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=_t(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=On(t,this.array);return t}setX(e,t){if(this.normalized)t=_t(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=On(t,this.array);return t}setY(e,t){if(this.normalized)t=_t(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=On(t,this.array);return t}setZ(e,t){if(this.normalized)t=_t(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=On(t,this.array);return t}setW(e,t){if(this.normalized)t=_t(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=_t(t,this.array),n=_t(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=_t(t,this.array),n=_t(n,this.array),i=_t(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=_t(t,this.array),n=_t(n,this.array),i=_t(i,this.array),s=_t(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 jr extends yn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ea extends yn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Kt extends yn{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Vu=new Oi,Es=new O,Fa=new O;class Vs{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 Vu.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;Es.subVectors(e,this.center);let t=Es.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Es,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 Fa.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Es.copy(e.center).add(Fa)),this.expandByPoint(Es.copy(e.center).sub(Fa));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 Wu=0,vn=new Tt,Oa=new Xt,ss=new O,dn=new Oi,As=new Oi,Wt=new O;class gn extends ii{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Wu++}),this.uuid=mi(),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((Ru(e))?ea:jr)(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 Oa.lookAt(e),Oa.updateMatrix(),this.applyMatrix4(Oa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ss).negate(),this.translate(ss.x,ss.y,ss.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 Kt(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 Oi;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("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(dn.setFromBufferAttribute(s),this.morphTargetsRelative)Wt.addVectors(this.boundingBox.min,dn.min),this.boundingBox.expandByPoint(Wt),Wt.addVectors(this.boundingBox.max,dn.max),this.boundingBox.expandByPoint(Wt);else this.boundingBox.expandByPoint(dn.min),this.boundingBox.expandByPoint(dn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Fe('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 Vs;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("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(dn.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){let a=t[s];if(As.setFromBufferAttribute(a),this.morphTargetsRelative)Wt.addVectors(dn.min,As.min),dn.expandByPoint(Wt),Wt.addVectors(dn.max,As.max),dn.expandByPoint(Wt);else dn.expandByPoint(As.min),dn.expandByPoint(As.max)}dn.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)ss.fromBufferAttribute(e,l),Wt.add(ss);i=Math.max(i,n.distanceToSquared(Wt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Fe('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){Fe("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 gn,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 Yo{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=mi()}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=mi();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=mi();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 ln=new O;class Ns{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++)ln.fromBufferAttribute(this,t),ln.applyMatrix4(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ln.fromBufferAttribute(this,t),ln.applyNormalMatrix(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ln.fromBufferAttribute(this,t),ln.transformDirection(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=On(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=_t(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=_t(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=_t(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=_t(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=_t(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=On(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=On(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=On(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=On(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=_t(t,this.array),n=_t(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=_t(t,this.array),n=_t(n,this.array),i=_t(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=_t(t,this.array),n=_t(n,this.array),i=_t(i,this.array),s=_t(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){Ls("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 Ns(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Ls("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 Ba=new O,Xu=new O,qu=new ke;class Fn{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=Ba.subVectors(n,t).cross(Xu.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(Ba),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||qu.getNormalMatrix(e),i=this.coplanarPoint(Ba).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 Yu=0;class yi extends ii{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yu++}),this.uuid=mi(),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 Ve(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 Ve().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 Fn().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 vs extends yi{constructor(e){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ve(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 rs,Cs=new O,as=new O,os=new O,ls=new ze,Rs=new ze,uh=new Tt,cr=new O,Is=new O,hr=new O,Ql=new ze,za=new ze,jl=new ze;class Ws extends Xt{constructor(e=new vs){super();if(this.isSprite=!0,this.type="Sprite",rs===void 0){rs=new gn;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 Yo(t,5);rs.setIndex([0,1,2,0,2,3]),rs.setAttribute("position",new Ns(n,3,0,!1)),rs.setAttribute("uv",new Ns(n,2,3,!1))}this.geometry=rs,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)Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(as.setFromMatrixScale(this.matrixWorld),uh.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),os.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)as.multiplyScalar(-os.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;ur(cr.set(-0.5,-0.5,0),os,r,as,i,s),ur(Is.set(0.5,-0.5,0),os,r,as,i,s),ur(hr.set(0.5,0.5,0),os,r,as,i,s),Ql.set(0,0),za.set(1,0),jl.set(1,1);let a=e.ray.intersectTriangle(cr,Is,hr,!1,Cs);if(a===null){if(ur(Is.set(-0.5,0.5,0),os,r,as,i,s),za.set(0,1),a=e.ray.intersectTriangle(cr,hr,Is,!1,Cs),a===null)return}let o=e.ray.origin.distanceTo(Cs);if(o<e.near||o>e.far)return;t.push({distance:o,point:Cs.clone(),uv:fn.getInterpolation(Cs,cr,Is,hr,Ql,za,jl,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 ur(e,t,n,i,s,r){if(ls.subVectors(e,n).addScalar(0.5).multiply(i),s!==void 0)Rs.x=r*ls.x-s*ls.y,Rs.y=s*ls.x+r*ls.y;else Rs.copy(ls);e.copy(t),e.x+=Rs.x,e.y+=Rs.y,e.applyMatrix4(uh)}var $n=new O,ka=new O,dr=new O,Mr=new O;class ta{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){ka.copy(e).add(t).multiplyScalar(0.5),dr.copy(t).sub(e).normalize(),Mr.copy(this.origin).sub(ka);let s=e.distanceTo(t)*0.5,r=-this.direction.dot(dr),a=Mr.dot(this.direction),o=-Mr.dot(dr),l=Mr.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(ka).addScaledVector(dr,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,I,H,ee,G;if(C>=y&&C>=b)if(_=o,R=u,I=p,G=m,o>=0)w=l,A=c,M=d,B=h,U=v,W=T,H=f,ee=E;else w=c,A=l,M=h,B=d,U=T,W=v,H=E,ee=f;else if(y>=b)if(_=l,R=d,I=v,G=f,l>=0)w=c,A=o,M=h,B=u,U=T,W=p,H=E,ee=m;else w=o,A=c,M=u,B=h,U=p,W=T,H=m,ee=E;else if(_=c,R=h,I=T,G=E,c>=0)w=o,A=l,M=u,B=d,U=p,W=v,H=m,ee=f;else w=l,A=o,M=d,B=u,U=v,W=p,H=f,ee=m;if(_===0)return null;let se=w/_,Y=A/_,te=1/_,j=M-se*R,ve=B-Y*R,Se=U-se*I,$e=W-Y*I,Ue=H-se*G,q=ee-Y*G,ae=Ue*$e-q*Se,oe=j*q-ve*Ue,Te=Se*ve-$e*j;if(i){if(ae<0||oe<0||Te<0)return null}else if((ae<0||oe<0||Te<0)&&(ae>0||oe>0||Te>0))return null;let Le=ae+oe+Te;if(Le===0)return null;let Ne=te*(ae*R+oe*I+Te*G);if(Le>0?Ne<0:Ne>0)return null;return this.at(Ne/Le,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 zt extends yi{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ve(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 _i,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 ec=new Tt,Ai=new ta,Er=new Vs,tc=new O,Ar=new O,Cr=new O,Rr=new O,Ga=new O,Ir=new O,nc=new O,Pr=new O;class Ge extends Xt{constructor(e=new gn,t=new zt){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){Ir.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(Ga.fromBufferAttribute(u,e),r)Ir.addScaledVector(Ga,c);else Ir.addScaledVector(Ga.sub(t),c)}t.add(Ir)}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(Er.copy(n.boundingSphere),Er.applyMatrix4(s),Ai.copy(e.ray).recast(e.near),Er.containsPoint(Ai.origin)===!1){if(Ai.intersectSphere(Er,tc)===null)return;if(Ai.origin.distanceToSquared(tc)>(e.far-e.near)**2)return}if(ec.copy(s).invert(),Ai.copy(e.ray).applyMatrix4(ec),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=Lr(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=Lr(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=Lr(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=Lr(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}}}function Zu(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;Pr.copy(o),Pr.applyMatrix4(e.matrixWorld);let c=n.ray.origin.distanceTo(Pr);if(c<n.near||c>n.far)return null;return{distance:c,point:Pr.clone(),object:e}}function Lr(e,t,n,i,s,r,a,o,l,c){e.getVertexPosition(o,Ar),e.getVertexPosition(l,Cr),e.getVertexPosition(c,Rr);let u=Zu(e,t,n,i,Ar,Cr,Rr,nc);if(u){let d=new O;if(fn.getBarycoord(nc,Ar,Cr,Rr,d),s)u.uv=fn.getInterpolatedAttribute(s,o,l,c,d,new ze);if(r)u.uv1=fn.getInterpolatedAttribute(r,o,l,c,d,new ze);if(a){if(u.normal=fn.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};fn.getNormal(Ar,Cr,Rr,h.normal),u.face=h,u.barycoord=d}return u}class Xs extends $t{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 Vs,Ju=new ze(0.5,0.5),Nr=new O;class qs{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,s=new Fn,r=new Fn){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=Ju.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(Nr.x=i.normal.x>0?e.max.x:e.min.x,Nr.y=i.normal.y>0?e.max.y:e.min.y,Nr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Nr)<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 na extends $t{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 $t{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 Bi extends $t{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 zs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class Zo extends Bi{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 ia extends $t{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Hn extends gn{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 Kt(l,3)),this.setAttribute("normal",new Kt(c,3)),this.setAttribute("uv",new Kt(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,I=w+1,H=A+1,ee=0,G=0,se=new O;for(let Y=0;Y<H;Y++){let te=Y*B-U;for(let j=0;j<I;j++){let ve=j*M-R;se[v]=ve*f,se[T]=te*E,se[m]=W,l.push(se.x,se.y,se.z),se[v]=0,se[T]=0,se[m]=b>0?1:-1,c.push(se.x,se.y,se.z),u.push(j/w),u.push(1-Y/A),ee+=1}}for(let Y=0;Y<A;Y++)for(let te=0;te<w;te++){let j=d+te+I*Y,ve=d+te+I*(Y+1),Se=d+(te+1)+I*(Y+1),$e=d+(te+1)+I*Y;o.push(j,ve,$e),o.push(ve,Se,$e),G+=6}a.addGroup(h,G,_),h+=G,d+=ee}}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 ys extends gn{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 Kt(r,3)),this.setAttribute("normal",new Kt(a,3)),this.setAttribute("uv",new Kt(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ys(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class _n extends gn{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 Kt(u,3)),this.setAttribute("normal",new Kt(d,3)),this.setAttribute("uv",new Kt(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,I=Math.sin(W),H=Math.cos(W);y.x=B*I,y.y=-M*n+T,y.z=B*H,u.push(y.x,y.y,y.z),C.set(I,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,I=Math.cos(W),H=Math.sin(W);w.x=_*H,w.y=T*M,w.z=_*I,u.push(w.x,w.y,w.z),d.push(0,M,0),b.x=I*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 _n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class It extends gn{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 Kt(p,3)),this.setAttribute("normal",new Kt(v,3)),this.setAttribute("uv",new Kt(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new It(e.width,e.height,e.widthSegments,e.heightSegments)}}function zi(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let s=e[n][i];if(ic(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(ic(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 an(e){let t={};for(let n=0;n<e.length;n++){let i=zi(e[n]);for(let s in i)t[s]=i[s]}return t}function ic(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function $u(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Jo(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return et.workingColorSpace}var dh={clone:zi,merge:an},Ku=`void main() {
|
|
1
|
+
import{sr}from"./chunk-index-zynq0b0w.js";import{gn,_t,Wr,zt,Yt,li,It,kt,Hi,Yr,lt,Hr,yn,jr,Kr,ci,Jr,ji,es,ts,ns,is,Ki,Ht,jt,Tt,rs,qn,ui,ss,di,as,os}from"./chunk-index-6twb7ccd.js";import{Dt}from"./chunk-index-jw7dtshr.js";var uc="186";var dc=0,Xa=1,fc=2;var Gs=1,pc=2,Ss=3,Ms=0,qt=1,ln=2,On=0,Rn=1,Kn=2,qa=3,Ya=4,mc=5;var bs=100,gc=101,_c=102,xc=103,vc=104,yc=200,Sc=201,Mc=202,bc=203,Tc=204,wc=205,Ec=206,Ac=207,Cc=208,Rc=209,Ic=210,Pc=211,Lc=212,Nc=213,Dc=214,Uc=0,Fc=1,Oc=2,Za=3,Bc=4,zc=5,kc=6,Gc=7,Hc=0,Vc=1,Wc=2,In=0,Ja=1,$a=2,Ka=3,Qa=4,ja=5,eo=6,to=7;var Ts=301,Ci=302,Nr=303,Dr=304,Hs=306,Vs=1000,Bn=1001,Xc=1002,Pn=1003,qc=1004;var Ws=1005;var nn=1006,Ur=1007;var Ri=1008;var dn=1009,Yc=1010,Zc=1011,Xs=1012,no=1013,_i=1014,Qn=1015,zn=1016,io=1017,so=1018,ws=1020,Jc=35902,$c=35899,Kc=1021,Qc=1022,kn=1023,Ii=1026,Pi=1027,Fr=1028,ro=1029,Li=1030,ao=1031;var oo=1033,Or=33776,Br=33777,zr=33778,kr=33779,lo=35840,co=35841,ho=35842,uo=35843,fo=36196,po=37492,mo=37496,go=37488,_o=37489,Gr=37490,xo=37491,vo=37808,yo=37809,So=37810,Mo=37811,bo=37812,To=37813,wo=37814,Eo=37815,Ao=37816,Co=37817,Ro=37818,Io=37819,Po=37820,Lo=37821,No=36492,Do=36494,Uo=36495,Fo=36283,Oo=36284,Vr=36285,Bo=36286;var zo=0,jc=1,Ni="",xi="srgb",ko="srgb-linear",Go="linear",xt="srgb";var eh=512,th=513,nh=514,Xr=515,ih=516,sh=517,qr=518,rh=519;var Ho="300 es",Vo=2000;function Ru(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Iu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ah(){let e=Bs("canvas");return e.style.display="block",e}var kl={},ys=null;function zs(...e){let t="THREE."+e.shift();if(ys)ys("log",t,...e);else console.log(t,...e)}function oh(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=oh(e);let t="THREE."+e.shift();if(ys)ys("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Fe(...e){e=oh(e);let t="THREE."+e.shift();if(ys)ys("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 kl)return;kl[t]=!0,Oe(...e)}function lh(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 ch={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class jn{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 en=["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 ya=Math.PI/180,Lr=180/Math.PI;function mi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(en[e&255]+en[e>>8&255]+en[e>>16&255]+en[e>>24&255]+"-"+en[t&255]+en[t>>8&255]+"-"+en[t>>16&15|64]+en[t>>24&255]+"-"+en[n&63|128]+en[n>>8&255]+"-"+en[n>>16&255]+en[n>>24&255]+en[i&255]+en[i>>8&255]+en[i>>16&255]+en[i>>24&255]).toLowerCase()}function et(e,t,n){return Math.max(t,Math.min(n,e))}function Pu(e,t){return(e%t+t)%t}function Sa(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=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(et(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 ei{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(et(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(Gl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Gl.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=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this.z=et(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this.z=et(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){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 Ma.copy(this).projectOnVector(e),this.sub(Ma)}reflect(e){return this.sub(Ma.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(et(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 Ma=new O,Gl=new ei;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(ba.makeScale(e,t)),this}rotate(e){return Ai("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ba.makeRotation(-e)),this}translate(e,t){return Ai("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ba.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 ba=new ke,Hl=new ke().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Vl=new ke().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Lu(){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=$n(s.r),s.g=$n(s.g),s.b=$n(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=vs(s.r),s.g=vs(s.g),s.b=vs(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:Hl,fromXYZ:Vl,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Hl,fromXYZ:Vl,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Lu();function $n(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function vs(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var qi;class Wo{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=Bs("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=Bs("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]=$n(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($n(t[n]/255)*255);else t[n]=$n(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 Nu=0;class qs{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Nu++}),this.uuid=mi(),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(Ta(i[r].image));else s.push(Ta(i[r]))}else s=Ta(i);n.url=s}if(!t)e.images[this.uuid]=n;return n}}function Ta(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Wo.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 Du=0,wa=new O;class $t extends jn{constructor(e=$t.DEFAULT_IMAGE,t=$t.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=$t.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Du++}),this.uuid=mi(),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(wa).x}get height(){return this.source.getSize(wa).y}get depth(){return this.source.getSize(wa).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++}}$t.DEFAULT_IMAGE=null;$t.DEFAULT_MAPPING=300;$t.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=et(this.x,e.x,t.x),this.y=et(this.y,e.y,t.y),this.z=et(this.z,e.z,t.z),this.w=et(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=et(this.x,e,t),this.y=et(this.y,e,t),this.z=et(this.z,e,t),this.w=et(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(et(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Xo extends jn{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 $t(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 fn extends Xo{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class Zr extends $t{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 qo extends $t{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 St{static{St.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 St().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(Uu,e,Fu)}lookAt(e,t,n){let i=this.elements;if(cn.subVectors(e,t),cn.lengthSq()===0)cn.z=1;if(cn.normalize(),ai.crossVectors(n,cn),ai.lengthSq()===0){if(Math.abs(n.z)===1)cn.x+=0.0001;else cn.z+=0.0001;cn.normalize(),ai.crossVectors(n,cn)}return ai.normalize(),hr.crossVectors(cn,ai),i[0]=ai.x,i[4]=hr.x,i[8]=cn.x,i[1]=ai.y,i[5]=hr.y,i[9]=cn.y,i[2]=ai.z,i[6]=hr.z,i[10]=cn.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],I=i[6],H=i[10],ee=i[14],G=i[3],se=i[7],Y=i[11],te=i[15];return s[0]=r*b+a*M+o*W+l*G,s[4]=r*w+a*B+o*I+l*se,s[8]=r*A+a*R+o*H+l*Y,s[12]=r*_+a*U+o*ee+l*te,s[1]=c*b+u*M+d*W+h*G,s[5]=c*w+u*B+d*I+h*se,s[9]=c*A+u*R+d*H+h*Y,s[13]=c*_+u*U+d*ee+h*te,s[2]=p*b+v*M+T*W+m*G,s[6]=p*w+v*B+T*I+m*se,s[10]=p*A+v*R+T*H+m*Y,s[14]=p*_+v*U+T*ee+m*te,s[3]=f*b+E*M+C*W+y*G,s[7]=f*w+E*B+C*I+y*se,s[11]=f*A+E*R+C*H+y*Y,s[15]=f*_+E*U+C*ee+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 I=1/W;return e[0]=(a*U-o*R+l*B)*I,e[1]=(i*R-n*U-s*B)*I,e[2]=(v*w-T*b+m*y)*I,e[3]=(d*b-u*w-h*y)*I,e[4]=(o*M-r*U-l*_)*I,e[5]=(t*U-i*M+s*_)*I,e[6]=(T*C-p*w-m*E)*I,e[7]=(c*w-d*C+h*E)*I,e[8]=(r*R-a*M+l*A)*I,e[9]=(n*M-t*R-s*A)*I,e[10]=(p*b-v*C+m*f)*I,e[11]=(u*C-c*b-h*f)*I,e[12]=(a*_-r*B-o*A)*I,e[13]=(t*B-n*_+i*A)*I,e[14]=(v*E-p*y-T*f)*I,e[15]=(c*y-u*E+d*f)*I,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;En.copy(this);let l=1/r,c=1/a,u=1/o;return En.elements[0]*=l,En.elements[1]*=l,En.elements[2]*=l,En.elements[4]*=c,En.elements[5]*=c,En.elements[6]*=c,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),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,En=new St,Uu=new O(0,0,0),Fu=new O(1,1,1),ai=new O,hr=new O,cn=new O,Wl=new St,Xl=new ei;class gi{constructor(e=0,t=0,n=0,i=gi.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(et(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(-et(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(et(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(-et(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(et(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(-et(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 Wl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Wl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Xl.setFromEuler(this),this.setFromQuaternion(Xl,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}}gi.DEFAULT_ORDER="XYZ";class Ys{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 Ou=0,ql=new O,Zi=new ei,Wn=new St,ur=new O,Ps=new O,Bu=new O,zu=new ei,Yl=new O(1,0,0),Zl=new O(0,1,0),Jl=new O(0,0,1),$l={type:"added"},ku={type:"removed"},Ji={type:"childadded",child:null},Ea={type:"childremoved",child:null};class Xt extends jn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ou++}),this.uuid=mi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xt.DEFAULT_UP.clone();let e=new O,t=new gi,n=new ei,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 St},normalMatrix:{value:new ke}}),this.matrix=new St,this.matrixWorld=new St,this.matrixAutoUpdate=Xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ys,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(Yl,e)}rotateY(e){return this.rotateOnAxis(Zl,e)}rotateZ(e){return this.rotateOnAxis(Jl,e)}translateOnAxis(e,t){return ql.copy(e).applyQuaternion(this.quaternion),this.position.add(ql.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yl,e)}translateY(e){return this.translateOnAxis(Zl,e)}translateZ(e){return this.translateOnAxis(Jl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wn.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)ur.copy(e);else ur.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Ps.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Wn.lookAt(Ps,ur,this.up);else Wn.lookAt(ur,Ps,this.up);if(this.quaternion.setFromRotationMatrix(Wn),i)Wn.extractRotation(i.matrixWorld),Zi.setFromRotationMatrix(Wn),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 Fe("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($l),Ji.child=e,this.dispatchEvent(Ji),Ji.child=null;else Fe("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(ku),Ea.child=e,this.dispatchEvent(Ea),Ea.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),Wn.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Wn.multiply(e.parent.matrixWorld);return e.applyMatrix4(Wn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent($l),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(Ps,e,Bu),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ps,zu,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 Jt extends Xt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Gu={type:"move"};class Zs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Jt,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 Jt,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 Jt,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(Gu)}}}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 Jt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var hh={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},oi={h:0,s:0,l:0},dr={h:0,s:0,l:0};function Aa(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 Ve{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=Pu(e,1),t=et(t,0,1),n=et(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=Aa(r,s,e+0.3333333333333333),this.g=Aa(r,s,e),this.b=Aa(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=hh[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=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=vs(e.r),this.g=vs(e.g),this.b=vs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(tn.copy(this),e),Math.round(et(tn.r*255,0,255))*65536+Math.round(et(tn.g*255,0,255))*256+Math.round(et(tn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(tn.copy(this),t);let{r:n,g:i,b:s}=tn,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(tn.copy(this),t),e.r=tn.r,e.g=tn.g,e.b=tn.b,e}getStyle(e="srgb"){je.workingToColorSpace(tn.copy(this),e);let{r:t,g:n,b:i}=tn;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(oi),this.setHSL(oi.h+e,oi.s+t,oi.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(oi),e.getHSL(dr);let n=Sa(oi.h,dr.h,t),i=Sa(oi.s,dr.s,t),s=Sa(oi.l,dr.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 tn=new Ve;Ve.NAMES=hh;class Js{constructor(e,t=1,n=1000){this.isFog=!0,this.name="",this.color=new Ve(e),this.near=t,this.far=n}clone(){return new Js(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $r 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 gi,this.environmentIntensity=1,this.environmentRotation=new gi,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 An=new O,Xn=new O,Ca=new O,Yn=new O,$i=new O,Qi=new O,Kl=new O,Ra=new O,Ia=new O,Pa=new O,La=new wt,Na=new wt,Da=new wt;class un{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),An.subVectors(e,t),i.cross(An);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){An.subVectors(i,t),Xn.subVectors(n,t),Ca.subVectors(e,t);let r=An.dot(An),a=An.dot(Xn),o=An.dot(Ca),l=Xn.dot(Xn),c=Xn.dot(Ca),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,Yn)===null)return!1;return Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,n,i,s,r,a,o){if(this.getBarycoord(e,t,n,i,Yn)===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,Yn.x),o.addScaledVector(r,Yn.y),o.addScaledVector(a,Yn.z),o}static getInterpolatedAttribute(e,t,n,i,s,r){return La.setScalar(0),Na.setScalar(0),Da.setScalar(0),La.fromBufferAttribute(e,t),Na.fromBufferAttribute(e,n),Da.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(La,s.x),r.addScaledVector(Na,s.y),r.addScaledVector(Da,s.z),r}static isFrontFacing(e,t,n,i){return An.subVectors(n,t),Xn.subVectors(e,t),An.cross(Xn).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 An.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),An.cross(Xn).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return un.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return un.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return un.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),Qi.subVectors(s,n),Ra.subVectors(e,n);let o=$i.dot(Ra),l=Qi.dot(Ra);if(o<=0&&l<=0)return t.copy(n);Ia.subVectors(e,i);let c=$i.dot(Ia),u=Qi.dot(Ia);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);Pa.subVectors(e,s);let h=$i.dot(Pa),p=Qi.dot(Pa);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 Kl.subVectors(s,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(Kl,a);let m=1/(T+v+d);return r=v*m,a=d*m,t.copy(n).addScaledVector($i,r).addScaledVector(Qi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Di{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(Cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Cn.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=Cn.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,Cn);else Cn.fromBufferAttribute(s,r);Cn.applyMatrix4(e.matrixWorld),this.expandByPoint(Cn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();fr.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();fr.copy(n.boundingBox)}fr.applyMatrix4(e.matrixWorld),this.union(fr)}}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,Cn),Cn.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(Ls),pr.subVectors(this.max,Ls),ls.subVectors(e.a,Ls),cs.subVectors(e.b,Ls),hs.subVectors(e.c,Ls),hi.subVectors(cs,ls),fi.subVectors(hs,cs),bi.subVectors(ls,hs);let t=[0,-hi.z,hi.y,0,-fi.z,fi.y,0,-bi.z,bi.y,hi.z,0,-hi.x,fi.z,0,-fi.x,bi.z,0,-bi.x,-hi.y,hi.x,0,-fi.y,fi.x,0,-bi.y,bi.x,0];if(!Ua(t,ls,cs,hs,pr))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Ua(t,ls,cs,hs,pr))return!1;return mr.crossVectors(hi,fi),t=[mr.x,mr.y,mr.z],Ua(t,ls,cs,hs,pr)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Cn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Cn).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 Zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zn),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 Zn=[new O,new O,new O,new O,new O,new O,new O,new O],Cn=new O,fr=new Di,ls=new O,cs=new O,hs=new O,hi=new O,fi=new O,bi=new O,Ls=new O,pr=new O,mr=new O,Ti=new O;function Ua(e,t,n,i,s){for(let r=0,a=e.length-3;r<=a;r+=3){Ti.fromArray(e,r);let o=s.x*Math.abs(Ti.x)+s.y*Math.abs(Ti.y)+s.z*Math.abs(Ti.z),l=t.dot(Ti),c=n.dot(Ti),u=i.dot(Ti);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}var Ut=new O,gr=new ze,Hu=0;class vn extends jn{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:Hu++}),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++)gr.fromBufferAttribute(this,t),gr.applyMatrix3(e),this.setXY(t,gr.x,gr.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=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 Qr extends vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ea extends vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Kt extends vn{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Vu=new Di,Ns=new O,Fa=new O;class $s{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 Vu.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;Ns.subVectors(e,this.center);let t=Ns.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Ns,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 Fa.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ns.copy(e.center).add(Fa)),this.expandByPoint(Ns.copy(e.center).sub(Fa));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 Wu=0,xn=new St,Oa=new Xt,us=new O,hn=new Di,Ds=new Di,Wt=new O;class pn extends jn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Wu++}),this.uuid=mi(),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((Ru(e))?ea:Qr)(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 xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,n){return xn.makeTranslation(e,t,n),this.applyMatrix4(xn),this}scale(e,t,n){return xn.makeScale(e,t,n),this.applyMatrix4(xn),this}lookAt(e){return Oa.lookAt(e),Oa.updateMatrix(),this.applyMatrix4(Oa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(us).negate(),this.translate(us.x,us.y,us.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 Kt(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 Di;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("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(hn.setFromBufferAttribute(s),this.morphTargetsRelative)Wt.addVectors(this.boundingBox.min,hn.min),this.boundingBox.expandByPoint(Wt),Wt.addVectors(this.boundingBox.max,hn.max),this.boundingBox.expandByPoint(Wt);else this.boundingBox.expandByPoint(hn.min),this.boundingBox.expandByPoint(hn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Fe('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 $s;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("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(hn.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){let a=t[s];if(Ds.setFromBufferAttribute(a),this.morphTargetsRelative)Wt.addVectors(hn.min,Ds.min),hn.expandByPoint(Wt),Wt.addVectors(hn.max,Ds.max),hn.expandByPoint(Wt);else hn.expandByPoint(Ds.min),hn.expandByPoint(Ds.max)}hn.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)us.fromBufferAttribute(e,l),Wt.add(us);i=Math.max(i,n.distanceToSquared(Wt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Fe('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){Fe("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 vn(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 vn(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 vn(d,c,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new pn,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 Yo{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=mi()}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=mi();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=mi();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 ks{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=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){zs("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 vn(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 ks(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){zs("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 Ba=new O,Xu=new O,qu=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=Ba.subVectors(n,t).cross(Xu.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(Ba),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||qu.getNormalMatrix(e),i=this.coplanarPoint(Ba).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 Yu=0;class vi extends jn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yu++}),this.uuid=mi(),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 Ve(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 Ve().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 Es extends vi{constructor(e){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ve(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 ds,Us=new O,fs=new O,ps=new O,ms=new ze,Fs=new ze,uh=new St,_r=new O,Os=new O,xr=new O,Ql=new ze,za=new ze,jl=new ze;class Ks extends Xt{constructor(e=new Es){super();if(this.isSprite=!0,this.type="Sprite",ds===void 0){ds=new pn;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 Yo(t,5);ds.setIndex([0,1,2,0,2,3]),ds.setAttribute("position",new ks(n,3,0,!1)),ds.setAttribute("uv",new ks(n,2,3,!1))}this.geometry=ds,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)Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(fs.setFromMatrixScale(this.matrixWorld),uh.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ps.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)fs.multiplyScalar(-ps.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;vr(_r.set(-0.5,-0.5,0),ps,r,fs,i,s),vr(Os.set(0.5,-0.5,0),ps,r,fs,i,s),vr(xr.set(0.5,0.5,0),ps,r,fs,i,s),Ql.set(0,0),za.set(1,0),jl.set(1,1);let a=e.ray.intersectTriangle(_r,Os,xr,!1,Us);if(a===null){if(vr(Os.set(-0.5,0.5,0),ps,r,fs,i,s),za.set(0,1),a=e.ray.intersectTriangle(_r,xr,Os,!1,Us),a===null)return}let o=e.ray.origin.distanceTo(Us);if(o<e.near||o>e.far)return;t.push({distance:o,point:Us.clone(),uv:un.getInterpolation(Us,_r,Os,xr,Ql,za,jl,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 vr(e,t,n,i,s,r){if(ms.subVectors(e,n).addScalar(0.5).multiply(i),s!==void 0)Fs.x=r*ms.x-s*ms.y,Fs.y=s*ms.x+r*ms.y;else Fs.copy(ms);e.copy(t),e.x+=Fs.x,e.y+=Fs.y,e.applyMatrix4(uh)}var Jn=new O,ka=new O,yr=new O,Sr=new O;class ta{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,Jn)),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=Jn.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Jn.copy(this.origin).addScaledVector(this.direction,t),Jn.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){ka.copy(e).add(t).multiplyScalar(0.5),yr.copy(t).sub(e).normalize(),Sr.copy(this.origin).sub(ka);let s=e.distanceTo(t)*0.5,r=-this.direction.dot(yr),a=Sr.dot(this.direction),o=-Sr.dot(yr),l=Sr.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(ka).addScaledVector(yr,d);return h}intersectSphere(e,t){if(e.radius<0)return null;Jn.subVectors(e.center,this.origin);let n=Jn.dot(this.direction),i=Jn.dot(Jn)-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,Jn)!==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,I,H,ee,G;if(C>=y&&C>=b)if(_=o,R=u,I=p,G=m,o>=0)w=l,A=c,M=d,B=h,U=v,W=T,H=f,ee=E;else w=c,A=l,M=h,B=d,U=T,W=v,H=E,ee=f;else if(y>=b)if(_=l,R=d,I=v,G=f,l>=0)w=c,A=o,M=h,B=u,U=T,W=p,H=E,ee=m;else w=o,A=c,M=u,B=h,U=p,W=T,H=m,ee=E;else if(_=c,R=h,I=T,G=E,c>=0)w=o,A=l,M=u,B=d,U=p,W=v,H=m,ee=f;else w=l,A=o,M=d,B=u,U=v,W=p,H=f,ee=m;if(_===0)return null;let se=w/_,Y=A/_,te=1/_,j=M-se*R,ve=B-Y*R,Se=U-se*I,Je=W-Y*I,Ue=H-se*G,q=ee-Y*G,ae=Ue*Je-q*Se,oe=j*q-ve*Ue,Te=Se*ve-Je*j;if(i){if(ae<0||oe<0||Te<0)return null}else if((ae<0||oe<0||Te<0)&&(ae>0||oe>0||Te>0))return null;let Le=ae+oe+Te;if(Le===0)return null;let Ne=te*(ae*R+oe*I+Te*G);if(Le>0?Ne<0:Ne>0)return null;return this.at(Ne/Le,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 vi{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ve(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 gi,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 ec=new St,wi=new ta,Mr=new $s,tc=new O,br=new O,Tr=new O,wr=new O,Ga=new O,Er=new O,nc=new O,Ar=new O;class Ge extends Xt{constructor(e=new pn,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){Er.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(Ga.fromBufferAttribute(u,e),r)Er.addScaledVector(Ga,c);else Er.addScaledVector(Ga.sub(t),c)}t.add(Er)}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),wi.copy(e.ray).recast(e.near),Mr.containsPoint(wi.origin)===!1){if(wi.intersectSphere(Mr,tc)===null)return;if(wi.origin.distanceToSquared(tc)>(e.far-e.near)**2)return}if(ec.copy(s).invert(),wi.copy(e.ray).applyMatrix4(ec),n.boundingBox!==null){if(wi.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,wi)}_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=Cr(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=Cr(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=Cr(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=Cr(this,r,e,n,l,c,u,f,E,C),i)i.faceIndex=Math.floor(T/3),t.push(i)}}}}function Zu(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;Ar.copy(o),Ar.applyMatrix4(e.matrixWorld);let c=n.ray.origin.distanceTo(Ar);if(c<n.near||c>n.far)return null;return{distance:c,point:Ar.clone(),object:e}}function Cr(e,t,n,i,s,r,a,o,l,c){e.getVertexPosition(o,br),e.getVertexPosition(l,Tr),e.getVertexPosition(c,wr);let u=Zu(e,t,n,i,br,Tr,wr,nc);if(u){let d=new O;if(un.getBarycoord(nc,br,Tr,wr,d),s)u.uv=un.getInterpolatedAttribute(s,o,l,c,d,new ze);if(r)u.uv1=un.getInterpolatedAttribute(r,o,l,c,d,new ze);if(a){if(u.normal=un.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};un.getNormal(br,Tr,wr,h.normal),u.face=h,u.barycoord=d}return u}class Qs extends $t{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 Ei=new $s,Ju=new ze(0.5,0.5),Rr=new O;class js{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();Ei.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Ei.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ei)}intersectsSprite(e){Ei.center.set(0,0,0);let t=Ju.distanceTo(e.center);return Ei.radius=0.7071067811865476+t,Ei.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ei)}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(Rr.x=i.normal.x>0?e.max.x:e.min.x,Rr.y=i.normal.y>0?e.max.y:e.min.y,Rr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Rr)<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 na extends $t{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 yi extends $t{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 Ui extends $t{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 Zo extends Ui{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 ia extends $t{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gn extends pn{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 Kt(l,3)),this.setAttribute("normal",new Kt(c,3)),this.setAttribute("uv",new Kt(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,I=w+1,H=A+1,ee=0,G=0,se=new O;for(let Y=0;Y<H;Y++){let te=Y*B-U;for(let j=0;j<I;j++){let ve=j*M-R;se[v]=ve*f,se[T]=te*E,se[m]=W,l.push(se.x,se.y,se.z),se[v]=0,se[T]=0,se[m]=b>0?1:-1,c.push(se.x,se.y,se.z),u.push(j/w),u.push(1-Y/A),ee+=1}}for(let Y=0;Y<A;Y++)for(let te=0;te<w;te++){let j=d+te+I*Y,ve=d+te+I*(Y+1),Se=d+(te+1)+I*(Y+1),Je=d+(te+1)+I*Y;o.push(j,ve,Je),o.push(ve,Se,Je),G+=6}a.addGroup(h,G,_),h+=G,d+=ee}}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 As extends pn{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 Kt(r,3)),this.setAttribute("normal",new Kt(a,3)),this.setAttribute("uv",new Kt(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new As(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class mn extends pn{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 Kt(u,3)),this.setAttribute("normal",new Kt(d,3)),this.setAttribute("uv",new Kt(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,I=Math.sin(W),H=Math.cos(W);y.x=B*I,y.y=-M*n+T,y.z=B*H,u.push(y.x,y.y,y.z),C.set(I,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,I=Math.cos(W),H=Math.sin(W);w.x=_*H,w.y=T*M,w.z=_*I,u.push(w.x,w.y,w.z),d.push(0,M,0),b.x=I*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 mn(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ct extends pn{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 Kt(p,3)),this.setAttribute("normal",new Kt(v,3)),this.setAttribute("uv",new Kt(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ct(e.width,e.height,e.widthSegments,e.heightSegments)}}function Fi(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let s=e[n][i];if(ic(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(ic(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 sn(e){let t={};for(let n=0;n<e.length;n++){let i=Fi(e[n]);for(let s in i)t[s]=i[s]}return t}function ic(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function $u(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Jo(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var dh={clone:Fi,merge:sn},Ku=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,Qu=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`;class Sn extends yi{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ku,this.fragmentShader=Qu,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=zi(e.uniforms),this.uniformsGroups=$u(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 Ve().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 At().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ke().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Tt().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 $o extends Sn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ri extends yi{constructor(e){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ve(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(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 Ko extends yi{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 Qo extends yi{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 cs(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 Ha(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}class ki{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 jo extends ki{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 el extends ki{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 tl extends ki{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class nl extends ki{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=ed(n,t,f,y,i);s[p]=fh(w,v,E,b,T)}return s}}function fh(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 ju(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 ed(e,t,n,i,s){let r=(e-t)/(s-t);for(let a=0;a<8;a++){let o=fh(r,t,n,i,s)-e;if(Math.abs(o)<0.0000000001)break;let l=ju(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=cs(t,this.TimeBufferType),this.values=cs(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:cs(e.times,Array),values:cs(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Ha(e.settings))n.settings={inTangents:cs(e.settings.inTangents,Array),outTangents:cs(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new tl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new el(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new nl(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(Ha(this.settings))sc(this.settings.inTangents,e),sc(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)Fe("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Fe("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)){Fe("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(r!==null&&r>o){Fe("KeyframeTrack: Out of order keys.",this,a,o,r),e=!1;break}r=o}if(i!==void 0){if(Iu(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Fe("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,Ha(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function sc(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 Gi extends Mn{constructor(e,t,n){super(e,t,n)}}Gi.prototype.ValueTypeName="bool";Gi.prototype.ValueBufferType=Array;Gi.prototype.DefaultInterpolation=2300;Gi.prototype.InterpolantFactoryMethodLinear=void 0;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;class il extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}il.prototype.ValueTypeName="color";class sl extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}sl.prototype.ValueTypeName="number";class rl extends ki{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)si.slerpFlat(s,0,r,l-a,r,l,o);return s}}class sa extends Mn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new rl(this.times,this.values,this.getValueSize(),e)}}sa.prototype.ValueTypeName="quaternion";sa.prototype.InterpolantFactoryMethodSmooth=void 0;class Hi extends Mn{constructor(e,t,n){super(e,t,n)}}Hi.prototype.ValueTypeName="string";Hi.prototype.ValueBufferType=Array;Hi.prototype.DefaultInterpolation=2300;Hi.prototype.InterpolantFactoryMethodLinear=void 0;Hi.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="vector";class ol{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 ph=new ol;class ll{constructor(e){if(this.manager=e!==void 0?e:ph,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}}ll.DEFAULT_MATERIAL_NAME="__DEFAULT";class ra extends Xt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ve(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 Va=new Tt,rc=new O,ac=new O;class cl{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 Tt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qs,this._frameExtents=new ze(1,1),this._viewportCount=1,this._viewports=[new At(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;rc.setFromMatrixPosition(e.matrixWorld),t.position.copy(rc),ac.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ac),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Va.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Va,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(Va)}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 Dr=new O,Ur=new si,Un=new O;class aa extends Xt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Tt,this.projectionMatrix=new Tt,this.projectionMatrixInverse=new Tt,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(Dr,Ur,Un),Un.x===1&&Un.y===1&&Un.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Dr,Ur,Un.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Dr,Ur,Un),Un.x===1&&Un.y===1&&Un.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Dr,Ur,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var pi=new O,oc=new ze,lc=new ze;class cn extends aa{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=Fr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ya*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Fr*2*Math.atan(Math.tan(ya*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){pi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(pi.x,pi.y).multiplyScalar(-e/pi.z),pi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(pi.x,pi.y).multiplyScalar(-e/pi.z)}getViewSize(e,t){return this.getViewBounds(e,oc,lc),t.subVectors(lc,oc)}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(ya*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 Ys extends aa{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 mh extends cl{constructor(){super(new Ys(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class oa extends ra{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 mh}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 la extends ra{constructor(e,t){super(e,t);this.isAmbientLight=!0,this.type="AmbientLight"}}var hs=-90,us=1;class hl extends Xt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new cn(hs,us,e,t);i.layers=this.layers,this.add(i);let s=new cn(hs,us,e,t);s.layers=this.layers,this.add(s);let r=new cn(hs,us,e,t);r.layers=this.layers,this.add(r);let a=new cn(hs,us,e,t);a.layers=this.layers,this.add(a);let o=new cn(hs,us,e,t);o.layers=this.layers,this.add(o);let l=new cn(hs,us,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 ul extends cn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}var dl="\\[\\]\\.:\\/",td=new RegExp("["+dl+"]","g"),fl="[^"+dl+"]",nd="[^"+dl.replace("\\.","")+"]",id=/((?:WC+[\/:])*)/.source.replace("WC",fl),sd=/(WCOD+)?/.source.replace("WCOD",nd),rd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fl),ad=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fl),od=new RegExp("^"+id+sd+rd+ad+"$"),ld=["material","materials","bones","map"];class gh{constructor(e,t,n){let i=n||dt.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 dt{constructor(e,t,n){this.path=t,this.parsedPath=n||dt.parseTrackName(t),this.node=dt.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 dt(e,t,n);else return new dt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(td,"")}static parseTrackName(e){let t=od.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(ld.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=dt.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){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("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){Fe("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){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("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){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Fe("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;Fe("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){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("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}}dt.Composite=gh;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var S0=new Float32Array(1);var cc=new Tt;class ca{constructor(e,t,n=0,i=1/0){this.ray=new ta(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new ks,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 Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return cc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cc),this}intersectObject(e,t=!0,n=[]){return Wa(e,this,n,t),n.sort(hc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Wa(e[i],this,n,t);return n.sort(hc),n}}function hc(e,t){return e.distance-t.distance}function Wa(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++)Wa(r[a],t,n,!0)}}class pl{static{pl.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 ml(e,t,n,i){let s=cd(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 cd(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 Bh(){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 hd(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 ud=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`;class Sn extends vi{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ku,this.fragmentShader=Qu,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=Fi(e.uniforms),this.uniformsGroups=$u(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 Ve().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 St().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 $o extends Sn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ti extends vi{constructor(e){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ve(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(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 Ko extends vi{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 Qo extends vi{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 gs(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 Ha(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}class Oi{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 jo extends Oi{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 el extends Oi{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 tl extends Oi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class nl extends Oi{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=ed(n,t,f,y,i);s[p]=fh(w,v,E,b,T)}return s}}function fh(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 ju(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 ed(e,t,n,i,s){let r=(e-t)/(s-t);for(let a=0;a<8;a++){let o=fh(r,t,n,i,s)-e;if(Math.abs(o)<0.0000000001)break;let l=ju(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=gs(t,this.TimeBufferType),this.values=gs(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:gs(e.times,Array),values:gs(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Ha(e.settings))n.settings={inTangents:gs(e.settings.inTangents,Array),outTangents:gs(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new tl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new el(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new nl(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(Ha(this.settings))sc(this.settings.inTangents,e),sc(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)Fe("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Fe("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)){Fe("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(r!==null&&r>o){Fe("KeyframeTrack: Out of order keys.",this,a,o,r),e=!1;break}r=o}if(i!==void 0){if(Iu(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Fe("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,Ha(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function sc(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 Bi extends Mn{constructor(e,t,n){super(e,t,n)}}Bi.prototype.ValueTypeName="bool";Bi.prototype.ValueBufferType=Array;Bi.prototype.DefaultInterpolation=2300;Bi.prototype.InterpolantFactoryMethodLinear=void 0;Bi.prototype.InterpolantFactoryMethodSmooth=void 0;class il extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}il.prototype.ValueTypeName="color";class sl extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}sl.prototype.ValueTypeName="number";class rl extends Oi{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)ei.slerpFlat(s,0,r,l-a,r,l,o);return s}}class sa extends Mn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new rl(this.times,this.values,this.getValueSize(),e)}}sa.prototype.ValueTypeName="quaternion";sa.prototype.InterpolantFactoryMethodSmooth=void 0;class zi extends Mn{constructor(e,t,n){super(e,t,n)}}zi.prototype.ValueTypeName="string";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=2300;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Mn{constructor(e,t,n,i){super(e,t,n,i)}}al.prototype.ValueTypeName="vector";class ol{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 ph=new ol;class ll{constructor(e){if(this.manager=e!==void 0?e:ph,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}}ll.DEFAULT_MATERIAL_NAME="__DEFAULT";class ra extends Xt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Ve(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 Va=new St,rc=new O,ac=new O;class cl{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 St,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new js,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;rc.setFromMatrixPosition(e.matrixWorld),t.position.copy(rc),ac.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ac),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Va.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Va,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(Va)}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 Ir=new O,Pr=new ei,Dn=new O;class aa extends Xt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new St,this.projectionMatrix=new St,this.projectionMatrixInverse=new St,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(Ir,Pr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ir,Pr,Dn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ir,Pr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ir,Pr,Dn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var pi=new O,oc=new ze,lc=new ze;class on extends aa{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=Lr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ya*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Lr*2*Math.atan(Math.tan(ya*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){pi.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(pi.x,pi.y).multiplyScalar(-e/pi.z),pi.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(pi.x,pi.y).multiplyScalar(-e/pi.z)}getViewSize(e,t){return this.getViewBounds(e,oc,lc),t.subVectors(lc,oc)}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(ya*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 er extends aa{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 mh extends cl{constructor(){super(new er(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class oa extends ra{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 mh}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 la extends ra{constructor(e,t){super(e,t);this.isAmbientLight=!0,this.type="AmbientLight"}}var _s=-90,xs=1;class hl extends Xt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new on(_s,xs,e,t);i.layers=this.layers,this.add(i);let s=new on(_s,xs,e,t);s.layers=this.layers,this.add(s);let r=new on(_s,xs,e,t);r.layers=this.layers,this.add(r);let a=new on(_s,xs,e,t);a.layers=this.layers,this.add(a);let o=new on(_s,xs,e,t);o.layers=this.layers,this.add(o);let l=new on(_s,xs,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 ul extends on{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}var dl="\\[\\]\\.:\\/",td=new RegExp("["+dl+"]","g"),fl="[^"+dl+"]",nd="[^"+dl.replace("\\.","")+"]",id=/((?:WC+[\/:])*)/.source.replace("WC",fl),sd=/(WCOD+)?/.source.replace("WCOD",nd),rd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fl),ad=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fl),od=new RegExp("^"+id+sd+rd+ad+"$"),ld=["material","materials","bones","map"];class gh{constructor(e,t,n){let i=n||dt.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 dt{constructor(e,t,n){this.path=t,this.parsedPath=n||dt.parseTrackName(t),this.node=dt.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 dt(e,t,n);else return new dt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(td,"")}static parseTrackName(e){let t=od.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(ld.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=dt.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){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("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){Fe("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){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("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){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Fe("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;Fe("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){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("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}}dt.Composite=gh;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var S0=new Float32Array(1);var cc=new St;class ca{constructor(e,t,n=0,i=1/0){this.ray=new ta(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ys,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 Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return cc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cc),this}intersectObject(e,t=!0,n=[]){return Wa(e,this,n,t),n.sort(hc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Wa(e[i],this,n,t);return n.sort(hc),n}}function hc(e,t){return e.distance-t.distance}function Wa(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++)Wa(r[a],t,n,!0)}}class pl{static{pl.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 ml(e,t,n,i){let s=cd(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 cd(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 Bh(){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 hd(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 ud=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
7
|
#endif`,dd=`#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
|
-
}`,Ye={alphahash_fragment:ud,alphahash_pars_fragment:dd,alphamap_fragment:fd,alphamap_pars_fragment:pd,alphatest_fragment:md,alphatest_pars_fragment:gd,aomap_fragment:_d,aomap_pars_fragment:xd,batching_pars_vertex:vd,batching_vertex:yd,begin_vertex:Sd,beginnormal_vertex:Md,bsdfs:bd,iridescence_fragment:Td,bumpmap_pars_fragment:wd,clipping_planes_fragment:Ed,clipping_planes_pars_fragment:Ad,clipping_planes_pars_vertex:Cd,clipping_planes_vertex:Rd,color_fragment:Id,color_pars_fragment:Pd,color_pars_vertex:Ld,color_vertex:Nd,common:Dd,cube_uv_reflection_fragment:Ud,defaultnormal_vertex:Fd,displacementmap_pars_vertex:Od,displacementmap_vertex:Bd,emissivemap_fragment:zd,emissivemap_pars_fragment:kd,colorspace_fragment:Gd,colorspace_pars_fragment:Hd,envmap_fragment:Vd,envmap_common_pars_fragment:Wd,envmap_pars_fragment:Xd,envmap_pars_vertex:qd,envmap_physical_pars_fragment:sf,envmap_vertex:Yd,fog_vertex:Zd,fog_pars_vertex:Jd,fog_fragment:$d,fog_pars_fragment:Kd,gradientmap_pars_fragment:Qd,lightmap_pars_fragment:jd,lights_lambert_fragment:ef,lights_lambert_pars_fragment:tf,lights_pars_begin:nf,lights_toon_fragment:rf,lights_toon_pars_fragment:af,lights_phong_fragment:of,lights_phong_pars_fragment:lf,lights_physical_fragment:cf,lights_physical_pars_fragment:hf,lights_fragment_begin:uf,lights_fragment_maps:df,lights_fragment_end:ff,lightprobes_pars_fragment:pf,logdepthbuf_fragment:mf,logdepthbuf_pars_fragment:gf,logdepthbuf_pars_vertex:_f,logdepthbuf_vertex:xf,map_fragment:vf,map_pars_fragment:yf,map_particle_fragment:Sf,map_particle_pars_fragment:Mf,metalnessmap_fragment:bf,metalnessmap_pars_fragment:Tf,morphinstance_vertex:wf,morphcolor_vertex:Ef,morphnormal_vertex:Af,morphtarget_pars_vertex:Cf,morphtarget_vertex:Rf,normal_fragment_begin:If,normal_fragment_maps:Pf,normal_pars_fragment:Lf,normal_pars_vertex:Nf,normal_vertex:Df,normalmap_pars_fragment:Uf,clearcoat_normal_fragment_begin:Ff,clearcoat_normal_fragment_maps:Of,clearcoat_pars_fragment:Bf,iridescence_pars_fragment:zf,opaque_fragment:kf,packing:Gf,premultiplied_alpha_fragment:Hf,project_vertex:Vf,dithering_fragment:Wf,dithering_pars_fragment:Xf,roughnessmap_fragment:qf,roughnessmap_pars_fragment:Yf,shadowmap_pars_fragment:Zf,shadowmap_pars_vertex:Jf,shadowmap_vertex:$f,shadowmask_pars_fragment:Kf,skinbase_vertex:Qf,skinning_pars_vertex:jf,skinning_vertex:ep,skinnormal_vertex:tp,specularmap_fragment:np,specularmap_pars_fragment:ip,tonemapping_fragment:sp,tonemapping_pars_fragment:rp,transmission_fragment:ap,transmission_pars_fragment:op,uv_pars_fragment:lp,uv_pars_vertex:cp,uv_vertex:hp,worldpos_vertex:up,background_vert:dp,background_frag:fp,backgroundCube_vert:pp,backgroundCube_frag:mp,cube_vert:gp,cube_frag:_p,depth_vert:xp,depth_frag:vp,distance_vert:yp,distance_frag:Sp,equirect_vert:Mp,equirect_frag:bp,linedashed_vert:Tp,linedashed_frag:wp,meshbasic_vert:Ep,meshbasic_frag:Ap,meshlambert_vert:Cp,meshlambert_frag:Rp,meshmatcap_vert:Ip,meshmatcap_frag:Pp,meshnormal_vert:Lp,meshnormal_frag:Np,meshphong_vert:Dp,meshphong_frag:Up,meshphysical_vert:Fp,meshphysical_frag:Op,meshtoon_vert:Bp,meshtoon_frag:zp,points_vert:kp,points_frag:Gp,shadow_vert:Hp,shadow_frag:Vp,sprite_vert:Wp,sprite_frag:Xp},me={common:{diffuse:{value:new Ve(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 Ve(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 Ve(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 Ve(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:an([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:an([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ve(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:an([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:an([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:an([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ve(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:an([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:an([me.points,me.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:an([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:an([me.common,me.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:an([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:an([me.sprite,me.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:an([me.common,me.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:an([me.lights,me.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Wn.physical={uniforms:an([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 Ve(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 Ve(0)},specularColor:{value:new Ve(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:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var ha={r:0,b:0,g:0},qp=new Tt,zh=new ke;zh.set(-1,0,0,0,1,0,0,0,1);function Yp(e,t,n,i,s,r){let a=new Ve(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===Us)){if(c===void 0)c=new Ge(new Hn(1,1,1),new Sn({name:"BackgroundCubeMaterial",uniforms:zi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Yt,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(qp.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(zh);if(c.material.toneMapped=et.getTransfer(y.colorSpace)!==yt,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 It(2,2),new Sn({name:"BackgroundMaterial",uniforms:zi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:ms,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=et.getTransfer(y.colorSpace)!==yt,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(ha,Jo(e)),n.buffers.color.setClear(ha.r,ha.g,ha.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 Zp(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(R,U,W,I,H){let ee=!1,G=d(R,I,W,U);if(r!==G)r=G,c(r.object);if(ee=p(R,I,W,H),ee)v(R,I,W,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(ee||a){if(a=!1,y(R,U,W,I),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,I){let H=I.wireframe===!0,ee=i[U.id];if(ee===void 0)ee={},i[U.id]=ee;let G=R.isInstancedMesh===!0?R.id:0,se=ee[G];if(se===void 0)se={},ee[G]=se;let Y=se[W.id];if(Y===void 0)Y={},se[W.id]=Y;let te=Y[H];if(te===void 0)te=h(l()),Y[H]=te;return te}function h(R){let U=[],W=[],I=[];for(let H=0;H<n;H++)U[H]=0,W[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:I,object:R,attributes:{},index:null}}function p(R,U,W,I){let H=r.attributes,ee=U.attributes,G=0,se=W.getAttributes();for(let Y in se)if(se[Y].location>=0){let j=H[Y],ve=ee[Y];if(ve===void 0){if(Y==="instanceMatrix"&&R.instanceMatrix)ve=R.instanceMatrix;if(Y==="instanceColor"&&R.instanceColor)ve=R.instanceColor}if(j===void 0)return!0;if(j.attribute!==ve)return!0;if(ve&&j.data!==ve.data)return!0;G++}if(r.attributesNum!==G)return!0;if(r.index!==I)return!0;return!1}function v(R,U,W,I){let H={},ee=U.attributes,G=0,se=W.getAttributes();for(let Y in se)if(se[Y].location>=0){let j=ee[Y];if(j===void 0){if(Y==="instanceMatrix"&&R.instanceMatrix)j=R.instanceMatrix;if(Y==="instanceColor"&&R.instanceColor)j=R.instanceColor}let ve={};if(ve.attribute=j,j&&j.data)ve.data=j.data;H[Y]=ve,G++}r.attributes=H,r.attributesNum=G,r.index=I}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,I=r.enabledAttributes,H=r.attributeDivisors;if(W[R]=1,I[R]===0)e.enableVertexAttribArray(R),I[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,I=U.length;W<I;W++)if(U[W]!==R[W])e.disableVertexAttribArray(W),U[W]=0}function C(R,U,W,I,H,ee,G){if(G===!0)e.vertexAttribIPointer(R,U,W,H,ee);else e.vertexAttribPointer(R,U,W,I,H,ee)}function y(R,U,W,I){T();let H=I.attributes,ee=W.getAttributes(),G=U.defaultAttributeValues;for(let se in ee){let Y=ee[se];if(Y.location>=0){let te=H[se];if(te===void 0){if(se==="instanceMatrix"&&R.instanceMatrix)te=R.instanceMatrix;if(se==="instanceColor"&&R.instanceColor)te=R.instanceColor}if(te!==void 0){let j=te.normalized,ve=te.itemSize,Se=t.get(te);if(Se===void 0)continue;let{buffer:$e,type:Ue,bytesPerElement:q}=Se,ae=Ue===e.INT||Ue===e.UNSIGNED_INT||te.gpuType===no;if(te.isInterleavedBufferAttribute){let oe=te.data,Te=oe.stride,Le=te.offset;if(oe.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Y.locationSize;Ne++)f(Y.location+Ne,oe.meshPerAttribute);if(R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=oe.meshPerAttribute*oe.count}else for(let Ne=0;Ne<Y.locationSize;Ne++)m(Y.location+Ne);e.bindBuffer(e.ARRAY_BUFFER,$e);for(let Ne=0;Ne<Y.locationSize;Ne++)C(Y.location+Ne,ve/Y.locationSize,Ue,j,Te*q,(Le+ve/Y.locationSize*Ne)*q,ae)}else{if(te.isInstancedBufferAttribute){for(let oe=0;oe<Y.locationSize;oe++)f(Y.location+oe,te.meshPerAttribute);if(R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=te.meshPerAttribute*te.count}else for(let oe=0;oe<Y.locationSize;oe++)m(Y.location+oe);e.bindBuffer(e.ARRAY_BUFFER,$e);for(let oe=0;oe<Y.locationSize;oe++)C(Y.location+oe,ve/Y.locationSize,Ue,j,ve*q,ve/Y.locationSize*oe*q,ae)}}else if(G!==void 0){let j=G[se];if(j!==void 0)switch(j.length){case 2:e.vertexAttrib2fv(Y.location,j);break;case 3:e.vertexAttrib3fv(Y.location,j);break;case 4:e.vertexAttrib4fv(Y.location,j);break;default:e.vertexAttrib1fv(Y.location,j)}}}}E()}function b(){M();for(let R in i){let U=i[R];for(let W in U){let I=U[W];for(let H in I){let ee=I[H];for(let G in ee)u(ee[G].object),delete ee[G];delete I[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 I=U[W];for(let H in I){let ee=I[H];for(let G in ee)u(ee[G].object),delete ee[G];delete I[H]}}delete i[R.id]}function A(R){for(let U in i){let W=i[U];for(let I in W){let H=W[I];if(H[R.id]===void 0)continue;let ee=H[R.id];for(let G in ee)u(ee[G].object),delete ee[G];delete H[R.id]}}}function _(R){for(let U in i){let W=i[U],I=R.isInstancedMesh===!0?R.id:0,H=W[I];if(H===void 0)continue;for(let ee in H){let G=H[ee];for(let se in G)u(G[se].object),delete G[se];delete H[ee]}if(delete W[I],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 Jp(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 $p(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===kn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==pn&&A!==ni&&!_&&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 Kp(e){let t=this,n=null,i=0,s=!1,r=!1,a=new Fn,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 Ms=4,Qp=6,jp=20,em=256,Zs=new Ys,_h=new Ve,gl=null,_l=0,xl=0,vl=!1,tm=new O,Vi=new O;class Ml{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=tm}=s;gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),vl=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=yh(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=vh(),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(gl,_l,xl),this._renderer.xr.enabled=vl,e.scissorTest=!1,Ss(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===_s||e.mapping===Pi)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),vl=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:rn,minFilter:rn,generateMipmaps:!1,type:kn,format:Gn,colorSpace:ko,depthBuffer:!1},i=xh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=xh(e,t,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=nm(s)),this._blurMaterial=sm(s,e,t),this._ggxMaterial=im(s,e,t)}return i}_compileMaterial(e){let t=new Ge(new gn,e);this._renderer.compile(t,Zs)}_sceneToCubeUV(e,t,n,i,s){let o=new cn(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(_h),u.toneMapping=Pn,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 zt({name:"PMREM.Background",side:Yt,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(_h),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(Ss(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===_s||e.mapping===Pi;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=yh();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=vh();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;Ss(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(r,Zs)}_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-Ms?n-p+Ms:0),m=4*(this._cubeSize-v);o.envMap.value=e.texture,o.roughness.value=h,o.mipInt.value=p-t,Ss(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,Zs),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,Ss(e,T,m,3*v,2*v),i.setRenderTarget(e),i.render(a,Zs)}_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-Ms?i-this._lodMax+Ms:0),d=4*(this._cubeSize-c);Ss(t,u,d,3*c,2*c),r.setRenderTarget(t),r.render(o,Zs)}}function nm(e){let t=[],n=[],i=e,s=e-Ms+1+Qp;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)Vi.set(1,A,w);else if(f===1)Vi.set(-w,1,-A);else if(f===2)Vi.set(-w,A,1);else if(f===3)Vi.set(-1,A,-w);else if(f===4)Vi.set(-w,-1,A);else Vi.set(w,A,-1);Vi.toArray(T,(f*h+b)*p)}}let m=new gn;if(m.setAttribute("position",new yn(v,p)),m.setAttribute("outputDirection",new yn(T,p)),n.push(new Ge(m,null)),i>Ms)i--}return{lodMeshes:n,sizeLods:t}}function xh(e,t,n){let i=new mn(e,t,n);return i.texture.mapping=Us,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ss(e,t,n,i,s){e.viewport.set(t,n,i,s),e.scissor.set(t,n,i,s)}function im(e,t,n){return new Sn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:em,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:da(),fragmentShader:`
|
|
3823
|
+
}`,Ye={alphahash_fragment:ud,alphahash_pars_fragment:dd,alphamap_fragment:fd,alphamap_pars_fragment:pd,alphatest_fragment:md,alphatest_pars_fragment:gd,aomap_fragment:_d,aomap_pars_fragment:xd,batching_pars_vertex:vd,batching_vertex:yd,begin_vertex:Sd,beginnormal_vertex:Md,bsdfs:bd,iridescence_fragment:Td,bumpmap_pars_fragment:wd,clipping_planes_fragment:Ed,clipping_planes_pars_fragment:Ad,clipping_planes_pars_vertex:Cd,clipping_planes_vertex:Rd,color_fragment:Id,color_pars_fragment:Pd,color_pars_vertex:Ld,color_vertex:Nd,common:Dd,cube_uv_reflection_fragment:Ud,defaultnormal_vertex:Fd,displacementmap_pars_vertex:Od,displacementmap_vertex:Bd,emissivemap_fragment:zd,emissivemap_pars_fragment:kd,colorspace_fragment:Gd,colorspace_pars_fragment:Hd,envmap_fragment:Vd,envmap_common_pars_fragment:Wd,envmap_pars_fragment:Xd,envmap_pars_vertex:qd,envmap_physical_pars_fragment:sf,envmap_vertex:Yd,fog_vertex:Zd,fog_pars_vertex:Jd,fog_fragment:$d,fog_pars_fragment:Kd,gradientmap_pars_fragment:Qd,lightmap_pars_fragment:jd,lights_lambert_fragment:ef,lights_lambert_pars_fragment:tf,lights_pars_begin:nf,lights_toon_fragment:rf,lights_toon_pars_fragment:af,lights_phong_fragment:of,lights_phong_pars_fragment:lf,lights_physical_fragment:cf,lights_physical_pars_fragment:hf,lights_fragment_begin:uf,lights_fragment_maps:df,lights_fragment_end:ff,lightprobes_pars_fragment:pf,logdepthbuf_fragment:mf,logdepthbuf_pars_fragment:gf,logdepthbuf_pars_vertex:_f,logdepthbuf_vertex:xf,map_fragment:vf,map_pars_fragment:yf,map_particle_fragment:Sf,map_particle_pars_fragment:Mf,metalnessmap_fragment:bf,metalnessmap_pars_fragment:Tf,morphinstance_vertex:wf,morphcolor_vertex:Ef,morphnormal_vertex:Af,morphtarget_pars_vertex:Cf,morphtarget_vertex:Rf,normal_fragment_begin:If,normal_fragment_maps:Pf,normal_pars_fragment:Lf,normal_pars_vertex:Nf,normal_vertex:Df,normalmap_pars_fragment:Uf,clearcoat_normal_fragment_begin:Ff,clearcoat_normal_fragment_maps:Of,clearcoat_pars_fragment:Bf,iridescence_pars_fragment:zf,opaque_fragment:kf,packing:Gf,premultiplied_alpha_fragment:Hf,project_vertex:Vf,dithering_fragment:Wf,dithering_pars_fragment:Xf,roughnessmap_fragment:qf,roughnessmap_pars_fragment:Yf,shadowmap_pars_fragment:Zf,shadowmap_pars_vertex:Jf,shadowmap_vertex:$f,shadowmask_pars_fragment:Kf,skinbase_vertex:Qf,skinning_pars_vertex:jf,skinning_vertex:ep,skinnormal_vertex:tp,specularmap_fragment:np,specularmap_pars_fragment:ip,tonemapping_fragment:sp,tonemapping_pars_fragment:rp,transmission_fragment:ap,transmission_pars_fragment:op,uv_pars_fragment:lp,uv_pars_vertex:cp,uv_vertex:hp,worldpos_vertex:up,background_vert:dp,background_frag:fp,backgroundCube_vert:pp,backgroundCube_frag:mp,cube_vert:gp,cube_frag:_p,depth_vert:xp,depth_frag:vp,distance_vert:yp,distance_frag:Sp,equirect_vert:Mp,equirect_frag:bp,linedashed_vert:Tp,linedashed_frag:wp,meshbasic_vert:Ep,meshbasic_frag:Ap,meshlambert_vert:Cp,meshlambert_frag:Rp,meshmatcap_vert:Ip,meshmatcap_frag:Pp,meshnormal_vert:Lp,meshnormal_frag:Np,meshphong_vert:Dp,meshphong_frag:Up,meshphysical_vert:Fp,meshphysical_frag:Op,meshtoon_vert:Bp,meshtoon_frag:zp,points_vert:kp,points_frag:Gp,shadow_vert:Hp,shadow_frag:Vp,sprite_vert:Wp,sprite_frag:Xp},me={common:{diffuse:{value:new Ve(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 Ve(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 Ve(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 Ve(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:sn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:sn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ve(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:sn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:sn([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:sn([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ve(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:sn([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:sn([me.points,me.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:sn([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:sn([me.common,me.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:sn([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:sn([me.sprite,me.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:sn([me.common,me.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:sn([me.lights,me.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Vn.physical={uniforms:sn([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 Ve(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 Ve(0)},specularColor:{value:new Ve(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:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var ha={r:0,b:0,g:0},qp=new St,zh=new ke;zh.set(-1,0,0,0,1,0,0,0,1);function Yp(e,t,n,i,s,r){let a=new Ve(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===Hs)){if(c===void 0)c=new Ge(new Gn(1,1,1),new Sn({name:"BackgroundCubeMaterial",uniforms:Fi(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(qp.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(zh);if(c.material.toneMapped=je.getTransfer(y.colorSpace)!==xt,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 Ct(2,2),new Sn({name:"BackgroundMaterial",uniforms:Fi(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:Ms,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)!==xt,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(ha,Jo(e)),n.buffers.color.setClear(ha.r,ha.g,ha.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 Zp(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(R,U,W,I,H){let ee=!1,G=d(R,I,W,U);if(r!==G)r=G,c(r.object);if(ee=p(R,I,W,H),ee)v(R,I,W,H);if(H!==null)t.update(H,e.ELEMENT_ARRAY_BUFFER);if(ee||a){if(a=!1,y(R,U,W,I),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,I){let H=I.wireframe===!0,ee=i[U.id];if(ee===void 0)ee={},i[U.id]=ee;let G=R.isInstancedMesh===!0?R.id:0,se=ee[G];if(se===void 0)se={},ee[G]=se;let Y=se[W.id];if(Y===void 0)Y={},se[W.id]=Y;let te=Y[H];if(te===void 0)te=h(l()),Y[H]=te;return te}function h(R){let U=[],W=[],I=[];for(let H=0;H<n;H++)U[H]=0,W[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:I,object:R,attributes:{},index:null}}function p(R,U,W,I){let H=r.attributes,ee=U.attributes,G=0,se=W.getAttributes();for(let Y in se)if(se[Y].location>=0){let j=H[Y],ve=ee[Y];if(ve===void 0){if(Y==="instanceMatrix"&&R.instanceMatrix)ve=R.instanceMatrix;if(Y==="instanceColor"&&R.instanceColor)ve=R.instanceColor}if(j===void 0)return!0;if(j.attribute!==ve)return!0;if(ve&&j.data!==ve.data)return!0;G++}if(r.attributesNum!==G)return!0;if(r.index!==I)return!0;return!1}function v(R,U,W,I){let H={},ee=U.attributes,G=0,se=W.getAttributes();for(let Y in se)if(se[Y].location>=0){let j=ee[Y];if(j===void 0){if(Y==="instanceMatrix"&&R.instanceMatrix)j=R.instanceMatrix;if(Y==="instanceColor"&&R.instanceColor)j=R.instanceColor}let ve={};if(ve.attribute=j,j&&j.data)ve.data=j.data;H[Y]=ve,G++}r.attributes=H,r.attributesNum=G,r.index=I}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,I=r.enabledAttributes,H=r.attributeDivisors;if(W[R]=1,I[R]===0)e.enableVertexAttribArray(R),I[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,I=U.length;W<I;W++)if(U[W]!==R[W])e.disableVertexAttribArray(W),U[W]=0}function C(R,U,W,I,H,ee,G){if(G===!0)e.vertexAttribIPointer(R,U,W,H,ee);else e.vertexAttribPointer(R,U,W,I,H,ee)}function y(R,U,W,I){T();let H=I.attributes,ee=W.getAttributes(),G=U.defaultAttributeValues;for(let se in ee){let Y=ee[se];if(Y.location>=0){let te=H[se];if(te===void 0){if(se==="instanceMatrix"&&R.instanceMatrix)te=R.instanceMatrix;if(se==="instanceColor"&&R.instanceColor)te=R.instanceColor}if(te!==void 0){let j=te.normalized,ve=te.itemSize,Se=t.get(te);if(Se===void 0)continue;let{buffer:Je,type:Ue,bytesPerElement:q}=Se,ae=Ue===e.INT||Ue===e.UNSIGNED_INT||te.gpuType===no;if(te.isInterleavedBufferAttribute){let oe=te.data,Te=oe.stride,Le=te.offset;if(oe.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Y.locationSize;Ne++)f(Y.location+Ne,oe.meshPerAttribute);if(R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=oe.meshPerAttribute*oe.count}else for(let Ne=0;Ne<Y.locationSize;Ne++)m(Y.location+Ne);e.bindBuffer(e.ARRAY_BUFFER,Je);for(let Ne=0;Ne<Y.locationSize;Ne++)C(Y.location+Ne,ve/Y.locationSize,Ue,j,Te*q,(Le+ve/Y.locationSize*Ne)*q,ae)}else{if(te.isInstancedBufferAttribute){for(let oe=0;oe<Y.locationSize;oe++)f(Y.location+oe,te.meshPerAttribute);if(R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=te.meshPerAttribute*te.count}else for(let oe=0;oe<Y.locationSize;oe++)m(Y.location+oe);e.bindBuffer(e.ARRAY_BUFFER,Je);for(let oe=0;oe<Y.locationSize;oe++)C(Y.location+oe,ve/Y.locationSize,Ue,j,ve*q,ve/Y.locationSize*oe*q,ae)}}else if(G!==void 0){let j=G[se];if(j!==void 0)switch(j.length){case 2:e.vertexAttrib2fv(Y.location,j);break;case 3:e.vertexAttrib3fv(Y.location,j);break;case 4:e.vertexAttrib4fv(Y.location,j);break;default:e.vertexAttrib1fv(Y.location,j)}}}}E()}function b(){M();for(let R in i){let U=i[R];for(let W in U){let I=U[W];for(let H in I){let ee=I[H];for(let G in ee)u(ee[G].object),delete ee[G];delete I[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 I=U[W];for(let H in I){let ee=I[H];for(let G in ee)u(ee[G].object),delete ee[G];delete I[H]}}delete i[R.id]}function A(R){for(let U in i){let W=i[U];for(let I in W){let H=W[I];if(H[R.id]===void 0)continue;let ee=H[R.id];for(let G in ee)u(ee[G].object),delete ee[G];delete H[R.id]}}}function _(R){for(let U in i){let W=i[U],I=R.isInstancedMesh===!0?R.id:0,H=W[I];if(H===void 0)continue;for(let ee in H){let G=H[ee];for(let se in G)u(G[se].object),delete G[se];delete H[ee]}if(delete W[I],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 Jp(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 $p(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!==dn&&A!==Qn&&!_&&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 Kp(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 Rs=4,Qp=6,jp=20,em=256,tr=new er,_h=new Ve,gl=null,_l=0,xl=0,vl=!1,tm=new O,ki=new O;class Ml{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=tm}=s;gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),vl=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=yh(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=vh(),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(gl,_l,xl),this._renderer.xr.enabled=vl,e.scissorTest=!1,Cs(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ts||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);gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),vl=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:nn,minFilter:nn,generateMipmaps:!1,type:zn,format:kn,colorSpace:ko,depthBuffer:!1},i=xh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=xh(e,t,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=nm(s)),this._blurMaterial=sm(s,e,t),this._ggxMaterial=im(s,e,t)}return i}_compileMaterial(e){let t=new Ge(new pn,e);this._renderer.compile(t,tr)}_sceneToCubeUV(e,t,n,i,s){let o=new on(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(_h),u.toneMapping=In,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 Ft({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(_h),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(Cs(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===Ts||e.mapping===Ci;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=yh();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=vh();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;Cs(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(r,tr)}_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-Rs?n-p+Rs:0),m=4*(this._cubeSize-v);o.envMap.value=e.texture,o.roughness.value=h,o.mipInt.value=p-t,Cs(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,tr),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,Cs(e,T,m,3*v,2*v),i.setRenderTarget(e),i.render(a,tr)}_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-Rs?i-this._lodMax+Rs:0),d=4*(this._cubeSize-c);Cs(t,u,d,3*c,2*c),r.setRenderTarget(t),r.render(o,tr)}}function nm(e){let t=[],n=[],i=e,s=e-Rs+1+Qp;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)ki.set(1,A,w);else if(f===1)ki.set(-w,1,-A);else if(f===2)ki.set(-w,A,1);else if(f===3)ki.set(-1,A,-w);else if(f===4)ki.set(-w,-1,A);else ki.set(w,A,-1);ki.toArray(T,(f*h+b)*p)}}let m=new pn;if(m.setAttribute("position",new vn(v,p)),m.setAttribute("outputDirection",new vn(T,p)),n.push(new Ge(m,null)),i>Rs)i--}return{lodMeshes:n,sizeLods:t}}function xh(e,t,n){let i=new fn(e,t,n);return i.texture.mapping=Hs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Cs(e,t,n,i,s){e.viewport.set(t,n,i,s),e.scissor.set(t,n,i,s)}function im(e,t,n){return new Sn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:em,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:da(),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:
|
|
3927
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function sm(e,t,n){return new Sn({name:"SphericalGaussianBlur",defines:{SAMPLES:jp,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:da(),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:
|
|
3987
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function vh(){return new Sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:da(),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:
|
|
4006
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function yh(){return new Sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:da(),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:
|
|
4022
|
+
`,blending:On,depthTest:!1,depthWrite:!1})}function da(){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 wl extends
|
|
4037
|
+
`}class wl extends fn{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 na(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:Fi(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===Ri)t.minFilter=nn;return new hl(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 rm(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===Nr||p===Dr)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 wl(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===Nr||p===Dr,T=p===Ts||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 Ml(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 Ml(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===Nr)h.mapping=Ts;else if(p===Dr)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 am(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 om(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?ea:Qr)(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 lm(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 cm(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:Fe("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 hm(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=Qn,A.needsUpdate=!0;let _=C*4;for(let B=0;B<d;B++){let R=m[B],U=f[B],W=E[B],I=y*b*4*B;for(let H=0;H<R.count;H++){let ee=H*_;if(p===!0)s.fromBufferAttribute(R,H),w[I+ee+0]=s.x,w[I+ee+1]=s.y,w[I+ee+2]=s.z,w[I+ee+3]=0;if(v===!0)s.fromBufferAttribute(U,H),w[I+ee+4]=s.x,w[I+ee+5]=s.y,w[I+ee+6]=s.z,w[I+ee+7]=0;if(T===!0)s.fromBufferAttribute(W,H),w[I+ee+8]=s.x,w[I+ee+9]=s.y,w[I+ee+10]=s.z,w[I+ee+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 um(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 dm={[Ja]:"LINEAR_TONE_MAPPING",[$a]:"REINHARD_TONE_MAPPING",[Ka]:"CINEON_TONE_MAPPING",[Qa]:"ACES_FILMIC_TONE_MAPPING",[eo]:"AGX_TONE_MAPPING",[to]:"NEUTRAL_TONE_MAPPING",[ja]:"CUSTOM_TONE_MAPPING"};function fm(e,t,n,i,s,r){let a=new fn(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 pn;c.setAttribute("position",new Kt([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Kt([0,2,0,0,2,0],2));let u=new $o({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 er(-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 fn(b,w,{type:zn,depthBuffer:!1,stencilBuffer:!1}),l=new fn(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===In&&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=In,!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)===xt)u.defines.SRGB_TRANSFER="";let _=dm[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 kh=new $t,bl=new Ui(1,1),Gh=new Zr,Hh=new qo,Vh=new na,Sh=[],Mh=[],bh=new Float32Array(16),Th=new Float32Array(9),wh=new Float32Array(4);function Is(e,t,n){let i=e[0];if(i<=0||i>0)return e;let s=t*n,r=Sh[s];if(r===void 0)r=new Float32Array(s),Sh[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 Gt(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 Vt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function fa(e,t){let n=Mh[t];if(n===void 0)n=new Int32Array(t),Mh[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function pm(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function mm(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(Gt(n,t))return;e.uniform2fv(this.addr,t),Vt(n,t)}}function gm(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(Gt(n,t))return;e.uniform3fv(this.addr,t),Vt(n,t)}}function _m(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(Gt(n,t))return;e.uniform4fv(this.addr,t),Vt(n,t)}}function xm(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Gt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Vt(n,t)}else{if(Gt(n,i))return;wh.set(i),e.uniformMatrix2fv(this.addr,!1,wh),Vt(n,i)}}function vm(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Gt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Vt(n,t)}else{if(Gt(n,i))return;Th.set(i),e.uniformMatrix3fv(this.addr,!1,Th),Vt(n,i)}}function ym(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Gt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Vt(n,t)}else{if(Gt(n,i))return;bh.set(i),e.uniformMatrix4fv(this.addr,!1,bh),Vt(n,i)}}function Sm(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function Mm(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(Gt(n,t))return;e.uniform2iv(this.addr,t),Vt(n,t)}}function bm(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(Gt(n,t))return;e.uniform3iv(this.addr,t),Vt(n,t)}}function Tm(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(Gt(n,t))return;e.uniform4iv(this.addr,t),Vt(n,t)}}function wm(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function Em(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(Gt(n,t))return;e.uniform2uiv(this.addr,t),Vt(n,t)}}function Am(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(Gt(n,t))return;e.uniform3uiv(this.addr,t),Vt(n,t)}}function Cm(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(Gt(n,t))return;e.uniform4uiv(this.addr,t),Vt(n,t)}}function Rm(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)bl.compareFunction=n.isReversedDepthBuffer()?qr:Xr,r=bl;else r=kh;n.setTexture2D(t||r,s)}function Im(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||Hh,s)}function Pm(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||Vh,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.setTexture2DArray(t||Gh,s)}function Nm(e){switch(e){case 5126:return pm;case 35664:return mm;case 35665:return gm;case 35666:return _m;case 35674:return xm;case 35675:return vm;case 35676:return ym;case 5124:case 35670:return Sm;case 35667:case 35671:return Mm;case 35668:case 35672:return bm;case 35669:case 35673:return Tm;case 5125:return wm;case 36294:return Em;case 36295:return Am;case 36296:return Cm;case 35678:case 36198:case 36298:case 36306:case 35682:return Rm;case 35679:case 36299:case 36307:return Im;case 35680:case 36300:case 36308:case 36293:return Pm;case 36289:case 36303:case 36311:case 36292:return Lm}}function Dm(e,t){e.uniform1fv(this.addr,t)}function Um(e,t){let n=Is(t,this.size,2);e.uniform2fv(this.addr,n)}function Fm(e,t){let n=Is(t,this.size,3);e.uniform3fv(this.addr,n)}function Om(e,t){let n=Is(t,this.size,4);e.uniform4fv(this.addr,n)}function Bm(e,t){let n=Is(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function zm(e,t){let n=Is(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function km(e,t){let n=Is(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Gm(e,t){e.uniform1iv(this.addr,t)}function Hm(e,t){e.uniform2iv(this.addr,t)}function Vm(e,t){e.uniform3iv(this.addr,t)}function Wm(e,t){e.uniform4iv(this.addr,t)}function Xm(e,t){e.uniform1uiv(this.addr,t)}function qm(e,t){e.uniform2uiv(this.addr,t)}function Ym(e,t){e.uniform3uiv(this.addr,t)}function Zm(e,t){e.uniform4uiv(this.addr,t)}function Jm(e,t,n){let i=this.cache,s=t.length,r=fa(n,s);if(!Gt(i,r))e.uniform1iv(this.addr,r),Vt(i,r);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=bl;else a=kh;for(let o=0;o!==s;++o)n.setTexture2D(t[o]||a,r[o])}function $m(e,t,n){let i=this.cache,s=t.length,r=fa(n,s);if(!Gt(i,r))e.uniform1iv(this.addr,r),Vt(i,r);for(let a=0;a!==s;++a)n.setTexture3D(t[a]||Hh,r[a])}function Km(e,t,n){let i=this.cache,s=t.length,r=fa(n,s);if(!Gt(i,r))e.uniform1iv(this.addr,r),Vt(i,r);for(let a=0;a!==s;++a)n.setTextureCube(t[a]||Vh,r[a])}function Qm(e,t,n){let i=this.cache,s=t.length,r=fa(n,s);if(!Gt(i,r))e.uniform1iv(this.addr,r),Vt(i,r);for(let a=0;a!==s;++a)n.setTexture2DArray(t[a]||Gh,r[a])}function jm(e){switch(e){case 5126:return Dm;case 35664:return Um;case 35665:return Fm;case 35666:return Om;case 35674:return Bm;case 35675:return zm;case 35676:return km;case 5124:case 35670:return Gm;case 35667:case 35671:return Hm;case 35668:case 35672:return Vm;case 35669:case 35673:return Wm;case 5125:return Xm;case 36294:return qm;case 36295:return Ym;case 36296:return Zm;case 35678:case 36198:case 36298:case 36306:case 35682:return Jm;case 35679:case 36299:case 36307:return $m;case 35680:case 36300:case 36308:case 36293:return Km;case 36289:case 36303:case 36311:case 36292:return Qm}}class Wh{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Nm(t.type)}}class Xh{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=jm(t.type)}}class qh{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 yl=/(\w+)(\])?(\[|\.)?/g;function Eh(e,t){e.seq.push(t),e.map[t.id]=t}function eg(e,t,n){let i=e.name,s=i.length;yl.lastIndex=0;while(!0){let r=yl.exec(i),a=yl.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l)o=o|0;if(c===void 0||c==="["&&a+2===s){Eh(n,c===void 0?new Wh(o,e,t):new Xh(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new qh(o),Eh(n,d);n=d}}}class rr{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);eg(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 Ah(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var tg=37297,ng=0;function ig(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 Ch=new ke;function sg(e){
|
|
4120
|
+
`)}var Ch=new ke;function sg(e){je._getMatrix(Ch,je.workingColorSpace,e);let t=`mat3( ${Ch.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case Go:return[t,"LinearTransferOETF"];case xt:return[t,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Rh(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
|
`+ig(e.getShaderSource(t),o)}else return r}function rg(e,t){let n=sg(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
|
|
4125
|
-
`)}var ag={[Ja]:"Linear",[$a]:"Reinhard",[Ka]:"Cineon",[Qa]:"ACESFilmic",[eo]:"AgX",[to]:"Neutral",[ja]:"Custom"};function og(e,t){let n=ag[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 ua=new O;function lg(){
|
|
4126
|
-
`)}function cg(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(
|
|
4125
|
+
`)}var ag={[Ja]:"Linear",[$a]:"Reinhard",[Ka]:"Cineon",[Qa]:"ACESFilmic",[eo]:"AgX",[to]:"Neutral",[ja]:"Custom"};function og(e,t){let n=ag[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 ua=new O;function lg(){je.getLuminanceCoefficients(ua);let e=ua.x.toFixed(4),t=ua.y.toFixed(4),n=ua.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
|
|
4126
|
+
`)}function cg(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ir).join(`
|
|
4127
4127
|
`)}function hg(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 ug(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 ug(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 ir(e){return e!==""}function Ih(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 Ph(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var dg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Tl(e){return e.replace(dg,pg)}var fg=new Map;function pg(e,t){let n=Ye[t];if(n===void 0){let i=fg.get(t);if(i!==void 0)n=Ye[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 Tl(n)}var mg=/#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 Lh(e){return e.replace(mg,gg)}function gg(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 Nh(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,15 +4145,15 @@ 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 _g={[
|
|
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 _g={[Gs]:"SHADOWMAP_TYPE_PCF",[Ss]:"SHADOWMAP_TYPE_VSM"};function xg(e){return _g[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var vg={[Ts]:"ENVMAP_TYPE_CUBE",[Ci]:"ENVMAP_TYPE_CUBE",[Hs]:"ENVMAP_TYPE_CUBE_UV"};function yg(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return vg[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var Sg={[Ci]:"ENVMAP_MODE_REFRACTION"};function Mg(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return Sg[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var bg={[Hc]:"ENVMAP_BLENDING_MULTIPLY",[Vc]:"ENVMAP_BLENDING_MIX",[Wc]:"ENVMAP_BLENDING_ADD"};function Tg(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return bg[e.combine]||"ENVMAP_BLENDING_NONE"}function wg(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 Eg(e,t,n,i){let s=e.getContext(),{defines:r,vertexShader:a,fragmentShader:o}=n,l=xg(n),c=yg(n),u=Mg(n),d=Tg(n),h=wg(n),p=cg(n),v=hg(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(ir).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(ir).join(`
|
|
4152
4152
|
`),f.length>0)f+=`
|
|
4153
4153
|
`}else m=[Nh(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(
|
|
4155
|
-
`),f=[Nh(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!==
|
|
4156
|
-
`].filter(
|
|
4154
|
+
`].filter(ir).join(`
|
|
4155
|
+
`),f=[Nh(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!==In?"#define TONE_MAPPING":"",n.toneMapping!==In?Ye.tonemapping_pars_fragment:"",n.toneMapping!==In?og("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,rg("linearToOutputTexel",n.outputColorSpace),lg(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
|
|
4156
|
+
`].filter(ir).join(`
|
|
4157
4157
|
`);if(a=Tl(a),a=Ih(a,n),a=Ph(a,n),o=Tl(o),o=Ih(o,n),o=Ph(o,n),a=Lh(a),o=Lh(o),n.isRawShaderMaterial!==!0)E=`#version 300 es
|
|
4158
4158
|
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4159
4159
|
`)+`
|
|
@@ -4166,7 +4166,7 @@ Material Type: `+R.type+`
|
|
|
4166
4166
|
|
|
4167
4167
|
Program Info Log: `+H+`
|
|
4168
4168
|
`+te+`
|
|
4169
|
-
`+j)}else if(H!=="")Oe("WebGLProgram: Program Info Log:",H);else if(ee===""||G==="")Y=!1;if(Y)R.diagnostics={runnable:se,programLog:H,vertexShader:{log:ee,prefix:m},fragmentShader:{log:G,prefix:f}}}s.deleteShader(b),s.deleteShader(w),_=new Ks(s,T),M=ug(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,tg);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=ng++,this.cacheKey=t,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=w,this}var Ag=0;class Yh{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 Zh(e),t.set(e,n);return n}}class Zh{constructor(e){this.id=Ag++,this.code=e,this.usedTimes=0}}function Cg(e){return e===Ui||e===Yr||e===Zr}function Rg(e,t,n,i,s,r){let a=new ks,o=new Yh,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 I=R.fog,H=U.geometry,ee=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,se=t.get(_.envMap||ee,G),Y=!!se&&se.mapping===Us?se.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 j=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,ve=j!==void 0?j.length:0,Se=0;if(H.morphAttributes.position!==void 0)Se=1;if(H.morphAttributes.normal!==void 0)Se=2;if(H.morphAttributes.color!==void 0)Se=3;let $e,Ue,q,ae;if(te){let ct=Wn[te];$e=ct.vertexShader,Ue=ct.fragmentShader}else{$e=_.vertexShader,Ue=_.fragmentShader;let ct=o.getVertexShaderStage(_),st=o.getFragmentShaderStage(_);o.update(_,ct,st),q=ct.id,ae=st.id}let oe=e.getRenderTarget(),Te=e.state.buffers.depth.getReversed(),Le=U.isInstancedMesh===!0,Ne=U.isBatchedMesh===!0,Ct=!!_.map,We=!!_.matcap,Ke=!!se,rt=!!_.aoMap,je=!!_.lightMap,Dt=!!_.bumpMap&&_.wireframe===!1,at=!!_.normalMap,kt=!!_.displacementMap,Et=!!_.emissiveMap,Rt=!!_.metalnessMap,L=!!_.roughnessMap,Gt=_.anisotropy>0,nt=_.clearcoat>0,xt=_.dispersion>0,S=_.retroreflectivity>0,g=_.iridescence>0,P=_.sheen>0,V=_.transmission>0,ne=Gt&&!!_.anisotropyMap,le=nt&&!!_.clearcoatMap,fe=nt&&!!_.clearcoatNormalMap,Z=nt&&!!_.clearcoatRoughnessMap,Q=g&&!!_.iridescenceMap,ge=g&&!!_.iridescenceThicknessMap,Ie=P&&!!_.sheenColorMap,ue=P&&!!_.sheenRoughnessMap,re=!!_.specularMap,Ee=!!_.specularColorMap,De=!!_.specularIntensityMap,Ze=V&&!!_.transmissionMap,N=V&&!!_.thicknessMap,he=!!_.gradientMap,K=!!_.alphaMap,de=_.alphaTest>0,ye=!!_.alphaHash,ie=!!_.extensions,pe=Pn;if(_.toneMapped){if(oe===null||oe.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:te,shaderType:_.type,shaderName:_.name,vertexShader:$e,fragmentShader:Ue,defines:_.defines,customVertexShaderID:q,customFragmentShaderID:ae,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Ne,batchingColor:Ne&&U._colorsTexture!==null,instancing:Le,instancingColor:Le&&U.instanceColor!==null,instancingMorph:Le&&U.morphTexture!==null,outputColorSpace:oe===null?e.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Ct,matcap:We,envMap:Ke,envMapMode:Ke&&se.mapping,envMapCubeUVHeight:Y,aoMap:rt,lightMap:je,bumpMap:Dt,normalMap:at,displacementMap:kt,emissiveMap:Et,normalMapObjectSpace:at&&_.normalMapType===jc,normalMapTangentSpace:at&&_.normalMapType===zo,packedNormalMap:at&&_.normalMapType===zo&&Cg(_.normalMap.format),metalnessMap:Rt,roughnessMap:L,anisotropy:Gt,anisotropyMap:ne,clearcoat:nt,clearcoatMap:le,clearcoatNormalMap:fe,clearcoatRoughnessMap:Z,dispersion:xt,retroreflection:S,iridescence:g,iridescenceMap:Q,iridescenceThicknessMap:ge,sheen:P,sheenColorMap:Ie,sheenRoughnessMap:ue,specularMap:re,specularColorMap:Ee,specularIntensityMap:De,transmission:V,transmissionMap:Ze,thicknessMap:N,gradientMap:he,opaque:_.transparent===!1&&_.blending===In&&_.alphaToCoverage===!1,alphaMap:K,alphaTest:de,alphaHash:ye,combine:_.combine,mapUv:Ct&&v(_.map.channel),aoMapUv:rt&&v(_.aoMap.channel),lightMapUv:je&&v(_.lightMap.channel),bumpMapUv:Dt&&v(_.bumpMap.channel),normalMapUv:at&&v(_.normalMap.channel),displacementMapUv:kt&&v(_.displacementMap.channel),emissiveMapUv:Et&&v(_.emissiveMap.channel),metalnessMapUv:Rt&&v(_.metalnessMap.channel),roughnessMapUv:L&&v(_.roughnessMap.channel),anisotropyMapUv:ne&&v(_.anisotropyMap.channel),clearcoatMapUv:le&&v(_.clearcoatMap.channel),clearcoatNormalMapUv:fe&&v(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Z&&v(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&v(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&v(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&v(_.sheenColorMap.channel),sheenRoughnessMapUv:ue&&v(_.sheenRoughnessMap.channel),specularMapUv:re&&v(_.specularMap.channel),specularColorMapUv:Ee&&v(_.specularColorMap.channel),specularIntensityMapUv:De&&v(_.specularIntensityMap.channel),transmissionMapUv:Ze&&v(_.transmissionMap.channel),thicknessMapUv:N&&v(_.thicknessMap.channel),alphaMapUv:K&&v(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(at||Gt),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!H.attributes.uv&&(Ct||K),fog:!!I,useFog:_.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&at===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Te,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:ve,morphTextureStride:Se,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:pe,decodeVideoTexture:Ct&&_.map.isVideoTexture===!0&&et.getTransfer(_.map.colorSpace)===yt,decodeVideoTextureEmissive:Et&&_.emissiveMap.isVideoTexture===!0&&et.getTransfer(_.emissiveMap.colorSpace)===yt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===hn,flipSided:_.side===Yt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ie&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ie&&_.extensions.multiDraw===!0||Ne)&&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=dh.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 Eg(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 Ig(){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 Pg(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 Dh(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 Uh(){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||Pg);if(i.length>1)i.sort(p||Dh);if(s.length>1)s.sort(p||Dh)}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 Lg(){let e=new WeakMap;function t(i,s){let r=e.get(i),a;if(r===void 0)a=new Uh,e.set(i,[a]);else if(s>=r.length)a=new Uh,r.push(a);else a=r[s];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ng(){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 Ve};break;case"SpotLight":n={position:new O,direction:new O,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":n={color:new Ve,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function Dg(){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 Ug=0;function Fg(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Og(e){let t=new Ng,n=Dg(),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 Tt,a=new Tt;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(Fg);for(let U=0,W=c.length;U<W;U++){let I=c[U],{color:H,intensity:ee,distance:G}=I,se=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===Ui)se=I.shadow.map.texture;else se=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=H.r*ee,d+=H.g*ee,h+=H.b*ee;else if(I.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(I.sh.coefficients[Y],ee);B++}else if(I.isSunLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize.copy(te.mapSize).multiply(te.getFrameExtents()),i.sunShadow[v]=j,i.sunShadowMap[v]=se;let ve=te.getViewportCount();for(let Se=0;Se<ve;Se++)i.sunShadowMatrix[T+Se]=te.getMatrix(Se),i.sunShadowCascade[T+Se]=te._cascadeData[Se];T+=ve,v++}i.sun[p]=Y,p++}else if(I.isDirectionalLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,i.directionalShadow[m]=j,i.directionalShadowMap[m]=se,i.directionalShadowMatrix[m]=I.shadow.matrix,b++}i.directional[m]=Y,m++}else if(I.isSpotLight){let Y=t.get(I);Y.position.setFromMatrixPosition(I.matrixWorld),Y.color.copy(H).multiplyScalar(ee),Y.distance=G,Y.coneCos=Math.cos(I.angle),Y.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),Y.decay=I.decay,i.spot[E]=Y;let te=I.shadow;if(I.map){if(i.spotLightMap[_]=I.map,_++,te.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[E]=te.matrix,I.castShadow){let j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,i.spotShadow[E]=j,i.spotShadowMap[E]=se,A++}E++}else if(I.isRectAreaLight){let Y=t.get(I);Y.color.copy(H).multiplyScalar(ee),Y.halfWidth.set(I.width*0.5,0,0),Y.halfHeight.set(0,I.height*0.5,0),i.rectArea[C]=Y,C++}else if(I.isPointLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),Y.distance=I.distance,Y.decay=I.decay,I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,j.shadowCameraNear=te.camera.near,j.shadowCameraFar=te.camera.far,i.pointShadow[f]=j,i.pointShadowMap[f]=se,i.pointShadowMatrix[f]=I.shadow.matrix,w++}i.point[f]=Y,f++}else if(I.isHemisphereLight){let Y=t.get(I);Y.skyColor.copy(I.color).multiplyScalar(ee),Y.groundColor.copy(I.groundColor).multiplyScalar(ee),i.hemi[y]=Y,y++}}if(C>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=me.LTC_FLOAT_1,i.rectAreaLTC2=me.LTC_FLOAT_2;else i.rectAreaLTC1=me.LTC_HALF_1,i.rectAreaLTC2=me.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=Ug++}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 Fh(e){let t=new Og(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 Bg(e){let t=new WeakMap;function n(s,r=0){let a=t.get(s),o;if(a===void 0)o=new Fh(e),t.set(s,[o]);else if(r>=a.length)o=new Fh(e),a.push(o);else o=a[r];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}var zg=`void main() {
|
|
4169
|
+
`+j)}else if(H!=="")Oe("WebGLProgram: Program Info Log:",H);else if(ee===""||G==="")Y=!1;if(Y)R.diagnostics={runnable:se,programLog:H,vertexShader:{log:ee,prefix:m},fragmentShader:{log:G,prefix:f}}}s.deleteShader(b),s.deleteShader(w),_=new rr(s,T),M=ug(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,tg);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=ng++,this.cacheKey=t,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=w,this}var Ag=0;class Yh{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 Zh(e),t.set(e,n);return n}}class Zh{constructor(e){this.id=Ag++,this.code=e,this.usedTimes=0}}function Cg(e){return e===Li||e===Gr||e===Vr}function Rg(e,t,n,i,s,r){let a=new Ys,o=new Yh,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 I=R.fog,H=U.geometry,ee=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,se=t.get(_.envMap||ee,G),Y=!!se&&se.mapping===Hs?se.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 j=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,ve=j!==void 0?j.length:0,Se=0;if(H.morphAttributes.position!==void 0)Se=1;if(H.morphAttributes.normal!==void 0)Se=2;if(H.morphAttributes.color!==void 0)Se=3;let Je,Ue,q,ae;if(te){let ct=Vn[te];Je=ct.vertexShader,Ue=ct.fragmentShader}else{Je=_.vertexShader,Ue=_.fragmentShader;let ct=o.getVertexShaderStage(_),it=o.getFragmentShaderStage(_);o.update(_,ct,it),q=ct.id,ae=it.id}let oe=e.getRenderTarget(),Te=e.state.buffers.depth.getReversed(),Le=U.isInstancedMesh===!0,Ne=U.isBatchedMesh===!0,Et=!!_.map,We=!!_.matcap,$e=!!se,st=!!_.aoMap,Qe=!!_.lightMap,Lt=!!_.bumpMap&&_.wireframe===!1,rt=!!_.normalMap,Ot=!!_.displacementMap,bt=!!_.emissiveMap,At=!!_.metalnessMap,L=!!_.roughnessMap,Bt=_.anisotropy>0,tt=_.clearcoat>0,mt=_.dispersion>0,S=_.retroreflectivity>0,g=_.iridescence>0,P=_.sheen>0,V=_.transmission>0,ne=Bt&&!!_.anisotropyMap,le=tt&&!!_.clearcoatMap,fe=tt&&!!_.clearcoatNormalMap,Z=tt&&!!_.clearcoatRoughnessMap,Q=g&&!!_.iridescenceMap,ge=g&&!!_.iridescenceThicknessMap,Ie=P&&!!_.sheenColorMap,ue=P&&!!_.sheenRoughnessMap,re=!!_.specularMap,Ee=!!_.specularColorMap,De=!!_.specularIntensityMap,Ze=V&&!!_.transmissionMap,N=V&&!!_.thicknessMap,he=!!_.gradientMap,K=!!_.alphaMap,de=_.alphaTest>0,ye=!!_.alphaHash,ie=!!_.extensions,pe=In;if(_.toneMapped){if(oe===null||oe.isXRRenderTarget===!0)pe=e.toneMapping}let Be={shaderID:te,shaderType:_.type,shaderName:_.name,vertexShader:Je,fragmentShader:Ue,defines:_.defines,customVertexShaderID:q,customFragmentShaderID:ae,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Ne,batchingColor:Ne&&U._colorsTexture!==null,instancing:Le,instancingColor:Le&&U.instanceColor!==null,instancingMorph:Le&&U.morphTexture!==null,outputColorSpace:oe===null?e.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Et,matcap:We,envMap:$e,envMapMode:$e&&se.mapping,envMapCubeUVHeight:Y,aoMap:st,lightMap:Qe,bumpMap:Lt,normalMap:rt,displacementMap:Ot,emissiveMap:bt,normalMapObjectSpace:rt&&_.normalMapType===jc,normalMapTangentSpace:rt&&_.normalMapType===zo,packedNormalMap:rt&&_.normalMapType===zo&&Cg(_.normalMap.format),metalnessMap:At,roughnessMap:L,anisotropy:Bt,anisotropyMap:ne,clearcoat:tt,clearcoatMap:le,clearcoatNormalMap:fe,clearcoatRoughnessMap:Z,dispersion:mt,retroreflection:S,iridescence:g,iridescenceMap:Q,iridescenceThicknessMap:ge,sheen:P,sheenColorMap:Ie,sheenRoughnessMap:ue,specularMap:re,specularColorMap:Ee,specularIntensityMap:De,transmission:V,transmissionMap:Ze,thicknessMap:N,gradientMap:he,opaque:_.transparent===!1&&_.blending===Rn&&_.alphaToCoverage===!1,alphaMap:K,alphaTest:de,alphaHash:ye,combine:_.combine,mapUv:Et&&v(_.map.channel),aoMapUv:st&&v(_.aoMap.channel),lightMapUv:Qe&&v(_.lightMap.channel),bumpMapUv:Lt&&v(_.bumpMap.channel),normalMapUv:rt&&v(_.normalMap.channel),displacementMapUv:Ot&&v(_.displacementMap.channel),emissiveMapUv:bt&&v(_.emissiveMap.channel),metalnessMapUv:At&&v(_.metalnessMap.channel),roughnessMapUv:L&&v(_.roughnessMap.channel),anisotropyMapUv:ne&&v(_.anisotropyMap.channel),clearcoatMapUv:le&&v(_.clearcoatMap.channel),clearcoatNormalMapUv:fe&&v(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Z&&v(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&v(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&v(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&v(_.sheenColorMap.channel),sheenRoughnessMapUv:ue&&v(_.sheenRoughnessMap.channel),specularMapUv:re&&v(_.specularMap.channel),specularColorMapUv:Ee&&v(_.specularColorMap.channel),specularIntensityMapUv:De&&v(_.specularIntensityMap.channel),transmissionMapUv:Ze&&v(_.transmissionMap.channel),thicknessMapUv:N&&v(_.thicknessMap.channel),alphaMapUv:K&&v(_.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(rt||Bt),vertexNormals:!!H.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!H.attributes.uv&&(Et||K),fog:!!I,useFog:_.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||H.attributes.normal===void 0&&rt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Te,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:ve,morphTextureStride:Se,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:pe,decodeVideoTexture:Et&&_.map.isVideoTexture===!0&&je.getTransfer(_.map.colorSpace)===xt,decodeVideoTextureEmissive:bt&&_.emissiveMap.isVideoTexture===!0&&je.getTransfer(_.emissiveMap.colorSpace)===xt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===ln,flipSided:_.side===qt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ie&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ie&&_.extensions.multiDraw===!0||Ne)&&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=dh.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 Eg(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 Ig(){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 Pg(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 Dh(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 Uh(){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||Pg);if(i.length>1)i.sort(p||Dh);if(s.length>1)s.sort(p||Dh)}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 Lg(){let e=new WeakMap;function t(i,s){let r=e.get(i),a;if(r===void 0)a=new Uh,e.set(i,[a]);else if(s>=r.length)a=new Uh,r.push(a);else a=r[s];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ng(){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 Ve};break;case"SpotLight":n={position:new O,direction:new O,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":n={color:new Ve,position:new O,halfWidth:new O,halfHeight:new O};break}return e[t.id]=n,n}}}function Dg(){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 Ug=0;function Fg(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Og(e){let t=new Ng,n=Dg(),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 St,a=new St;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(Fg);for(let U=0,W=c.length;U<W;U++){let I=c[U],{color:H,intensity:ee,distance:G}=I,se=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===Li)se=I.shadow.map.texture;else se=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=H.r*ee,d+=H.g*ee,h+=H.b*ee;else if(I.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(I.sh.coefficients[Y],ee);B++}else if(I.isSunLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize.copy(te.mapSize).multiply(te.getFrameExtents()),i.sunShadow[v]=j,i.sunShadowMap[v]=se;let ve=te.getViewportCount();for(let Se=0;Se<ve;Se++)i.sunShadowMatrix[T+Se]=te.getMatrix(Se),i.sunShadowCascade[T+Se]=te._cascadeData[Se];T+=ve,v++}i.sun[p]=Y,p++}else if(I.isDirectionalLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,i.directionalShadow[m]=j,i.directionalShadowMap[m]=se,i.directionalShadowMatrix[m]=I.shadow.matrix,b++}i.directional[m]=Y,m++}else if(I.isSpotLight){let Y=t.get(I);Y.position.setFromMatrixPosition(I.matrixWorld),Y.color.copy(H).multiplyScalar(ee),Y.distance=G,Y.coneCos=Math.cos(I.angle),Y.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),Y.decay=I.decay,i.spot[E]=Y;let te=I.shadow;if(I.map){if(i.spotLightMap[_]=I.map,_++,te.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[E]=te.matrix,I.castShadow){let j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,i.spotShadow[E]=j,i.spotShadowMap[E]=se,A++}E++}else if(I.isRectAreaLight){let Y=t.get(I);Y.color.copy(H).multiplyScalar(ee),Y.halfWidth.set(I.width*0.5,0,0),Y.halfHeight.set(0,I.height*0.5,0),i.rectArea[C]=Y,C++}else if(I.isPointLight){let Y=t.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),Y.distance=I.distance,Y.decay=I.decay,I.castShadow){let te=I.shadow,j=n.get(I);j.shadowIntensity=te.intensity,j.shadowBias=te.bias,j.shadowNormalBias=te.normalBias,j.shadowRadius=te.radius,j.shadowMapSize=te.mapSize,j.shadowCameraNear=te.camera.near,j.shadowCameraFar=te.camera.far,i.pointShadow[f]=j,i.pointShadowMap[f]=se,i.pointShadowMatrix[f]=I.shadow.matrix,w++}i.point[f]=Y,f++}else if(I.isHemisphereLight){let Y=t.get(I);Y.skyColor.copy(I.color).multiplyScalar(ee),Y.groundColor.copy(I.groundColor).multiplyScalar(ee),i.hemi[y]=Y,y++}}if(C>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=me.LTC_FLOAT_1,i.rectAreaLTC2=me.LTC_FLOAT_2;else i.rectAreaLTC1=me.LTC_HALF_1,i.rectAreaLTC2=me.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=Ug++}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 Fh(e){let t=new Og(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 Bg(e){let t=new WeakMap;function n(s,r=0){let a=t.get(s),o;if(a===void 0)o=new Fh(e),t.set(s,[o]);else if(r>=a.length)o=new Fh(e),a.push(o);else o=a[r];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}var zg=`void main() {
|
|
4170
4170
|
gl_Position = vec4( position, 1.0 );
|
|
4171
4171
|
}`,kg=`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
|
-
}`,Gg=[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)],Hg=[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)],Oh=new Tt,Js=new O,Sl=new O;function Vg(e,t,n){let i=new qs,s=new ze,r=new ze,a=new At,o=new Ko,l=new Qo,c={},u=n.maxTextureSize,d={[ms]:Yt,[Yt]:ms,[hn]:hn},h=new Sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:zg,fragmentShader:kg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new gn;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=Ds;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===pc)Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ds;let M=e.getRenderTarget(),B=e.getActiveCubeFace(),R=e.getActiveMipmapLevel(),U=e.state;if(U.setBlending(Bn),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(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((H)=>H.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,H=w.length;I<H;I++){let ee=w[I],G=ee.shadow;if(G===void 0){Oe("WebGLShadowMap:",ee,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let se=G.getFrameExtents();if(s.multiply(se),r.copy(G.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/se.x),s.x=r.x*se.x,G.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/se.y),s.y=r.y*se.y,G.mapSize.y=r.y}let Y=e.state.buffers.depth.getReversed();if(G.camera._reversedDepth=Y,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===ps){if(ee.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new mn(s.x,s.y,{format:Ui,type:kn,minFilter:rn,magFilter:rn,generateMipmaps:!1}),G.map.texture.name=ee.name+".shadowMap",G.map.depthTexture=new Bi(s.x,s.y,ni),G.map.depthTexture.name=ee.name+".shadowMapDepth",G.map.depthTexture.format=Ni,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ln,G.map.depthTexture.magFilter=Ln}else{if(ee.isPointLight)G.map=new wl(s.x),G.map.depthTexture=new Zo(s.x,xi);else G.map=new mn(s.x,s.y),G.map.depthTexture=new Bi(s.x,s.y,xi);if(G.map.depthTexture.name=ee.name+".shadowMap",G.map.depthTexture.format=Ni,this.type===Ds)G.map.depthTexture.compareFunction=Y?$r:Jr,G.map.depthTexture.minFilter=rn,G.map.depthTexture.magFilter=rn;else G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ln,G.map.depthTexture.magFilter=Ln}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(ee.isPointLight!==!0)G.updateMatrices(ee,_);for(let j=0;j<te;j++){let ve=G.getCamera(j);if(ee.isPointLight){let{camera:Se,matrix:$e}=G,Ue=ee.distance||Se.far;if(Ue!==Se.far)Se.far=Ue,Se.updateProjectionMatrix();Js.setFromMatrixPosition(ee.matrixWorld),Se.position.copy(Js),Sl.copy(Se.position),Sl.add(Gg[j]),Se.up.copy(Hg[j]),Se.lookAt(Sl),Se.updateMatrixWorld(),$e.makeTranslation(-Js.x,-Js.y,-Js.z),Oh.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),G._frustum.setFromProjectionMatrix(Oh,Se.coordinateSystem,Se.reversedDepth)}if(G.map.isWebGLCubeRenderTarget)e.setRenderTarget(G.map,j),e.clear();else{if(j===0)e.setRenderTarget(G.map),e.clear();let Se=G.getViewport(j);a.set(r.x*Se.x,r.y*Se.y,r.x*Se.z,r.y*Se.w),U.viewport(a)}i=G.getFrustum(j),y(A,_,ve,ee,this.type)}if(G.isPointLightShadow!==!0&&this.type===ps)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 mn(s.x,s.y,{format:Ui,type:kn});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,I=c[U];if(I===void 0)I={},c[U]=I;let H=I[W];if(H===void 0)H=B.clone(),I[W]=H,A.addEventListener("dispose",b);B=H}if(B.visible=A.visible,B.wireframe=A.wireframe,M===ps)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===ps)&&(!w.frustumCulled||w.intersectsFrustum(i))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let W=t.update(w),I=w.material;if(Array.isArray(I)){let H=W.groups;for(let ee=0,G=H.length;ee<G;ee++){let se=H[ee],Y=I[se.materialIndex];if(Y&&Y.visible){let te=C(w,Y,M,B);w.onBeforeShadow(e,w,A,_,W,te,se),e.renderBufferDirect(_,null,W,te,w,se),w.onAfterShadow(e,w,A,_,W,te,se)}}}else if(I.visible){let H=C(w,I,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,I=U.length;W<I;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 Wg(e,t){function n(){let N=!1,he=new At,K=null,de=new At(0,0,0,0);return{setMask:function(ye){if(K!==ye&&!N)e.colorMask(ye,ye,ye,ye),K=ye},setLocked:function(ye){N=ye},setClear:function(ye,ie,pe,Be,ct){if(ct===!0)ye*=Be,ie*=Be,pe*=Be;if(he.set(ye,ie,pe,Be),de.equals(he)===!1)e.clearColor(ye,ie,pe,Be),de.copy(he)},reset:function(){N=!1,K=null,de.set(-1,0,0,0)}}}function i(){let N=!1,he=!1,K=null,de=null,ye=null;return{setReversed:function(ie){if(he!==ie){let pe=t.get("EXT_clip_control");if(ie)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);he=ie;let Be=ye;ye=null,this.setClear(Be)}},getReversed:function(){return he},setTest:function(ie){if(ie)oe(e.DEPTH_TEST);else Te(e.DEPTH_TEST)},setMask:function(ie){if(K!==ie&&!N)e.depthMask(ie),K=ie},setFunc:function(ie){if(he)ie=ch[ie];if(de!==ie){switch(ie){case Uc:e.depthFunc(e.NEVER);break;case Fc:e.depthFunc(e.ALWAYS);break;case Oc:e.depthFunc(e.LESS);break;case Za:e.depthFunc(e.LEQUAL);break;case Bc:e.depthFunc(e.EQUAL);break;case zc:e.depthFunc(e.GEQUAL);break;case kc:e.depthFunc(e.GREATER);break;case Gc:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}de=ie}},setLocked:function(ie){N=ie},setClear:function(ie){if(ye!==ie){if(ye=ie,he)ie=1-ie;e.clearDepth(ie)}},reset:function(){N=!1,K=null,de=null,ye=null,he=!1}}}function s(){let N=!1,he=null,K=null,de=null,ye=null,ie=null,pe=null,Be=null,ct=null;return{setTest:function(st){if(!N)if(st)oe(e.STENCIL_TEST);else Te(e.STENCIL_TEST)},setMask:function(st){if(he!==st&&!N)e.stencilMask(st),he=st},setFunc:function(st,F,J){if(K!==st||de!==F||ye!==J)e.stencilFunc(st,F,J),K=st,de=F,ye=J},setOp:function(st,F,J){if(ie!==st||pe!==F||Be!==J)e.stencilOp(st,F,J),ie=st,pe=F,Be=J},setLocked:function(st){N=st},setClear:function(st){if(ct!==st)e.clearStencil(st),ct=st},reset:function(){N=!1,he=null,K=null,de=null,ye=null,ie=null,pe=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 Ve(0,0,0),M=0,B=!1,R=null,U=null,W=null,I=null,H=null,ee=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),G=!1,se=0,Y=e.getParameter(e.VERSION);if(Y.indexOf("WebGL")!==-1)se=parseFloat(/^WebGL (\d)/.exec(Y)[1]),G=se>=1;else if(Y.indexOf("OpenGL ES")!==-1)se=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),G=se>=2;let te=null,j={},ve=e.getParameter(e.SCISSOR_BOX),Se=e.getParameter(e.VIEWPORT),$e=new At().fromArray(ve),Ue=new At().fromArray(Se);function q(N,he,K,de){let ye=new Uint8Array(4),ie=e.createTexture();e.bindTexture(N,ie),e.texParameteri(N,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(N,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<K;pe++)if(N===e.TEXTURE_3D||N===e.TEXTURE_2D_ARRAY)e.texImage3D(he,0,e.RGBA,1,1,de,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(he+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ie}let ae={};ae[e.TEXTURE_2D]=q(e.TEXTURE_2D,e.TEXTURE_2D,1),ae[e.TEXTURE_CUBE_MAP]=q(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[e.TEXTURE_2D_ARRAY]=q(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),ae[e.TEXTURE_3D]=q(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),oe(e.DEPTH_TEST),a.setFunc(Za),Dt(!1),at(Xa),oe(e.CULL_FACE),rt(Bn);function oe(N){if(u[N]!==!0)e.enable(N),u[N]=!0}function Te(N){if(u[N]!==!1)e.disable(N),u[N]=!1}function Le(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 Ne(N,he){let K=v,de=!1;if(N){if(K=p.get(he),K===void 0)K=[],p.set(he,K);let ye=N.textures;if(K.length!==ye.length||K[0]!==e.COLOR_ATTACHMENT0){for(let ie=0,pe=ye.length;ie<pe;ie++)K[ie]=e.COLOR_ATTACHMENT0+ie;K.length=ye.length,de=!0}}else if(K[0]!==e.BACK)K[0]=e.BACK,de=!0;if(de)e.drawBuffers(K)}function Ct(N){if(T!==N)return e.useProgram(N),T=N,!0;return!1}let We={[gs]:e.FUNC_ADD,[gc]:e.FUNC_SUBTRACT,[_c]:e.FUNC_REVERSE_SUBTRACT};We[xc]=e.MIN,We[vc]=e.MAX;let Ke={[yc]:e.ZERO,[Sc]:e.ONE,[Mc]:e.SRC_COLOR,[Tc]:e.SRC_ALPHA,[Ic]:e.SRC_ALPHA_SATURATE,[Cc]:e.DST_COLOR,[Ec]:e.DST_ALPHA,[bc]:e.ONE_MINUS_SRC_COLOR,[wc]:e.ONE_MINUS_SRC_ALPHA,[Rc]:e.ONE_MINUS_DST_COLOR,[Ac]:e.ONE_MINUS_DST_ALPHA,[Pc]:e.CONSTANT_COLOR,[Lc]:e.ONE_MINUS_CONSTANT_COLOR,[Nc]:e.CONSTANT_ALPHA,[Dc]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(N,he,K,de,ye,ie,pe,Be,ct,st){if(N===Bn){if(m===!0)Te(e.BLEND),m=!1;return}if(m===!1)oe(e.BLEND),m=!0;if(N!==mc){if(N!==f||st!==B){if(E!==gs||b!==gs)e.blendEquation(e.FUNC_ADD),E=gs,b=gs;if(st)switch(N){case In:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ti:e.blendFunc(e.ONE,e.ONE);break;case qa:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Ya:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Fe("WebGLState: Invalid blending: ",N);break}else switch(N){case In:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ti:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case qa:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ya:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",N);break}C=null,y=null,w=null,A=null,_.set(0,0,0),M=0,f=N,B=st}return}if(ye=ye||he,ie=ie||K,pe=pe||de,he!==E||ye!==b)e.blendEquationSeparate(We[he],We[ye]),E=he,b=ye;if(K!==C||de!==y||ie!==w||pe!==A)e.blendFuncSeparate(Ke[K],Ke[de],Ke[ie],Ke[pe]),C=K,y=de,w=ie,A=pe;if(Be.equals(_)===!1||ct!==M)e.blendColor(Be.r,Be.g,Be.b,ct),_.copy(Be),M=ct;f=N,B=!1}function je(N,he){N.side===hn?Te(e.CULL_FACE):oe(e.CULL_FACE);let K=N.side===Yt;if(he)K=!K;Dt(K),N.blending===In&&N.transparent===!1?rt(Bn):rt(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 de=N.stencilWrite;if(o.setTest(de),de)o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass);Et(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?oe(e.SAMPLE_ALPHA_TO_COVERAGE):Te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Dt(N){if(R!==N){if(N)e.frontFace(e.CW);else e.frontFace(e.CCW);R=N}}function at(N){if(N!==dc){if(oe(e.CULL_FACE),N!==U)if(N===Xa)e.cullFace(e.BACK);else if(N===fc)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Te(e.CULL_FACE);U=N}function kt(N){if(N!==W){if(G)e.lineWidth(N);W=N}}function Et(N,he,K){if(N){if(oe(e.POLYGON_OFFSET_FILL),I!==he||H!==K){if(I=he,H=K,a.getReversed())he=-he;e.polygonOffset(he,K)}}else Te(e.POLYGON_OFFSET_FILL)}function Rt(N){if(N)oe(e.SCISSOR_TEST);else Te(e.SCISSOR_TEST)}function L(N){if(N===void 0)N=e.TEXTURE0+ee-1;if(te!==N)e.activeTexture(N),te=N}function Gt(N,he,K){if(K===void 0)if(te===null)K=e.TEXTURE0+ee-1;else K=te;let de=j[K];if(de===void 0)de={type:void 0,texture:void 0},j[K]=de;if(de.type!==N||de.texture!==he){if(te!==K)e.activeTexture(K),te=K;e.bindTexture(N,he||ae[N]),de.type=N,de.texture=he}}function nt(){let N=j[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){Fe("WebGLState:",N)}}function S(){try{e.compressedTexImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function g(){try{e.texSubImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function P(){try{e.texSubImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function ne(){try{e.compressedTexSubImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function le(){try{e.texStorage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function fe(){try{e.texStorage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function Z(){try{e.texImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function Q(){try{e.texImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function ge(N){if(d[N]!==void 0)return d[N];else return e.getParameter(N)}function Ie(N,he){if(d[N]!==he)e.pixelStorei(N,he),d[N]=he}function ue(N){if($e.equals(N)===!1)e.scissor(N.x,N.y,N.z,N.w),$e.copy(N)}function re(N){if(Ue.equals(N)===!1)e.viewport(N.x,N.y,N.z,N.w),Ue.copy(N)}function Ee(N,he){let K=c.get(he);if(K===void 0)K=new WeakMap,c.set(he,K);let de=K.get(N);if(de===void 0)de=e.getUniformBlockIndex(he,N.name),K.set(N,de)}function De(N,he){let de=c.get(he).get(N);if(l.get(he)!==de)e.uniformBlockBinding(he,de,N.__bindingPointIndex),l.set(he,de)}function Ze(){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,j={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new Ve(0,0,0),M=0,B=!1,R=null,U=null,W=null,I=null,H=null,$e.set(0,0,e.canvas.width,e.canvas.height),Ue.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:oe,disable:Te,bindFramebuffer:Le,drawBuffers:Ne,useProgram:Ct,setBlending:rt,setMaterial:je,setFlipSided:Dt,setCullFace:at,setLineWidth:kt,setPolygonOffset:Et,setScissorTest:Rt,activeTexture:L,bindTexture:Gt,unbindTexture:nt,compressedTexImage2D:xt,compressedTexImage3D:S,texImage2D:Z,texImage3D:Q,pixelStorei:Ie,getParameter:ge,updateUBOMapping:Ee,uniformBlockBinding:De,texStorage2D:le,texStorage3D:fe,texSubImage2D:g,texSubImage3D:P,compressedTexSubImage2D:V,compressedTexSubImage3D:ne,scissor:ue,viewport:re,reset:Ze}}function Xg(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):Ps("canvas")}function m(S,g,P){let V=1,ne=xt(S);if(ne.width>P||ne.height>P)V=P/Math.max(ne.width,ne.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*ne.width),fe=Math.floor(V*ne.height);if(h===void 0)h=T(le,fe);let Z=g?T(le,fe):h;return Z.width=le,Z.height=fe,Z.getContext("2d").drawImage(S,0,0,le,fe),Oe("WebGLRenderer: Texture has been resized from ("+ne.width+"x"+ne.height+") to ("+le+"x"+fe+")."),Z}else{if("data"in S)Oe("WebGLRenderer: Image in DataTexture is too big ("+ne.width+"x"+ne.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,P,V,ne,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 fe;if(V){if(fe=t.get("EXT_texture_norm16"),!fe)Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Z=g;if(g===e.RED){if(P===e.FLOAT)Z=e.R32F;if(P===e.HALF_FLOAT)Z=e.R16F;if(P===e.UNSIGNED_BYTE)Z=e.R8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.R16_EXT;if(P===e.SHORT&&fe)Z=fe.R16_SNORM_EXT}if(g===e.RED_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.R8UI;if(P===e.UNSIGNED_SHORT)Z=e.R16UI;if(P===e.UNSIGNED_INT)Z=e.R32UI;if(P===e.BYTE)Z=e.R8I;if(P===e.SHORT)Z=e.R16I;if(P===e.INT)Z=e.R32I}if(g===e.RG){if(P===e.FLOAT)Z=e.RG32F;if(P===e.HALF_FLOAT)Z=e.RG16F;if(P===e.UNSIGNED_BYTE)Z=e.RG8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RG16_EXT;if(P===e.SHORT&&fe)Z=fe.RG16_SNORM_EXT}if(g===e.RG_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RG8UI;if(P===e.UNSIGNED_SHORT)Z=e.RG16UI;if(P===e.UNSIGNED_INT)Z=e.RG32UI;if(P===e.BYTE)Z=e.RG8I;if(P===e.SHORT)Z=e.RG16I;if(P===e.INT)Z=e.RG32I}if(g===e.RGB_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RGB8UI;if(P===e.UNSIGNED_SHORT)Z=e.RGB16UI;if(P===e.UNSIGNED_INT)Z=e.RGB32UI;if(P===e.BYTE)Z=e.RGB8I;if(P===e.SHORT)Z=e.RGB16I;if(P===e.INT)Z=e.RGB32I}if(g===e.RGBA_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RGBA8UI;if(P===e.UNSIGNED_SHORT)Z=e.RGBA16UI;if(P===e.UNSIGNED_INT)Z=e.RGBA32UI;if(P===e.BYTE)Z=e.RGBA8I;if(P===e.SHORT)Z=e.RGBA16I;if(P===e.INT)Z=e.RGBA32I}if(g===e.RGB){if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RGB16_EXT;if(P===e.SHORT&&fe)Z=fe.RGB16_SNORM_EXT;if(P===e.UNSIGNED_INT_5_9_9_9_REV)Z=e.RGB9_E5;if(P===e.UNSIGNED_INT_10F_11F_11F_REV)Z=e.R11F_G11F_B10F}if(g===e.RGBA){let Q=le?Go:et.getTransfer(ne);if(P===e.FLOAT)Z=e.RGBA32F;if(P===e.HALF_FLOAT)Z=e.RGBA16F;if(P===e.UNSIGNED_BYTE)Z=Q===yt?e.SRGB8_ALPHA8:e.RGBA8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RGBA16_EXT;if(P===e.SHORT&&fe)Z=fe.RGBA16_SNORM_EXT;if(P===e.UNSIGNED_SHORT_4_4_4_4)Z=e.RGBA4;if(P===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 P;if(S){if(g===null||g===xi||g===xs)P=e.DEPTH24_STENCIL8;else if(g===ni)P=e.DEPTH32F_STENCIL8;else if(g===Bs)P=e.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(g===null||g===xi||g===xs)P=e.DEPTH_COMPONENT24;else if(g===ni)P=e.DEPTH_COMPONENT32F;else if(g===Bs)P=e.DEPTH_COMPONENT16;return P}function w(S,g){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==Ln&&S.minFilter!==rn)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 P=S.source,V=p.get(P);if(V){let ne=V[g.__cacheKey];if(ne.usedTimes--,ne.usedTimes===0)B(S);if(Object.keys(V).length===0)p.delete(P)}i.remove(S)}function B(S){let g=i.get(S);e.deleteTexture(g.__webglTexture);let P=S.source,V=p.get(P);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 ne=0;ne<g.__webglFramebuffer[V].length;ne++)e.deleteFramebuffer(g.__webglFramebuffer[V][ne]);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 P=S.textures;for(let V=0,ne=P.length;V<ne;V++){let le=i.get(P[V]);if(le.__webglTexture)e.deleteTexture(le.__webglTexture),a.memory.textures--;i.remove(P[V])}i.remove(S)}let U=0;function W(){U=0}function I(){return U}function H(S){U=S}function ee(){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 se(S,g){let P=i.get(S);if(S.isVideoTexture)Gt(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&P.__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{Te(P,S,g);return}}else if(S.isExternalTexture)P.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,P.__webglTexture,e.TEXTURE0+g)}function Y(S,g){let P=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&P.__version!==S.version){Te(P,S,g);return}else if(S.isExternalTexture)P.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,P.__webglTexture,e.TEXTURE0+g)}function te(S,g){let P=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&P.__version!==S.version){Te(P,S,g);return}n.bindTexture(e.TEXTURE_3D,P.__webglTexture,e.TEXTURE0+g)}function j(S,g){let P=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&P.__version!==S.version){Le(P,S,g);return}n.bindTexture(e.TEXTURE_CUBE_MAP,P.__webglTexture,e.TEXTURE0+g)}let ve={[Fs]:e.REPEAT,[zn]:e.CLAMP_TO_EDGE,[Xc]:e.MIRRORED_REPEAT},Se={[Ln]:e.NEAREST,[qc]:e.NEAREST_MIPMAP_NEAREST,[Os]:e.NEAREST_MIPMAP_LINEAR,[rn]:e.LINEAR,[Gr]:e.LINEAR_MIPMAP_NEAREST,[Li]:e.LINEAR_MIPMAP_LINEAR},$e={[eh]:e.NEVER,[rh]:e.ALWAYS,[th]:e.LESS,[Jr]:e.LEQUAL,[nh]:e.EQUAL,[$r]:e.GEQUAL,[ih]:e.GREATER,[sh]:e.NOTEQUAL};function Ue(S,g){if(g.type===ni&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===rn||g.magFilter===Gr||g.magFilter===Os||g.magFilter===Li||g.minFilter===rn||g.minFilter===Gr||g.minFilter===Os||g.minFilter===Li))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,ve[g.wrapS]),e.texParameteri(S,e.TEXTURE_WRAP_T,ve[g.wrapT]),S===e.TEXTURE_3D||S===e.TEXTURE_2D_ARRAY)e.texParameteri(S,e.TEXTURE_WRAP_R,ve[g.wrapR]);if(e.texParameteri(S,e.TEXTURE_MAG_FILTER,Se[g.magFilter]),e.texParameteri(S,e.TEXTURE_MIN_FILTER,Se[g.minFilter]),g.compareFunction)e.texParameteri(S,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(S,e.TEXTURE_COMPARE_FUNC,$e[g.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Ln)return;if(g.minFilter!==Os&&g.minFilter!==Li)return;if(g.type===ni&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||i.get(g).__currentAnisotropy){let P=t.get("EXT_texture_filter_anisotropic");e.texParameterf(S,P.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),i.get(g).__currentAnisotropy=g.anisotropy}}}function q(S,g){let P=!1;if(S.__webglInit===void 0)S.__webglInit=!0,g.addEventListener("dispose",A);let V=g.source,ne=p.get(V);if(ne===void 0)ne={},p.set(V,ne);let le=G(g);if(le!==S.__cacheKey){if(ne[le]===void 0)ne[le]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,P=!0;ne[le].usedTimes++;let fe=ne[S.__cacheKey];if(fe!==void 0){if(ne[S.__cacheKey].usedTimes--,fe.usedTimes===0)B(g)}S.__cacheKey=le,S.__webglTexture=ne[le].texture}return P}function ae(S,g,P){return Math.floor(Math.floor(S/P)/g)}function oe(S,g,P,V){let le=S.updateRanges;if(le.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,g.width,g.height,P,V,g.data);else{le.sort((Ie,ue)=>Ie.start-ue.start);let fe=0;for(let Ie=1;Ie<le.length;Ie++){let ue=le[fe],re=le[Ie],Ee=ue.start+ue.count,De=ae(re.start,g.width,4),Ze=ae(ue.start,g.width,4);if(re.start<=Ee+1&&De===Ze&&ae(re.start+re.count-1,g.width,4)===De)ue.count=Math.max(ue.count,re.start+re.count-ue.start);else++fe,le[fe]=re}le.length=fe+1;let Z=n.getParameter(e.UNPACK_ROW_LENGTH),Q=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,g.width);for(let Ie=0,ue=le.length;Ie<ue;Ie++){let re=le[Ie],Ee=Math.floor(re.start/4),De=Math.ceil(re.count/4),Ze=Ee%g.width,N=Math.floor(Ee/g.width),he=De,K=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Ze),n.pixelStorei(e.UNPACK_SKIP_ROWS,N),n.texSubImage2D(e.TEXTURE_2D,0,Ze,N,he,1,P,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,ge)}}function Te(S,g,P){let V=e.TEXTURE_2D;if(g.isDataArrayTexture||g.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(g.isData3DTexture)V=e.TEXTURE_3D;let ne=q(S,g),le=g.source;n.bindTexture(V,S.__webglTexture,e.TEXTURE0+P);let fe=i.get(le);if(le.version!==fe.__version||ne===!0){if(n.activeTexture(e.TEXTURE0+P),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){let K=et.getPrimaries(et.workingColorSpace),de=g.colorSpace===Fi?null:et.getPrimaries(g.colorSpace),ye=g.colorSpace===Fi||K===de?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,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment);let Q=m(g.image,!1,s.maxTextureSize);Q=nt(g,Q);let ge=r.convert(g.format,g.colorSpace),Ie=r.convert(g.type),ue=y(g.internalFormat,ge,Ie,g.normalized,g.colorSpace,g.isVideoTexture);Ue(V,g);let re,Ee=g.mipmaps,De=g.isVideoTexture!==!0,Ze=fe.__version===void 0||ne===!0,N=le.dataReady,he=w(g,Q);if(g.isDepthTexture){if(ue=b(g.format===Di,g.type),Ze)if(De)n.texStorage2D(e.TEXTURE_2D,1,ue,Q.width,Q.height);else n.texImage2D(e.TEXTURE_2D,0,ue,Q.width,Q.height,0,ge,Ie,null)}else if(g.isDataTexture)if(Ee.length>0){if(De&&Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Ee[0].width,Ee[0].height);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,Ie,re.data)}else n.texImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,ge,Ie,re.data);g.generateMipmaps=!1}else if(De){if(Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Q.width,Q.height);if(N)oe(g,Q,ge,Ie)}else n.texImage2D(e.TEXTURE_2D,0,ue,Q.width,Q.height,0,ge,Ie,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){if(De&&Ze)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,ue,Ee[0].width,Ee[0].height,Q.depth);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],g.format!==Gn)if(ge!==null)if(De){if(N)if(g.layerUpdates.size>0){let ye=ml(re.width,re.height,g.format,g.type);for(let ie of g.layerUpdates){let pe=re.data.subarray(ie*ye/re.data.BYTES_PER_ELEMENT,(ie+1)*ye/re.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,ie,re.width,re.height,1,ge,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,re.width,re.height,Q.depth,ge,re.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,ue,re.width,re.height,Q.depth,0,re.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(N)n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,re.width,re.height,Q.depth,ge,Ie,re.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,K,ue,re.width,re.height,Q.depth,0,ge,Ie,re.data);if(g.layerUpdates.size>0)g.clearLayerUpdates()}else{if(De&&Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Ee[0].width,Ee[0].height);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],g.format!==Gn)if(ge!==null)if(De){if(N)n.compressedTexSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,re.data)}else n.compressedTexImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,re.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,Ie,re.data)}else n.texImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,ge,Ie,re.data)}else if(g.isDataArrayTexture)if(De){if(Ze)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,ue,Q.width,Q.height,Q.depth);if(N)if(g.layerUpdates.size>0){let K=ml(Q.width,Q.height,g.format,g.type);for(let de of g.layerUpdates){let ye=Q.data.subarray(de*K/Q.data.BYTES_PER_ELEMENT,(de+1)*K/Q.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,ge,Ie,ye)}g.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ge,Ie,Q.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ue,Q.width,Q.height,Q.depth,0,ge,Ie,Q.data);else if(g.isData3DTexture)if(De){if(Ze)n.texStorage3D(e.TEXTURE_3D,he,ue,Q.width,Q.height,Q.depth);if(N)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ge,Ie,Q.data)}else n.texImage3D(e.TEXTURE_3D,0,ue,Q.width,Q.height,Q.depth,0,ge,Ie,Q.data);else if(g.isFramebufferTexture){if(Ze)if(De)n.texStorage2D(e.TEXTURE_2D,he,ue,Q.width,Q.height);else{let K=Q.width,de=Q.height;for(let ye=0;ye<he;ye++)n.texImage2D(e.TEXTURE_2D,ye,ue,K,de,0,ge,Ie,null),K>>=1,de>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in e){let K=e.canvas;if(!K.hasAttribute("layoutsubtree"))K.setAttribute("layoutsubtree","true");if(Q.parentNode!==K){K.appendChild(Q),d.add(g),K.onpaint=(de)=>{let ye=de.changedElements;for(let ie of d)if(ye.includes(ie.image))ie.needsUpdate=!0},K.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,Q);else{let{RGBA:ye,RGBA:ie,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ie,pe,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(Ee.length>0){if(De&&Ze){let K=xt(Ee[0]);n.texStorage2D(e.TEXTURE_2D,he,ue,K.width,K.height)}for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,ge,Ie,re)}else n.texImage2D(e.TEXTURE_2D,K,ue,ge,Ie,re);g.generateMipmaps=!1}else if(De){if(Ze){let K=xt(Q);n.texStorage2D(e.TEXTURE_2D,he,ue,K.width,K.height)}if(N)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ie,Q)}else n.texImage2D(e.TEXTURE_2D,0,ue,ge,Ie,Q);if(f(g))E(V);if(fe.__version=le.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Le(S,g,P){if(g.image.length!==6)return;let V=q(S,g),ne=g.source;n.bindTexture(e.TEXTURE_CUBE_MAP,S.__webglTexture,e.TEXTURE0+P);let le=i.get(ne);if(ne.version!==le.__version||V===!0){n.activeTexture(e.TEXTURE0+P);let fe=et.getPrimaries(et.workingColorSpace),Z=g.colorSpace===Fi?null:et.getPrimaries(g.colorSpace),Q=g.colorSpace===Fi||fe===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 ge=g.isCompressedTexture||g.image[0].isCompressedTexture,Ie=g.image[0]&&g.image[0].isDataTexture,ue=[];for(let ie=0;ie<6;ie++){if(!ge&&!Ie)ue[ie]=m(g.image[ie],!0,s.maxCubemapSize);else ue[ie]=Ie?g.image[ie].image:g.image[ie];ue[ie]=nt(g,ue[ie])}let re=ue[0],Ee=r.convert(g.format,g.colorSpace),De=r.convert(g.type),Ze=y(g.internalFormat,Ee,De,g.normalized,g.colorSpace),N=g.isVideoTexture!==!0,he=le.__version===void 0||V===!0,K=ne.dataReady,de=w(g,re);Ue(e.TEXTURE_CUBE_MAP,g);let ye;if(ge){if(N&&he)n.texStorage2D(e.TEXTURE_CUBE_MAP,de,Ze,re.width,re.height);for(let ie=0;ie<6;ie++){ye=ue[ie].mipmaps;for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(g.format!==Gn)if(Ee!==null)if(N){if(K)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,0,0,Be.width,Be.height,Ee,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,Ze,Be.width,Be.height,0,Be.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,0,0,Be.width,Be.height,Ee,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,Ze,Be.width,Be.height,0,Ee,De,Be.data)}}}else{if(ye=g.mipmaps,N&&he){if(ye.length>0)de++;let ie=xt(ue[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,de,Ze,ie.width,ie.height)}for(let ie=0;ie<6;ie++)if(Ie){if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,ue[ie].width,ue[ie].height,Ee,De,ue[ie].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,Ze,ue[ie].width,ue[ie].height,0,Ee,De,ue[ie].data);for(let pe=0;pe<ye.length;pe++){let ct=ye[pe].image[ie].image;if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,0,0,ct.width,ct.height,Ee,De,ct.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,Ze,ct.width,ct.height,0,Ee,De,ct.data)}}else{if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,Ee,De,ue[ie])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,Ze,Ee,De,ue[ie]);for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,0,0,Ee,De,Be.image[ie])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,Ze,Ee,De,Be.image[ie])}}}if(f(g))E(e.TEXTURE_CUBE_MAP);if(le.__version=ne.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Ne(S,g,P,V,ne,le){let fe=r.convert(P.format,P.colorSpace),Z=r.convert(P.type),Q=y(P.internalFormat,fe,Z,P.normalized,P.colorSpace),ge=i.get(g),Ie=i.get(P);if(Ie.__renderTarget=g,!ge.__hasExternalTextures){let ue=Math.max(1,g.width>>le),re=Math.max(1,g.height>>le);if(ne===e.TEXTURE_3D||ne===e.TEXTURE_2D_ARRAY)n.texImage3D(ne,le,Q,ue,re,g.depth,0,fe,Z,null);else n.texImage2D(ne,le,Q,ue,re,0,fe,Z,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,S),L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ne,Ie.__webglTexture,0,Rt(g));else if(ne===e.TEXTURE_2D||ne>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ne<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ne,Ie.__webglTexture,le);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Ct(S,g,P){if(e.bindRenderbuffer(e.RENDERBUFFER,S),g.depthBuffer){let V=g.depthTexture,ne=V&&V.isDepthTexture?V.type:null,le=b(g.stencilBuffer,ne),fe=g.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Rt(g),le,g.width,g.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Rt(g),le,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,le,g.width,g.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,fe,e.RENDERBUFFER,S)}else{let V=g.textures;for(let ne=0;ne<V.length;ne++){let le=V[ne],fe=r.convert(le.format,le.colorSpace),Z=r.convert(le.type),Q=y(le.internalFormat,fe,Z,le.normalized,le.colorSpace);if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Rt(g),Q,g.width,g.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Rt(g),Q,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,Q,g.width,g.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function We(S,g,P){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 ne=i.get(g.depthTexture);if(ne.__renderTarget=g,!ne.__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(ne.__webglInit===void 0)ne.__webglInit=!0,g.depthTexture.addEventListener("dispose",A);if(ne.__webglTexture===void 0){ne.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ne.__webglTexture),Ue(e.TEXTURE_CUBE_MAP,g.depthTexture);let ge=r.convert(g.depthTexture.format),Ie=r.convert(g.depthTexture.type),ue;if(g.depthTexture.format===Ni)ue=e.DEPTH_COMPONENT24;else if(g.depthTexture.format===Di)ue=e.DEPTH24_STENCIL8;for(let re=0;re<6;re++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,ue,g.width,g.height,0,ge,Ie,null)}}else se(g.depthTexture,0);let le=ne.__webglTexture,fe=Rt(g),Z=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+P:e.TEXTURE_2D,Q=g.depthTexture.format===Di?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(g.depthTexture.format===Ni)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,fe);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else if(g.depthTexture.format===Di)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,fe);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ke(S){let g=i.get(S),P=S.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(g.__depthDisposeCallback)g.__depthDisposeCallback();if(V){let ne=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,V.removeEventListener("dispose",ne)};V.addEventListener("dispose",ne),g.__depthDisposeCallback=ne}g.__boundDepthTexture=V}if(S.depthTexture&&!g.__autoAllocateDepthBuffer)if(P)for(let V=0;V<6;V++)We(g.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)We(g.__webglFramebuffer[0],S,0);else We(g.__webglFramebuffer,S,0)}else if(P){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(),Ct(g.__webglDepthbuffer[V],S,!1);else{let ne=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ne,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(),Ct(g.__webglDepthbuffer,S,!1);else{let ne=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ne,e.RENDERBUFFER,le)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function rt(S,g,P){let V=i.get(S);if(g!==void 0)Ne(V.__webglFramebuffer,S,S.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(P!==void 0)Ke(S)}function je(S){let g=S.texture,P=i.get(S),V=i.get(g);S.addEventListener("dispose",_);let ne=S.textures,le=S.isWebGLCubeRenderTarget===!0,fe=ne.length>1;if(!fe){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=g.version,a.memory.textures++}if(le){P.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0){P.__webglFramebuffer[Z]=[];for(let Q=0;Q<g.mipmaps.length;Q++)P.__webglFramebuffer[Z][Q]=e.createFramebuffer()}else P.__webglFramebuffer[Z]=e.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){P.__webglFramebuffer=[];for(let Z=0;Z<g.mipmaps.length;Z++)P.__webglFramebuffer[Z]=e.createFramebuffer()}else P.__webglFramebuffer=e.createFramebuffer();if(fe)for(let Z=0,Q=ne.length;Z<Q;Z++){let ge=i.get(ne[Z]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),a.memory.textures++}if(S.samples>0&&L(S)===!1){P.__webglMultisampledFramebuffer=e.createFramebuffer(),P.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,P.__webglMultisampledFramebuffer);for(let Z=0;Z<ne.length;Z++){let Q=ne[Z];P.__webglColorRenderbuffer[Z]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,P.__webglColorRenderbuffer[Z]);let ge=r.convert(Q.format,Q.colorSpace),Ie=r.convert(Q.type),ue=y(Q.internalFormat,ge,Ie,Q.normalized,Q.colorSpace,S.isXRRenderTarget===!0),re=Rt(S);e.renderbufferStorageMultisample(e.RENDERBUFFER,re,ue,S.width,S.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Z,e.RENDERBUFFER,P.__webglColorRenderbuffer[Z])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),S.depthBuffer)P.__webglDepthRenderbuffer=e.createRenderbuffer(),Ct(P.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(le){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Ue(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++)Ne(P.__webglFramebuffer[Z][Q],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Ne(P.__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(fe){for(let Z=0,Q=ne.length;Z<Q;Z++){let ge=ne[Z],Ie=i.get(ge),ue=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)ue=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ue,Ie.__webglTexture),Ue(ue,ge),Ne(P.__webglFramebuffer,S,ge,e.COLOR_ATTACHMENT0+Z,ue,0),f(ge))E(ue)}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),Ue(Z,g),g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)Ne(P.__webglFramebuffer[Q],S,g,e.COLOR_ATTACHMENT0,Z,Q);else Ne(P.__webglFramebuffer,S,g,e.COLOR_ATTACHMENT0,Z,0);if(f(g))E(Z);n.unbindTexture()}if(S.depthBuffer)Ke(S)}function Dt(S){let g=S.textures;for(let P=0,V=g.length;P<V;P++){let ne=g[P];if(f(ne)){let le=C(S),fe=i.get(ne).__webglTexture;n.bindTexture(le,fe),E(le),n.unbindTexture()}}}let at=[],kt=[];function Et(S){if(S.samples>0){if(L(S)===!1){let{textures:g,width:P,height:V}=S,ne=e.COLOR_BUFFER_BIT,le=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,fe=i.get(S),Z=g.length>1;if(Z)for(let ge=0;ge<g.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,fe.__webglMultisampledFramebuffer);let Q=S.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__webglFramebuffer);for(let ge=0;ge<g.length;ge++){if(S.resolveDepthBuffer){if(S.depthBuffer)ne|=e.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)ne|=e.STENCIL_BUFFER_BIT}if(Z){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,fe.__webglColorRenderbuffer[ge]);let Ie=i.get(g[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,P,V,0,0,P,V,ne,e.NEAREST),l===!0){if(at.length=0,kt.length=0,at.push(e.COLOR_ATTACHMENT0+ge),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)at.push(le),kt.push(le),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,kt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,at)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Z)for(let ge=0;ge<g.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,fe.__webglColorRenderbuffer[ge]);let Ie=i.get(g[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__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 Rt(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 Gt(S){let g=a.render.frame;if(u.get(S)!==g)u.set(S,g),S.update()}function nt(S,g){let{colorSpace:P,format:V,type:ne}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return g;if(P!==ko&&P!==Fi)if(et.getTransfer(P)===yt){if(V!==Gn||ne!==pn)Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Fe("WebGLTextures: Unsupported texture color space:",P);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=ee,this.resetTextureUnits=W,this.getTextureUnits=I,this.setTextureUnits=H,this.setTexture2D=se,this.setTexture2DArray=Y,this.setTexture3D=te,this.setTextureCube=j,this.rebindTextures=rt,this.setupRenderTarget=je,this.updateRenderTargetMipmap=Dt,this.updateMultisampleRenderTarget=Et,this.setupDepthRenderbuffer=Ke,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function qg(e,t){function n(i,s=Fi){let r,a=et.getTransfer(s);if(i===pn)return e.UNSIGNED_BYTE;if(i===io)return e.UNSIGNED_SHORT_4_4_4_4;if(i===so)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Jc)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===$c)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Yc)return e.BYTE;if(i===Zc)return e.SHORT;if(i===Bs)return e.UNSIGNED_SHORT;if(i===no)return e.INT;if(i===xi)return e.UNSIGNED_INT;if(i===ni)return e.FLOAT;if(i===kn)return e.HALF_FLOAT;if(i===Kc)return e.ALPHA;if(i===Qc)return e.RGB;if(i===Gn)return e.RGBA;if(i===Ni)return e.DEPTH_COMPONENT;if(i===Di)return e.DEPTH_STENCIL;if(i===Hr)return e.RED;if(i===ro)return e.RED_INTEGER;if(i===Ui)return e.RG;if(i===ao)return e.RG_INTEGER;if(i===oo)return e.RGBA_INTEGER;if(i===Vr||i===Wr||i===Xr||i===qr)if(a===yt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Vr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Xr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===qr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Vr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Wr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Xr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===qr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===lo||i===co||i===ho||i===uo)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===lo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===co)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ho)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===uo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===fo||i===po||i===mo||i===go||i===_o||i===Yr||i===xo)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(i===fo||i===po)return a===yt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===mo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===go)return r.COMPRESSED_R11_EAC;if(i===_o)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Yr)return r.COMPRESSED_RG11_EAC;if(i===xo)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===vo||i===yo||i===So||i===Mo||i===bo||i===To||i===wo||i===Eo||i===Ao||i===Co||i===Ro||i===Io||i===Po||i===Lo)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(i===vo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===yo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===So)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Mo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===bo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===To)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===wo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Eo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ao)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Co)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ro)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Io)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Po)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Lo)return a===yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===No||i===Do||i===Uo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(i===No)return a===yt?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===Zr||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===Zr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Bo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===xs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Yg=`
|
|
4196
|
+
}`,Gg=[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)],Hg=[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)],Oh=new St,nr=new O,Sl=new O;function Vg(e,t,n){let i=new js,s=new ze,r=new ze,a=new wt,o=new Ko,l=new Qo,c={},u=n.maxTextureSize,d={[Ms]:qt,[qt]:Ms,[ln]:ln},h=new Sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:zg,fragmentShader:kg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new pn;v.setAttribute("position",new vn(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=Gs;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===pc)Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Gs;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(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((H)=>H.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,H=w.length;I<H;I++){let ee=w[I],G=ee.shadow;if(G===void 0){Oe("WebGLShadowMap:",ee,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let se=G.getFrameExtents();if(s.multiply(se),r.copy(G.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/se.x),s.x=r.x*se.x,G.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/se.y),s.y=r.y*se.y,G.mapSize.y=r.y}let Y=e.state.buffers.depth.getReversed();if(G.camera._reversedDepth=Y,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===Ss){if(ee.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new fn(s.x,s.y,{format:Li,type:zn,minFilter:nn,magFilter:nn,generateMipmaps:!1}),G.map.texture.name=ee.name+".shadowMap",G.map.depthTexture=new Ui(s.x,s.y,Qn),G.map.depthTexture.name=ee.name+".shadowMapDepth",G.map.depthTexture.format=Ii,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Pn,G.map.depthTexture.magFilter=Pn}else{if(ee.isPointLight)G.map=new wl(s.x),G.map.depthTexture=new Zo(s.x,_i);else G.map=new fn(s.x,s.y),G.map.depthTexture=new Ui(s.x,s.y,_i);if(G.map.depthTexture.name=ee.name+".shadowMap",G.map.depthTexture.format=Ii,this.type===Gs)G.map.depthTexture.compareFunction=Y?qr:Xr,G.map.depthTexture.minFilter=nn,G.map.depthTexture.magFilter=nn;else G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Pn,G.map.depthTexture.magFilter=Pn}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(ee.isPointLight!==!0)G.updateMatrices(ee,_);for(let j=0;j<te;j++){let ve=G.getCamera(j);if(ee.isPointLight){let{camera:Se,matrix:Je}=G,Ue=ee.distance||Se.far;if(Ue!==Se.far)Se.far=Ue,Se.updateProjectionMatrix();nr.setFromMatrixPosition(ee.matrixWorld),Se.position.copy(nr),Sl.copy(Se.position),Sl.add(Gg[j]),Se.up.copy(Hg[j]),Se.lookAt(Sl),Se.updateMatrixWorld(),Je.makeTranslation(-nr.x,-nr.y,-nr.z),Oh.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),G._frustum.setFromProjectionMatrix(Oh,Se.coordinateSystem,Se.reversedDepth)}if(G.map.isWebGLCubeRenderTarget)e.setRenderTarget(G.map,j),e.clear();else{if(j===0)e.setRenderTarget(G.map),e.clear();let Se=G.getViewport(j);a.set(r.x*Se.x,r.y*Se.y,r.x*Se.z,r.y*Se.w),U.viewport(a)}i=G.getFrustum(j),y(A,_,ve,ee,this.type)}if(G.isPointLightShadow!==!0&&this.type===Ss)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 fn(s.x,s.y,{format:Li,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,I=c[U];if(I===void 0)I={},c[U]=I;let H=I[W];if(H===void 0)H=B.clone(),I[W]=H,A.addEventListener("dispose",b);B=H}if(B.visible=A.visible,B.wireframe=A.wireframe,M===Ss)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===Ss)&&(!w.frustumCulled||w.intersectsFrustum(i))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let W=t.update(w),I=w.material;if(Array.isArray(I)){let H=W.groups;for(let ee=0,G=H.length;ee<G;ee++){let se=H[ee],Y=I[se.materialIndex];if(Y&&Y.visible){let te=C(w,Y,M,B);w.onBeforeShadow(e,w,A,_,W,te,se),e.renderBufferDirect(_,null,W,te,w,se),w.onAfterShadow(e,w,A,_,W,te,se)}}}else if(I.visible){let H=C(w,I,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,I=U.length;W<I;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 Wg(e,t){function n(){let N=!1,he=new wt,K=null,de=new wt(0,0,0,0);return{setMask:function(ye){if(K!==ye&&!N)e.colorMask(ye,ye,ye,ye),K=ye},setLocked:function(ye){N=ye},setClear:function(ye,ie,pe,Be,ct){if(ct===!0)ye*=Be,ie*=Be,pe*=Be;if(he.set(ye,ie,pe,Be),de.equals(he)===!1)e.clearColor(ye,ie,pe,Be),de.copy(he)},reset:function(){N=!1,K=null,de.set(-1,0,0,0)}}}function i(){let N=!1,he=!1,K=null,de=null,ye=null;return{setReversed:function(ie){if(he!==ie){let pe=t.get("EXT_clip_control");if(ie)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);he=ie;let Be=ye;ye=null,this.setClear(Be)}},getReversed:function(){return he},setTest:function(ie){if(ie)oe(e.DEPTH_TEST);else Te(e.DEPTH_TEST)},setMask:function(ie){if(K!==ie&&!N)e.depthMask(ie),K=ie},setFunc:function(ie){if(he)ie=ch[ie];if(de!==ie){switch(ie){case Uc:e.depthFunc(e.NEVER);break;case Fc:e.depthFunc(e.ALWAYS);break;case Oc:e.depthFunc(e.LESS);break;case Za:e.depthFunc(e.LEQUAL);break;case Bc:e.depthFunc(e.EQUAL);break;case zc:e.depthFunc(e.GEQUAL);break;case kc:e.depthFunc(e.GREATER);break;case Gc:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}de=ie}},setLocked:function(ie){N=ie},setClear:function(ie){if(ye!==ie){if(ye=ie,he)ie=1-ie;e.clearDepth(ie)}},reset:function(){N=!1,K=null,de=null,ye=null,he=!1}}}function s(){let N=!1,he=null,K=null,de=null,ye=null,ie=null,pe=null,Be=null,ct=null;return{setTest:function(it){if(!N)if(it)oe(e.STENCIL_TEST);else Te(e.STENCIL_TEST)},setMask:function(it){if(he!==it&&!N)e.stencilMask(it),he=it},setFunc:function(it,F,J){if(K!==it||de!==F||ye!==J)e.stencilFunc(it,F,J),K=it,de=F,ye=J},setOp:function(it,F,J){if(ie!==it||pe!==F||Be!==J)e.stencilOp(it,F,J),ie=it,pe=F,Be=J},setLocked:function(it){N=it},setClear:function(it){if(ct!==it)e.clearStencil(it),ct=it},reset:function(){N=!1,he=null,K=null,de=null,ye=null,ie=null,pe=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 Ve(0,0,0),M=0,B=!1,R=null,U=null,W=null,I=null,H=null,ee=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),G=!1,se=0,Y=e.getParameter(e.VERSION);if(Y.indexOf("WebGL")!==-1)se=parseFloat(/^WebGL (\d)/.exec(Y)[1]),G=se>=1;else if(Y.indexOf("OpenGL ES")!==-1)se=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),G=se>=2;let te=null,j={},ve=e.getParameter(e.SCISSOR_BOX),Se=e.getParameter(e.VIEWPORT),Je=new wt().fromArray(ve),Ue=new wt().fromArray(Se);function q(N,he,K,de){let ye=new Uint8Array(4),ie=e.createTexture();e.bindTexture(N,ie),e.texParameteri(N,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(N,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<K;pe++)if(N===e.TEXTURE_3D||N===e.TEXTURE_2D_ARRAY)e.texImage3D(he,0,e.RGBA,1,1,de,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(he+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ie}let ae={};ae[e.TEXTURE_2D]=q(e.TEXTURE_2D,e.TEXTURE_2D,1),ae[e.TEXTURE_CUBE_MAP]=q(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[e.TEXTURE_2D_ARRAY]=q(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),ae[e.TEXTURE_3D]=q(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),oe(e.DEPTH_TEST),a.setFunc(Za),Lt(!1),rt(Xa),oe(e.CULL_FACE),st(On);function oe(N){if(u[N]!==!0)e.enable(N),u[N]=!0}function Te(N){if(u[N]!==!1)e.disable(N),u[N]=!1}function Le(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 Ne(N,he){let K=v,de=!1;if(N){if(K=p.get(he),K===void 0)K=[],p.set(he,K);let ye=N.textures;if(K.length!==ye.length||K[0]!==e.COLOR_ATTACHMENT0){for(let ie=0,pe=ye.length;ie<pe;ie++)K[ie]=e.COLOR_ATTACHMENT0+ie;K.length=ye.length,de=!0}}else if(K[0]!==e.BACK)K[0]=e.BACK,de=!0;if(de)e.drawBuffers(K)}function Et(N){if(T!==N)return e.useProgram(N),T=N,!0;return!1}let We={[bs]:e.FUNC_ADD,[gc]:e.FUNC_SUBTRACT,[_c]:e.FUNC_REVERSE_SUBTRACT};We[xc]=e.MIN,We[vc]=e.MAX;let $e={[yc]:e.ZERO,[Sc]:e.ONE,[Mc]:e.SRC_COLOR,[Tc]:e.SRC_ALPHA,[Ic]:e.SRC_ALPHA_SATURATE,[Cc]:e.DST_COLOR,[Ec]:e.DST_ALPHA,[bc]:e.ONE_MINUS_SRC_COLOR,[wc]:e.ONE_MINUS_SRC_ALPHA,[Rc]:e.ONE_MINUS_DST_COLOR,[Ac]:e.ONE_MINUS_DST_ALPHA,[Pc]:e.CONSTANT_COLOR,[Lc]:e.ONE_MINUS_CONSTANT_COLOR,[Nc]:e.CONSTANT_ALPHA,[Dc]:e.ONE_MINUS_CONSTANT_ALPHA};function st(N,he,K,de,ye,ie,pe,Be,ct,it){if(N===On){if(m===!0)Te(e.BLEND),m=!1;return}if(m===!1)oe(e.BLEND),m=!0;if(N!==mc){if(N!==f||it!==B){if(E!==bs||b!==bs)e.blendEquation(e.FUNC_ADD),E=bs,b=bs;if(it)switch(N){case Rn:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Kn:e.blendFunc(e.ONE,e.ONE);break;case qa:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Ya:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Fe("WebGLState: Invalid blending: ",N);break}else switch(N){case Rn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Kn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case qa:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ya:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",N);break}C=null,y=null,w=null,A=null,_.set(0,0,0),M=0,f=N,B=it}return}if(ye=ye||he,ie=ie||K,pe=pe||de,he!==E||ye!==b)e.blendEquationSeparate(We[he],We[ye]),E=he,b=ye;if(K!==C||de!==y||ie!==w||pe!==A)e.blendFuncSeparate($e[K],$e[de],$e[ie],$e[pe]),C=K,y=de,w=ie,A=pe;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===ln?Te(e.CULL_FACE):oe(e.CULL_FACE);let K=N.side===qt;if(he)K=!K;Lt(K),N.blending===Rn&&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 de=N.stencilWrite;if(o.setTest(de),de)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?oe(e.SAMPLE_ALPHA_TO_COVERAGE):Te(e.SAMPLE_ALPHA_TO_COVERAGE)}function Lt(N){if(R!==N){if(N)e.frontFace(e.CW);else e.frontFace(e.CCW);R=N}}function rt(N){if(N!==dc){if(oe(e.CULL_FACE),N!==U)if(N===Xa)e.cullFace(e.BACK);else if(N===fc)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Te(e.CULL_FACE);U=N}function Ot(N){if(N!==W){if(G)e.lineWidth(N);W=N}}function bt(N,he,K){if(N){if(oe(e.POLYGON_OFFSET_FILL),I!==he||H!==K){if(I=he,H=K,a.getReversed())he=-he;e.polygonOffset(he,K)}}else Te(e.POLYGON_OFFSET_FILL)}function At(N){if(N)oe(e.SCISSOR_TEST);else Te(e.SCISSOR_TEST)}function L(N){if(N===void 0)N=e.TEXTURE0+ee-1;if(te!==N)e.activeTexture(N),te=N}function Bt(N,he,K){if(K===void 0)if(te===null)K=e.TEXTURE0+ee-1;else K=te;let de=j[K];if(de===void 0)de={type:void 0,texture:void 0},j[K]=de;if(de.type!==N||de.texture!==he){if(te!==K)e.activeTexture(K),te=K;e.bindTexture(N,he||ae[N]),de.type=N,de.texture=he}}function tt(){let N=j[te];if(N!==void 0&&N.type!==void 0)e.bindTexture(N.type,null),N.type=void 0,N.texture=void 0}function mt(){try{e.compressedTexImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function S(){try{e.compressedTexImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function g(){try{e.texSubImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function P(){try{e.texSubImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function ne(){try{e.compressedTexSubImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function le(){try{e.texStorage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function fe(){try{e.texStorage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function Z(){try{e.texImage2D(...arguments)}catch(N){Fe("WebGLState:",N)}}function Q(){try{e.texImage3D(...arguments)}catch(N){Fe("WebGLState:",N)}}function ge(N){if(d[N]!==void 0)return d[N];else return e.getParameter(N)}function Ie(N,he){if(d[N]!==he)e.pixelStorei(N,he),d[N]=he}function ue(N){if(Je.equals(N)===!1)e.scissor(N.x,N.y,N.z,N.w),Je.copy(N)}function re(N){if(Ue.equals(N)===!1)e.viewport(N.x,N.y,N.z,N.w),Ue.copy(N)}function Ee(N,he){let K=c.get(he);if(K===void 0)K=new WeakMap,c.set(he,K);let de=K.get(N);if(de===void 0)de=e.getUniformBlockIndex(he,N.name),K.set(N,de)}function De(N,he){let de=c.get(he).get(N);if(l.get(he)!==de)e.uniformBlockBinding(he,de,N.__bindingPointIndex),l.set(he,de)}function Ze(){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,j={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,E=null,C=null,y=null,b=null,w=null,A=null,_=new Ve(0,0,0),M=0,B=!1,R=null,U=null,W=null,I=null,H=null,Je.set(0,0,e.canvas.width,e.canvas.height),Ue.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:oe,disable:Te,bindFramebuffer:Le,drawBuffers:Ne,useProgram:Et,setBlending:st,setMaterial:Qe,setFlipSided:Lt,setCullFace:rt,setLineWidth:Ot,setPolygonOffset:bt,setScissorTest:At,activeTexture:L,bindTexture:Bt,unbindTexture:tt,compressedTexImage2D:mt,compressedTexImage3D:S,texImage2D:Z,texImage3D:Q,pixelStorei:Ie,getParameter:ge,updateUBOMapping:Ee,uniformBlockBinding:De,texStorage2D:le,texStorage3D:fe,texSubImage2D:g,texSubImage3D:P,compressedTexSubImage2D:V,compressedTexSubImage3D:ne,scissor:ue,viewport:re,reset:Ze}}function Xg(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):Bs("canvas")}function m(S,g,P){let V=1,ne=mt(S);if(ne.width>P||ne.height>P)V=P/Math.max(ne.width,ne.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*ne.width),fe=Math.floor(V*ne.height);if(h===void 0)h=T(le,fe);let Z=g?T(le,fe):h;return Z.width=le,Z.height=fe,Z.getContext("2d").drawImage(S,0,0,le,fe),Oe("WebGLRenderer: Texture has been resized from ("+ne.width+"x"+ne.height+") to ("+le+"x"+fe+")."),Z}else{if("data"in S)Oe("WebGLRenderer: Image in DataTexture is too big ("+ne.width+"x"+ne.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,P,V,ne,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 fe;if(V){if(fe=t.get("EXT_texture_norm16"),!fe)Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Z=g;if(g===e.RED){if(P===e.FLOAT)Z=e.R32F;if(P===e.HALF_FLOAT)Z=e.R16F;if(P===e.UNSIGNED_BYTE)Z=e.R8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.R16_EXT;if(P===e.SHORT&&fe)Z=fe.R16_SNORM_EXT}if(g===e.RED_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.R8UI;if(P===e.UNSIGNED_SHORT)Z=e.R16UI;if(P===e.UNSIGNED_INT)Z=e.R32UI;if(P===e.BYTE)Z=e.R8I;if(P===e.SHORT)Z=e.R16I;if(P===e.INT)Z=e.R32I}if(g===e.RG){if(P===e.FLOAT)Z=e.RG32F;if(P===e.HALF_FLOAT)Z=e.RG16F;if(P===e.UNSIGNED_BYTE)Z=e.RG8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RG16_EXT;if(P===e.SHORT&&fe)Z=fe.RG16_SNORM_EXT}if(g===e.RG_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RG8UI;if(P===e.UNSIGNED_SHORT)Z=e.RG16UI;if(P===e.UNSIGNED_INT)Z=e.RG32UI;if(P===e.BYTE)Z=e.RG8I;if(P===e.SHORT)Z=e.RG16I;if(P===e.INT)Z=e.RG32I}if(g===e.RGB_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RGB8UI;if(P===e.UNSIGNED_SHORT)Z=e.RGB16UI;if(P===e.UNSIGNED_INT)Z=e.RGB32UI;if(P===e.BYTE)Z=e.RGB8I;if(P===e.SHORT)Z=e.RGB16I;if(P===e.INT)Z=e.RGB32I}if(g===e.RGBA_INTEGER){if(P===e.UNSIGNED_BYTE)Z=e.RGBA8UI;if(P===e.UNSIGNED_SHORT)Z=e.RGBA16UI;if(P===e.UNSIGNED_INT)Z=e.RGBA32UI;if(P===e.BYTE)Z=e.RGBA8I;if(P===e.SHORT)Z=e.RGBA16I;if(P===e.INT)Z=e.RGBA32I}if(g===e.RGB){if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RGB16_EXT;if(P===e.SHORT&&fe)Z=fe.RGB16_SNORM_EXT;if(P===e.UNSIGNED_INT_5_9_9_9_REV)Z=e.RGB9_E5;if(P===e.UNSIGNED_INT_10F_11F_11F_REV)Z=e.R11F_G11F_B10F}if(g===e.RGBA){let Q=le?Go:je.getTransfer(ne);if(P===e.FLOAT)Z=e.RGBA32F;if(P===e.HALF_FLOAT)Z=e.RGBA16F;if(P===e.UNSIGNED_BYTE)Z=Q===xt?e.SRGB8_ALPHA8:e.RGBA8;if(P===e.UNSIGNED_SHORT&&fe)Z=fe.RGBA16_EXT;if(P===e.SHORT&&fe)Z=fe.RGBA16_SNORM_EXT;if(P===e.UNSIGNED_SHORT_4_4_4_4)Z=e.RGBA4;if(P===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 P;if(S){if(g===null||g===_i||g===ws)P=e.DEPTH24_STENCIL8;else if(g===Qn)P=e.DEPTH32F_STENCIL8;else if(g===Xs)P=e.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(g===null||g===_i||g===ws)P=e.DEPTH_COMPONENT24;else if(g===Qn)P=e.DEPTH_COMPONENT32F;else if(g===Xs)P=e.DEPTH_COMPONENT16;return P}function w(S,g){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==Pn&&S.minFilter!==nn)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 P=S.source,V=p.get(P);if(V){let ne=V[g.__cacheKey];if(ne.usedTimes--,ne.usedTimes===0)B(S);if(Object.keys(V).length===0)p.delete(P)}i.remove(S)}function B(S){let g=i.get(S);e.deleteTexture(g.__webglTexture);let P=S.source,V=p.get(P);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 ne=0;ne<g.__webglFramebuffer[V].length;ne++)e.deleteFramebuffer(g.__webglFramebuffer[V][ne]);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 P=S.textures;for(let V=0,ne=P.length;V<ne;V++){let le=i.get(P[V]);if(le.__webglTexture)e.deleteTexture(le.__webglTexture),a.memory.textures--;i.remove(P[V])}i.remove(S)}let U=0;function W(){U=0}function I(){return U}function H(S){U=S}function ee(){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 se(S,g){let P=i.get(S);if(S.isVideoTexture)Bt(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&P.__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{Te(P,S,g);return}}else if(S.isExternalTexture)P.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,P.__webglTexture,e.TEXTURE0+g)}function Y(S,g){let P=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&P.__version!==S.version){Te(P,S,g);return}else if(S.isExternalTexture)P.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,P.__webglTexture,e.TEXTURE0+g)}function te(S,g){let P=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&P.__version!==S.version){Te(P,S,g);return}n.bindTexture(e.TEXTURE_3D,P.__webglTexture,e.TEXTURE0+g)}function j(S,g){let P=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&P.__version!==S.version){Le(P,S,g);return}n.bindTexture(e.TEXTURE_CUBE_MAP,P.__webglTexture,e.TEXTURE0+g)}let ve={[Vs]:e.REPEAT,[Bn]:e.CLAMP_TO_EDGE,[Xc]:e.MIRRORED_REPEAT},Se={[Pn]:e.NEAREST,[qc]:e.NEAREST_MIPMAP_NEAREST,[Ws]:e.NEAREST_MIPMAP_LINEAR,[nn]:e.LINEAR,[Ur]:e.LINEAR_MIPMAP_NEAREST,[Ri]:e.LINEAR_MIPMAP_LINEAR},Je={[eh]:e.NEVER,[rh]:e.ALWAYS,[th]:e.LESS,[Xr]:e.LEQUAL,[nh]:e.EQUAL,[qr]:e.GEQUAL,[ih]:e.GREATER,[sh]:e.NOTEQUAL};function Ue(S,g){if(g.type===Qn&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===nn||g.magFilter===Ur||g.magFilter===Ws||g.magFilter===Ri||g.minFilter===nn||g.minFilter===Ur||g.minFilter===Ws||g.minFilter===Ri))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,ve[g.wrapS]),e.texParameteri(S,e.TEXTURE_WRAP_T,ve[g.wrapT]),S===e.TEXTURE_3D||S===e.TEXTURE_2D_ARRAY)e.texParameteri(S,e.TEXTURE_WRAP_R,ve[g.wrapR]);if(e.texParameteri(S,e.TEXTURE_MAG_FILTER,Se[g.magFilter]),e.texParameteri(S,e.TEXTURE_MIN_FILTER,Se[g.minFilter]),g.compareFunction)e.texParameteri(S,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(S,e.TEXTURE_COMPARE_FUNC,Je[g.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Pn)return;if(g.minFilter!==Ws&&g.minFilter!==Ri)return;if(g.type===Qn&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||i.get(g).__currentAnisotropy){let P=t.get("EXT_texture_filter_anisotropic");e.texParameterf(S,P.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),i.get(g).__currentAnisotropy=g.anisotropy}}}function q(S,g){let P=!1;if(S.__webglInit===void 0)S.__webglInit=!0,g.addEventListener("dispose",A);let V=g.source,ne=p.get(V);if(ne===void 0)ne={},p.set(V,ne);let le=G(g);if(le!==S.__cacheKey){if(ne[le]===void 0)ne[le]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,P=!0;ne[le].usedTimes++;let fe=ne[S.__cacheKey];if(fe!==void 0){if(ne[S.__cacheKey].usedTimes--,fe.usedTimes===0)B(g)}S.__cacheKey=le,S.__webglTexture=ne[le].texture}return P}function ae(S,g,P){return Math.floor(Math.floor(S/P)/g)}function oe(S,g,P,V){let le=S.updateRanges;if(le.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,g.width,g.height,P,V,g.data);else{le.sort((Ie,ue)=>Ie.start-ue.start);let fe=0;for(let Ie=1;Ie<le.length;Ie++){let ue=le[fe],re=le[Ie],Ee=ue.start+ue.count,De=ae(re.start,g.width,4),Ze=ae(ue.start,g.width,4);if(re.start<=Ee+1&&De===Ze&&ae(re.start+re.count-1,g.width,4)===De)ue.count=Math.max(ue.count,re.start+re.count-ue.start);else++fe,le[fe]=re}le.length=fe+1;let Z=n.getParameter(e.UNPACK_ROW_LENGTH),Q=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,g.width);for(let Ie=0,ue=le.length;Ie<ue;Ie++){let re=le[Ie],Ee=Math.floor(re.start/4),De=Math.ceil(re.count/4),Ze=Ee%g.width,N=Math.floor(Ee/g.width),he=De,K=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Ze),n.pixelStorei(e.UNPACK_SKIP_ROWS,N),n.texSubImage2D(e.TEXTURE_2D,0,Ze,N,he,1,P,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,ge)}}function Te(S,g,P){let V=e.TEXTURE_2D;if(g.isDataArrayTexture||g.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(g.isData3DTexture)V=e.TEXTURE_3D;let ne=q(S,g),le=g.source;n.bindTexture(V,S.__webglTexture,e.TEXTURE0+P);let fe=i.get(le);if(le.version!==fe.__version||ne===!0){if(n.activeTexture(e.TEXTURE0+P),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){let K=je.getPrimaries(je.workingColorSpace),de=g.colorSpace===Ni?null:je.getPrimaries(g.colorSpace),ye=g.colorSpace===Ni||K===de?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,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,g.unpackAlignment);let Q=m(g.image,!1,s.maxTextureSize);Q=tt(g,Q);let ge=r.convert(g.format,g.colorSpace),Ie=r.convert(g.type),ue=y(g.internalFormat,ge,Ie,g.normalized,g.colorSpace,g.isVideoTexture);Ue(V,g);let re,Ee=g.mipmaps,De=g.isVideoTexture!==!0,Ze=fe.__version===void 0||ne===!0,N=le.dataReady,he=w(g,Q);if(g.isDepthTexture){if(ue=b(g.format===Pi,g.type),Ze)if(De)n.texStorage2D(e.TEXTURE_2D,1,ue,Q.width,Q.height);else n.texImage2D(e.TEXTURE_2D,0,ue,Q.width,Q.height,0,ge,Ie,null)}else if(g.isDataTexture)if(Ee.length>0){if(De&&Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Ee[0].width,Ee[0].height);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,Ie,re.data)}else n.texImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,ge,Ie,re.data);g.generateMipmaps=!1}else if(De){if(Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Q.width,Q.height);if(N)oe(g,Q,ge,Ie)}else n.texImage2D(e.TEXTURE_2D,0,ue,Q.width,Q.height,0,ge,Ie,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){if(De&&Ze)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,ue,Ee[0].width,Ee[0].height,Q.depth);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],g.format!==kn)if(ge!==null)if(De){if(N)if(g.layerUpdates.size>0){let ye=ml(re.width,re.height,g.format,g.type);for(let ie of g.layerUpdates){let pe=re.data.subarray(ie*ye/re.data.BYTES_PER_ELEMENT,(ie+1)*ye/re.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,ie,re.width,re.height,1,ge,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,re.width,re.height,Q.depth,ge,re.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,K,ue,re.width,re.height,Q.depth,0,re.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(N)n.texSubImage3D(e.TEXTURE_2D_ARRAY,K,0,0,0,re.width,re.height,Q.depth,ge,Ie,re.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,K,ue,re.width,re.height,Q.depth,0,ge,Ie,re.data);if(g.layerUpdates.size>0)g.clearLayerUpdates()}else{if(De&&Ze)n.texStorage2D(e.TEXTURE_2D,he,ue,Ee[0].width,Ee[0].height);for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],g.format!==kn)if(ge!==null)if(De){if(N)n.compressedTexSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,re.data)}else n.compressedTexImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,re.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,re.width,re.height,ge,Ie,re.data)}else n.texImage2D(e.TEXTURE_2D,K,ue,re.width,re.height,0,ge,Ie,re.data)}else if(g.isDataArrayTexture)if(De){if(Ze)n.texStorage3D(e.TEXTURE_2D_ARRAY,he,ue,Q.width,Q.height,Q.depth);if(N)if(g.layerUpdates.size>0){let K=ml(Q.width,Q.height,g.format,g.type);for(let de of g.layerUpdates){let ye=Q.data.subarray(de*K/Q.data.BYTES_PER_ELEMENT,(de+1)*K/Q.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,ge,Ie,ye)}g.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ge,Ie,Q.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,ue,Q.width,Q.height,Q.depth,0,ge,Ie,Q.data);else if(g.isData3DTexture)if(De){if(Ze)n.texStorage3D(e.TEXTURE_3D,he,ue,Q.width,Q.height,Q.depth);if(N)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ge,Ie,Q.data)}else n.texImage3D(e.TEXTURE_3D,0,ue,Q.width,Q.height,Q.depth,0,ge,Ie,Q.data);else if(g.isFramebufferTexture){if(Ze)if(De)n.texStorage2D(e.TEXTURE_2D,he,ue,Q.width,Q.height);else{let K=Q.width,de=Q.height;for(let ye=0;ye<he;ye++)n.texImage2D(e.TEXTURE_2D,ye,ue,K,de,0,ge,Ie,null),K>>=1,de>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in e){let K=e.canvas;if(!K.hasAttribute("layoutsubtree"))K.setAttribute("layoutsubtree","true");if(Q.parentNode!==K){K.appendChild(Q),d.add(g),K.onpaint=(de)=>{let ye=de.changedElements;for(let ie of d)if(ye.includes(ie.image))ie.needsUpdate=!0},K.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,Q);else{let{RGBA:ye,RGBA:ie,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ie,pe,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(Ee.length>0){if(De&&Ze){let K=mt(Ee[0]);n.texStorage2D(e.TEXTURE_2D,he,ue,K.width,K.height)}for(let K=0,de=Ee.length;K<de;K++)if(re=Ee[K],De){if(N)n.texSubImage2D(e.TEXTURE_2D,K,0,0,ge,Ie,re)}else n.texImage2D(e.TEXTURE_2D,K,ue,ge,Ie,re);g.generateMipmaps=!1}else if(De){if(Ze){let K=mt(Q);n.texStorage2D(e.TEXTURE_2D,he,ue,K.width,K.height)}if(N)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ie,Q)}else n.texImage2D(e.TEXTURE_2D,0,ue,ge,Ie,Q);if(f(g))E(V);if(fe.__version=le.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Le(S,g,P){if(g.image.length!==6)return;let V=q(S,g),ne=g.source;n.bindTexture(e.TEXTURE_CUBE_MAP,S.__webglTexture,e.TEXTURE0+P);let le=i.get(ne);if(ne.version!==le.__version||V===!0){n.activeTexture(e.TEXTURE0+P);let fe=je.getPrimaries(je.workingColorSpace),Z=g.colorSpace===Ni?null:je.getPrimaries(g.colorSpace),Q=g.colorSpace===Ni||fe===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 ge=g.isCompressedTexture||g.image[0].isCompressedTexture,Ie=g.image[0]&&g.image[0].isDataTexture,ue=[];for(let ie=0;ie<6;ie++){if(!ge&&!Ie)ue[ie]=m(g.image[ie],!0,s.maxCubemapSize);else ue[ie]=Ie?g.image[ie].image:g.image[ie];ue[ie]=tt(g,ue[ie])}let re=ue[0],Ee=r.convert(g.format,g.colorSpace),De=r.convert(g.type),Ze=y(g.internalFormat,Ee,De,g.normalized,g.colorSpace),N=g.isVideoTexture!==!0,he=le.__version===void 0||V===!0,K=ne.dataReady,de=w(g,re);Ue(e.TEXTURE_CUBE_MAP,g);let ye;if(ge){if(N&&he)n.texStorage2D(e.TEXTURE_CUBE_MAP,de,Ze,re.width,re.height);for(let ie=0;ie<6;ie++){ye=ue[ie].mipmaps;for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(g.format!==kn)if(Ee!==null)if(N){if(K)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,0,0,Be.width,Be.height,Ee,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,Ze,Be.width,Be.height,0,Be.data);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,0,0,Be.width,Be.height,Ee,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe,Ze,Be.width,Be.height,0,Ee,De,Be.data)}}}else{if(ye=g.mipmaps,N&&he){if(ye.length>0)de++;let ie=mt(ue[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,de,Ze,ie.width,ie.height)}for(let ie=0;ie<6;ie++)if(Ie){if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,ue[ie].width,ue[ie].height,Ee,De,ue[ie].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,Ze,ue[ie].width,ue[ie].height,0,Ee,De,ue[ie].data);for(let pe=0;pe<ye.length;pe++){let ct=ye[pe].image[ie].image;if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,0,0,ct.width,ct.height,Ee,De,ct.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,Ze,ct.width,ct.height,0,Ee,De,ct.data)}}else{if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,Ee,De,ue[ie])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,Ze,Ee,De,ue[ie]);for(let pe=0;pe<ye.length;pe++){let Be=ye[pe];if(N){if(K)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,0,0,Ee,De,Be.image[ie])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,pe+1,Ze,Ee,De,Be.image[ie])}}}if(f(g))E(e.TEXTURE_CUBE_MAP);if(le.__version=ne.version,g.onUpdate)g.onUpdate(g)}S.__version=g.version}function Ne(S,g,P,V,ne,le){let fe=r.convert(P.format,P.colorSpace),Z=r.convert(P.type),Q=y(P.internalFormat,fe,Z,P.normalized,P.colorSpace),ge=i.get(g),Ie=i.get(P);if(Ie.__renderTarget=g,!ge.__hasExternalTextures){let ue=Math.max(1,g.width>>le),re=Math.max(1,g.height>>le);if(ne===e.TEXTURE_3D||ne===e.TEXTURE_2D_ARRAY)n.texImage3D(ne,le,Q,ue,re,g.depth,0,fe,Z,null);else n.texImage2D(ne,le,Q,ue,re,0,fe,Z,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,S),L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ne,Ie.__webglTexture,0,At(g));else if(ne===e.TEXTURE_2D||ne>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ne<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,V,ne,Ie.__webglTexture,le);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(S,g,P){if(e.bindRenderbuffer(e.RENDERBUFFER,S),g.depthBuffer){let V=g.depthTexture,ne=V&&V.isDepthTexture?V.type:null,le=b(g.stencilBuffer,ne),fe=g.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,At(g),le,g.width,g.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,At(g),le,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,le,g.width,g.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,fe,e.RENDERBUFFER,S)}else{let V=g.textures;for(let ne=0;ne<V.length;ne++){let le=V[ne],fe=r.convert(le.format,le.colorSpace),Z=r.convert(le.type),Q=y(le.internalFormat,fe,Z,le.normalized,le.colorSpace);if(L(g))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,At(g),Q,g.width,g.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,At(g),Q,g.width,g.height);else e.renderbufferStorage(e.RENDERBUFFER,Q,g.width,g.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function We(S,g,P){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 ne=i.get(g.depthTexture);if(ne.__renderTarget=g,!ne.__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(ne.__webglInit===void 0)ne.__webglInit=!0,g.depthTexture.addEventListener("dispose",A);if(ne.__webglTexture===void 0){ne.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ne.__webglTexture),Ue(e.TEXTURE_CUBE_MAP,g.depthTexture);let ge=r.convert(g.depthTexture.format),Ie=r.convert(g.depthTexture.type),ue;if(g.depthTexture.format===Ii)ue=e.DEPTH_COMPONENT24;else if(g.depthTexture.format===Pi)ue=e.DEPTH24_STENCIL8;for(let re=0;re<6;re++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,ue,g.width,g.height,0,ge,Ie,null)}}else se(g.depthTexture,0);let le=ne.__webglTexture,fe=At(g),Z=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+P:e.TEXTURE_2D,Q=g.depthTexture.format===Pi?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(g.depthTexture.format===Ii)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,fe);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else if(g.depthTexture.format===Pi)if(L(g))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,Q,Z,le,0,fe);else e.framebufferTexture2D(e.FRAMEBUFFER,Q,Z,le,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function $e(S){let g=i.get(S),P=S.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(g.__depthDisposeCallback)g.__depthDisposeCallback();if(V){let ne=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,V.removeEventListener("dispose",ne)};V.addEventListener("dispose",ne),g.__depthDisposeCallback=ne}g.__boundDepthTexture=V}if(S.depthTexture&&!g.__autoAllocateDepthBuffer)if(P)for(let V=0;V<6;V++)We(g.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)We(g.__webglFramebuffer[0],S,0);else We(g.__webglFramebuffer,S,0)}else if(P){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(),Et(g.__webglDepthbuffer[V],S,!1);else{let ne=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ne,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(),Et(g.__webglDepthbuffer,S,!1);else{let ne=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,le=g.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,le),e.framebufferRenderbuffer(e.FRAMEBUFFER,ne,e.RENDERBUFFER,le)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function st(S,g,P){let V=i.get(S);if(g!==void 0)Ne(V.__webglFramebuffer,S,S.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(P!==void 0)$e(S)}function Qe(S){let g=S.texture,P=i.get(S),V=i.get(g);S.addEventListener("dispose",_);let ne=S.textures,le=S.isWebGLCubeRenderTarget===!0,fe=ne.length>1;if(!fe){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=g.version,a.memory.textures++}if(le){P.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(g.mipmaps&&g.mipmaps.length>0){P.__webglFramebuffer[Z]=[];for(let Q=0;Q<g.mipmaps.length;Q++)P.__webglFramebuffer[Z][Q]=e.createFramebuffer()}else P.__webglFramebuffer[Z]=e.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){P.__webglFramebuffer=[];for(let Z=0;Z<g.mipmaps.length;Z++)P.__webglFramebuffer[Z]=e.createFramebuffer()}else P.__webglFramebuffer=e.createFramebuffer();if(fe)for(let Z=0,Q=ne.length;Z<Q;Z++){let ge=i.get(ne[Z]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),a.memory.textures++}if(S.samples>0&&L(S)===!1){P.__webglMultisampledFramebuffer=e.createFramebuffer(),P.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,P.__webglMultisampledFramebuffer);for(let Z=0;Z<ne.length;Z++){let Q=ne[Z];P.__webglColorRenderbuffer[Z]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,P.__webglColorRenderbuffer[Z]);let ge=r.convert(Q.format,Q.colorSpace),Ie=r.convert(Q.type),ue=y(Q.internalFormat,ge,Ie,Q.normalized,Q.colorSpace,S.isXRRenderTarget===!0),re=At(S);e.renderbufferStorageMultisample(e.RENDERBUFFER,re,ue,S.width,S.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Z,e.RENDERBUFFER,P.__webglColorRenderbuffer[Z])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),S.depthBuffer)P.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(P.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(le){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Ue(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++)Ne(P.__webglFramebuffer[Z][Q],S,g,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Ne(P.__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(fe){for(let Z=0,Q=ne.length;Z<Q;Z++){let ge=ne[Z],Ie=i.get(ge),ue=e.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)ue=S.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ue,Ie.__webglTexture),Ue(ue,ge),Ne(P.__webglFramebuffer,S,ge,e.COLOR_ATTACHMENT0+Z,ue,0),f(ge))E(ue)}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),Ue(Z,g),g.mipmaps&&g.mipmaps.length>0)for(let Q=0;Q<g.mipmaps.length;Q++)Ne(P.__webglFramebuffer[Q],S,g,e.COLOR_ATTACHMENT0,Z,Q);else Ne(P.__webglFramebuffer,S,g,e.COLOR_ATTACHMENT0,Z,0);if(f(g))E(Z);n.unbindTexture()}if(S.depthBuffer)$e(S)}function Lt(S){let g=S.textures;for(let P=0,V=g.length;P<V;P++){let ne=g[P];if(f(ne)){let le=C(S),fe=i.get(ne).__webglTexture;n.bindTexture(le,fe),E(le),n.unbindTexture()}}}let rt=[],Ot=[];function bt(S){if(S.samples>0){if(L(S)===!1){let{textures:g,width:P,height:V}=S,ne=e.COLOR_BUFFER_BIT,le=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,fe=i.get(S),Z=g.length>1;if(Z)for(let ge=0;ge<g.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,fe.__webglMultisampledFramebuffer);let Q=S.texture.mipmaps;if(Q&&Q.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__webglFramebuffer);for(let ge=0;ge<g.length;ge++){if(S.resolveDepthBuffer){if(S.depthBuffer)ne|=e.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)ne|=e.STENCIL_BUFFER_BIT}if(Z){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,fe.__webglColorRenderbuffer[ge]);let Ie=i.get(g[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,P,V,0,0,P,V,ne,e.NEAREST),l===!0){if(rt.length=0,Ot.length=0,rt.push(e.COLOR_ATTACHMENT0+ge),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)rt.push(le),Ot.push(le),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Ot);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,rt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Z)for(let ge=0;ge<g.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,fe.__webglColorRenderbuffer[ge]);let Ie=i.get(g[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,fe.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,fe.__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 At(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 Bt(S){let g=a.render.frame;if(u.get(S)!==g)u.set(S,g),S.update()}function tt(S,g){let{colorSpace:P,format:V,type:ne}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return g;if(P!==ko&&P!==Ni)if(je.getTransfer(P)===xt){if(V!==kn||ne!==dn)Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Fe("WebGLTextures: Unsupported texture color space:",P);return g}function mt(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=ee,this.resetTextureUnits=W,this.getTextureUnits=I,this.setTextureUnits=H,this.setTexture2D=se,this.setTexture2DArray=Y,this.setTexture3D=te,this.setTextureCube=j,this.rebindTextures=st,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=Lt,this.updateMultisampleRenderTarget=bt,this.setupDepthRenderbuffer=$e,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function qg(e,t){function n(i,s=Ni){let r,a=je.getTransfer(s);if(i===dn)return e.UNSIGNED_BYTE;if(i===io)return e.UNSIGNED_SHORT_4_4_4_4;if(i===so)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Jc)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===$c)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Yc)return e.BYTE;if(i===Zc)return e.SHORT;if(i===Xs)return e.UNSIGNED_SHORT;if(i===no)return e.INT;if(i===_i)return e.UNSIGNED_INT;if(i===Qn)return e.FLOAT;if(i===zn)return e.HALF_FLOAT;if(i===Kc)return e.ALPHA;if(i===Qc)return e.RGB;if(i===kn)return e.RGBA;if(i===Ii)return e.DEPTH_COMPONENT;if(i===Pi)return e.DEPTH_STENCIL;if(i===Fr)return e.RED;if(i===ro)return e.RED_INTEGER;if(i===Li)return e.RG;if(i===ao)return e.RG_INTEGER;if(i===oo)return e.RGBA_INTEGER;if(i===Or||i===Br||i===zr||i===kr)if(a===xt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Or)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Br)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===zr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===kr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Or)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Br)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===zr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===kr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===lo||i===co||i===ho||i===uo)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===lo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===co)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ho)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===uo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===fo||i===po||i===mo||i===go||i===_o||i===Gr||i===xo)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(i===fo||i===po)return a===xt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===mo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===go)return r.COMPRESSED_R11_EAC;if(i===_o)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Gr)return r.COMPRESSED_RG11_EAC;if(i===xo)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===vo||i===yo||i===So||i===Mo||i===bo||i===To||i===wo||i===Eo||i===Ao||i===Co||i===Ro||i===Io||i===Po||i===Lo)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(i===vo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===yo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===So)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Mo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===bo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===To)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===wo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Eo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ao)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Co)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ro)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Io)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Po)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Lo)return a===xt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===No||i===Do||i===Uo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(i===No)return a===xt?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===Vr||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===Vr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Bo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===ws)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Yg=`
|
|
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 Jh{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ia(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:Yg,fragmentShader:Zg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ge(new It(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $h extends ii{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 Jh,m={},f=t.getContextAttributes(),E=null,C=null,y=[],b=[],w=new ze,A=null,_=null,M=new cn;M.viewport=new At;let B=new cn;B.viewport=new At;let R=[M,B],U=new ul,W=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ae=y[q];if(ae===void 0)ae=new Gs,y[q]=ae;return ae.getTargetRaySpace()},this.getControllerGrip=function(q){let ae=y[q];if(ae===void 0)ae=new Gs,y[q]=ae;return ae.getGripSpace()},this.getHand=function(q){let ae=y[q];if(ae===void 0)ae=new Gs,y[q]=ae;return ae.getHandSpace()};function H(q){let ae=b.indexOf(q.inputSource);if(ae===-1)return;let oe=y[ae];if(oe!==void 0)oe.update(q.inputSource,q.frame,l||r),oe.dispatchEvent({type:q.type,data:q.inputSource})}function ee(){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",ee),i.removeEventListener("inputsourceschange",G);for(let q=0;q<y.length;q++){let ae=b[q];if(ae===null)continue;b[q]=null,y[q].disconnect(ae)}W=null,I=null,T.reset();for(let q in m)delete m[q];if(e.setRenderTarget(E),h=null,d=null,u=null,i=null,C=null,Ue.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(w.width,w.height,!1),_!==null){let q=_.camera;q.fov=_.fov,q.zoom=_.zoom,q.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){if(s=q,n.isPresenting===!0)Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){if(a=q,n.isPresenting===!0)Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(q){l=q},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(q){if(i=q,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",ee),i.addEventListener("inputsourceschange",G),f.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(w),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let oe={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,t,oe),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new mn(h.framebufferWidth,h.framebufferHeight,{format:Gn,type:pn,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let oe=null,Te=null,Le=null;if(f.depth)Le=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=f.stencil?Di:Ni,Te=f.stencil?xs:xi;let Ne={colorFormat:t.RGBA8,depthFormat:Le,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ne),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),C=new mn(d.textureWidth,d.textureHeight,{format:Gn,type:pn,depthTexture:new Bi(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,oe),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),Ue.setContext(i),Ue.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(q){for(let ae=0;ae<q.removed.length;ae++){let oe=q.removed[ae],Te=b.indexOf(oe);if(Te>=0)b[Te]=null,y[Te].disconnect(oe)}for(let ae=0;ae<q.added.length;ae++){let oe=q.added[ae],Te=b.indexOf(oe);if(Te===-1){for(let Ne=0;Ne<y.length;Ne++)if(Ne>=b.length){b.push(oe),Te=Ne;break}else if(b[Ne]===null){b[Ne]=oe,Te=Ne;break}if(Te===-1)break}let Le=y[Te];if(Le)Le.connect(oe)}}let se=new O,Y=new O;function te(q,ae,oe){se.setFromMatrixPosition(ae.matrixWorld),Y.setFromMatrixPosition(oe.matrixWorld);let Te=se.distanceTo(Y),Le=ae.projectionMatrix.elements,Ne=oe.projectionMatrix.elements,Ct=Le[14]/(Le[10]-1),We=Le[14]/(Le[10]+1),Ke=(Le[9]+1)/Le[5],rt=(Le[9]-1)/Le[5],je=(Le[8]-1)/Le[0],Dt=(Ne[8]+1)/Ne[0],at=Ct*je,kt=Ct*Dt,Et=Te/(-je+Dt),Rt=Et*-je;if(ae.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(Rt),q.translateZ(Et),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Le[10]===-1)q.projectionMatrix.copy(ae.projectionMatrix),q.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{let L=Ct+Et,Gt=We+Et,nt=at-Rt,xt=kt+(Te-Rt),S=Ke*We/Gt*L,g=rt*We/Gt*L;q.projectionMatrix.makePerspective(nt,xt,S,g,L,Gt),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function j(q,ae){if(ae===null)q.matrixWorld.copy(q.matrix);else q.matrixWorld.multiplyMatrices(ae.matrixWorld,q.matrix);q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(i===null)return;let{near:ae,far:oe}=q;if(T.texture!==null){if(T.depthNear>0)ae=T.depthNear;if(T.depthFar>0)oe=T.depthFar}if(U.near=B.near=M.near=ae,U.far=B.far=M.far=oe,W!==U.near||I!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,I=U.far;U.layers.mask=q.layers.mask|6,M.layers.mask=U.layers.mask&-5,B.layers.mask=U.layers.mask&-3;let Te=q.parent,Le=U.cameras;j(U,Te);for(let Ne=0;Ne<Le.length;Ne++)j(Le[Ne],Te);if(Le.length===2)te(U,M,B);else U.projectionMatrix.copy(M.projectionMatrix);if(_===null&&q.isPerspectiveCamera)_={camera:q,fov:q.fov,zoom:q.zoom};ve(q,U,Te)};function ve(q,ae,oe){if(oe===null)q.matrix.copy(ae.matrixWorld);else q.matrix.copy(oe.matrixWorld),q.matrix.invert(),q.matrix.multiply(ae.matrixWorld);if(q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(ae.projectionMatrix),q.projectionMatrixInverse.copy(ae.projectionMatrixInverse),q.isPerspectiveCamera)q.fov=Fr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(q){if(o=q,d!==null)d.fixedFoveation=q;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=q},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)},this.getCameraTexture=function(q){return m[q]};let Se=null;function $e(q,ae){if(c=ae.getViewerPose(l||r),p=ae,c!==null){let oe=c.views;if(h!==null)e.setRenderTargetFramebuffer(C,h.framebuffer),e.setRenderTarget(C);let Te=!1;if(oe.length!==U.cameras.length)U.cameras.length=0,Te=!0;for(let We=0;We<oe.length;We++){let Ke=oe[We],rt=null;if(h!==null)rt=h.getViewport(Ke);else{let Dt=u.getViewSubImage(d,Ke);if(rt=Dt.viewport,We===0)e.setRenderTargetTextures(C,Dt.colorTexture,Dt.depthStencilTexture),e.setRenderTarget(C)}let je=R[We];if(je===void 0)je=new cn,je.layers.enable(We),je.viewport=new At,R[We]=je;if(je.matrix.fromArray(Ke.transform.matrix),je.matrix.decompose(je.position,je.quaternion,je.scale),je.projectionMatrix.fromArray(Ke.projectionMatrix),je.projectionMatrixInverse.copy(je.projectionMatrix).invert(),je.viewport.set(rt.x,rt.y,rt.width,rt.height),We===0)U.matrix.copy(je.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Te===!0)U.cameras.push(je)}let Le=i.enabledFeatures;if(Le&&Le.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let We=u.getDepthInformation(oe[0]);if(We&&We.isValid&&We.texture)T.init(We,i.renderState)}if(Le&&Le.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let We=0;We<oe.length;We++){let Ke=oe[We].camera;if(Ke){let rt=m[Ke];if(!rt)rt=new ia,m[Ke]=rt;let je=u.getCameraImage(Ke);rt.sourceTexture=je}}}}for(let oe=0;oe<y.length;oe++){let Te=b[oe],Le=y[oe];if(Te!==null&&Le!==void 0)Le.update(Te,ae,l||r)}if(Se)Se(q,ae);if(ae.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:ae});p=null}let Ue=new Bh;Ue.setAnimationLoop($e),this.setAnimationLoop=function(q){Se=q},this.dispose=function(){}}}var Jg=new Tt,Kh=new ke;Kh.set(-1,0,0,0,1,0,0,0,1);function $g(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,Jo(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===Yt)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===Yt)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(Jg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(Kh);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===Yt)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 Kg(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 Fe("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 I=R[U],H=Array.isArray(I.value)?I.value:[I.value];for(let ee=0,G=H.length;ee<G;ee++){let se=H[ee],Y=f(se),te=w%A,j=te%Y.boundary,ve=te+j;if(w+=j,ve!==0&&A-ve<Y.storage)w+=A-ve;I.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=w,w+=Y.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 Qg=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 jg(){if(Vn===null)Vn=new Xs(Qg,16,16,Ui,kn),Vn.name="DFG_LUT",Vn.minFilter=rn,Vn.magFilter=rn,Vn.wrapS=zn,Vn.wrapT=zn,Vn.generateMipmaps=!1,Vn.needsUpdate=!0;return Vn}class El{constructor(e={}){let{canvas:t=ah(),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=pn}=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([oo,ao,ro]),m=new Set([pn,xi,Bs,xs,io,so]),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=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,B=!1,R=null,U=null,W=null,I=null;this._outputColorSpace=vi;let H=0,ee=0,G=null,se=-1,Y=null,te=new At,j=new At,ve=null,Se=new Ve(0),$e=0,{width:Ue,height:q}=t,ae=1,oe=null,Te=null,Le=new At(0,0,Ue,q),Ne=new At(0,0,Ue,q),Ct=!1,We=new qs,Ke=!1,rt=!1,je=new Tt,Dt=new O,at=new At,kt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Et=!1;function Rt(){return G===null?ae:1}let L=n;function Gt(x,D){return t.getContext(x,D)}let nt,xt,S,g,P,V,ne,le,fe,Z,Q,ge,Ie,ue,re,Ee,De,Ze,N,he,K,de,ye;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${uc}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",st,!1),L===null){if(L=Gt("webgl2",x),L===null)if(Gt("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ie()}catch(x){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",st,!1),Fe("WebGLRenderer: "+x.message),x}function ie(){if(nt=new am(L),nt.init(),K=new qg(L,nt),xt=new $p(L,nt,e,K),S=new Wg(L,nt),xt.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);U=L.createFramebuffer(),W=L.createFramebuffer(),I=L.createFramebuffer(),g=new cm(L),P=new Ig,V=new Xg(L,nt,S,P,xt,K,g),ne=new rm(M),le=new hd(L),de=new Zp(L,le),fe=new om(L,le,g,de),Z=new um(L,fe,le,de,g),Ze=new hm(L,xt,V),re=new Kp(P),Q=new Rg(M,ne,nt,xt,de,re),ge=new $g(M,P),Ie=new Lg,ue=new Bg(nt),De=new Yp(M,ne,S,Z,p,o),Ee=new Vg(M,Z,xt),ye=new Kg(L,g,xt,S),N=new Jp(L,nt,g),he=new lm(L,nt,g),g.programs=Q.programs,M.capabilities=xt,M.extensions=nt,M.properties=P,M.renderLists=Ie,M.shadowMap=Ee,M.state=S,M.info=g}if(v!==pn)_=new fm(v,t.width,t.height,a,i,s);let pe=new $h(M,L);this.xr=pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let x=nt.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=nt.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(x){if(x===void 0)return;ae=x,this.setSize(Ue,q,!1)},this.getSize=function(x){return x.set(Ue,q)},this.setSize=function(x,D,X=!0){if(pe.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Ue=x,q=D,t.width=Math.floor(x*ae),t.height=Math.floor(D*ae),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(Ue*ae,q*ae).floor()},this.setDrawingBufferSize=function(x,D,X){Ue=x,q=D,ae=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===pn){Fe("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(Le)},this.setViewport=function(x,D,X,z){if(x.isVector4)Le.set(x.x,x.y,x.z,x.w);else Le.set(x,D,X,z);S.viewport(te.copy(Le).multiplyScalar(ae).round())},this.getScissor=function(x){return x.copy(Ne)},this.setScissor=function(x,D,X,z){if(x.isVector4)Ne.set(x.x,x.y,x.z,x.w);else Ne.set(x,D,X,z);S.scissor(j.copy(Ne).multiplyScalar(ae).round())},this.getScissorTest=function(){return Ct},this.setScissorTest=function(x){S.setScissorTest(Ct=x)},this.setOpaqueSort=function(x){oe=x},this.setTransparentSort=function(x){Te=x},this.getClearColor=function(x){return x.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,X=!0){let z=0;if(x){let k=!1;if(G!==null){let xe=G.texture.format;k=T.has(xe)}if(k){let xe=G.texture.type,be=m.has(xe),_e=De.getClearColor(),Ce=De.getClearAlpha(),{r:Pe,g:qe,b:Qe}=_e;if(be)f[0]=Pe,f[1]=qe,f[2]=Qe,f[3]=Ce,L.clearBufferuiv(L.COLOR,0,f);else E[0]=Pe,E[1]=qe,E[2]=Qe,E[3]=Ce,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",st,!1),De.dispose(),Ie.dispose(),ue.dispose(),P.dispose(),ne.dispose(),Z.dispose(),de.dispose(),ye.dispose(),Q.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",ot),pe.removeEventListener("sessionend",St),He.stop()};function Be(x){x.preventDefault(),Ls("WebGLRenderer: Context Lost."),B=!0}function ct(){Ls("WebGLRenderer: Context Restored."),B=!1;let x=g.autoReset,D=Ee.enabled,X=Ee.autoUpdate,z=Ee.needsUpdate,k=Ee.type;ie(),g.autoReset=x,Ee.enabled=D,Ee.autoUpdate=X,Ee.needsUpdate=z,Ee.type=k}function st(x){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function F(x){let D=x.target;D.removeEventListener("dispose",F),J(D)}function J(x){ce(x),P.remove(x)}function ce(x){let D=P.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,xe){if(D===null)D=kt;let be=k.isMesh&&k.matrixWorld.determinantAffine()<0,_e=Eu(x,D,X,z,k);S.setMaterial(z,be);let Ce=X.index,Pe=1;if(z.wireframe===!0){if(Ce=fe.getWireframeAttribute(X),Ce===void 0)return;Pe=2}let qe=X.drawRange,Qe=X.attributes.position,Re=qe.start*Pe,lt=(qe.start+qe.count)*Pe;if(xe!==null)Re=Math.max(Re,xe.start*Pe),lt=Math.min(lt,(xe.start+xe.count)*Pe);if(Ce!==null)Re=Math.max(Re,0),lt=Math.min(lt,Ce.count);else if(Qe!==void 0&&Qe!==null)Re=Math.max(Re,0),lt=Math.min(lt,Qe.count);let Ut=lt-Re;if(Ut<0||Ut===1/0)return;de.setup(k,z,_e,X,Ce);let wt,vt=N;if(Ce!==null)wt=le.get(Ce),vt=he,vt.setIndex(wt);if(k.isMesh)if(z.wireframe===!0)S.setLineWidth(z.wireframeLinewidth*Rt()),vt.setMode(L.LINES);else vt.setMode(L.TRIANGLES);else if(k.isLine){let jt=z.linewidth;if(jt===void 0)jt=1;if(S.setLineWidth(jt*Rt()),k.isLineSegments)vt.setMode(L.LINES);else if(k.isLineLoop)vt.setMode(L.LINE_LOOP);else vt.setMode(L.LINE_STRIP)}else if(k.isPoints)vt.setMode(L.POINTS);else if(k.isSprite)vt.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:jt,_multiDrawCounts:Me,_multiDrawCount:on}=k,it=Ce?le.get(Ce).bytesPerElement:1,xn=P.get(z).currentProgram.getUniforms();for(let Dn=0;Dn<on;Dn++)xn.setValue(L,"_gl_DrawID",Dn),vt.render(jt[Dn]/it,Me[Dn])}else vt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else if(k.isInstancedMesh)vt.renderInstances(Re,Ut,k.count);else if(X.isInstancedBufferGeometry){let jt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Me=Math.min(X.instanceCount,jt);vt.renderInstances(Re,Ut,Me)}else vt.render(Re,Ut)};function we(x,D,X,z){if(R!==null&&x.isNodeMaterial)R.setObject(z,x);if(Ke===!0)re.setState(x,X,!1);if(x.transparent===!0&&x.side===hn&&x.forceSinglePass===!1)x.side=Yt,x.needsUpdate=!0,wn(x,D,z),x.side=ms,x.needsUpdate=!0,wn(x,D,z),x.side=hn;else wn(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=ue.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(rt=this.localClippingEnabled,Ke=re.init(this.clippingPlanes,rt),Ke===!0)re.setGlobalState(this.clippingPlanes,D);if(R!==null)Ee.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 xe=k.material;if(xe)if(Array.isArray(xe))for(let be=0;be<xe.length;be++){let _e=xe[be];we(_e,X,D,k),z.add(_e)}else we(xe,X,D,k),z.add(xe)}),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 xe(){if(z.forEach(function(be){let Ce=P.get(be).currentProgram;if(Ce===void 0||Ce.isReady())z.delete(be)}),z.size===0){k(x);return}setTimeout(xe,10)}if(nt.get("KHR_parallel_shader_compile")!==null)xe();else setTimeout(xe,10)})};let Ae=null;function Xe(x){if(Ae)Ae(x)}function ot(){He.stop()}function St(){He.start()}let He=new Bh;if(He.setAnimationLoop(Xe),typeof self<"u")He.setContext(self);this.setAnimationLoop=function(x){Ae=x,pe.setAnimationLoop(x),x===null?He.stop():He.start()},pe.addEventListener("sessionstart",ot),pe.addEventListener("sessionend",St),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(R!==null)R.renderStart(x,D);let X=pe.enabled===!0&&pe.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(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(D);D=pe.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,G);if(b=ue.get(x,A.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),A.push(b),je.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),We.setFromProjectionMatrix(je,Vo,D.reversedDepth),rt=this.localClippingEnabled,Ke=re.init(this.clippingPlanes,rt),y=Ie.get(x,w.length),y.init(),w.push(y),pe.enabled===!0&&pe.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)bn(be,D,-1/0,M.sortObjects)}if(bn(x,D,0,M.sortObjects),y.finish(),R!==null)R.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(oe,Te);if(Et=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,Et)De.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ke===!0)re.beginShadows();let k=b.state.shadowsArray;if(Ee.render(k,x,D),Ke===!0)re.endShadows();if((z&&_.hasRenderPass())===!1){let be=y.opaque,_e=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Ce=D.cameras;if(_e.length>0)for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Qe=Ce[Pe];ai(be,_e,x,Qe)}if(Et)De.render(x);for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Qe=Ce[Pe];Tn(y,x,Qe,Qe.viewport)}}else{if(_e.length>0)ai(be,_e,x,D);if(Et)De.render(x);Tn(y,x,D)}}if(G!==null&&ee===0)V.updateMultisampleRenderTarget(G),V.updateRenderTargetMipmap(G);if(z)_.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(de.resetDefaultState(),se=-1,Y=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Ke===!0)re.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 bn(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(We)){if(z)at.setFromMatrixPosition(x.matrixWorld).applyMatrix4(je);let be=Z.update(x),_e=x.material;if(_e.visible)y.push(x,be,_e,X,at.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum(We)){let be=Z.update(x),_e=x.material;if(z){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();at.copy(x.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();at.copy(be.boundingSphere.center)}at.applyMatrix4(x.matrixWorld).applyMatrix4(je)}if(Array.isArray(_e)){let Ce=be.groups;for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Qe=Ce[Pe],Re=_e[Qe.materialIndex];if(Re&&Re.visible)y.push(x,be,Re,X,at.z,Qe,D)}}else if(_e.visible)y.push(x,be,_e,X,at.z,null,D)}}}let xe=x.children;for(let be=0,_e=xe.length;be<_e;be++)bn(xe[be],D,X,z)}function Tn(x,D,X,z){let{opaque:k,transmissive:xe,transparent:be}=x;if(b.setupLightsView(X),Ke===!0)re.setGlobalState(M.clippingPlanes,X);if(z)S.viewport(te.copy(z));if(k.length>0)ht(k,D,X);if(xe.length>0)ht(xe,D,X);if(be.length>0)ht(be,D,X);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function ai(x,D,X,z){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){let Re=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new mn(1,1,{generateMipmaps:!0,type:Re?kn:pn,minFilter:Li,samples:Math.max(4,xt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:et.workingColorSpace})}let xe=b.state.transmissionRenderTarget[z.id],be=z.viewport||te;xe.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let _e=M.getRenderTarget(),Ce=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(xe),M.getClearColor(Se),$e=M.getClearAlpha(),$e<1)M.setClearColor(16777215,0.5);if(M.clear(),Et)De.render(X);let qe=M.toneMapping;M.toneMapping=Pn;let Qe=z.viewport;if(z.viewport!==void 0)z.viewport=void 0;if(b.setupLightsView(z),Ke===!0)re.setGlobalState(M.clippingPlanes,z);if(ht(x,X,z),V.updateMultisampleRenderTarget(xe),V.updateRenderTargetMipmap(xe),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let lt=0,Ut=D.length;lt<Ut;lt++){let wt=D[lt],{object:vt,geometry:jt,material:Me,group:on}=wt;if(Me.side===hn&&vt.layers.test(z.layers)){let it=Me.side;Me.side=Yt,Me.needsUpdate=!0,ut(vt,X,z,jt,Me,on),Me.side=it,Me.needsUpdate=!0,Re=!0}}if(Re===!0)V.updateMultisampleRenderTarget(xe),V.updateRenderTargetMipmap(xe)}if(M.setRenderTarget(_e,Ce,Pe),M.setClearColor(Se,$e),Qe!==void 0)z.viewport=Qe;M.toneMapping=qe}function ht(x,D,X){let z=D.isScene===!0?D.overrideMaterial:null;for(let k=0,xe=x.length;k<xe;k++){let be=x[k],{object:_e,geometry:Ce,group:Pe}=be,qe=be.material;if(qe.allowOverride===!0&&z!==null)qe=z;if(_e.layers.test(X.layers))ut(_e,D,X,Ce,qe,Pe)}}function ut(x,D,X,z,k,xe){if(R!==null&&k.isNodeMaterial)R.setObject(x,k);if(x.onBeforeRender(M,D,X,z,k,xe),x.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),k.onBeforeRender(M,D,X,z,x,xe),k.transparent===!0&&k.side===hn&&k.forceSinglePass===!1)k.side=Yt,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,xe),k.side=ms,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,xe),k.side=hn;else M.renderBufferDirect(X,D,z,k,x,xe);x.onAfterRender(M,D,X,z,k,xe)}function wn(x,D,X){if(D.isScene!==!0)D=kt;let z=P.get(x),k=b.state.lights,xe=b.state.shadowsArray,be=k.state.version,_e=Q.getParameters(x,k.state,xe,D,X,b.state.lightProbeGridArray),Ce=Q.getProgramCacheKey(_e),Pe=z.programs;z.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,z.fog=D.fog;let qe=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(z.envMap=ne.get(x.envMap||z.environment,qe),z.envMapRotation=z.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Pe===void 0)x.addEventListener("dispose",F),Pe=new Map,z.programs=Pe;let Qe=Pe.get(Ce);if(Qe!==void 0){if(z.currentProgram===Qe&&z.lightsStateVersion===be)return Nn(x,_e),Qe}else{if(_e.uniforms=Q.getUniforms(x),R!==null&&x.isNodeMaterial)R.build(x,X,_e);x.onBeforeCompile(_e,M),Qe=Q.acquireProgram(_e,Ce),Pe.set(Ce,Qe),z.uniforms=_e.uniforms}let Re=z.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Re.clippingPlanes=re.uniform;if(Nn(x,_e),z.needsLights=Cu(x),z.lightsStateVersion=be,z.needsLights)Re.ambientLightColor.value=k.state.ambient,Re.lightProbe.value=k.state.probe,Re.sunLights.value=k.state.sun,Re.sunLightShadows.value=k.state.sunShadow,Re.directionalLights.value=k.state.directional,Re.directionalLightShadows.value=k.state.directionalShadow,Re.spotLights.value=k.state.spot,Re.spotLightShadows.value=k.state.spotShadow,Re.rectAreaLights.value=k.state.rectArea,Re.ltc_1.value=k.state.rectAreaLTC1,Re.ltc_2.value=k.state.rectAreaLTC2,Re.pointLights.value=k.state.point,Re.pointLightShadows.value=k.state.pointShadow,Re.hemisphereLights.value=k.state.hemi,Re.sunShadowMatrix.value=k.state.sunShadowMatrix,Re.sunShadowCascade.value=k.state.sunShadowCascade,Re.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Re.spotLightMatrix.value=k.state.spotLightMatrix,Re.spotLightMap.value=k.state.spotLightMap,Re.pointShadowMatrix.value=k.state.pointShadowMatrix;return z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=Qe,z.uniformsList=null,Qe}function Zt(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=Ks.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function Nn(x,D){let X=P.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 wu(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 Eu(x,D,X,z,k){if(D.isScene!==!0)D=kt;V.resetTextureUnits();let xe=D.fog,be=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?D.environment:null,_e=G===null?M.outputColorSpace:G.isXRRenderTarget===!0?G.texture.colorSpace:et.workingColorSpace,Ce=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Pe=ne.get(z.envMap||be,Ce),qe=z.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Qe=!!X.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Re=!!X.morphAttributes.position,lt=!!X.morphAttributes.normal,Ut=!!X.morphAttributes.color,wt=Pn;if(z.toneMapped){if(G===null||G.isXRRenderTarget===!0)wt=M.toneMapping}let vt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,jt=vt!==void 0?vt.length:0,Me=P.get(z),on=b.state.lights;if(Ke===!0){if(rt===!0||x!==Y){let bt=x===Y&&z.id===se;re.setState(z,x,bt)}}let it=!1;if(z.version===Me.__version){if(Me.needsLights&&Me.lightsStateVersion!==on.state.version)it=!0;else if(Me.outputColorSpace!==_e)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!==Pe)it=!0;else if(z.fog===!0&&Me.fog!==xe)it=!0;else if(Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==re.numPlanes||Me.numIntersection!==re.numIntersection))it=!0;else if(Me.vertexAlphas!==qe)it=!0;else if(Me.vertexTangents!==Qe)it=!0;else if(Me.morphTargets!==Re)it=!0;else if(Me.morphNormals!==lt)it=!0;else if(Me.morphColors!==Ut)it=!0;else if(Me.toneMapping!==wt)it=!0;else if(Me.morphTargetsCount!==jt)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=wn(z,D,k),R&&z.isNodeMaterial)R.onUpdateProgram(z,xn,Me)}let Dn=!1,oi=!1,qi=!1,gt=xn.getUniforms(),Nt=Me.uniforms;if(S.useProgram(xn.program))Dn=!0,oi=!0,qi=!0;if(z.id!==se)se=z.id,oi=!0;if(Me.needsLights){let bt=wu(b.state.lightProbeGridArray,k);if(Me.lightProbeGrid!==bt)Me.lightProbeGrid=bt,oi=!0}if(Dn||Y!==x){if(S.buffers.depth.getReversed()&&x.reversedDepth!==!0)x._reversedDepth=!0,x.updateProjectionMatrix();gt.setValue(L,"projectionMatrix",x.projectionMatrix),gt.setValue(L,"viewMatrix",x.matrixWorldInverse);let ci=gt.map.cameraPosition;if(ci!==void 0)ci.setValue(L,Dt.setFromMatrixPosition(x.matrixWorld));if(xt.logarithmicDepthBuffer)gt.setValue(L,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2));if(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)gt.setValue(L,"isOrthographic",x.isOrthographicCamera===!0);if(Y!==x)Y=x,oi=!0,qi=!0}if(Me.needsLights){if(on.state.sunShadowMap.length>0)gt.setValue(L,"sunShadowMap",on.state.sunShadowMap,V);if(on.state.directionalShadowMap.length>0)gt.setValue(L,"directionalShadowMap",on.state.directionalShadowMap,V);if(on.state.spotShadowMap.length>0)gt.setValue(L,"spotShadowMap",on.state.spotShadowMap,V);if(on.state.pointShadowMap.length>0)gt.setValue(L,"pointShadowMap",on.state.pointShadowMap,V)}if(k.isSkinnedMesh){gt.setOptional(L,k,"bindMatrix"),gt.setOptional(L,k,"bindMatrixInverse");let bt=k.skeleton;if(bt){if(bt.boneTexture===null)bt.computeBoneTexture();gt.setValue(L,"boneTexture",bt.boneTexture,V)}}if(k.isBatchedMesh){if(gt.setOptional(L,k,"batchingTexture"),gt.setValue(L,"batchingTexture",k._matricesTexture,V),gt.setOptional(L,k,"batchingIdTexture"),gt.setValue(L,"batchingIdTexture",k._indirectTexture,V),gt.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null)gt.setValue(L,"batchingColorTexture",k._colorsTexture,V)}let li=X.morphAttributes;if(li.position!==void 0||li.normal!==void 0||li.color!==void 0)Ze.update(k,X,xn);if(oi||Me.receiveShadow!==k.receiveShadow)Me.receiveShadow=k.receiveShadow,gt.setValue(L,"receiveShadow",k.receiveShadow);if((z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&D.environment!==null)Nt.envMapIntensity.value=D.environmentIntensity;if(Nt.dfgLUT!==void 0)Nt.dfgLUT.value=jg();if(oi){if(gt.setValue(L,"toneMappingExposure",M.toneMappingExposure),Me.needsLights)Au(Nt,qi);if(xe&&z.fog===!0)ge.refreshFogUniforms(Nt,xe);if(ge.refreshMaterialUniforms(Nt,z,ae,q,b.state.transmissionRenderTarget[x.id]),Me.needsLights&&Me.lightProbeGrid){let bt=Me.lightProbeGrid;Nt.probesSH.value=bt.texture,Nt.probesMin.value.copy(bt.boundingBox.min),Nt.probesMax.value.copy(bt.boundingBox.max),Nt.probesResolution.value.copy(bt.resolution)}Ks.upload(L,Zt(Me),Nt,V)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0)Ks.upload(L,Zt(Me),Nt,V),z.uniformsNeedUpdate=!1;if(z.isSpriteMaterial)gt.setValue(L,"center",k.center);if(gt.setValue(L,"modelViewMatrix",k.modelViewMatrix),gt.setValue(L,"normalMatrix",k.normalMatrix),gt.setValue(L,"modelMatrix",k.matrixWorld),z.uniformsGroups!==void 0){let bt=z.uniformsGroups;for(let ci=0,Yi=bt.length;ci<Yi;ci++){let zl=bt[ci];ye.update(zl,xn),ye.bind(zl,xn)}}return xn}function Au(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 Cu(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 ee},this.getRenderTarget=function(){return G},this.setRenderTargetTextures=function(x,D,X){let z=P.get(x);if(z.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1)z.__useRenderToTexture=!1;P.get(x.texture).__webglTexture=D,P.get(x.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:X,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let X=P.get(x);X.__webglFramebuffer=D,X.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,X=0){G=x,H=D,ee=X;let z=null,k=!1,xe=!1;if(x){let _e=P.get(x);if(_e.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(L.FRAMEBUFFER,_e.__webglFramebuffer),te.copy(x.viewport),j.copy(x.scissor),ve=x.scissorTest,S.viewport(te),S.scissor(j),S.setScissorTest(ve),se=-1;return}else if(_e.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(_e.__hasExternalTextures)V.rebindTextures(x,P.get(x.texture).__webglTexture,P.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let qe=x.depthTexture;if(_e.__boundDepthTexture!==qe){if(qe!==null&&P.has(qe)&&(x.width!==qe.image.width||x.height!==qe.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Ce=x.texture;if(Ce.isData3DTexture||Ce.isDataArrayTexture||Ce.isCompressedArrayTexture)xe=!0;let Pe=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Pe[D]))z=Pe[D][X];else z=Pe[D];k=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)z=P.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))z=Pe[X];else z=Pe;te.copy(x.viewport),j.copy(x.scissor),ve=x.scissorTest}else te.copy(Le).multiplyScalar(ae).floor(),j.copy(Ne).multiplyScalar(ae).floor(),ve=Ct;if(X!==0)z=U;if(S.bindFramebuffer(L.FRAMEBUFFER,z))S.drawBuffers(x,z);if(S.viewport(te),S.scissor(j),S.setScissorTest(ve),k){let _e=P.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+D,_e.__webglTexture,X)}else if(xe){let _e=D;for(let Ce=0;Ce<x.textures.length;Ce++){let Pe=P.get(x.textures[Ce]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Ce,Pe.__webglTexture,X,_e)}}else if(x!==null&&X!==0){let _e=P.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,_e.__webglTexture,X)}se=-1};function Bl(x){let D=P.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,xe,be,_e=0){if(!(x&&x.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ce=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ce=Ce[be];if(Ce){S.bindFramebuffer(L.FRAMEBUFFER,Ce);try{let Pe=x.textures[_e],{format:qe,type:Qe}=Pe;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+_e);let Re=Bl(Pe);if(Re.__formatReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){Fe("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,K.convert(qe),K.convert(Qe),xe)}finally{let Pe=G!==null?P.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(x,D,X,z,k,xe,be,_e=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ce=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ce=Ce[be];if(Ce)if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k)){S.bindFramebuffer(L.FRAMEBUFFER,Ce);let Pe=x.textures[_e],{format:qe,type:Qe}=Pe;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+_e);let Re=Bl(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__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,xe.byteLength,L.STREAM_READ),L.readPixels(D,X,z,k,K.convert(qe),K.convert(Qe),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Ut=G!==null?P.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Ut);let wt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await lh(L,wt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,lt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,xe),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(lt),L.deleteSync(wt),xe}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),xe=Math.floor(x.image.height*z),be=D!==null?D.x:0,_e=D!==null?D.y:0;V.setTexture2D(x,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,be,_e,k,xe),S.unbindTexture()},this.copyTextureToTexture=function(x,D,X=null,z=null,k=0,xe=0){let be,_e,Ce,Pe,qe,Qe,Re,lt,Ut,wt=x.isCompressedTexture?x.mipmaps[xe]:x.image;if(X!==null)be=X.max.x-X.min.x,_e=X.max.y-X.min.y,Ce=X.isBox3?X.max.z-X.min.z:1,Pe=X.min.x,qe=X.min.y,Qe=X.isBox3?X.min.z:0;else{let Nt=Math.pow(2,-k);if(be=Math.floor(wt.width*Nt),_e=Math.floor(wt.height*Nt),x.isDataArrayTexture)Ce=wt.depth;else if(x.isData3DTexture)Ce=Math.floor(wt.depth*Nt);else Ce=1;Pe=0,qe=0,Qe=0}if(z!==null)Re=z.x,lt=z.y,Ut=z.z;else Re=0,lt=0,Ut=0;let vt=K.convert(D.format),jt=K.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 on=S.getParameter(L.UNPACK_ROW_LENGTH),it=S.getParameter(L.UNPACK_IMAGE_HEIGHT),xn=S.getParameter(L.UNPACK_SKIP_PIXELS),Dn=S.getParameter(L.UNPACK_SKIP_ROWS),oi=S.getParameter(L.UNPACK_SKIP_IMAGES);S.pixelStorei(L.UNPACK_ROW_LENGTH,wt.width),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,wt.height),S.pixelStorei(L.UNPACK_SKIP_PIXELS,Pe),S.pixelStorei(L.UNPACK_SKIP_ROWS,qe),S.pixelStorei(L.UNPACK_SKIP_IMAGES,Qe);let qi=x.isDataArrayTexture||x.isData3DTexture,gt=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let Nt=P.get(x),li=P.get(D),bt=P.get(Nt.__renderTarget),ci=P.get(li.__renderTarget);S.bindFramebuffer(L.READ_FRAMEBUFFER,bt.__webglFramebuffer),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,ci.__webglFramebuffer);for(let Yi=0;Yi<Ce;Yi++){if(qi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(x).__webglTexture,k,Qe+Yi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(D).__webglTexture,xe,Ut+Yi);L.blitFramebuffer(Pe,qe,be,_e,Re,lt,be,_e,L.DEPTH_BUFFER_BIT,L.NEAREST)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||x.isRenderTargetTexture||P.has(x)){let Nt=P.get(x),li=P.get(D);S.bindFramebuffer(L.READ_FRAMEBUFFER,W),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,I);for(let bt=0;bt<Ce;bt++){if(qi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Nt.__webglTexture,k,Qe+bt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Nt.__webglTexture,k);if(gt)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,li.__webglTexture,xe,Ut+bt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,li.__webglTexture,xe);if(k!==0)L.blitFramebuffer(Pe,qe,be,_e,Re,lt,be,_e,L.COLOR_BUFFER_BIT,L.NEAREST);else if(gt)L.copyTexSubImage3D(Me,xe,Re,lt,Ut+bt,Pe,qe,be,_e);else L.copyTexSubImage2D(Me,xe,Re,lt,Pe,qe,be,_e)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(gt)if(x.isDataTexture||x.isData3DTexture)L.texSubImage3D(Me,xe,Re,lt,Ut,be,_e,Ce,vt,jt,wt.data);else if(D.isCompressedArrayTexture)L.compressedTexSubImage3D(Me,xe,Re,lt,Ut,be,_e,Ce,vt,wt.data);else L.texSubImage3D(Me,xe,Re,lt,Ut,be,_e,Ce,vt,jt,wt);else if(x.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,xe,Re,lt,be,_e,vt,jt,wt.data);else if(x.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,xe,Re,lt,wt.width,wt.height,vt,wt.data);else L.texSubImage2D(L.TEXTURE_2D,xe,Re,lt,be,_e,vt,jt,wt);if(S.pixelStorei(L.UNPACK_ROW_LENGTH,on),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,it),S.pixelStorei(L.UNPACK_SKIP_PIXELS,xn),S.pixelStorei(L.UNPACK_SKIP_ROWS,Dn),S.pixelStorei(L.UNPACK_SKIP_IMAGES,oi),xe===0&&D.generateMipmaps)L.generateMipmap(Me);S.unbindTexture()},this.initRenderTarget=function(x){if(P.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,ee=0,G=null,S.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Vo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}}function Lt(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 Al=(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}},Qh=(e,t)=>t>0.7?e.glassLight:t<0.3?e.glassDark:e.glass,Wi=(e,t,n)=>{e.strokeStyle=t,e.lineWidth=n,e.lineJoin="round",e.lineCap="round",e.stroke()};function jh(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 bi(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 eu(e){let[t,n]=Lt(512,512),i=Al(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 tu(e){let[t,n]=Lt(512,512),i=Al(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 pa(e){let[n,i]=Lt(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)bi(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 bi(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=e.bg,i.globalAlpha=0.55,bi(i,0,0,52,0.4),i.fill(),n}function Cl(e,t){let n=Al(t==="rose"?5:9);if(t==="lancet"){let[l,c]=Lt(256,512);jh(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=Qh(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)bi(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 jh(c,14,10,228,492),Wi(c,e.ink,12),l}let i=512,[s,r]=Lt(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=Qh(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]])bi(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),Wi(r,e.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Wi(r,e.stoneShade,14),s}function nu(e,t){let[n,i]=Lt(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(),Wi(i,e.bannerEdge,14),s(),Wi(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")bi(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,bi(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(),bi(i,128,215,34,0.3),i.fill();return n}function iu(e){let[t,n]=Lt(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 su(e){let[t,n]=Lt(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(),Wi(n,e.ink,7),i(64,74,176,24),n.fillStyle=e.flameCore,n.fill(),t}function ru(e){let[t,n]=Lt(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Wi(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 ma(){let[e,t]=Lt(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 au(){let[e,t]=Lt(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 ou(e){let[t,n]=Lt(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 ga=0.034,Rl=0.02,Il=0.024,e0=(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 Pl(e,t,n,i){let[s,r]=Lt(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 Ll(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 lu(e,t,n){let{rim:i,ink:s,edge:r}=n,a=await e0(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*(ga+Rl+Il))+2,[d,h]=Lt(l+u*2,c+u*2),p=Pl(a,l,c,s),v=Pl(a,l,c,i),T=Pl(a,l,c,r);for(let[m,f]of Ll(t*(ga+Rl)))h.drawImage(T,u+m+t*Il*0.5,u+f+t*Il);for(let[m,f]of Ll(t*(ga+Rl)))h.drawImage(p,u+m,u+f);for(let[m,f]of Ll(t*ga))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function _a(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 Qs=Math.PI*2,xa=(e,t=0,n=1)=>Math.min(n,Math.max(t,e));function t0(e){let[t,n]=Lt(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=e.paper,r=_a(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,Qs),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,Qs);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,Qs),n.fill();return n.restore(),t}function n0(e){let[t,n]=Lt(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 i0(){let[e,t]=Lt(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 Nl{hall;group=new Jt;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=vi,this.textures.set(e,i),i}plane(e,t,n){let i=this.planes.get(e);if(i)return i;let s=new It(t,n);return this.planes.set(e,s),s}get glow(){return this.hall.additive?ti:In}puff(e,t){let n=this.hall,i=this.texture("cloud",()=>t0(n)),s=this.texture("sparkle",()=>n0(n)),r=Array.from({length:7},(o,l)=>{let c=Qs*l/7+l%2*0.4,u=new Ws(new vs({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 Ws(new vs({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:Qs*l/4+0.7}});this.runs.push({start:t,update:(o)=>{let l=xa(o/qt),c=Jn(l/0.35),u=1-(1-l)**2,d=1-xa((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*Jn(xa((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-xa((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]=Lt(256,256);return h.drawImage(pa(n),0,0,256,256),d}),s=this.texture("column",i0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Jt;o.position.set(e.x,e.y+0.03,e.z);let l=new Ge(r,new zt({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 Jt;c.position.set(e.x,e.y+0.1,e.z);let u=new zt({map:s,color:n.rune,transparent:!0,depthWrite:!1,blending:this.glow,side:hn,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<Ft},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 cu(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 I=d[W],H=h[W];if(R[H](a,_[I](C)),M)for(let ee=0,G=M.length;ee<G;ee++)U[ee][H](a,M[ee][I](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 s0(){let e=new Uint8Array([125,195,255]),t=new Xs(e,3,1,Hr,pn);return t.minFilter=Ln,t.magFilter=Ln,t.generateMipmaps=!1,t.needsUpdate=!0,t}class Dl{steps=s0();lit=new Map;flat=new Map;ink=new Ve("#000000");hullMaterial=new zt({color:this.ink,side:Yt,fog:!1});toon(e,t){let n=this.lit.get(e);if(!n)n=new ri({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 zt({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 r0(e,t){let n=e.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=cu(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=r0(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 Xi=12,js=12,a0=["moon","star","crest"];class hu{textures=[];geometries=[];materials=[];texture(e,t){let n=new Si(e);if(n.colorSpace=vi,t)n.wrapS=Fs,n.wrapT=Fs,n.repeat.set(t[0],t[1]);else n.wrapS=zn,n.wrapT=zn;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 uu(e,t,n){let i=new hu,s=new Jt,r=new Map,a=pt(t),o=a+9.5,l=(j,ve={})=>i.material(new zt({map:j,transparent:!0,depthWrite:!1,fog:!1,...ve})),c=e.additive?ti:In,u=i.texture(eu(e),[o/2.2,o/2.2]),d=new Ge(i.geometry(new ys(o+1,72)),i.material(new ri({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Ge(i.geometry(new _n(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 It((a-0.7)*2,(a-0.7)*2)),l(i.texture(pa(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 ri({color:"#ffffff",map:i.texture(tu(e),[o*Pt/7,Xi/5]),gradientMap:n.steps,side:Yt})),T=new Ge(i.geometry(new _n(o,o,Xi,72,1,!0)),v);T.position.y=Xi/2,s.add(T);let m=new Ge(i.geometry(new ys(o+1,48)),i.material(new zt({color:e.bg,side:hn})));m.rotation.x=Math.PI/2,m.position.y=Xi,s.add(m);let f=i.geometry(new _n(0.6,0.66,Xi,14)),E=i.geometry(new _n(0.88,0.7,0.5,14)),C=i.geometry(new _n(0.78,0.9,0.6,14)),y=i.geometry(new It(2.2,4.4)),b=i.geometry(new _n(0.34,0.2,0.36,10)),w=i.geometry(new _n(0.06,0.06,0.7,6)),A=i.geometry(new It(0.62,0.93)),_=i.geometry(new It(2.6,2.6)),M=l(i.texture(su(e)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),B=l(i.texture(ma()),{color:e.flame,blending:c,opacity:e.night?0.55:0.28}),R=a0.map((j)=>i.material(new zt({map:i.texture(nu(e,j)),transparent:!0,alphaTest:0.4,fog:!1}))),U=[],W=(j,ve,Se,$e)=>($e.position.set(Math.sin(j)*ve,Se,Math.cos(j)*ve),$e.rotation.y=j+Math.PI,s.add($e),$e);for(let j=0;j<js;j+=1){let ve=Pt*(j+0.5)/js,Se=new Ge(f,n.toon("pillar",e.stone));W(ve,o-0.7,Xi/2,Se),Ti(Se,n,0.06,r);let $e=new Ge(E,n.toon("pillar",e.stone));W(ve,o-0.7,Xi-0.55,$e);let Ue=new Ge(C,n.toon("pillar",e.stone));W(ve,o-0.7,0.3,Ue);let q=new Ge(y,R[j%R.length]??R[0]);W(ve,o-1.34,6.8,q);let ae=new Ge(w,n.toon("iron",e.woodDark));W(ve,o-1.4,2.8,ae),ae.rotation.x=Math.PI/2;let oe=new Ge(b,n.toon("iron",e.woodDark));W(ve,o-1.75,2.95,oe),Ti(oe,n,0.04,r);let Te=new Ge(A,M);Te.position.set(Math.sin(ve)*(o-1.75),3.5,Math.cos(ve)*(o-1.75)),Te.renderOrder=3,s.add(Te);let Le=new Ge(_,B);Le.position.copy(Te.position),Le.renderOrder=2,s.add(Le),U.push({body:Te,halo:Le,phase:j*1.7,base:1})}let I=i.geometry(new It(2.6,5.2)),H=i.geometry(new It(4.6,4.6)),ee=l(i.texture(Cl(e,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),G=l(i.texture(Cl(e,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),se=i.geometry(new It(3.4,10)),Y=l(i.texture(au()),{color:e.beam,opacity:e.beamAlpha,blending:c,side:hn}),te=[];for(let j=0;j<js;j+=1){let ve=Pt*j/js,Se=j===js/2,$e=new Ge(Se?H:I,Se?G:ee);W(ve,o-0.12,Se?7.1:6.2,$e);let Ue=new Ge(se,Y),q=o-4.4;Ue.position.set(Math.sin(ve)*q,4.4,Math.cos(ve)*q),Ue.rotation.set(0,ve+Math.PI,0),Ue.rotateX(-0.62),Ue.renderOrder=1,s.add(Ue),te.push(Ue)}return{group:s,flames:U,beams:te,wallRadius:o,dispose(){for(let j of r.values())j.dispose();i.dispose()}}}function du(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 fu(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 mu=2;var gu=(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,o0=(e,t,n)=>n<t?(t+n)/2:Math.min(n,Math.max(t,e));function pu(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)=>o0(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)=>gu(f,E)))continue;d=f,h=m}return d}function _u(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=pu(c,s,n,t);if(!u){if(u=pu(c,s,[],t),u&&n.some((h)=>gu(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 l0=1.06,c0=0.68,xu=12,h0=16;class Ul{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",ft)}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",()=>this.click(n)),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(xu,Math.min(h0,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,l0,u*c0),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||xu*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-mu}}let o=_u(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 mr(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 vu=0.62;function u0(e,t){let n=Math.atan2(e,t),i=(s)=>Math.max(-vu,Math.min(vu,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(Bt(n-Math.PI))}var er=1.3,d0=1.24,f0=0.31,p0=[512,128],va={waiting:0,alert:1,done:2,error:3};function yu(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 Fl{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 It(0.84,1.05));platePlane=this.own(new It(d0,f0));glowPlane=this.own(new It(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new It(1.25,1.25));constructor(e){this.hall=e;let t=new _n(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(iu(e)),this.glowTexture=this.texture(ma()),this.badgeTexture=this.texture(ru(e)),this.marksTexture=this.texture(ou(e));let n=(i)=>{let s=new It(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(va.waiting),alert:n(va.alert),done:n(va.done),error:n(va.error)}}own(e){return this.geometries.push(e),e}texture(e){let t=new Si(e);return t.colorSpace=vi,t.wrapS=zn,t.wrapT=zn,t.anisotropy=4,t.minFilter=rn,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 tr{init;kit;group=new Jt;rig=new Jt;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 ri({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]=p0,[p,v]=Lt(d,h);this.plateTexture=t.texture(p),this.plateText=fr(v,e.name,d,h,i),this.plateMaterial=new zt({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 zt({transparent:!0,alphaTest:0.4,fog:!1});if(this.boardMaterial=f,this.board=new Ge(new It(Je,Je),f),this.board.visible=!1,this.board.position.y=er+Je/2,s(this.board),this.glowMaterial=new zt({map:t.glowTexture,color:e.accent,transparent:!0,opacity:0,depthWrite:!1,fog:!1,blending:i.additive?ti:In}),this.glow=new Ge(t.glowPlane,this.glowMaterial),this.glow.position.set(0,er+Je/2,-0.5),this.glow.visible=!1,this.badgeMaterial=new zt({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,er+Je,0.05),this.badge.visible=!1,this.badge.renderOrder=5,this.marksMaterial=new zt({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,er+Je*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=er+Je*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+Je*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=u0(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 Su(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 m0=2,g0=1.5,_0=60,Mu=8,x0=1.22,v0=0.82,bu=(e,t,n,i)=>e+(t-e)*(1-Math.exp(-n*i)),Ol=0.2,y0=2,Tu=(e)=>e.init.id??e.init.kind;function iS(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?g0:m0,l=new El({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??Mt,d=new Ul(e,u,(F)=>{if(F.init.kind==="agent"&&F.init.id)t.onSeatClick({id:F.init.id,name:F.init.name});else if(F.init.kind==="more")t.onMore?.()}),h=Su(e,()=>s),p=new Qr,v=new cn(42,1,0.1,90),T=new la,m=new oa;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=nn(0,1),I=W,H=W,ee=0,G=0,se,Y=!1,te=()=>w?.slots??jn(C.length),j=()=>te().count,ve=(F)=>{let J=w?.slotOf.get(F);return J===void 0?void 0:Qt(J,j())},Se=()=>{let F=R?ve(R):void 0;return F===void 0?nn(U,j(),v.aspect,c.clientWidth||void 0):Or(F,j())},$e=()=>{let{position:F,target:J}=Mi(W);v.position.set(...F),v.lookAt(J[0],J[1],J[2]),v.rotateZ(W.roll);let ce=Ri(W.fov,v.aspect);if(Math.abs(v.fov-ce)>0.001)v.fov=ce,v.updateProjectionMatrix()},Ue=(F,J)=>{let ce=yr(W,F,s||J);if(ce.cut)W=F,G=0;else I=W,H=F,ee=performance.now(),G=ce.ms;return g.wake(),ce},q=()=>{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,J)=>{let ce=b.get(F),we=w;if(!ce||!we)return;let Ae=we.slotOf.get(F),Xe=Ae===void 0?void 0:we.podiums[Ae];if(Xe?.init.kind!=="agent")return;try{let ot=await lu(ce,320,{rim:we.hall.paper,ink:we.hall.ink,edge:_a(C.find((St)=>St.id===F)?.color??we.hall.gold,we.hall.ink,0.35)});if(J!==A||w!==we)return;_.set(F,{svg:ce,tone:M(),canvas:ot.canvas}),Xe.setSticker(ot.canvas),g.wake()}catch{}},oe=(F,J)=>{F.setBadge(yu(J))},Te=(F)=>{let J=++A;q();let ce=tn(f,E),we=jn(C.length),Ae=new Dl;Ae.setInk(ce.ink);let Xe=new Fl(ce),ot=uu(ce,we.count,Ae),St=new Jt;St.add(ot.group);let He=new Map,bn=[],Tn=[],ai=(ht,ut,wn=0)=>{let Zt=br(ht,we.count),Nn=1+wn/pt(we.count);ut.group.position.set(Zt.x*Nn,0.2,Zt.z*Nn),ut.group.rotation.y=Zt.yaw,Tn[ht]=ut,St.add(ut.group)};if(ai(0,new tr({id:void 0,name:t.ownerName??"You",kind:"owner",accent:ce.gold},Xe,Ae),1.2),C.slice(0,we.seated).forEach((ht,ut)=>{let wn=ut+1;He.set(ht.id,wn),bn.push(ht.id);let Zt=new tr({id:ht.id,name:ht.name,kind:"agent",accent:ht.color},Xe,Ae);Zt.setDim(ht.dim===!0),oe(Zt,y.get(ht.id)??ht.state??"idle"),ai(wn,Zt);let Nn=_.get(ht.id);if(Nn&&Nn.svg===b.get(ht.id)&&Nn.tone===M())Zt.setSticker(Nn.canvas)}),we.more>0)ai(we.count-1,new tr({id:void 0,name:`+${we.more}`,kind:"more",accent:ce.gold},Xe,Ae));if(w={hall:ce,toon:Ae,kit:Xe,built:ot,group:St,slots:we,podiums:Tn,slotOf:He,order:bn},F&&B){let ht=new Set;for(let ut of Tn){let wn={x:ut.group.position.x,z:ut.group.position.z,yaw:ut.group.rotation.y},Zt=F.from.get(Tu(ut));if(Zt)B.slides.push({podium:ut,from:Zt,to:wn}),ut.group.position.x=Zt.x,ut.group.position.z=Zt.z,ut.group.rotation.y=Zt.yaw;if(ut.init.id&&F.joining.has(ut.init.id))ut.group.visible=!1,ut.labelHidden=!0,ht.add(ut)}B.risers=[...ht]}p.add(St),St.updateMatrixWorld(!0),p.background=new Ve(ce.bg),p.fog=new Hs(ce.bg,17,46),T.color.set(ce.ambient),T.intensity=ce.ambientI,m.color.set(ce.key),m.intensity=ce.keyI;for(let ht of C.slice(0,we.seated)){let ut=_.get(ht.id);if(ut&&ut.svg===b.get(ht.id)&&ut.tone===M())continue;ae(ht.id,J)}if(R&&!He.has(R))R=null;Ue(Se(),F===void 0),d.paint(ce),d.set(Tn,(ht)=>y.get(ht.init.id??"")??"idle"),g.wake()},Le=(F)=>F.slice(0,jn(F.length).seated).map((J)=>J.id),Ne=()=>{let F=new Map;for(let J of w?.podiums??[])F.set(Tu(J),{x:J.group.position.x,z:J.group.position.z,yaw:J.group.rotation.y});return F},Ct=(F)=>{F.swapped=!0;let J=Ne();C=F.next,F.slides=[],Te({from:J,joining:new Set(F.plan.joining)});for(let ce of F.risers)F.fx?.circle({x:ce.group.position.x,y:Ol,z:ce.group.position.z},F.plan.riseAt)},We=(F)=>{for(let J of F.timers)clearTimeout(J);for(let J of F.slides)J.podium.group.position.x=J.to.x,J.podium.group.position.z=J.to.z,J.podium.group.rotation.y=J.to.yaw;for(let J of F.risers)J.group.visible=!0,J.group.position.y=Ol,J.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;g.wake()},Ke=()=>{let F=B;if(!F)return;if(!F.swapped)F.swapped=!0,C=F.next,Te();We(F)},rt=(F,J)=>{let ce={plan:J,start:performance.now(),next:F,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(B=ce,J.mode==="fade"){for(let Xe of[c,d.root])Xe.style.transition=`opacity ${mt}ms linear`,Xe.style.opacity="0";ce.timers.push(setTimeout(()=>{ce.swapped=!0,C=F,Te();for(let Xe of[c,d.root])Xe.style.opacity="1"},mt),setTimeout(()=>We(ce),mt*2));return}let we=w;if(!we)return;let Ae=new Nl(we.hall);ce.fx=Ae,p.add(Ae.group);for(let Xe of J.leaving){let ot=we.slotOf.get(Xe),St=ot===void 0?void 0:we.podiums[ot];if(!St)continue;ce.leavers.push(St),Ae.puff({x:St.group.position.x,y:y0,z:St.group.position.z},0)}if(J.swapAt===0)Ct(ce);g.wake()},je=(F)=>{let J=B;if(!J||J.plan.mode!=="play")return J!==void 0;let ce=Math.max(0,F-J.start);if(!J.swapped){let Ae=_r(ce);for(let Xe of J.leavers)if(Xe.group.scale.set(Ae.scaleX,Ae.scaleY,Ae.scaleX),Ae.gone)Xe.group.visible=!1;if(ce>=J.plan.swapAt)Ct(J)}if(J.swapped){let Ae=kr(ce-J.plan.swapAt);for(let{podium:ot,from:St,to:He}of J.slides)ot.group.position.x=St.x+(He.x-St.x)*Ae,ot.group.position.z=St.z+(He.z-St.z)*Ae,ot.group.rotation.y=Tr(St.yaw,He.yaw,Ae);let Xe=ei(ce-J.plan.riseAt);for(let ot of J.risers)ot.group.visible=Xe.shown,ot.group.position.y=Ol-Xe.depth*wr,ot.labelHidden=!Xe.named}let we=J.fx?.step(ce)??!1;if(ce>=J.plan.total&&!we)return We(J),!1;return!0},Dt,at=new O,kt=0,Et=0,Rt=0,L=0,Gt=0,nt=0,xt=performance.now(),g=fu({frame:(F,J)=>{let ce=performance.now();kt+=J/1000;let we=!1;if(je(F))we=!0;if(G>0){let ot=(F-ee)/G;if(ot>=1)W=H,G=0;else W=gr(I,H,Kn(ot)),we=!0}else if(se)we=!0;$e(),v.getWorldPosition(at);let Ae=w;if(Ae){let ot=R===null?void 0:Ae.slotOf.get(R);for(let He of Ae.podiums)He.group.updateMatrixWorld(!0);let St=d.place(v,at,e.clientWidth,e.clientHeight,ot===void 0?void 0:Ae.podiums[ot]);if(R===null&&St!==Dt)Dt=St,t.onNames?.(St);du(Ae.built.flames,kt,s);for(let He of Ae.built.flames)He.body.lookAt(at.x,He.body.position.y,at.z);for(let He of Ae.podiums){if(He.init.kind!=="agent")continue;let bn=y.get(He.init.id??"")??"idle",Tn=bn==="speaking"?1:0,ai=bn==="thinking"||bn==="working"?1:0,ht=He.speak;He.speak=s?Tn:bu(He.speak,Tn,7,J/1000),He.bob=s?0:bu(He.bob,ai,5,J/1000);let ut=He.speak>0.02;if(He.glow.visible=ut&&He.board.visible,He.glowMaterial.opacity=0.85*He.speak,He.board.position.y=He.boardY+Math.sin(kt*3.1+He.phase)*0.035*He.bob,He.face(at),He.markFrame(bn==="speaking",kt,s))we=!0;if(Math.abs(He.speak-Tn)>0.01||Math.abs(ht-He.speak)>0.001||He.bob>0.02)we=!0}}l.render(p,v),Rt+=1,Et+=1;let Xe=performance.now()-ce;if(L+=Xe,Gt=Math.max(Gt,Xe),F-xt>=1000)nt=Et*1000/(F-xt),P={...P,fps:nt,frameMs:L/Math.max(Et,1),frameMsMax:Gt},Et=0,L=0,Gt=0,xt=F;return we},host:{request:(F)=>requestAnimationFrame(F),cancel:(F)=>cancelAnimationFrame(F),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),P={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},V=()=>{let{clientWidth:F,clientHeight:J}=e;if(F<=0||J<=0)return;if(l.setSize(F,J,!1),v.aspect=F/J,v.updateProjectionMatrix(),R===null&&!se&&w)if(G===0)W=Se();else H=Se();d.size(F),g.wake()},ne=new ResizeObserver(V);ne.observe(e);let le=new IntersectionObserver((F)=>{for(let J of F)g.setVisible(J.isIntersecting)});le.observe(e);let fe=()=>g.sync();document.addEventListener("visibilitychange",fe);let Z=(F)=>{F.preventDefault(),n?.()};c.addEventListener("webglcontextlost",Z);let Q=(F,J,ce)=>{let we=F!==null&&w?.slotOf.has(F)?F:null;if(we===R)return;R=we;let Ae=Ue(Se(),J);if(we!==null&&Y&&!Ae.cut)h.play();if(ce)t.onFocus?.(we)},ge=new ze,Ie=new ca,ue=(F,J)=>{let ce=w;if(!ce)return;let we=c.getBoundingClientRect();return ge.set((F-we.left)/we.width*2-1,-((J-we.top)/we.height)*2+1),Ie.setFromCamera(ge,v),Ie.intersectObjects(ce.podiums.filter((Xe)=>Xe.group.visible).flatMap((Xe)=>Xe.hits).filter((Xe)=>Xe.visible),!1)[0]?.object.userData},re=new Map,Ee,De=0,Ze=!1,N=()=>{let[F,J]=[...re.values()];return F&&J?Math.hypot(F.x-J.x,F.y-J.y):0},he=(F)=>{if(re.set(F.pointerId,{x:F.clientX,y:F.clientY}),re.size===2){De=N(),Ze=!1,Ee=void 0,se=void 0;return}let J=c.getBoundingClientRect(),ce=!xr(F.clientX,F.clientY,J,{width:innerWidth,height:innerHeight});if(Ee={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"},K=(F)=>{if(re.has(F.pointerId))re.set(F.pointerId,{x:F.clientX,y:F.clientY});if(re.size===2&&De>0&&!Ze){let we=N()/De,Ae=we>x0?"in":we<v0?"out":"none";if(Ae!=="none")Ze=!0,pe(Ae==="in"?-1:1);return}if(!Ee){if(F.buttons===0)c.style.cursor=ue(F.clientX,F.clientY)?"pointer":"grab";return}if(!Ee.ok||R!==null)return;let J=F.clientX-Ee.x;if(Math.abs(J)<Mu&&!se)return;let ce=Ee.az+vr(J,c.clientWidth);se={az:ce},W=nn(ce,j(),v.aspect,c.clientWidth||void 0),G=0,g.wake()},de=(F)=>{if(re.delete(F.pointerId),re.size<2)De=0;c.style.cursor="grab";let J=Ee;if(Ee=void 0,!J||Ze){if(re.size===0)Ze=!1;return}let ce=F.clientX-J.x,we=F.clientY-J.y;if(se){U=Qi(se.az,j()),se=void 0,Ue(nn(U,j(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ce,we)<Mu){if(J.hold&&performance.now()-J.at>=gi)return;let Ae=ue(F.clientX,F.clientY);if(!Ae)return;if(Ae.kind==="agent"&&Ae.seat){let Xe=C.find((ot)=>ot.id===Ae.seat);if(Xe)t.onSeatClick({id:Xe.id,name:Xe.name})}else if(Ae.kind==="more")t.onMore?.();else if(Ae.kind==="owner"&&R!==null)Q(null,!1,!0);return}if(J.ok&&R!==null&&Math.abs(ce)>=_0&&Math.abs(ce)>Math.abs(we))ie(ce<0?1:-1)},ye=(F)=>{if(re.delete(F.pointerId),Ee=void 0,se)U=Qi(se.az,j()),se=void 0,Ue(nn(U,j(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ie=(F)=>{let J=w;if(!J||R===null||J.order.length<2)return;let ce=J.order.indexOf(R),we=J.order[(ce+F+J.order.length)%J.order.length];if(we)Q(we,!1,!0)},pe=(F)=>{let J=w;if(!J)return;let ce=Sr(F,R!==null);if(ce==="in"){let we=pr(U,J.slots),Ae=we===void 0?void 0:J.order[we-1];if(Ae)Q(Ae,!1,!0)}else if(ce==="out")Q(null,!1,!0)},Be=0,ct=(F)=>{F.preventDefault();let J=performance.now();if(J-Be<450||Math.abs(F.deltaY)<4)return;Be=J,pe(F.deltaY)};c.addEventListener("pointerdown",he),c.addEventListener("pointermove",K),c.addEventListener("pointerup",de),c.addEventListener("pointercancel",ye),c.addEventListener("wheel",ct,{passive:!1});let st=(F)=>F.length===C.length&&F.every((J,ce)=>J.id===C[ce]?.id&&J.name===C[ce]?.name&&J.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 Te(),W=Se(),V(),Y=!0,{kind:"webgl",setTheme(F,J){if(F===f&&J===E)return;Ke(),f=F,E=J,Te()},setSeats(F){Ke();let J=!st(F),ce=F.map((Ae)=>({...Ae})),we=J&&Y&&w?Rn(Le(C),Le(ce),s):void 0;for(let Ae of ce){if(Ae.state)y.set(Ae.id,Ae.state);if(Ae.avatarSvg&&Ae.avatarSvg!==b.get(Ae.id))b.set(Ae.id,Ae.avatarSvg)}if(we&&we.mode!=="cut"){rt(ce,we);return}if(C=ce,J)Te();else{let Ae=w;for(let Xe of C){let ot=Ae?.slotOf.get(Xe.id);(ot===void 0?void 0:Ae?.podiums[ot])?.setDim(Xe.dim===!0),ae(Xe.id,A)}}g.wake()},setState(F,J){y.set(F,J);let ce=w?.slotOf.get(F),we=ce===void 0?void 0:w?.podiums[ce];if(we)oe(we,J),d.relabel(we,J);g.wake()},async setAvatar(F,J){b.set(F,J),await ae(F,A)},setReducedMotion(F){if(s=F,P.reduced=F,F)Ue(Se(),!0);g.wake()},resetCamera(){U=0,Q(null,!1,!0),Ue(Se(),!1)},focus(F,J){Q(F,J?.cut===!0,!1)},focused:()=>R,seatAt(F,J){let ce=ue(F,J);return ce?.kind==="agent"?ce.seat:null},getStats(){let F=l.info;return{...P,drawCalls:F.render.calls,triangles:F.render.triangles,textures:F.memory.textures,geometries:F.memory.geometries,loop:g.state,seats:C.length,renders:Rt,reduced:s}},dispose(){if(B){for(let F of B.timers)clearTimeout(F);B.fx?.dispose(),B=void 0}g.dispose(),ne.disconnect(),le.disconnect(),document.removeEventListener("visibilitychange",fe),c.removeEventListener("webglcontextlost",Z),c.removeEventListener("pointerdown",he),c.removeEventListener("pointermove",K),c.removeEventListener("pointerup",de),c.removeEventListener("pointercancel",ye),c.removeEventListener("wheel",ct),h.dispose(),d.dispose(),q(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{iS as createTable3D};
|
|
4220
|
+
}`;class Jh{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ia(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:Yg,fragmentShader:Zg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ge(new Ct(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $h extends jn{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 Jh,m={},f=t.getContextAttributes(),E=null,C=null,y=[],b=[],w=new ze,A=null,_=null,M=new on;M.viewport=new wt;let B=new on;B.viewport=new wt;let R=[M,B],U=new ul,W=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ae=y[q];if(ae===void 0)ae=new Zs,y[q]=ae;return ae.getTargetRaySpace()},this.getControllerGrip=function(q){let ae=y[q];if(ae===void 0)ae=new Zs,y[q]=ae;return ae.getGripSpace()},this.getHand=function(q){let ae=y[q];if(ae===void 0)ae=new Zs,y[q]=ae;return ae.getHandSpace()};function H(q){let ae=b.indexOf(q.inputSource);if(ae===-1)return;let oe=y[ae];if(oe!==void 0)oe.update(q.inputSource,q.frame,l||r),oe.dispatchEvent({type:q.type,data:q.inputSource})}function ee(){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",ee),i.removeEventListener("inputsourceschange",G);for(let q=0;q<y.length;q++){let ae=b[q];if(ae===null)continue;b[q]=null,y[q].disconnect(ae)}W=null,I=null,T.reset();for(let q in m)delete m[q];if(e.setRenderTarget(E),h=null,d=null,u=null,i=null,C=null,Ue.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(w.width,w.height,!1),_!==null){let q=_.camera;q.fov=_.fov,q.zoom=_.zoom,q.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){if(s=q,n.isPresenting===!0)Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){if(a=q,n.isPresenting===!0)Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(q){l=q},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(q){if(i=q,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",ee),i.addEventListener("inputsourceschange",G),f.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(w),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let oe={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,t,oe),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new fn(h.framebufferWidth,h.framebufferHeight,{format:kn,type:dn,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let oe=null,Te=null,Le=null;if(f.depth)Le=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=f.stencil?Pi:Ii,Te=f.stencil?ws:_i;let Ne={colorFormat:t.RGBA8,depthFormat:Le,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ne),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),C=new fn(d.textureWidth,d.textureHeight,{format:kn,type:dn,depthTexture:new Ui(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,oe),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),Ue.setContext(i),Ue.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(q){for(let ae=0;ae<q.removed.length;ae++){let oe=q.removed[ae],Te=b.indexOf(oe);if(Te>=0)b[Te]=null,y[Te].disconnect(oe)}for(let ae=0;ae<q.added.length;ae++){let oe=q.added[ae],Te=b.indexOf(oe);if(Te===-1){for(let Ne=0;Ne<y.length;Ne++)if(Ne>=b.length){b.push(oe),Te=Ne;break}else if(b[Ne]===null){b[Ne]=oe,Te=Ne;break}if(Te===-1)break}let Le=y[Te];if(Le)Le.connect(oe)}}let se=new O,Y=new O;function te(q,ae,oe){se.setFromMatrixPosition(ae.matrixWorld),Y.setFromMatrixPosition(oe.matrixWorld);let Te=se.distanceTo(Y),Le=ae.projectionMatrix.elements,Ne=oe.projectionMatrix.elements,Et=Le[14]/(Le[10]-1),We=Le[14]/(Le[10]+1),$e=(Le[9]+1)/Le[5],st=(Le[9]-1)/Le[5],Qe=(Le[8]-1)/Le[0],Lt=(Ne[8]+1)/Ne[0],rt=Et*Qe,Ot=Et*Lt,bt=Te/(-Qe+Lt),At=bt*-Qe;if(ae.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(At),q.translateZ(bt),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Le[10]===-1)q.projectionMatrix.copy(ae.projectionMatrix),q.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{let L=Et+bt,Bt=We+bt,tt=rt-At,mt=Ot+(Te-At),S=$e*We/Bt*L,g=st*We/Bt*L;q.projectionMatrix.makePerspective(tt,mt,S,g,L,Bt),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function j(q,ae){if(ae===null)q.matrixWorld.copy(q.matrix);else q.matrixWorld.multiplyMatrices(ae.matrixWorld,q.matrix);q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(i===null)return;let{near:ae,far:oe}=q;if(T.texture!==null){if(T.depthNear>0)ae=T.depthNear;if(T.depthFar>0)oe=T.depthFar}if(U.near=B.near=M.near=ae,U.far=B.far=M.far=oe,W!==U.near||I!==U.far)i.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,I=U.far;U.layers.mask=q.layers.mask|6,M.layers.mask=U.layers.mask&-5,B.layers.mask=U.layers.mask&-3;let Te=q.parent,Le=U.cameras;j(U,Te);for(let Ne=0;Ne<Le.length;Ne++)j(Le[Ne],Te);if(Le.length===2)te(U,M,B);else U.projectionMatrix.copy(M.projectionMatrix);if(_===null&&q.isPerspectiveCamera)_={camera:q,fov:q.fov,zoom:q.zoom};ve(q,U,Te)};function ve(q,ae,oe){if(oe===null)q.matrix.copy(ae.matrixWorld);else q.matrix.copy(oe.matrixWorld),q.matrix.invert(),q.matrix.multiply(ae.matrixWorld);if(q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(ae.projectionMatrix),q.projectionMatrixInverse.copy(ae.projectionMatrixInverse),q.isPerspectiveCamera)q.fov=Lr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1}this.getCamera=function(){return U},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(q){if(o=q,d!==null)d.fixedFoveation=q;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=q},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)},this.getCameraTexture=function(q){return m[q]};let Se=null;function Je(q,ae){if(c=ae.getViewerPose(l||r),p=ae,c!==null){let oe=c.views;if(h!==null)e.setRenderTargetFramebuffer(C,h.framebuffer),e.setRenderTarget(C);let Te=!1;if(oe.length!==U.cameras.length)U.cameras.length=0,Te=!0;for(let We=0;We<oe.length;We++){let $e=oe[We],st=null;if(h!==null)st=h.getViewport($e);else{let Lt=u.getViewSubImage(d,$e);if(st=Lt.viewport,We===0)e.setRenderTargetTextures(C,Lt.colorTexture,Lt.depthStencilTexture),e.setRenderTarget(C)}let Qe=R[We];if(Qe===void 0)Qe=new on,Qe.layers.enable(We),Qe.viewport=new wt,R[We]=Qe;if(Qe.matrix.fromArray($e.transform.matrix),Qe.matrix.decompose(Qe.position,Qe.quaternion,Qe.scale),Qe.projectionMatrix.fromArray($e.projectionMatrix),Qe.projectionMatrixInverse.copy(Qe.projectionMatrix).invert(),Qe.viewport.set(st.x,st.y,st.width,st.height),We===0)U.matrix.copy(Qe.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);if(Te===!0)U.cameras.push(Qe)}let Le=i.enabledFeatures;if(Le&&Le.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let We=u.getDepthInformation(oe[0]);if(We&&We.isValid&&We.texture)T.init(We,i.renderState)}if(Le&&Le.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let We=0;We<oe.length;We++){let $e=oe[We].camera;if($e){let st=m[$e];if(!st)st=new ia,m[$e]=st;let Qe=u.getCameraImage($e);st.sourceTexture=Qe}}}}for(let oe=0;oe<y.length;oe++){let Te=b[oe],Le=y[oe];if(Te!==null&&Le!==void 0)Le.update(Te,ae,l||r)}if(Se)Se(q,ae);if(ae.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:ae});p=null}let Ue=new Bh;Ue.setAnimationLoop(Je),this.setAnimationLoop=function(q){Se=q},this.dispose=function(){}}}var Jg=new St,Kh=new ke;Kh.set(-1,0,0,0,1,0,0,0,1);function $g(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,Jo(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(Jg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(Kh);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 Kg(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 Fe("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 I=R[U],H=Array.isArray(I.value)?I.value:[I.value];for(let ee=0,G=H.length;ee<G;ee++){let se=H[ee],Y=f(se),te=w%A,j=te%Y.boundary,ve=te+j;if(w+=j,ve!==0&&A-ve<Y.storage)w+=A-ve;I.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=w,w+=Y.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 Qg=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 jg(){if(Hn===null)Hn=new Qs(Qg,16,16,Li,zn),Hn.name="DFG_LUT",Hn.minFilter=nn,Hn.magFilter=nn,Hn.wrapS=Bn,Hn.wrapT=Bn,Hn.generateMipmaps=!1,Hn.needsUpdate=!0;return Hn}class El{constructor(e={}){let{canvas:t=ah(),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=dn}=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([oo,ao,ro]),m=new Set([dn,_i,Xs,ws,io,so]),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=In,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,B=!1,R=null,U=null,W=null,I=null;this._outputColorSpace=xi;let H=0,ee=0,G=null,se=-1,Y=null,te=new wt,j=new wt,ve=null,Se=new Ve(0),Je=0,{width:Ue,height:q}=t,ae=1,oe=null,Te=null,Le=new wt(0,0,Ue,q),Ne=new wt(0,0,Ue,q),Et=!1,We=new js,$e=!1,st=!1,Qe=new St,Lt=new O,rt=new wt,Ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},bt=!1;function At(){return G===null?ae:1}let L=n;function Bt(x,D){return t.getContext(x,D)}let tt,mt,S,g,P,V,ne,le,fe,Z,Q,ge,Ie,ue,re,Ee,De,Ze,N,he,K,de,ye;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${uc}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",it,!1),L===null){if(L=Bt("webgl2",x),L===null)if(Bt("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ie()}catch(x){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Fe("WebGLRenderer: "+x.message),x}function ie(){if(tt=new am(L),tt.init(),K=new qg(L,tt),mt=new $p(L,tt,e,K),S=new Wg(L,tt),mt.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);U=L.createFramebuffer(),W=L.createFramebuffer(),I=L.createFramebuffer(),g=new cm(L),P=new Ig,V=new Xg(L,tt,S,P,mt,K,g),ne=new rm(M),le=new hd(L),de=new Zp(L,le),fe=new om(L,le,g,de),Z=new um(L,fe,le,de,g),Ze=new hm(L,mt,V),re=new Kp(P),Q=new Rg(M,ne,tt,mt,de,re),ge=new $g(M,P),Ie=new Lg,ue=new Bg(tt),De=new Yp(M,ne,S,Z,p,o),Ee=new Vg(M,Z,mt),ye=new Kg(L,g,mt,S),N=new Jp(L,tt,g),he=new lm(L,tt,g),g.programs=Q.programs,M.capabilities=mt,M.extensions=tt,M.properties=P,M.renderLists=Ie,M.shadowMap=Ee,M.state=S,M.info=g}if(v!==dn)_=new fm(v,t.width,t.height,a,i,s);let pe=new $h(M,L);this.xr=pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let x=tt.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=tt.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(x){if(x===void 0)return;ae=x,this.setSize(Ue,q,!1)},this.getSize=function(x){return x.set(Ue,q)},this.setSize=function(x,D,X=!0){if(pe.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Ue=x,q=D,t.width=Math.floor(x*ae),t.height=Math.floor(D*ae),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(Ue*ae,q*ae).floor()},this.setDrawingBufferSize=function(x,D,X){Ue=x,q=D,ae=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===dn){Fe("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(Le)},this.setViewport=function(x,D,X,z){if(x.isVector4)Le.set(x.x,x.y,x.z,x.w);else Le.set(x,D,X,z);S.viewport(te.copy(Le).multiplyScalar(ae).round())},this.getScissor=function(x){return x.copy(Ne)},this.setScissor=function(x,D,X,z){if(x.isVector4)Ne.set(x.x,x.y,x.z,x.w);else Ne.set(x,D,X,z);S.scissor(j.copy(Ne).multiplyScalar(ae).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(x){S.setScissorTest(Et=x)},this.setOpaqueSort=function(x){oe=x},this.setTransparentSort=function(x){Te=x},this.getClearColor=function(x){return x.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,X=!0){let z=0;if(x){let k=!1;if(G!==null){let xe=G.texture.format;k=T.has(xe)}if(k){let xe=G.texture.type,be=m.has(xe),_e=De.getClearColor(),Ce=De.getClearAlpha(),{r:Pe,g:qe,b:Ke}=_e;if(be)f[0]=Pe,f[1]=qe,f[2]=Ke,f[3]=Ce,L.clearBufferuiv(L.COLOR,0,f);else E[0]=Pe,E[1]=qe,E[2]=Ke,E[3]=Ce,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",it,!1),De.dispose(),Ie.dispose(),ue.dispose(),P.dispose(),ne.dispose(),Z.dispose(),de.dispose(),ye.dispose(),Q.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",at),pe.removeEventListener("sessionend",vt),He.stop()};function Be(x){x.preventDefault(),zs("WebGLRenderer: Context Lost."),B=!0}function ct(){zs("WebGLRenderer: Context Restored."),B=!1;let x=g.autoReset,D=Ee.enabled,X=Ee.autoUpdate,z=Ee.needsUpdate,k=Ee.type;ie(),g.autoReset=x,Ee.enabled=D,Ee.autoUpdate=X,Ee.needsUpdate=z,Ee.type=k}function it(x){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function F(x){let D=x.target;D.removeEventListener("dispose",F),J(D)}function J(x){ce(x),P.remove(x)}function ce(x){let D=P.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,xe){if(D===null)D=Ot;let be=k.isMesh&&k.matrixWorld.determinantAffine()<0,_e=Eu(x,D,X,z,k);S.setMaterial(z,be);let Ce=X.index,Pe=1;if(z.wireframe===!0){if(Ce=fe.getWireframeAttribute(X),Ce===void 0)return;Pe=2}let qe=X.drawRange,Ke=X.attributes.position,Re=qe.start*Pe,ot=(qe.start+qe.count)*Pe;if(xe!==null)Re=Math.max(Re,xe.start*Pe),ot=Math.min(ot,(xe.start+xe.count)*Pe);if(Ce!==null)Re=Math.max(Re,0),ot=Math.min(ot,Ce.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ot=Math.min(ot,Ke.count);let Nt=ot-Re;if(Nt<0||Nt===1/0)return;de.setup(k,z,_e,X,Ce);let Mt,gt=N;if(Ce!==null)Mt=le.get(Ce),gt=he,gt.setIndex(Mt);if(k.isMesh)if(z.wireframe===!0)S.setLineWidth(z.wireframeLinewidth*At()),gt.setMode(L.LINES);else gt.setMode(L.TRIANGLES);else if(k.isLine){let Qt=z.linewidth;if(Qt===void 0)Qt=1;if(S.setLineWidth(Qt*At()),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(!tt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Qt,_multiDrawCounts:Me,_multiDrawCount:rn}=k,nt=Ce?le.get(Ce).bytesPerElement:1,_n=P.get(z).currentProgram.getUniforms();for(let Nn=0;Nn<rn;Nn++)_n.setValue(L,"_gl_DrawID",Nn),gt.render(Qt[Nn]/nt,Me[Nn])}else gt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else if(k.isInstancedMesh)gt.renderInstances(Re,Nt,k.count);else if(X.isInstancedBufferGeometry){let Qt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Me=Math.min(X.instanceCount,Qt);gt.renderInstances(Re,Nt,Me)}else gt.render(Re,Nt)};function we(x,D,X,z){if(R!==null&&x.isNodeMaterial)R.setObject(z,x);if($e===!0)re.setState(x,X,!1);if(x.transparent===!0&&x.side===ln&&x.forceSinglePass===!1)x.side=qt,x.needsUpdate=!0,wn(x,D,z),x.side=Ms,x.needsUpdate=!0,wn(x,D,z),x.side=ln;else wn(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=ue.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,$e=re.init(this.clippingPlanes,st),$e===!0)re.setGlobalState(this.clippingPlanes,D);if(R!==null)Ee.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 xe=k.material;if(xe)if(Array.isArray(xe))for(let be=0;be<xe.length;be++){let _e=xe[be];we(_e,X,D,k),z.add(_e)}else we(xe,X,D,k),z.add(xe)}),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 xe(){if(z.forEach(function(be){let Ce=P.get(be).currentProgram;if(Ce===void 0||Ce.isReady())z.delete(be)}),z.size===0){k(x);return}setTimeout(xe,10)}if(tt.get("KHR_parallel_shader_compile")!==null)xe();else setTimeout(xe,10)})};let Ae=null;function Xe(x){if(Ae)Ae(x)}function at(){He.stop()}function vt(){He.start()}let He=new Bh;if(He.setAnimationLoop(Xe),typeof self<"u")He.setContext(self);this.setAnimationLoop=function(x){Ae=x,pe.setAnimationLoop(x),x===null?He.stop():He.start()},pe.addEventListener("sessionstart",at),pe.addEventListener("sessionend",vt),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(R!==null)R.renderStart(x,D);let X=pe.enabled===!0&&pe.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(pe.enabled===!0&&pe.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(D);D=pe.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,G);if(b=ue.get(x,A.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),A.push(b),Qe.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),We.setFromProjectionMatrix(Qe,Vo,D.reversedDepth),st=this.localClippingEnabled,$e=re.init(this.clippingPlanes,st),y=Ie.get(x,w.length),y.init(),w.push(y),pe.enabled===!0&&pe.isPresenting===!0){let be=M.xr.getDepthSensingMesh();if(be!==null)bn(be,D,-1/0,M.sortObjects)}if(bn(x,D,0,M.sortObjects),y.finish(),R!==null)R.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(oe,Te);if(bt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,bt)De.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if($e===!0)re.beginShadows();let k=b.state.shadowsArray;if(Ee.render(k,x,D),$e===!0)re.endShadows();if((z&&_.hasRenderPass())===!1){let be=y.opaque,_e=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Ce=D.cameras;if(_e.length>0)for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Ke=Ce[Pe];ni(be,_e,x,Ke)}if(bt)De.render(x);for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Ke=Ce[Pe];Tn(y,x,Ke,Ke.viewport)}}else{if(_e.length>0)ni(be,_e,x,D);if(bt)De.render(x);Tn(y,x,D)}}if(G!==null&&ee===0)V.updateMultisampleRenderTarget(G),V.updateRenderTargetMipmap(G);if(z)_.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(de.resetDefaultState(),se=-1,Y=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),$e===!0)re.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 bn(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(We)){if(z)rt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Qe);let be=Z.update(x),_e=x.material;if(_e.visible)y.push(x,be,_e,X,rt.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum(We)){let be=Z.update(x),_e=x.material;if(z){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();rt.copy(x.boundingSphere.center)}else{if(be.boundingSphere===null)be.computeBoundingSphere();rt.copy(be.boundingSphere.center)}rt.applyMatrix4(x.matrixWorld).applyMatrix4(Qe)}if(Array.isArray(_e)){let Ce=be.groups;for(let Pe=0,qe=Ce.length;Pe<qe;Pe++){let Ke=Ce[Pe],Re=_e[Ke.materialIndex];if(Re&&Re.visible)y.push(x,be,Re,X,rt.z,Ke,D)}}else if(_e.visible)y.push(x,be,_e,X,rt.z,null,D)}}}let xe=x.children;for(let be=0,_e=xe.length;be<_e;be++)bn(xe[be],D,X,z)}function Tn(x,D,X,z){let{opaque:k,transmissive:xe,transparent:be}=x;if(b.setupLightsView(X),$e===!0)re.setGlobalState(M.clippingPlanes,X);if(z)S.viewport(te.copy(z));if(k.length>0)ht(k,D,X);if(xe.length>0)ht(xe,D,X);if(be.length>0)ht(be,D,X);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function ni(x,D,X,z){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){let Re=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new fn(1,1,{generateMipmaps:!0,type:Re?zn:dn,minFilter:Ri,samples:Math.max(4,mt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let xe=b.state.transmissionRenderTarget[z.id],be=z.viewport||te;xe.setSize(be.z*M.transmissionResolutionScale,be.w*M.transmissionResolutionScale);let _e=M.getRenderTarget(),Ce=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(xe),M.getClearColor(Se),Je=M.getClearAlpha(),Je<1)M.setClearColor(16777215,0.5);if(M.clear(),bt)De.render(X);let qe=M.toneMapping;M.toneMapping=In;let Ke=z.viewport;if(z.viewport!==void 0)z.viewport=void 0;if(b.setupLightsView(z),$e===!0)re.setGlobalState(M.clippingPlanes,z);if(ht(x,X,z),V.updateMultisampleRenderTarget(xe),V.updateRenderTargetMipmap(xe),tt.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ot=0,Nt=D.length;ot<Nt;ot++){let Mt=D[ot],{object:gt,geometry:Qt,material:Me,group:rn}=Mt;if(Me.side===ln&>.layers.test(z.layers)){let nt=Me.side;Me.side=qt,Me.needsUpdate=!0,ut(gt,X,z,Qt,Me,rn),Me.side=nt,Me.needsUpdate=!0,Re=!0}}if(Re===!0)V.updateMultisampleRenderTarget(xe),V.updateRenderTargetMipmap(xe)}if(M.setRenderTarget(_e,Ce,Pe),M.setClearColor(Se,Je),Ke!==void 0)z.viewport=Ke;M.toneMapping=qe}function ht(x,D,X){let z=D.isScene===!0?D.overrideMaterial:null;for(let k=0,xe=x.length;k<xe;k++){let be=x[k],{object:_e,geometry:Ce,group:Pe}=be,qe=be.material;if(qe.allowOverride===!0&&z!==null)qe=z;if(_e.layers.test(X.layers))ut(_e,D,X,Ce,qe,Pe)}}function ut(x,D,X,z,k,xe){if(R!==null&&k.isNodeMaterial)R.setObject(x,k);if(x.onBeforeRender(M,D,X,z,k,xe),x.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),k.onBeforeRender(M,D,X,z,x,xe),k.transparent===!0&&k.side===ln&&k.forceSinglePass===!1)k.side=qt,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,xe),k.side=Ms,k.needsUpdate=!0,M.renderBufferDirect(X,D,z,k,x,xe),k.side=ln;else M.renderBufferDirect(X,D,z,k,x,xe);x.onAfterRender(M,D,X,z,k,xe)}function wn(x,D,X){if(D.isScene!==!0)D=Ot;let z=P.get(x),k=b.state.lights,xe=b.state.shadowsArray,be=k.state.version,_e=Q.getParameters(x,k.state,xe,D,X,b.state.lightProbeGridArray),Ce=Q.getProgramCacheKey(_e),Pe=z.programs;z.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,z.fog=D.fog;let qe=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(z.envMap=ne.get(x.envMap||z.environment,qe),z.envMapRotation=z.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Pe===void 0)x.addEventListener("dispose",F),Pe=new Map,z.programs=Pe;let Ke=Pe.get(Ce);if(Ke!==void 0){if(z.currentProgram===Ke&&z.lightsStateVersion===be)return Ln(x,_e),Ke}else{if(_e.uniforms=Q.getUniforms(x),R!==null&&x.isNodeMaterial)R.build(x,X,_e);x.onBeforeCompile(_e,M),Ke=Q.acquireProgram(_e,Ce),Pe.set(Ce,Ke),z.uniforms=_e.uniforms}let Re=z.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Re.clippingPlanes=re.uniform;if(Ln(x,_e),z.needsLights=Cu(x),z.lightsStateVersion=be,z.needsLights)Re.ambientLightColor.value=k.state.ambient,Re.lightProbe.value=k.state.probe,Re.sunLights.value=k.state.sun,Re.sunLightShadows.value=k.state.sunShadow,Re.directionalLights.value=k.state.directional,Re.directionalLightShadows.value=k.state.directionalShadow,Re.spotLights.value=k.state.spot,Re.spotLightShadows.value=k.state.spotShadow,Re.rectAreaLights.value=k.state.rectArea,Re.ltc_1.value=k.state.rectAreaLTC1,Re.ltc_2.value=k.state.rectAreaLTC2,Re.pointLights.value=k.state.point,Re.pointLightShadows.value=k.state.pointShadow,Re.hemisphereLights.value=k.state.hemi,Re.sunShadowMatrix.value=k.state.sunShadowMatrix,Re.sunShadowCascade.value=k.state.sunShadowCascade,Re.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Re.spotLightMatrix.value=k.state.spotLightMatrix,Re.spotLightMap.value=k.state.spotLightMap,Re.pointShadowMatrix.value=k.state.pointShadowMatrix;return z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=Ke,z.uniformsList=null,Ke}function Zt(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=rr.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function Ln(x,D){let X=P.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 wu(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 Eu(x,D,X,z,k){if(D.isScene!==!0)D=Ot;V.resetTextureUnits();let xe=D.fog,be=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?D.environment:null,_e=G===null?M.outputColorSpace:G.isXRRenderTarget===!0?G.texture.colorSpace:je.workingColorSpace,Ce=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Pe=ne.get(z.envMap||be,Ce),qe=z.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ke=!!X.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Re=!!X.morphAttributes.position,ot=!!X.morphAttributes.normal,Nt=!!X.morphAttributes.color,Mt=In;if(z.toneMapped){if(G===null||G.isXRRenderTarget===!0)Mt=M.toneMapping}let gt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Qt=gt!==void 0?gt.length:0,Me=P.get(z),rn=b.state.lights;if($e===!0){if(st===!0||x!==Y){let yt=x===Y&&z.id===se;re.setState(z,x,yt)}}let nt=!1;if(z.version===Me.__version){if(Me.needsLights&&Me.lightsStateVersion!==rn.state.version)nt=!0;else if(Me.outputColorSpace!==_e)nt=!0;else if(k.isBatchedMesh&&Me.batching===!1)nt=!0;else if(!k.isBatchedMesh&&Me.batching===!0)nt=!0;else if(k.isBatchedMesh&&Me.batchingColor===!0&&k._colorsTexture===null)nt=!0;else if(k.isBatchedMesh&&Me.batchingColor===!1&&k._colorsTexture!==null)nt=!0;else if(k.isInstancedMesh&&Me.instancing===!1)nt=!0;else if(!k.isInstancedMesh&&Me.instancing===!0)nt=!0;else if(k.isSkinnedMesh&&Me.skinning===!1)nt=!0;else if(!k.isSkinnedMesh&&Me.skinning===!0)nt=!0;else if(k.isInstancedMesh&&Me.instancingColor===!0&&k.instanceColor===null)nt=!0;else if(k.isInstancedMesh&&Me.instancingColor===!1&&k.instanceColor!==null)nt=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!0&&k.morphTexture===null)nt=!0;else if(k.isInstancedMesh&&Me.instancingMorph===!1&&k.morphTexture!==null)nt=!0;else if(Me.envMap!==Pe)nt=!0;else if(z.fog===!0&&Me.fog!==xe)nt=!0;else if(Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==re.numPlanes||Me.numIntersection!==re.numIntersection))nt=!0;else if(Me.vertexAlphas!==qe)nt=!0;else if(Me.vertexTangents!==Ke)nt=!0;else if(Me.morphTargets!==Re)nt=!0;else if(Me.morphNormals!==ot)nt=!0;else if(Me.morphColors!==Nt)nt=!0;else if(Me.toneMapping!==Mt)nt=!0;else if(Me.morphTargetsCount!==Qt)nt=!0;else if(!!Me.lightProbeGrid!==b.state.lightProbeGridArray.length>0)nt=!0}else nt=!0,Me.__version=z.version;let _n=Me.currentProgram;if(nt===!0){if(_n=wn(z,D,k),R&&z.isNodeMaterial)R.onUpdateProgram(z,_n,Me)}let Nn=!1,ii=!1,Wi=!1,ft=_n.getUniforms(),Pt=Me.uniforms;if(S.useProgram(_n.program))Nn=!0,ii=!0,Wi=!0;if(z.id!==se)se=z.id,ii=!0;if(Me.needsLights){let yt=wu(b.state.lightProbeGridArray,k);if(Me.lightProbeGrid!==yt)Me.lightProbeGrid=yt,ii=!0}if(Nn||Y!==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 ri=ft.map.cameraPosition;if(ri!==void 0)ri.setValue(L,Lt.setFromMatrixPosition(x.matrixWorld));if(mt.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(Y!==x)Y=x,ii=!0,Wi=!0}if(Me.needsLights){if(rn.state.sunShadowMap.length>0)ft.setValue(L,"sunShadowMap",rn.state.sunShadowMap,V);if(rn.state.directionalShadowMap.length>0)ft.setValue(L,"directionalShadowMap",rn.state.directionalShadowMap,V);if(rn.state.spotShadowMap.length>0)ft.setValue(L,"spotShadowMap",rn.state.spotShadowMap,V);if(rn.state.pointShadowMap.length>0)ft.setValue(L,"pointShadowMap",rn.state.pointShadowMap,V)}if(k.isSkinnedMesh){ft.setOptional(L,k,"bindMatrix"),ft.setOptional(L,k,"bindMatrixInverse");let yt=k.skeleton;if(yt){if(yt.boneTexture===null)yt.computeBoneTexture();ft.setValue(L,"boneTexture",yt.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 si=X.morphAttributes;if(si.position!==void 0||si.normal!==void 0||si.color!==void 0)Ze.update(k,X,_n);if(ii||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)Pt.envMapIntensity.value=D.environmentIntensity;if(Pt.dfgLUT!==void 0)Pt.dfgLUT.value=jg();if(ii){if(ft.setValue(L,"toneMappingExposure",M.toneMappingExposure),Me.needsLights)Au(Pt,Wi);if(xe&&z.fog===!0)ge.refreshFogUniforms(Pt,xe);if(ge.refreshMaterialUniforms(Pt,z,ae,q,b.state.transmissionRenderTarget[x.id]),Me.needsLights&&Me.lightProbeGrid){let yt=Me.lightProbeGrid;Pt.probesSH.value=yt.texture,Pt.probesMin.value.copy(yt.boundingBox.min),Pt.probesMax.value.copy(yt.boundingBox.max),Pt.probesResolution.value.copy(yt.resolution)}rr.upload(L,Zt(Me),Pt,V)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0)rr.upload(L,Zt(Me),Pt,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 yt=z.uniformsGroups;for(let ri=0,Xi=yt.length;ri<Xi;ri++){let zl=yt[ri];ye.update(zl,_n),ye.bind(zl,_n)}}return _n}function Au(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 Cu(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 ee},this.getRenderTarget=function(){return G},this.setRenderTargetTextures=function(x,D,X){let z=P.get(x);if(z.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1)z.__useRenderToTexture=!1;P.get(x.texture).__webglTexture=D,P.get(x.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:X,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let X=P.get(x);X.__webglFramebuffer=D,X.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,X=0){G=x,H=D,ee=X;let z=null,k=!1,xe=!1;if(x){let _e=P.get(x);if(_e.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(L.FRAMEBUFFER,_e.__webglFramebuffer),te.copy(x.viewport),j.copy(x.scissor),ve=x.scissorTest,S.viewport(te),S.scissor(j),S.setScissorTest(ve),se=-1;return}else if(_e.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(_e.__hasExternalTextures)V.rebindTextures(x,P.get(x.texture).__webglTexture,P.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let qe=x.depthTexture;if(_e.__boundDepthTexture!==qe){if(qe!==null&&P.has(qe)&&(x.width!==qe.image.width||x.height!==qe.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Ce=x.texture;if(Ce.isData3DTexture||Ce.isDataArrayTexture||Ce.isCompressedArrayTexture)xe=!0;let Pe=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Pe[D]))z=Pe[D][X];else z=Pe[D];k=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)z=P.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))z=Pe[X];else z=Pe;te.copy(x.viewport),j.copy(x.scissor),ve=x.scissorTest}else te.copy(Le).multiplyScalar(ae).floor(),j.copy(Ne).multiplyScalar(ae).floor(),ve=Et;if(X!==0)z=U;if(S.bindFramebuffer(L.FRAMEBUFFER,z))S.drawBuffers(x,z);if(S.viewport(te),S.scissor(j),S.setScissorTest(ve),k){let _e=P.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+D,_e.__webglTexture,X)}else if(xe){let _e=D;for(let Ce=0;Ce<x.textures.length;Ce++){let Pe=P.get(x.textures[Ce]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Ce,Pe.__webglTexture,X,_e)}}else if(x!==null&&X!==0){let _e=P.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,_e.__webglTexture,X)}se=-1};function Bl(x){let D=P.get(x);if(D.__readFormat!==x.format||D.__readType!==x.type)D.__readFormat=x.format,D.__readType=x.type,D.__formatReadable=mt.textureFormatReadable(x.format),D.__typeReadable=mt.textureTypeReadable(x.type);return D}if(this.readRenderTargetPixels=function(x,D,X,z,k,xe,be,_e=0){if(!(x&&x.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ce=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ce=Ce[be];if(Ce){S.bindFramebuffer(L.FRAMEBUFFER,Ce);try{let Pe=x.textures[_e],{format:qe,type:Ke}=Pe;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+_e);let Re=Bl(Pe);if(Re.__formatReadable===!1){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){Fe("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,K.convert(qe),K.convert(Ke),xe)}finally{let Pe=G!==null?P.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(x,D,X,z,k,xe,be,_e=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ce=P.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&be!==void 0)Ce=Ce[be];if(Ce)if(D>=0&&D<=x.width-z&&(X>=0&&X<=x.height-k)){S.bindFramebuffer(L.FRAMEBUFFER,Ce);let Pe=x.textures[_e],{format:qe,type:Ke}=Pe;if(x.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+_e);let Re=Bl(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ot=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,ot),L.bufferData(L.PIXEL_PACK_BUFFER,xe.byteLength,L.STREAM_READ),L.readPixels(D,X,z,k,K.convert(qe),K.convert(Ke),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Nt=G!==null?P.get(G).__webglFramebuffer:null;S.bindFramebuffer(L.FRAMEBUFFER,Nt);let Mt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await lh(L,Mt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,ot),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,xe),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(ot),L.deleteSync(Mt),xe}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),xe=Math.floor(x.image.height*z),be=D!==null?D.x:0,_e=D!==null?D.y:0;V.setTexture2D(x,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,be,_e,k,xe),S.unbindTexture()},this.copyTextureToTexture=function(x,D,X=null,z=null,k=0,xe=0){let be,_e,Ce,Pe,qe,Ke,Re,ot,Nt,Mt=x.isCompressedTexture?x.mipmaps[xe]:x.image;if(X!==null)be=X.max.x-X.min.x,_e=X.max.y-X.min.y,Ce=X.isBox3?X.max.z-X.min.z:1,Pe=X.min.x,qe=X.min.y,Ke=X.isBox3?X.min.z:0;else{let Pt=Math.pow(2,-k);if(be=Math.floor(Mt.width*Pt),_e=Math.floor(Mt.height*Pt),x.isDataArrayTexture)Ce=Mt.depth;else if(x.isData3DTexture)Ce=Math.floor(Mt.depth*Pt);else Ce=1;Pe=0,qe=0,Ke=0}if(z!==null)Re=z.x,ot=z.y,Nt=z.z;else Re=0,ot=0,Nt=0;let gt=K.convert(D.format),Qt=K.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 rn=S.getParameter(L.UNPACK_ROW_LENGTH),nt=S.getParameter(L.UNPACK_IMAGE_HEIGHT),_n=S.getParameter(L.UNPACK_SKIP_PIXELS),Nn=S.getParameter(L.UNPACK_SKIP_ROWS),ii=S.getParameter(L.UNPACK_SKIP_IMAGES);S.pixelStorei(L.UNPACK_ROW_LENGTH,Mt.width),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Mt.height),S.pixelStorei(L.UNPACK_SKIP_PIXELS,Pe),S.pixelStorei(L.UNPACK_SKIP_ROWS,qe),S.pixelStorei(L.UNPACK_SKIP_IMAGES,Ke);let Wi=x.isDataArrayTexture||x.isData3DTexture,ft=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let Pt=P.get(x),si=P.get(D),yt=P.get(Pt.__renderTarget),ri=P.get(si.__renderTarget);S.bindFramebuffer(L.READ_FRAMEBUFFER,yt.__webglFramebuffer),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,ri.__webglFramebuffer);for(let Xi=0;Xi<Ce;Xi++){if(Wi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(x).__webglTexture,k,Ke+Xi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(D).__webglTexture,xe,Nt+Xi);L.blitFramebuffer(Pe,qe,be,_e,Re,ot,be,_e,L.DEPTH_BUFFER_BIT,L.NEAREST)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||x.isRenderTargetTexture||P.has(x)){let Pt=P.get(x),si=P.get(D);S.bindFramebuffer(L.READ_FRAMEBUFFER,W),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,I);for(let yt=0;yt<Ce;yt++){if(Wi)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pt.__webglTexture,k,Ke+yt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Pt.__webglTexture,k);if(ft)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,si.__webglTexture,xe,Nt+yt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,si.__webglTexture,xe);if(k!==0)L.blitFramebuffer(Pe,qe,be,_e,Re,ot,be,_e,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ft)L.copyTexSubImage3D(Me,xe,Re,ot,Nt+yt,Pe,qe,be,_e);else L.copyTexSubImage2D(Me,xe,Re,ot,Pe,qe,be,_e)}S.bindFramebuffer(L.READ_FRAMEBUFFER,null),S.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ft)if(x.isDataTexture||x.isData3DTexture)L.texSubImage3D(Me,xe,Re,ot,Nt,be,_e,Ce,gt,Qt,Mt.data);else if(D.isCompressedArrayTexture)L.compressedTexSubImage3D(Me,xe,Re,ot,Nt,be,_e,Ce,gt,Mt.data);else L.texSubImage3D(Me,xe,Re,ot,Nt,be,_e,Ce,gt,Qt,Mt);else if(x.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,xe,Re,ot,be,_e,gt,Qt,Mt.data);else if(x.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,xe,Re,ot,Mt.width,Mt.height,gt,Mt.data);else L.texSubImage2D(L.TEXTURE_2D,xe,Re,ot,be,_e,gt,Qt,Mt);if(S.pixelStorei(L.UNPACK_ROW_LENGTH,rn),S.pixelStorei(L.UNPACK_IMAGE_HEIGHT,nt),S.pixelStorei(L.UNPACK_SKIP_PIXELS,_n),S.pixelStorei(L.UNPACK_SKIP_ROWS,Nn),S.pixelStorei(L.UNPACK_SKIP_IMAGES,ii),xe===0&&D.generateMipmaps)L.generateMipmap(Me);S.unbindTexture()},this.initRenderTarget=function(x){if(P.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,ee=0,G=null,S.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Vo}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 Rt(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 Al=(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}},Qh=(e,t)=>t>0.7?e.glassLight:t<0.3?e.glassDark:e.glass,Gi=(e,t,n)=>{e.strokeStyle=t,e.lineWidth=n,e.lineJoin="round",e.lineCap="round",e.stroke()};function jh(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 Si(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 eu(e){let[t,n]=Rt(512,512),i=Al(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 tu(e){let[t,n]=Rt(512,512),i=Al(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 pa(e){let[n,i]=Rt(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)Si(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 Si(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=e.bg,i.globalAlpha=0.55,Si(i,0,0,52,0.4),i.fill(),n}function Cl(e,t){let n=Al(t==="rose"?5:9);if(t==="lancet"){let[l,c]=Rt(256,512);jh(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=Qh(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)Si(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 jh(c,14,10,228,492),Gi(c,e.ink,12),l}let i=512,[s,r]=Rt(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=Qh(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]])Si(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),Gi(r,e.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Gi(r,e.stoneShade,14),s}function nu(e,t){let[n,i]=Rt(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(),Gi(i,e.bannerEdge,14),s(),Gi(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")Si(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,Si(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(),Si(i,128,215,34,0.3),i.fill();return n}function iu(e){let[t,n]=Rt(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 su(e){let[t,n]=Rt(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(),Gi(n,e.ink,7),i(64,74,176,24),n.fillStyle=e.flameCore,n.fill(),t}function ru(e){let[t,n]=Rt(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Gi(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 ma(){let[e,t]=Rt(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 au(){let[e,t]=Rt(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 ou(e){let[t,n]=Rt(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 ga=0.034,Rl=0.02,Il=0.024,e0=(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 Pl(e,t,n,i){let[s,r]=Rt(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 Ll(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 lu(e,t,n){let{rim:i,ink:s,edge:r}=n,a=await e0(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*(ga+Rl+Il))+2,[d,h]=Rt(l+u*2,c+u*2),p=Pl(a,l,c,s),v=Pl(a,l,c,i),T=Pl(a,l,c,r);for(let[m,f]of Ll(t*(ga+Rl)))h.drawImage(T,u+m+t*Il*0.5,u+f+t*Il);for(let[m,f]of Ll(t*(ga+Rl)))h.drawImage(p,u+m,u+f);for(let[m,f]of Ll(t*ga))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function _a(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 ar=Math.PI*2,xa=(e,t=0,n=1)=>Math.min(n,Math.max(t,e));function t0(e){let[t,n]=Rt(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=e.paper,r=_a(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,ar),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,ar);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,ar),n.fill();return n.restore(),t}function n0(e){let[t,n]=Rt(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 i0(){let[e,t]=Rt(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 Nl{hall;group=new Jt;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 yi(t());return i.colorSpace=xi,this.textures.set(e,i),i}plane(e,t,n){let i=this.planes.get(e);if(i)return i;let s=new Ct(t,n);return this.planes.set(e,s),s}get glow(){return this.hall.additive?Kn:Rn}puff(e,t){let n=this.hall,i=this.texture("cloud",()=>t0(n)),s=this.texture("sparkle",()=>n0(n)),r=Array.from({length:7},(o,l)=>{let c=ar*l/7+l%2*0.4,u=new Ks(new Es({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 Ks(new Es({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:ar*l/4+0.7}});this.runs.push({start:t,update:(o)=>{let l=xa(o/Ht),c=ui(l/0.35),u=1-(1-l)**2,d=1-xa((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*ui(xa((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-xa((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]=Rt(256,256);return h.drawImage(pa(n),0,0,256,256),d}),s=this.texture("column",i0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Jt;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 Jt;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:ln,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=di(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<jt},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 cu(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 I=d[W],H=h[W];if(R[H](a,_[I](C)),M)for(let ee=0,G=M.length;ee<G;ee++)U[ee][H](a,M[ee][I](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 s0(){let e=new Uint8Array([125,195,255]),t=new Qs(e,3,1,Fr,dn);return t.minFilter=Pn,t.magFilter=Pn,t.generateMipmaps=!1,t.needsUpdate=!0,t}class Dl{steps=s0();lit=new Map;flat=new Map;ink=new Ve("#000000");hullMaterial=new Ft({color:this.ink,side:qt,fog:!1});toon(e,t){let n=this.lit.get(e);if(!n)n=new ti({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 r0(e,t){let n=e.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=cu(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 Mi(e,t,n,i){let s=i.get(e.geometry);if(!s)s=r0(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,or=12,a0=["moon","star","crest"];class hu{textures=[];geometries=[];materials=[];texture(e,t){let n=new yi(e);if(n.colorSpace=xi,t)n.wrapS=Vs,n.wrapT=Vs,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 uu(e,t,n){let i=new hu,s=new Jt,r=new Map,a=kt(t),o=a+9.5,l=(j,ve={})=>i.material(new Ft({map:j,transparent:!0,depthWrite:!1,fog:!1,...ve})),c=e.additive?Kn:Rn,u=i.texture(eu(e),[o/2.2,o/2.2]),d=new Ge(i.geometry(new As(o+1,72)),i.material(new ti({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Ge(i.geometry(new mn(a+1.9,a+2.15,0.2,72)),n.toon("dais",e.stoneShade));h.position.y=0.1,Mi(h,n,0.07,r),s.add(h);let p=new Ge(i.geometry(new Ct((a-0.7)*2,(a-0.7)*2)),l(i.texture(pa(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 ti({color:"#ffffff",map:i.texture(tu(e),[o*zt/7,Vi/5]),gradientMap:n.steps,side:qt})),T=new Ge(i.geometry(new mn(o,o,Vi,72,1,!0)),v);T.position.y=Vi/2,s.add(T);let m=new Ge(i.geometry(new As(o+1,48)),i.material(new Ft({color:e.bg,side:ln})));m.rotation.x=Math.PI/2,m.position.y=Vi,s.add(m);let f=i.geometry(new mn(0.6,0.66,Vi,14)),E=i.geometry(new mn(0.88,0.7,0.5,14)),C=i.geometry(new mn(0.78,0.9,0.6,14)),y=i.geometry(new Ct(2.2,4.4)),b=i.geometry(new mn(0.34,0.2,0.36,10)),w=i.geometry(new mn(0.06,0.06,0.7,6)),A=i.geometry(new Ct(0.62,0.93)),_=i.geometry(new Ct(2.6,2.6)),M=l(i.texture(su(e)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),B=l(i.texture(ma()),{color:e.flame,blending:c,opacity:e.night?0.55:0.28}),R=a0.map((j)=>i.material(new Ft({map:i.texture(nu(e,j)),transparent:!0,alphaTest:0.4,fog:!1}))),U=[],W=(j,ve,Se,Je)=>(Je.position.set(Math.sin(j)*ve,Se,Math.cos(j)*ve),Je.rotation.y=j+Math.PI,s.add(Je),Je);for(let j=0;j<or;j+=1){let ve=zt*(j+0.5)/or,Se=new Ge(f,n.toon("pillar",e.stone));W(ve,o-0.7,Vi/2,Se),Mi(Se,n,0.06,r);let Je=new Ge(E,n.toon("pillar",e.stone));W(ve,o-0.7,Vi-0.55,Je);let Ue=new Ge(C,n.toon("pillar",e.stone));W(ve,o-0.7,0.3,Ue);let q=new Ge(y,R[j%R.length]??R[0]);W(ve,o-1.34,6.8,q);let ae=new Ge(w,n.toon("iron",e.woodDark));W(ve,o-1.4,2.8,ae),ae.rotation.x=Math.PI/2;let oe=new Ge(b,n.toon("iron",e.woodDark));W(ve,o-1.75,2.95,oe),Mi(oe,n,0.04,r);let Te=new Ge(A,M);Te.position.set(Math.sin(ve)*(o-1.75),3.5,Math.cos(ve)*(o-1.75)),Te.renderOrder=3,s.add(Te);let Le=new Ge(_,B);Le.position.copy(Te.position),Le.renderOrder=2,s.add(Le),U.push({body:Te,halo:Le,phase:j*1.7,base:1})}let I=i.geometry(new Ct(2.6,5.2)),H=i.geometry(new Ct(4.6,4.6)),ee=l(i.texture(Cl(e,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),G=l(i.texture(Cl(e,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),se=i.geometry(new Ct(3.4,10)),Y=l(i.texture(au()),{color:e.beam,opacity:e.beamAlpha,blending:c,side:ln}),te=[];for(let j=0;j<or;j+=1){let ve=zt*j/or,Se=j===or/2,Je=new Ge(Se?H:I,Se?G:ee);W(ve,o-0.12,Se?7.1:6.2,Je);let Ue=new Ge(se,Y),q=o-4.4;Ue.position.set(Math.sin(ve)*q,4.4,Math.cos(ve)*q),Ue.rotation.set(0,ve+Math.PI,0),Ue.rotateX(-0.62),Ue.renderOrder=1,s.add(Ue),te.push(Ue)}return{group:s,flames:U,beams:te,wallRadius:o,dispose(){for(let j of r.values())j.dispose();i.dispose()}}}function du(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 fu(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 mu=2;var gu=(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,o0=(e,t,n)=>n<t?(t+n)/2:Math.min(n,Math.max(t,e));function pu(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)=>o0(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)=>gu(f,E)))continue;d=f,h=m}return d}function _u(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=pu(c,s,n,t);if(!u){if(u=pu(c,s,[],t),u&&n.some((h)=>gu(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 l0=1.06,c0=0.68,xu=12,h0=16;class Ul{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",_t)}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",()=>this.click(n)),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(xu,Math.min(h0,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,l0,u*c0),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||xu*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-mu}}let o=_u(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 Hr(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 vu=0.62;function u0(e,t){let n=Math.atan2(e,t),i=(s)=>Math.max(-vu,Math.min(vu,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(Yt(n-Math.PI))}var lr=1.3,d0=1.24,f0=0.31,p0=[512,128],va={waiting:0,alert:1,done:2,error:3};function yu(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 Fl{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 Ct(0.84,1.05));platePlane=this.own(new Ct(d0,f0));glowPlane=this.own(new Ct(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new Ct(1.25,1.25));constructor(e){this.hall=e;let t=new mn(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(iu(e)),this.glowTexture=this.texture(ma()),this.badgeTexture=this.texture(ru(e)),this.marksTexture=this.texture(ou(e));let n=(i)=>{let s=new Ct(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(va.waiting),alert:n(va.alert),done:n(va.done),error:n(va.error)}}own(e){return this.geometries.push(e),e}texture(e){let t=new yi(e);return t.colorSpace=xi,t.wrapS=Bn,t.wrapT=Bn,t.anisotropy=4,t.minFilter=nn,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 cr{init;kit;group=new Jt;rig=new Jt;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,Mi(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,Mi(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,Mi(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 ti({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]=p0,[p,v]=Rt(d,h);this.plateTexture=t.texture(p),this.plateText=Wr(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 Ct(lt,lt),f),this.board.visible=!1,this.board.position.y=lr+lt/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?Kn:Rn}),this.glow=new Ge(t.glowPlane,this.glowMaterial),this.glow.position.set(0,lr+lt/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,lr+lt,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,lr+lt*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=lr+lt*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+lt*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=u0(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 Su(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 m0=2,g0=1.5,_0=60,Mu=8,x0=1.22,v0=0.82,bu=(e,t,n,i)=>e+(t-e)*(1-Math.exp(-n*i)),Ol=0.2,y0=2,Tu=(e)=>e.init.id??e.init.kind;function iS(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?g0:m0,l=new El({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??Dt,d=new Ul(e,u,(F)=>{if(F.init.kind==="agent"&&F.init.id)t.onSeatClick({id:F.init.id,name:F.init.name});else if(F.init.kind==="more")t.onMore?.()}),h=Su(e,()=>s),p=new $r,v=new on(42,1,0.1,90),T=new la,m=new oa;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=yn(0,1),I=W,H=W,ee=0,G=0,se,Y=!1,te=()=>w?.slots??li(C.length),j=()=>te().count,ve=(F)=>{let J=w?.slotOf.get(F);return J===void 0?void 0:It(J,j())},Se=()=>{let F=R?ve(R):void 0;return F===void 0?yn(U,j(),v.aspect,c.clientWidth||void 0):jr(F,j())},Je=()=>{let{position:F,target:J}=ji(W);v.position.set(...F),v.lookAt(J[0],J[1],J[2]),v.rotateZ(W.roll);let ce=Ki(W.fov,v.aspect);if(Math.abs(v.fov-ce)>0.001)v.fov=ce,v.updateProjectionMatrix()},Ue=(F,J)=>{let ce=Jr(W,F,s||J);if(ce.cut)W=F,G=0;else I=W,H=F,ee=performance.now(),G=ce.ms;return g.wake(),ce},q=()=>{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,J)=>{let ce=b.get(F),we=w;if(!ce||!we)return;let Ae=we.slotOf.get(F),Xe=Ae===void 0?void 0:we.podiums[Ae];if(Xe?.init.kind!=="agent")return;try{let at=await lu(ce,320,{rim:we.hall.paper,ink:we.hall.ink,edge:_a(C.find((vt)=>vt.id===F)?.color??we.hall.gold,we.hall.ink,0.35)});if(J!==A||w!==we)return;_.set(F,{svg:ce,tone:M(),canvas:at.canvas}),Xe.setSticker(at.canvas),g.wake()}catch{}},oe=(F,J)=>{F.setBadge(yu(J))},Te=(F)=>{let J=++A;q();let ce=gn(f,E),we=li(C.length),Ae=new Dl;Ae.setInk(ce.ink);let Xe=new Fl(ce),at=uu(ce,we.count,Ae),vt=new Jt;vt.add(at.group);let He=new Map,bn=[],Tn=[],ni=(ht,ut,wn=0)=>{let Zt=es(ht,we.count),Ln=1+wn/kt(we.count);ut.group.position.set(Zt.x*Ln,0.2,Zt.z*Ln),ut.group.rotation.y=Zt.yaw,Tn[ht]=ut,vt.add(ut.group)};if(ni(0,new cr({id:void 0,name:t.ownerName??"You",kind:"owner",accent:ce.gold},Xe,Ae),1.2),C.slice(0,we.seated).forEach((ht,ut)=>{let wn=ut+1;He.set(ht.id,wn),bn.push(ht.id);let Zt=new cr({id:ht.id,name:ht.name,kind:"agent",accent:ht.color},Xe,Ae);Zt.setDim(ht.dim===!0),oe(Zt,y.get(ht.id)??ht.state??"idle"),ni(wn,Zt);let Ln=_.get(ht.id);if(Ln&&Ln.svg===b.get(ht.id)&&Ln.tone===M())Zt.setSticker(Ln.canvas)}),we.more>0)ni(we.count-1,new cr({id:void 0,name:`+${we.more}`,kind:"more",accent:ce.gold},Xe,Ae));if(w={hall:ce,toon:Ae,kit:Xe,built:at,group:vt,slots:we,podiums:Tn,slotOf:He,order:bn},F&&B){let ht=new Set;for(let ut of Tn){let wn={x:ut.group.position.x,z:ut.group.position.z,yaw:ut.group.rotation.y},Zt=F.from.get(Tu(ut));if(Zt)B.slides.push({podium:ut,from:Zt,to:wn}),ut.group.position.x=Zt.x,ut.group.position.z=Zt.z,ut.group.rotation.y=Zt.yaw;if(ut.init.id&&F.joining.has(ut.init.id))ut.group.visible=!1,ut.labelHidden=!0,ht.add(ut)}B.risers=[...ht]}p.add(vt),vt.updateMatrixWorld(!0),p.background=new Ve(ce.bg),p.fog=new Js(ce.bg,17,46),T.color.set(ce.ambient),T.intensity=ce.ambientI,m.color.set(ce.key),m.intensity=ce.keyI;for(let ht of C.slice(0,we.seated)){let ut=_.get(ht.id);if(ut&&ut.svg===b.get(ht.id)&&ut.tone===M())continue;ae(ht.id,J)}if(R&&!He.has(R))R=null;Ue(Se(),F===void 0),d.paint(ce),d.set(Tn,(ht)=>y.get(ht.init.id??"")??"idle"),g.wake()},Le=(F)=>F.slice(0,li(F.length).seated).map((J)=>J.id),Ne=()=>{let F=new Map;for(let J of w?.podiums??[])F.set(Tu(J),{x:J.group.position.x,z:J.group.position.z,yaw:J.group.rotation.y});return F},Et=(F)=>{F.swapped=!0;let J=Ne();C=F.next,F.slides=[],Te({from:J,joining:new Set(F.plan.joining)});for(let ce of F.risers)F.fx?.circle({x:ce.group.position.x,y:Ol,z:ce.group.position.z},F.plan.riseAt)},We=(F)=>{for(let J of F.timers)clearTimeout(J);for(let J of F.slides)J.podium.group.position.x=J.to.x,J.podium.group.position.z=J.to.z,J.podium.group.rotation.y=J.to.yaw;for(let J of F.risers)J.group.visible=!0,J.group.position.y=Ol,J.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;g.wake()},$e=()=>{let F=B;if(!F)return;if(!F.swapped)F.swapped=!0,C=F.next,Te();We(F)},st=(F,J)=>{let ce={plan:J,start:performance.now(),next:F,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(B=ce,J.mode==="fade"){for(let Xe of[c,d.root])Xe.style.transition=`opacity ${Tt}ms linear`,Xe.style.opacity="0";ce.timers.push(setTimeout(()=>{ce.swapped=!0,C=F,Te();for(let Xe of[c,d.root])Xe.style.opacity="1"},Tt),setTimeout(()=>We(ce),Tt*2));return}let we=w;if(!we)return;let Ae=new Nl(we.hall);ce.fx=Ae,p.add(Ae.group);for(let Xe of J.leaving){let at=we.slotOf.get(Xe),vt=at===void 0?void 0:we.podiums[at];if(!vt)continue;ce.leavers.push(vt),Ae.puff({x:vt.group.position.x,y:y0,z:vt.group.position.z},0)}if(J.swapAt===0)Et(ce);g.wake()},Qe=(F)=>{let J=B;if(!J||J.plan.mode!=="play")return J!==void 0;let ce=Math.max(0,F-J.start);if(!J.swapped){let Ae=ss(ce);for(let Xe of J.leavers)if(Xe.group.scale.set(Ae.scaleX,Ae.scaleY,Ae.scaleX),Ae.gone)Xe.group.visible=!1;if(ce>=J.plan.swapAt)Et(J)}if(J.swapped){let Ae=as(ce-J.plan.swapAt);for(let{podium:at,from:vt,to:He}of J.slides)at.group.position.x=vt.x+(He.x-vt.x)*Ae,at.group.position.z=vt.z+(He.z-vt.z)*Ae,at.group.rotation.y=os(vt.yaw,He.yaw,Ae);let Xe=di(ce-J.plan.riseAt);for(let at of J.risers)at.group.visible=Xe.shown,at.group.position.y=Ol-Xe.depth*rs,at.labelHidden=!Xe.named}let we=J.fx?.step(ce)??!1;if(ce>=J.plan.total&&!we)return We(J),!1;return!0},Lt,rt=new O,Ot=0,bt=0,At=0,L=0,Bt=0,tt=0,mt=performance.now(),g=fu({frame:(F,J)=>{let ce=performance.now();Ot+=J/1000;let we=!1;if(Qe(F))we=!0;if(G>0){let at=(F-ee)/G;if(at>=1)W=H,G=0;else W=Kr(I,H,ci(at)),we=!0}else if(se)we=!0;Je(),v.getWorldPosition(rt);let Ae=w;if(Ae){let at=R===null?void 0:Ae.slotOf.get(R);for(let He of Ae.podiums)He.group.updateMatrixWorld(!0);let vt=d.place(v,rt,e.clientWidth,e.clientHeight,at===void 0?void 0:Ae.podiums[at]);if(R===null&&vt!==Lt)Lt=vt,t.onNames?.(vt);du(Ae.built.flames,Ot,s);for(let He of Ae.built.flames)He.body.lookAt(rt.x,He.body.position.y,rt.z);for(let He of Ae.podiums){if(He.init.kind!=="agent")continue;let bn=y.get(He.init.id??"")??"idle",Tn=bn==="speaking"?1:0,ni=bn==="thinking"||bn==="working"?1:0,ht=He.speak;He.speak=s?Tn:bu(He.speak,Tn,7,J/1000),He.bob=s?0:bu(He.bob,ni,5,J/1000);let ut=He.speak>0.02;if(He.glow.visible=ut&&He.board.visible,He.glowMaterial.opacity=0.85*He.speak,He.board.position.y=He.boardY+Math.sin(Ot*3.1+He.phase)*0.035*He.bob,He.face(rt),He.markFrame(bn==="speaking",Ot,s))we=!0;if(Math.abs(He.speak-Tn)>0.01||Math.abs(ht-He.speak)>0.001||He.bob>0.02)we=!0}}l.render(p,v),At+=1,bt+=1;let Xe=performance.now()-ce;if(L+=Xe,Bt=Math.max(Bt,Xe),F-mt>=1000)tt=bt*1000/(F-mt),P={...P,fps:tt,frameMs:L/Math.max(bt,1),frameMsMax:Bt},bt=0,L=0,Bt=0,mt=F;return we},host:{request:(F)=>requestAnimationFrame(F),cancel:(F)=>cancelAnimationFrame(F),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),P={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},V=()=>{let{clientWidth:F,clientHeight:J}=e;if(F<=0||J<=0)return;if(l.setSize(F,J,!1),v.aspect=F/J,v.updateProjectionMatrix(),R===null&&!se&&w)if(G===0)W=Se();else H=Se();d.size(F),g.wake()},ne=new ResizeObserver(V);ne.observe(e);let le=new IntersectionObserver((F)=>{for(let J of F)g.setVisible(J.isIntersecting)});le.observe(e);let fe=()=>g.sync();document.addEventListener("visibilitychange",fe);let Z=(F)=>{F.preventDefault(),n?.()};c.addEventListener("webglcontextlost",Z);let Q=(F,J,ce)=>{let we=F!==null&&w?.slotOf.has(F)?F:null;if(we===R)return;R=we;let Ae=Ue(Se(),J);if(we!==null&&Y&&!Ae.cut)h.play();if(ce)t.onFocus?.(we)},ge=new ze,Ie=new ca,ue=(F,J)=>{let ce=w;if(!ce)return;let we=c.getBoundingClientRect();return ge.set((F-we.left)/we.width*2-1,-((J-we.top)/we.height)*2+1),Ie.setFromCamera(ge,v),Ie.intersectObjects(ce.podiums.filter((Xe)=>Xe.group.visible).flatMap((Xe)=>Xe.hits).filter((Xe)=>Xe.visible),!1)[0]?.object.userData},re=new Map,Ee,De=0,Ze=!1,N=()=>{let[F,J]=[...re.values()];return F&&J?Math.hypot(F.x-J.x,F.y-J.y):0},he=(F)=>{if(re.set(F.pointerId,{x:F.clientX,y:F.clientY}),re.size===2){De=N(),Ze=!1,Ee=void 0,se=void 0;return}let J=c.getBoundingClientRect(),ce=!ns(F.clientX,F.clientY,J,{width:innerWidth,height:innerHeight});if(Ee={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"},K=(F)=>{if(re.has(F.pointerId))re.set(F.pointerId,{x:F.clientX,y:F.clientY});if(re.size===2&&De>0&&!Ze){let we=N()/De,Ae=we>x0?"in":we<v0?"out":"none";if(Ae!=="none")Ze=!0,pe(Ae==="in"?-1:1);return}if(!Ee){if(F.buttons===0)c.style.cursor=ue(F.clientX,F.clientY)?"pointer":"grab";return}if(!Ee.ok||R!==null)return;let J=F.clientX-Ee.x;if(Math.abs(J)<Mu&&!se)return;let ce=Ee.az+ts(J,c.clientWidth);se={az:ce},W=yn(ce,j(),v.aspect,c.clientWidth||void 0),G=0,g.wake()},de=(F)=>{if(re.delete(F.pointerId),re.size<2)De=0;c.style.cursor="grab";let J=Ee;if(Ee=void 0,!J||Ze){if(re.size===0)Ze=!1;return}let ce=F.clientX-J.x,we=F.clientY-J.y;if(se){U=Hi(se.az,j()),se=void 0,Ue(yn(U,j(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ce,we)<Mu){if(J.hold&&performance.now()-J.at>=sr)return;let Ae=ue(F.clientX,F.clientY);if(!Ae)return;if(Ae.kind==="agent"&&Ae.seat){let Xe=C.find((at)=>at.id===Ae.seat);if(Xe)t.onSeatClick({id:Xe.id,name:Xe.name})}else if(Ae.kind==="more")t.onMore?.();else if(Ae.kind==="owner"&&R!==null)Q(null,!1,!0);return}if(J.ok&&R!==null&&Math.abs(ce)>=_0&&Math.abs(ce)>Math.abs(we))ie(ce<0?1:-1)},ye=(F)=>{if(re.delete(F.pointerId),Ee=void 0,se)U=Hi(se.az,j()),se=void 0,Ue(yn(U,j(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ie=(F)=>{let J=w;if(!J||R===null||J.order.length<2)return;let ce=J.order.indexOf(R),we=J.order[(ce+F+J.order.length)%J.order.length];if(we)Q(we,!1,!0)},pe=(F)=>{let J=w;if(!J)return;let ce=is(F,R!==null);if(ce==="in"){let we=Yr(U,J.slots),Ae=we===void 0?void 0:J.order[we-1];if(Ae)Q(Ae,!1,!0)}else if(ce==="out")Q(null,!1,!0)},Be=0,ct=(F)=>{F.preventDefault();let J=performance.now();if(J-Be<450||Math.abs(F.deltaY)<4)return;Be=J,pe(F.deltaY)};c.addEventListener("pointerdown",he),c.addEventListener("pointermove",K),c.addEventListener("pointerup",de),c.addEventListener("pointercancel",ye),c.addEventListener("wheel",ct,{passive:!1});let it=(F)=>F.length===C.length&&F.every((J,ce)=>J.id===C[ce]?.id&&J.name===C[ce]?.name&&J.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 Te(),W=Se(),V(),Y=!0,{kind:"webgl",setTheme(F,J){if(F===f&&J===E)return;$e(),f=F,E=J,Te()},setSeats(F){$e();let J=!it(F),ce=F.map((Ae)=>({...Ae})),we=J&&Y&&w?qn(Le(C),Le(ce),s):void 0;for(let Ae of ce){if(Ae.state)y.set(Ae.id,Ae.state);if(Ae.avatarSvg&&Ae.avatarSvg!==b.get(Ae.id))b.set(Ae.id,Ae.avatarSvg)}if(we&&we.mode!=="cut"){st(ce,we);return}if(C=ce,J)Te();else{let Ae=w;for(let Xe of C){let at=Ae?.slotOf.get(Xe.id);(at===void 0?void 0:Ae?.podiums[at])?.setDim(Xe.dim===!0),ae(Xe.id,A)}}g.wake()},setState(F,J){y.set(F,J);let ce=w?.slotOf.get(F),we=ce===void 0?void 0:w?.podiums[ce];if(we)oe(we,J),d.relabel(we,J);g.wake()},async setAvatar(F,J){b.set(F,J),await ae(F,A)},setReducedMotion(F){if(s=F,P.reduced=F,F)Ue(Se(),!0);g.wake()},resetCamera(){U=0,Q(null,!1,!0),Ue(Se(),!1)},focus(F,J){Q(F,J?.cut===!0,!1)},focused:()=>R,seatAt(F,J){let ce=ue(F,J);return ce?.kind==="agent"?ce.seat:null},getStats(){let F=l.info;return{...P,drawCalls:F.render.calls,triangles:F.render.triangles,textures:F.memory.textures,geometries:F.memory.geometries,loop:g.state,seats:C.length,renders:At,reduced:s}},dispose(){if(B){for(let F of B.timers)clearTimeout(F);B.fx?.dispose(),B=void 0}g.dispose(),ne.disconnect(),le.disconnect(),document.removeEventListener("visibilitychange",fe),c.removeEventListener("webglcontextlost",Z),c.removeEventListener("pointerdown",he),c.removeEventListener("pointermove",K),c.removeEventListener("pointerup",de),c.removeEventListener("pointercancel",ye),c.removeEventListener("wheel",ct),h.dispose(),d.dispose(),q(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{iS as createTable3D};
|