@egen-civitas/esm-app-shell 2.1.0 → 2.2.0
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 +25 -0
- package/dist/0e44e729978549df.js +1 -0
- package/dist/0e44e729978549df.js.map +1 -0
- package/dist/100e7c99afd2869a.js +1 -0
- package/dist/100e7c99afd2869a.js.map +1 -0
- package/dist/104a9d544f2d1bee.js +1 -0
- package/dist/104a9d544f2d1bee.js.map +1 -0
- package/dist/165cd7c9a57e9fd4.js +1 -0
- package/dist/165cd7c9a57e9fd4.js.map +1 -0
- package/dist/20c375935cdfd472.js +1 -0
- package/dist/20c375935cdfd472.js.map +1 -0
- package/dist/2387ac2d7d438c25.js +1 -0
- package/dist/2387ac2d7d438c25.js.map +1 -0
- package/dist/28213ad7c964ca67.js +1 -0
- package/dist/28213ad7c964ca67.js.map +1 -0
- package/dist/28ee358f798f3afc.js +1 -0
- package/dist/28ee358f798f3afc.js.map +1 -0
- package/dist/2a6578b999e69afa.js +1 -0
- package/dist/2a6578b999e69afa.js.map +1 -0
- package/dist/2e996b9d664c67d5.js +1 -0
- package/dist/2e996b9d664c67d5.js.map +1 -0
- package/dist/2f3c2b970b4f3f2a.js +1 -0
- package/dist/2f3c2b970b4f3f2a.js.map +1 -0
- package/dist/301f10a4f624d74f.js +1 -0
- package/dist/301f10a4f624d74f.js.map +1 -0
- package/dist/3421840c2ad1831a.js +1 -0
- package/dist/3421840c2ad1831a.js.map +1 -0
- package/dist/35750147bebf81e6.js +1 -0
- package/dist/35750147bebf81e6.js.map +1 -0
- package/dist/38e195234254e1ed.js +1 -0
- package/dist/38e195234254e1ed.js.map +1 -0
- package/dist/392ff79c3df465de.js +1 -0
- package/dist/392ff79c3df465de.js.map +1 -0
- package/dist/39e4bad4d556fdf0.js +1 -0
- package/dist/39e4bad4d556fdf0.js.map +1 -0
- package/dist/3f0bf1710c0f5c33.js +1 -0
- package/dist/3f0bf1710c0f5c33.js.map +1 -0
- package/dist/40a802fc37195f5f.js +1 -0
- package/dist/40a802fc37195f5f.js.map +1 -0
- package/dist/4726bdbff3230ea5.js +1 -0
- package/dist/4726bdbff3230ea5.js.map +1 -0
- package/dist/4ce174ac213a420d.js +1 -0
- package/dist/4ce174ac213a420d.js.map +1 -0
- package/dist/503f6ee851a6c84c.js +1 -0
- package/dist/503f6ee851a6c84c.js.map +1 -0
- package/dist/5a15fdd1c746d468.js +1 -0
- package/dist/5a15fdd1c746d468.js.map +1 -0
- package/dist/5c94ce2b2b091a81.js +1 -0
- package/dist/5c94ce2b2b091a81.js.map +1 -0
- package/dist/6740948aa3c94b36.js +1 -0
- package/dist/6740948aa3c94b36.js.map +1 -0
- package/dist/6face530dd71d3ab.js +1 -0
- package/dist/6face530dd71d3ab.js.map +1 -0
- package/dist/6ff5fd266c168d37.js +1 -0
- package/dist/6ff5fd266c168d37.js.map +1 -0
- package/dist/7133b1158c1eee9f.js +1 -0
- package/dist/7133b1158c1eee9f.js.map +1 -0
- package/dist/7405a39d009c0cd9.js +1 -0
- package/dist/7405a39d009c0cd9.js.map +1 -0
- package/dist/746d6624966d97cc.js +1 -0
- package/dist/746d6624966d97cc.js.map +1 -0
- package/dist/7486f1056be8aac2.js +1 -0
- package/dist/7486f1056be8aac2.js.map +1 -0
- package/dist/7fe1ae38f4e52228.js +1 -0
- package/dist/7fe1ae38f4e52228.js.map +1 -0
- package/dist/86ca4f4caca86a05.js +20 -0
- package/dist/86ca4f4caca86a05.js.map +1 -0
- package/dist/8a1e9fb14542294e.js +1 -0
- package/dist/8a1e9fb14542294e.js.map +1 -0
- package/dist/996aced69a32fb34.js +1 -0
- package/dist/996aced69a32fb34.js.map +1 -0
- package/dist/99b0e92c982b69e3.wasm +0 -0
- package/dist/99ff6ed3397c063c.js +1 -0
- package/dist/99ff6ed3397c063c.js.map +1 -0
- package/dist/9da38ddd134bbac0.wasm +0 -0
- package/dist/9f95152ca23cbda2.js +1 -0
- package/dist/9f95152ca23cbda2.js.map +1 -0
- package/dist/9fb2e1c5007395e8.js +1 -0
- package/dist/9fb2e1c5007395e8.js.map +1 -0
- package/dist/a2203b7ab1be4fe5.js +1 -0
- package/dist/a2203b7ab1be4fe5.js.map +1 -0
- package/dist/a5299431ca4e1890.js +1 -0
- package/dist/a5299431ca4e1890.js.map +1 -0
- package/dist/{888ab4f4534f9acb.css → a6455eee3c1cdefe.css} +1 -1
- package/dist/{888ab4f4534f9acb.css.map → a6455eee3c1cdefe.css.map} +1 -1
- package/dist/af9d1a058dafb22f.js +1 -0
- package/dist/b4c358eb41ead1a6.js +1 -0
- package/dist/b4c358eb41ead1a6.js.map +1 -0
- package/dist/b97ae94953bb55a1.js +1 -0
- package/dist/b97ae94953bb55a1.js.map +1 -0
- package/dist/bd220d0c8e3bcf3e.js +1 -0
- package/dist/bd220d0c8e3bcf3e.js.map +1 -0
- package/dist/c2c6850fc4d942cc.js +1 -0
- package/dist/c2c6850fc4d942cc.js.map +1 -0
- package/dist/c4bf6419e95bcb10.js +1 -0
- package/dist/c4bf6419e95bcb10.js.map +1 -0
- package/dist/c5be968929b7b675.js +1 -0
- package/dist/c5be968929b7b675.js.map +1 -0
- package/dist/c6231509ea43d4cf.js +1 -0
- package/dist/c6231509ea43d4cf.js.map +1 -0
- package/dist/c8956121db18ddca.js +1 -0
- package/dist/c8956121db18ddca.js.map +1 -0
- package/dist/cabfdf9ddd4121e9.wasm +0 -0
- package/dist/d2cacd093023c7fc.js +1 -0
- package/dist/d2cacd093023c7fc.js.map +1 -0
- package/dist/d427071073895236.js +1 -0
- package/dist/d427071073895236.js.map +1 -0
- package/dist/d63e75be7857458a.wasm +0 -0
- package/dist/d714a019d4dfd0f1.js +1 -0
- package/dist/d714a019d4dfd0f1.js.map +1 -0
- package/dist/db9d140f9cb6fbb6.js +1 -0
- package/dist/db9d140f9cb6fbb6.js.map +1 -0
- package/dist/deb33db385797b5e.js +1 -0
- package/dist/deb33db385797b5e.js.map +1 -0
- package/dist/ea485a963430e479.js +1 -0
- package/dist/ea485a963430e479.js.map +1 -0
- package/dist/eb96cd859ce842b3.js +1 -0
- package/dist/eb96cd859ce842b3.js.map +1 -0
- package/dist/{egen.f35ccbd9a7ae43e2.js → egen.8b9857424e0e5992.js} +4 -4
- package/dist/egen.8b9857424e0e5992.js.map +1 -0
- package/dist/{egen.a395d41c58c43ffb.css → egen.c5e7dd6c93adda21.css} +1 -1
- package/dist/f3f2147432dcd6ef.js +1 -0
- package/dist/f3f2147432dcd6ef.js.map +1 -0
- package/dist/f443206d9f3ee012.js +1 -0
- package/dist/f443206d9f3ee012.js.map +1 -0
- package/dist/f4941e9d6d02713b.js +1 -0
- package/dist/f4941e9d6d02713b.js.map +1 -0
- package/dist/f516f10149ceaf20.js +1 -0
- package/dist/f516f10149ceaf20.js.map +1 -0
- package/dist/f7e95e9103f6bea5.js +1 -0
- package/dist/f7e95e9103f6bea5.js.map +1 -0
- package/dist/f87c9fff5312393d.js +1 -0
- package/dist/f87c9fff5312393d.js.map +1 -0
- package/dist/fdd8e6bc172cc6c8.js +1 -0
- package/dist/fdd8e6bc172cc6c8.js.map +1 -0
- package/dist/icon_128x128.addc1ce9ab1985d5e40ed48c2de69bb5.png +0 -0
- package/dist/icon_144x144.f4cc490c1b5ae9623ea84e233facf32e.png +0 -0
- package/dist/icon_192x192.628002be9ce9c4510018b7d94b94b90e.png +0 -0
- package/dist/icon_256x256.04e54c3231fe1852ee4f14359bf8fc37.png +0 -0
- package/dist/icon_384x384.9bef3ed318d064b36823da2035f62bec.png +0 -0
- package/dist/icon_512x512.bd73077d044266a7cf5f8bd6d7cb3b1b.png +0 -0
- package/dist/icon_96x96.6ec9feb388f20c73eecf14e2e2aea004.png +0 -0
- package/dist/index.html +1 -1
- package/dist/logo-512.png +0 -0
- package/dist/logo.svg +0 -0
- package/dist/{manifest.60265363becdf876d27bddc4588dc7c2.json → manifest.5a7b59c177c6ce166fbd2239a14d5fb8.json} +7 -7
- package/package.json +3 -3
- package/dist/c18393f118f80bc5.js +0 -1
- package/dist/c18393f118f80bc5.js.map +0 -1
- package/dist/eb27d690cf45cd5e.js +0 -20
- package/dist/eb27d690cf45cd5e.js.map +0 -1
- package/dist/egen.f35ccbd9a7ae43e2.js.map +0 -1
- package/dist/icon_128x128.3dde25c6e69b1c010a6a5d6b27b3f436.png +0 -0
- package/dist/icon_144x144.e263e02b838d229b02ff9133e6e0f2ba.png +0 -0
- package/dist/icon_192x192.d3d318638bbe8a10a3c687d3d302d01a.png +0 -0
- package/dist/icon_256x256.c729f6e7e914b58fcea5ce91d7aa9bad.png +0 -0
- package/dist/icon_384x384.c8923df6b6bd08eba5c79b78d7fcecc0.png +0 -0
- package/dist/icon_512x512.7163efb26df832de513bc58d925ea22e.png +0 -0
- package/dist/icon_96x96.682ee334ae19d49894217370b8596f61.png +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_egen_civitas_esm_app_shell=self.webpackChunk_egen_civitas_esm_app_shell||[]).push([["1581"],{2061(e,t,r){r.d(t,{$:()=>TE,$a:()=>Sy,$b:()=>Nu,A:()=>mh,Aa:()=>T1,Ab:()=>Sq,Ac:()=>NL,B:()=>mf,Ba:()=>T2,Bb:()=>Sj,Bc:()=>ND,C:()=>Tn,Ca:()=>T3,Cb:()=>SX,Cc:()=>NU,D:()=>Ti,Da:()=>T4,Db:()=>SK,Dc:()=>NO,E:()=>Ta,Ea:()=>T5,Eb:()=>SY,Ec:()=>NI,F:()=>To,Fa:()=>T6,Fb:()=>SQ,Fc:()=>NV,G:()=>Ts,Ga:()=>T8,Gb:()=>SZ,Gc:()=>NG,H:()=>Tu,Ha:()=>T9,Hb:()=>SJ,Hc:()=>Nz,I:()=>Tl,Ia:()=>T7,Ib:()=>S$,Ic:()=>NW,J:()=>Tc,Ja:()=>Se,Jb:()=>S0,Jc:()=>NH,K:()=>Td,Ka:()=>St,Kb:()=>S1,Kc:()=>Nq,L:()=>Th,La:()=>Sr,Lb:()=>S2,Lc:()=>Nj,M:()=>Tf,Ma:()=>Sn,Mb:()=>S3,Mc:()=>NX,N:()=>Tp,Na:()=>Si,Nb:()=>S4,Nc:()=>NK,O:()=>Tv,Oa:()=>Sa,Ob:()=>S5,Oc:()=>NY,P:()=>Tg,Pa:()=>So,Pb:()=>S6,Pc:()=>NQ,Q:()=>Tm,Qa:()=>Ss,Qb:()=>S8,Qc:()=>NZ,R:()=>Ty,Ra:()=>Su,Rb:()=>S9,Rc:()=>NJ,S:()=>Tb,Sa:()=>Sl,Sb:()=>S7,Sc:()=>N1,T:()=>Tx,Ta:()=>Sc,Tb:()=>Ne,Tc:()=>N2,U:()=>T_,Ua:()=>Sd,Ub:()=>Nt,Uc:()=>N3,V:()=>TT,Va:()=>Sh,Vb:()=>Nr,Vc:()=>N4,W:()=>TS,Wa:()=>Sf,Wb:()=>Nn,X:()=>TN,Xa:()=>Sp,Xb:()=>Ni,Y:()=>Tk,Ya:()=>Sv,Yb:()=>Na,Z:()=>Tw,Za:()=>Sg,Zb:()=>No,_:()=>TA,_a:()=>Sm,_b:()=>Ns,a:()=>eh,aa:()=>TR,ab:()=>Sb,ac:()=>Nl,b:()=>i4,ba:()=>TC,bb:()=>Sx,bc:()=>Nc,c:()=>lo,ca:()=>TM,cb:()=>S_,cc:()=>Nd,d:()=>lu,da:()=>TF,db:()=>ST,dc:()=>Nh,e:()=>lc,ea:()=>TB,eb:()=>SS,ec:()=>Nf,f:()=>lx,fa:()=>TP,fb:()=>SN,fc:()=>Np,g:()=>lT,ga:()=>TL,gb:()=>Sk,gc:()=>Nv,h:()=>lF,ha:()=>TD,hb:()=>Sw,hc:()=>Ng,i:()=>lL,ia:()=>TU,ib:()=>SA,ic:()=>Nm,j:()=>lV,ja:()=>TO,jb:()=>SE,jc:()=>Ny,k:()=>lz,ka:()=>TI,kb:()=>SR,kc:()=>Nb,l:()=>lH,la:()=>TV,lb:()=>SC,lc:()=>Nx,m:()=>cA,ma:()=>TG,mb:()=>SM,mc:()=>N_,n:()=>dl,na:()=>Tz,nb:()=>SF,nc:()=>NT,o:()=>df,oa:()=>TW,ob:()=>SB,oc:()=>NS,p:()=>dv,pa:()=>TH,pb:()=>SP,pc:()=>NN,q:()=>db,qa:()=>Tq,qb:()=>SL,qc:()=>Nk,r:()=>dT,ra:()=>Tj,rb:()=>SD,rc:()=>Nw,s:()=>dk,sa:()=>TX,sb:()=>SU,sc:()=>NA,t:()=>dE,ta:()=>TK,tb:()=>SO,tc:()=>NE,u:()=>dF,ua:()=>TY,ub:()=>SI,uc:()=>NR,v:()=>fh,va:()=>TQ,vb:()=>SV,vc:()=>NC,w:()=>vm,wa:()=>TZ,wb:()=>SG,wc:()=>NM,x:()=>vQ,xa:()=>TJ,xb:()=>Sz,xc:()=>NF,y:()=>gB,ya:()=>T$,yb:()=>SW,yc:()=>NB,z:()=>md,za:()=>T0,zb:()=>SH,zc:()=>NP});var n,i,a,o,s,u,l,c=r(3027);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function h(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){r(e);return}s.done?t(u):Promise.resolve(u).then(n,i)}function f(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){h(a,n,i,o,s,"next",e)}function s(e){h(a,n,i,o,s,"throw",e)}o(void 0)})}}function p(e,t,r){return t=_(t),w(e,B()?Reflect.construct(t,r||[],_(e).constructor):t.apply(e,r))}function v(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function g(e,t,r){return(g=B()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&A(i,r.prototype),i}).apply(null,arguments)}function m(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function y(e,t,r){return t&&m(e.prototype,t),r&&m(e,r),e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e,t,r){return(x="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r||e):i.value}})(e,t,r||e)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&A(e,t)}function S(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){b(e,t,r[t])})}return e}function k(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function w(e,t){if(t&&("object"===C(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e,t){return(A=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(r=i.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return a}}(e,t)||M(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||M(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function M(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}function F(e){var t="function"==typeof Map?new Map:void 0;return(F=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return g(e,arguments,_(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),A(r,e)})(e)}function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(B=function(){return!!e})()}function P(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(o,"next",{value:u(0)}),s(o,"throw",{value:u(1)}),s(o,"return",{value:u(2)}),"function"==typeof Symbol&&s(o,Symbol.iterator,{value:function(){return this}}),o;function u(s){return function(u){var l=[s,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&l[0]?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){a.label=l[1];break}if(6===l[0]&&a.label<i[1]){a.label=i[1],i=l;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(l);break}i[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var L=function(e){ew[e]={get:function(){this._cache=this._cache||{};var t=this._cache[e];return void 0===t&&(t=new ec(this,new ex(e,"uint")),this._cache[e]=t),t},set:function(t){this[e].assign(tg(t))}}},D=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],U=new WeakMap,O=new WeakMap,I=new WeakMap,V=function(){function e(t){v(this,e),this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=!0===t.object.isSkinnedMesh,this.refreshUniforms=D,this.renderId=0}return y(e,[{key:"firstInitialization",value:function(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}},{key:"needsVelocity",value:function(e){var t=e.getMRT();return null!==t&&t.has("velocity")}},{key:"getRenderObjectData",value:function(e){var t=this.renderObjects.get(e);if(void 0===t){var r=e.geometry,n=e.object;if(t={geometryId:r.id,worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),e.material.transmission>0){var i=e.context,a=i.width,o=i.height;t.bufferWidth=a,t.bufferHeight=o}var s=e.scene,u=s.environmentIntensity,l=s.environmentRotation;t.environmentIntensity=u,t.environmentRotation=l.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}},{key:"getAttributesData",value:function(e){var t={};for(var r in e){var n=e[r];t[r]={id:n.isInterleavedBufferAttribute?n.data.uuid:n.id,version:n.isInterleavedBufferAttribute?n.data.version:n.version}}return t}},{key:"containsNode",value:function(e){var t=e.material;for(var r in t)if(t[r]&&t[r].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}},{key:"getGeometryData",value:function(e){var t=I.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},I.set(e,t)),t}},{key:"getMaterialData",value:function(e){var t=O.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};var r=!0,n=!1,i=void 0;try{for(var a,o=this.refreshUniforms[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=e[s];null!=u&&("object"==(void 0===u?"undefined":C(u))&&void 0!==u.clone?!0===u.isTexture?t[s]={id:u.id,version:0}:t[s]=u.clone():t[s]=u)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}O.set(e,t)}return t}},{key:"equals",value:function(e,t,r){var n=e.object,i=e.material,a=e.geometry,o=this.getRenderObjectData(e);if(!0!==o.worldMatrix.equals(n.matrixWorld))return o.worldMatrix.copy(n.matrixWorld),!1;var s=this.getMaterialData(e.material);if(s._renderId!==r){for(var u in s._renderId=r,s){var l=s[u],c=i[u];if("_renderId"!==u&&"_equal"!==u){if(void 0!==l.equals){if(!1===l.equals(c))return l.copy(c),s._equal=!1,!1}else if(!0===c.isTexture){if(l.id!==c.id||l.version!==c.version)return l.id=c.id,l.version=c.version,s._equal=!1,!1}else if(l!==c)return s[u]=c,s._equal=!1,!1}}if(s.transmission>0){var d=e.context,h=d.width,f=d.height;if(o.bufferWidth!==h||o.bufferHeight!==f)return o.bufferWidth=h,o.bufferHeight=f,s._equal=!1,!1}s._equal=!0}else if(!1===s._equal)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;var p=this.getGeometryData(e.geometry);if(p._renderId!==r){p._renderId=r;var v=a.attributes,g=p.attributes,m=0,y=0;for(var b in v)m++;for(var x in g){y++;var _=g[x],T=v[x];if(void 0===T)return delete g[x],p._equal=!1,!1;var S=T.isInterleavedBufferAttribute?T.data.uuid:T.id,N=T.isInterleavedBufferAttribute?T.data.version:T.version;if(_.id!==S||_.version!==N)return _.id=S,_.version=N,p._equal=!1,!1}if(y!==m)return p.attributes=this.getAttributesData(v),p._equal=!1,!1;var k=a.index,w=p.indexId,A=p.indexVersion,E=k?k.id:null,R=k?k.version:null;if(w!==E||A!==R)return p.indexId=E,p.indexVersion=R,p._equal=!1,!1;if(p.drawRange.start!==a.drawRange.start||p.drawRange.count!==a.drawRange.count)return p.drawRange.start=a.drawRange.start,p.drawRange.count=a.drawRange.count,p._equal=!1,!1;p._equal=!0}else if(!1===p._equal)return!1;if(o.morphTargetInfluences){for(var C=!1,M=0;M<o.morphTargetInfluences.length;M++)o.morphTargetInfluences[M]!==n.morphTargetInfluences[M]&&(o.morphTargetInfluences[M]=n.morphTargetInfluences[M],C=!0);if(C)return!1}if(o.lights){for(var F=0;F<t.length;F++)if(o.lights[F].map!==t[F].map)return!1}var B=e.scene;return null===B.environment||null!==i.envMap||o.environmentIntensity===B.environmentIntensity&&!1!==o.environmentRotation.equals(B.environmentRotation)?o.center&&!1===o.center.equals(n.center)?(o.center.copy(n.center),!1):(null!==e.bundle&&(o.version=e.bundle.version),!0):(o.environmentIntensity=B.environmentIntensity,o.environmentRotation.copy(B.environmentRotation),!1)}},{key:"getLightsData",value:function(e,t){t.length=0;var r=!0,n=!1,i=void 0;try{for(var a,o=e[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;!0===s.isSpotLight&&null!==s.map&&t.push({map:s.map.version})}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t}},{key:"getLights",value:function(e,t){var r=U.get(e);return void 0===r&&(r={renderId:-1,lightsData:[]},U.set(e,r)),r.renderId===t||(r.renderId=t,this.getLightsData(e.getLights(),r.lightsData)),r.lightsData}},{key:"needsRefresh",value:function(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;var r=t.renderId;if(this.renderId!==r){this.renderId=r;var n=this.getRenderObjectData(e);if(n.worldMatrix.copy(e.object.matrixWorld),n.morphTargetInfluences)for(var i=e.object.morphTargetInfluences,a=0;a<n.morphTargetInfluences.length;a++)n.morphTargetInfluences[a]=i[a];return n.center&&e.object.center&&n.center.copy(e.object.center),!0}var o=!0===e.object.static,s=null!==e.bundle&&!0===e.bundle.static&&this.getRenderObjectData(e).version===e.bundle.version;if(o||s)return!1;var u=this.getLights(e.lightsNode,r);return!0!==this.equals(e,u,r)}}]),e}(),G=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],z=function(){function e(){var t,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(this,e),this.isStackTrace=!0,this.stack=(t=n||Error().stack,r=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/,t.split("\n").map(function(e){var t=e.match(r);if(!t)return null;var n=t[1]||t[2]||"",i=t[3].split("?")[0],a=parseInt(t[4],10),o=parseInt(t[5],10);return{fn:n,file:i.split("/").pop(),line:a,column:o}}).filter(function(e){return e&&!G.some(function(t){return t.test(e.file)})}))}return y(e,[{key:"getLocation",value:function(){if(0===this.stack.length)return"[Unknown location]";var e=this.stack[0],t=e.fn;return"".concat(t?'"'.concat(t,'()" at '):"",'"').concat(e.file,":").concat(e.line,'"')}},{key:"getError",value:function(e){return 0===this.stack.length?e:"".concat(e,"\n").concat(this.stack.map(function(e){var t="".concat(e.file,":").concat(e.line,":").concat(e.column);return e.fn?" at ".concat(e.fn," (").concat(t,")"):" at ".concat(t)}).join("\n"))}}]),e}();function W(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0xdeadbeef^t,n=0x41c6ce57^t;if(Array.isArray(e))for(var i,a=0;a<e.length;a++)r=Math.imul(r^(i=e[a]),0x9e3779b1),n=Math.imul(n^i,0x5f356495);else for(var o,s=0;s<e.length;s++)r=Math.imul(r^(o=e.charCodeAt(s)),0x9e3779b1),n=Math.imul(n^o,0x5f356495);return r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),0x100000000*(2097151&(n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35)))+(r>>>0)}var H=function(e){return W(e)},q=function(e){return W(e)},j=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return W(t)},X=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),K=new WeakMap;function Y(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error("THREE.NodeUtils: Unsupported type: ".concat(e))}function Q(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?9:/mat4/.test(e)?16:void(0,c.xc)("TSL: Unsupported type: ".concat(e),new z)}function Z(e){if(null==e)return null;var t=void 0===e?"undefined":C(e);return!0===e.isNode?"node":"number"===t?"float":"boolean"===t?"bool":"string"===t?"string":"function"===t?"shader":!0===e.isVector2?"vec2":!0===e.isVector3?"vec3":!0===e.isVector4?"vec4":!0===e.isMatrix2?"mat2":!0===e.isMatrix3?"mat3":!0===e.isMatrix4?"mat4":!0===e.isColor?"color":S(e,ArrayBuffer)?"ArrayBuffer":null}function J(e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=e?e.slice(-4):void 0;return 1===n.length&&("vec2"===a?n=[n[0],n[0]]:"vec3"===a?n=[n[0],n[0],n[0]]:"vec4"===a&&(n=[n[0],n[0],n[0],n[0]])),"color"===e?g(c.Tc,R(n)):"vec2"===a?g(c.Dc,R(n)):"vec3"===a?g(c.Fc,R(n)):"vec4"===a?g(c.Jc,R(n)):"mat2"===a?g(c.Pe,R(n)):"mat3"===a?g(c.Gc,R(n)):"mat4"===a?g(c.Oc,R(n)):"bool"===e?n[0]||!1:"float"===e||"int"===e||"uint"===e?n[0]||0:"string"===e?n[0]||"":"ArrayBuffer"===e?(t=n[0],Uint8Array.from(atob(t),function(e){return e.charCodeAt(0)}).buffer):null}function $(e){var t=K.get(e);return void 0===t&&(t={},K.set(e,t)),t}var ee={VERTEX:"vertex",FRAGMENT:"fragment"},et={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},er={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},en=["fragment","vertex"],ei=["setup","analyze","generate"],ea=R(en).concat(["compute"]),eo=["x","y","z","w"],es={analyze:"setup",generate:"analyze"},eu=0,el=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).nodeType=r,e.updateType=et.NONE,e.updateBeforeType=et.NONE,e.updateAfterType=et.NONE,e.version=0,e.name="",e.global=!1,e.parents=!1,e.isNode=!0,e._beforeNodes=null,e._cacheKey=null,e._uuid=null,e._cacheKeyVersion=0,e.id=eu++,e.stackTrace=null,!0===el.captureStackTrace&&(e.stackTrace=new z),e}return T(t,e),y(t,[{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{key:"uuid",get:function(){return null===this._uuid&&(this._uuid=c.Cc.generateUUID()),this._uuid}},{key:"type",get:function(){return this.constructor.type}},{key:"onUpdate",value:function(e,t){return this.updateType=t,this.update=e.bind(this),this}},{key:"onFrameUpdate",value:function(e){return this.onUpdate(e,et.FRAME)}},{key:"onRenderUpdate",value:function(e){return this.onUpdate(e,et.RENDER)}},{key:"onObjectUpdate",value:function(e){return this.onUpdate(e,et.OBJECT)}},{key:"onReference",value:function(e){return this.updateReference=e.bind(this),this}},{key:"updateReference",value:function(){return this}},{key:"isGlobal",value:function(){return this.global}},{key:"getChildren",value:function(){var e,t,r,n,i,a;return P(this,function(o){switch(o.label){case 0:e=!0,t=!1,r=void 0,o.label=1;case 1:o.trys.push([1,6,7,8]),n=this._getChildren()[Symbol.iterator](),o.label=2;case 2:if(e=(i=n.next()).done)return[3,5];return[4,i.value.childNode];case 3:o.sent(),o.label=4;case 4:return e=!0,[3,2];case 5:return[3,8];case 6:return a=o.sent(),t=!0,r=a,[3,8];case 7:try{e||null==n.return||n.return()}finally{if(t)throw r}return[7];case 8:return[2]}})}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}},{key:"traverse",value:function(e){e(this);var t=!0,r=!1,n=void 0;try{for(var i,a=this.getChildren()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)i.value.traverse(e)}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"_getChildren",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Set,t=[];e.add(this);var r=!0,n=!1,i=void 0;try{for(var a,o=Object.getOwnPropertyNames(this)[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=this[s];if(!0!==s.startsWith("_")&&!e.has(u)){if(!0===Array.isArray(u))for(var l=0;l<u.length;l++){var c=u[l];c&&!0===c.isNode&&t.push({property:s,index:l,childNode:c})}else if(u&&!0===u.isNode)t.push({property:s,childNode:u});else if(u&&Object.getPrototypeOf(u)===Object.prototype){for(var d in u)if(!0!==d.startsWith("_")){var h=u[d];h&&!0===h.isNode&&t.push({property:s,index:d,childNode:h})}}}}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t}},{key:"getCacheKey",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!0===(e=e||this.version!==this._cacheKeyVersion)||null===this._cacheKey){null===t&&(t=new Set);var r=[],n=!0,i=!1,a=void 0;try{for(var o,s=this._getChildren(t)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=u.property,c=u.childNode;r.push(H(l.slice(0,-4)),c.getCacheKey(e,t))}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}this._cacheKey=j(q(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}},{key:"customCacheKey",value:function(){return this.id}},{key:"getScope",value:function(){return this}},{key:"getHash",value:function(){return String(this.id)}},{key:"getUpdateType",value:function(){return this.updateType}},{key:"getUpdateBeforeType",value:function(){return this.updateBeforeType}},{key:"getUpdateAfterType",value:function(){return this.updateAfterType}},{key:"getElementType",value:function(e){var t=this.getNodeType(e);return e.getElementType(t)}},{key:"getMemberType",value:function(){return"void"}},{key:"getNodeType",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.getDataFromNode(this);return null!==r?(n.typeFromOutput=n.typeFromOutput||{},void 0===(t=n.typeFromOutput[r])&&(t=this.generateNodeType(e,r),n.typeFromOutput[r]=t)):void 0===(t=n.type)&&(n.type=t=this.generateNodeType(e)),t}},{key:"generateNodeType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e,t):this.nodeType}},{key:"getShared",value:function(e){var t=this.getHash(e),r=e.getNodeFromHash(t),n=null;if(r&&r!==this)n=r;else if(e.context.overrideNodes){var i=e.context.overrideNodes.get(this);if(i){var a=e.getDataFromNode(this);!0!==a.isOverwritten?(a.isOverwritten=!0,a.sharedNode=n=i(e).overrideNode(this,null)):n=a.sharedNode}}return n||this}},{key:"getArrayCount",value:function(){return null}},{key:"setup",value:function(e){var t=e.getNodeProperties(this),r=0,n=!0,i=!1,a=void 0;try{for(var o,s=this.getChildren()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;t["node"+r++]=u}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return t.outputNode||null}},{key:"analyze",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=e.increaseUsage(this);if(!0===this.parents){var n=e.getDataFromNode(this,"any");n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(1===r){var i=e.getNodeProperties(this),a=!0,o=!1,s=void 0;try{for(var u,l=Object.values(i)[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;c&&!0===c.isNode&&c.build(e,this)}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}}}},{key:"generate",value:function(e,t){var r=e.getNodeProperties(this).outputNode;if(r&&!0===r.isNode)return r.build(e,t)}},{key:"updateBefore",value:function(){(0,c.wc)("Abstract function.")}},{key:"updateAfter",value:function(){(0,c.wc)("Abstract function.")}},{key:"update",value:function(){(0,c.wc)("Abstract function.")}},{key:"before",value:function(e){return null===this._beforeNodes&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}},{key:"build",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.getShared(e);if(this!==r)return r.build(e,t);if(null!==this._beforeNodes){var n=this._beforeNodes;this._beforeNodes=null;var i=!0,a=!1,o=void 0;try{for(var s,u=n[Symbol.iterator]();!(i=(s=u.next()).done);i=!0)s.value.build(e,t)}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}this._beforeNodes=n}var l=e.getDataFromNode(this);l.buildStages=l.buildStages||{},l.buildStages[e.buildStage]=!0;var d=es[e.buildStage];if(d&&!0!==l.buildStages[d]){var h=e.getBuildStage();e.setBuildStage(d),this.build(e),e.setBuildStage(h)}e.addChain(this);var f=null,p=e.getBuildStage();if("setup"===p){e.addNode(this),this.updateReference(e);var v=e.getNodeProperties(this);if(!0!==v.initialized){v.initialized=!0,v.outputNode=this.setup(e)||v.outputNode||null;var g=!0,m=!1,y=void 0;try{for(var b,x=Object.values(v)[Symbol.iterator]();!(g=(b=x.next()).done);g=!0){var _=b.value;if(_&&!0===_.isNode){if(!0===_.parents){var T=e.getNodeProperties(_);T.parents=T.parents||[],T.parents.push(this)}_.build(e)}}}catch(e){m=!0,y=e}finally{try{g||null==x.return||x.return()}finally{if(m)throw y}}e.addSequentialNode(this)}f=v.outputNode}else if("analyze"===p)this.analyze(e,t);else if("generate"===p){if(this.generate.length<2){var S=this.getNodeType(e),N=e.getDataFromNode(this);void 0===(f=N.snippet)?void 0===N.generated?(N.generated=!0,N.snippet=f=this.generate(e)||""):((0,c.wc)("Node: Recursion detected.",this),f="/* Recursion detected. */"):void 0!==N.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),f=e.format(f,S,t)}else f=this.generate(e,t)||"";""===f&&null!==t&&"void"!==t&&"OutputType"!==t&&((0,c.xc)('TSL: Invalid generated code, expected a "'.concat(t,'".')),f=e.generateConst(t))}return e.removeChain(this),f}},{key:"getSerializeChildren",value:function(){return this._getChildren()}},{key:"serialize",value:function(e){var t=this.getSerializeChildren(),r={},n=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=u.property,c=u.index,d=u.childNode;void 0!==c?(void 0===r[l]&&(r[l]=Number.isInteger(c)?[]:{}),r[l][c]=d.toJSON(e.meta).uuid):r[l]=d.toJSON(e.meta).uuid}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}Object.keys(r).length>0&&(e.inputNodes=r)}},{key:"deserialize",value:function(e){if(void 0!==e.inputNodes){var t=e.meta.nodes;for(var r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){var n=[],i=!0,a=!1,o=void 0;try{for(var s,u=e.inputNodes[r][Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n.push(t[l])}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}this[r]=n}else if("object"==C(e.inputNodes[r])){var c={};for(var d in e.inputNodes[r]){var h=e.inputNodes[r][d];c[d]=t[h]}this[r]=c}else{var f=e.inputNodes[r];this[r]=t[f]}}}},{key:"toJSON",value:function(e){var t=this.uuid,r=this.type,n=void 0===e||"string"==typeof e;n&&(e={textures:{},images:{},nodes:{}});var i=e.nodes[t];function a(e){var t=[];for(var r in e){var n=e[r];delete n.metadata,t.push(n)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==n&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),n){var o=a(e.textures),s=a(e.images),u=a(e.nodes);o.length>0&&(i.textures=o),s.length>0&&(i.images=s),u.length>0&&(i.nodes=u)}return i}}],[{key:"type",get:function(){return"Node"}}]),t}(c.Bc);el.captureStackTrace=!1;var ec=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).node=e,n.indexNode=r,n.isArrayElementNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.node.getElementType(e)}},{key:"getMemberType",value:function(e,t){return this.node.getMemberType(e,t)}},{key:"generate",value:function(e){var t=this.indexNode.getNodeType(e);return"".concat(this.node.build(e),"[ ").concat(this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")," ]")}}],[{key:"type",get:function(){return"ArrayElementNode"}}]),t}(el),ed=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).node=e,n.convertTo=r,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){var t=this.node.getNodeType(e),r=null,n=!0,i=!1,a=void 0;try{for(var o,s=this.convertTo.split("|")[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;(null===r||e.getTypeLength(t)===e.getTypeLength(u))&&(r=u)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return r}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.convertTo=this.convertTo}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.convertTo=e.convertTo}},{key:"generate",value:function(e,t){var r=this.node,n=this.getNodeType(e),i=r.build(e,n);return e.format(i,n,t)}}],[{key:"type",get:function(){return"ConvertNode"}}]),t}(el),eh=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r])).isTempNode=!0,e}return T(t,e),y(t,[{key:"hasDependencies",value:function(e){return e.getDataFromNode(this).usageCount>1}},{key:"build",value:function(e,r){if("generate"===e.getBuildStage()){var n=e.getVectorType(this.getNodeType(e,r)),i=e.getDataFromNode(this);if(void 0!==i.propertyName)return e.format(i.propertyName,n,r);if("void"!==n&&"void"!==r&&this.hasDependencies(e)){var a=x(_(t.prototype),"build",this).call(this,e,n),o=e.getVarFromNode(this,null,n),s=e.getPropertyName(o);return e.addLineFlowCode("".concat(s," = ").concat(a),this),i.snippet=a,i.propertyName=s,e.format(i.propertyName,n,r)}}return x(_(t.prototype),"build",this).call(this,e,r)}}],[{key:"type",get:function(){return"TempNode"}}]),t}(el),ef=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(e=p(this,t,[n])).nodes=r,e}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(function(t,r){return t+e.getTypeLength(r.getNodeType(e))},0))}},{key:"generate",value:function(e,t){var r=this.getNodeType(e),n=e.getTypeLength(r),i=this.nodes,a=e.getComponentType(r),o=[],s=0,u=!0,l=!1,d=void 0;try{for(var h,f=i[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var p=h.value;if(s>=n){(0,c.xc)("TSL: Length of parameters exceeds maximum length of function '".concat(r,"()' type."),this.stackTrace);break}var v=void 0,g=p.getNodeType(e),m=e.getTypeLength(g);if(s+m>n&&((0,c.xc)("TSL: Length of '".concat(r,"()' data exceeds maximum length of output type."),this.stackTrace),m=n-s,g=e.getTypeFromLength(m)),s+=m,v=p.build(e,g),e.getComponentType(g)!==a){var y=e.getTypeFromLength(m,a);v=e.format(v,g,y)}o.push(v)}}catch(e){l=!0,d=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw d}}var b="".concat(e.getType(r),"( ").concat(o.join(", ")," )");return e.format(b,r,t)}}],[{key:"type",get:function(){return"JoinNode"}}]),t}(eh),ep=eo.join(""),ev=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x";return v(this,t),(r=p(this,t)).node=e,r.components=n,r.isSplitNode=!0,r}return T(t,e),y(t,[{key:"getVectorLength",value:function(){var e=this.components.length,t=!0,r=!1,n=void 0;try{for(var i,a=this.components[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;e=Math.max(eo.indexOf(o)+1,e)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return e}},{key:"getComponentType",value:function(e){return e.getComponentType(this.node.getNodeType(e))}},{key:"generateNodeType",value:function(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}},{key:"getScope",value:function(){return this.node.getScope()}},{key:"generate",value:function(e,t){var r=this.node,n=e.getTypeLength(r.getNodeType(e)),i=null;if(n>1){var a=null;this.getVectorLength()>=n&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));var o=r.build(e,a);i=this.components.length===n&&this.components===ep.slice(0,this.components.length)?e.format(o,a,t):e.format("".concat(o,".").concat(this.components),this.getNodeType(e),t)}else i=r.build(e,t);return i}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.components=this.components}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.components=e.components}}],[{key:"type",get:function(){return"SplitNode"}}]),t}(el),eg=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t)).sourceNode=e,i.components=r,i.targetNode=n,i}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.sourceNode.getNodeType(e)}},{key:"generate",value:function(e){for(var t=this.sourceNode,r=this.components,n=this.targetNode,i=this.getNodeType(e),a=e.getComponentType(n.getNodeType(e)),o=e.getTypeFromLength(r.length,a),s=n.build(e,o),u=t.build(e,i),l=e.getTypeLength(i),c=[],d=0;d<l;d++){var h=eo[d];h===r[0]?(c.push(s),d+=r.length-1):c.push(u+"."+h)}return"".concat(e.getType(i),"( ").concat(c.join(", ")," )")}}],[{key:"type",get:function(){return"SetNode"}}]),t}(eh),em=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).sourceNode=e,n.components=r,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.sourceNode.getNodeType(e)}},{key:"generate",value:function(e){var t=this.components,r=this.sourceNode,n=this.getNodeType(e),i=r.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+i,this);for(var s=e.getTypeLength(n),u=[],l=0,c=0;c<s;c++){var d=eo[c];d===t[l]?(u.push("1.0 - "+o+"."+d),l++):u.push(o+"."+d)}return"".concat(e.getType(n),"( ").concat(u.join(", ")," )")}}],[{key:"type",get:function(){return"FlipNode"}}]),t}(eh),ey=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[n])).isInputNode=!0,r.value=e,r.precision=null,r}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return null===this.nodeType?Z(this.value):this.nodeType}},{key:"getInputType",value:function(e){return this.getNodeType(e)}},{key:"setPrecision",value:function(e){return this.precision=e,this}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Z(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=function(e){for(var t="",r=new Uint8Array(e),n=0;n<r.length;n++)t+=String.fromCharCode(r[n]);return btoa(t)}(e.value)),e.precision=this.precision}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?J.apply(void 0,[e.valueType].concat(R(e.value))):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}},{key:"generate",value:function(){(0,c.wc)("Abstract function.")}}],[{key:"type",get:function(){return"InputNode"}}]),t}(el),eb=/float|u?int/,ex=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e,n])).isConstNode=!0,r}return T(t,e),y(t,[{key:"generateConst",value:function(e){return e.generateConst(this.getNodeType(e),this.value)}},{key:"generate",value:function(e,t){var r=this.getNodeType(e);return eb.test(r)&&eb.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}],[{key:"type",get:function(){return"ConstNode"}}]),t}(ey),e_=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).structNode=e,n.property=r,n.isMemberNode=!0,n}return T(t,e),y(t,[{key:"hasMember",value:function(e){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(e))&&"void"!==this.structNode.getMemberType(e,this.property)}},{key:"generateNodeType",value:function(e){return!1===this.hasMember(e)?"float":this.structNode.getMemberType(e,this.property)}},{key:"getMemberType",value:function(e,t){if(!1===this.hasMember(e))return"float";var r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}},{key:"generate",value:function(e){if(!1===this.hasMember(e)){(0,c.wc)('TSL: Member "'.concat(this.property,'" does not exist in struct.'),this.stackTrace);var t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}],[{key:"type",get:function(){return"MemberNode"}}]),t}(el),eT=null,eS=new Map;function eN(e,t){if(eS.has(e))(0,c.wc)("TSL: Redefinition of method chaining '".concat(e,"'."));else{if("function"!=typeof t)throw Error("THREE.TSL: Node element ".concat(e," is not a function"));eS.set(e,t),"assign"!==e&&(el.prototype[e]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return this.isStackNode?this.addToStack(t.apply(void 0,R(r))):t.apply(void 0,[this].concat(R(r)))},el.prototype[e+"Assign"]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return this.isStackNode?this.assign(r[0],t.apply(void 0,R(r))):this.assign(t.apply(void 0,[this].concat(R(r))))})}}var ek=function(e){return e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w").split("").sort().join("")};el.prototype.assign=function(){for(var e,t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];if(!0!==this.isStackNode)return null!==eT?(e=eT).assign.apply(e,[this].concat(R(r))):(0,c.xc)("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new z),this;var i=eS.get("assign");return this.addToStack(i.apply(void 0,R(r)))},el.prototype.toVarIntent=function(){return this},el.prototype.get=function(e){return new e_(this,e)};var ew={};function eA(e,t,r){ew[e]=ew[t]=ew[r]={get:function(){this._cache=this._cache||{};var t=this._cache[e];return void 0===t&&(t=new ev(this,e),this._cache[e]=t),t},set:function(t){this[e].assign(tg(t))}};var n=e.toUpperCase(),i=t.toUpperCase(),a=r.toUpperCase();el.prototype["set"+n]=el.prototype["set"+i]=el.prototype["set"+a]=function(t){return new eg(this,ek(e),tg(t))},el.prototype["flip"+n]=el.prototype["flip"+i]=el.prototype["flip"+a]=function(){return new em(this,ek(e))}}for(var eE=["x","y","z","w"],eR=["r","g","b","a"],eC=["s","t","p","q"],eM=0;eM<4;eM++){var eF=eE[eM],eB=eR[eM],eP=eC[eM];eA(eF,eB,eP);for(var eL=0;eL<4;eL++){eF=eE[eM]+eE[eL],eA(eF,eB=eR[eM]+eR[eL],eP=eC[eM]+eC[eL]);for(var eD=0;eD<4;eD++){eF=eE[eM]+eE[eL]+eE[eD],eA(eF,eB=eR[eM]+eR[eL]+eR[eD],eP=eC[eM]+eC[eL]+eC[eD]);for(var eU=0;eU<4;eU++)eF=eE[eM]+eE[eL]+eE[eD]+eE[eU],eA(eF,eB=eR[eM]+eR[eL]+eR[eD]+eR[eU],eP=eC[eM]+eC[eL]+eC[eD]+eC[eU])}}}for(var eO=0;eO<32;eO++)L(eO);Object.defineProperties(el.prototype,ew);var eI=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;for(var r in e)e[r]=tg(e[r],t);return e},eV=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=e.length,n=0;n<r;n++)e[n]=tg(e[n],t);return e},eG=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;function i(e){return null!==n?(e=tg(Object.assign(e,n)),!0===n.intent&&(e=e.toVarIntent())):e=tg(e),e}var a,o,s,u=t;function l(t){var r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==o&&t.length<o?((0,c.xc)('TSL: "'.concat(r,'" parameter length is less than minimum required.'),new z),t.concat(Array(o-t.length).fill(0))):void 0!==s&&t.length>s?((0,c.xc)('TSL: "'.concat(r,'" parameter length exceeds limit.'),new z),t.slice(0,s)):t}return null===t?a=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return i(g(e,R(tb(l(r)))))}:null!==r?(r=tg(r),a=function(){for(var n=arguments.length,a=Array(n),o=0;o<n;o++)a[o]=arguments[o];return i(g(e,[t].concat(R(tb(l(a))),[r])))}):a=function(){for(var r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];return i(g(e,[t].concat(R(tb(l(n))))))},a.setParameterLength=function(){for(var e,t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return 1===r.length?o=s=r[0]:2===r.length&&(o=(e=E(r,2))[0],s=e[1]),a},a.setName=function(e){return u=e,a},a},ez=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return g(e,R(tb(r)))},eW=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).shaderNode=e,n.rawInputs=r,n.isShaderCallNodeInternal=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}},{key:"getElementType",value:function(e){return this.getOutputNode(e).getElementType(e)}},{key:"getMemberType",value:function(e,t){return this.getOutputNode(e).getMemberType(e,t)}},{key:"call",value:function(e){var t=this.shaderNode,r=this.rawInputs,n=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||"",a=i||"default";if(n[a])return n[a];var o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;var u=null;if(t.layout){if(r){var l=t.layout.inputs;if(eH(r))for(var c=0;c<l.length;c++){var d=r[c];d&&d.isNode&&d.build(e)}else{var h=r[0],f=!0,p=!1,v=void 0;try{for(var g,m=l[Symbol.iterator]();!(f=(g=m.next()).done);f=!0){var y=h[g.value.name];y&&y.isNode&&y.build(e)}}catch(e){p=!0,v=e}finally{try{f||null==m.return||m.return()}finally{if(p)throw v}}}}var b=e.buildFunctionNode(t);e.addInclude(b);var x=r?(ty(r),eH(r)?R(r):r[0]):null;u=b.call(x)}else{var _,T=new Proxy(e,{get:function(e,t,r){return Symbol.iterator===t?function(){return P(this,function(e){switch(e.label){case 0:return[4];case 1:return e.sent(),[2]}})}:Reflect.get(e,t,r)}}),N=r?(_=0,ty(r),new Proxy(r,{get:function(e,t,n){var i;if("length"===t)return r.length;if(Symbol.iterator===t)i=function(){var e,t,n,i,a,o;return P(this,function(s){switch(s.label){case 0:e=!0,t=!1,n=void 0,s.label=1;case 1:s.trys.push([1,6,7,8]),i=r[Symbol.iterator](),s.label=2;case 2:if(e=(a=i.next()).done)return[3,5];return[4,tg(a.value)];case 3:s.sent(),s.label=4;case 4:return e=!0,[3,2];case 5:return[3,8];case 6:return o=s.sent(),t=!0,n=o,[3,8];case 7:try{e||null==i.return||i.return()}finally{if(t)throw n}return[7];case 8:return[2]}})};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){var a=r[0];i=void 0===a[t]?a[_++]:Reflect.get(a,t,n)}else S(r[0],el)&&(i=void 0===r[t]?r[_++]:Reflect.get(r,t,n));else i=Reflect.get(e,t,n);i=tg(i)}return i}})):null,k=Array.isArray(r)?r.length>0:null!==r,w=t.jsFunc;u=tg(k||w.length>1?w(N,T):w(T))}return e.subBuildFn=o,e.fnCall=s,t.once&&(n[a]=u),u}},{key:"setupOutput",value:function(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}},{key:"getOutputNode",value:function(e){var t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}},{key:"build",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=null,n=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,"setup"===n){var u=e.getSubBuildProperty("initialized",this),l=!0,c=!1,d=void 0;if(!0!==i[u]&&(i[u]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))try{for(var h,f=e.chaining[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var p=h.value,v=e.getDataFromNode(p,"any");v.subBuilds=v.subBuilds||new Set;var g=!0,m=!1,y=void 0;try{for(var b,x=this.shaderNode.subBuilds[Symbol.iterator]();!(g=(b=x.next()).done);g=!0){var _=b.value;v.subBuilds.add(_)}}catch(e){m=!0,y=e}finally{try{g||null==x.return||x.return()}finally{if(m)throw y}}}}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}r=i[a]}else"analyze"===n?o.build(e,t):"generate"===n&&(r=o.build(e,t)||"");return e.fnCall=s,r}}]),t}(el);function eH(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}for(var eq=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[r])).jsFunc=e,n.layout=null,n.global=!0,n.once=!1,n}return T(t,e),y(t,[{key:"setLayout",value:function(e){return this.layout=e,this}},{key:"getLayout",value:function(){return this.layout}},{key:"call",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return new eW(this,e)}},{key:"setup",value:function(){return this.call()}}]),t}(el),ej=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],eX=new Map,eK=0,eY=[!1,!0];eK<eY.length;eK++){var eQ=eY[eK];eX.set(eQ,new ex(eQ))}for(var eZ=new Map,eJ=0,e$=[0,1,2,3];eJ<e$.length;eJ++){var e0=e$[eJ];eZ.set(e0,new ex(e0,"uint"))}for(var e1=new Map(R(eZ).map(function(e){return new ex(e.value,"int")})),e2=0,e3=[-1,-2];e2<e3.length;e2++){var e4=e3[e2];e1.set(e4,new ex(e4,"int"))}var e5=new Map(R(e1).map(function(e){return new ex(e.value)})),e6=!0,e8=!1,e9=void 0;try{for(var e7,te,tt,tr=ej[Symbol.iterator]();!(e6=(tt=tr.next()).done);e6=!0){var tn=tt.value;e5.set(tn,new ex(tn))}}catch(e){e8=!0,e9=e}finally{try{e6||null==tr.return||tr.return()}finally{if(e8)throw e9}}var ti=!0,ta=!1,to=void 0;try{for(var ts,tu=ej[Symbol.iterator]();!(ti=(ts=tu.next()).done);ti=!0){var tl=ts.value;e5.set(-tl,new ex(-tl))}}catch(e){ta=!0,to=e}finally{try{ti||null==tu.return||tu.return()}finally{if(ta)throw to}}var tc=new Map(R(eX).concat(R(e5))),td=function(e,t){return tc.has(e)?tc.get(e):!0===e.isNode?e:new ex(e,t)},th=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(){for(var r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var a=!0,o=!1,s=void 0;try{for(var u,l=n[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var d=u.value;if(void 0===d)return(0,c.xc)('TSL: Invalid parameter for the type "'.concat(e,'".'),new z),new ex(0,e)}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}if((0===n.length||!["bool","float","int","uint"].includes(e)&&n.every(function(e){var t=void 0===e?"undefined":C(e);return"object"!==t&&"function"!==t}))&&(n=[J.apply(void 0,[e].concat(R(n)))]),1===n.length&&null!==t&&t.has(n[0]))return tm(t.get(n[0]));if(1===n.length){var h=td(n[0],e);return h.nodeType===e?tm(h):tm(new ed(h,e))}return tm(new ef(n.map(function(e){return td(e)}),e))}};function tf(e){return e&&e.isNode&&e.traverse(function(t){t.isConstNode&&(e=t.value)}),!!e}var tp=function(e){return null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null};function tv(e,t){return new eq(e,t)}var tg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=Z(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?tg(td(e,t)):"shader"===r?e.isFn?e:tw(e):e}(e,t)},tm=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return tg(e,t).toVarIntent()},ty=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new eI(e,t)},tb=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new eV(e,t)},tx=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return new eG(e,t,r,n)},t_=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return g(ez,[e].concat(R(r)))},tT=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new eG(e,t,r,k(N({},n),{intent:!0}))},tS=function(e,t){return new Proxy(e,{get:function(e,r,n){return Reflect.get(t,r,n)},set:function(e,r,n){return Reflect.set(t,r,n)}})},tN=0,tk=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;v(this,t),r=p(this,t);var i=null;return null!==n&&("object"==(void 0===n?"undefined":C(n))?i=n.return:("string"==typeof n?i=n:(0,c.xc)("TSL: Invalid layout type.",new z),n=null)),r.shaderNode=new tv(e,i),null!==n&&r.setLayout(n),r.isFn=!0,r}return T(t,e),y(t,[{key:"setLayout",value:function(e){var t=this.shaderNode.nodeType;if("object"!=C(e.inputs)){var r={name:"fn"+tN++,type:t,inputs:[]};for(var n in e)"return"!==n&&r.inputs.push({name:n,type:e[n]});e=r}return this.shaderNode.setLayout(e),this}},{key:"generateNodeType",value:function(e){return this.shaderNode.getNodeType(e)||"float"}},{key:"call",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=this.shaderNode.call(t);return"void"===this.shaderNode.nodeType&&n.toStack(),n.toVarIntent()}},{key:"once",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}},{key:"generate",value:function(e){var t=this.getNodeType(e);return(0,c.xc)('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}]),t}(el);function tw(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=new tk(e,r);return new Proxy(function(){},{apply:function(e,r,i){return(t=n).call.apply(t,R(i))},get:function(e,t,r){return Reflect.get(n,t,r)},set:function(e,t,r,i){return Reflect.set(n,t,r,i)}})}var tA=function(e){eT=e},tE=function(){return eT},tR=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(e7=eT).If.apply(e7,R(t))};function tC(e){return eT&&eT.addToStack(e),e}eN("toStack",tC);var tM=new th("color"),tF=new th("float",e5),tB=new th("int",e1),tP=new th("uint",eZ),tL=new th("bool",eX),tD=new th("vec2"),tU=new th("ivec2"),tO=new th("uvec2"),tI=new th("bvec2"),tV=new th("vec3"),tG=new th("ivec3"),tz=new th("uvec3"),tW=new th("bvec3"),tH=new th("vec4"),tq=new th("ivec4"),tj=new th("uvec4"),tX=new th("bvec4"),tK=new th("mat2"),tY=new th("mat3"),tQ=new th("mat4");eN("toColor",tM),eN("toFloat",tF),eN("toInt",tB),eN("toUint",tP),eN("toBool",tL),eN("toVec2",tD),eN("toIVec2",tU),eN("toUVec2",tO),eN("toBVec2",tI),eN("toVec3",tV),eN("toIVec3",tG),eN("toUVec3",tz),eN("toBVec3",tW),eN("toVec4",tH),eN("toIVec4",tq),eN("toUVec4",tj),eN("toBVec4",tX),eN("toMat2",tK),eN("toMat3",tY),eN("toMat4",tQ);var tZ=tx(ec).setParameterLength(2),tJ=function(e,t){return new ed(tg(e),t)};eN("element",tZ),eN("convert",tJ),eN("append",function(e){return(0,c.wc)("TSL: .append() has been renamed to .toStack().",new z),tC(e)});var t$=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(r=p(this,t,[e])).name=n,r.varying=i,r.placeholderNode=tg(a),r.isPropertyNode=!0,r.global=!0,r}return T(t,e),y(t,[{key:"getNodeType",value:function(e){var r=x(_(t.prototype),"getNodeType",this).call(this,e);return"output"===r?e.getOutputType():r}},{key:"customCacheKey",value:function(){return H(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}},{key:"getHash",value:function(e){return this.name||x(_(t.prototype),"getHash",this).call(this,e)}},{key:"generate",value:function(e){var t;if(!0===this.varying)(t=e.getVaryingFromNode(this,this.name)).needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),null!==this.placeholderNode&&!1===e.hasWriteUsage(this)){var r=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode("".concat(e.getPropertyName(t)," = ").concat(r),this)}return e.getPropertyName(t)}}],[{key:"type",get:function(){return"PropertyNode"}}]),t}(el),t0=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new t$(e,t,!1,r)},t1=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new t$(e,t,!0,r)},t2=t_(t$,"vec4","DiffuseColor"),t3=t_(t$,"vec3","DiffuseContribution"),t4=t_(t$,"vec3","EmissiveColor"),t5=t_(t$,"float","Roughness"),t6=t_(t$,"float","Metalness"),t8=t_(t$,"float","Clearcoat"),t9=t_(t$,"float","ClearcoatRoughness"),t7=t_(t$,"vec3","Sheen"),re=t_(t$,"float","SheenRoughness"),rt=t_(t$,"float","Iridescence"),rr=t_(t$,"float","IridescenceIOR"),rn=t_(t$,"float","IridescenceThickness"),ri=t_(t$,"float","AlphaT"),ra=t_(t$,"float","Anisotropy"),ro=t_(t$,"vec3","AnisotropyT"),rs=t_(t$,"vec3","AnisotropyB"),ru=t_(t$,"color","SpecularColor"),rl=t_(t$,"color","SpecularColorBlended"),rc=t_(t$,"float","SpecularF90"),rd=t_(t$,"float","Shininess"),rh=t_(t$,"output","Output"),rf=t_(t$,"float","dashSize"),rp=t_(t$,"float","gapSize"),rv=t_(t$,"float","pointWidth"),rg=t_(t$,"float","IOR"),rm=t_(t$,"float","Transmission"),ry=t_(t$,"float","Thickness"),rb=t_(t$,"float","AttenuationDistance"),rx=t_(t$,"color","AttenuationColor"),r_=t_(t$,"float","Dispersion"),rT=t_(t$,"float","AmbientOcclusion",!1,1),rS=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(r=p(this,t,["string"])).name=e,r.shared=n,r.order=i,r.updateType=a,r.isUniformGroup=!0,r}return T(t,e),y(t,[{key:"update",value:function(){this.needsUpdate=!0}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.name=this.name,e.version=this.version,e.shared=this.shared}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.name=e.name,this.version=e.version,this.shared=e.shared}}],[{key:"type",get:function(){return"UniformGroupNode"}}]),t}(el),rN=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new rS(e,!1,t,r)},rk=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new rS(e,!0,t,r)},rw=rk("frame",0,et.FRAME),rA=rk("render",0,et.RENDER),rE=rN("object",1,et.OBJECT),rR=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e,n])).isUniformNode=!0,r.name="",r.groupNode=rE,r}return T(t,e),y(t,[{key:"setName",value:function(e){return this.name=e,this}},{key:"label",value:function(e){return(0,c.wc)('TSL: "label()" has been deprecated. Use "setName()" instead.',new z),this.setName(e)}},{key:"setGroup",value:function(e){return this.groupNode=e,this}},{key:"getGroup",value:function(){return this.groupNode}},{key:"getUniformHash",value:function(e){return this.getHash(e)}},{key:"onUpdate",value:function(e,r){var n=this;return e=e.bind(this),x(_(t.prototype),"onUpdate",this).call(this,function(t){var r=e(t,n);void 0!==r&&(n.value=r)},r)}},{key:"getInputType",value:function(e){var r=x(_(t.prototype),"getInputType",this).call(this,e);return"bool"===r&&(r="uint"),r}},{key:"generate",value:function(e,t){var r=this.getNodeType(e),n=this.getUniformHash(e),i=e.getNodeFromHash(n);void 0===i&&(e.setHashNode(this,n),i=this);var a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);void 0!==e.context.nodeName&&delete e.context.nodeName;var u=s;if("bool"===r){var l=e.getDataFromNode(this),c=l.propertyName;if(void 0===c){var d=e.getVarFromNode(this,null,"bool");l.propertyName=c=e.getPropertyName(d),u=e.format(s,a,r),e.addLineFlowCode("".concat(c," = ").concat(u),this)}u=c}return e.format(u,r,t)}}],[{key:"type",get:function(){return"UniformNode"}}]),t}(ey),rC=function(e,t){var r=tp(t||e);if(r===e&&(e=J(r)),e&&!0===e.isNode){var n=e.value;e.traverse(function(e){!0===e.isConstNode&&(n=e.value)}),e=n}return new rR(e,r)},rM=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e])).count=r,n.values=i,n.isArrayNode=!0,n}return T(t,e),y(t,[{key:"getArrayCount",value:function(){return this.count}},{key:"generateNodeType",value:function(e){return null===this.nodeType?this.values[0].getNodeType(e):this.nodeType}},{key:"getElementType",value:function(e){return this.getNodeType(e)}},{key:"getMemberType",value:function(e,r){return null===this.nodeType?this.values[0].getMemberType(e,r):x(_(t.prototype),"getMemberType",this).call(this,e,r)}},{key:"generate",value:function(e){var t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}],[{key:"type",get:function(){return"ArrayNode"}}]),t}(eh),rF=function(){for(var e,t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];if(1===r.length){var i=r[0];e=new rM(null,i.length,i)}else e=new rM(r[0],r[1]);return tg(e)};eN("toArray",function(e,t){return rF(Array(t).fill(e))});var rB=tx(function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).targetNode=e,n.sourceNode=r,n.isAssignNode=!0,n}return T(t,e),y(t,[{key:"hasDependencies",value:function(){return!1}},{key:"generateNodeType",value:function(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}},{key:"needsSplitAssign",value:function(e){var t=this.targetNode;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){var r=e.getTypeLength(t.node.getNodeType(e));return eo.join("").slice(0,r)!==t.components}return!1}},{key:"setup",value:function(e){var t=this.targetNode,r=this.sourceNode,n=t.getScope();e.getDataFromNode(n).assign=!0;var i=e.getNodeProperties(this);i.sourceNode=r,i.targetNode=t.context({assign:!0})}},{key:"generate",value:function(e,t){var r,n=e.getNodeProperties(this),i=n.targetNode,a=n.sourceNode,o=this.needsSplitAssign(e),s=i.build(e),u=i.getNodeType(e),l=a.build(e,u),c=a.getNodeType(e),d=e.getDataFromNode(this);if(!0===d.initialized)"void"!==t&&(r=s);else if(o){var h=e.getVarFromNode(this,null,u),f=e.getPropertyName(h);e.addLineFlowCode("".concat(f," = ").concat(l),this);for(var p=i.node,v=p.node.context({assign:!0}).build(e),g=0;g<p.components.length;g++){var m=p.components[g];e.addLineFlowCode("".concat(v,".").concat(m," = ").concat(f,"[ ").concat(g," ]"),this)}"void"!==t&&(r=s)}else r="".concat(s," = ").concat(l),("void"===t||"void"===c)&&(e.addLineFlowCode(r,this),"void"!==t&&(r=s));return d.initialized=!0,e.format(r,u,t)}}],[{key:"type",get:function(){return"AssignNode"}}]),t}(eh)).setParameterLength(2);eN("assign",rB);var rP=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v(this,t),(e=p(this,t)).functionNode=r,e.parameters=n,e}return T(t,e),y(t,[{key:"setParameters",value:function(e){return this.parameters=e,this}},{key:"getParameters",value:function(){return this.parameters}},{key:"generateNodeType",value:function(e){return this.functionNode.getNodeType(e)}},{key:"getMemberType",value:function(e,t){return this.functionNode.getMemberType(e,t)}},{key:"generate",value:function(e){var t=[],r=this.functionNode,n=r.getInputs(e),i=this.parameters,a=function(t,r){var n=r.type;return"pointer"===n?"&"+t.build(e):t.build(e,n)},o=!0,s=!1,u=void 0;if(Array.isArray(i)){if(i.length>n.length)(0,c.xc)("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=n.length;else if(i.length<n.length)for((0,c.xc)("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<n.length;)i.push(tF(0));for(var l=0;l<i.length;l++)t.push(a(i[l],n[l]))}else try{for(var d,h=n[Symbol.iterator]();!(o=(d=h.next()).done);o=!0){var f=d.value,p=i[f.name];void 0!==p?t.push(a(p,f)):((0,c.xc)("TSL: Input '".concat(f.name,"' not found in 'Fn()'.")),t.push(a(tF(0),f)))}}catch(e){s=!0,u=e}finally{try{o||null==h.return||h.return()}finally{if(s)throw u}}return"".concat(r.build(e,"property"),"( ").concat(t.join(", ")," )")}}],[{key:"type",get:function(){return"FunctionCallNode"}}]),t}(eh),rL=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return r=r.length>1||r[0]&&!0===r[0].isNode?tb(r):ty(r[0]),new rP(tg(e),r)};eN("call",rL);var rD={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},rU=function(e){function t(e,r,n){for(var i,a=arguments.length,o=Array(a>3?a-3:0),s=3;s<a;s++)o[s-3]=arguments[s];if(v(this,t),i=p(this,t),o.length>0){for(var u=new rU(e,r,n),l=0;l<o.length-1;l++)u=new rU(e,u,o[l]);r=u,n=o[o.length-1]}return i.op=e,i.aNode=r,i.bNode=n,i.isOperatorNode=!0,i}return T(t,e),y(t,[{key:"getOperatorMethod",value:function(e,t){return e.getMethod(rD[this.op],t)}},{key:"generateNodeType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.op,n=this.aNode,i=this.bNode,a=n.getNodeType(e),o=i?i.getNodeType(e):null;if("void"===a||"void"===o)return t||"void";if("%"===r)return a;if("~"===r||"&"===r||"|"===r||"^"===r||">>"===r||"<<"===r)return e.getIntegerType(a);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){var s=e.getTypeLength(a);return s>1?"bvec".concat(s):"bool"}if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r){var u=Math.max(e.getTypeLength(a),e.getTypeLength(o));return u>1?"bvec".concat(u):"bool"}if(e.isMatrix(a)){if("float"===o)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if("float"===a)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}},{key:"generate",value:function(e,t){var r=this.op,n=this.aNode,i=this.bNode,a=this.getNodeType(e,t),o=null,s=null;"void"!==a?(o=n.getNodeType(e),s=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s="float"):">>"===r||"<<"===r?(o=a,s=e.changeComponentType(s,"uint")):"%"===r?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?"float"===s?s="float":e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?"float"===o?"float":e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a):o=s=a;var u=n.build(e,o),l=i?i.build(e,s):null,d=e.getFunctionOperator(r);if("void"!==t){var h=e.renderer.coordinateSystem===c.oc;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return h&&e.isVector(o)?e.format("".concat(this.getOperatorMethod(e,t),"( ").concat(u,", ").concat(l," )"),a,t):e.format("( ".concat(u," ").concat(r," ").concat(l," )"),a,t);if("%"===r)return e.isInteger(s)?e.format("( ".concat(u," % ").concat(l," )"),a,t):e.format("".concat(this.getOperatorMethod(e,a),"( ").concat(u,", ").concat(l," )"),a,t);if("!"===r)return h&&e.isVector(o)?e.format("not( ".concat(u," )"),t):e.format("( ".concat(r," ").concat(u," )"),o,t);if("~"===r)return e.format("( ".concat(r," ").concat(u," )"),o,t);if(d)return e.format("".concat(d,"( ").concat(u,", ").concat(l," )"),a,t);if(e.isMatrix(o)&&"float"===s)return e.format("( ".concat(l," ").concat(r," ").concat(u," )"),a,t);if("float"===o&&e.isMatrix(s))return e.format("".concat(u," ").concat(r," ").concat(l),a,t);var f="( ".concat(u," ").concat(r," ").concat(l," )");return!h&&"bool"===a&&e.isVector(o)&&e.isVector(s)&&(f="all".concat(f)),e.format(f,a,t)}if("void"!==o)return d?e.format("".concat(d,"( ").concat(u,", ").concat(l," )"),a,t):e.isMatrix(o)&&"float"===s?e.format("".concat(l," ").concat(r," ").concat(u),a,t):e.format("".concat(u," ").concat(r," ").concat(l),a,t)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.op=this.op}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.op=e.op}}],[{key:"type",get:function(){return"OperatorNode"}}]),t}(eh),rO=tT(rU,"+").setParameterLength(2,1/0).setName("add"),rI=tT(rU,"-").setParameterLength(2,1/0).setName("sub"),rV=tT(rU,"*").setParameterLength(2,1/0).setName("mul"),rG=tT(rU,"/").setParameterLength(2,1/0).setName("div"),rz=tT(rU,"%").setParameterLength(2).setName("mod"),rW=tT(rU,"==").setParameterLength(2).setName("equal"),rH=tT(rU,"!=").setParameterLength(2).setName("notEqual"),rq=tT(rU,"<").setParameterLength(2).setName("lessThan"),rj=tT(rU,">").setParameterLength(2).setName("greaterThan"),rX=tT(rU,"<=").setParameterLength(2).setName("lessThanEqual"),rK=tT(rU,">=").setParameterLength(2).setName("greaterThanEqual"),rY=tT(rU,"&&").setParameterLength(2,1/0).setName("and"),rQ=tT(rU,"||").setParameterLength(2,1/0).setName("or"),rZ=tT(rU,"!").setParameterLength(1).setName("not"),rJ=tT(rU,"^^").setParameterLength(2).setName("xor"),r$=tT(rU,"&").setParameterLength(2).setName("bitAnd"),r0=tT(rU,"~").setParameterLength(1).setName("bitNot"),r1=tT(rU,"|").setParameterLength(2).setName("bitOr"),r2=tT(rU,"^").setParameterLength(2).setName("bitXor"),r3=tT(rU,"<<").setParameterLength(2).setName("shiftLeft"),r4=tT(rU,">>").setParameterLength(2).setName("shiftRight"),r5=tw(function(e){var t=E(e,1)[0];return t.addAssign(1),t}),r6=tw(function(e){var t=E(e,1)[0];return t.subAssign(1),t}),r8=tw(function(e){var t=E(e,1)[0],r=tB(t).toConst();return t.addAssign(1),r}),r9=tw(function(e){var t=E(e,1)[0],r=tB(t).toConst();return t.subAssign(1),r});eN("add",rO),eN("sub",rI),eN("mul",rV),eN("div",rG),eN("mod",rz),eN("equal",rW),eN("notEqual",rH),eN("lessThan",rq),eN("greaterThan",rj),eN("lessThanEqual",rX),eN("greaterThanEqual",rK),eN("and",rY),eN("or",rQ),eN("not",rZ),eN("xor",rJ),eN("bitAnd",r$),eN("bitNot",r0),eN("bitOr",r1),eN("bitXor",r2),eN("shiftLeft",r3),eN("shiftRight",r4),eN("incrementBefore",r5),eN("decrementBefore",r6),eN("increment",r8),eN("decrement",r9);var r7=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(v(this,t),n=p(this,t),(e===r7.MAX||e===r7.MIN)&&arguments.length>3){for(var o=new r7(e,r,i),s=3;s<arguments.length-1;s++)o=new r7(e,o,arguments[s]);r=o,i=arguments[arguments.length-1],a=null}return n.method=e,n.aNode=r,n.bNode=i,n.cNode=a,n.isMathNode=!0,n}return T(t,e),y(t,[{key:"getInputType",value:function(e){var t=this.aNode.getNodeType(e),r=this.bNode?this.bNode.getNodeType(e):null,n=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(r)?0:e.getTypeLength(r),o=e.isMatrix(n)?0:e.getTypeLength(n);return i>a&&i>o?t:a>o?r:o>i?n:t}},{key:"generateNodeType",value:function(e){var t=this.method;return t===r7.LENGTH||t===r7.DISTANCE||t===r7.DOT?"float":t===r7.CROSS?"vec3":t===r7.ALL||t===r7.ANY?"bool":t===r7.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}},{key:"setup",value:function(e){var r,n,i=this.aNode,a=this.bNode,o=this.method,s=null;return o===r7.ONE_MINUS?s=rI(1,i):o===r7.RECIPROCAL?s=rG(1,i):o===r7.DIFFERENCE?s=nF(rI(i,a)):o===r7.TRANSFORM_DIRECTION&&(e.isMatrix(i.getNodeType(e))?(r=i,n=a):(r=a,n=i),s=ny(rV(r,tH(tV(n),0)).xyz)),null!==s?s:x(_(t.prototype),"setup",this).call(this,e)}},{key:"generate",value:function(e,r){if(e.getNodeProperties(this).outputNode)return x(_(t.prototype),"generate",this).call(this,e,r);var n=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,s=this.bNode,u=this.cNode,l=e.renderer.coordinateSystem;if(n===r7.NEGATE)return e.format("( - "+o.build(e,a)+" )",i,r);var d=[];return n===r7.CROSS?d.push(o.build(e,i),s.build(e,i)):l===c.oc&&n===r7.STEP?d.push(o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":a),s.build(e,a)):l!==c.oc||n!==r7.MIN&&n!==r7.MAX?n===r7.REFRACT?d.push(o.build(e,a),s.build(e,a),u.build(e,"float")):n===r7.MIX?d.push(o.build(e,a),s.build(e,a),u.build(e,1===e.getTypeLength(u.getNodeType(e))?"float":a)):(l===c.pc&&n===r7.ATAN&&null!==s&&(n="atan2"),"fragment"!==e.shaderStage&&(n===r7.DFDX||n===r7.DFDY)&&((0,c.wc)("TSL: '".concat(n,"' is not supported in the ").concat(e.shaderStage," stage."),this.stackTrace),n="/*"+n+"*/"),d.push(o.build(e,a)),null!==s&&d.push(s.build(e,a)),null!==u&&d.push(u.build(e,a))):d.push(o.build(e,a),s.build(e,1===e.getTypeLength(s.getNodeType(e))?"float":a)),e.format("".concat(e.getMethod(n,i),"( ").concat(d.join(", ")," )"),i,r)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.method=this.method}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.method=e.method}}],[{key:"type",get:function(){return"MathNode"}}]),t}(eh);r7.ALL="all",r7.ANY="any",r7.RADIANS="radians",r7.DEGREES="degrees",r7.EXP="exp",r7.EXP2="exp2",r7.LOG="log",r7.LOG2="log2",r7.SQRT="sqrt",r7.INVERSE_SQRT="inversesqrt",r7.FLOOR="floor",r7.CEIL="ceil",r7.NORMALIZE="normalize",r7.FRACT="fract",r7.SIN="sin",r7.SINH="sinh",r7.COS="cos",r7.COSH="cosh",r7.TAN="tan",r7.TANH="tanh",r7.ASIN="asin",r7.ASINH="asinh",r7.ACOS="acos",r7.ACOSH="acosh",r7.ATAN="atan",r7.ATANH="atanh",r7.ABS="abs",r7.SIGN="sign",r7.LENGTH="length",r7.NEGATE="negate",r7.ONE_MINUS="oneMinus",r7.DFDX="dFdx",r7.DFDY="dFdy",r7.ROUND="round",r7.RECIPROCAL="reciprocal",r7.TRUNC="trunc",r7.FWIDTH="fwidth",r7.TRANSPOSE="transpose",r7.DETERMINANT="determinant",r7.INVERSE="inverse",r7.EQUALS="equals",r7.MIN="min",r7.MAX="max",r7.STEP="step",r7.REFLECT="reflect",r7.DISTANCE="distance",r7.DIFFERENCE="difference",r7.DOT="dot",r7.CROSS="cross",r7.POW="pow",r7.TRANSFORM_DIRECTION="transformDirection",r7.MIX="mix",r7.CLAMP="clamp",r7.REFRACT="refract",r7.SMOOTHSTEP="smoothstep",r7.FACEFORWARD="faceforward";var ne=tF(1e-6),nt=tF(1e6),nr=tF(Math.PI),nn=tF(2*Math.PI),ni=tF(2*Math.PI),na=tF(.5*Math.PI),no=tT(r7,r7.ALL).setParameterLength(1),ns=tT(r7,r7.ANY).setParameterLength(1),nu=tT(r7,r7.RADIANS).setParameterLength(1),nl=tT(r7,r7.DEGREES).setParameterLength(1),nc=tT(r7,r7.EXP).setParameterLength(1),nd=tT(r7,r7.EXP2).setParameterLength(1),nh=tT(r7,r7.LOG).setParameterLength(1),nf=tT(r7,r7.LOG2).setParameterLength(1),np=tT(r7,r7.SQRT).setParameterLength(1),nv=tT(r7,r7.INVERSE_SQRT).setParameterLength(1),ng=tT(r7,r7.FLOOR).setParameterLength(1),nm=tT(r7,r7.CEIL).setParameterLength(1),ny=tT(r7,r7.NORMALIZE).setParameterLength(1),nb=tT(r7,r7.FRACT).setParameterLength(1),nx=tT(r7,r7.SIN).setParameterLength(1),n_=tT(r7,r7.SINH).setParameterLength(1),nT=tT(r7,r7.COS).setParameterLength(1),nS=tT(r7,r7.COSH).setParameterLength(1),nN=tT(r7,r7.TAN).setParameterLength(1),nk=tT(r7,r7.TANH).setParameterLength(1),nw=tT(r7,r7.ASIN).setParameterLength(1),nA=tT(r7,r7.ASINH).setParameterLength(1),nE=tT(r7,r7.ACOS).setParameterLength(1),nR=tT(r7,r7.ACOSH).setParameterLength(1),nC=tT(r7,r7.ATAN).setParameterLength(1,2),nM=tT(r7,r7.ATANH).setParameterLength(1),nF=tT(r7,r7.ABS).setParameterLength(1),nB=tT(r7,r7.SIGN).setParameterLength(1),nP=tT(r7,r7.LENGTH).setParameterLength(1),nL=tT(r7,r7.NEGATE).setParameterLength(1),nD=tT(r7,r7.ONE_MINUS).setParameterLength(1),nU=tT(r7,r7.DFDX).setParameterLength(1),nO=tT(r7,r7.DFDY).setParameterLength(1),nI=tT(r7,r7.ROUND).setParameterLength(1),nV=tT(r7,r7.RECIPROCAL).setParameterLength(1),nG=tT(r7,r7.TRUNC).setParameterLength(1),nz=tT(r7,r7.FWIDTH).setParameterLength(1),nW=tT(r7,r7.TRANSPOSE).setParameterLength(1),nH=tT(r7,r7.DETERMINANT).setParameterLength(1),nq=tT(r7,r7.INVERSE).setParameterLength(1),nj=tT(r7,r7.MIN).setParameterLength(2,1/0),nX=tT(r7,r7.MAX).setParameterLength(2,1/0),nK=tT(r7,r7.STEP).setParameterLength(2),nY=tT(r7,r7.REFLECT).setParameterLength(2),nQ=tT(r7,r7.DISTANCE).setParameterLength(2),nZ=tT(r7,r7.DIFFERENCE).setParameterLength(2),nJ=tT(r7,r7.DOT).setParameterLength(2),n$=tT(r7,r7.CROSS).setParameterLength(2),n0=tT(r7,r7.POW).setParameterLength(2),n1=function(e){return rV(e,e)},n2=function(e){return rV(e,e,e)},n3=function(e){return rV(e,e,e,e)},n4=tT(r7,r7.TRANSFORM_DIRECTION).setParameterLength(2),n5=function(e,t){return ny(rV(t,tH(tV(e),0)).xyz)},n6=function(e,t){return ny(tH(tV(e),0).mul(t).xyz)},n8=function(e){return rV(nB(e),n0(nF(e),1/3))},n9=function(e){return nJ(e,e)},n7=tT(r7,r7.MIX).setParameterLength(3),ie=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r7(r7.CLAMP,tg(e),tg(t),tg(r))},it=function(e){return ie(e)},ir=tT(r7,r7.REFRACT).setParameterLength(3),ii=tT(r7,r7.SMOOTHSTEP).setParameterLength(3),ia=tT(r7,r7.FACEFORWARD).setParameterLength(3),io=tw(function(e){return nb(nx(rz(nJ(E(e,1)[0].xy,tD(12.9898,78.233)),nr)).mul(43758.5453))}),is=function(e,t,r){return n7(t,r,e)},iu=function(e,t,r){return ii(t,r,e)},il=function(e,t){return nK(t,e)};eN("all",no),eN("any",ns),eN("radians",nu),eN("degrees",nl),eN("exp",nc),eN("exp2",nd),eN("log",nh),eN("log2",nf),eN("sqrt",np),eN("inverseSqrt",nv),eN("floor",ng),eN("ceil",nm),eN("normalize",ny),eN("fract",nb),eN("sin",nx),eN("sinh",n_),eN("cos",nT),eN("cosh",nS),eN("tan",nN),eN("tanh",nk),eN("asin",nw),eN("asinh",nA),eN("acos",nE),eN("acosh",nR),eN("atan",nC),eN("atanh",nM),eN("abs",nF),eN("sign",nB),eN("length",nP),eN("lengthSq",n9),eN("negate",nL),eN("oneMinus",nD),eN("dFdx",nU),eN("dFdy",nO),eN("round",nI),eN("reciprocal",nV),eN("trunc",nG),eN("fwidth",nz),eN("min",nj),eN("max",nX),eN("step",il),eN("reflect",nY),eN("distance",nQ),eN("dot",nJ),eN("cross",n$),eN("pow",n0),eN("pow2",n1),eN("pow3",n2),eN("pow4",n3),eN("transformDirection",n4),eN("transformNormalByViewMatrix",n5),eN("transformNormalByInverseViewMatrix",n6),eN("mix",is),eN("clamp",ie),eN("refract",ir),eN("smoothstep",iu),eN("faceForward",ia),eN("difference",nZ),eN("saturate",it),eN("cbrt",n8),eN("transpose",nW),eN("determinant",nH),eN("inverse",nq),eN("rand",io);var ic=tx(function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t)).condNode=e,n.ifNode=r,n.elseNode=i,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){var t=e.getNodeProperties(this),r=t.ifNode,n=t.elseNode;if(void 0===r)return e.flowBuildStage(this,"setup"),this.getNodeType(e);var i=r.getNodeType(e);if(null!==n){var a=n.getNodeType(e);if(e.getTypeLength(a)>e.getTypeLength(i))return a}return i}},{key:"setup",value:function(e){var t=this.condNode,r=this.ifNode.isolate(),n=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==n&&(e.getDataFromNode(n).parentNodeBlock=i);var a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?r:r.context({nodeBlock:r}),o.elseNode=n?a?n:n.context({nodeBlock:n}):null}},{key:"generate",value:function(e,t){var r=this.getNodeType(e),n=e.getDataFromNode(this);if(void 0!==n.nodeProperty)return n.nodeProperty;var i=e.getNodeProperties(this),a=i.condNode,o=i.ifNode,s=i.elseNode,u=e.currentFunctionNode,l="void"!==t,d=l?t0(r).build(e):"";n.nodeProperty=d;var h=a.build(e,"bool");if(e.context.uniformFlow&&null!==s){var f=o.build(e,r),p=s.build(e,r),v=e.getTernary(h,f,p);return e.format(v,r,t)}e.addFlowCode("\n".concat(e.tab,"if ( ").concat(h," ) {\n\n")).addFlowTab();var g=o.build(e,r);if(g&&(l?g=d+" = "+g+";":(g="return "+g+";",null===u&&((0,c.wc)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),g="// "+g))),e.removeFlowTab().addFlowCode(e.tab+" "+g+"\n\n"+e.tab+"}"),null!==s){e.addFlowCode(" else {\n\n").addFlowTab();var m=s.build(e,r);m&&(l?m=d+" = "+m+";":(m="return "+m+";",null===u&&((0,c.wc)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),m="// "+m))),e.removeFlowTab().addFlowCode(e.tab+" "+m+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(d,r,t)}}],[{key:"type",get:function(){return"ConditionalNode"}}]),t}(el)).setParameterLength(2,3);eN("select",ic);var id=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v(this,t),(e=p(this,t)).isContextNode=!0,e.node=r,e.value=n,e}return T(t,e),y(t,[{key:"getScope",value:function(){return this.node.getScope()}},{key:"generateNodeType",value:function(e){return this.node.getNodeType(e)}},{key:"getFlowContextData",value:function(){var e,t=[];return this.traverse(function(e){!0===e.isContextNode&&t.push(e.value)}),(e=Object).assign.apply(e,[{}].concat(R(t)))}},{key:"getMemberType",value:function(e,t){return this.node.getMemberType(e,t)}},{key:"analyze",value:function(e){var t=e.addContext(this.value);this.node.build(e),e.setContext(t)}},{key:"setup",value:function(e){var t=e.addContext(this.value);this.node.build(e),e.setContext(t)}},{key:"generate",value:function(e,t){var r=e.addContext(this.value),n=this.node.build(e,t);return e.setContext(r),n}}],[{key:"type",get:function(){return"ContextNode"}}]),t}(el),ih=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e;return(null===r||!0!==r.isNode)&&(t=r||t,r=null),new id(r,t)},ip=function(e){return ih(e,{uniformFlow:!0})},iv=function(e,t){return ih(e,{nodeName:t})};function ig(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return ih(r,{getShadow:function(r){var n=r.light,i=r.shadowColorNode;return t===n?i.mul(e):i}})}function im(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return ih(t,{getAO:function(t,r){return!0===r.material.transparent?t:null!==t?t.mul(e):e}})}function iy(e,t){return(0,c.wc)('TSL: "label()" has been deprecated. Use "setName()" instead.'),iv(e,t)}eN("context",ih),eN("label",iy),eN("uniformFlow",ip),eN("setName",iv),eN("builtinShadowContext",function(e,t,r){return ig(t,r,e)}),eN("builtinAOContext",function(e,t){return im(t,e)});var ib=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return v(this,t),(r=p(this,t)).node=e,r.name=n,r.global=!0,r.isVarNode=!0,r.readOnly=i,r.parents=!0,r.intent=!1,r}return T(t,e),y(t,[{key:"setIntent",value:function(e){return this.intent=e,this}},{key:"isIntent",value:function(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}},{key:"getIntent",value:function(){return this.intent}},{key:"getMemberType",value:function(e,t){return this.node.getMemberType(e,t)}},{key:"getElementType",value:function(e){return this.node.getElementType(e)}},{key:"generateNodeType",value:function(e){return this.node.getNodeType(e)}},{key:"getArrayCount",value:function(e){return this.node.getArrayCount(e)}},{key:"isAssign",value:function(e){return e.getDataFromNode(this).assign}},{key:"build",value:function(){for(var e,r,n=arguments.length,i=Array(n),a=0;a<n;a++)i[a]=arguments[a];var o=i[0],s=this.getShared(o);if(this!==s)return s.build.apply(s,R(i));if(!1===this._hasStack(o)&&"setup"===o.buildStage&&(o.context.nodeLoop||o.context.nodeBlock)){var u=!1;this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&o.fnCall&&o.fnCall.shaderNode&&o.getDataFromNode(this.node.shaderNode).hasLoop&&(o.getDataFromNode(this).forceDeclaration=!0,u=!0);var l=o.getBaseStack();u?l.addToStackBefore(this):l.addToStack(this)}return this.isIntent(o)&&!0!==this.isAssign(o)?(e=this.node).build.apply(e,R(i)):(r=x(_(t.prototype),"build",this)).call.apply(r,[this].concat(R(i)))}},{key:"generate",value:function(e){var t=this.node,r=this.name,n=this.readOnly,i=!0===e.renderer.backend.isWebGPUBackend,a=!1,o=!1;n&&(a=e.isDeterministic(t),o=i?n:a);var s=this.getNodeType(e);if("void"==s)return!0!==this.isIntent(e)&&(0,c.xc)('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);var u=e.getVectorType(s),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),h=e.getPropertyName(d),f=h;if(o)if(i)f=a?"const ".concat(h):"let ".concat(h);else{var p=t.getArrayCount(e);f="const ".concat(e.getVar(d.type,h,p))}return e.addLineFlowCode("".concat(f," = ").concat(l),this),h}},{key:"_hasStack",value:function(e){return void 0!==e.getDataFromNode(this).stack}}],[{key:"type",get:function(){return"VarNode"}}]),t}(el),ix=tx(ib),i_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return ix(e,t).toStack()},iT=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return ix(e,t,!0).toStack()},iS=function(e){return ix(e).setIntent(!0).toStack()};eN("toVar",i_),eN("toConst",iT),eN("toVarIntent",iS);var iN=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[i])).node=e,n.name=r,n.isSubBuildNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);var t=this.node.getNodeType(e);return e.removeSubBuild(),t}},{key:"build",value:function(e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];e.addSubBuild(this.name);var a=(t=this.node).build.apply(t,[e].concat(R(n)));return e.removeSubBuild(),a}}],[{key:"type",get:function(){return"SubBuild"}}]),t}(el),ik=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new iN(tg(e),t,r)},iw=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t)).node=ik(e,"VERTEX"),r.name=n,r.isVaryingNode=!0,r.interpolationType=null,r.interpolationSampling=null,r.global=!0,r}return T(t,e),y(t,[{key:"setInterpolation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.interpolationType=e,this.interpolationSampling=t,this}},{key:"getHash",value:function(e){return this.name||x(_(t.prototype),"getHash",this).call(this,e)}},{key:"generateNodeType",value:function(e){return this.node.getNodeType(e)}},{key:"setupVarying",value:function(e){var t=e.getNodeProperties(this),r=t.varying;if(void 0===r){var n=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,n,i,a,o),t.node=ik(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}},{key:"setup",value:function(e){this.setupVarying(e),e.flowNodeFromShaderStage(ee.VERTEX,this.node)}},{key:"analyze",value:function(e){this.setupVarying(e),e.flowNodeFromShaderStage(ee.VERTEX,this.node)}},{key:"generate",value:function(e){var t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),n=this.setupVarying(e);if(void 0===r[t]){var i=this.getNodeType(e),a=e.getPropertyName(n,ee.VERTEX);if(e.shaderStage===ee.VERTEX){var o=r.node.build(e,i);e.addLineFlowCode("".concat(a," = ").concat(o),this)}else e.flowNodeFromShaderStage(ee.VERTEX,r.node,i,a);r[t]=a}return e.getPropertyName(n)}}],[{key:"type",get:function(){return"VaryingNode"}}]),t}(el)).setParameterLength(1,2),iA=function(e){return iw(e)};eN("toVarying",iw),eN("toVertexStage",iA);var iE=tw(function(e){var t=E(e,1)[0];return n7(t.mul(.9478672986).add(.0521327014).pow(2.4),t.mul(.0773993808),t.lessThanEqual(.04045))}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iR=tw(function(e){var t=E(e,1)[0];return n7(t.pow(.41666).mul(1.055).sub(.055),t.mul(12.92),t.lessThanEqual(.0031308))}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iC="WorkingColorSpace",iM=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t,["vec4"])).colorNode=e,i.source=r,i.target=n,i}return T(t,e),y(t,[{key:"resolveColorSpace",value:function(e,t){return t===iC?c.Hc.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}},{key:"setup",value:function(e){var t=this.colorNode,r=this.resolveColorSpace(e,this.source),n=this.resolveColorSpace(e,this.target),i=t;return!1!==c.Hc.enabled&&r!==n&&r&&n&&(c.Hc.getTransfer(r)===c.Lb&&(i=tH(iE(i.rgb),i.a)),c.Hc.getPrimaries(r)!==c.Hc.getPrimaries(n)&&(i=tH(tY(c.Hc._getMatrix(new c.Gc,r,n)).mul(i.rgb),i.a)),c.Hc.getTransfer(n)===c.Lb&&(i=tH(iR(i.rgb),i.a))),i}}],[{key:"type",get:function(){return"ColorSpaceNode"}}]),t}(eh),iF=function(e,t){return new iM(tg(e),iC,t)},iB=function(e,t){return new iM(tg(e),t,iC)};eN("workingToColorSpace",iF),eN("colorSpaceToWorking",iB);var iP=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).referenceNode=e,n.isReferenceElementNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return this.referenceNode.uniformType}},{key:"generate",value:function(e){var r=x(_(t.prototype),"generate",this).call(this,e),n=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(r,n,i)}}],[{key:"type",get:function(){return"ReferenceElementNode"}}]),t}(ec),iL=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(n=p(this,t)).property=e,n.uniformType=r,n.object=i,n.count=a,n.properties=e.split("."),n.reference=i,n.node=null,n.group=null,n.updateType=et.OBJECT,n}return T(t,e),y(t,[{key:"setGroup",value:function(e){return this.group=e,this}},{key:"element",value:function(e){return new iP(this,tg(e))}},{key:"setNodeType",value:function(e){var t=rC(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}},{key:"generateNodeType",value:function(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}},{key:"getValueFromReference",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.reference,t=this.properties,r=e[t[0]],n=1;n<t.length;n++)r=r[t[n]];return r}},{key:"updateReference",value:function(e){return this.reference=null!==this.object?this.object:e.object,this.reference}},{key:"setup",value:function(){return this.updateValue(),this.node}},{key:"update",value:function(){this.updateValue()}},{key:"updateValue",value:function(){null===this.node&&this.setNodeType(this.uniformType);var e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}],[{key:"type",get:function(){return"ReferenceBaseNode"}}]),t}(el),iD=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e,r,i])).renderer=i,n.setGroup(rA),n}return T(t,e),y(t,[{key:"updateReference",value:function(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}],[{key:"type",get:function(){return"RendererReferenceNode"}}]),t}(iL),iU=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new iD(e,t,r)},iO=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:iV,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(r=p(this,t,["vec3"]))._toneMapping=e,r.exposureNode=n,r.colorNode=i,r}return T(t,e),y(t,[{key:"customCacheKey",value:function(){return j(this._toneMapping)}},{key:"setToneMapping",value:function(e){return this._toneMapping=e,this}},{key:"getToneMapping",value:function(){return this._toneMapping}},{key:"setup",value:function(e){var t=this.colorNode||e.context.color,r=this._toneMapping;if(r===c.Y)return t;var n=null,i=e.renderer.library.getToneMappingFunction(r);return null!==i?n=tH(i(t.rgb,this.exposureNode),t.a):((0,c.xc)("ToneMappingNode: Unsupported Tone Mapping configuration.",r),n=t),n}}],[{key:"type",get:function(){return"ToneMappingNode"}}]),t}(eh),iI=function(e,t,r){return new iO(e,tg(t),tg(r))},iV=iU("toneMappingExposure","float");eN("toneMapping",function(e,t,r){return iI(t,r,e)});var iG=new WeakMap;function iz(e,t){var r=iG.get(e);return void 0===r&&(r=new c.ed(e,t),iG.set(e,r)),r}var iW=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return v(this,t),(r=p(this,t,[e,n])).isBufferNode=!0,r.bufferType=n,r.bufferStride=i,r.bufferOffset=a,r.usage=c.lc,r.instanced=!1,r.attribute=null,r.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(r.attribute=e,r.usage=e.usage,r.instanced=e.isInstancedBufferAttribute),r}return T(t,e),y(t,[{key:"getHash",value:function(e){var t;if(0===this.bufferStride&&0===this.bufferOffset){var r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}},{key:"generateNodeType",value:function(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}},{key:"setup",value:function(e){if(null===this.attribute){var t,r=this.getNodeType(e),n=e.getTypeLength(r),i=this.value,a=this.bufferStride||n,o=this.bufferOffset;t=!0===i.isInterleavedBuffer?i:!0===i.isBufferAttribute?iz(i.array,a):iz(i,a);var s=new c.fd(t,n,o);t.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}}},{key:"generate",value:function(e){var t,r=this.getNodeType(e),n=e.context.nodeName;void 0!==n&&delete e.context.nodeName;var i=e.getBufferAttributeFromNode(this,r,n),a=e.getPropertyName(i),o=null;return"vertex"===e.shaderStage||"compute"===e.shaderStage?(this.name=a,o=a):(n&&(t=n+"Varying"),o=iw(this,t).build(e,r)),o}},{key:"getInputType",value:function(){return"bufferAttribute"}},{key:"setUsage",value:function(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}},{key:"setInstanced",value:function(e){return this.instanced=e,this}}],[{key:"type",get:function(){return"BufferAttributeNode"}}]),t}(ey);function iH(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:c.lc,a=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return"mat3"===t||null===t&&9===e.itemSize?tY(new iW(e,"vec3",9,0).setUsage(i).setInstanced(a),new iW(e,"vec3",9,3).setUsage(i).setInstanced(a),new iW(e,"vec3",9,6).setUsage(i).setInstanced(a)):"mat4"===t||null===t&&16===e.itemSize?tQ(new iW(e,"vec4",16,0).setUsage(i).setInstanced(a),new iW(e,"vec4",16,4).setUsage(i).setInstanced(a),new iW(e,"vec4",16,8).setUsage(i).setInstanced(a),new iW(e,"vec4",16,12).setUsage(i).setInstanced(a)):new iW(e,t,r,n).setUsage(i)}var iq=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return iH(e,t,r,n)},ij=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return iH(e,t,r,n,c.lc,!0)},iX=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return iH(e,t,r,n,c.mc,!0)};eN("toAttribute",function(e){return iq(e.value)});var iK=function(e){function t(e){var r;return v(this,t),(r=p(this,t,["uint"])).scope=e,r.isIndexNode=!0,r}return T(t,e),y(t,[{key:"generate",value:function(e){var t,r=this.getNodeType(e),n=this.scope;if(n===iK.VERTEX)t=e.getVertexIndex();else if(n===iK.INSTANCE)t=e.getInstanceIndex();else if(n===iK.DRAW)t=e.getDrawIndex();else if(n===iK.INVOCATION_LOCAL)t=e.getInvocationLocalIndex();else if(n===iK.INVOCATION_SUBGROUP)t=e.getInvocationSubgroupIndex();else{if(n!==iK.SUBGROUP)throw Error("THREE.IndexNode: Unknown scope: "+n);t=e.getSubgroupIndex()}return"vertex"===e.shaderStage||"compute"===e.shaderStage?t:iw(this).build(e,r)}}],[{key:"type",get:function(){return"IndexNode"}}]),t}(el);iK.VERTEX="vertex",iK.INSTANCE="instance",iK.SUBGROUP="subgroup",iK.INVOCATION_LOCAL="invocationLocal",iK.INVOCATION_SUBGROUP="invocationSubgroup",iK.DRAW="draw";var iY=t_(iK,iK.VERTEX),iQ=t_(iK,iK.INSTANCE),iZ=t_(iK,iK.SUBGROUP),iJ=t_(iK,iK.INVOCATION_SUBGROUP),i$=t_(iK,iK.INVOCATION_LOCAL),i0=t_(iK,iK.DRAW),i1=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,["void"])).isComputeNode=!0,n.computeNode=e,n.workgroupSize=r,n.count=null,n.dispatchSize=null,n.version=1,n.name="",n.updateBeforeType=et.OBJECT,n.onInitFunction=null,n.countNode=null,n}return T(t,e),y(t,[{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}},{key:"setName",value:function(e){return this.name=e,this}},{key:"label",value:function(e){return(0,c.wc)('TSL: "label()" has been deprecated. Use "setName()" instead.',new z),this.setName(e)}},{key:"onInit",value:function(e){return this.onInitFunction=e,this}},{key:"updateBefore",value:function(e){e.renderer.compute(this)}},{key:"setup",value:function(e){var t=this;null!==this.count&&null===this.countNode&&(this.countNode=rC(this.count,"uint").onObjectUpdate(function(){return t.count}));var r=this.computeNode.build(e);return r&&(e.getNodeProperties(this).outputComputeNode=r.outputNode,r.outputNode=null),r}},{key:"generate",value:function(e,t){if("compute"===e.shaderStage){var r=this.computeNode.build(e,"void");if(""!==r&&e.addLineFlowCode(r,this),null!==this.count&&!0===e.allowEarlyReturns){var n=this.countNode.build(e,"uint"),i=iQ.build(e,"uint");e.flow.code="".concat(e.tab,"if ( ").concat(i," >= ").concat(n," ) { return; }\n\n").concat(e.flow.code)}}else{var a=e.getNodeProperties(this).outputComputeNode;if(a)return a.build(e,t)}}}],[{key:"type",get:function(){return"ComputeNode"}}]),t}(el),i2=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[64];(0===t.length||t.length>3)&&(0,c.xc)("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new z);for(var r=0;r<t.length;r++){var n=t[r];("number"!=typeof n||n<=0||!Number.isInteger(n))&&(0,c.xc)("TSL: compute() workgroupSize element at index [ ".concat(r," ] must be a positive integer"),new z)}for(;t.length<3;)t.push(1);return new i1(tg(e),t)},i3=function(e,t,r){var n=i2(e,r);return"number"==typeof t?n.count=t:n.dispatchSize=t,n};eN("compute",i3),eN("computeKernel",i2);var i4=function(e){function t(e){var r,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return v(this,t),(r=p(this,t)).node=e,r.parent=n,r.isIsolateNode=!0,r}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){var t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);var n=this.node.getNodeType(e);return e.setCache(t),n}},{key:"build",value:function(e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=e.getCache(),o=e.getCacheFromNode(this,this.parent);e.setCache(o);var s=(t=this.node).build.apply(t,[e].concat(R(n)));return e.setCache(a),s}},{key:"setParent",value:function(e){return this.parent=e,this}},{key:"getParent",value:function(){return this.parent}}],[{key:"type",get:function(){return"IsolateNode"}}]),t}(el),i5=function(e){return new i4(tg(e))};function i6(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return(0,c.wc)('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),i5(e).setParent(t)}eN("cache",i6),eN("isolate",i5);var i8=tx(function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).isBypassNode=!0,n.outputNode=e,n.callNode=r,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.outputNode.getNodeType(e)}},{key:"generate",value:function(e){var t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}],[{key:"type",get:function(){return"BypassNode"}}]),t}(el)).setParameterLength(2);eN("bypass",i8);var i9=tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=t[2],a=t[3],o=void 0===a?tF(0):a,s=t[4],u=void 0===s?tF(1):s,l=t[5],c=void 0===l?tL(!1):l,d=r.sub(n).div(i.sub(n));return tf(c)&&(d=d.clamp()),d.mul(u.sub(o)).add(o)});function i7(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tF(0),i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:tF(1);return i9(e,t,r,n,i,!0)}eN("remap",i9),eN("remapClamp",i7);var ae=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"void";return v(this,t),(e=p(this,t,[n])).snippet=r,e}return T(t,e),y(t,[{key:"generate",value:function(e,t){var r=this.getNodeType(e),n=this.snippet;if("void"!==r)return e.format(n,r,t);e.addLineFlowCode(n,this)}}],[{key:"type",get:function(){return"ExpressionNode"}}]),t}(el),at=tx(ae).setParameterLength(1,2),ar=function(e){return(e?ic(e,at("discard")):at("discard")).toStack()};eN("discard",ar);var an=tw(function(e){var t=E(e,1)[0];return tH(t.rgb.mul(t.a),t.a)},{color:"vec4",return:"vec4"}),ai=tw(function(e){var t=E(e,1)[0];return t.a.equal(0).select(tH(0),tH(t.rgb.div(t.a),t.a))},{color:"vec4",return:"vec4"}),aa=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t,["vec4"])).colorNode=e,i._toneMapping=r,i.outputColorSpace=n,i.isRenderOutputNode=!0,i}return T(t,e),y(t,[{key:"setToneMapping",value:function(e){return this._toneMapping=e,this}},{key:"getToneMapping",value:function(){return this._toneMapping}},{key:"setup",value:function(e){var t=e.context,r=this.colorNode||t.color;r=ai(r=tH(r.rgb,r.a.clamp(0,1)));var n=(null!==this._toneMapping?this._toneMapping:t.toneMapping)||c.Y,i=(null!==this.outputColorSpace?this.outputColorSpace:t.outputColorSpace)||c.Hb;return n!==c.Y&&(r=r.toneMapping(n)),i!==c.Hb&&i!==c.Hc.workingColorSpace&&(r=r.workingToColorSpace(i)),r=an(r)}}],[{key:"type",get:function(){return"RenderOutputNode"}}]),t}(eh),ao=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new aa(tg(e),t,r)};eN("renderOutput",ao);var as=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t)).node=e,r.callback=n,r}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.node.getNodeType(e)}},{key:"setup",value:function(e){return this.node.build(e)}},{key:"analyze",value:function(e){return this.node.build(e)}},{key:"generate",value:function(e){var t=this.callback,r=this.node.build(e);if(null!==t)t(e,r);else{var n="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(n.length),a="";a+="// #"+n+"#\n"+e.flow.code.replace(/^\t/gm,"")+"\n"+("/* ... */ "+r)+" /* ... */\n"+("// #"+i)+"#\n",(0,c.vc)(a)}return r}}],[{key:"type",get:function(){return"DebugNode"}}]),t}(eh),au=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new as(tg(e),t).toStack()};eN("debug",au);var al=function(e){function t(){var e;return v(this,t),(e=p(this,t))._renderer=null,e.currentFrame=null,e}return T(t,e),y(t,[{key:"nodeFrame",get:function(){return this._renderer._nodes.nodeFrame}},{key:"setRenderer",value:function(e){return this._renderer=e,this}},{key:"getRenderer",value:function(){return this._renderer}},{key:"init",value:function(){}},{key:"begin",value:function(){}},{key:"finish",value:function(){}},{key:"inspect",value:function(){}},{key:"computeAsync",value:function(){}},{key:"beginCompute",value:function(){}},{key:"finishCompute",value:function(){}},{key:"beginRender",value:function(){}},{key:"finishRender",value:function(){}},{key:"copyTextureToTexture",value:function(){}},{key:"copyFramebufferToTexture",value:function(){}}]),t}(c.Bc),ac=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(r=p(this,t)).node=e,r.name=n,r.callback=i,r.updateType=et.FRAME,r.isInspectorNode=!0,r}return T(t,e),y(t,[{key:"getName",value:function(){return this.name||this.node.name}},{key:"update",value:function(e){e.renderer.inspector.inspect(this)}},{key:"generateNodeType",value:function(e){return this.node.getNodeType(e)}},{key:"setup",value:function(e){var t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==al&&(0,c.yc)('TSL: ".toInspector()" is only available with WebGPU.'),t}}],[{key:"type",get:function(){return"InspectorNode"}}]),t}(el);function ad(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(e=tg(e)).before(new ac(e,t,r))}eN("toInspector",ad);var ah,af,ap=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[n])).global=!0,r._attributeName=e,r}return T(t,e),y(t,[{key:"getHash",value:function(e){return this.getAttributeName(e)}},{key:"generateNodeType",value:function(e){var t=this.nodeType;if(null===t){var r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){var n=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(n)}else t="float"}return t}},{key:"setAttributeName",value:function(e){return this._attributeName=e,this}},{key:"getAttributeName",value:function(){return this._attributeName}},{key:"generate",value:function(e){var t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){var n=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(n),a=e.getAttribute(t,i);return"vertex"===e.shaderStage?e.format(a.name,i,r):iw(this).build(e,r)}return(0,c.wc)('AttributeNode: Vertex attribute "'.concat(t,'" not found on geometry.')),e.generateConst(r)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.global=this.global,e._attributeName=this._attributeName}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.global=e.global,this._attributeName=e._attributeName}}],[{key:"type",get:function(){return"AttributeNode"}}]),t}(el),av=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new ap(e,t)},ag=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return av("uv"+(e>0?e:""),"vec2")},am=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,["uvec2"])).isTextureSizeNode=!0,r.textureNode=e,r.levelNode=n,r}return T(t,e),y(t,[{key:"generate",value:function(e,t){var r=this.textureNode.build(e,"property"),n=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format("".concat(e.getMethod("textureDimensions"),"( ").concat(r,", ").concat(n," )"),this.getNodeType(e),t)}}],[{key:"type",get:function(){return"TextureSizeNode"}}]),t}(el)).setParameterLength(1,2),ay=tx(function(e){function t(e){var r;return v(this,t),(r=p(this,t,[0]))._textureNode=e,r.updateType=et.FRAME,r}return T(t,e),y(t,[{key:"textureNode",get:function(){return this._textureNode}},{key:"texture",get:function(){return this._textureNode.value}},{key:"update",value:function(){var e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){var n=r.width,i=r.height;this.value=Math.log2(Math.max(n,i))}}}],[{key:"type",get:function(){return"MaxMipLevelNode"}}]),t}(rR)).setParameterLength(1),ab=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e])).name="NodeError",r.stackTrace=n,r}return T(t,e),t}(F(Error)),ax=new c.Ic,a_=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ax,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(e=p(this,t,[r])).isTextureNode=!0,e.uvNode=n,e.levelNode=i,e.biasNode=a,e.compareNode=null,e.depthNode=null,e.gradNode=null,e.gatherNode=null,e.offsetNode=null,e.sampler=!0,e.updateMatrix=!1,e.updateType=et.NONE,e.referenceNode=null,e._value=r,e._matrixUniform=null,e._flipYUniform=null,e.setUpdateMatrix(null===n),e}return T(t,e),y(t,[{key:"value",get:function(){return this.referenceNode?this.referenceNode.value:this._value},set:function(e){this.referenceNode?this.referenceNode.value=e:this._value=e}},{key:"getUniformHash",value:function(){return this.value.uuid}},{key:"generateNodeType",value:function(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===c.za?"uvec4":this.value.type===c.ya?"ivec4":"vec4"}},{key:"getInputType",value:function(){return"texture"}},{key:"getDefaultUV",value:function(){return ag(this.value.channel)}},{key:"updateReference",value:function(){return this.value}},{key:"getTransformedUV",value:function(e){return null===this._matrixUniform&&(this._matrixUniform=rC(this.value.matrix)),this._matrixUniform.mul(tV(e,1)).xy}},{key:"setUpdateMatrix",value:function(e){return this.updateMatrix=e,this}},{key:"setupUV",value:function(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=rC(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(tB(am(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}},{key:"setup",value:function(e){var t=this,r=e.getNodeProperties(this);r.referenceNode=this.referenceNode;var n=this.value;if(!n||!0!==n.isTexture)throw new ab("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);var i=tw(function(){var r=t.uvNode;return(null===r||!0===e.context.forceUVContext)&&e.context.getUV&&(r=e.context.getUV(t,e)),r||(r=t.getDefaultUV()),!0===t.updateMatrix&&(r=t.getTransformedUV(r)),r=t.setupUV(e,r),t.updateType=null!==t._matrixUniform||null!==t._flipYUniform?et.OBJECT:et.NONE,r})(),a=this.levelNode;null===a&&e.context.getTextureLevel&&(a=e.context.getTextureLevel(this));var o=null,s=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(c.rc.TEXTURE_COMPARE))o=this.compareNode;else{var u=n.compareFunction;null===u||u===c.ec||u===c.gc||u===c.hc||u===c.jc?s=this.compareNode:(o=this.compareNode,(0,c.yc)('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}r.uvNode=i,r.levelNode=a,r.biasNode=this.biasNode,r.compareNode=o,r.compareStepNode=s,r.gradNode=this.gradNode,r.gatherNode=this.gatherNode,r.depthNode=this.depthNode,r.offsetNode=this.offsetNode}},{key:"generateUV",value:function(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}},{key:"generateOffset",value:function(e,t){return t.build(e,"ivec2")}},{key:"generateSnippet",value:function(e,t,r,n,i,a,o,s,u,l,c){var d=this.value;return i?e.generateTextureBias(d,t,r,i,a,l):s?e.generateTextureGrad(d,t,r,s,a,l):u?o?e.generateTextureGatherCompare(d,t,r,o,a,l,c):e.generateTextureGather(d,t,r,u,a,l,c):o?e.generateTextureCompare(d,t,r,o,a,l):!1===this.sampler?e.generateTextureLoad(d,t,r,n,a,l):n?e.generateTextureLevel(d,t,r,n,a,l):e.generateTexture(d,t,r,a,l)}},{key:"generate",value:function(e,r){var n=this.value,i=e.getNodeProperties(this),a=x(_(t.prototype),"generate",this).call(this,e,"property");if(/^sampler/.test(r))return a+"_sampler";if(e.isReference(r))return a;var o=e.getDataFromNode(this),s=this.getNodeType(e),u=o.propertyName;if(void 0===u){var l=i.uvNode,d=i.levelNode,h=i.biasNode,f=i.compareNode,p=i.compareStepNode,v=i.depthNode,g=i.gradNode,m=i.gatherNode,y=i.offsetNode,b=this.generateUV(e,l),T=d?d.build(e,"float"):null,S=h?h.build(e,"float"):null,N=v?v.build(e,"int"):null,k=f?f.build(e,"float"):null,w=p?p.build(e,"float"):null,A=g?[g[0].build(e,"vec2"),g[1].build(e,"vec2")]:null,E=m?m.build(e,"int"):null,R=y?this.generateOffset(e,y):null,C=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;E&&(s="vec4");var M=N;null===M&&n.isArrayTexture&&!0!==this.isTexture3DNode&&(M="0");var F=e.getVarFromNode(this);u=e.getPropertyName(F);var B=this.generateSnippet(e,a,b,T,S,M,k,A,E,R,C);if(null!==w){var P=n.compareFunction;B=P===c.hc||P===c.jc?nK(at(B,s),at(w,"float")).build(e,s):nK(at(w,"float"),at(B,s)).build(e,s)}e.addLineFlowCode("".concat(u," = ").concat(B),this),o.snippet=B,o.propertyName=u}var L=u;return e.needsToWorkingColorSpace(n)&&(L=iB(at(L,s),n.colorSpace).setup(e).build(e,s)),e.format(L,s,r)}},{key:"setSampler",value:function(e){return this.sampler=e,this}},{key:"getSampler",value:function(){return this.sampler}},{key:"sample",value:function(e){var t=this.clone();return t.uvNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"load",value:function(e){return this.sample(e).setSampler(!1)}},{key:"blur",value:function(e){var t=this.clone();t.biasNode=tg(e).mul(ay(t)),t.referenceNode=this.getBase();var r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===c.na||r.magFilter===c.na)&&((0,c.wc)("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),tg(t)}},{key:"level",value:function(e){var t=this.clone();return t.levelNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"size",value:function(e){return am(this,e)}},{key:"bias",value:function(e){var t=this.clone();return t.biasNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"getBase",value:function(){return this.referenceNode?this.referenceNode.getBase():this}},{key:"compare",value:function(e){var t=this.clone();return t.compareNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"grad",value:function(e,t){var r=this.clone();return r.gradNode=[tg(e),tg(t)],r.referenceNode=this.getBase(),tg(r)}},{key:"gather",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.clone();return t.gatherNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"depth",value:function(e){var t=this.clone();return t.depthNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"offset",value:function(e){var t=this.clone();return t.offsetNode=tg(e),t.referenceNode=this.getBase(),tg(t)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}},{key:"update",value:function(){var e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();var r=this._flipYUniform;null!==r&&(r.value=S(e.image,ImageBitmap)&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}},{key:"clone",value:function(){var e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}],[{key:"type",get:function(){return"TextureNode"}}]),t}(rR),aT=tx(a_).setParameterLength(1,4).setName("texture"),aS=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ax,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return t&&!0===t.isTextureNode?((e=tg(t.clone())).referenceNode=t.getBase(),null!==r&&(e.uvNode=tg(r)),null!==n&&(e.levelNode=tg(n)),null!==i&&(e.biasNode=tg(i))):e=aT(t,r,n,i),e},aN=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return aS.apply(void 0,R(t)).setSampler(!1)},ak=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return v(this,t),(n=p(this,t,[e,r])).isBufferNode=!0,n.bufferType=r,n.bufferCount=i,n.updateRanges=[],n}return T(t,e),y(t,[{key:"addUpdateRange",value:function(e,t){this.updateRanges.push({start:e,count:t})}},{key:"clearUpdateRanges",value:function(){this.updateRanges.length=0}},{key:"getElementType",value:function(e){return this.getNodeType(e)}},{key:"getInputType",value:function(){return"buffer"}}],[{key:"type",get:function(){return"BufferNode"}}]),t}(rR),aw=function(e,t,r){return new ak(e,t,r)},aA=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).isArrayBufferElementNode=!0,n}return T(t,e),y(t,[{key:"generate",value:function(e){var r=x(_(t.prototype),"generate",this).call(this,e),n=this.getNodeType(e),i=this.node.getPaddedType();return e.format(r,i,n)}}],[{key:"type",get:function(){return"UniformArrayElementNode"}}]),t}(ec),aE=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[null])).array=e,r.elementType=null===n?Z(e[0]):n,r.paddedType=r.getPaddedType(),r.updateType=et.RENDER,r.isArrayBufferNode=!0,r}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return this.paddedType}},{key:"getElementType",value:function(){return this.elementType}},{key:"getPaddedType",value:function(){var e=this.elementType,t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}},{key:"update",value:function(){var e=this.array,t=this.value,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(var n=0;n<e.length;n++)t[4*n]=e[n];else if("color"===r)for(var i=0;i<e.length;i++){var a=4*i,o=e[i];t[a]=o.r,t[a+1]=o.g,t[a+2]=o.b||0}else if("mat2"===r)for(var s=0;s<e.length;s++){var u=4*s,l=e[s];t[u]=l.elements[0],t[u+1]=l.elements[1],t[u+2]=l.elements[2],t[u+3]=l.elements[3]}else if("mat3"===r)for(var c=0;c<e.length;c++){var d=16*c,h=e[c];t[d]=h.elements[0],t[d+1]=h.elements[1],t[d+2]=h.elements[2],t[d+4]=h.elements[3],t[d+5]=h.elements[4],t[d+6]=h.elements[5],t[d+8]=h.elements[6],t[d+9]=h.elements[7],t[d+10]=h.elements[8],t[d+15]=1}else if("mat4"===r)for(var f=0;f<e.length;f++)for(var p=16*f,v=e[f],g=0;g<v.elements.length;g++)t[p+g]=v.elements[g];else for(var m=0;m<e.length;m++){var y=4*m,b=e[m];t[y]=b.x,t[y+1]=b.y,t[y+2]=b.z||0,t[y+3]=b.w||0}}},{key:"setup",value:function(e){var r=this.array.length,n=this.elementType,i=Float32Array,a=this.paddedType,o=e.getTypeLength(a);return"i"===n.charAt(0)&&(i=Int32Array),"u"===n.charAt(0)&&(i=Uint32Array),this.value=new i(r*o),this.bufferCount=r,this.bufferType=a,this.update(),x(_(t.prototype),"setup",this).call(this,e)}},{key:"element",value:function(e){return new aA(this,tg(e))}}],[{key:"type",get:function(){return"UniformArrayNode"}}]),t}(ak),aR=function(e,t){return new aE(e,t)},aC=tx(function(e){function t(e){var r;return v(this,t),(r=p(this,t,["float"])).name=e,r.isBuiltinNode=!0,r}return T(t,e),y(t,[{key:"generate",value:function(){return this.name}}]),t}(el)).setParameterLength(1),aM=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).scope=e,r._output=null,r.isViewportNode=!0,r}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return this.scope===aM.DPR?"float":this.scope===aM.VIEWPORT?"vec4":"vec2"}},{key:"getUpdateType",value:function(){var e=et.NONE;return(this.scope===aM.SIZE||this.scope===aM.VIEWPORT||this.scope===aM.DPR)&&(e=et.RENDER),this.updateType=e,e}},{key:"update",value:function(e){var t=e.renderer,r=t.getRenderTarget();this.scope===aM.VIEWPORT?null!==r?af.copy(r.viewport):(t.getViewport(af),af.multiplyScalar(t.getPixelRatio())):this.scope===aM.DPR?this._output.value=t.getPixelRatio():null!==r?(ah.width=r.width,ah.height=r.height):t.getDrawingBufferSize(ah)}},{key:"setup",value:function(){var e=this.scope,t=null;return t=e===aM.SIZE?rC(ah||(ah=new c.Dc)):e===aM.VIEWPORT?rC(af||(af=new c.Jc)):e===aM.DPR?null!==this._output?this._output:rC(1):tD(aL.div(aP)),this._output=t,t}},{key:"generate",value:function(e){if(this.scope===aM.COORDINATE){var r=e.getFragCoord();if(e.isFlipY()){var n=e.getNodeProperties(aP).outputNode.build(e);r="".concat(e.getType("vec2"),"( ").concat(r,".x, ").concat(n,".y - ").concat(r,".y )")}return r}return x(_(t.prototype),"generate",this).call(this,e)}}],[{key:"type",get:function(){return"ScreenNode"}}]),t}(el);aM.COORDINATE="coordinate",aM.VIEWPORT="viewport",aM.SIZE="size",aM.UV="uv",aM.DPR="dpr";var aF=t_(aM,aM.DPR),aB=t_(aM,aM.UV),aP=t_(aM,aM.SIZE),aL=t_(aM,aM.COORDINATE),aD=t_(aM,aM.VIEWPORT),aU=aD.zw,aO=aL.sub(aD.xy),aI=aO.div(aU),aV=tw(function(){return(0,c.wc)('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new z),aP},"vec2").once()(),aG=null,az=null,aW=null,aH=null,aq=null,aj=null,aX=null,aK=null,aY=null,aQ=null,aZ=null,aJ=null,a$=null,a0=null,a1=rC(0,"uint").setName("u_cameraIndex").setGroup(rk("cameraIndex")).toVarying("v_cameraIndex"),a2=rC("float").setName("cameraNear").setGroup(rA).onRenderUpdate(function(e){return e.camera.near}),a3=rC("float").setName("cameraFar").setGroup(rA).onRenderUpdate(function(e){return e.camera.far}),a4=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.projectionMatrix)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===az?az=aR(r).setGroup(rA).setName("cameraProjectionMatrices"):az.array=r,o=az.element(t.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aG&&(aG=rC(t.projectionMatrix).setName("cameraProjectionMatrix").setGroup(rA).onRenderUpdate(function(e){return e.camera.projectionMatrix})),o=aG;return o}).once()(),a5=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.projectionMatrixInverse)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===aH?aH=aR(r).setGroup(rA).setName("cameraProjectionMatricesInverse"):aH.array=r,o=aH.element(t.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aW&&(aW=rC(t.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(rA).onRenderUpdate(function(e){return e.camera.projectionMatrixInverse})),o=aW;return o}).once()(),a6=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.matrixWorldInverse)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===aj?aj=aR(r).setGroup(rA).setName("cameraViewMatrices"):aj.array=r,o=aj.element(t.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aq&&(aq=rC(t.matrixWorldInverse).setName("cameraViewMatrix").setGroup(rA).onRenderUpdate(function(e){return e.camera.matrixWorldInverse})),o=aq;return o}).once()(),a8=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.matrixWorld)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===aK?aK=aR(r).setGroup(rA).setName("cameraWorldMatrices"):aK.array=r,o=aK.element(t.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aX&&(aX=rC(t.matrixWorld).setName("cameraWorldMatrix").setGroup(rA).onRenderUpdate(function(e){return e.camera.matrixWorld})),o=aX;return o}).once()(),a9=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.normalMatrix)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===aQ?aQ=aR(r).setGroup(rA).setName("cameraNormalMatrices"):aQ.array=r,o=aQ.element(t.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aY&&(aY=rC(t.normalMatrix).setName("cameraNormalMatrix").setGroup(rA).onRenderUpdate(function(e){return e.camera.normalMatrix})),o=aY;return o}).once()(),a7=tw(function(e){var t,r=e.camera;if(r.isArrayCamera&&r.cameras.length>0){for(var n=[],i=0,a=r.cameras.length;i<a;i++)n.push(new c.Fc);null===aJ?aJ=aR(n).setGroup(rA).setName("cameraPositions").onRenderUpdate(function(e,t){for(var r=e.camera.cameras,n=t.array,i=0,a=r.length;i<a;i++)n[i].setFromMatrixPosition(r[i].matrixWorld)}):aJ.array=n,t=aJ.element(r.isMultiViewCamera?aC("gl_ViewID_OVR"):a1)}else null===aZ&&(aZ=rC(new c.Fc).setName("cameraPosition").setGroup(rA).onRenderUpdate(function(e,t){var r=e.camera;return t.value.setFromMatrixPosition(r.matrixWorld)})),t=aZ;return t}).once()(),oe=tw(function(e){var t=e.camera;if(t.isArrayCamera&&t.cameras.length>0){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s,u=t.cameras[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var l=s.value;r.push(l.viewport)}}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}null===a0?a0=aR(r,"vec4").setGroup(rA).setName("cameraViewports"):a0.array=r,o=a0.element(a1)}else null===a$&&(a$=tH(0,0,aP.x,aP.y).toConst("cameraViewport")),o=a$;return o}).once()(),ot=new c.cd,or=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t)).scope=e,r.object3d=n,r.updateType=et.OBJECT,r.uniformNode=new rR(null),r}return T(t,e),y(t,[{key:"generateNodeType",value:function(){var e=this.scope;return e===or.WORLD_MATRIX?"mat4":e===or.POSITION||e===or.VIEW_POSITION||e===or.DIRECTION||e===or.SCALE?"vec3":e===or.RADIUS?"float":void 0}},{key:"update",value:function(e){var t=this.object3d,r=this.uniformNode,n=this.scope;if(n===or.WORLD_MATRIX)r.value=t.matrixWorld;else if(n===or.POSITION)r.value=r.value||new c.Fc,r.value.setFromMatrixPosition(t.matrixWorld);else if(n===or.SCALE)r.value=r.value||new c.Fc,r.value.setFromMatrixScale(t.matrixWorld);else if(n===or.DIRECTION)r.value=r.value||new c.Fc,t.getWorldDirection(r.value);else if(n===or.VIEW_POSITION){var i=e.camera;r.value=r.value||new c.Fc,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}else if(n===or.RADIUS){var a=e.object.geometry;null===a.boundingSphere&&a.computeBoundingSphere(),ot.copy(a.boundingSphere).applyMatrix4(t.matrixWorld),r.value=ot.radius}}},{key:"generate",value:function(e){var t=this.scope;return t===or.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===or.POSITION||t===or.VIEW_POSITION||t===or.DIRECTION||t===or.SCALE?this.uniformNode.nodeType="vec3":t===or.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.scope=this.scope}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.scope=e.scope}}],[{key:"type",get:function(){return"Object3DNode"}}]),t}(el);or.WORLD_MATRIX="worldMatrix",or.POSITION="position",or.SCALE="scale",or.VIEW_POSITION="viewPosition",or.DIRECTION="direction",or.RADIUS="radius";var on=tx(or,or.DIRECTION).setParameterLength(1),oi=tx(or,or.WORLD_MATRIX).setParameterLength(1),oa=tx(or,or.POSITION).setParameterLength(1),oo=tx(or,or.SCALE).setParameterLength(1),os=tx(or,or.VIEW_POSITION).setParameterLength(1),ou=tx(or,or.RADIUS).setParameterLength(1),ol=function(e){function t(e){return v(this,t),p(this,t,[e])}return T(t,e),y(t,[{key:"update",value:function(e){this.object3d=e.object,x(_(t.prototype),"update",this).call(this,e)}}],[{key:"type",get:function(){return"ModelNode"}}]),t}(or),oc=t_(ol,ol.DIRECTION),od=t_(ol,ol.WORLD_MATRIX),oh=t_(ol,ol.POSITION),of=t_(ol,ol.SCALE),op=t_(ol,ol.VIEW_POSITION),ov=t_(ol,ol.RADIUS),og=rC(new c.Gc).onObjectUpdate(function(e,t){var r=e.object;return t.value.getNormalMatrix(r.matrixWorld)}),om=rC(new c.Oc).onObjectUpdate(function(e,t){var r=e.object;return t.value.copy(r.matrixWorld).invert()}),oy=tw(function(e){return e.context.modelViewMatrix||ob}).once()().toVar("modelViewMatrix"),ob=a6.mul(od),ox=tw(function(e){return e.context.isHighPrecisionModelViewMatrix=!0,rC("mat4").onObjectUpdate(function(e){var t=e.object,r=e.camera;return t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld)})}).once()().toVar("highpModelViewMatrix"),o_=tw(function(e){var t=e.context.isHighPrecisionModelViewMatrix;return rC("mat3").onObjectUpdate(function(e){var r=e.object,n=e.camera;return!0!==t&&r.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,r.matrixWorld),r.normalMatrix.getNormalMatrix(r.modelViewMatrix)})}).once()().toVar("highpModelNormalViewMatrix"),oT=tw(function(e){return"fragment"!==e.shaderStage?((0,c.yc)("TSL: `clipSpace` is only available in fragment stage."),tH()):e.context.clipSpace.toVarying("v_clipSpace")}).once()(),oS=av("position","vec3"),oN=oS.toVarying("positionLocal"),ok=oS.toVarying("positionPrevious"),ow=tw(function(e){return od.mul(oN).xyz.toVarying(e.getSubBuildProperty("v_positionWorld"))},"vec3").once(["POSITION"])(),oA=tw(function(){return oN.transformDirection(od).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection")},"vec3").once(["POSITION"])(),oE=tw(function(e){if("fragment"===e.shaderStage&&e.material.vertexNode){var t=a5.mul(oT);return t.xyz.div(t.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),oR=tw(function(e){return(e.camera.isOrthographicCamera?tV(0,0,1):oE.negate().toVarying("v_positionViewDirection").normalize()).toVar("positionViewDirection")},"vec3").once(["POSITION"])(),oC=t_(function(e){function t(){var e;return v(this,t),(e=p(this,t,["bool"])).isFrontFacingNode=!0,e}return T(t,e),y(t,[{key:"generate",value:function(e){return"fragment"!==e.shaderStage?"true":e.material.side===c.k?"false":e.getFrontFacing()}}],[{key:"type",get:function(){return"FrontFacingNode"}}]),t}(el)),oM=tF(oC).mul(2).sub(1),oF=tw(function(e,t){var r=E(e,1)[0],n=t.material.side;return n===c.k?r=r.mul(-1):n===c.l&&(r=r.mul(oM)),r}),oB=av("normal","vec3"),oP=tw(function(e){return!1===e.geometry.hasAttribute("normal")?((0,c.wc)('TSL: Vertex attribute "normal" not found on geometry.'),tV(0,1,0)):oB},"vec3").once()().toVar("normalLocal"),oL=oE.dFdx().cross(oE.dFdy()).normalize().toVar("normalFlat"),oD=tw(function(e){return e.isFlatShading()?oL:oz(oP).toVarying("v_normalViewGeometry").normalize()},"vec3").once()().toVar("normalViewGeometry"),oU=tw(function(e){var t=oD.transformNormalByInverseViewMatrix(a6);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),oO=tw(function(e){var t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=oD,!0!==e.isFlatShading()&&(t=oF(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),oI=oO.transformNormalByInverseViewMatrix(a6).toVar("normalWorld"),oV=tw(function(e){var t=e.subBuildFn,r=e.context;return"NORMAL"===t||"VERTEX"===t?oO:r.setupClearcoatNormal().context({getUV:null,getTextureLevel:null})},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),oG=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return tY(void 0===n?od:n).inverse().transpose().mul(r).normalize()});eN("transformNormal",oG);var oz=tw(function(e,t){var r=E(e,1)[0],n=t.context.modelNormalViewMatrix;return n?r.transformNormalByViewMatrix(n):og.mul(r).transformNormalByViewMatrix(a6)}),oW=tw(function(){return(0,c.wc)('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),oO}).once(["NORMAL","VERTEX"])(),oH=tw(function(){return(0,c.wc)('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),oI}).once(["NORMAL","VERTEX"])(),oq=tw(function(){return(0,c.wc)('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),oV}).once(["NORMAL","VERTEX"])(),oj=new c.Oc,oX=rC(0).onReference(function(e){return e.material}).onObjectUpdate(function(e){return e.material.refractionRatio}),oK=rC(1).onReference(function(e){return e.material}).onObjectUpdate(function(e){var t=e.material,r=e.scene;return t.envMap?t.envMapIntensity:r.environmentIntensity}),oY=rC(new c.Oc).onReference(function(e){return e.material}).onObjectUpdate(function(e){var t=e.material,r=e.scene,n=null!==r.environment&&null===t.envMap?r.environmentRotation:t.envMapRotation;return n?oj.makeRotationFromEuler(n).transpose():oj.identity(),oj}),oQ=oR.negate().reflect(oO),oZ=oR.negate().refract(oO,oX),oJ=oQ.transformDirection(a8).toVar("reflectVector"),o$=oZ.transformDirection(a8).toVar("refractVector"),o0=new c.Ad,o1=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(r=p(this,t,[e,n,i,a])).isCubeTextureNode=!0,r}return T(t,e),y(t,[{key:"getInputType",value:function(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}},{key:"getDefaultUV",value:function(){var e=this.value;return e.mapping===c.fa?oJ:e.mapping===c.ga?o$:((0,c.xc)('CubeTextureNode: Mapping "%s" not supported.',e.mapping),tV(0,0,0))}},{key:"setUpdateMatrix",value:function(){}},{key:"setupUV",value:function(e,t){var r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===c.pc?tV(t.x,t.y.negate(),t.z):t:(t=oY.mul(t),e.renderer.coordinateSystem!==c.pc&&r.isRenderTargetTexture||(t=tV(t.x.negate(),t.yz)),t)}},{key:"generateUV",value:function(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}],[{key:"type",get:function(){return"CubeTextureNode"}}]),t}(a_)).setParameterLength(1,4).setName("cubeTexture"),o2=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return t&&!0===t.isCubeTextureNode?((e=tg(t.clone())).referenceNode=t,null!==r&&(e.uvNode=tg(r)),null!==n&&(e.levelNode=tg(n)),null!==i&&(e.biasNode=tg(i))):e=o1(t,r,n,i),e},o3=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).referenceNode=e,n.isReferenceElementNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return this.referenceNode.uniformType}},{key:"generate",value:function(e){var r=x(_(t.prototype),"generate",this).call(this,e),n=this.referenceNode.getNodeType(e),i=this.getNodeType(e);return e.format(r,n,i)}}],[{key:"type",get:function(){return"ReferenceElementNode"}}]),t}(ec),o4=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(n=p(this,t)).property=e,n.uniformType=r,n.object=i,n.count=a,n.properties=e.split("."),n.reference=i,n.node=null,n.group=null,n.name=null,n.updateType=et.OBJECT,n}return T(t,e),y(t,[{key:"element",value:function(e){return new o3(this,tg(e))}},{key:"setGroup",value:function(e){return this.group=e,this}},{key:"setName",value:function(e){return this.name=e,this}},{key:"label",value:function(e){return(0,c.wc)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}},{key:"setNodeType",value:function(e){var t=null;null!==this.count?t=aw(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=aR(null,e)).updateType=et.OBJECT:t="texture"===e?aS(null):"cubeTexture"===e?o2(null):rC(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}},{key:"generateNodeType",value:function(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}},{key:"getValueFromReference",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.reference,t=this.properties,r=e[t[0]],n=1;n<t.length;n++)r=r[t[n]];return r}},{key:"updateReference",value:function(e){return this.reference=null!==this.object?this.object:e.object,this.reference}},{key:"setup",value:function(){return this.updateValue(),this.node}},{key:"update",value:function(){this.updateValue()}},{key:"updateValue",value:function(){null===this.node&&this.setNodeType(this.uniformType);var e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}],[{key:"type",get:function(){return"ReferenceNode"}}]),t}(el),o5=function(e,t,r){return new o4(e,t,r)},o6=function(e,t,r,n){return new o4(e,t,n,r)},o8=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e,r,i])).material=i,n.isMaterialReferenceNode=!0,n}return T(t,e),y(t,[{key:"updateReference",value:function(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}],[{key:"type",get:function(){return"MaterialReferenceNode"}}]),t}(o4),o9=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new o8(e,t,r)},o7=ag(),se=oE.dFdx(),st=oE.dFdy(),sr=o7.dFdx(),sn=o7.dFdy(),si=st.cross(oO),sa=oO.cross(se),so=si.mul(sr.x).add(sa.mul(sn.x)),ss=si.mul(sr.y).add(sa.mul(sn.y)),su=so.dot(so).max(ss.dot(ss)),sl=su.equal(0).select(0,su.inverseSqrt()),sc=so.mul(sl).toVar("tangentViewFrame"),sd=ss.mul(sl).toVar("bitangentViewFrame"),sh=av("tangent","vec4"),sf=sh.xyz.toVar("tangentLocal"),sp=tw(function(e){var t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?oy.mul(tH(sf,0)).xyz.toVarying("v_tangentView").normalize():sc,!0!==e.isFlatShading()&&(t=oF(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),sv=sp.transformDirection(a8).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),sg=tw(function(e,t){var r=E(e,2),n=r[0],i=r[1],a=n.mul(sh.w).xyz;return"NORMAL"===t.subBuildFn&&!0!==t.isFlatShading()&&(a=a.toVarying(i)),a}).once(["NORMAL"]),sm=sg(oB.cross(sh),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),sy=sg(oP.cross(sf),"v_bitangentLocal").normalize().toVar("bitangentLocal"),sb=tw(function(e){var t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?sg(oO.cross(sp),"v_bitangentView").normalize():sd,!0!==e.isFlatShading()&&(t=oF(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),sx=sg(oI.cross(sv),"v_bitangentWorld").normalize().toVar("bitangentWorld"),s_=tY(sp,sb,oO).toVar("TBNViewMatrix"),sT=oR.mul(s_),sS=tw(function(){var e=rs.cross(oR);return n7(e=e.cross(rs).normalize(),oO,ra.mul(t5.oneMinus()).oneMinus().pow2().pow2()).normalize()}).once()(),sN=function(e){return tg(e).mul(.5).add(.5)},sk=function(e){return tg(e).mul(2).sub(1)},sw=function(e){return tV(e,np(it(tF(1).sub(nJ(e,e)))))},sA=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,["vec3"])).node=e,r.scaleNode=n,r.normalMapType=c.Fb,r.unpackNormalMode=c.Mb,r}return T(t,e),y(t,[{key:"setup",value:function(e){var t=this.normalMapType,r=this.scaleNode,n=this.unpackNormalMode,i=this.node.mul(2).sub(1);if(t===c.Fb?n===c.Nb?i=sw(i.xy):n===c.Ob?i=sw(i.yw):n!==c.Mb&&(0,c.xc)("THREE.NodeMaterial: Unexpected unpack normal mode: ".concat(n)):n!==c.Mb&&(0,c.xc)("THREE.NodeMaterial: Normal map type '".concat(t,"' is not compatible with unpack normal mode '").concat(n,"'")),null!==r){var a=r;!0===e.isFlatShading()&&(a=oF(a)),i=tV(i.xy.mul(a),i.z)}var o=null;return t===c.Gb?o=oz(i):t===c.Fb?o=s_.mul(i).normalize():((0,c.xc)("NodeMaterial: Unsupported normal map type: ".concat(t)),o=oO),o}}],[{key:"type",get:function(){return"NormalMapNode"}}]),t}(eh)).setParameterLength(1,2),sE=tw(function(e){var t=e.textureNode,r=e.bumpScale,n=function(e){return t.isolate().context({getUV:function(t){return e(t.uvNode||ag())},forceUVContext:!0})},i=tF(n(function(e){return e}));return tD(tF(n(function(e){return e.add(e.dFdx())})).sub(i),tF(n(function(e){return e.add(e.dFdy())})).sub(i)).mul(r)}),sR=tw(function(e){var t=e.surf_pos,r=e.surf_norm,n=e.dHdxy,i=t.dFdx().normalize(),a=t.dFdy().normalize().cross(r),o=r.cross(i),s=i.dot(a).mul(oM),u=s.sign().mul(n.x.mul(a).add(n.y.mul(o)));return s.abs().mul(r).sub(u).normalize()}),sC=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,["vec3"])).textureNode=e,r.scaleNode=n,r}return T(t,e),y(t,[{key:"setup",value:function(e){if(!0===e.material.wireframe)return oO;var t=null!==this.scaleNode?this.scaleNode:1;return sR({surf_pos:oE,surf_norm:oO,dHdxy:sE({textureNode:this.textureNode,bumpScale:t})})}}],[{key:"type",get:function(){return"BumpMapNode"}}]),t}(eh)).setParameterLength(1,2),sM=new Map,sF=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).scope=e,r}return T(t,e),y(t,[{key:"getCache",value:function(e,t){var r=sM.get(e);return void 0===r&&(r=o9(e,t),sM.set(e,r)),r}},{key:"getFloat",value:function(e){return this.getCache(e,"float")}},{key:"getColor",value:function(e){return this.getCache(e,"color")}},{key:"getTexture",value:function(e){return this.getCache("map"===e?"map":e+"Map","texture")}},{key:"setup",value:function(e){var t=e.context.material,r=this.scope,n=null;if(r===sF.COLOR){var i=void 0!==t.color?this.getColor(r):tV();n=t.map&&!0===t.map.isTexture?i.mul(this.getTexture("map")):i}else if(r===sF.OPACITY){var a=this.getFloat(r);n=t.alphaMap&&!0===t.alphaMap.isTexture?a.mul(this.getTexture("alpha")):a}else if(r===sF.SPECULAR_STRENGTH)n=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:tF(1);else if(r===sF.SPECULAR_INTENSITY){var o=this.getFloat(r);n=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?o.mul(this.getTexture(r).a):o}else if(r===sF.SPECULAR_COLOR){var s=this.getColor(r);n=t.specularColorMap&&!0===t.specularColorMap.isTexture?s.mul(this.getTexture(r).rgb):s}else if(r===sF.ROUGHNESS){var u=this.getFloat(r);n=t.roughnessMap&&!0===t.roughnessMap.isTexture?u.mul(this.getTexture(r).g):u}else if(r===sF.METALNESS){var l=this.getFloat(r);n=t.metalnessMap&&!0===t.metalnessMap.isTexture?l.mul(this.getTexture(r).b):l}else if(r===sF.EMISSIVE){var d=this.getFloat("emissiveIntensity"),h=this.getColor(r).mul(d);n=t.emissiveMap&&!0===t.emissiveMap.isTexture?h.mul(this.getTexture(r)):h}else if(r===sF.NORMAL)t.normalMap?((n=sA(this.getTexture("normal"),this.getCache("normalScale","vec2"))).normalMapType=t.normalMapType,(t.normalMap.format==c.Oa||t.normalMap.format==c.yb||t.normalMap.format==c.db)&&(n.unpackNormalMode=c.Nb)):n=t.bumpMap?sC(this.getTexture("bump").r,this.getFloat("bumpScale")):oO;else if(r===sF.CLEARCOAT){var f=this.getFloat(r);n=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?f.mul(this.getTexture(r).r):f}else if(r===sF.CLEARCOAT_ROUGHNESS){var p=this.getFloat(r);n=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?p.mul(this.getTexture(r).r):p}else if(r===sF.CLEARCOAT_NORMAL)n=t.clearcoatNormalMap?sA(this.getTexture(r),this.getCache(r+"Scale","vec2")):oO;else if(r===sF.SHEEN){var v=this.getColor("sheenColor").mul(this.getFloat("sheen"));n=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?v.mul(this.getTexture("sheenColor").rgb):v}else if(r===sF.SHEEN_ROUGHNESS){var g=this.getFloat(r);n=(n=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?g.mul(this.getTexture(r).a):g).clamp(1e-4,1)}else if(r===sF.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){var m=this.getTexture(r);n=tK(uo.x,uo.y,uo.y.negate(),uo.x).mul(m.rg.mul(2).sub(tD(1)).normalize().mul(m.b))}else n=uo;else if(r===sF.IRIDESCENCE_THICKNESS){var y=o5("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){var b=o5("0","float",t.iridescenceThicknessRange);n=y.sub(b).mul(this.getTexture(r).g).add(b)}else n=y}else if(r===sF.TRANSMISSION){var x=this.getFloat(r);n=t.transmissionMap?x.mul(this.getTexture(r).r):x}else if(r===sF.THICKNESS){var _=this.getFloat(r);n=t.thicknessMap?_.mul(this.getTexture(r).g):_}else if(r===sF.IOR)n=this.getFloat(r);else if(r===sF.LIGHT_MAP)n=t.lightMap?this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):tV(0);else if(r===sF.AO)n=t.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):tF(1);else if(r===sF.LINE_DASH_OFFSET)n=t.dashOffset?this.getFloat(r):tF(0);else{var T=this.getNodeType(e);n=this.getCache(r,T)}return n}}],[{key:"type",get:function(){return"MaterialNode"}}]),t}(el);sF.ALPHA_TEST="alphaTest",sF.COLOR="color",sF.OPACITY="opacity",sF.SHININESS="shininess",sF.SPECULAR="specular",sF.SPECULAR_STRENGTH="specularStrength",sF.SPECULAR_INTENSITY="specularIntensity",sF.SPECULAR_COLOR="specularColor",sF.REFLECTIVITY="reflectivity",sF.ROUGHNESS="roughness",sF.METALNESS="metalness",sF.NORMAL="normal",sF.CLEARCOAT="clearcoat",sF.CLEARCOAT_ROUGHNESS="clearcoatRoughness",sF.CLEARCOAT_NORMAL="clearcoatNormal",sF.EMISSIVE="emissive",sF.ROTATION="rotation",sF.SHEEN="sheen",sF.SHEEN_ROUGHNESS="sheenRoughness",sF.ANISOTROPY="anisotropy",sF.IRIDESCENCE="iridescence",sF.IRIDESCENCE_IOR="iridescenceIOR",sF.IRIDESCENCE_THICKNESS="iridescenceThickness",sF.IOR="ior",sF.TRANSMISSION="transmission",sF.THICKNESS="thickness",sF.ATTENUATION_DISTANCE="attenuationDistance",sF.ATTENUATION_COLOR="attenuationColor",sF.LINE_SCALE="scale",sF.LINE_DASH_SIZE="dashSize",sF.LINE_GAP_SIZE="gapSize",sF.LINE_WIDTH="linewidth",sF.LINE_DASH_OFFSET="dashOffset",sF.POINT_SIZE="size",sF.DISPERSION="dispersion",sF.LIGHT_MAP="light",sF.AO="ao";var sB=t_(sF,sF.ALPHA_TEST),sP=t_(sF,sF.COLOR),sL=t_(sF,sF.SHININESS),sD=t_(sF,sF.EMISSIVE),sU=t_(sF,sF.OPACITY),sO=t_(sF,sF.SPECULAR),sI=t_(sF,sF.SPECULAR_INTENSITY),sV=t_(sF,sF.SPECULAR_COLOR),sG=t_(sF,sF.SPECULAR_STRENGTH),sz=t_(sF,sF.REFLECTIVITY),sW=t_(sF,sF.ROUGHNESS),sH=t_(sF,sF.METALNESS),sq=t_(sF,sF.NORMAL),sj=t_(sF,sF.CLEARCOAT),sX=t_(sF,sF.CLEARCOAT_ROUGHNESS),sK=t_(sF,sF.CLEARCOAT_NORMAL),sY=t_(sF,sF.ROTATION),sQ=t_(sF,sF.SHEEN),sZ=t_(sF,sF.SHEEN_ROUGHNESS),sJ=t_(sF,sF.ANISOTROPY),s$=t_(sF,sF.IRIDESCENCE),s0=t_(sF,sF.IRIDESCENCE_IOR),s1=t_(sF,sF.IRIDESCENCE_THICKNESS),s2=t_(sF,sF.TRANSMISSION),s3=t_(sF,sF.THICKNESS),s4=t_(sF,sF.IOR),s5=t_(sF,sF.ATTENUATION_DISTANCE),s6=t_(sF,sF.ATTENUATION_COLOR),s8=t_(sF,sF.LINE_SCALE),s9=t_(sF,sF.LINE_DASH_SIZE),s7=t_(sF,sF.LINE_GAP_SIZE),ue=t_(sF,sF.LINE_WIDTH),ut=t_(sF,sF.LINE_DASH_OFFSET),ur=t_(sF,sF.POINT_SIZE),un=t_(sF,sF.DISPERSION),ui=t_(sF,sF.LIGHT_MAP),ua=t_(sF,sF.AO),uo=rC(new c.Dc).onReference(function(e){return e.material}).onRenderUpdate(function(e){var t=e.material;this.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation))}),us=tw(function(e){return e.context.setupModelViewProjection()},"vec4").once()().toVarying("v_modelViewProjection"),uu=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,["void"])).eventType=e,n.callback=r,e===uu.OBJECT?n.updateType=et.OBJECT:e===uu.MATERIAL?n.updateType=et.RENDER:e===uu.FRAME?n.updateType=et.FRAME:e===uu.BEFORE_OBJECT?n.updateBeforeType=et.OBJECT:e===uu.BEFORE_MATERIAL?n.updateBeforeType=et.RENDER:e===uu.BEFORE_FRAME?n.updateBeforeType=et.FRAME:e===uu.AFTER_OBJECT&&(n.updateAfterType=et.OBJECT),n}return T(t,e),y(t,[{key:"update",value:function(e){this.callback(e)}},{key:"updateBefore",value:function(e){this.callback(e)}},{key:"updateAfter",value:function(e){this.callback(e)}}],[{key:"type",get:function(){return"EventNode"}}]),t}(el);uu.OBJECT="object",uu.MATERIAL="material",uu.FRAME="frame",uu.BEFORE_OBJECT="beforeObject",uu.BEFORE_MATERIAL="beforeMaterial",uu.BEFORE_FRAME="beforeFrame",uu.AFTER_OBJECT="afterObject";var ul=function(e,t){return new uu(e,t).toStack()},uc=function(e){return ul(uu.OBJECT,e)},ud=function(e){return ul(uu.FRAME,e)},uh=tx(function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).isStorageArrayElementNode=!0,n}return T(t,e),y(t,[{key:"storageBufferNode",get:function(){return this.node},set:function(e){this.node=e}},{key:"getMemberType",value:function(e,t){var r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}},{key:"setup",value:function(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),x(_(t.prototype),"setup",this).call(this,e)}},{key:"generate",value:function(e,r){var n,i=e.isContextAssign();if(n=!1===e.isAvailable("storageBuffer")?!0===this.node.isPBO&&!0!==i&&(this.node.value.isInstancedBufferAttribute||"compute"!==e.shaderStage)?e.generatePBO(this):this.node.build(e):x(_(t.prototype),"generate",this).call(this,e),!0!==i){var a=this.getNodeType(e);n=e.format(n,a,r)}return n}}],[{key:"type",get:function(){return"StorageArrayElementNode"}}]),t}(ec)).setParameterLength(2),uf=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;v(this,t);var a,o,s=null;return n&&n.isStructTypeNode?(o="struct",s=n,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):null===n&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=e.itemSize,o=X.get(r),i=e.count):o=n,(a=p(this,t,[e,o,i])).isStorageBufferNode=!0,a.structTypeNode=s,a.access=er.READ_WRITE,a.isAtomic=!1,a.isPBO=!1,a._attribute=null,a._varying=null,a.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0),a}return T(t,e),y(t,[{key:"getHash",value:function(e){var t;if(0===this.bufferCount){var r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}},{key:"getInputType",value:function(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}},{key:"element",value:function(e){return uh(this,e)}},{key:"setPBO",value:function(e){return this.isPBO=e,this}},{key:"getPBO",value:function(){return this.isPBO}},{key:"setAccess",value:function(e){return this.access=e,this}},{key:"toReadOnly",value:function(){return this.setAccess(er.READ_ONLY)}},{key:"setAtomic",value:function(e){return this.isAtomic=e,this}},{key:"toAtomic",value:function(){return this.setAtomic(!0)}},{key:"getAttributeData",value:function(){return null===this._attribute&&(this._attribute=iq(this.value),this._varying=iw(this._attribute)),{attribute:this._attribute,varying:this._varying}}},{key:"generateNodeType",value:function(e){return null!==this.structTypeNode?this.structTypeNode.getNodeType(e):e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer")?x(_(t.prototype),"generateNodeType",this).call(this,e):this.getAttributeData().attribute.getNodeType(e)}},{key:"getMemberType",value:function(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}},{key:"generate",value:function(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return x(_(t.prototype),"generate",this).call(this,e);var r=this.getAttributeData(),n=r.attribute,i=r.varying.build(e);return e.registerTransform(i,n),i}}],[{key:"type",get:function(){return"StorageBufferNode"}}]),t}(ak),up=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new uf(e,t,r)},uv=new WeakMap,ug=new WeakMap,um=new WeakMap;function uy(e,t,r){var n;if(!0===t.isStorageInstancedBufferAttribute)n=up(t,"mat4",Math.max(r,1)).element(iQ);else if(16*r*4<=e.getUniformBufferLimit())n=aw(t.array,"mat4",Math.max(r,1)).element(iQ);else{var i=uv.get(t);i||(i=new c.Me(t.array,16,1),uv.set(t,i));var a=t.usage===c.mc?iX:ij,o=[a(i,"vec4",16,0),a(i,"vec4",16,4),a(i,"vec4",16,8),a(i,"vec4",16,12)];n=tQ.apply(void 0,R(o))}return n}var ub=t1("vec3","vInstanceColor"),ux=tw(function(e,t){var r=E(e,3),n=r[0],i=r[1],a=r[2],o=void 0===a?null:a;n=n.value;var s=!0===i.isStorageInstancedBufferAttribute,u=o&&!0===o.isStorageInstancedBufferAttribute,l=uy(t,i,n);t.spInstanceMatrixNode=l;var d=null;s||16*n*4>t.getUniformBufferLimit()&&(d=uv.get(i));var h=null,f=null;if(o)if(u)h=up(o,"vec3",Math.max(o.count,1)).element(iQ);else{var p=ug.get(o);p||(p=new c.pd(o.array,3),ug.set(o,p)),f=p,h=tV((o.usage===c.mc?iX:ij)(p,"vec3",3,0))}(null!==d||null!==f)&&ud(function(){var e,t;null!==d&&(d.clearUpdateRanges(),(e=d.updateRanges).push.apply(e,R(i.updateRanges)),i.version!==d.version&&(d.version=i.version)),o&&null!==f&&(f.clearUpdateRanges(),(t=f.updateRanges).push.apply(t,R(o.updateRanges)),o.version!==f.version&&(f.version=o.version))});var v=l.mul(oN).xyz;if(oN.assign(v),t.needsPreviousData()){var g=t.object;ul(uu.AFTER_OBJECT,function(e){var t=e.object;um.get(t).previousInstanceMatrix.array.set(i.array)});var m=function(e,t,r,n){var i=um.get(e);if(void 0===i){var a=t.clone();i={previousInstanceMatrix:a,node:uy(r,a,n)},um.set(e,i)}return i.node}(g,i,t,n);ok.assign(m.mul(ok).xyz)}if(t.hasGeometryAttribute("normal")){var y=oG(oP,l);oP.assign(y)}null!==h&&ub.assign(h)},"void"),u_=tw(function(e){var t=E(e,1)[0];ux(t.count,t.instanceMatrix,t.instanceColor)},"void"),uT=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tB(am(aN(r),0).x).toConst(),a=tB(n);return aN(r,tU(a.mod(i).toConst(),a.div(i).toConst()))}),uS=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tB(am(aN(r),0).x).toConst();return aN(r,tU(tB(n).mod(i).toConst(),tB(n).div(i).toConst())).x}),uN=t1("vec4","vBatchColor"),uk=tw(function(e,t){var r=E(e,1)[0],n=null===t.getDrawIndex()?iQ:i0,i=uS(r._indirectTexture,tB(n)),a=r._matricesTexture,o=tB(am(aN(a),0).x).toConst(),s=tF(i).mul(4).toInt().toConst(),u=s.mod(o).toConst(),l=s.div(o).toConst(),c=tQ(aN(a,tU(u,l)),aN(a,tU(u.add(1),l)),aN(a,tU(u.add(2),l)),aN(a,tU(u.add(3),l))),d=r._colorsTexture;if(null!==d){var h=uT(d,i);uN.assign(h)}var f=tY(c);oN.assign(c.mul(oN));var p=oP.div(tV(f[0].dot(f[0]),f[1].dot(f[1]),f[2].dot(f[2]))),v=f.mul(p).xyz;oP.assign(v),t.hasGeometryAttribute("tangent")&&sf.mulAssign(f)},"void"),uw=new WeakMap,uA=new WeakMap;function uE(e,t,r,n,i,a){var o=e.element(i.x),s=e.element(i.y),u=e.element(i.z),l=e.element(i.w),c=r.mul(t),d=rO(o.mul(a.x).mul(c),s.mul(a.y).mul(c),u.mul(a.z).mul(c),l.mul(a.w).mul(c));return n.mul(d).xyz}function uR(e,t,r,n,i,a,o){var s=e.element(a.x),u=e.element(a.y),l=e.element(a.z),c=e.element(a.w),d=rO(o.x.mul(s),o.y.mul(u),o.z.mul(l),o.w.mul(c));return{skinNormal:(d=i.mul(d).mul(n)).transformDirection(t).xyz,skinTangent:d.transformDirection(r).xyz}}function uC(e,t,r,n,i){var a=e.skeleton,o=uA.get(a);if(void 0===o){a.update();var s=new Float32Array(a.boneMatrices);o={previousBoneMatrices:s,node:aw(s,"mat4",a.bones.length)},uA.set(a,o)}return uE(o.node,ok,t,r,n,i)}var uM=tw(function(e,t){var r=E(e,1)[0],n=av("skinIndex","uvec4"),i=av("skinWeight","vec4"),a=o5("bindMatrix","mat4"),o=o5("bindMatrixInverse","mat4"),s=o6("skeleton.boneMatrices","mat4",r.skeleton.bones.length);if(uc(function(e){var t=e.object,r=e.frameId,n=t.skeleton;if(uw.get(n)!==r){uw.set(n,r);var i=uA.get(n);void 0!==i&&i.previousBoneMatrices.set(n.boneMatrices),n.update()}}),t.needsPreviousData()){var u=uC(r,a,o,n,i);ok.assign(u)}var l=uE(s,oN,a,o,n,i);if(oN.assign(l),t.hasGeometryAttribute("normal")){var c=uR(s,oP,sf,a,o,n,i),d=c.skinNormal,h=c.skinTangent;oP.assign(d),t.hasGeometryAttribute("tangent")&&sf.assign(h)}},"void"),uF=tw(function(e,t){var r=E(e,2),n=r[0],i=r[1],a=void 0===i?null:i,o=up(new c.pd(n.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(iQ).toVar(),s=up(new c.pd(new Uint32Array(n.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(iQ).toVar(),u=up(new c.pd(n.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(iQ).toVar(),l=rC(n.bindMatrix,"mat4"),d=rC(n.bindMatrixInverse,"mat4"),h=aw(n.skeleton.boneMatrices,"mat4",n.skeleton.bones.length),f=n.skeleton;if(uc(function(e){var t=e.frameId;if(uw.get(f)!==t){uw.set(f,t);var r=uA.get(f);void 0!==r&&r.previousBoneMatrices.set(f.boneMatrices),f.update()}}),t.needsPreviousData()){var p=uC(n,l,d,s,u);ok.assign(p)}var v=uE(h,o,l,d,s,u);if(null!==a&&a.assign(v),t.hasGeometryAttribute("normal")){var g=uR(h,oP,sf,l,d,s,u),m=g.skinNormal,y=g.skinTangent;oP.assign(m),t.hasGeometryAttribute("tangent")&&sf.assign(y)}return v}),uB=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return v(this,t),(e=p(this,t,["void"])).params=r,e}return T(t,e),y(t,[{key:"getVarName",value:function(e){return String.fromCharCode(105+e)}},{key:"getProperties",value:function(e){var t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;for(var r={},n=0,i=this.params.length-1;n<i;n++){var a=this.params[n],o=!0!==a.isNode&&a.name||this.getVarName(n),s=!0!==a.isNode&&a.type||"int";r[o]=at(o,s)}var u=e.addStack(),l=this.params[this.params.length-1](r);t.returnsNode=l.context({nodeLoop:l}),t.stackNode=u;var c=this.params[0];if(!0!==c.isNode&&"function"==typeof c.update){var d=tw(this.params[0].update)(r);t.updateNode=d.context({nodeLoop:d})}return e.removeStack(),t}},{key:"setup",value:function(e){this.getProperties(e),e.fnCall&&(e.getDataFromNode(e.fnCall.shaderNode).hasLoop=!0)}},{key:"generate",value:function(e){for(var t,r=this.getProperties(e),n=this.params,i=r.stackNode,a=0,o=n.length-1;a<o;a++)t=this,function(i){var a=void 0,o=n[i],s=!1,u=null,l=null,d=null,h=null,f=null,p=null;if(o.isNode?"bool"===o.getNodeType(e)?(s=!0,h="bool",l=o.build(e,h)):(h="int",d=t.getVarName(i),u="0",l=o.build(e,h),f="<"):(h=o.type||"int",d=o.name||t.getVarName(i),u=o.start,l=o.end,f=o.condition,p=o.update,"number"==typeof u?u=e.generateConst(h,u):u&&u.isNode&&(u=u.build(e,h)),"number"==typeof l?l=e.generateConst(h,l):l&&l.isNode&&(l=l.build(e,h)),void 0!==u&&void 0===l?(u+=" - 1",l="0",f=">="):void 0!==l&&void 0===u&&(u="0",f="<"),void 0===f&&(f=Number(u)>Number(l)?">=":"<")),s)a="while ( ".concat(l," )");else{var v=void 0,g=u,m=l,y=function(){return f.includes("<")?"+=":"-="};if(null!=p)switch(void 0===p?"undefined":C(p)){case"function":v=e.flowStagesNode(r.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":v=d+" "+y()+" "+e.generateConst(h,p);break;case"string":v=d+" "+p;break;default:p.isNode?v=d+" "+y()+" "+p.build(e):((0,c.xc)("TSL: 'Loop( { update: ... } )' is not a function, string or number.",t.stackTrace),v="break /* invalid update */")}else v=d+" "+(p="int"===h||"uint"===h?f.includes("<")?"++":"--":y()+" 1.");a="for ( ".concat(e.getVar(h,d)+" = "+g,"; ").concat(d+" "+f+" "+m,"; ").concat(v," )")}e.addFlowCode((0===i?"\n":"")+e.tab+a+" {\n\n").addFlowTab()}(a);var s=i.build(e,"void");r.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+s);for(var u=0,l=this.params.length-1;u<l;u++)e.addFlowCode((0===u?"":e.tab)+"}\n\n").removeFlowTab();e.addFlowTab()}}],[{key:"type",get:function(){return"LoopNode"}}]),t}(el),uP=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new uB(tb(t,"int")).toStack()},uL=function(){return at("break").toStack()},uD=new WeakMap,uU=new c.Jc,uO=new WeakMap,uI=tw(function(e){var t=e.bufferMap,r=e.influence,n=e.stride,i=e.width,a=e.depth,o=e.offset,s=tB(iY).mul(n).add(o),u=s.div(i);return aN(t,tU(s.sub(u.mul(i)),u)).depth(a).xyz.mul(r)}),uV=tw(function(e){var t=E(e,1)[0],r=t.geometry,n=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,a=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,o=void 0!==a?a.length:0;if(0!==o){var s=uO.get(t);(void 0===s||s.count!==o)&&(s={base:rC(1),influences:t.morphTargetInfluences?aR(t.morphTargetInfluences,"float"):null,count:o},uO.set(t,s));var u=s.base,l=s.influences,d=function(e){var t=void 0!==e.morphAttributes.position,r=void 0!==e.morphAttributes.normal,n=void 0!==e.morphAttributes.color,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==i?i.length:0,o=uD.get(e);if(void 0===o||o.count!==a){var s=function(){g.dispose(),uD.delete(e),e.removeEventListener("dispose",s)};void 0!==o&&o.texture.dispose();var u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[],h=0;!0===t&&(h=1),!0===r&&(h=2),!0===n&&(h=3);var f=e.attributes.position.count*h,p=1;f>4096&&(p=Math.ceil(f/4096),f=4096);var v=new Float32Array(f*p*4*a),g=new c.Mc(v,f,p,a);g.type=c.Aa,g.needsUpdate=!0;for(var m=4*h,y=0;y<a;y++)for(var b=u[y],x=l[y],_=d[y],T=f*p*4*y,S=0;S<b.count;S++){var N=S*m;!0===t&&(uU.fromBufferAttribute(b,S),v[T+N+0]=uU.x,v[T+N+1]=uU.y,v[T+N+2]=uU.z,v[T+N+3]=0),!0===r&&(uU.fromBufferAttribute(x,S),v[T+N+4]=uU.x,v[T+N+5]=uU.y,v[T+N+6]=uU.z,v[T+N+7]=0),!0===n&&(uU.fromBufferAttribute(_,S),v[T+N+8]=uU.x,v[T+N+9]=uU.y,v[T+N+10]=uU.z,v[T+N+11]=4===_.itemSize?uU.w:1)}o={count:a,texture:g,stride:h,size:new c.Dc(f,p)},uD.set(e,o),e.addEventListener("dispose",s)}return o}(r),h=d.texture,f=d.stride,p=d.size;!0===n&&oN.mulAssign(u),!0===i&&oP.mulAssign(u);var v=tB(p.width);uP(o,function(e){var r=e.i,a=tF(0).toVar();t.count>1&&null!==t.morphTexture&&void 0!==t.morphTexture?a.assign(aN(t.morphTexture,tU(tB(r).add(1),tB(iQ))).r):a.assign(l.element(r).toVar()),tR(a.notEqual(0),function(){!0===n&&oN.addAssign(uI({bufferMap:h,influence:a,stride:f,width:v,depth:r,offset:tB(0)})),!0===i&&oP.addAssign(uI({bufferMap:h,influence:a,stride:f,width:v,depth:r,offset:tB(1)}))})}),uc(function(e){var t=e.object,r=s.base,n=s.influences;t.geometry.morphTargetsRelative?r.value=1:r.value=1-t.morphTargetInfluences.reduce(function(e,t){return e+t},0),n&&(n.array=t.morphTargetInfluences,n.update())})}},"void"),uG=function(e){function t(){var e;return v(this,t),(e=p(this,t,["vec3"])).isLightingNode=!0,e}return T(t,e),y(t,null,[{key:"type",get:function(){return"LightingNode"}}]),t}(el),uz=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).aoNode=r,e}return T(t,e),y(t,[{key:"setup",value:function(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}],[{key:"type",get:function(){return"AONode"}}]),t}(uG),uW=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return v(this,t),(r=p(this,t,[e])).lightingModel=n,r.materialLightings=i,r.backdropNode=a,r.backdropAlphaNode=o,r._value=null,r}return T(t,e),y(t,[{key:"getContext",value:function(){var e=this.materialLightings,t=this.backdropNode,r=this.backdropAlphaNode,n={directDiffuse:tV().toVar("directDiffuse"),directSpecular:tV().toVar("directSpecular"),indirectDiffuse:tV().toVar("indirectDiffuse"),indirectSpecular:tV().toVar("indirectSpecular")};return{radiance:tV().toVar("radiance"),irradiance:tV().toVar("irradiance"),iblIrradiance:tV().toVar("iblIrradiance"),ambientOcclusion:tF(1).toVar("ambientOcclusion"),reflectedLight:n,materialLightings:e,backdrop:t,backdropAlpha:r}}},{key:"setup",value:function(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,x(_(t.prototype),"setup",this).call(this,e)}}],[{key:"type",get:function(){return"LightingContextNode"}}]),t}(id)),uH=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).node=e,r}return T(t,e),y(t,[{key:"setup",value:function(e){e.context.irradiance.addAssign(this.node)}}],[{key:"type",get:function(){return"IrradianceNode"}}]),t}(uG),uq=new c.Dc,uj=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:aB,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;v(this,t);var a=null;return null===i?((a=new c.zd).minFilter=c.sa,i=a):a=i,(e=p(this,t,[i,r,n])).generateMipmaps=!1,e.defaultFramebuffer=a,e.isOutputTextureNode=!0,e.updateBeforeType=et.RENDER,e._cacheTextures=new WeakMap,e}return T(t,e),y(t,[{key:"getTextureForReference",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.referenceNode?(e=this.referenceNode.defaultFramebuffer,t=this.referenceNode._cacheTextures):(e=this.defaultFramebuffer,t=this._cacheTextures),null===r)return e;if(!1===t.has(r)){var n=e.clone();t.set(r,n)}return t.get(r)}},{key:"updateReference",value:function(e){var t=e.renderer,r=t.getRenderTarget(),n=t.getCanvasTarget();return this.value=this.getTextureForReference(r||n),this.value}},{key:"updateBefore",value:function(e){var t=e.renderer,r=t.getRenderTarget(),n=t.getCanvasTarget(),i=r||n;null===i?t.getDrawingBufferSize(uq):i.getDrawingBufferSize?i.getDrawingBufferSize(uq):uq.set(i.width,i.height);var a=this.getTextureForReference(i);(a.image.width!==uq.width||a.image.height!==uq.height)&&(a.image.width=uq.width,a.image.height=uq.height,a.needsUpdate=!0);var o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}},{key:"clone",value:function(){var e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}],[{key:"type",get:function(){return"ViewportTextureNode"}}]),t}(a_),uX=tx(uj).setParameterLength(0,3),uK=tx(uj,null,null,{generateMipmaps:!0}).setParameterLength(0,3),uY=uK(),uQ=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:aB,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return uY.sample(e,t)},uZ=null,uJ=tx(function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:aB,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),null===n&&(null===uZ&&(uZ=new c.Cd),n=uZ),p(this,t,[e,r,n])}return T(t,e),y(t,null,[{key:"type",get:function(){return"ViewportDepthTextureNode"}}]),t}(uj)).setParameterLength(0,3),u$=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,["float"])).scope=e,r.valueNode=n,r.isViewportDepthNode=!0,r}return T(t,e),y(t,[{key:"generate",value:function(e){return this.scope===u$.DEPTH_BASE?e.getFragDepth():x(_(t.prototype),"generate",this).call(this,e)}},{key:"setup",value:function(e){var t=e.camera,r=this.scope,n=this.valueNode,i=null;return r===u$.DEPTH_BASE?null!==n&&(i=u6().assign(n)):r===u$.DEPTH?i=t.isPerspectiveCamera?u2(oE.z,a2,a3):u0(oE.z,a2,a3):r===u$.LINEAR_DEPTH&&(i=null!==n?t.isPerspectiveCamera?u0(u4(n,a2,a3),a2,a3):n:u0(oE.z,a2,a3)),i}}],[{key:"type",get:function(){return"ViewportDepthNode"}}]),t}(el);u$.DEPTH_BASE="depthBase",u$.DEPTH="depth",u$.LINEAR_DEPTH="linearDepth";var u0=function(e,t,r){return e.add(t).div(t.sub(r))},u1=tw(function(e,t){var r=E(e,3),n=r[0],i=r[1],a=r[2];return!0===t.renderer.reversedDepthBuffer?a.sub(i).mul(n).sub(a):i.sub(a).mul(n).sub(i)}),u2=function(e,t,r){return t.add(e).mul(r).div(r.sub(t).mul(e))},u3=function(e,t,r){return t.mul(e.add(r)).div(e.mul(t.sub(r)))},u4=tw(function(e,t){var r=E(e,3),n=r[0],i=r[1],a=r[2];return!0===t.renderer.reversedDepthBuffer?i.mul(a).div(i.sub(a).mul(n).sub(i)):i.mul(a).div(a.sub(i).mul(n).sub(a))}),u5=function(e,t,r){t=t.max(1e-6).toVar();var n=nf(e.negate().div(t)),i=nf(r.div(t));return n.div(i)},u6=tx(u$,u$.DEPTH_BASE),u8=t_(u$,u$.DEPTH),u9=tx(u$,u$.LINEAR_DEPTH).setParameterLength(0,1),u7=u9(uJ());u8.assign=function(e){return u6(e)};var le=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:le.DEFAULT;return v(this,t),(e=p(this,t)).scope=r,e}return T(t,e),y(t,[{key:"setup",value:function(e){x(_(t.prototype),"setup",this).call(this,e);var r=e.clippingContext,n=r.intersectionPlanes,i=r.unionPlanes;return this.hardwareClipping=e.hardwareClipping,this.scope===le.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,i):this.scope===le.HARDWARE?this.setupHardwareClipping(i,e):this.setupDefault(n,i)}},{key:"setupAlphaToCoverage",value:function(e,t){var r=this;return tw(function(){var n=tF().toVar("distanceToPlane"),i=tF().toVar("distanceToGradient"),a=tF(1).toVar("clipOpacity"),o=t.length;if(!1===r.hardwareClipping&&o>0){var s=aR(t).setGroup(rA);uP(o,function(e){var t=e.i,r=s.element(t);n.assign(oE.dot(r.xyz).negate().add(r.w)),i.assign(n.fwidth().div(2)),a.mulAssign(ii(i.negate(),i,n))})}var u=e.length;if(u>0){var l=aR(e).setGroup(rA),c=tF(1).toVar("intersectionClipOpacity");uP(u,function(e){var t=e.i,r=l.element(t);n.assign(oE.dot(r.xyz).negate().add(r.w)),i.assign(n.fwidth().div(2)),c.mulAssign(ii(i.negate(),i,n).oneMinus())}),a.mulAssign(c.oneMinus())}t2.a.mulAssign(a),t2.a.equal(0).discard()})()}},{key:"setupDefault",value:function(e,t){var r=this;return tw(function(){var n=t.length;if(!1===r.hardwareClipping&&n>0){var i=aR(t).setGroup(rA);uP(n,function(e){var t=e.i,r=i.element(t);oE.dot(r.xyz).greaterThan(r.w).discard()})}var a=e.length;if(a>0){var o=aR(e).setGroup(rA),s=tL(!0).toVar("clipped");uP(a,function(e){var t=e.i,r=o.element(t);s.assign(oE.dot(r.xyz).greaterThan(r.w).and(s))}),s.discard()}})()}},{key:"setupHardwareClipping",value:function(e,t){var r=e.length;return t.enableHardwareClipping(r),tw(function(){var n=aR(e).setGroup(rA),i=aC(t.getClipDistance());uP(r,function(e){var t=e.i,r=n.element(t),a=oE.dot(r.xyz).sub(r.w).negate();i.element(t).assign(a)})})()}}],[{key:"type",get:function(){return"ClippingNode"}}]),t}(el);le.ALPHA_TO_COVERAGE="alphaToCoverage",le.DEFAULT="default",le.HARDWARE="hardware";var lt=tw(function(e){var t=E(e,1)[0];return nb(rV(1e4,nx(rV(17,t.x).add(rV(.1,t.y)))).mul(rO(.1,nF(nx(rV(13,t.y).add(t.x))))))}),lr=tw(function(e){var t=E(e,1)[0];return lt(tD(lt(t.xy),t.z))}),ln=tw(function(e){var t=E(e,1)[0],r=nX(nP(nU(t.xyz)),nP(nO(t.xyz))),n=tF(1).div(tF(.05).mul(r)).toVar("pixScale"),i=tD(nd(ng(nf(n))),nd(nm(nf(n)))),a=tD(lr(ng(i.x.mul(t.xyz))),lr(ng(i.y.mul(t.xyz)))),o=nb(nf(n)),s=rO(rV(o.oneMinus(),a.x),rV(o,a.y)),u=nj(o,o.oneMinus()),l=tV(s.mul(s).div(rV(2,u).mul(rI(1,u))),s.sub(rV(.5,u)).div(rI(1,u)),rI(1,rI(1,s).mul(rI(1,s)).div(rV(2,u).mul(rI(1,u)))));return ie(s.lessThan(u.oneMinus()).select(s.lessThan(u).select(l.x,l.y),l.z),1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]}),li=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[null,"vec4"])).isVertexColorNode=!0,r.index=e,r}return T(t,e),y(t,[{key:"getAttributeName",value:function(){var e=this.index;return"color"+(e>0?e:"")}},{key:"generate",value:function(e){var r=this.getAttributeName(e);return!0===e.hasGeometryAttribute(r)?x(_(t.prototype),"generate",this).call(this,e):e.generateConst(this.nodeType,new c.Jc(1,1,1,1))}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.index=this.index}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.index=e.index}}],[{key:"type",get:function(){return"VertexColorNode"}}]),t}(ap),la=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new li(e)},lo=function(e){function t(){var e;return v(this,t),(e=p(this,t)).isNodeMaterial=!0,e.fog=!0,e.lights=!1,e.lightsNode=null,e.envNode=null,e.aoNode=null,e.colorNode=null,e.normalNode=null,e.opacityNode=null,e.backdropNode=null,e.backdropAlphaNode=null,e.alphaTestNode=null,e.maskNode=null,e.maskShadowNode=null,e.positionNode=null,e.geometryNode=null,e.depthNode=null,e.receivedShadowPositionNode=null,e.castShadowPositionNode=null,e.receivedShadowNode=null,e.castShadowNode=null,e.outputNode=null,e.mrtNode=null,e.fragmentNode=null,e.vertexNode=null,e.contextNode=null,e}return T(t,e),y(t,[{key:"type",get:function(){return this.constructor.type},set:function(e){}},{key:"_getNodeChildren",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,a=Object.getOwnPropertyNames(this)[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(!0!==o.startsWith("_")){var s=this[o];s&&!0===s.isNode&&e.push({property:o,childNode:s})}}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return e}},{key:"customProgramCacheKey",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,a=this._getNodeChildren()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=o.property,u=o.childNode;e.push(H(s.slice(0,-4)),u.getCacheKey())}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return this.type+q(e)}},{key:"build",value:function(e){this.setup(e)}},{key:"setupObserver",value:function(e){return new V(e)}},{key:"setup",value:function(e){var t=this;e.context.setupNormal=function(){return ik(t.setupNormal(e),"NORMAL","vec3")},e.context.setupPositionView=function(){return t.setupPositionView(e)},e.context.setupModelViewProjection=function(){return t.setupModelViewProjection(e)};var r=e.renderer,n=r.getRenderTarget();e.addStack();var i=this.setupVertex(e),a=ik(this.vertexNode||i,"VERTEX");e.context.clipSpace=a,e.stack.outputNode=a,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();var o,s=this.setupClipping(e);if((!0===this.depthWrite||!0===this.depthTest)&&(null!==n?!0===n.depthBuffer&&this.setupDepth(e):!0===r.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);var u=this.setupLighting(e);null!==s&&e.stack.addToStack(s);var l=tH(u,t2.a).max(0);o=this.setupOutput(e,l),rh.assign(o);var c=null!==this.outputNode;if(c&&(o=this.outputNode),e.context.getOutput&&(o=e.context.getOutput(o,e)),null!==n){var d=r.getMRT(),h=this.mrtNode;null!==d?(c&&rh.assign(o),o=d,null!==h&&(o=d.merge(h))):null!==h&&(o=h)}}else{var f=this.fragmentNode;!0!==f.isOutputStructNode&&(f=f.convert(e.getOutputType())),o=this.setupOutput(e,f)}e.stack.outputNode=o,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}},{key:"setupClipping",value:function(e){if(null===e.clippingContext)return null;var t=e.clippingContext,r=t.unionPlanes,n=t.intersectionPlanes,i=null;if(r.length>0||n.length>0){var a=e.renderer.currentSamples;this.alphaToCoverage&&a>1?i=new le(le.ALPHA_TO_COVERAGE):e.stack.addToStack(new le)}return i}},{key:"setupHardwareClipping",value:function(e){if(e.hardwareClipping=!1,null!==e.clippingContext){var t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new le(le.HARDWARE)),e.hardwareClipping=!0)}}},{key:"setupDepth",value:function(e){var t=e.renderer,r=e.camera,n=this.depthNode;if(null===n){var i=t.getMRT();i&&i.has("depth")?n=i.get("depth"):!0===t.logarithmicDepthBuffer&&(n=r.isPerspectiveCamera?u5(oE.z,a2,a3):u0(oE.z,a2,a3))}null!==n&&u8.assign(n).toStack()}},{key:"setupPositionView",value:function(){return oy.mul(oN).xyz}},{key:"setupModelViewProjection",value:function(){return a4.mul(oE)}},{key:"setupVertex",value:function(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),us}},{key:"setupPosition",value:function(e){var t=e.object,r=e.geometry;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&uV(t),!0===t.isSkinnedMesh&&uM(t),this.displacementMap){var n=o9("displacementMap","texture"),i=o9("displacementScale","float"),a=o9("displacementBias","float");oN.addAssign(oP.normalize().mul(n.x.mul(i).add(a)))}return t.isBatchedMesh&&uk(t),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&u_(t),null!==this.positionNode&&oN.assign(ik(this.positionNode,"POSITION","vec3")),oN}},{key:"setupDiffuseColor",value:function(e){var t=e.object,r=e.geometry;null!==this.maskNode&&tL(this.maskNode).not().discard();var n=this.colorNode?tH(this.colorNode):sP;!0===this.vertexColors&&r.hasAttribute("color")&&(n=n.mul(la())),t.instanceColor&&(n=ub.mul(n)),t.isBatchedMesh&&t._colorsTexture&&(n=uN.mul(n)),t2.assign(n);var i=this.opacityNode?tF(this.opacityNode):sU;t2.a.assign(t2.a.mul(i));var a=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(a=null!==this.alphaTestNode?tF(this.alphaTestNode):sB,!0===this.alphaToCoverage?(t2.a=ii(a,a.add(nz(t2.a)),t2.a),t2.a.lessThanEqual(0).discard()):t2.a.lessThanEqual(a).discard()),!0===this.alphaHash&&t2.a.lessThan(ln(oN)).discard(),e.isOpaque()&&t2.a.assign(1)}},{key:"setupVariants",value:function(){}},{key:"setupOutgoingLight",value:function(){return!0===this.lights?tV(0):t2.rgb}},{key:"setupNormal",value:function(){return this.normalNode?tV(this.normalNode):sq}},{key:"setupEnvironment",value:function(){var e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?o9("envMap","cubeTexture"):o9("envMap","texture")),e}},{key:"setupLightMap",value:function(e){var t=null;return e.material.lightMap&&(t=new uH(ui)),t}},{key:"setupMaterialLightings",value:function(e){var t=[];if(!1===e.renderer.lighting.enabled)return t;var r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);var n=this.setupLightMap(e);return n&&n.isLightingNode&&t.push(n),e.context.ambientOcclusion&&t.push(new uz(e.context.ambientOcclusion)),t}},{key:"setupAmbientOcclusion",value:function(e){var t=this.aoNode;null===t&&e.material.aoMap&&(t=ua),e.context.getAO&&(t=e.context.getAO(t,e)),null!==t&&(rT.assign(t),e.context.ambientOcclusion=rT)}},{key:"setupLightingModel",value:function(){}},{key:"setupLighting",value:function(e){var t=e.material,r=this.backdropNode,n=this.backdropAlphaNode,i=this.emissiveNode,a=!0===this.lights||null!==this.lightsNode,o=!0===this.lights?this.setupMaterialLightings(e):[],s=a?this.lightsNode||e.lightsNode:null,u=this.setupOutgoingLight(e);return s&&(o.length>0||s.getScope().hasLights)?u=uW(s,this.setupLightingModel(e)||null,o,r,n):null!==r&&(u=tV(null!==n?n7(u,r,n):r)),(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(t4.assign(tV(i||sD)),u=u.add(t4)),u}},{key:"setupFog",value:function(e,t){var r=e.fogNode;return r&&(rh.assign(t),t=tH(r.toVar())),t}},{key:"setupPremultipliedAlpha",value:function(e,t){return an(t)}},{key:"setupOutput",value:function(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}},{key:"setDefaultValues",value:function(e){for(var t in e){var r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}var n=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(var i in n)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,i)&&void 0!==n[i].get&&Object.defineProperty(this.constructor.prototype,i,n[i])}},{key:"toJSON",value:function(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});var r=c.gd.prototype.toJSON.call(this,e);r.inputNodes={};var n=!0,i=!1,a=void 0;try{for(var o,s=this._getNodeChildren()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=u.property,d=u.childNode;r.inputNodes[l]=d.toJSON(e).uuid}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}function h(e){var t=[];for(var r in e){var n=e[r];delete n.metadata,t.push(n)}return t}if(t){var f=h(e.textures),p=h(e.images),v=h(e.nodes);f.length>0&&(r.textures=f),p.length>0&&(r.images=p),v.length>0&&(r.nodes=v)}return r}},{key:"copy",value:function(e){var t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(var r in t)if(void 0!==t[r].set&&void 0!==e[r]){var n=e[r];this[r]&&void 0!==this[r].copy?this[r].copy(n):this[r]=n}for(var i in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(i)&&void 0!==this[i]&&void 0!==e[i]){var a=e[i];this[i]&&void 0!==this[i].copy?this[i].copy(a):this[i]=a}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(function(e){return e.clone()}):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}}],[{key:"type",get:function(){return"NodeMaterial"}}]),t}(c.gd),ls=new c.ud,lu=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isLineBasicNodeMaterial=!0,r.setDefaultValues(ls),r.setValues(e),r}return T(t,e),y(t,null,[{key:"type",get:function(){return"LineBasicNodeMaterial"}}]),t}(lo),ll=new c.ne,lc=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isLineDashedNodeMaterial=!0,r.setDefaultValues(ll),r.dashOffset=0,r.offsetNode=null,r.dashScaleNode=null,r.dashSizeNode=null,r.gapSizeNode=null,r.setValues(e),r}return T(t,e),y(t,[{key:"setupVariants",value:function(){var e=this.offsetNode?tF(this.offsetNode):ut,t=this.dashScaleNode?tF(this.dashScaleNode):s8,r=this.dashSizeNode?tF(this.dashSizeNode):s9,n=this.gapSizeNode?tF(this.gapSizeNode):s7;rf.assign(r),rp.assign(n);var i=iw(av("lineDistance").mul(t));(e?i.add(e):i).mod(rf.add(rp)).greaterThan(rf).discard()}}],[{key:"type",get:function(){return"LineDashedNodeMaterial"}}]),t}(lo),ld=new c.ne,lh=t1("vec3","worldStart"),lf=t1("vec3","worldEnd"),lp=t1("float","lineDistance"),lv=t1("vec4","worldPos"),lg=tw(function(e){var t=e.start,r=e.end,n=a4.element(2).element(2),i=a4.element(3).element(2);return n.greaterThan(0).select(i.negate().div(n.add(1)),i.mul(-.5).div(n)).sub(t.z).div(r.z.sub(t.z))},{start:"vec4",end:"vec4",return:"float"}),lm=tw(function(e){var t=e.p1,r=e.p2,n=e.p3,i=e.p4,a=t.sub(n),o=i.sub(n),s=r.sub(t),u=a.dot(o),l=o.dot(s),c=a.dot(s),d=o.dot(o),h=s.dot(s).mul(d).sub(l.mul(l)),f=u.mul(l).sub(c.mul(d)).div(h).clamp(),p=u.add(l.mul(f)).div(d).clamp();return tD(f,p)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"}),ly=tw(function(e){var t,r,n=e.material,i=n._useDash,a=n._useWorldUnits,o=av("instanceStart"),s=av("instanceEnd"),u=tH(oy.mul(tH(o,1))).toVar("start"),l=tH(oy.mul(tH(s,1))).toVar("end");i&&(t=tF(av("instanceDistanceStart")).toVar("distanceStart"),r=tF(av("instanceDistanceEnd")).toVar("distanceEnd")),a&&(lh.assign(u.xyz),lf.assign(l.xyz));var c=aD.z.div(aD.w),d=a4.element(2).element(3).equal(-1);if(tR(d,function(){tR(u.z.lessThan(0).and(l.z.greaterThan(0)),function(){var e=lg({start:u,end:l});l.assign(tH(n7(u.xyz,l.xyz,e),l.w)),i&&r.assign(n7(t,r,e))}).ElseIf(l.z.lessThan(0).and(u.z.greaterThanEqual(0)),function(){var e=lg({start:l,end:u});u.assign(tH(n7(l.xyz,u.xyz,e),u.w)),i&&t.assign(n7(r,t,e))})}),i){var h=n.dashScaleNode?tF(n.dashScaleNode):s8,f=n.offsetNode?tF(n.offsetNode):ut,p=oS.y.lessThan(.5).select(h.mul(t),h.mul(r));p=p.add(f),lp.assign(p)}var v=a4.mul(u),g=a4.mul(l),m=v.xyz.div(v.w),y=g.xyz.div(g.w),b=y.xy.sub(m.xy).toVar();b.x.assign(b.x.mul(c)),b.assign(b.dot(b).greaterThan(1e-12).select(b.normalize(),tD(1,0)));var x=tH().toVar();if(a){var _=l.xyz.sub(u.xyz).normalize(),T=n7(u.xyz,l.xyz,.5).normalize(),S=_.cross(T).normalize(),N=_.cross(S);lv.assign(oS.y.lessThan(.5).select(u,l));var k=ue.mul(.5);lv.addAssign(tH(oS.x.lessThan(0).select(S.mul(k),S.mul(k).negate()),0)),i||(lv.addAssign(tH(oS.y.lessThan(.5).select(_.mul(k).negate(),_.mul(k)),0)),lv.addAssign(tH(N.mul(k),0)),tR(oS.y.greaterThan(1).or(oS.y.lessThan(0)),function(){lv.subAssign(tH(N.mul(2).mul(k),0))})),x.assign(a4.mul(lv));var w=tV().toVar();w.assign(oS.y.lessThan(.5).select(m,y)),x.z.assign(w.z.mul(x.w))}else{var A=tD(b.y,b.x.negate()).toVar("offset");b.x.assign(b.x.div(c)),A.x.assign(A.x.div(c)),A.assign(oS.x.lessThan(0).select(A.negate(),A)),tR(oS.y.lessThan(0),function(){A.assign(A.sub(b))}).ElseIf(oS.y.greaterThan(1),function(){A.assign(A.add(b))}),A.assign(A.mul(ue)),A.assign(A.div(aD.w.div(aF))),x.assign(oS.y.lessThan(.5).select(v,g)),A.assign(A.mul(x.w)),x.assign(x.add(tH(A,0,0))),tR(d.and(x.w.lessThanEqual(0)),function(){x.assign(tH(0,0,2,1))})}return x})(),lb=tw(function(e){var t=e.material,r=e.renderer,n=t._useAlphaToCoverage,i=t._useDash,a=t._useWorldUnits,o=ag();if(i){var s=t.dashSizeNode?tF(t.dashSizeNode):s9,u=t.gapSizeNode?tF(t.gapSizeNode):s7;rf.assign(s),rp.assign(u),o.y.lessThan(-1).or(o.y.greaterThan(1)).discard(),lp.mod(rf.add(rp)).greaterThan(rf).discard()}var l=tF(1).toVar("alpha");if(a){var c=lv.xyz.normalize().mul(1e5),d=lf.sub(lh),h=lm({p1:lh,p2:lf,p3:tV(0,0,0),p4:c}),f=lh.add(d.mul(h.x)),p=c.mul(h.y),v=f.sub(p).length().div(ue);if(!i)if(n&&r.currentSamples>0){var g=v.fwidth();l.assign(ii(g.negate().add(.5),g.add(.5),v).oneMinus())}else v.greaterThan(.5).discard()}else if(n&&r.currentSamples>0){var m=o.x,y=o.y.greaterThan(0).select(o.y.sub(1),o.y.add(1)),b=m.mul(m).add(y.mul(y)),x=tF(b.fwidth()).toVar("dlen");tR(o.y.abs().greaterThan(1),function(){l.assign(ii(x.oneMinus(),x.add(1),b).oneMinus())})}else tR(o.y.abs().greaterThan(1),function(){var e=o.x,t=o.y.greaterThan(0).select(o.y.sub(1),o.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return l})(),lx=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this,t),(e=p(this,t)).isLine2NodeMaterial=!0,e.setDefaultValues(ld),e.vertexColors=r.vertexColors,e.dashOffset=0,e.offsetNode=null,e.dashScaleNode=null,e.dashSizeNode=null,e.gapSizeNode=null,e.blending=c.m,e._useDash=r.dashed,e._useAlphaToCoverage=!0,e._useWorldUnits=!1,e.setValues(r),e}return T(t,e),y(t,[{key:"setupDiffuseColor",value:function(e){if(x(_(t.prototype),"setupDiffuseColor",this).call(this,e),t2.a.mulAssign(lb),!0===this.vertexColors&&e.geometry.hasAttribute("instanceColorStart")){var r=av("instanceColorStart"),n=av("instanceColorEnd"),i=oS.y.lessThan(.5).select(r,n);t2.rgb.mulAssign(i)}this.transparent&&t2.rgb.assign(t2.rgb.mul(t2.a).add(uQ().rgb.mul(t2.a.oneMinus())))}},{key:"setupModelViewProjection",value:function(){return ly}},{key:"lineColorNode",get:function(){return this.colorNode},set:function(e){(0,c.yc)('Line2NodeMaterial: "lineColorNode" has been deprecated. Use "colorNode" instead.'),this.colorNode=e}},{key:"worldUnits",get:function(){return this._useWorldUnits},set:function(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}},{key:"dashed",get:function(){return this._useDash},set:function(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}},{key:"alphaToCoverage",get:function(){return this._useAlphaToCoverage},set:function(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}],[{key:"type",get:function(){return"Line2NodeMaterial"}}]),t}(lo),l_=new c.ie,lT=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshNormalNodeMaterial=!0,r.setDefaultValues(l_),r.setValues(e),r}return T(t,e),y(t,[{key:"setupDiffuseColor",value:function(){var e=this.opacityNode?tF(this.opacityNode):sU;t2.assign(iB(tH(sN(oO),e),c.Ib))}}],[{key:"type",get:function(){return"MeshNormalNodeMaterial"}}]),t}(lo),lS=tw(function(e){var t=E(e,1)[0],r=void 0===t?oA:t;return tD(r.z.atan(r.x).mul(1/(2*Math.PI)).add(.5),r.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))}),lN=tw(function(e){var t=E(e,1)[0],r=void 0===t?ag():t,n=r.x.sub(.5).mul(2*Math.PI),i=r.y.sub(.5).mul(Math.PI),a=i.cos();return tV(a.mul(n.cos()),i.sin(),a.mul(n.sin()))}),lk=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v(this,t),(e=p(this,t,[r,r,n])).isCubeRenderTarget=!0;var i={width:r,height:r,depth:1};return e.texture=new c.Ad([i,i,i,i,i,i]),e._setTextureOptions(n),e.texture.isRenderTargetTexture=!0,e}return T(t,e),y(t,[{key:"fromEquirectangularTexture",value:function(e,t){var r=t.minFilter,n=t.generateMipmaps;t.generateMipmaps=!0,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;var i=new c.Ed(5,5,5),a=lS(oA),o=new lo;o.colorNode=aS(t,a,0),o.side=c.k,o.blending=c.m;var s=new c.ld(i,o),u=new c.Vc;u.add(s),t.minFilter===c.sa&&(t.minFilter=c.qa);var l=new c.Ie(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.generateMipmaps=n,s.geometry.dispose(),s.material.dispose(),this}},{key:"clear",value:function(e){for(var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=!(arguments.length>3)||void 0===arguments[3]||arguments[3],i=e.getRenderTarget(),a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,r,n);e.setRenderTarget(i)}}]),t}(c.Kc),lw=new WeakMap;function lA(e){var t=e.target;t.removeEventListener("dispose",lA);var r=lw.get(t);void 0!==r&&(lw.delete(t),r.dispose())}function lE(e,t){t===c.ha?e.mapping=c.fa:t===c.ia&&(e.mapping=c.ga)}var lR=tx(function(e){function t(e){v(this,t),(r=p(this,t,["vec3"])).envNode=e,r._cubeTexture=null,r._cubeTextureNode=o2(null);var r,n=new c.Ad;return n.isRenderTargetTexture=!0,r._defaultTexture=n,r.updateBeforeType=et.RENDER,r}return T(t,e),y(t,[{key:"updateBefore",value:function(e){var t=e.renderer,r=e.material,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){var i=n.isTextureNode?n.value:r[n.property];if(i&&i.isTexture){var a=i.mapping;if(a===c.ha||a===c.ia){if(lw.has(i)){var o=lw.get(i);lE(o,i.mapping),this._cubeTexture=o}else{var s=i.image;if(null!=s&&s.height>0){var u=new lk(s.height);u.fromEquirectangularTexture(t,i),lE(u.texture,i.mapping),this._cubeTexture=u.texture,lw.set(i,u.texture),i.addEventListener("dispose",lA)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}},{key:"setup",value:function(e){return this.updateBefore(e),this._cubeTextureNode}}],[{key:"type",get:function(){return"CubeMapNode"}}]),t}(eh)).setParameterLength(1),lC=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).envNode=r,e}return T(t,e),y(t,[{key:"setup",value:function(e){e.context.environment=lR(this.envNode)}}],[{key:"type",get:function(){return"BasicEnvironmentNode"}}]),t}(uG),lM=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).lightMapNode=r,e}return T(t,e),y(t,[{key:"setup",value:function(e){var t=tF(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}],[{key:"type",get:function(){return"BasicLightMapNode"}}]),t}(uG),lF=function(){function e(){v(this,e)}return y(e,[{key:"start",value:function(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}},{key:"finish",value:function(){}},{key:"direct",value:function(){}},{key:"directRectArea",value:function(){}},{key:"indirect",value:function(){}},{key:"ambientOcclusion",value:function(){}}]),e}(),lB=function(e){function t(){return v(this,t),p(this,t)}return T(t,e),y(t,[{key:"indirect",value:function(e){var t=e.context,r=t.ambientOcclusion,n=t.reflectedLight,i=t.irradianceLightMap;n.indirectDiffuse.assign(tH(0)),i?n.indirectDiffuse.addAssign(i):n.indirectDiffuse.addAssign(tH(1,1,1,0)),n.indirectDiffuse.mulAssign(r),n.indirectDiffuse.mulAssign(t2.rgb)}},{key:"finish",value:function(e){var t=e.material,r=e.context.outgoingLight,n=e.context.environment;if(n)switch(t.combine){case c.V:r.rgb.assign(n7(r.rgb,r.rgb.mul(n.rgb),sG.mul(sz)));break;case c.W:r.rgb.assign(n7(r.rgb,n.rgb,sG.mul(sz)));break;case c.X:r.rgb.addAssign(n.rgb.mul(sG.mul(sz)));break;default:(0,c.wc)("BasicLightingModel: Unsupported .combine value:",t.combine)}}}]),t}(lF),lP=new c.kd,lL=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshBasicNodeMaterial=!0,r.lights=!0,r.setDefaultValues(lP),r.setValues(e),r}return T(t,e),y(t,[{key:"setupNormal",value:function(){return oF(oD)}},{key:"setupEnvironment",value:function(e){var r=x(_(t.prototype),"setupEnvironment",this).call(this,e);return r?new lC(r):null}},{key:"setupLightMap",value:function(e){var t=null;return e.material.lightMap&&(t=new lM(ui)),t}},{key:"setupOutgoingLight",value:function(){return t2.rgb}},{key:"setupLightingModel",value:function(){return new lB}}],[{key:"type",get:function(){return"MeshBasicNodeMaterial"}}]),t}(lo),lD=tw(function(e){var t=e.f0,r=e.f90,n=e.dotVH,i=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return t.mul(i.oneMinus()).add(r.mul(i))}),lU=tw(function(e){return e.diffuseColor.mul(1/Math.PI)}),lO=tw(function(e){var t=e.dotNH;return rd.mul(tF(.5)).add(1).mul(tF(1/Math.PI)).mul(t.pow(rd))}),lI=tw(function(e){var t=e.lightDirection.add(oR).normalize(),r=oO.dot(t).clamp(),n=lD({f0:ru,f90:1,dotVH:oR.dot(t).clamp()}),i=tF(.25),a=lO({dotNH:r});return n.mul(i).mul(a)}),lV=function(e){function t(){var e,r=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return v(this,t),(e=p(this,t)).specular=r,e}return T(t,e),y(t,[{key:"direct",value:function(e){var t=e.lightDirection,r=e.lightColor,n=e.reflectedLight,i=oO.dot(t).clamp().mul(r);n.directDiffuse.addAssign(i.mul(lU({diffuseColor:t2.rgb}))),!0===this.specular&&n.directSpecular.addAssign(i.mul(lI({lightDirection:t})).mul(sG))}},{key:"indirect",value:function(e){var t=e.context,r=t.ambientOcclusion,n=t.irradiance,i=t.reflectedLight;i.indirectDiffuse.addAssign(n.mul(lU({diffuseColor:t2}))),i.indirectDiffuse.mulAssign(r)}}]),t}(lB),lG=new c.je,lz=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshLambertNodeMaterial=!0,r.lights=!0,r.setDefaultValues(lG),r.setValues(e),r}return T(t,e),y(t,[{key:"setupEnvironment",value:function(e){var r=x(_(t.prototype),"setupEnvironment",this).call(this,e);return r?new lC(r):null}},{key:"setupLightingModel",value:function(){return new lV(!1)}}],[{key:"type",get:function(){return"MeshLambertNodeMaterial"}}]),t}(lo),lW=new c.ge,lH=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshPhongNodeMaterial=!0,r.lights=!0,r.shininessNode=null,r.specularNode=null,r.setDefaultValues(lW),r.setValues(e),r}return T(t,e),y(t,[{key:"setupEnvironment",value:function(e){var r=x(_(t.prototype),"setupEnvironment",this).call(this,e);return r?new lC(r):null}},{key:"setupLightingModel",value:function(){return new lV}},{key:"setupVariants",value:function(){var e=(this.shininessNode?tF(this.shininessNode):sL).max(1e-4);rd.assign(e);var t=this.specularNode||sO;ru.assign(t)}}],[{key:"type",get:function(){return"MeshPhongNodeMaterial"}}]),t}(lo),lq=tw(function(e){if(!1===e.geometry.hasAttribute("normal"))return tF(0);var t=oD.dFdx().abs().max(oD.dFdy().abs());return t.x.max(t.y).max(t.z)}),lj=tw(function(e){var t=e.roughness,r=lq(),n=t.max(.0525);return(n=n.add(r)).min(1)}),lX=tw(function(e){var t=e.alpha,r=e.dotNL,n=e.dotNV,i=t.pow2(),a=r.mul(i.add(i.oneMinus().mul(n.pow2())).sqrt()),o=n.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt());return rG(.5,a.add(o).max(ne))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),lK=tw(function(e){var t=e.alphaT,r=e.alphaB,n=e.dotTV,i=e.dotBV,a=e.dotTL,o=e.dotBL,s=e.dotNV,u=e.dotNL,l=u.mul(tV(t.mul(n),r.mul(i),s).length()),c=s.mul(tV(t.mul(a),r.mul(o),u).length());return rG(.5,l.add(c).max(ne))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),lY=tw(function(e){var t=e.alpha,r=e.dotNH,n=t.pow2(),i=r.pow2().mul(n.oneMinus()).oneMinus();return n.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),lQ=tF(1/Math.PI),lZ=tw(function(e){var t=e.alphaT,r=e.alphaB,n=e.dotNH,i=e.dotTH,a=e.dotBH,o=t.mul(r),s=tV(r.mul(i),t.mul(a),o.mul(n)),u=s.dot(s),l=o.div(u);return lQ.mul(o.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),lJ=tw(function(e){var t,r,n=e.lightDirection,i=e.f0,a=e.f90,o=e.roughness,s=e.f,u=e.normalView,l=void 0===u?oO:u,c=e.USE_IRIDESCENCE,d=e.USE_ANISOTROPY,h=o.pow2(),f=n.add(oR).normalize(),p=l.dot(n).clamp(),v=l.dot(oR).clamp(),g=l.dot(f).clamp(),m=lD({f0:i,f90:a,dotVH:oR.dot(f).clamp()});if(tf(c)&&(m=rt.mix(m,s)),tf(d)){var y=ro.dot(n),b=ro.dot(oR),x=ro.dot(f),_=rs.dot(n),T=rs.dot(oR),S=rs.dot(f);t=lK({alphaT:ri,alphaB:h,dotTV:b,dotBV:T,dotTL:y,dotBL:_,dotNV:v,dotNL:p}),r=lZ({alphaT:ri,alphaB:h,dotNH:g,dotTH:x,dotBH:S})}else t=lX({alpha:h,dotNL:p,dotNV:v}),r=lY({alpha:h,dotNH:g});return m.mul(t).mul(r)}),l$=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]),l0=null,l1=tw(function(e){var t=e.roughness,r=e.dotNV;null===l0&&((l0=new c.nd(l$,16,16,c.Oa,c.Ba)).name="DFG_LUT",l0.minFilter=c.qa,l0.magFilter=c.qa,l0.wrapS=c.la,l0.wrapT=c.la,l0.generateMipmaps=!1,l0.needsUpdate=!0);var n=tD(t,r);return aS(l0,n).rg}),l2=tw(function(e){var t=e.lightDirection,r=e.f0,n=e.f90,i=e.roughness,a=lJ({lightDirection:t,f0:r,f90:n,roughness:i,f:e.f,USE_IRIDESCENCE:e.USE_IRIDESCENCE,USE_ANISOTROPY:e.USE_ANISOTROPY}),o=oO.dot(t).clamp(),s=l1({roughness:i,dotNV:oO.dot(oR).clamp()}),u=l1({roughness:i,dotNV:o}),l=r.mul(s.x).add(n.mul(s.y)),c=r.mul(u.x).add(n.mul(u.y)),d=s.x.add(s.y),h=u.x.add(u.y),f=tF(1).sub(d),p=tF(1).sub(h),v=r.add(r.oneMinus().mul(.047619)),g=l.mul(c).mul(v).div(tF(1).sub(f.mul(p).mul(v).mul(v)).add(ne)),m=f.mul(p),y=g.mul(m);return a.add(y)}),l3=tw(function(e){var t=e.dotNV,r=e.specularColor,n=e.specularF90,i=l1({dotNV:t,roughness:e.roughness});return r.mul(i.x).add(n.mul(i.y))}),l4=tw(function(e){var t=e.f,r=e.f90,n=e.dotVH.oneMinus().saturate(),i=n.mul(n),a=n.mul(i,i).clamp(0,.9999);return t.sub(tV(r).mul(a)).div(a.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),l5=tw(function(e){var t=e.roughness,r=e.dotNH,n=t.pow2(),i=tF(1).div(n),a=r.pow2().oneMinus().max(.0078125);return tF(2).add(i).mul(a.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),l6=tw(function(e){var t=e.dotNV,r=e.dotNL;return tF(1).div(tF(4).mul(r.add(t).sub(r.mul(t))))}).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),l8=tw(function(e){var t=e.lightDirection,r=t.add(oR).normalize(),n=oO.dot(t).clamp(),i=oO.dot(oR).clamp(),a=l5({roughness:re,dotNH:oO.dot(r).clamp()}),o=l6({dotNV:i,dotNL:n});return t7.mul(a).mul(o)}),l9=tw(function(e){var t=e.N,r=e.V,n=tD(e.roughness,t.dot(r).saturate().oneMinus().sqrt());return n.assign(n.mul(.984375).add(.0078125)),n}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),l7=tw(function(e){var t=e.f,r=t.length();return nX(r.mul(r).add(t.z).div(r.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),ce=tw(function(e){var t=e.v1,r=e.v2,n=t.dot(r),i=n.abs().toVar(),a=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),o=i.add(4.1616724).mul(i).add(3.417594).toVar(),s=a.div(o),u=n.greaterThan(0).select(s,nX(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(s));return t.cross(r).mul(u)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),ct=tw(function(e){var t=e.N,r=e.V,n=e.P,i=e.mInv,a=e.p0,o=e.p1,s=e.p2,u=e.p3,l=o.sub(a).toVar(),c=u.sub(a).toVar(),d=l.cross(c),h=tV().toVar();return tR(d.dot(n.sub(a)).greaterThanEqual(0),function(){var e=r.sub(t.mul(r.dot(t))).normalize(),l=t.cross(e).negate(),c=i.mul(tY(e,l,t).transpose()).toVar(),d=c.mul(a.sub(n)).normalize().toVar(),f=c.mul(o.sub(n)).normalize().toVar(),p=c.mul(s.sub(n)).normalize().toVar(),v=c.mul(u.sub(n)).normalize().toVar(),g=tV(0).toVar();g.addAssign(ce({v1:d,v2:f})),g.addAssign(ce({v1:f,v2:p})),g.addAssign(ce({v1:p,v2:v})),g.addAssign(ce({v1:v,v2:d})),h.assign(tV(l7({f:g})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),cr=1/6,cn=function(e){return rV(cr,rV(e,rV(e,e.negate().add(3)).sub(3)).add(1))},ci=function(e){return rV(cr,rV(e,rV(e,rV(3,e).sub(6))).add(4))},ca=function(e){return rV(cr,rV(e,rV(e,rV(-3,e).add(3)).add(3)).add(1))},co=function(e){return rV(cr,n0(e,3))},cs=function(e){return cn(e).add(ci(e))},cu=function(e){return ca(e).add(co(e))},cl=function(e){return rO(-1,ci(e).div(cn(e).add(ci(e))))},cc=function(e){return rO(1,co(e).div(ca(e).add(co(e))))},cd=function(e,t,r){var n=rV(e.uvNode,t.zw).add(.5),i=ng(n),a=nb(n),o=cs(a.x),s=cu(a.x),u=cl(a.x),l=cc(a.x),c=cl(a.y),d=cc(a.y),h=tD(i.x.add(u),i.y.add(c)).sub(.5).mul(t.xy),f=tD(i.x.add(l),i.y.add(c)).sub(.5).mul(t.xy),p=tD(i.x.add(u),i.y.add(d)).sub(.5).mul(t.xy),v=tD(i.x.add(l),i.y.add(d)).sub(.5).mul(t.xy),g=cs(a.y).mul(rO(o.mul(e.sample(h).level(r)),s.mul(e.sample(f).level(r)))),m=cu(a.y).mul(rO(o.mul(e.sample(p).level(r)),s.mul(e.sample(v).level(r))));return g.add(m)},ch=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tD(r.size(tB(n))),a=tD(r.size(tB(n.add(1)))),o=rG(1,i),s=rG(1,a),u=cd(r,tH(o,i),ng(n)),l=cd(r,tH(s,a),nm(n));return nb(n).mix(u,l)}),cf=tw(function(e){var t=E(e,2),r=t[0],n=t[1].mul(ay(r));return ch(r,n)}),cp=tw(function(e){var t=E(e,5),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=tV(ir(n.negate(),ny(r),rG(1,a))),u=tV(nP(o[0].xyz),nP(o[1].xyz),nP(o[2].xyz));return ny(s).mul(i.mul(u))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),cv=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return r.mul(ie(n.mul(2).sub(2),0,1))}).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),cg=uK(),cm=uQ(),cy=tw(function(e,t){var r=E(e,3),n=r[0],i=r[1],a=r[2];return ch((t.material.side===c.k?cg:cm).sample(n),nf(aP.x).mul(cv(i,a)))}),cb=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2];return tR(i.notEqual(0),function(){return nc(nh(n).negate().div(i).negate().mul(r))}),tV(1)}).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),cx=tw(function(e){var t,r,n=E(e,15),i=n[0],a=n[1],o=n[2],s=n[3],u=n[4],l=n[5],c=n[6],d=n[7],h=n[8],f=n[9],p=n[10],v=n[11],g=n[12],m=n[13],y=n[14];if(y){t=tH().toVar(),r=tV().toVar();var b=p.sub(1).mul(y.mul(.025)),x=tV(p.sub(b),p,p.add(b));uP({start:0,end:3},function(e){var n=e.i,u=x.element(n),l=cp(i,a,v,u,d),p=c.add(l),y=f.mul(h.mul(tH(p,1))),b=tD(y.xy.div(y.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(tD(b.x,b.y.oneMinus()));var _=cy(b,o,u);t.element(n).assign(_.element(n)),t.a.addAssign(_.a),r.element(n).assign(s.element(n).mul(cb(nP(l),g,m).element(n)))}),t.a.divAssign(3)}else{var _=cp(i,a,v,p,d),T=c.add(_),S=f.mul(h.mul(tH(T,1))),N=tD(S.xy.div(S.w)).toVar();N.addAssign(1),N.divAssign(2),N.assign(tD(N.x,N.y.oneMinus())),t=cy(N,o,p),r=s.mul(cb(nP(_),g,m))}var k=r.rgb.mul(t.rgb),w=tV(l3({dotNV:i.dot(a).clamp(),specularColor:u,specularF90:l,roughness:o})),A=r.r.add(r.g,r.b).div(3);return tH(w.oneMinus().mul(k),t.a.oneMinus().mul(A).oneMinus())}),c_=tY(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cT=function(e,t){return e.sub(t).div(e.add(t)).pow2()},cS=tw(function(e){var t,r=e.outsideIOR,n=e.eta2,i=e.cosTheta1,a=e.thinFilmThickness,o=e.baseF0,s=n7(r,n,ii(0,.03,a)),u=r.div(s).pow2().mul(i.pow2().oneMinus()).oneMinus();tR(u.lessThan(0),function(){return tV(1)});var l=u.sqrt(),c=lD({f0:cT(s,r),f90:1,dotVH:i}),d=c.oneMinus(),h=s.lessThan(r).select(Math.PI,0),f=tF(Math.PI).sub(h),p=(t=o.clamp(0,.9999).sqrt(),tV(1).add(t).div(tV(1).sub(t))),v=lD({f0:cT(p,s.toVec3()),f90:1,dotVH:l}),g=tV(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),m=s.mul(a,l,2),y=tV(f).add(g),b=c.mul(v).clamp(1e-5,.9999),x=b.sqrt(),_=d.pow2().mul(v).div(tV(1).sub(b)),T=c.add(_).toVar(),S=_.sub(d).toVar();return uP({start:1,end:2,condition:"<=",name:"m"},function(e){var t,r,n,i,a,o,s,u,l=e.m;S.mulAssign(x);var c=(t=tF(l).mul(m),r=tF(l).mul(y),n=t.mul(2*Math.PI*1e-9),i=tV(54856e-17,44201e-17,52481e-17),a=tV(1681e3,1795300,2208400),o=tV(43278e5,93046e5,66121e5),s=tF(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(r.x).cos()).mul(n.pow2().mul(-45282e5).exp()),u=tV((u=i.mul(o.mul(2*Math.PI).sqrt()).mul(a.mul(n).add(r).cos()).mul(n.pow2().negate().mul(o).exp())).x.add(s),u.y,u.z).div(10685e-11),c_.mul(u)).mul(2);T.addAssign(S.mul(c))}),T.max(tV(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),cN=tw(function(e){var t=e.normal,r=e.viewDir,n=e.roughness,i=t.dot(r).saturate(),a=n.mul(n),o=n.add(.1).reciprocal(),s=tF(-1.9362).add(n.mul(1.0678)).add(a.mul(.4573)).sub(o.mul(.8469)),u=tF(-.6014).add(n.mul(.5538)).sub(a.mul(.467)).sub(o.mul(.1255));return s.mul(i).add(u).exp().saturate()}),ck=tV(.04),cw=tF(1),cA=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return v(this,t),(e=p(this,t)).clearcoat=r,e.sheen=n,e.iridescence=i,e.anisotropy=a,e.transmission=o,e.dispersion=s,e.clearcoatRadiance=null,e.clearcoatSpecularDirect=null,e.clearcoatSpecularIndirect=null,e.sheenSpecularDirect=null,e.sheenSpecularIndirect=null,e.iridescenceFresnel=null,e.iridescenceF0=null,e.iridescenceF0Dielectric=null,e.iridescenceF0Metallic=null,e}return T(t,e),y(t,[{key:"start",value:function(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=tV().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=tV().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=tV().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=tV().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=tV().toVar("sheenSpecularIndirect")),!0===this.iridescence){var r=oO.dot(oR).clamp(),n=cS({outsideIOR:tF(1),eta2:rr,cosTheta1:r,thinFilmThickness:rn,baseF0:ru}),i=cS({outsideIOR:tF(1),eta2:rr,cosTheta1:r,thinFilmThickness:rn,baseF0:t2.rgb});this.iridescenceFresnel=n7(n,i,t6),this.iridescenceF0Dielectric=l4({f:n,f90:1,dotVH:r}),this.iridescenceF0Metallic=l4({f:i,f90:1,dotVH:r}),this.iridescenceF0=n7(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,t6)}if(!0===this.transmission){var a=a7.sub(ow).normalize(),o=e.context;o.backdrop=cx(oI,a,t5,t3,rl,rc,ow,od,a6,a4,rg,ry,rx,rb,this.dispersion?r_:null),o.backdropAlpha=rm,t2.a.mulAssign(n7(1,o.backdrop.a,rm))}x(_(t.prototype),"start",this).call(this,e)}},{key:"computeMultiscattering",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=l1({roughness:t5,dotNV:oO.dot(oR).clamp()}),o=i?rt.mix(n,i):n,s=o.mul(a.x).add(r.mul(a.y)),u=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),c=s.mul(l).div(u.mul(l).oneMinus());e.addAssign(s),t.addAssign(c.mul(u))}},{key:"direct",value:function(e){var t=e.lightDirection,r=e.lightColor,n=e.reflectedLight,i=oO.dot(t).clamp().mul(r).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(i.mul(l8({lightDirection:t})));var a=cN({normal:oO,viewDir:oR,roughness:re}),o=cN({normal:oO,viewDir:t,roughness:re}),s=t7.r.max(t7.g).max(t7.b).mul(a.max(o)).oneMinus();i.mulAssign(s)}if(!0===this.clearcoat){var u=oV.dot(t).clamp().mul(r);this.clearcoatSpecularDirect.addAssign(u.mul(lJ({lightDirection:t,f0:ck,f90:cw,roughness:t9,normalView:oV})))}n.directDiffuse.addAssign(i.mul(lU({diffuseColor:t3}))),n.directSpecular.addAssign(i.mul(l2({lightDirection:t,f0:rl,f90:1,roughness:t5,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}},{key:"directRectArea",value:function(e){var t=e.lightColor,r=e.lightPosition,n=e.halfWidth,i=e.halfHeight,a=e.reflectedLight,o=e.ltc_1,s=e.ltc_2,u=r.add(n).sub(i),l=r.sub(n).sub(i),c=r.sub(n).add(i),d=r.add(n).add(i),h=oE.toVar(),f=l9({N:oO,V:oR,roughness:t5}),p=o.sample(f).toVar(),v=s.sample(f).toVar(),g=tY(tV(p.x,0,p.y),tV(0,1,0),tV(p.z,0,p.w)).toVar(),m=rl.mul(v.x).add(rc.sub(rl).mul(v.y)).toVar();if(a.directSpecular.addAssign(t.mul(m).mul(ct({N:oO,V:oR,P:h,mInv:g,p0:u,p1:l,p2:c,p3:d}))),a.directDiffuse.addAssign(t.mul(t3).mul(ct({N:oO,V:oR,P:h,mInv:tY(1,0,0,0,1,0,0,0,1),p0:u,p1:l,p2:c,p3:d}))),!0===this.clearcoat){var y=l9({N:oV,V:oR,roughness:t9}),b=o.sample(y),x=s.sample(y),_=tY(tV(b.x,0,b.y),tV(0,1,0),tV(b.z,0,b.w)),T=ck.mul(x.x).add(cw.sub(ck).mul(x.y));this.clearcoatSpecularDirect.addAssign(t.mul(T).mul(ct({N:oV,V:oR,P:h,mInv:_,p0:u,p1:l,p2:c,p3:d})))}}},{key:"indirect",value:function(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}},{key:"indirectDiffuse",value:function(e){var t=e.context,r=t.irradiance,n=t.reflectedLight,i=r.mul(lU({diffuseColor:t3})).toVar();if(!0===this.sheen){var a=cN({normal:oO,viewDir:oR,roughness:re}),o=t7.r.max(t7.g).max(t7.b).mul(a).oneMinus();i.mulAssign(o)}n.indirectDiffuse.addAssign(i)}},{key:"indirectSpecular",value:function(e){var t=e.context,r=t.radiance,n=t.iblIrradiance,i=t.reflectedLight;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(n.mul(t7,cN({normal:oO,viewDir:oR,roughness:re}))),!0===this.clearcoat){var a=l3({dotNV:oV.dot(oR).clamp(),specularColor:ck,specularF90:cw,roughness:t9});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(a))}var o=tV().toVar("singleScatteringDielectric"),s=tV().toVar("multiScatteringDielectric"),u=tV().toVar("singleScatteringMetallic"),l=tV().toVar("multiScatteringMetallic");this.computeMultiscattering(o,s,rc,ru,this.iridescenceF0Dielectric),this.computeMultiscattering(u,l,rc,t2.rgb,this.iridescenceF0Metallic);var c=n7(o,u,t6),d=n7(s,l,t6),h=o.add(s),f=t3.mul(h.oneMinus()),p=n.mul(1/Math.PI),v=r.mul(c).add(d.mul(p)).toVar(),g=f.mul(p).toVar();if(!0===this.sheen){var m=cN({normal:oO,viewDir:oR,roughness:re}),y=t7.r.max(t7.g).max(t7.b).mul(m).oneMinus();v.mulAssign(y),g.mulAssign(y)}i.indirectSpecular.addAssign(v),i.indirectDiffuse.addAssign(g)}},{key:"ambientOcclusion",value:function(e){var t=e.context,r=t.ambientOcclusion,n=t.reflectedLight,i=oO.dot(oR).clamp().add(r),a=t5.mul(-16).oneMinus().negate().exp2(),o=r.sub(i.pow(a).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(r),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(r),n.indirectDiffuse.mulAssign(r),n.indirectSpecular.mulAssign(o)}},{key:"finish",value:function(e){var t=e.context.outgoingLight;if(!0===this.clearcoat){var r=lD({dotVH:oV.dot(oR).clamp(),f0:ck,f90:cw}),n=t.mul(t8.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(t8));t.assign(n)}if(!0===this.sheen){var i=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(i)}}}]),t}(lF),cE=tF(1),cR=tF(-2),cC=tF(.8),cM=tF(-1),cF=tF(.4),cB=tF(2),cP=tF(.305),cL=tF(3),cD=tF(.21),cU=tF(4),cO=tF(4),cI=tF(16),cV=tw(function(e){var t=E(e,1)[0],r=tV(nF(t)).toVar(),n=tF(-1).toVar();return tR(r.x.greaterThan(r.z),function(){tR(r.x.greaterThan(r.y),function(){n.assign(ic(t.x.greaterThan(0),0,3))}).Else(function(){n.assign(ic(t.y.greaterThan(0),1,4))})}).Else(function(){tR(r.z.greaterThan(r.y),function(){n.assign(ic(t.z.greaterThan(0),2,5))}).Else(function(){n.assign(ic(t.y.greaterThan(0),1,4))})}),n}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),cG=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tD().toVar();return tR(n.equal(0),function(){i.assign(tD(r.z,r.y).div(nF(r.x)))}).ElseIf(n.equal(1),function(){i.assign(tD(r.x.negate(),r.z.negate()).div(nF(r.y)))}).ElseIf(n.equal(2),function(){i.assign(tD(r.x.negate(),r.y).div(nF(r.z)))}).ElseIf(n.equal(3),function(){i.assign(tD(r.z.negate(),r.y).div(nF(r.x)))}).ElseIf(n.equal(4),function(){i.assign(tD(r.x.negate(),r.z).div(nF(r.y)))}).Else(function(){i.assign(tD(r.x,r.y).div(nF(r.z)))}),rV(.5,i.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),cz=tw(function(e){var t=E(e,1)[0],r=tF(0).toVar();return tR(t.greaterThanEqual(cC),function(){r.assign(cE.sub(t).mul(cM.sub(cR)).div(cE.sub(cC)).add(cR))}).ElseIf(t.greaterThanEqual(cF),function(){r.assign(cC.sub(t).mul(cB.sub(cM)).div(cC.sub(cF)).add(cM))}).ElseIf(t.greaterThanEqual(cP),function(){r.assign(cF.sub(t).mul(cL.sub(cB)).div(cF.sub(cP)).add(cB))}).ElseIf(t.greaterThanEqual(cD),function(){r.assign(cP.sub(t).mul(cU.sub(cL)).div(cP.sub(cD)).add(cL))}).Else(function(){r.assign(tF(-2).mul(nf(rV(1.16,t))))}),r}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),cW=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=r.toVar();i.assign(rV(2,i).sub(1));var a=tV(i,1).toVar();return tR(n.equal(0),function(){a.assign(a.zyx)}).ElseIf(n.equal(1),function(){a.assign(a.xzy),a.xz.mulAssign(-1)}).ElseIf(n.equal(2),function(){a.x.mulAssign(-1)}).ElseIf(n.equal(3),function(){a.assign(a.zyx),a.xz.mulAssign(-1)}).ElseIf(n.equal(4),function(){a.assign(a.xzy),a.xy.mulAssign(-1)}).ElseIf(n.equal(5),function(){a.z.mulAssign(-1)}),a}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),cH=tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=tF(i),l=tV(n),c=ie(cz(u),cR,s),d=nb(c),h=ng(c),f=tV(cq(r,l,h,a,o,s)).toVar();return tR(d.notEqual(0),function(){var e=tV(cq(r,l,h.add(1),a,o,s)).toVar();f.assign(n7(f,e,d))}),f}),cq=tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=tF(i).toVar(),l=tV(n),c=tF(cV(l)).toVar(),d=tF(nX(cO.sub(u),0)).toVar();u.assign(nX(u,cO));var h=tF(nd(u)).toVar(),f=tD(cG(l,c).mul(h.sub(2)).add(1)).toVar();return tR(c.greaterThan(2),function(){f.y.addAssign(h),c.subAssign(3)}),f.x.addAssign(c.mul(h)),f.x.addAssign(d.mul(rV(3,cI))),f.y.addAssign(rV(4,nd(s).sub(h))),f.x.mulAssign(a),f.y.mulAssign(o),r.sample(f).grad(tD(),tD())}),cj=tw(function(e){var t=e.envMap,r=e.mipInt,n=e.outputDirection,i=e.theta,a=e.axis,o=e.CUBEUV_TEXEL_WIDTH,s=e.CUBEUV_TEXEL_HEIGHT,u=e.CUBEUV_MAX_MIP,l=nT(i);return cq(t,n.mul(l).add(a.cross(n).mul(nx(i))).add(a.mul(a.dot(n).mul(l.oneMinus()))),r,o,s,u)}),cX=tw(function(e){var t=e.n,r=e.latitudinal,n=e.poleAxis,i=e.outputDirection,a=e.weights,o=e.samples,s=e.dTheta,u=e.mipInt,l=e.envMap,c=e.CUBEUV_TEXEL_WIDTH,d=e.CUBEUV_TEXEL_HEIGHT,h=e.CUBEUV_MAX_MIP,f=tV(ic(r,n,n$(n,i))).toVar();tR(f.equal(tV(0)),function(){f.assign(tV(i.z,0,i.x.negate()))}),f.assign(ny(f));var p=tV().toVar();return p.addAssign(a.element(0).mul(cj({theta:0,axis:f,outputDirection:i,mipInt:u,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),uP({start:tB(1),end:t},function(e){var t=e.i;tR(t.greaterThanEqual(o),function(){uL()});var r=tF(s.mul(tF(t))).toVar();p.addAssign(a.element(t).mul(cj({theta:r.mul(-1),axis:f,outputDirection:i,mipInt:u,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),p.addAssign(a.element(t).mul(cj({theta:r,axis:f,outputDirection:i,mipInt:u,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),tH(p,1)}),cK=tw(function(e){var t=tP(E(e,1)[0]).toVar();return t.assign(t.shiftLeft(tP(16)).bitOr(t.shiftRight(tP(16)))),t.assign(t.bitAnd(tP(0x55555555)).shiftLeft(tP(1)).bitOr(t.bitAnd(tP(0xaaaaaaaa)).shiftRight(tP(1)))),t.assign(t.bitAnd(tP(0x33333333)).shiftLeft(tP(2)).bitOr(t.bitAnd(tP(0xcccccccc)).shiftRight(tP(2)))),t.assign(t.bitAnd(tP(0xf0f0f0f)).shiftLeft(tP(4)).bitOr(t.bitAnd(tP(0xf0f0f0f0)).shiftRight(tP(4)))),t.assign(t.bitAnd(tP(0xff00ff)).shiftLeft(tP(8)).bitOr(t.bitAnd(tP(0xff00ff00)).shiftRight(tP(8)))),tF(t).mul(23283064365386963e-26)}),cY=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return tD(tF(r).div(tF(n)),cK(r))}),cQ=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=i.mul(i).toConst(),o=tV(1,0,0).toConst(),s=n$(n,o).toConst(),u=np(r.x).toConst(),l=rV(2,3.14159265359).mul(r.y).toConst(),c=u.mul(nT(l)).toConst(),d=u.mul(nx(l)).toVar(),h=rV(.5,n.z.add(1)).toConst();d.assign(h.oneMinus().mul(np(c.mul(c).oneMinus())).add(h.mul(d)));var f=o.mul(c).add(s.mul(d)).add(n.mul(np(nX(0,c.mul(c).add(d.mul(d)).oneMinus()))));return ny(tV(a.mul(f.x),a.mul(f.y),nX(0,f.z)))}),cZ=tw(function(e){var t=e.roughness,r=e.mipInt,n=e.envMap,i=e.N_immutable,a=e.GGX_SAMPLES,o=e.CUBEUV_TEXEL_WIDTH,s=e.CUBEUV_TEXEL_HEIGHT,u=e.CUBEUV_MAX_MIP,l=tV(i).toVar(),c=tV(0).toVar(),d=tF(0).toVar();return tR(t.lessThan(.001),function(){c.assign(cq(n,l,r,o,s,u))}).Else(function(){var e=ny(n$(ic(nF(l.z).lessThan(.999),tV(0,0,1),tV(1,0,0)),l)).toVar(),i=n$(l,e).toVar();uP({start:tP(0),end:a},function(h){var f=cQ(cY(h.i,a),tV(0,0,1),t),p=ny(e.mul(f.x).add(i.mul(f.y)).add(l.mul(f.z))),v=ny(p.mul(nJ(l,p).mul(2)).sub(l)),g=nX(nJ(l,v),0);tR(g.greaterThan(0),function(){var e=cq(n,v,r,o,s,u);c.addAssign(e.mul(g)),d.addAssign(g)})}),tR(d.greaterThan(0),function(){c.assign(c.div(d))})}),tH(c,1)}),cJ=[.125,.215,.35,.446,.526,.582],c$=new c.Ae(-1,1,1,-1,0,1),c0=new c.xe(90,1),c1=new c.Tc,c2=null,c3=0,c4=0,c5=new c.Fc,c6=new WeakMap,c8=[3,1,5,0,4,2],c9=cW(ag(),av("faceIndex")).normalize(),c7=tV(c9.x,c9.y,c9.z),de=function(){function e(t){v(this,e),this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}return y(e,[{key:"_hasInitialized",get:function(){return this._renderer.hasInitialized()}},{key:"fromScene",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i.size,o=i.position,s=i.renderTarget;if(this._setSize(void 0===a?256:a),!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');c2=this._renderer.getRenderTarget(),c3=this._renderer.getActiveCubeFace(),c4=this._renderer.getActiveMipmapLevel();var u=(void 0===s?null:s)||this._allocateTarget(!0);return this._init(u),this._sceneToCubeUV(e,r,n,u,void 0===o?c5:o),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}},{key:"fromSceneAsync",value:function(e){return f(function(e){var t,r,n,i,a=arguments;return P(this,function(o){switch(o.label){case 0:return t=a.length>1&&void 0!==a[1]?a[1]:0,r=a.length>2&&void 0!==a[2]?a[2]:.1,n=a.length>3&&void 0!==a[3]?a[3]:100,i=a.length>4&&void 0!==a[4]?a[4]:{},(0,c.yc)('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),[4,this._renderer.init()];case 1:return[2,(o.sent(),this.fromScene(e,t,r,n,i))]}})}).apply(this,arguments)}},{key:"fromEquirectangular",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}},{key:"fromEquirectangularAsync",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return f(function(){return P(this,function(r){switch(r.label){case 0:return(0,c.yc)('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),[4,this._renderer.init()];case 1:return[2,(r.sent(),this._fromTexture(e,t))]}})}).call(this)}},{key:"fromCubemap",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}},{key:"fromCubemapAsync",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return f(function(){return P(this,function(r){switch(r.label){case 0:return(0,c.yc)('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),[4,this._renderer.init()];case 1:return[2,(r.sent(),this._fromTexture(e,t))]}})}).call(this)}},{key:"compileCubemapShader",value:function(){return f(function(){return P(this,function(e){switch(e.label){case 0:if(null!==this._cubemapMaterial)return[3,2];return this._cubemapMaterial=dn(),[4,this._compileMaterial(this._cubemapMaterial)];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(this)}},{key:"compileEquirectangularShader",value:function(){return f(function(){return P(this,function(e){switch(e.label){case 0:if(null!==this._equirectMaterial)return[3,2];return this._equirectMaterial=di(),[4,this._compileMaterial(this._equirectMaterial)];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(this)}},{key:"dispose",value:function(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}},{key:"_setSizeFromTexture",value:function(e){e.mapping===c.fa||e.mapping===c.ga?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}},{key:"_setSize",value:function(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}},{key:"_dispose",value:function(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(var e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}},{key:"_cleanup",value:function(e){this._renderer.setRenderTarget(c2,c3,c4),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}},{key:"_fromTexture",value:function(e,t){this._setSizeFromTexture(e),c2=this._renderer.getRenderTarget(),c3=this._renderer.getActiveCubeFace(),c4=this._renderer.getActiveMipmapLevel();var r=t||this._allocateTarget(!1);return this._init(r),this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}},{key:"_allocateTarget",value:function(e){return dt(3*Math.max(this._cubeSize,112),4*this._cubeSize,e)}},{key:"_init",value:function(e){if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=dt(e.width,e.height);var t,r,n,i,a,o,s,u,l,d,h,f,p,v=this._lodMax;p=function(e){for(var t=[],r=[],n=[],i=e,a=e-4+1+cJ.length,o=0;o<a;o++){var s=Math.pow(2,i);t.push(s);var u=1/s;o>e-4?u=cJ[o-e+4-1]:0===o&&(u=0),r.push(u);for(var l=1/(s-2),d=-l,h=1+l,f=[d,d,h,d,h,h,d,d,h,h,d,h],p=new Float32Array(108),v=new Float32Array(72),g=new Float32Array(36),m=0;m<6;m++){var y=m%3*2/3-1,b=m>2?0:-1,x=[y,b,0,y+2/3,b,0,y+2/3,b+1,0,y,b,0,y+2/3,b+1,0,y,b+1,0],_=c8[m];p.set(x,18*_),v.set(f,12*_);var T=[_,_,_,_,_,_];g.set(T,6*_)}var S=new c.dd;S.setAttribute("position",new c.Zc(p,3)),S.setAttribute("uv",new c.Zc(v,2)),S.setAttribute("faceIndex",new c.Zc(g,1)),n.push(new c.ld(S,null)),i>4&&i--}return{lodMeshes:n,sizeLods:t,sigmas:r}}(v),this._lodMeshes=p.lodMeshes,this._sizeLods=p.sizeLods,this._sigmas=p.sigmas,this._blurMaterial=(t=e.width,r=e.height,n=aR(Array(20).fill(0)),i=rC(new c.Fc(0,1,0)),a=rC(0),s={n:tF(20),latitudinal:o=rC(0),weights:n,poleAxis:i,outputDirection:c7,dTheta:a,samples:rC(1),envMap:aS(),mipInt:rC(0),CUBEUV_TEXEL_WIDTH:tF(1/t),CUBEUV_TEXEL_HEIGHT:tF(1/r),CUBEUV_MAX_MIP:tF(v)},(u=dr("blur")).fragmentNode=cX(k(N({},s),{latitudinal:o.equal(1)})),c6.set(u,s),u),this._ggxMaterial=(l=e.width,d=e.height,h={envMap:aS(),roughness:rC(0),mipInt:rC(0),CUBEUV_TEXEL_WIDTH:tF(1/l),CUBEUV_TEXEL_HEIGHT:tF(1/d),CUBEUV_MAX_MIP:tF(v)},(f=dr("ggx")).fragmentNode=cZ(k(N({},h),{N_immutable:c7,GGX_SAMPLES:tP(512)})),c6.set(f,h),f)}}},{key:"_compileMaterial",value:function(e){return f(function(){var t;return P(this,function(r){switch(r.label){case 0:return t=new c.ld(new c.dd,e),[4,this._renderer.compile(t,c$)];case 1:return r.sent(),[2]}})}).call(this)}},{key:"_sceneToCubeUV",value:function(e,t,r,n,i){c0.near=t,c0.far=r;var a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],s=this._renderer,u=s.autoClear;s.getClearColor(c1),s.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new c.ld(new c.Ed,new c.kd({name:"PMREM.Background",side:c.k,depthWrite:!1,depthTest:!1})));var l=this._backgroundBox,d=l.material,h=!1,f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,h=!0):(d.color.copy(c1),h=!0),s.setRenderTarget(n),s.clear(),h&&s.render(l,c0);for(var p=0;p<6;p++){var v=p%3;0===v?(c0.up.set(0,a[p],0),c0.position.set(i.x,i.y,i.z),c0.lookAt(i.x+o[p],i.y,i.z)):1===v?(c0.up.set(0,0,a[p]),c0.position.set(i.x,i.y,i.z),c0.lookAt(i.x,i.y+o[p],i.z)):(c0.up.set(0,a[p],0),c0.position.set(i.x,i.y,i.z),c0.lookAt(i.x,i.y,i.z+o[p]));var g=this._cubeSize;this._setViewport(n,v*g,p>2?g:0,g,g),s.render(e,c0)}s.autoClear=u,e.background=f}},{key:"_textureToCubeUV",value:function(e,t){var r=this._renderer,n=e.mapping===c.fa||e.mapping===c.ga;n?null===this._cubemapMaterial&&(this._cubemapMaterial=dn(e)):null===this._equirectMaterial&&(this._equirectMaterial=di(e));var i=n?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;var a=this._lodMeshes[0];a.material=i;var o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),r.setRenderTarget(t),r.render(a,c$)}},{key:"_applyPMREM",value:function(e){var t=this._renderer,r=t.autoClear;t.autoClear=!1;for(var n=this._lodMeshes.length,i=1;i<n;i++)this._applyGGXFilter(e,i-1,i);t.autoClear=r}},{key:"_applyGGXFilter",value:function(e,t,r){var n=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;var s=c6.get(a),u=r/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),c=Math.sqrt(u*u-l*l)*(0+1.25*u),d=this._lodMax,h=this._sizeLods[r],f=3*h*(r>d-4?r-d+4:0),p=4*(this._cubeSize-h);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=c,s.mipInt.value=d-t,this._setViewport(i,f,p,3*h,2*h),n.setRenderTarget(i),n.render(o,c$),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-r,this._setViewport(e,f,p,3*h,2*h),n.setRenderTarget(e),n.render(o,c$)}},{key:"_blur",value:function(e,t,r,n,i){var a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,n,"latitudinal",i),this._halfBlur(a,e,r,r,n,"longitudinal",i)}},{key:"_halfBlur",value:function(e,t,r,n,i,a,o){var s=this._renderer,u=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&(0,c.xc)("blur direction must be either latitudinal or longitudinal!");var l=this._lodMeshes[n];l.material=u;var d=c6.get(u),h=this._sizeLods[r]-1,f=isFinite(i)?Math.PI/(2*h):2*Math.PI/39,p=i/f,v=isFinite(i)?1+Math.floor(3*p):20;v>20&&(0,c.wc)("sigmaRadians, ".concat(i,", is too large and will clip, as it requested ").concat(v," samples when the maximum is set to 20"));for(var g=[],m=0,y=0;y<20;++y){var b=y/p,x=Math.exp(-b*b/2);g.push(x),0===y?m+=x:y<v&&(m+=2*x)}for(var _=0;_<g.length;_++)g[_]=g[_]/m;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=v,d.weights.array=g,d.latitudinal.value=+("latitudinal"===a),o&&(d.poleAxis.value=o);var T=this._lodMax;d.dTheta.value=f,d.mipInt.value=T-r;var S=this._sizeLods[n],N=4*(this._cubeSize-S);this._setViewport(t,3*S*(n>T-4?n-T+4:0),N,3*S,2*S),s.setRenderTarget(t),s.render(l,c$)}},{key:"_setViewport",value:function(e,t,r,n,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-r,n,i),e.scissor.set(t,e.height-i-r,n,i)):(e.viewport.set(t,r,n,i),e.scissor.set(t,r,n,i))}}]),e}();function dt(e,t,r){var n=new c.Kc(e,t,{magFilter:c.qa,minFilter:c.qa,generateMipmaps:!1,type:c.Ba,format:c.Ja,colorSpace:c.Jb,depthBuffer:r});return n.texture.mapping=c.ja,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function dr(e){var t=new lo;return t.depthTest=!1,t.depthWrite=!1,t.blending=c.m,t.name="PMREM_".concat(e),t}function dn(e){var t=dr("cubemap");return t.fragmentNode=o2(e,c7),t}function di(e){var t=dr("equirect");return t.fragmentNode=aS(e,lS(c7),0),t}var da=new WeakMap,ds=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;v(this,t),(r=p(this,t,["vec3"]))._value=e,r._pmrem=null,r.uvNode=n,r.levelNode=i,r._generator=null;var a=new c.Ic;return a.isRenderTargetTexture=!0,r._texture=aS(a),r._width=rC(0),r._height=rC(0),r._maxMip=rC(0),r.updateBeforeType=et.RENDER,r}return T(t,e),y(t,[{key:"value",get:function(){return this._value},set:function(e){this._value=e,this._pmrem=null}},{key:"updateFromTexture",value:function(e){var t,r,n={texelWidth:1/(3*Math.max(Math.pow(2,r=Math.log2(t=e.image.height)-2),112)),texelHeight:1/t,maxMip:r};this._texture.value=e,this._width.value=n.texelWidth,this._height.value=n.texelHeight,this._maxMip.value=n.maxMip}},{key:"updateBefore",value:function(e){var t=this._pmrem,r=t?t.pmremVersion:-1,n=this._value;r!==n.pmremVersion&&null!==(t=!0===n.isPMREMTexture||n.mapping===c.ja?n:function(e,t,r){var n=(void 0===(a=da.get(t))&&(a=new WeakMap,da.set(t,a)),a),i=n.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){var a,o=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;for(var t=0,r=0;r<6;r++)void 0!==e[r]&&t++;return 6===t}(o))return null;i=r.fromCubemap(e,i)}else{if(!(null!=o&&o.height>0))return null;i=r.fromEquirectangular(e,i)}if(i.pmremVersion=e.pmremVersion,!1===n.has(e)){var s=function(){e.removeEventListener("dispose",s);var t=n.get(e);void 0!==t&&(t.dispose(),n.delete(e))};e.addEventListener("dispose",s)}n.set(e,i)}return i.texture}(n,e.renderer,this._generator))&&(this._pmrem=t,this.updateFromTexture(t))}},{key:"setup",value:function(e){null===this._generator&&(this._generator=new de(e.renderer)),this.updateBefore(e);var t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?oY.mul(tV(t.x,t.y.negate(),t.z)):oY.mul(t);var r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),cH(this._texture,t,r,this._width,this._height,this._maxMip)}},{key:"dispose",value:function(){x(_(t.prototype),"dispose",this).call(this),null!==this._generator&&this._generator.dispose()}}],[{key:"type",get:function(){return"PMREMNode"}}]),t}(eh)).setParameterLength(1,3),du=new WeakMap,dl=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).envNode=r,e}return T(t,e),y(t,[{key:"setup",value:function(e){var t=e.material,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){var n=r.isTextureNode?r.value:t[r.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(n);void 0===a&&(a=ds(n),i.set(n,a)),r=a}var o=!0===t.useAnisotropy||t.anisotropy>0?sS:oO,s=r.context(dc(t5,o)).mul(oK),u=r.context(dd(oI)).mul(Math.PI).mul(oK),l=i5(s),c=i5(u);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);var d=e.context.lightingModel.clearcoatRadiance;if(d){var h=i5(r.context(dc(t9,oV)).mul(oK));d.addAssign(h)}}},{key:"_getPMREMNodeCache",value:function(e){var t=du.get(e);return void 0===t&&(t=new WeakMap,du.set(e,t)),t}}],[{key:"type",get:function(){return"EnvironmentNode"}}]),t}(uG),dc=function(e,t){var r=null;return{getUV:function(){return null===r&&(r=oR.negate().reflect(t),r=(r=n3(e).mix(r,t).normalize()).transformDirection(a8)),r},getTextureLevel:function(){return e}}},dd=function(e){return{getUV:function(){return e},getTextureLevel:function(){return tF(1)}}},dh=new c.ee,df=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshStandardNodeMaterial=!0,r.lights=!0,r.emissiveNode=null,r.metalnessNode=null,r.roughnessNode=null,r.setDefaultValues(dh),r.setValues(e),r}return T(t,e),y(t,[{key:"setupEnvironment",value:function(e){var r=x(_(t.prototype),"setupEnvironment",this).call(this,e);return null===r&&e.environmentNode&&(r=e.environmentNode),r?new dl(r):null}},{key:"setupLightingModel",value:function(){return new cA}},{key:"setupSpecular",value:function(){var e=n7(tV(.04),t2.rgb,t6);ru.assign(tV(.04)),rl.assign(e),rc.assign(1)}},{key:"setupVariants",value:function(){var e=this.metalnessNode?tF(this.metalnessNode):sH;t6.assign(e);var t=this.roughnessNode?tF(this.roughnessNode):sW;t=lj({roughness:t}),t5.assign(t),this.setupSpecular(),t3.assign(t2.rgb.mul(e.oneMinus()))}}],[{key:"type",get:function(){return"MeshStandardNodeMaterial"}}]),t}(lo),dp=new c.fe,dv=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshPhysicalNodeMaterial=!0,r.clearcoatNode=null,r.clearcoatRoughnessNode=null,r.clearcoatNormalNode=null,r.sheenNode=null,r.sheenRoughnessNode=null,r.iridescenceNode=null,r.iridescenceIORNode=null,r.iridescenceThicknessNode=null,r.specularIntensityNode=null,r.specularColorNode=null,r.iorNode=null,r.transmissionNode=null,r.thicknessNode=null,r.attenuationDistanceNode=null,r.attenuationColorNode=null,r.dispersionNode=null,r.anisotropyNode=null,r.setDefaultValues(dp),r.setValues(e),r}return T(t,e),y(t,[{key:"useClearcoat",get:function(){return this.clearcoat>0||null!==this.clearcoatNode}},{key:"useIridescence",get:function(){return this.iridescence>0||null!==this.iridescenceNode}},{key:"useSheen",get:function(){return this.sheen>0||null!==this.sheenNode}},{key:"useAnisotropy",get:function(){return this.anisotropy>0||null!==this.anisotropyNode}},{key:"useTransmission",get:function(){return this.transmission>0||null!==this.transmissionNode}},{key:"useDispersion",get:function(){return this.dispersion>0||null!==this.dispersionNode}},{key:"setupSpecular",value:function(){var e=this.iorNode?tF(this.iorNode):s4;rg.assign(e),ru.assign(nj(n1(rg.sub(1).div(rg.add(1))).mul(sV),tV(1)).mul(sI)),rl.assign(n7(ru,t2.rgb,t6)),rc.assign(n7(sI,1,t6))}},{key:"setupLightingModel",value:function(){return new cA(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}},{key:"setupVariants",value:function(e){if(x(_(t.prototype),"setupVariants",this).call(this,e),this.useClearcoat){var r=this.clearcoatNode?tF(this.clearcoatNode):sj,n=this.clearcoatRoughnessNode?tF(this.clearcoatRoughnessNode):sX;t8.assign(r),t9.assign(lj({roughness:n}))}if(this.useSheen){var i=this.sheenNode?tV(this.sheenNode):sQ,a=this.sheenRoughnessNode?tF(this.sheenRoughnessNode):sZ;t7.assign(i),re.assign(a)}if(this.useIridescence){var o=this.iridescenceNode?tF(this.iridescenceNode):s$,s=this.iridescenceIORNode?tF(this.iridescenceIORNode):s0,u=this.iridescenceThicknessNode?tF(this.iridescenceThicknessNode):s1;rt.assign(o),rr.assign(s),rn.assign(u)}if(this.useAnisotropy){var l=(this.anisotropyNode?tD(this.anisotropyNode):sJ).toVar();ra.assign(l.length()),tR(ra.equal(0),function(){l.assign(tD(1,0))}).Else(function(){l.divAssign(tD(ra)),ra.assign(ra.saturate())}),ri.assign(ra.pow2().mix(t5.pow2(),1)),ro.assign(s_[0].mul(l.x).add(s_[1].mul(l.y))),rs.assign(s_[1].mul(l.x).sub(s_[0].mul(l.y)))}if(this.useTransmission){var c=this.transmissionNode?tF(this.transmissionNode):s2,d=this.thicknessNode?tF(this.thicknessNode):s3,h=this.attenuationDistanceNode?tF(this.attenuationDistanceNode):s5,f=this.attenuationColorNode?tV(this.attenuationColorNode):s6;if(rm.assign(c),ry.assign(d),rb.assign(h),rx.assign(f),this.useDispersion){var p=this.dispersionNode?tF(this.dispersionNode):un;r_.assign(p)}}}},{key:"setupClearcoatNormal",value:function(){return this.clearcoatNormalNode?tV(this.clearcoatNormalNode):sK}},{key:"setup",value:function(e){var r=this;e.context.setupClearcoatNormal=function(){return ik(r.setupClearcoatNormal(e),"NORMAL","vec3")},x(_(t.prototype),"setup",this).call(this,e)}}],[{key:"type",get:function(){return"MeshPhysicalNodeMaterial"}}]),t}(df),dg=tw(function(e){var t=e.normal,r=e.lightDirection,n=e.builder,i=tD(t.dot(r).mul(.5).add(.5),0);if(n.material.gradientMap)return tV(o9("gradientMap","texture").context({getUV:function(){return i}}).r);var a=i.fwidth().mul(.5);return n7(tV(.7),tV(1),ii(tF(.7).sub(a.x),tF(.7).add(a.x),i.x))}),dm=function(e){function t(){return v(this,t),p(this,t,arguments)}return T(t,e),y(t,[{key:"direct",value:function(e,t){var r=e.lightDirection,n=e.lightColor,i=e.reflectedLight,a=dg({normal:oB,lightDirection:r,builder:t}).mul(n);i.directDiffuse.addAssign(a.mul(lU({diffuseColor:t2.rgb})))}},{key:"indirect",value:function(e){var t=e.context,r=t.ambientOcclusion,n=t.irradiance,i=t.reflectedLight;i.indirectDiffuse.addAssign(n.mul(lU({diffuseColor:t2}))),i.indirectDiffuse.mulAssign(r)}}]),t}(lF),dy=new c.he,db=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshToonNodeMaterial=!0,r.lights=!0,r.setDefaultValues(dy),r.setValues(e),r}return T(t,e),y(t,[{key:"setupLightingModel",value:function(){return new dm}}],[{key:"type",get:function(){return"MeshToonNodeMaterial"}}]),t}(lo),dx=tw(function(){var e=tV(oR.z,0,oR.x.negate()).normalize(),t=oR.cross(e);return tD(e.dot(oO),t.dot(oO)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),d_=new c.me,dT=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isMeshMatcapNodeMaterial=!0,r.setDefaultValues(d_),r.setValues(e),r}return T(t,e),y(t,[{key:"setupVariants",value:function(e){var t;t=e.material.matcap?o9("matcap","texture").context({getUV:function(){return dx}}):tV(n7(.2,.8,dx.y)),t2.rgb.mulAssign(t.rgb)}}],[{key:"type",get:function(){return"MeshMatcapNodeMaterial"}}]),t}(lo),dS=tx(function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).positionNode=e,n.rotationNode=r,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.positionNode.getNodeType(e)}},{key:"setup",value:function(e){var t=this.rotationNode,r=this.positionNode;if("vec2"===this.getNodeType(e)){var n=t.cos(),i=t.sin();return tK(n,i,i.negate(),n).mul(r)}var a=tQ(tH(1,0,0,0),tH(0,nT(t.x),nx(t.x).negate(),0),tH(0,nx(t.x),nT(t.x),0),tH(0,0,0,1)),o=tQ(tH(nT(t.y),0,nx(t.y),0),tH(0,1,0,0),tH(nx(t.y).negate(),0,nT(t.y),0),tH(0,0,0,1)),s=tQ(tH(nT(t.z),nx(t.z).negate(),0,0),tH(nx(t.z),nT(t.z),0,0),tH(0,0,1,0),tH(0,0,0,1));return a.mul(o).mul(s).mul(tH(r,1)).xyz}}],[{key:"type",get:function(){return"RotateNode"}}]),t}(eh)).setParameterLength(2),dN=new c.hd,dk=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isSpriteNodeMaterial=!0,r._useSizeAttenuation=!0,r.positionNode=null,r.rotationNode=null,r.scaleNode=null,r.transparent=!0,r.setDefaultValues(dN),r.setValues(e),r}return T(t,e),y(t,[{key:"setupPositionView",value:function(e){var t=e.object,r=e.camera,n=this.positionNode,i=this.rotationNode,a=this.scaleNode,o=this.sizeAttenuation,s=oy.mul(tV(n||0)),u=tD(od[0].xyz.length(),od[1].xyz.length());null!==a&&(u=u.mul(tD(a))),r.isPerspectiveCamera&&!1===o&&(u=u.mul(s.z.negate()));var l=oS.xy;if(t.center&&!0===t.center.isVector2){var c=new iL("center","vec2",t);l=l.sub(c.sub(.5))}var d=dS(l=l.mul(u),tF(i||sY));return tH(s.xy.add(d),s.zw)}},{key:"sizeAttenuation",get:function(){return this._useSizeAttenuation},set:function(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}],[{key:"type",get:function(){return"SpriteNodeMaterial"}}]),t}(lo),dw=new c.xd,dA=new c.Dc,dE=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).sizeNode=null,r.isPointsNodeMaterial=!0,r.setDefaultValues(dw),r.setValues(e),r}return T(t,e),y(t,[{key:"setupPositionView",value:function(){var e=this.positionNode;return oy.mul(tV(e||oN)).xyz}},{key:"setupVertexSprite",value:function(e){var r=e.material,n=e.camera,i=this.rotationNode,a=this.scaleNode,o=this.sizeNode,s=this.sizeAttenuation,u=x(_(t.prototype),"setupVertex",this).call(this,e);if(!0!==r.isNodeMaterial)return u;var l=null!==o?tD(o):ur;l=l.mul(aF),n.isPerspectiveCamera&&!0===s&&(l=l.mul(dR.div(oE.z.negate()))),a&&a.isNode&&(l=l.mul(tD(a)));var c=oS.xy;return i&&i.isNode&&(c=dS(c,tF(i))),c=(c=(c=c.mul(l)).div(aU.div(2))).mul(u.w),u=u.add(tH(c,0,0))}},{key:"setupVertex",value:function(e){return e.object.isPoints?x(_(t.prototype),"setupVertex",this).call(this,e):this.setupVertexSprite(e)}},{key:"alphaToCoverage",get:function(){return this._useAlphaToCoverage},set:function(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}],[{key:"type",get:function(){return"PointsNodeMaterial"}}]),t}(dk),dR=rC(1).onFrameUpdate(function(e){var t=e.renderer.getSize(dA);this.value=.5*t.y}),dC=function(e){function t(){var e;return v(this,t),(e=p(this,t)).shadowNode=tF(1).toVar("shadowMask"),e}return T(t,e),y(t,[{key:"direct",value:function(e){var t=e.lightNode;null!==t.shadowNode&&this.shadowNode.mulAssign(t.shadowNode)}},{key:"finish",value:function(e){var t=e.context;t2.a.mulAssign(this.shadowNode.oneMinus()),t.outgoingLight.rgb.assign(t2.rgb)}}]),t}(lF),dM=new c.Zd,dF=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).isShadowNodeMaterial=!0,r.lights=!0,r.transparent=!0,r.setDefaultValues(dM),r.setValues(e),r}return T(t,e),y(t,[{key:"setupLightingModel",value:function(){return new dC}}],[{key:"type",get:function(){return"ShadowNodeMaterial"}}]),t}(lo),dB=(t0("vec3"),t0("vec3"),t0("vec3"),function(){function e(t,r,n){v(this,e),this.renderer=t,this.nodes=r,this.info=n,this._context=("u"<typeof self?"undefined":C(self))<"u"?self:null,this._animationLoop=null,this._requestId=null}return y(e,[{key:"start",value:function(){var e=this,t=function(r,n){e._requestId=e._context.requestAnimationFrame(t),!0===e.info.autoReset&&e.info.reset(),e.nodes.nodeFrame.update(),e.info.frame=e.nodes.nodeFrame.frameId,e.renderer._inspector.begin(),null!==e._animationLoop&&e._animationLoop(r,n),e.renderer._inspector.finish()};t()}},{key:"stop",value:function(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}},{key:"getAnimationLoop",value:function(){return this._animationLoop}},{key:"setAnimationLoop",value:function(e){this._animationLoop=e}},{key:"getContext",value:function(){return this._context}},{key:"setContext",value:function(e){this._context=e}},{key:"dispose",value:function(){this.stop()}}]),e}()),dP=function(){function e(){v(this,e),this.weakMaps={}}return y(e,[{key:"_getWeakMap",value:function(e){var t=e.length,r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}},{key:"get",value:function(e){for(var t=this._getWeakMap(e),r=0;r<e.length-1;r++)if(void 0===(t=t.get(e[r])))return;return t.get(e[e.length-1])}},{key:"set",value:function(e,t){for(var r=this._getWeakMap(e),n=0;n<e.length-1;n++){var i=e[n];!1===r.has(i)&&r.set(i,new WeakMap),r=r.get(i)}return r.set(e[e.length-1],t),this}},{key:"delete",value:function(e){for(var t=this._getWeakMap(e),r=0;r<e.length-1;r++)if(void 0===(t=t.get(e[r])))return!1;return t.delete(e[e.length-1])}}]),e}(),dL=0,dD=new WeakMap;function dU(e){return Object.freeze({isMaterial:!0,isDrawState:!0,id:e.id,name:e.name,type:e.type,transparent:e.transparent,blending:e.blending,premultipliedAlpha:e.premultipliedAlpha,blendSrc:e.blendSrc,blendDst:e.blendDst,blendEquation:e.blendEquation,blendSrcAlpha:e.blendSrcAlpha,blendDstAlpha:e.blendDstAlpha,blendEquationAlpha:e.blendEquationAlpha,blendColor:e.blendColor,blendAlpha:e.blendAlpha,colorWrite:e.colorWrite,depthWrite:e.depthWrite,depthTest:e.depthTest,depthFunc:e.depthFunc,stencilWrite:e.stencilWrite,stencilFunc:e.stencilFunc,stencilRef:e.stencilRef,stencilFail:e.stencilFail,stencilZFail:e.stencilZFail,stencilZPass:e.stencilZPass,stencilFuncMask:e.stencilFuncMask,stencilWriteMask:e.stencilWriteMask,side:e.side,wireframe:!0===e.wireframe,alphaToCoverage:e.alphaToCoverage,forceSinglePass:e.forceSinglePass,polygonOffset:e.polygonOffset,polygonOffsetFactor:e.polygonOffsetFactor,polygonOffsetUnits:e.polygonOffsetUnits})}function dO(e,t){if(null===e||null===t)return e===t;for(var r in e)if(e[r]!==t[r])return!1;return!0}var dI=["colorNode","depthNode","positionNode","side","transparent","alphaTest","alphaMap","displacementMap","displacementScale","displacementBias"],dV=function(){function e(t,r,n,i){v(this,e),this.target=t,this.owner=r,this.passId=n,this.priority=i,this.lightsNode=null,this.lights=null,this.buildState=null,this.builder=null,this.pipeline=null,this.prewarm=!1,this.status=null,this._settledCallbacks=null}return y(e,[{key:"onSettled",value:function(e){null===this.status?(null===this._settledCallbacks&&(this._settledCallbacks=[]),this._settledCallbacks.push(e)):e(this)}}]),e}(),dG=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(this,e),this.renderer=t,this.timeBudget=2,this.burstTimeBudget=12,this._burst=!1,this.burstDutyCycle=.85,this._dutyWindowStart=-1,this._dutyWindowBusy=0,this.stats=null!==t?t.info.asyncCompilation:{queued:0,pipelines:0,promotions:0,failed:0,mainThreadTime:0},this._entries=new Map,this._queue=[],this._current=null,this._promotions=[],this._failures=new Map,this._pipelinesInFlight=0,this._prewarms=0,this._didBuild=!1,this._updating=!1,this._updateScheduled=!1,this._notifyRequested=!1,this._idleHandle=null,this._timeoutHandle=null,this._onServiceCallback=this._service.bind(this)}return y(e,[{key:"burst",get:function(){return this._burst},set:function(e){(e=!0===e)!==this._burst&&(this._burst=e,this._dutyWindowStart=-1,this._dutyWindowBusy=0)}},{key:"request",value:function(e,t){var r=null!==e.pending?e.pending:e,n=this._entries.get(r);if(void 0!==n)return n;if(void 0!==this.renderer._pipelines.get(r).pipeline||!0===this.isFailed(r.initialCacheKey))return null;var i,a=r.object,o=r.material,s=void 0!==a.compilePriority?a.compilePriority:void 0!==o.compilePriority?o.compilePriority:0,u=r!==e?e:null;i=s>0?0:s<0?3:null===u&&null===this.renderer._compilationPromises?1:2;var l=new dV(r,u,t,i);null!==this.renderer._compilationPromises&&(l.prewarm=!0,this._prewarms++);var c=r.lightsNode;return null!=c&&(l.lightsNode=c,l.lights=c.getLights().slice()),l.buildState=function(e){var t=null,r=!0,n=!1,i=void 0;try{for(var a,o=dI[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=e[s];void 0!==u&&(null===t&&(t={}),t[s]=u)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t}(o),this._entries.set(r,l),this._insert(l),this.requestUpdate(),this._syncInfo(),l}},{key:"update",value:function(){if(!0!==this._updating&&(0!==this._queue.length||null!==this._current)){this._updating=!0;var e=!0===this.burst,t=performance.now(),r=t+(!0===e?this.burstTimeBudget:this.timeBudget);try{do{var n=void 0,i=this._current;if(null===i){if(i=this._queue.shift(),void 0===i)break;if(null!==i.status)continue;if(!0===this._isStale(i)){this._settle(i,"stale");continue}this._current=i}try{n=this._advance(i,r)}catch(e){this._fail(i,e),n=!0}if(!0===n&&(this._current=null,!0===this._didBuild&&(this._didBuild=!1,!1===e)))break}while(performance.now()<r)}finally{this._updating=!1}var a=performance.now();this.stats.mainThreadTime+=a-t,this._noteDuty(a,a-t),this._queue.length>0||null!==this._current?this.requestUpdate():(this._dutyWindowStart=-1,this._dutyWindowBusy=0),this._syncInfo()}}},{key:"_noteDuty",value:function(e,t){this._dutyWindowStart<0&&(this._dutyWindowStart=e-t),this._dutyWindowBusy+=t;var r=e-this._dutyWindowStart;r>=500&&(this._dutyWindowStart=e-r/2,this._dutyWindowBusy*=.5)}},{key:"_dutyCycle",value:function(e){if(this._dutyWindowStart<0)return 0;var t=e-this._dutyWindowStart;return t<100?0:Math.min(1,this._dutyWindowBusy/t)}},{key:"applyPromotions",value:function(){var e=this._promotions;if(0!==e.length){for(var t=this.renderer._objects,r=0;r<e.length;r++){var n=e[r];try{!0===t.promote(n.owner,n.target,n.passId)&&this.stats.promotions++}catch(e){(0,c.xc)("AsyncCompilation: Promotion failed.",e)}}e.length=0}}},{key:"rememberFailure",value:function(e){var t=this._failures;for(!0===t.has(e)&&t.delete(e),t.set(e,!0);t.size>256;)t.delete(t.keys().next().value)}},{key:"isFailed",value:function(e){return this._failures.has(e)}},{key:"requestUpdate",value:function(){!0!==this._updateScheduled&&(this._updateScheduled=!0,this._prewarms>0||!0===this._burst&&this._dutyCycle(performance.now())<this.burstDutyCycle?("u"<typeof self?"undefined":C(self))<"u"&&void 0!==self.scheduler&&void 0!==self.scheduler.yield?self.scheduler.yield().then(this._onServiceCallback):this._timeoutHandle=setTimeout(this._onServiceCallback,0):0==(("u"<typeof document?"undefined":C(document))<"u"&&"hidden"===document.visibilityState)&&("u"<typeof requestIdleCallback?"undefined":C(requestIdleCallback))<"u"?(this._idleHandle=requestIdleCallback(this._onServiceCallback,{timeout:100}),this._timeoutHandle=setTimeout(this._onServiceCallback,150)):this._timeoutHandle=setTimeout(this._onServiceCallback,0))}},{key:"cancel",value:function(e){var t=this._entries.get(e);void 0!==t&&(this._settle(t,"cancelled"),t.builder=null,t.lights=null,t.lightsNode=null,t.buildState=null,t.pipeline=null,t.target=null,t.owner=null,this._syncInfo())}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cancelled";this._queue.length=0,this._current=null,this._promotions.length=0;var t=!0,r=!1,n=void 0;try{for(var i,a=Array.from(this._entries.values())[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this._settle(o,e)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}this._entries.clear(),this._notifyRequested=!1,this._didBuild=!1,this._cancelServiceCallback(),this._syncInfo()}},{key:"dispose",value:function(){this.clear("disposed"),this._failures.clear()}},{key:"_advance",value:function(e,t){var r=this,n=this.renderer,i=e.target;if(!0===this._isStale(e))return this._settle(e,"stale"),!0;var a=n._nodes;if(void 0===a.get(i).nodeBuilderState){var o=i.material,s=e.buildState,u=null;if(null!==s)for(var l in u={},s)u[l]=o[l],o[l]=s[l];try{var c=a.getForRenderCacheKey(i);if(void 0===a.nodeBuilderCache.get(c)&&void 0===a._spResurrectRetired(c)){var d=e.lightsNode,h=null!==d?d.getLights():null;null!==d&&d.setLights(e.lights);var f=i.context,p=n._mrt,v=n._renderTarget,g=n._activeCubeFace,m=n._activeMipmapLevel;n._mrt=void 0!==f.mrt?f.mrt:null,n._renderTarget=void 0!==f.renderTarget?f.renderTarget:null,n._activeCubeFace=f.activeCubeFace||0,n._activeMipmapLevel=f.activeMipmapLevel||0;var y=!1;try{null===e.builder&&(e.builder=a._createNodeBuilder(i,i.material)),y=e.builder.buildStep(t)}finally{null!==d&&d.setLights(h),n._mrt=p,n._renderTarget=v,n._activeCubeFace=g,n._activeMipmapLevel=m}if(!1===y)return!1;a.adoptNodeBuilder(c,e.builder),e.builder=null,this._didBuild=!0}a.getForRender(i)}finally{if(null!==u)for(var b in u)o[b]=u[b]}}n._bindings.getForRender(i);var x=n._pipelines.getForRenderAsync(i),_=x.pipeline,T=x.promise;if(e.pipeline=_,null!==T){this._pipelinesInFlight++;var S=function(){r._pipelinesInFlight--,r._settlePipeline(e)};T.then(S,S)}else this._settlePipeline(e);return!0}},{key:"_settlePipeline",value:function(e){if(null===e.status){var t=this.renderer,r=e.target;!0===this._isStale(e)?this._settle(e,"stale"):!0===t._pipelines.isPipelineFailed(e.pipeline)?this._fail(e,Error("Async render pipeline creation failed.")):(t.backend.syncRenderUpdateState(r,null!==r.drawState?r.drawState:r.material),null!==e.owner?this._promotions.push(e):this.stats.promotions++,this._settle(e,"ready"),this._requestNotify()),this._syncInfo()}}},{key:"_fail",value:function(e,t){var r=t.stackTrace;!r&&t.stack&&(r=new z(t.stack)),(0,c.xc)("TSL: "+t,r),e.builder=null,this.rememberFailure(e.target.initialCacheKey),this.stats.failed++;var n=e.owner;this._settle(e,"failed"),null!==n&&n.pending===e.target&&(n.pending=null,e.target.dispose())}},{key:"_settle",value:function(e,t){if(null===e.status){e.status=t,!0===e.prewarm&&(e.prewarm=!1,this._prewarms--),this._entries.delete(e.target),this._current===e&&(this._current=null);var r=e._settledCallbacks;if(null!==r){e._settledCallbacks=null;for(var n=0;n<r.length;n++)r[n](e)}}}},{key:"_isStale",value:function(e){var t=e.target,r=e.owner;return!0===t.disposed||null!==r&&(!0===r.disposed||r.pending!==t)}},{key:"_insert",value:function(e){for(var t=this._queue,r=t.length;r>0&&t[r-1].priority>e.priority;)r--;t.splice(r,0,e)}},{key:"_service",value:function(){if(!1!==this._updateScheduled&&(this._updateScheduled=!1,this._cancelServiceCallback(),this.update(),!0===this._notifyRequested)){this._notifyRequested=!1;var e=this.renderer;null!==e&&"function"==typeof e.onBackgroundWorkReady&&e.onBackgroundWorkReady()}}},{key:"_cancelServiceCallback",value:function(){null!==this._idleHandle&&(("u"<typeof cancelIdleCallback?"undefined":C(cancelIdleCallback))<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null),null!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=null),this._updateScheduled=!1}},{key:"_requestNotify",value:function(){this._notifyRequested=!0,this.requestUpdate()}},{key:"_syncInfo",value:function(){var e=this.stats;e.queued=this._queue.length+ +(null!==this._current),e.pipelines=this._pipelinesInFlight}}]),e}(),dz=function(){function e(t,r,n,i,a,o,s,u,l,c){var d=this;v(this,e),this.id=dL++,this._nodes=t,this._geometries=r,this.renderer=n,this.object=i,this.material=a,this.scene=o,this.camera=s,this.lightsNode=u,this.context=l,this.geometry=i.geometry,this.version=a.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=c,this.clippingContextCacheKey=null!==c?c.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this._sourceMaterial=n._currentSourceMaterial,this._chainGroup=null,this.pending=null,this.drawState=null,this.disposed=!1,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=function(){d.dispose()},this.onGeometryDispose=function(){d.attributes=null,d.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),null!==this._sourceMaterial&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}return y(e,[{key:"updateClipping",value:function(e){this.clippingContext=e}},{key:"clippingNeedsUpdate",get:function(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}},{key:"hardwareClippingPlanes",get:function(){return!0===this.getNodeBuilderState().hardwareClipping?this.clippingContext.unionClippingCount:0}},{key:"drawMaterial",get:function(){return null!==this.drawState&&!0===this.renderer._asyncCompilation?this.drawState:this.material}},{key:"getNodeBuilderState",value:function(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}},{key:"getMonitor",value:function(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}},{key:"getBindings",value:function(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}},{key:"getBindingGroup",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,a=this.getBindings()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(o.name===e)return o}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"getIndex",value:function(){return this._geometries.getIndex(this)}},{key:"getIndirect",value:function(){return this._geometries.getIndirect(this)}},{key:"getIndirectOffset",value:function(){return this._geometries.getIndirectOffset(this)}},{key:"getChainArray",value:function(){return null!==this._chainGroup?[this.object,this.material,this.context,this.lightsNode,this._chainGroup]:[this.object,this.material,this.context,this.lightsNode]}},{key:"setGeometry",value:function(e){this.geometry=e,this.attributes=null,this.attributesId=null}},{key:"getAttributes",value:function(){if(null!==this.attributes)return this.attributes;var e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],n=new Set,i={},a=!0,o=!1,s=void 0;try{for(var u,l=e[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value,d=void 0;if(c.node&&c.node.attribute?d=c.node.attribute:(d=t.getAttribute(c.name),void 0!==d&&(d.isInterleavedBufferAttribute?i[c.name]=d.data.uuid:i[c.name]=d.id)),void 0!==d){r.push(d);var h=d.isInterleavedBufferAttribute?d.data:d;n.add(h)}}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}return this.attributes=r,this.attributesId=i,this.vertexBuffers=Array.from(n.values()),r}},{key:"getVertexBuffers",value:function(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}},{key:"getDrawParameters",value:function(){var e=this.object,t=this.geometry,r=this.group,n=this.drawRange,i=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a,s=1;if(!0===t.isInstancedBufferGeometry){if(!1===Number.isFinite(s=t.instanceCount)){var u=1/0;for(var l in t.attributes){var c=t.attributes[l];!0===c.isInterleavedBufferAttribute&&!0===c.data.isInstancedInterleavedBuffer?u=Math.min(u,c.data.meshPerAttribute*c.data.count):!0===c.isInstancedBufferAttribute&&(u=Math.min(u,c.meshPerAttribute*c.count))}s=Number.isFinite(u)?u:0}}else void 0!==e.count&&(s=Math.max(0,e.count));if(0===s)return null;if(i.instanceCount=s,!0===e.isBatchedMesh)return i;var d=1;!0!==this.drawMaterial.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(d=2);var h=n.start*d,f=(n.start+n.count)*d;null!==r&&(h=Math.max(h,r.start*d),f=Math.min(f,(r.start+r.count)*d));var p=t.attributes.position,v=1/0;o?v=a.count:null!=p&&(v=p.count),h=Math.max(h,0);var g=(f=Math.min(f,v))-h;return g<0||g===1/0?null:(i.vertexCount=g,i.firstVertex=h,i)}},{key:"getGeometryCacheKey",value:function(){var e=this.geometry,t="",r=!0,n=!1,i=void 0;try{for(var a,o=Object.keys(e.attributes).sort()[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=e.attributes[s];t+=s+",",u.data&&(t+=u.data.stride+","),u.offset&&(t+=u.offset+","),u.itemSize&&(t+=u.itemSize+","),u.normalized&&(t+="n,")}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}var l=!0,c=!1,d=void 0;try{for(var h,f=Object.keys(e.morphAttributes).sort()[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var p=h.value,v=e.morphAttributes[p];t+="morph-"+p+",";for(var g=0,m=v.length;g<m;g++)t+=v[g].id+","}}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}return e.index&&(t+="index,"),t}},{key:"getMaterialCacheKey",value:function(){var e,t=this.object,r=this.material,n=this.renderer,i=null!=n._currentSourceMaterial?n._currentSourceMaterial:this._sourceMaterial;if(!0===r.isShadowPassMaterial&&null!=i&&i!==r){var a=i.castShadowNode&&i.castShadowNode.isNode,o=i.maskShadowNode&&i.maskShadowNode.isNode||i.maskNode&&i.maskNode.isNode,s=i.alphaTest>0||!0===n.shadowMap.transmitted||a||o,u=(s&&i.map&&i.map.isTexture?"m":"")+(s&&i.colorNode&&i.colorNode.isNode?"o":"")+(a?"c":"")+(o?"k":"")+(i.depthNode&&i.depthNode.isNode?"d":"")+(i.castShadowPositionNode&&i.castShadowPositionNode.isNode?"p":i.positionNode&&i.positionNode.isNode?"q":"");e=""===u?"shadow()":"shadow("+u+"):"+i.customProgramCacheKey()}else e=r.customProgramCacheKey();var l=!0,c=!1,d=void 0;try{for(var h,f=(function(e){var t=Object.keys(e),r=dD.get(e.constructor);if(void 0===r){r=[];for(var n=Object.getPrototypeOf(e);n;){var i=Object.getOwnPropertyDescriptors(n);for(var a in i){var o=i[a];o&&"function"==typeof o.get&&r.push(a)}n=Object.getPrototypeOf(n)}dD.set(e.constructor,r)}for(var s=0;s<r.length;s++)t.push(r[s]);return t})(r)[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var p=h.value;if(!/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(p)){var v=void 0,g=r[p];if(null!==g){var m=void 0===g?"undefined":C(g);"number"===m?v="side"===p?String(g):0!==g?"1":"0":"object"===m?(v="{",g.isTexture&&(v+=g.mapping,!0===n.backend.isWebGPUBackend&&(v+=g.magFilter,v+=g.minFilter,v+=g.wrapS,v+=g.wrapT,v+=g.wrapR)),v+="}"):v=String(g)}else v=String(g);e+=v+","}}}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}return e+=this.clippingContextCacheKey+",",t.geometry&&(e+=this.getGeometryCacheKey()),t.skeleton&&(e+=t.skeleton.bones.length+","),t.isBatchedMesh&&(e+=t._matricesTexture.uuid+",",null!==t._colorsTexture&&(e+=t._colorsTexture.uuid+",")),(t.isInstancedMesh||t.count>1)&&(e+=t.uuid+","),e+=this.context.nodeCacheKey+",",H(e+=t.receiveShadow+",")}},{key:"needsGeometryUpdate",get:function(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){var e=this.attributesId;for(var t in e){var r=this.geometry.getAttribute(t);if(void 0===r)return!0;var n=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==n)return!0}}return!1}},{key:"needsUpdate",get:function(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}},{key:"getDynamicCacheKey",value:function(){var e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=j(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=j(e,1)),e=j(e,this.renderer.contextNode.id,this.renderer.contextNode.version)}},{key:"getCacheKey",value:function(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}},{key:"dispose",value:function(){!0!==this.disposed&&(this.disposed=!0,this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),null!==this._sourceMaterial&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose())}}]),e}(),dW=[],dH=[],dq=function(){function e(t,r,n,i,a,o){v(this,e),this.renderer=t,this.nodes=r,this.geometries=n,this.pipelines=i,this.bindings=a,this.info=o,this.chainMaps={},this._classifications=new WeakMap}return y(e,[{key:"updateClassification",value:function(e){var t=this._classifications.get(e);void 0===t&&(t={transparent:!1,doublePass:!1},this._classifications.set(e,t)),t.transparent=he(e),t.doublePass=ht(e)}},{key:"resetClassifications",value:function(){this._classifications=new WeakMap}},{key:"getClassification",value:function(e){if(!0!==this.renderer._asyncCompilation)return null;var t=this._classifications.get(e);return void 0!==t?t:null}},{key:"get",value:function(e,t,r,n,i,a,o,s){var u,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,c=this.getChainMap(s),d=null!=l&&r.overrideMaterial===t&&Array.isArray(e.material)?l:null;null!==d?(u=dH)[4]=d:u=dW,u[0]=e,u[1]=t,u[2]=a,u[3]=i;var h=c.get(u);if(void 0===h)(h=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,n,i,a,o,s))._chainGroup=d,c.set(u,h),!0===this.renderer._asyncCompilation&&!1===this.renderer._compilation._updating&&!0!==e.isQuadMesh&&(h.drawState=dU(t),this.renderer._compilation.request(h,s));else{h.camera=n,h.updateClipping(o);var f=!1,p=!1;if(h.needsGeometryUpdate&&(f=!0,h.setGeometry(e.geometry),p=h.initialCacheKey!==h.getCacheKey()),p||h.version!==t.version||h.needsUpdate)if(!0===this.renderer._asyncCompilation&&!1===this.renderer._compilation._updating&&!0!==e.isQuadMesh&&!0===this.pipelines.isReady(h)&&!1===f){var v=h.getCacheKey();h.initialCacheKey!==v&&this.requestPending(h,v,!1,s),h.version=t.version}else h.initialCacheKey!==h.getCacheKey()?(h.dispose(),h=this.get(e,t,r,n,i,a,o,s,l)):h.version=t.version}return u[0]=null,u[1]=null,u[2]=null,u[3]=null,u===dH&&(u[4]=null),h}},{key:"requestPending",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0,i=this.renderer._compilation,a=e.material;e.initialCacheKey=t,e.initialNodesCacheKey=e.getDynamicCacheKey();var o=dU(a),s=e.pending;if(null!==s){if(s.initialCacheKey===t&&(!1===r||dO(s.drawState,o)))return;e.pending=null,s.dispose()}if((!(this.nodes.get(e).cacheKey===t&&(!1===r||dO(e.drawState,o)))||!1!==this.renderer.backend.detectAttachmentMismatch(e))&&!0!==i.isFailed(t)){var u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e.object,a,e.scene,e.camera,e.lightsNode,e.context,e.clippingContext,n);u.drawState=o,u._chainGroup=e._chainGroup,e.pending=u,i.request(e,n)}}},{key:"promote",value:function(e,t,r){return e.pending===t&&!0!==e.disposed&&(e.pending=null,this.getChainMap(r).set(t.getChainArray(),t),this.updateClassification(t.material),null!==e.bundle&&(e.bundle.needsUpdate=!0),e.dispose(),!0)}},{key:"getChainMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";return this.chainMaps[e]||(this.chainMaps[e]=new dP)}},{key:"dispose",value:function(){this.chainMaps={}}},{key:"createRenderObject",value:function(e,t,r,n,i,a,o,s,u,l,c){var d=this,h=this.getChainMap(c),f=new dz(e,t,r,n,i,a,o,s,u,l);return f.onDispose=function(){null!==d.renderer._compilation&&d.renderer._compilation.cancel(f),d.pipelines.delete(f),d.bindings.deleteForRender(f),d.nodes.delete(f);var e=f.pending;null!==e&&(f.pending=null,e.dispose());var t=f.getChainArray();h.get(t)===f&&h.delete(t)},f}}]),e}(),dj=function(){function e(){v(this,e),this.data=new WeakMap}return y(e,[{key:"get",value:function(e){var t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}},{key:"delete",value:function(e){var t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}},{key:"has",value:function(e){return this.data.has(e)}},{key:"dispose",value:function(){this.data=new WeakMap}}]),e}(),dX=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).backend=e,n.info=r,n}return T(t,e),y(t,[{key:"delete",value:function(e){var r=x(_(t.prototype),"delete",this).call(this,e);return null!==r&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),r}},{key:"update",value:function(e,t){var r=this.get(e);if(void 0===r.version)1===t?(this.backend.createAttribute(e),this.info.createAttribute(e)):2===t?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):3===t?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):4===t&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{var n=this._getBufferAttribute(e);(r.version<n.version||n.usage===c.mc)&&(this.backend.updateAttribute(e),r.version=n.version)}}},{key:"_getBufferAttribute",value:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}]),t}(dj);function dK(e){return null!==e.index?e.index.version:e.attributes.position.version}function dY(e){return null!==e.index?e.index.id:e.attributes.position.id}function dQ(e){var t=[],r=e.index,n=e.attributes.position;if(null!==r)for(var i=r.array,a=0,o=i.length;a<o;a+=3){var s=i[a+0],u=i[a+1],l=i[a+2];t.push(s,u,u,l,l,s)}else for(var d=0,h=n.array.length/3-1;d<h;d+=3){var f=d+0,p=d+1,v=d+2;t.push(f,p,p,v,v,f)}var g=new(n.count>=65535?c.$c:c._c)(t,1);return g.version=dK(e),g.__id=dY(e),g}var dZ=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).attributes=e,n.info=r,n.wireframes=new WeakMap,n.attributeCall=new WeakMap,n._geometryDisposeListeners=new Map,n}return T(t,e),y(t,[{key:"has",value:function(e){var r=e.geometry;return x(_(t.prototype),"has",this).call(this,r)&&!0===this.get(r).initialized}},{key:"updateForRender",value:function(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}},{key:"initGeometry",value:function(e){var t=this,r=e.geometry;this.get(r).initialized=!0,this.info.memory.geometries++;var n=function(){t.info.memory.geometries--;var i=r.index,a=e.getAttributes();for(var o in null!==i&&t.attributes.delete(i),r.attributes)t.attributes.delete(r.attributes[o]);var s=!0,u=!1,l=void 0;try{for(var c,d=a[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value;t.attributes.delete(h)}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}var f=t.wireframes.get(r);void 0!==f&&t.attributes.delete(f),r.removeEventListener("dispose",n),t._geometryDisposeListeners.delete(r)};r.addEventListener("dispose",n),this._geometryDisposeListeners.set(r,n)}},{key:"releaseReplacedAttributes",value:function(e){var t=this.get(e),r=t.uploadedAttributes;void 0===r&&(t.uploadedAttributes=r=new Map);var n=!0,i=!1,a=void 0;try{for(var o,s=r[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=E(o.value,2),l=u[0],c=u[1];e.attributes[l]!==c&&(this.attributes.delete(c),r.delete(l))}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}for(var d in e.attributes)r.set(d,e.attributes[d]);var h=e.index;void 0!==t.uploadedIndex&&t.uploadedIndex!==h&&this.attributes.delete(t.uploadedIndex),t.uploadedIndex=h}},{key:"updateAttributes",value:function(e){var t=e.getAttributes();this.releaseReplacedAttributes(e.geometry);var r=!0,n=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,3):this.updateAttribute(s,1)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}var u=this.getIndex(e);null!==u&&this.updateAttribute(u,2);var l=e.geometry.indirect;null!==l&&this.updateAttribute(l,4)}},{key:"updateAttribute",value:function(e,t){var r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}},{key:"getIndirect",value:function(e){return e.geometry.indirect}},{key:"getIndirectOffset",value:function(e){return e.geometry.indirectOffset}},{key:"getIndex",value:function(e){var t=e.geometry,r=t.index;if(!0===e.drawMaterial.wireframe){var n=this.wireframes,i=n.get(t);void 0===i?(i=dQ(t),n.set(t,i)):(i.version!==dK(t)||i.__id!==dY(t))&&(this.attributes.delete(i),i=dQ(t),n.set(t,i)),r=i}return r}},{key:"dispose",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._geometryDisposeListeners.entries()[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=E(n.value,2),o=a[0],s=a[1];o.removeEventListener("dispose",s)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}this._geometryDisposeListeners.clear()}}]),t}(dj),dJ=function(){function e(){v(this,e),this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.asyncCompilation={queued:0,pipelines:0,promotions:0,failed:0,mainThreadTime:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}return y(e,[{key:"update",value:function(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*r:e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=t/2*r:e.isLine?this.render.lines+=r*(t-1):(0,c.xc)("WebGPUInfo: Unknown object type.")}},{key:"reset",value:function(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}},{key:"dispose",value:function(){for(var e in this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory)this.memory[e]=0;this.memoryMap.clear()}},{key:"createTexture",value:function(e){var t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}},{key:"destroyTexture",value:function(e){var t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}},{key:"_createAttribute",value:function(e,t){var r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}},{key:"createAttribute",value:function(e){this._createAttribute(e,"attributes")}},{key:"createIndexAttribute",value:function(e){this._createAttribute(e,"indexAttributes")}},{key:"createStorageAttribute",value:function(e){this._createAttribute(e,"storageAttributes")}},{key:"createIndirectStorageAttribute",value:function(e){this._createAttribute(e,"indirectStorageAttributes")}},{key:"destroyAttribute",value:function(e){var t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}},{key:"createReadbackBuffer",value:function(e){var t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}},{key:"destroyReadbackBuffer",value:function(e){var t=this.memoryMap.get(e).size;this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}},{key:"createUniformBuffer",value:function(e){var t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}},{key:"destroyUniformBuffer",value:function(e){var t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}},{key:"createProgram",value:function(e){var t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}},{key:"destroyProgram",value:function(e){var t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}},{key:"_getTextureMemorySize",value:function(e){if(e.isCompressedTexture)return 1;var t=1;e.type===c.va||e.type===c.ua?t=1:e.type===c.wa||e.type===c.xa||e.type===c.Ba?t=2:(e.type===c.ya||e.type===c.za||e.type===c.Aa)&&(t=4);var r=4;e.format===c.Ha||e.format===c.Ma||e.format===c.Na||e.format===c.Ka||e.format===c.La?r=1:e.format===c.Oa||e.format===c.Pa?r=2:(e.format===c.Ia||e.format===c.Qa)&&(r=3);var n=t*r;e.type===c.Ca||e.type===c.Da?n=2:(e.type===c.Ea||e.type===c.Fa||e.type===c.Ga)&&(n=4);var i=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1,s=i*a*o*n,u=e.mipmaps;if(u&&u.length>0){for(var l=0,d=0;d<u.length;d++){var h=u[d];h.data?l+=h.data.byteLength:l+=(h.width||Math.max(1,i>>d))*(h.height||Math.max(1,a>>d))*o*n}s+=l}else e.generateMipmaps&&(s*=1.333);return Math.round(s)}},{key:"_getAttributeMemorySize",value:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}]),e}(),d$=function e(t){v(this,e),this.cacheKey=t,this.usedTimes=0},d0=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t,[e])).vertexProgram=r,i.fragmentProgram=n,i}return T(t,e),t}(d$),d1=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e])).computeProgram=r,n.isComputePipeline=!0,n}return T(t,e),t}(d$),d2=0,d3=function e(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;v(this,e),this.id=d2++,this.code=t,this.stage=r,this.name=n,this.transforms=i,this.attributes=a,this.usedTimes=0},d4=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t)).backend=e,i.nodes=r,i.info=n,i.bindings=null,i.caches=new Map,i.programs={vertex:new Map,fragment:new Map,compute:new Map},i._inFlight=new Map,i}return T(t,e),y(t,[{key:"getForCompute",value:function(e,t){var r=this.backend,n=this.get(e);if(this._needsComputeUpdate(e)){var i=n.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);var a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);void 0===o&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),o=new d3(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),r.createProgram(o),this.info.createProgram(o));var s=this._getComputeCacheKey(e,o),u=this.caches.get(s);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,o,s,t)),u.usedTimes++,o.usedTimes++,n.version=e.version,n.pipeline=u}return n.pipeline}},{key:"getForRender",value:function(e){var t=this.get(e);if(this._needsRenderUpdate(e)){var r=t.pipeline;r&&(r.usedTimes--,r.vertexProgram.usedTimes--,r.fragmentProgram.usedTimes--);var n=e.getNodeBuilderState(),i=e.material?e.material.name:"",a=this._getProgramStage("vertex",n.vertexShader,i,r?r.vertexProgram:null),o=this._getProgramStage("fragment",n.fragmentShader,i,r?r.fragmentProgram:null),s=this._getRenderCacheKey(e,a,o),u=this.caches.get(s);void 0===u?(r&&0===r.usedTimes&&this._releasePipeline(r),u=this._getRenderPipeline(e,a,o,s)):e.pipeline=u,u.usedTimes++,a.usedTimes++,o.usedTimes++,t.pipeline=u,this.backend.get(e).compiledAttachmentKey=this.backend.getAttachmentStateKey(e)}return t.pipeline}},{key:"getForRenderAsync",value:function(e){var t=this,r=this.get(e),n=r.pipeline;if(void 0===n){var i=e.getNodeBuilderState(),a=e.material?e.material.name:"",o=this._getProgramStage("vertex",i.vertexShader,a),s=this._getProgramStage("fragment",i.fragmentShader,a),u=this._getRenderCacheKey(e,o,s);if(void 0===(n=this.caches.get(u))){n=new d0(u,o,s),this.caches.set(u,n),e.pipeline=n;var l=[];if(this.backend.createRenderPipeline(e,l),l.length>0){var c=Promise.all(l).finally(function(){t._inFlight.delete(n)});this._inFlight.set(n,c)}}else e.pipeline=n;n.usedTimes++,o.usedTimes++,s.usedTimes++,r.pipeline=n,this.backend.get(e).compiledAttachmentKey=this.backend.getAttachmentStateKey(e)}var d=this._inFlight.get(n);return{pipeline:n,promise:void 0!==d?d:null}}},{key:"isReady",value:function(e){var t=this.get(e).pipeline;return void 0!==t&&this.isPipelineReady(t)}},{key:"isPipelineReady",value:function(e){var t=this.backend.get(e);return void 0!==t.pipeline&&null!==t.pipeline}},{key:"isPipelineFailed",value:function(e){return!0===this.backend.get(e).error}},{key:"delete",value:function(e){var r=this.get(e).pipeline;return r&&(r.isComputePipeline?(r.usedTimes--,0===r.usedTimes&&this._releasePipeline(r),r.computeProgram.usedTimes--,0===r.computeProgram.usedTimes&&this._releaseProgram(r.computeProgram)):this.releaseRenderPipeline(r)),x(_(t.prototype),"delete",this).call(this,e)}},{key:"releaseRenderPipeline",value:function(e){e.usedTimes--,0===e.usedTimes&&this._releasePipeline(e),e.vertexProgram.usedTimes--,e.fragmentProgram.usedTimes--,0===e.vertexProgram.usedTimes&&this._releaseProgram(e.vertexProgram),0===e.fragmentProgram.usedTimes&&this._releaseProgram(e.fragmentProgram)}},{key:"dispose",value:function(){x(_(t.prototype),"dispose",this).call(this),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map},this._inFlight=new Map}},{key:"updateForRender",value:function(e){this.getForRender(e)}},{key:"_getComputePipeline",value:function(e,t,r,n){r=r||this._getComputeCacheKey(e,t);var i=this.caches.get(r);return void 0===i&&(i=new d1(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,n)),i}},{key:"_getRenderPipeline",value:function(e,t,r,n){n=n||this._getRenderCacheKey(e,t,r);var i=this.caches.get(n);return void 0===i&&(i=new d0(n,t,r),this.caches.set(n,i),e.pipeline=i,this.backend.createRenderPipeline(e,null)),i}},{key:"_getComputeCacheKey",value:function(e,t){return e.id+","+t.id}},{key:"_getRenderCacheKey",value:function(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}},{key:"_getProgramStage",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=this.programs[e].get(t);return void 0===i&&(null!==n&&0===n.usedTimes&&this._releaseProgram(n),i=new d3(t,e,r),this.programs[e].set(t,i),this.backend.createProgram(i),this.info.createProgram(i)),i}},{key:"_releasePipeline",value:function(e){this.caches.delete(e.cacheKey)}},{key:"_releaseProgram",value:function(e){var t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}},{key:"_needsComputeUpdate",value:function(e){var t=this.get(e);return void 0===t.pipeline||t.version!==e.version}},{key:"_needsRenderUpdate",value:function(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}]),t}(dj),d5=function(e){function t(e,r,n,i,a,o){var s;return v(this,t),(s=p(this,t)).backend=e,s.textures=n,s.pipelines=a,s.attributes=i,s.nodes=r,s.info=o,s.pipelines.bindings=s,s}return T(t,e),y(t,[{key:"getForRender",value:function(e){var t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0,e._spBindingsFresh=!0),t}},{key:"getForCompute",value:function(e){var t=this.nodes.getForCompute(e).bindings,r=this.get(e);return(!0!==r.initialized||r.bindings!==t)&&(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}},{key:"updateForCompute",value:function(e){this._updateBindings(this.getForCompute(e))}},{key:"updateForRender",value:function(e){this._updateBindings(this.getForRender(e))}},{key:"deleteForCompute",value:function(e){var t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}},{key:"deleteForRender",value:function(e){var t=e._bindings;null!==t&&this._destroyBindings(t),this.delete(e)}},{key:"_createBindings",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.get(o);if(void 0===s.bindGroup){var u=!0,l=!1,c=void 0;try{for(var d,h=o.bindings[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;if(f.isUniformBuffer)this.backend.createUniformBuffer(f),this.info.createUniformBuffer(f);else if(f.isSampledTexture)(null===f.texture||void 0===f.texture)&&(f.texture=f.textureNode&&f.textureNode.value||ye()),this.textures.updateTexture(f.texture);else if(f.isSampler)this.textures.updateSampler(f);else if(f.isStorageBuffer){var p=f.attribute,v=p.isIndirectStorageBufferAttribute?4:3;this.attributes.update(p,v)}}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}this.backend.createBindings(o,e,0),s.bindGroup=o,s.usedTimes=1}else s.usedTimes++}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"_destroyBindings",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.get(o);if(s.usedTimes--,0===s.usedTimes){var u=!0,l=!1,c=void 0;try{for(var d,h=o.bindings[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;f.isUniformBuffer?(this.backend.destroyUniformBuffer(f),this.info.destroyUniformBuffer(f),f.release()):f.isSampler&&(!0!==f.isSampledTexture&&this.backend.destroySampler(f),f.release())}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}this.backend.deleteBindGroupData(o),this.delete(o)}}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"_updateBindings",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this._update(o,e)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"_update",value:function(e,t){var r=this.backend,n=!1,i=!0,a=0,o=0,s=!0,u=!1,l=void 0;try{for(var c,d=e.bindings[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value;if(!1!==this.nodes.updateGroup(h)){if(h.isStorageBuffer){var f=h.attribute,p=f.isIndirectStorageBufferAttribute?4:3,v=r.get(h);this.attributes.update(f,p),v.attribute!==f&&(v.attribute=f,n=!0)}if(h.isUniformBuffer)h.update()&&r.updateBinding(h);else if(h.isSampledTexture){var g=h.update(),m=h.texture,y=this.textures.get(m);if(g&&(this.textures.updateTexture(m),h.generation!==y.generation&&(h.generation=y.generation,n=!0),y.bindGroups.add(e)),void 0!==r.get(m).externalTexture||y.isDefaultTexture?i=!1:(a=a+":"+m.id,o+=m.version),!0===m.isStorageTexture&&!0===m.mipmapsAutoUpdate){var b=this.get(m);!0===h.store?b.needsMipmap=!0:this.textures.needsMipmaps(m)&&!0===b.needsMipmap&&(this.backend.generateMipmaps(m),b.needsMipmap=!1)}}else if(h.isSampler&&h.update()){var x=this.textures.updateSampler(h);h.samplerKey!==x&&(h.samplerKey=x,n=!0)}h.isBuffer&&h.updateRanges.length>0&&h.clearUpdateRanges()}}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}!0===n&&this.backend.updateBindings(e,t,i?a:0,o)}}]),t}(dj),d6=Object.freeze([]),d8={transparent:!1,doublePass:!1};function d9(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function d7(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function he(e){return!!(!0===e.transparent||e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode||e.backdropNode&&e.backdropNode.isNode)}function ht(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===c.l&&!1===e.forceSinglePass}var hr=function(){function e(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;v(this,e),this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=t,this.lightsNode=t.getNode(r),this.lightsArray=[],this.scene=r,this.camera=n,this.occlusionQueryCount=0,this._lastOcclusionObject=null,this.objects=i}return y(e,[{key:"_classify",value:function(e){if(null!==this.objects){var t=this.objects.getClassification(e);if(null!==t)return t}return d8.transparent=he(e),d8.doublePass=d8.transparent&&ht(e),d8}},{key:"begin",value:function(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}},{key:"getNextRenderItem",value:function(e,t,r,n,i,a,o){var s=this.renderItems[this.renderItemsIndex];return void 0===s?(s={id:e.id,object:e,geometry:t,material:r,groupOrder:n,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=r,s.groupOrder=n,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}},{key:"push",value:function(e,t,r,n,i,a,o){var s=this.getNextRenderItem(e,t,r,n,i,a,o);!0===e.occlusionTest&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e);var u=this._classify(r);!0===u.transparent?(!0===u.doublePass&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}},{key:"unshift",value:function(e,t,r,n,i,a,o){var s=this.getNextRenderItem(e,t,r,n,i,a,o),u=this._classify(r);!0===u.transparent?(!0===u.doublePass&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}},{key:"pushBundle",value:function(e){this.bundles.push(e)}},{key:"pushLight",value:function(e){this.lightsArray.push(e)}},{key:"sort",value:function(e,t,r){this.opaque.length>1&&this.opaque.sort(e||d9),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||d7),this.transparent.length>1&&this.transparent.sort(t||d7),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}},{key:"finish",value:function(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:d6);for(var e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){var r=this.renderItems[e];if(null===r.id)break;r.id=null,r.object=null,r.geometry=null,r.material=null,r.groupOrder=null,r.renderOrder=null,r.z=null,r.group=null,r.clippingContext=null}this._lastOcclusionObject=null}}]),e}(),hn=[],hi=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;v(this,e),this.lighting=t,this.objects=r,this.lists=new dP}return y(e,[{key:"get",value:function(e,t){var r=this.lists;hn[0]=e,hn[1]=t;var n=r.get(hn);return void 0===n&&(n=new hr(this.lighting,e,t,this.objects),r.set(hn,n)),hn[0]=null,hn[1]=null,n}},{key:"dispose",value:function(){this.lists=new dP}}]),e}(),ha=0,ho=function(){function e(){v(this,e),this.id=ha++,this.nodeCacheKey="",this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new c.Jc,this.scissor=!1,this.scissorValue=new c.Jc,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}return y(e,[{key:"getCacheKey",value:function(){return hs(this)}}]),e}();function hs(e){var t=e.textures,r=[e.activeCubeFace,e.activeMipmapLevel],n=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;r.push(u.id)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return q(r)}var hu=function(){function e(t){v(this,e),this.renderer=t,this._renderContexts={}}return y(e,[{key:"get",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(null===t)e="default";else{var i=t.texture.format,a=t.texture.type;e="".concat(t.textures.length,":").concat(i,":").concat(a,":").concat(t.samples,":").concat(t.depthBuffer,":").concat(t.stencilBuffer)}var o=null!==r?r.id:"default",s=e+"-"+o+"-"+n,u=this._renderContexts[s];return void 0===u&&((u=new ho).mrt=r,u.nodeCacheKey=e+"-"+o,this._renderContexts[s]=u),null!==t&&(u.sampleCount=0===t.samples?1:t.samples),u.clearDepthValue=this.renderer.getClearDepth(),u.clearStencilValue=this.renderer.getClearStencil(),u}},{key:"dispose",value:function(){this._renderContexts={}}}]),e}(),hl=new c.Fc,hc=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t)).renderer=e,i.backend=r,i.info=n,i._htmlTextures=new Set,i}return T(t,e),y(t,[{key:"updateRenderTarget",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.get(e),i=0===e.samples?1:e.samples,a=n.depthTextureMips||(n.depthTextureMips={}),o=e.textures,s=this.getSize(o[0]),u=s.width>>r,l=s.height>>r,d=e.depthTexture||a[r],h=!0===e.depthBuffer||!0===e.stencilBuffer,f=!1,p=void 0!==d&&void 0!==d.image&&d.image.depth>1,v=s.depth>1&&(e.useArrayDepthTexture||e.multiview||p);void 0===d&&h&&((d=new c.Cd).format=e.stencilBuffer?c.La:c.Ka,d.type=e.stencilBuffer?c.Ea:c.za,d.image.width=u,d.image.height=l,d.image.depth=s.depth,d.renderTarget=e,a[r]=d),d&&(d.isArrayTexture=v),(n.width!==s.width||s.height!==n.height)&&(f=!0,d&&(d.needsUpdate=!0,d.image.width=u,d.image.height=l,d.image.depth=v?s.depth:1)),n.width=s.width,n.height=s.height,n.textures=o,n.depthTexture=d||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==i&&(f=!0,d&&(d.needsUpdate=!0),n.sampleCount=i);var g={sampleCount:i};if(!0!==e.isXRRenderTarget){for(var m=0;m<o.length;m++){var y=o[m];f&&(y.needsUpdate=!0),this.updateTexture(y,g)}d&&this.updateTexture(d,g)}!0!==n.initialized&&(n.initialized=!0,this.info.memory.renderTargets++,n.onDispose=function(){t._destroyRenderTarget(e)},e.addEventListener("dispose",n.onDispose))}},{key:"updateTexture",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.get(e);if(!0!==n.initialized||n.version!==e.version){var i=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,a=this.backend;if(i&&!0===n.initialized&&a.destroyTexture(e),e.isFramebufferTexture){var o=this.renderer.getRenderTarget();e.type=o?o.texture.type:c.ua}if(e.isHTMLTexture&&e.image){var s=this.renderer.domElement;if("requestPaint"in s){if(s.hasAttribute("layoutsubtree")||s.setAttribute("layoutsubtree","true"),e.image.parentNode!==s&&s.appendChild(e.image),0===this._htmlTextures.size){var u=this._htmlTextures;s.onpaint=function(e){var t=e&&e.changedElements,r=!0,n=!1,i=void 0;try{for(var a,o=u[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;(!t||t.includes(s.image))&&(s.needsUpdate=!0)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}}}this._htmlTextures.add(e)}}var l=this.getSize(e),d=l.width,h=l.height,f=l.depth;if(r.width=d,r.height=h,r.depth=f,r.needsMipmaps=this.needsMipmaps(e),r.levels=r.needsMipmaps?this.getMipLevels(e,d,h):1,e.isCubeTexture&&e.mipmaps.length>0&&r.levels++,i||!0===e.isStorageTexture||!0===e.isExternalTexture)a.createTexture(e,r),n.generation=e.version;else if(e.version>0){var p=e.image;if(void 0===p||!1===p.complete)(0,c.wc)(void 0===p?"Renderer: Texture marked for update but image is undefined.":"Renderer: Texture marked for update but image is incomplete."),void 0===a.get(e).texture&&(a.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version);else{if(e.images){var v=[],g=!0,m=!1,y=void 0;try{for(var b,x=e.images[Symbol.iterator]();!(g=(b=x.next()).done);g=!0){var _=b.value;v.push(_)}}catch(e){m=!0,y=e}finally{try{g||null==x.return||x.return()}finally{if(m)throw y}}r.images=v}else r.image=p;(void 0===n.isDefaultTexture||!0===n.isDefaultTexture)&&(a.createTexture(e,r),n.isDefaultTexture=!1,n.generation=e.version),!0===e.source.dataReady&&a.updateTexture(e,r);var T=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;r.needsMipmaps&&0===e.mipmaps.length&&!T&&a.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else a.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;!0!==n.initialized&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===c.Hc.enabled&&c.Hc.getTransfer(e.colorSpace)!==c.Lb&&(0,c.wc)("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),n.onDispose=function(){t._destroyTexture(e)},e.addEventListener("dispose",n.onDispose)),n.version=e.version}}},{key:"updateSampler",value:function(e){return this.backend.updateSampler(e)}},{key:"getSize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hl,r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):("u"<typeof HTMLVideoElement?"undefined":C(HTMLVideoElement))<"u"&&S(r,HTMLVideoElement)?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):("u"<typeof VideoFrame?"undefined":C(VideoFrame))<"u"&&S(r,VideoFrame)?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}},{key:"getMipLevels",value:function(e,t,r){return e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1}},{key:"needsMipmaps",value:function(e){return!0===e.generateMipmaps||e.mipmaps.length>0}},{key:"_destroyRenderTarget",value:function(e){if(!0===this.has(e)){var t=this.get(e),r=t.textures,n=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(var i=0;i<r.length;i++)this._destroyTexture(r[i]);n&&this._destroyTexture(n),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}},{key:"_destroyTexture",value:function(e){if(!0===this.has(e)){var t=this.get(e);e.removeEventListener("dispose",t.onDispose);var r=t.isDefaultTexture,n=!0,i=!1,a=void 0;if(this.backend.destroyTexture(e,r),t.bindGroups)try{for(var o,s=t.bindGroups[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=this.backend.get(u);l.groups=void 0,l.versions=void 0;var c=!0,d=!1,h=void 0;try{for(var f,p=u.bindings[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var v=f.value;v.isSampler&&v.texture===e&&(!0!==v.isSampledTexture&&this.backend.destroySampler(v),v.reset(),v.release())}}catch(e){d=!0,h=e}finally{try{c||null==p.return||p.return()}finally{if(d)throw h}}}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}}]),t}(dj),hd=function(e){function t(e,r,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return v(this,t),(i=p(this,t,[e,r,n])).a=a,i}return T(t,e),y(t,[{key:"set",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return this.a=i,x(_(t.prototype),"set",this).call(this,e,r,n)}},{key:"copy",value:function(e){return void 0!==e.a&&(this.a=e.a),x(_(t.prototype),"copy",this).call(this,e)}},{key:"clone",value:function(){return new this.constructor(this.r,this.g,this.b,this.a)}}]),t}(c.Tc),hh=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[n,{overrideNodes:e}])).isOverrideContextNode=!0,r}return T(t,e),y(t,[{key:"getFlowContextData",value:function(){var e=[];this.traverse(function(t){!0===t.isOverrideContextNode&&e.push(t.value.overrideNodes)});var r=new Map(e.flatMap(function(e){return Array.from(e.entries())})),n=x(_(t.prototype),"getFlowContextData",this).call(this);return n.overrideNodes=r,n}}],[{key:"type",get:function(){return"OverrideContextNode"}}]),t}(id);function hf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(t&&t.isNode){var n=t;t=function(){return n}}return new hh(new Map([[e,t]]),r)}function hp(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=new Map,n=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)!function(){var e=E(o.value,2),t=e[0],n=e[1];r.set(t,null!==n?"function"==typeof n?n:function(){return n}:null)}()}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return new hh(r,t)}eN("overrideNode",function(e,t,r){return hf(t,r,e)}),eN("overrideNodes",function(e,t){return hp(t,e)});var hv=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e,n])).isParameterNode=!0,r}return T(t,e),y(t,[{key:"getMemberType",value:function(e,t){var r,n=this.getNodeType(e),i=e.getStructTypeNode(n);return null!==i?r=i.getMemberType(e,t):((0,c.xc)('TSL: Member "'.concat(t,'" not found in struct "').concat(n,'".'),new z),r="float"),r}},{key:"getHash",value:function(){return String(this.id)}},{key:"generate",value:function(){return this.name}}],[{key:"type",get:function(){return"ParameterNode"}}]),t}(t$),hg=tx(function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).nodes=[],e.outputNode=null,e.parent=r,e._currentCond=null,e._expressionNode=null,e._currentNode=null,e._nodeDataLibrary=new Map,e.isStackNode=!0,e}return T(t,e),y(t,[{key:"getElementType",value:function(e){return this.outputNode?this.outputNode.getElementType(e):"void"}},{key:"generateNodeType",value:function(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}},{key:"getMemberType",value:function(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}},{key:"addToStack",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(!0!==e.isNode)return(0,c.xc)("TSL: Invalid node added to stack.",new z),this;if(-1===t)if(this._currentNode){var r=this._nodeDataLibrary.get(this._currentNode);void 0===r&&(r={delta:0},this._nodeDataLibrary.set(this._currentNode,r)),r.delta++,t=this.nodes.indexOf(this._currentNode)+r.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}},{key:"addToStackBefore",value:function(e){var t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}},{key:"If",value:function(e,t){var r=new tv(t);return this._currentCond=ic(e,r),this.addToStack(this._currentCond)}},{key:"ElseIf",value:function(e,t){var r=ic(e,new tv(t));return this._currentCond.elseNode=r,this._currentCond=r,this}},{key:"Else",value:function(e){return this._currentCond.elseNode=new tv(e),this}},{key:"Switch",value:function(e){return this._expressionNode=tg(e),this}},{key:"Case",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=[];if(t.length>=2)for(var i=0;i<t.length-1;i++)n.push(this._expressionNode.equal(tg(t[i])));else(0,c.xc)("TSL: Invalid parameter length. Case() requires at least two parameters.",new z);for(var a=new tv(t[t.length-1]),o=n[0],s=1;s<n.length;s++)o=o.or(n[s]);var u=ic(o,a);return null===this._currentCond?(this._currentCond=u,this.addToStack(this._currentCond)):(this._currentCond.elseNode=u,this._currentCond=u,this)}},{key:"Default",value:function(e){return this.Else(e),this}},{key:"setup",value:function(e){var t=e.getNodeProperties(this),r=0,n=!0,i=!1,a=void 0;try{for(var o,s=this.getChildren()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;u.isVarNode&&u.isIntent(e)&&!0!==u.isAssign(e)||(t["node"+r++]=u)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return t.outputNode||null}},{key:"build",value:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a,o,s=tE(),u=e.buildStage;tA(this),e.setActiveStack(this);for(var l=0;l<this.nodes.length;l++){var c=this.nodes[l],d=this._currentNode;if(this._currentNode=c,!c.isVarNode||!c.isIntent(e)||!0===c.isAssign(e)){if("setup"===u)c.build(e);else if("analyze"===u)c.build(e,this);else if("generate"===u){var h=e.getDataFromNode(c,"any").stages,f=h&&h[e.shaderStage];if(c.isVarNode&&f&&1===f.length&&f[0]&&f[0].isStackNode)continue;c.build(e,"void")}this._currentNode=d}}if(this.outputNode){var p,v=(p=this.outputNode).build.apply(p,[e].concat(R(n)));("generate"!==e.buildStage||"void"!==this.outputNode.getNodeType(e))&&(o=v)}else o=(a=x(_(t.prototype),"build",this)).call.apply(a,[this,e].concat(R(n)));return tA(s),e.removeActiveStack(this),o}}],[{key:"type",get:function(){return"StackNode"}}]),t}(el)).setParameterLength(0,1),hm=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,["struct"])).membersLayout=Object.entries(e).map(function(e){var t=E(e,2),r=t[0],n=t[1];return"string"==typeof n?{name:r,type:n,atomic:!1}:{name:r,type:n.type,atomic:n.atomic||!1}}),r.name=n,r.isStructTypeNode=!0,r}return T(t,e),y(t,[{key:"getLength",value:function(){var e=1,t=0,r=!0,n=!1,i=void 0;try{for(var a,o=this.membersLayout[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value.type,u=/float|int|uint|bool/.test(s)?1:/vec2/.test(s)?2:/vec3/.test(s)?3:/vec4/.test(s)||/mat2/.test(s)?4:/mat3/.test(s)?12:/mat4/.test(s)?16:void(0,c.xc)("TSL: Unsupported type: ".concat(s),new z),l=/float|int|uint|bool/.test(s)?1:/vec2/.test(s)?2:/vec3/.test(s)||/vec4/.test(s)?4:/mat2/.test(s)?2:/mat3/.test(s)||/mat4/.test(s)?4:void(0,c.xc)("TSL: Unsupported type: ".concat(s),new z);e=Math.max(e,l);var d=t%e%l;0!==d&&(t+=l-d),t+=u}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return Math.ceil(t/e)*e}},{key:"getMemberType",value:function(e,t){var r=this.membersLayout.find(function(e){return e.name===t});return r?r.type:"void"}},{key:"generateNodeType",value:function(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}},{key:"setup",value:function(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}},{key:"generate",value:function(e){return this.getNodeType(e)}}],[{key:"type",get:function(){return"StructTypeNode"}}]),t}(el),hy=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,["vec3"])).structTypeNode=e,n.values=r,n.isStructNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.structTypeNode.getNodeType(e)}},{key:"getMemberType",value:function(e,t){return this.structTypeNode.getMemberType(e,t)}},{key:"_getChildren",value:function(){var e=this,r=x(_(t.prototype),"_getChildren",this).call(this),n=r.find(function(t){return t.childNode===e.structTypeNode});return r.splice(r.indexOf(n),1),r.push(n),r}},{key:"generate",value:function(e){var t=e.getVarFromNode(this),r=t.type,n=e.getPropertyName(t);return e.addLineFlowCode("".concat(n," = ").concat(e.generateStruct(r,this.structTypeNode.membersLayout,this.values)),this),t.name}}],[{key:"type",get:function(){return"StructNode"}}]),t}(el),hb=function(e){function t(){for(var e,r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];return v(this,t),(e=p(this,t)).members=n,e.isOutputStructNode=!0,e}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return"OutputType"}},{key:"generate",value:function(e){var t=e.getDataFromNode(this),r=t.members;if(void 0===r&&(r=t.members=this.members),void 0===t.membersLayout){for(var n=[],i=0;i<r.length;i++){var a="m"+i,o=r[i].getNodeType(e);n.push({name:a,type:o,index:i})}t.membersLayout=n,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}for(var s=e.getOutputStructName(),u=""!==s?s+".":"",l=0;l<r.length;l++){var c=r[l].build(e,t.membersLayout[l].type);e.addLineFlowCode("".concat(u,"m").concat(l," = ").concat(c),this)}return s}}],[{key:"type",get:function(){return"OutputStructNode"}}]),t}(el),hx=tx(hb),h_=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c.n;v(this,e),this.blending=t,this.blendSrc=c.C,this.blendDst=c.D,this.blendEquation=c.t,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}return y(e,[{key:"copy",value:function(e){return this.blending=e.blending,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.premultiplyAlpha=e.premultiplyAlpha,this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),e}(),hT=new h_(c.m),hS=new h_(c.s);function hN(e,t){for(var r=0;r<e.length;r++)if(e[r].name===t)return r;return -1}var hk=tx(function(e){function t(e){var r;return v(this,t),(r=p(this,t)).outputNodes=e,r.blendModes={output:hS},r.isMRTNode=!0,r}return T(t,e),y(t,[{key:"setBlendMode",value:function(e,t){return this.blendModes[e]=t,this}},{key:"getBlendMode",value:function(e){return this.blendModes[e]||hT}},{key:"has",value:function(e){return void 0!==this.outputNodes[e]}},{key:"get",value:function(e){return this.outputNodes[e]}},{key:"merge",value:function(e){var t=N({},this.outputNodes,e.outputNodes),r=N({},this.blendModes,e.blendModes),n=hk(t);return n.blendings=r,n}},{key:"setup",value:function(e){var r=this.outputNodes,n=[],i=e.renderer.getRenderTarget().textures;for(var a in r){var o=hN(i,a);if(-1!==o){var s=e.getOutputType(o);n[o]=r[a].convert(s)}}return e.getDataFromNode(this).members=n,this.members=n,x(_(t.prototype),"setup",this).call(this,e)}}],[{key:"type",get:function(){return"MRTNode"}}]),t}(hb)),hw=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t)).valueNode=e,n.conversionType=r,n.inputType=i,n.isBitcastNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){if(null!==this.inputType){var t=this.valueNode.getNodeType(e),r=e.getTypeLength(t);return e.getTypeFromLength(r,this.conversionType)}return this.conversionType}},{key:"generate",value:function(e){var t=this.getNodeType(e),r="";if(null!==this.inputType){var n=this.valueNode.getNodeType(e);r=1===e.getTypeLength(n)?this.inputType:e.changeComponentType(n,this.inputType)}else r=this.valueNode.getNodeType(e);return"".concat(e.getBitcastMethod(t,r),"( ").concat(this.valueNode.build(e,r)," )")}}],[{key:"type",get:function(){return"BitcastNode"}}]),t}(eh),hA=tT(hw).setParameterLength(2),hE=function(e){return new hw(e,"uint","float")},hR={},hC=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).isBitcountNode=!0,n}return T(t,e),y(t,[{key:"_resolveElementType",value:function(e,t,r){"int"===r?t.assign(hA(e,"uint")):t.assign(e)}},{key:"_returnDataNode",value:function(e){switch(e){case"uint":return tP;case"int":return tB;case"uvec2":return tO;case"uvec3":return tz;case"uvec4":return tj;case"ivec2":return tU;case"ivec3":return tG;case"ivec4":return tq}}},{key:"_createTrailingZerosBaseLayout",value:function(e,t){var r=this,n=this._returnDataNode(t);return tw(function(e){var i=E(e,1)[0],a=tP(0);return r._resolveElementType(i,a,t),n(hE(tF(a.bitAnd(nL(a)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}},{key:"_createLeadingZerosBaseLayout",value:function(e,t){var r=this,n=this._returnDataNode(t);return tw(function(e){var i=E(e,1)[0];tR(i.equal(tP(0)),function(){return tP(32)});var a=tP(0),o=tP(0);return r._resolveElementType(i,a,t),tR(a.shiftRight(16).equal(0),function(){o.addAssign(16),a.shiftLeftAssign(16)}),tR(a.shiftRight(24).equal(0),function(){o.addAssign(8),a.shiftLeftAssign(8)}),tR(a.shiftRight(28).equal(0),function(){o.addAssign(4),a.shiftLeftAssign(4)}),tR(a.shiftRight(30).equal(0),function(){o.addAssign(2),a.shiftLeftAssign(2)}),tR(a.shiftRight(31).equal(0),function(){o.addAssign(1)}),n(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}},{key:"_createOneBitsBaseLayout",value:function(e,t){var r=this,n=this._returnDataNode(t);return tw(function(e){var i=E(e,1)[0],a=tP(0);return r._resolveElementType(i,a,t),a.assign(a.sub(a.shiftRight(tP(1)).bitAnd(tP(0x55555555)))),a.assign(a.bitAnd(tP(0x33333333)).add(a.shiftRight(tP(2)).bitAnd(tP(0x33333333)))),n(a.add(a.shiftRight(tP(4))).bitAnd(tP(0xf0f0f0f)).mul(tP(0x1010101)).shiftRight(tP(24)))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}},{key:"_createMainLayout",value:function(e,t,r,n){var i=this._returnDataNode(t);return tw(function(e){var t=E(e,1)[0];if(1===r)return i(n(t));for(var a=i(0),o=["x","y","z","w"],s=0;s<r;s++){var u=o[s];a[u].assign(n(t[u]))}return a}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}},{key:"setup",value:function(e){var r=this.method,n=this.aNode;if(e.renderer.backend.isWebGPUBackend)return x(_(t.prototype),"setup",this).call(this,e);var i=this.getInputType(e),a=e.getElementType(i),o=e.getTypeLength(i),s="".concat(r,"_base_").concat(a),u="".concat(r,"_").concat(i),l=hR[s];if(void 0===l){switch(r){case hC.COUNT_LEADING_ZEROS:l=this._createLeadingZerosBaseLayout(s,a);break;case hC.COUNT_TRAILING_ZEROS:l=this._createTrailingZerosBaseLayout(s,a);break;case hC.COUNT_ONE_BITS:l=this._createOneBitsBaseLayout(s,a)}hR[s]=l}var c=hR[u];return void 0===c&&(c=this._createMainLayout(u,i,o,l),hR[u]=c),tw(function(){return c(n)})()}}],[{key:"type",get:function(){return"BitcountNode"}}]),t}(r7);hC.COUNT_TRAILING_ZEROS="countTrailingZeros",hC.COUNT_LEADING_ZEROS="countLeadingZeros",hC.COUNT_ONE_BITS="countOneBits";var hM=tT(hC,hC.COUNT_TRAILING_ZEROS).setParameterLength(1),hF=tT(hC,hC.COUNT_LEADING_ZEROS).setParameterLength(1),hB=tT(hC,hC.COUNT_ONE_BITS).setParameterLength(1),hP=tw(function(e){var t=E(e,1)[0].toUint().mul(0x2c9277b5).add(0xac564b05),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(0x108ef2d9);return r.shiftRight(22).bitXor(r).toFloat().mul(1/0x100000000)}),hL=function(e,t){return n0(rV(4,e.mul(rI(1,e))),t)},hD=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).vectorNode=r,n.encoding=e,n.isPackFloatNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return"uint"}},{key:"generate",value:function(e){var t=this.vectorNode.getNodeType(e);return"".concat(e.getFloatPackingMethod(this.encoding),"(").concat(this.vectorNode.build(e,t),")")}}],[{key:"type",get:function(){return"PackFloatNode"}}]),t}(eh),hU=tT(hD,"snorm").setParameterLength(1),hO=tT(hD,"unorm").setParameterLength(1),hI=tT(hD,"float16").setParameterLength(1),hV=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).uintNode=r,n.encoding=e,n.isUnpackFloatNode=!0,n}return T(t,e),y(t,[{key:"generateNodeType",value:function(){return"vec2"}},{key:"generate",value:function(e){var t=this.uintNode.getNodeType(e);return"".concat(e.getFloatUnpackingMethod(this.encoding),"(").concat(this.uintNode.build(e,t),")")}}],[{key:"type",get:function(){return"UnpackFloatNode"}}]),t}(eh),hG=tT(hV,"snorm").setParameterLength(1),hz=tT(hV,"unorm").setParameterLength(1),hW=tT(hV,"float16").setParameterLength(1),hH=tw(function(e){return E(e,1)[0].fract().sub(.5).abs()}).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),hq=tw(function(e){var t=E(e,1)[0];return tV(hH(t.z.add(hH(t.y.mul(1)))),hH(t.z.add(hH(t.x.mul(1)))),hH(t.y.add(hH(t.x.mul(1)))))}).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),hj=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=tV(r).toVar(),o=tF(1.4).toVar(),s=tF(0).toVar(),u=tV(a).toVar();return uP({start:tF(0),end:tF(3),type:"float",condition:"<="},function(){var e=tV(hq(u.mul(2))).toVar();a.addAssign(e.add(i.mul(tF(.1).mul(n)))),u.mulAssign(1.8),o.mulAssign(1.5),a.mulAssign(1.2);var t=tF(hH(a.z.add(hH(a.x.add(hH(a.y)))))).toVar();s.addAssign(t.div(o)),u.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),hX=tx(function(e){function t(){for(var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length,i=Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];return v(this,t),(e=p(this,t)).functionNodes=r,e.parametersNodes=i,e._candidateFn=null,e.global=!0,e}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.getCandidateFn(e).shaderNode.layout.type}},{key:"getCandidateFn",value:function(e){var t=this.parametersNodes,r=this._candidateFn;if(null===r){var n=null,i=-1,a=!0,o=!1,s=void 0;try{for(var u,l=this.functionNodes[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value,d=c.shaderNode.layout;if(null===d)throw Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");var h=d.inputs;if(t.length===h.length){for(var f=0,p=0;p<t.length;p++){var v=t[p],g=h[p];v.getNodeType(e)===g.type&&f++}f>i&&(n=c,i=f)}}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}this._candidateFn=r=n}return r}},{key:"setup",value:function(e){return this.getCandidateFn(e).apply(this,R(this.parametersNodes))}}],[{key:"type",get:function(){return"FunctionOverloadingNode"}}]),t}(el)),hK=function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return hX.apply(void 0,[e].concat(R(r)))}},hY=rC(0).setGroup(rA).onRenderUpdate(function(e){return e.time}),hQ=rC(0).setGroup(rA).onRenderUpdate(function(e){return e.deltaTime}),hZ=rC(0,"uint").setGroup(rA).onRenderUpdate(function(e){return e.frameId}),hJ=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=void 0===i?tD(.5):i;return dS(r.sub(a),n).add(a)}),h$=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=void 0===i?tD(.5):i,o=r.sub(a),s=o.dot(o),u=s.mul(s).mul(n);return r.add(o.mul(u))}),h0=tw(function(e){var t,r=e.position,n=void 0===r?null:r,i=e.horizontal,a=e.vertical;null!==n?((t=od.toVar())[3][0]=n.x,t[3][1]=n.y,t[3][2]=n.z):t=od;var o=a6.mul(t);return tf(void 0===i||i)&&(o[0][0]=od[0].length(),o[0][1]=0,o[0][2]=0),tf(void 0!==a&&a)&&(o[1][0]=0,o[1][1]=od[1].length(),o[1][2]=0),o[2][0]=0,o[2][1]=0,o[2][2]=1,a4.mul(o).mul(oN)}),h1=tw(function(e){var t=E(e,1)[0],r=void 0===t?null:t,n=u9();return u9(uJ(r)).sub(n).lessThan(0).select(aB,r)}),h2=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=void 0===n?ag():n,a=t[2],o=void 0===a?tF(0):a,s=r.x,u=r.y,l=o.mod(s.mul(u)).floor(),c=l.mod(s),d=u.sub(l.add(1).div(s).ceil()),h=r.reciprocal(),f=tD(c,d);return i.add(f).mul(h)}),h3=tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=void 0===n?null:n,a=t[2],o=void 0===a?null:a,s=t[3],u=void 0===s?tF(1):s,l=t[4],c=void 0===l?oN:l,d=t[5],h=(void 0===d?oP:d).abs().normalize();h=h.div(h.dot(tV(1)));var f=c.yz.mul(u),p=c.zx.mul(u),v=c.xy.mul(u),g=r.value,m=null!==i?i.value:g,y=null!==o?o.value:g;return rO(aS(g,f).mul(h.x),aS(m,p).mul(h.y),aS(y,v).mul(h.z))}),h4=new c.rd,h5=new c.Fc,h6=new c.Fc,h8=new c.Fc,h9=new c.Oc,h7=new c.Fc(0,0,-1),fe=new c.Jc,ft=new c.Fc,fr=new c.Fc,fn=new c.Jc,fi=new c.Dc,fa=new c.Kc,fo=aB.flipX();fa.depthTexture=new c.Cd(1,1);var fs=!1,fu=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this,t),(e=p(this,t,[r.defaultTexture||fa.texture,fo]))._reflectorBaseNode=r.reflector||new fl(e,r),e._depthNode=null,e.setUpdateMatrix(!1),e}return T(t,e),y(t,[{key:"reflector",get:function(){return this._reflectorBaseNode}},{key:"target",get:function(){return this._reflectorBaseNode.target}},{key:"getDepthNode",value:function(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new fu({defaultTexture:fa.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}},{key:"setup",value:function(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),x(_(t.prototype),"setup",this).call(this,e)}},{key:"clone",value:function(){var e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}},{key:"dispose",value:function(){x(_(t.prototype),"dispose",this).call(this),this._reflectorBaseNode.dispose()}}],[{key:"type",get:function(){return"ReflectorNode"}}]),t}(a_),fl=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v(this,t),r=p(this,t);var i=n.target,a=void 0===i?new c.Rc:i,o=n.resolutionScale,s=n.generateMipmaps,u=n.bounces,l=void 0===u||u,d=n.depth,h=n.samples;return r.textureNode=e,r.target=a,r.resolutionScale=void 0===o?1:o,void 0!==n.resolution&&((0,c.yc)('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),r.resolutionScale=n.resolution),r.generateMipmaps=void 0!==s&&s,r.bounces=l,r.depth=void 0!==d&&d,r.samples=void 0===h?0:h,r.updateBeforeType=l?et.RENDER:et.FRAME,r.virtualCameras=new WeakMap,r.renderTargets=new Map,r.forceUpdate=!1,r.hasOutput=!1,r}return T(t,e),y(t,[{key:"_updateResolution",value:function(e,t){var r=this.resolutionScale;t.getDrawingBufferSize(fi),e.setSize(Math.round(fi.width*r),Math.round(fi.height*r))}},{key:"setup",value:function(e){return this._updateResolution(fa,e.renderer),x(_(t.prototype),"setup",this).call(this,e)}},{key:"dispose",value:function(){x(_(t.prototype),"dispose",this).call(this);var e=!0,r=!1,n=void 0;try{for(var i,a=this.renderTargets.values()[Symbol.iterator]();!(e=(i=a.next()).done);e=!0)i.value.dispose()}catch(e){r=!0,n=e}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"getVirtualCamera",value:function(e){var t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}},{key:"getRenderTarget",value:function(e){var t=this.renderTargets.get(e);return void 0===t&&(t=new c.Kc(0,0,{type:c.Ba,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=c.ta,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new c.Cd),this.renderTargets.set(e,t)),t}},{key:"updateBefore",value:function(e){if(!1===this.bounces&&fs)return!1;fs=!0;var t=e.scene,r=e.camera,n=e.renderer,i=e.material,a=this.target,o=this.getVirtualCamera(r),s=this.getRenderTarget(o);n.getDrawingBufferSize(fi),this._updateResolution(s,n),h6.setFromMatrixPosition(a.matrixWorld),h8.setFromMatrixPosition(r.matrixWorld),h9.extractRotation(a.matrixWorld),h5.set(0,0,1),h5.applyMatrix4(h9),ft.subVectors(h6,h8);var u=!1;if(!0==ft.dot(h5)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fs=!1);u=!0}ft.reflect(h5).negate(),ft.add(h6),h9.extractRotation(r.matrixWorld),h7.set(0,0,-1),h7.applyMatrix4(h9),h7.add(h8),fr.subVectors(h6,h7),fr.reflect(h5).negate(),fr.add(h6),o.coordinateSystem=r.coordinateSystem,o.position.copy(ft),o.up.set(0,1,0),o.up.applyMatrix4(h9),o.up.reflect(h5),o.lookAt(fr),o.near=r.near,o.far=r.far,o.updateMatrixWorld(),o.projectionMatrix.copy(r.projectionMatrix),h4.setFromNormalAndCoplanarPoint(h5,h6),h4.applyMatrix4(o.matrixWorldInverse),fe.set(h4.normal.x,h4.normal.y,h4.normal.z,h4.constant);var l=o.projectionMatrix;fn.x=(Math.sign(fe.x)+l.elements[8])/l.elements[0],fn.y=(Math.sign(fe.y)+l.elements[9])/l.elements[5],fn.z=-1,fn.w=(1+l.elements[10])/l.elements[14],fe.multiplyScalar(1/fe.dot(fn)),l.elements[2]=fe.x,l.elements[6]=fe.y,l.elements[10]=n.coordinateSystem===c.pc?fe.z-0:fe.z+1-0,l.elements[14]=fe.w,this.textureNode.value=s.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;var d=n.getRenderTarget(),h=n.getMRT(),f=n.autoClear;n.setMRT(null),n.setRenderTarget(s),n.autoClear=!0;var p=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(n.clear(),this.hasOutput=!1):(n.render(t,o),this.hasOutput=!0),t.name=p,n.setMRT(h),n.setRenderTarget(d),n.autoClear=f,i.visible=!0,fs=!1,this.forceUpdate=!1}},{key:"resolution",get:function(){return(0,c.yc)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale},set:function(e){(0,c.yc)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}],[{key:"type",get:function(){return"ReflectorBaseNode"}}]),t}(el),fc=new c.Ae(-1,1,1,-1,0,1),fd=new(function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return v(this,t),(e=p(this,t)).setAttribute("position",new c.bd([-1,3,0,-1,-1,0,3,-1,0],3)),e.setAttribute("uv",new c.bd(!1===r?[0,-1,0,1,2,1]:[0,2,0,0,2,0],2)),e}return T(t,e),t}(c.dd)),fh=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[fd,r])).camera=fc,e.isQuadMesh=!0,e}return T(t,e),y(t,[{key:"renderAsync",value:function(e){return f(function(){return P(this,function(t){switch(t.label){case 0:return(0,c.yc)('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),[4,e.init()];case 1:return t.sent(),e.render(this,fc),[2]}})}).call(this)}},{key:"render",value:function(e){e.render(this,fc)}}]),t}(c.ld),ff=new c.Dc,fp=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{type:c.Ba};v(this,t);var o=new c.Kc(n,i,a);return(r=p(this,t,[o.texture,ag()])).isRTTNode=!0,r.node=e,r.width=n,r.height=i,r.renderTarget=o,r.textureNeedsUpdate=!0,r.autoUpdate=!0,r._resolutionScale=1,r._rttNode=null,r._quadMesh=new fh(new lo),r.updateBeforeType=et.RENDER,r}return T(t,e),y(t,[{key:"autoResize",get:function(){return null===this.width}},{key:"setup",value:function(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,x(_(t.prototype),"setup",this).call(this,e)}},{key:"setSize",value:function(e,t){var r=Math.floor(e*this._resolutionScale),n=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,n),this.textureNeedsUpdate=!0}},{key:"setResolutionScale",value:function(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}},{key:"getResolutionScale",value:function(){return this._resolutionScale}},{key:"updateBefore",value:function(e){var t=e.renderer;if(!1!==this.textureNeedsUpdate||!1!==this.autoUpdate){this.textureNeedsUpdate=!1;var r=t.getRenderTarget();if(!0===this.autoResize){var n=t.getDrawingBufferSize(ff),i=Math.floor(n.width*this._resolutionScale),a=Math.floor(n.height*this._resolutionScale);(i!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(i,a),this.textureNeedsUpdate=!0)}var o="RTT";this.node.name&&(o=this.node.name+" [ "+o+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=o,t.setRenderTarget(this.renderTarget),this._quadMesh.render(t),t.setRenderTarget(r)}}},{key:"clone",value:function(){var e=new a_(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}],[{key:"type",get:function(){return"RTTNode"}}]),t}(a_),fv=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return g(fp,[tg(e)].concat(R(r)))},fg=tw(function(e,t){var r,n=E(e,3),i=n[0],a=n[1],o=n[2];r=t.renderer.coordinateSystem===c.pc?tH(tV(i=tD(i.x,i.y.oneMinus()).mul(2).sub(1),a),1):tH(tV(i.x,i.y.oneMinus(),a).mul(2).sub(1),1);var s=tH(o.mul(r));return s.xyz.div(s.w)}),fm=tw(function(e){var t=E(e,2),r=t[0],n=t[1].mul(tH(r,1)),i=n.xy.div(n.w).mul(.5).add(.5).toVar();return tD(i.x,i.y.oneMinus())}),fy=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=am(aN(n)),o=tU(r.mul(a)).toVar(),s=aN(n,o).toVar(),u=aN(n,o.sub(tU(2,0))).toVar(),l=aN(n,o.sub(tU(1,0))).toVar(),c=aN(n,o.add(tU(1,0))).toVar(),d=aN(n,o.add(tU(2,0))).toVar(),h=aN(n,o.add(tU(0,2))).toVar(),f=aN(n,o.add(tU(0,1))).toVar(),p=aN(n,o.sub(tU(0,1))).toVar(),v=aN(n,o.sub(tU(0,2))).toVar(),g=nF(rI(tF(2).mul(l).sub(u),s)).toVar(),m=nF(rI(tF(2).mul(c).sub(d),s)).toVar(),y=nF(rI(tF(2).mul(f).sub(h),s)).toVar(),b=nF(rI(tF(2).mul(p).sub(v),s)).toVar(),x=fg(r,s,i).toVar();return ny(n$(g.lessThan(m).select(x.sub(fg(r.sub(tD(tF(1).div(a.x),0)),l,i)),x.negate().add(fg(r.add(tD(tF(1).div(a.x),0)),c,i))),y.lessThan(b).select(x.sub(fg(r.add(tD(0,tF(1).div(a.y))),f,i)),x.negate().add(fg(r.sub(tD(0,tF(1).div(a.y))),p,i)))))}),fb=tw(function(e){var t=E(e,1)[0];return nb(tF(52.9829189).mul(nb(nJ(t,tD(.06711056,.00583715)))))}).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),fx=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=tF(2.399963229728653),o=np(tF(r).add(.5).div(tF(n))),s=tF(r).mul(a).add(i);return tD(nT(s),nx(s)).mul(o)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),f_=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t)).callback=e,r.uvNode=n,r.isSampleNode=!0,r}return T(t,e),y(t,[{key:"setup",value:function(){return this.sample(ag())}},{key:"sample",value:function(e){return this.callback(e)}}],[{key:"type",get:function(){return"SampleNode"}}]),t}(el),fT=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float32Array;return v(this,t),(n=p(this,t,[ArrayBuffer.isView(e)?e:new i(e*r),r])).isStorageInstancedBufferAttribute=!0,n}return T(t,e),t}(c.pd),fS=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float32Array;return v(this,t),(n=p(this,t,[ArrayBuffer.isView(e)?e:new i(e*r),r])).isStorageBufferAttribute=!0,n}return T(t,e),t}(c.Zc),fN=t_(function(e){function t(){var e;return v(this,t),(e=p(this,t,["vec2"])).isPointUVNode=!0,e}return T(t,e),y(t,[{key:"generate",value:function(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}],[{key:"type",get:function(){return"PointUVNode"}}]),t}(el)),fk=new c.Oc,fw=rC(0).setGroup(rA).onRenderUpdate(function(e){return e.scene.backgroundBlurriness}),fA=rC(1).setGroup(rA).onRenderUpdate(function(e){return e.scene.backgroundIntensity}),fE=rC(new c.Oc).setGroup(rA).onRenderUpdate(function(e){var t=e.scene,r=t.background;return null!==r&&r.isTexture&&r.mapping!==c.ea?fk.makeRotationFromEuler(t.backgroundRotation).transpose():fk.identity(),fk}),fR=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e,r])).storeNode=i,n.mipLevel=0,n.isStorageTextureNode=!0,n.access=er.WRITE_ONLY,n}return T(t,e),y(t,[{key:"getInputType",value:function(){return"storageTexture"}},{key:"getTransformedUV",value:function(e){return e}},{key:"setup",value:function(e){x(_(t.prototype),"setup",this).call(this,e);var r=e.getNodeProperties(this);return r.storeNode=this.storeNode,r}},{key:"setAccess",value:function(e){return this.access=e,this}},{key:"setMipLevel",value:function(e){return this.mipLevel=e,this}},{key:"generate",value:function(e,r){return null!==this.storeNode?(this.generateStore(e),""):x(_(t.prototype),"generate",this).call(this,e,r)}},{key:"generateSnippet",value:function(e,t,r,n,i,a,o,s,u){var l=this.value;return e.generateStorageTextureLoad(l,t,r,n,a,u)}},{key:"toReadWrite",value:function(){return this.setAccess(er.READ_WRITE)}},{key:"toReadOnly",value:function(){return this.setAccess(er.READ_ONLY)}},{key:"toWriteOnly",value:function(){return this.setAccess(er.WRITE_ONLY)}},{key:"store",value:function(e,t){var r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}},{key:"generateStore",value:function(e){var r=e.getNodeProperties(this),n=r.uvNode,i=r.storeNode,a=r.depthNode,o=x(_(t.prototype),"generate",this).call(this,e,"property"),s=n.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),u=i.build(e,"vec4"),l=a?a.build(e,"int"):null,c=e.generateTextureStore(this.value,o,s,l,u);e.addLineFlowCode(c,this)}},{key:"clone",value:function(){var e=x(_(t.prototype),"clone",this).call(this);return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}],[{key:"type",get:function(){return"StorageTextureNode"}}]),t}(a_),fC=tx(fR).setParameterLength(1,3),fM=tx(function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e,r,i])).isStorageTexture3DNode=!0,n}return T(t,e),y(t,[{key:"getDefaultUV",value:function(){return tV(.5,.5,.5)}},{key:"setUpdateMatrix",value:function(){}},{key:"generateUV",value:function(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}},{key:"generateOffset",value:function(e,t){return t.build(e,"ivec3")}}],[{key:"type",get:function(){return"StorageTexture3DNode"}}]),t}(fR)).setParameterLength(1,3),fF=tw(function(e){var t=e.texture,r=e.uv,n=tV().toVar();return tR(r.x.lessThan(1e-4),function(){n.assign(tV(1,0,0))}).ElseIf(r.y.lessThan(1e-4),function(){n.assign(tV(0,1,0))}).ElseIf(r.z.lessThan(1e-4),function(){n.assign(tV(0,0,1))}).ElseIf(r.x.greaterThan(.9999),function(){n.assign(tV(-1,0,0))}).ElseIf(r.y.greaterThan(.9999),function(){n.assign(tV(0,-1,0))}).ElseIf(r.z.greaterThan(.9999),function(){n.assign(tV(0,0,-1))}).Else(function(){var e=t.sample(r.add(tV(-.01,0,0))).r.sub(t.sample(r.add(tV(.01,0,0))).r),i=t.sample(r.add(tV(0,-.01,0))).r.sub(t.sample(r.add(tV(0,.01,0))).r),a=t.sample(r.add(tV(0,0,-.01))).r.sub(t.sample(r.add(tV(0,0,.01))).r);n.assign(tV(e,i,a))}),n.normalize()}),fB=tx(function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(r=p(this,t,[e,n,i])).isTexture3DNode=!0,r}return T(t,e),y(t,[{key:"getInputType",value:function(){return"texture3D"}},{key:"getDefaultUV",value:function(){return tV(.5,.5,.5)}},{key:"setUpdateMatrix",value:function(){}},{key:"generateUV",value:function(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}},{key:"generateOffset",value:function(e,t){return t.build(e,"ivec3")}},{key:"normal",value:function(e){return fF({texture:this,uv:e})}}],[{key:"type",get:function(){return"Texture3DNode"}}]),t}(a_)).setParameterLength(1,3),fP=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(n=p(this,t,[e,r,i])).userData=i,n}return T(t,e),y(t,[{key:"updateReference",value:function(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}],[{key:"type",get:function(){return"UserDataNode"}}]),t}(o4),fL=new WeakMap;function fD(e){var t=fL.get(e);return void 0===t&&(t={},fL.set(e,t)),t}function fU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=fD(e),n=r[t];return void 0===n&&(r[t]=n=new c.Oc,r[t].copy(e.matrixWorld)),n}var fO=t_(function(e){function t(){var e;return v(this,t),(e=p(this,t,["vec2"])).projectionMatrix=null,e.updateType=et.OBJECT,e.updateAfterType=et.OBJECT,e.previousModelWorldMatrix=rC(new c.Oc),e.previousProjectionMatrix=rC(new c.Oc).setGroup(rA),e.previousCameraViewMatrix=rC(new c.Oc),e}return T(t,e),y(t,[{key:"setProjectionMatrix",value:function(e){this.projectionMatrix=e}},{key:"update",value:function(e){var t=e.frameId,r=e.camera,n=fU(e.object);this.previousModelWorldMatrix.value.copy(n);var i=fD(r);i.frameId!==t&&(i.frameId=t,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new c.Oc,i.previousCameraViewMatrix=new c.Oc,i.currentProjectionMatrix=new c.Oc,i.currentCameraViewMatrix=new c.Oc,i.previousProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),i.previousCameraViewMatrix.copy(r.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),i.currentCameraViewMatrix.copy(r.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}},{key:"updateAfter",value:function(e){var t=e.object;fU(t).copy(t.matrixWorld)}},{key:"setup",value:function(){var e=null===this.projectionMatrix?a4:rC(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(oy).mul(oN),n=this.previousProjectionMatrix.mul(t).mul(ok);return rI(r.xy.div(r.w),n.xy.div(n.w))}}],[{key:"type",get:function(){return"VelocityNode"}}]),t}(eh)),fI=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return nj(1,r.oneMinus().div(n)).oneMinus()}).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),fV=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return nj(r.div(n.oneMinus()),1)}).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),fG=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return r.oneMinus().mul(n.oneMinus()).oneMinus()}).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),fz=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return n7(r.mul(2).mul(n),r.oneMinus().mul(2).mul(n.oneMinus()).oneMinus(),nK(.5,r))}).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),fW=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=n.a.add(r.a.mul(n.a.oneMinus()));return tH(n.rgb.mul(n.a).add(r.rgb.mul(r.a).mul(n.a.oneMinus())).div(i),i)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),fH=tw(function(e){return fK(E(e,1)[0].rgb)}),fq=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return(void 0===n?tF(1):n).mix(fK(r.rgb),r.rgb).max(0)}),fj=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=void 0===n?tF(0):n,a=rO(r.r,r.g,r.b).div(3),o=r.r.max(r.g.max(r.b)),s=o.sub(a).mul(i).mul(-3);return n7(r.rgb,o,s).max(0)}),fX=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=void 0===n?tF(1):n,a=tV(.57735,.57735,.57735),o=i.cos();return tV(r.rgb.mul(o).add(a.cross(r.rgb).mul(i.sin()).add(a.mul(nJ(a,r.rgb).mul(o.oneMinus()))))).max(0)}),fK=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tV(c.Hc.getLuminanceCoefficients(new c.Fc));return nJ(e,t)},fY=tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=void 0===n?tV(1):n,a=t[2],o=void 0===a?tV(0):a,s=t[3],u=void 0===s?tV(1):s,l=t[4],d=void 0===l?tF(1):l,h=t[5],f=void 0===h?tV(c.Hc.getLuminanceCoefficients(new c.Fc,c.Jb)):h,p=r.rgb.dot(tV(f)),v=nX(r.rgb.mul(i).add(o),0),g=v.pow(u);return tR(v.r.greaterThan(0),function(){v.r.assign(g.r)}),tR(v.g.greaterThan(0),function(){v.g.assign(g.g)}),tR(v.b.greaterThan(0),function(){v.b.assign(g.b)}),v.assign(p.add(v.sub(p).mul(d)).max(0)),tH(v.rgb,r.a)}),fQ=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return r.mul(n).floor().div(n)}),fZ=null,fJ=tx(function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:aB,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),null===fZ&&(fZ=new c.zd),p(this,t,[e,r,fZ])}return T(t,e),y(t,[{key:"getTextureForReference",value:function(){return fZ}},{key:"updateReference",value:function(){return this}}],[{key:"type",get:function(){return"ViewportSharedTextureNode"}}]),t}(uj)).setParameterLength(0,2),f$=new c.Dc,f0=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[r])).passNode=e,n.isPassTextureNode=!0,n.setUpdateMatrix(!1),n}return T(t,e),y(t,[{key:"setup",value:function(e){return e.getNodeProperties(this).passNode=this.passNode,x(_(t.prototype),"setup",this).call(this,e)}},{key:"clone",value:function(){return new this.constructor(this.passNode,this.value)}}],[{key:"type",get:function(){return"PassTextureNode"}}]),t}(a_),f1=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return v(this,t),(n=p(this,t,[e,null])).textureName=r,n.previousTexture=i,n.isPassMultipleTextureNode=!0,n}return T(t,e),y(t,[{key:"updateTexture",value:function(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}},{key:"setup",value:function(e){return this.updateTexture(),x(_(t.prototype),"setup",this).call(this,e)}},{key:"clone",value:function(){var e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}],[{key:"type",get:function(){return"PassMultipleTextureNode"}}]),t}(f0),f2=function(e){function t(e,r,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};v(this,t),(i=p(this,t,["vec4"])).scope=e,i.scene=r,i.camera=n,i.options=a,i._width=1,i._height=1;var o=new c.Kc(i._width,i._height,N({type:c.Ba},a));o.texture.name="output";var s=null;return(i.scope===f2.DEPTH||!1!==a.depthBuffer)&&((s=new c.Cd).isRenderTargetTexture=!0,s.name="depth",o.depthTexture=s),i.renderTarget=o,i.overrideMaterial=null,i.transparent=!0,i.opaque=!0,i.contextNode=null,i._contextNodeCache=null,i._textures={output:o.texture},null!==s&&(i._textures.depth=s),i._textureNodes={},i._linearDepthNodes={},i._viewZNodes={},i._previousTextures={},i._previousTextureNodes={},i._cameraNear=rC(0),i._cameraFar=rC(0),i._mrt=null,i._layers=null,i._resolutionScale=1,i._viewport=null,i._scissor=null,i.isPassNode=!0,i.updateBeforeType=et.FRAME,i.global=!0,i}return T(t,e),y(t,[{key:"setResolutionScale",value:function(e){return this._resolutionScale=e,this}},{key:"getResolutionScale",value:function(){return this._resolutionScale}},{key:"setResolution",value:function(e){return(0,c.wc)("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}},{key:"getResolution",value:function(){return(0,c.wc)("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}},{key:"setLayers",value:function(e){return this._layers=e,this}},{key:"getLayers",value:function(){return this._layers}},{key:"setMRT",value:function(e){return this._mrt=e,this}},{key:"getMRT",value:function(){return this._mrt}},{key:"getTexture",value:function(e){var t=this._textures[e];if(void 0===t){if("depth"===e)throw Error("THREE.PassNode: Depth texture is not available for this pass.");(t=this.renderTarget.texture.clone()).name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}},{key:"getPreviousTexture",value:function(e){var t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}},{key:"toggleTexture",value:function(e){var t=this._previousTextures[e];if(void 0!==t){var r=this._textures[e],n=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[n]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}},{key:"getTextureNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"output",t=this._textureNodes[e];return void 0===t&&((t=new f1(this,e)).updateTexture(),this._textureNodes[e]=t),t}},{key:"getPreviousTextureNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"output",t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),(t=new f1(this,e,!0)).updateTexture(),this._previousTextureNodes[e]=t),t}},{key:"getViewZNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"depth",t=this._viewZNodes[e];if(void 0===t){var r=this._cameraNear,n=this._cameraFar;this._viewZNodes[e]=t=u4(this.getTextureNode(e),r,n)}return t}},{key:"getLinearDepthNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"depth",t=this._linearDepthNodes[e];if(void 0===t){var r=this._cameraNear,n=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=u0(i,r,n)}return t}},{key:"compileAsync",value:function(e){return f(function(){var t,r;return P(this,function(n){switch(n.label){case 0:return t=e.getRenderTarget(),r=e.getMRT(),e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),[4,e.compileAsync(this.scene,this.camera)];case 1:return n.sent(),e.setRenderTarget(t),e.setMRT(r),[2]}})}).call(this)}},{key:"setup",value:function(e){var t=e.renderer;return this.renderTarget.samples=void 0===this.options.samples?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),!0===t.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=c.Aa),this.scope===f2.COLOR?this.getTextureNode():this.getLinearDepthNode()}},{key:"updateBefore",value:function(e){var t,r=e.renderer,n=this.scene,i=r.getOutputRenderTarget();i&&!0===i.isXRRenderTarget?(t=r.xr.getCamera(),r.xr.updateCamera(t),f$.set(i.width,i.height)):(t=this.camera,r.getDrawingBufferSize(f$)),this.setSize(f$.width,f$.height);var a=r.getRenderTarget(),o=r.getMRT(),s=r.autoClear,u=r.transparent,l=r.opaque,c=t.layers.mask,d=r.contextNode,h=n.overrideMaterial;for(var f in this._cameraNear.value=t.near,this._cameraFar.value=t.far,null!==this._layers&&(t.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(f);null!==this.overrideMaterial&&(n.overrideMaterial=this.overrideMaterial),r.setRenderTarget(this.renderTarget),r.setMRT(this._mrt),r.autoClear=!0,r.transparent=this.transparent,r.opaque=this.opaque,null!==this.contextNode&&((null===this._contextNodeCache||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:ih(N({},r.contextNode.getFlowContextData(),this.contextNode.getFlowContextData()))}),r.contextNode=this._contextNodeCache.context);var p=n.name;n.name=this.name?this.name:n.name,r.render(n,t),n.name=p,n.overrideMaterial=h,r.setRenderTarget(a),r.setMRT(o),r.autoClear=s,r.transparent=u,r.opaque=l,r.contextNode=d,t.layers.mask=c}},{key:"setSize",value:function(e,t){this._width=e,this._height=t;var r=Math.floor(this._width*this._resolutionScale),n=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,n),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}},{key:"setScissor",value:function(e,t,r,n){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new c.Jc),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,n))}},{key:"setViewport",value:function(e,t,r,n){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new c.Jc),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,n))}},{key:"dispose",value:function(){this.renderTarget.dispose()}}],[{key:"type",get:function(){return"PassNode"}}]),t}(eh);f2.COLOR="color",f2.DEPTH="depth";var f3=function(e){function t(e,r,n,i,a){var o;return v(this,t),(o=p(this,t,[f2.COLOR,e,r])).colorNode=n,o.thicknessNode=i,o.alphaNode=a,o._materialCache=new WeakMap,o.name="Outline Pass",o}return T(t,e),y(t,[{key:"updateBefore",value:function(e){var r=this,n=e.renderer,i=n.getRenderObjectFunction();n.setRenderObjectFunction(function(e,t,i,a,o,s,u,l){if((o.isMeshToonMaterial||o.isMeshToonNodeMaterial)&&!1===o.wireframe){var c=r._getOutlineMaterial(o);n.renderObject(e,t,i,a,c,s,u,l)}n.renderObject(e,t,i,a,o,s,u,l)}),x(_(t.prototype),"updateBefore",this).call(this,e),n.setRenderObjectFunction(i)}},{key:"_createMaterial",value:function(){var e=new lo;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=c.k;var t=oP.negate(),r=a4.mul(oy),n=tF(1),i=r.mul(tH(oN,1)),a=r.mul(tH(oN.add(t),1)),o=ny(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(n)),e.colorNode=tH(this.colorNode,this.alphaNode),e}},{key:"_getOutlineMaterial",value:function(e){var t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}],[{key:"type",get:function(){return"ToonOutlinePassNode"}}]),t}(f2),f4=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return r.mul(n).clamp()}).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),f5=tw(function(e){var t=E(e,2),r=t[0],n=t[1];return(r=r.mul(n)).div(r.add(1)).clamp()}).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),f6=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=(r=(r=r.mul(n)).sub(.004).max(0)).mul(r.mul(6.2).add(.5)),a=r.mul(r.mul(6.2).add(1.7)).add(.06);return i.div(a).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),f8=tw(function(e){var t=E(e,1)[0],r=t.mul(t.add(.0245786)).sub(90537e-9),n=t.mul(t.add(.432951).mul(.983729)).add(.238081);return r.div(n)}),f9=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tY(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),a=tY(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(n).div(.6),r=f8(r=i.mul(r)),(r=a.mul(r)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),f7=tY(tV(1.6605,-.1246,-.0182),tV(-.5876,1.1329,-.1006),tV(-.0728,-.0083,1.1187)),pe=tY(tV(.6274,.0691,.0164),tV(.3293,.9195,.088),tV(.0433,.0113,.8956)),pt=tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tV(t.mul(t)).toVar(),n=tV(r.mul(r)).toVar();return tF(15.5).mul(n.mul(r)).sub(rV(40.14,n.mul(t))).add(rV(31.96,n).sub(rV(6.868,r.mul(t))).add(rV(.4298,r).add(rV(.1191,t).sub(.00232))))}),pr=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tV(r).toVar(),a=tY(tV(.856627153315983,.137318972929847,.11189821299995),tV(.0951212405381588,.761241990602591,.0767994186031903),tV(.0482516061458583,.101439036467562,.811302368396859)),o=tY(tV(1.1271005818144368,-.1413297634984383,-.14132976349843826),tV(-.11060664309660323,1.157823702216272,-.11060664309660294),tV(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=tF(-12.47393),u=tF(4.026069);return i.mulAssign(n),i.assign(pe.mul(i)),i.assign(a.mul(i)),i.assign(nX(i,1e-10)),i.assign(nf(i)),i.assign(i.sub(s).div(u.sub(s))),i.assign(ie(i,0,1)),i.assign(pt(i)),i.assign(o.mul(i)),i.assign(n0(nX(tV(0),i),tV(2.2))),i.assign(f7.mul(i)),i.assign(ie(i,0,1)),i}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pn=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tF(.76),a=tF(.15),o=nj((r=r.mul(n)).r,nj(r.g,r.b)),s=ic(o.lessThan(.08),o.sub(rV(6.25,o.mul(o))),.04);r.subAssign(s);var u=nX(r.r,nX(r.g,r.b));tR(u.lessThan(i),function(){return r});var l=rI(1,i),c=rI(1,l.mul(l).div(u.add(l.sub(i))));r.mulAssign(c.div(u));var d=rI(1,rG(1,a.mul(u.sub(c)).add(1)));return n7(r,tV(c),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pi=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return v(this,t),(e=p(this,t,["code"])).isCodeNode=!0,e.global=!0,e.code=r,e.includes=n,e.language=i,e}return T(t,e),y(t,[{key:"setIncludes",value:function(e){return this.includes=e,this}},{key:"getIncludes",value:function(){return this.includes}},{key:"generate",value:function(e){var t=this.getIncludes(e),r=!0,n=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0)a.value.build(e)}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}var s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.code=this.code,e.language=this.language}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.code=e.code,this.language=e.language}}],[{key:"type",get:function(){return"CodeNode"}}]),t}(el),pa=tx(pi).setParameterLength(1,3),po=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return v(this,t),p(this,t,[e,r,n])}return T(t,e),y(t,[{key:"generateNodeType",value:function(e){return this.getNodeFunction(e).type}},{key:"getMemberType",value:function(e,t){var r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}},{key:"getInputs",value:function(e){return this.getNodeFunction(e).inputs}},{key:"getNodeFunction",value:function(e){var t=e.getDataFromNode(this),r=t.nodeFunction;return void 0===r&&(t.nodeFunction=r=e.parser.parseFunction(this.code)),r}},{key:"generate",value:function(e,r){x(_(t.prototype),"generate",this).call(this,e);var n=this.getNodeFunction(e),i=n.name,a=n.type,o=e.getCodeFromNode(this,a);""!==i&&(o.name=i);var s=e.getPropertyName(o);return o.code=this.getNodeFunction(e).getCode(s)+"\n","property"===r?s:e.format("".concat(s,"()"),a,r)}}],[{key:"type",get:function(){return"FunctionNode"}}]),t}(pi),ps=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=new po(e,r,n);return tS(function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=i).call.apply(t,R(r))},i)};function pu(e){var t,r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||oE.z).negate()}var pl=tw(function(e,t){var r=E(e,2);return ii(r[0],r[1],pu(t))}),pc=tw(function(e,t){var r=E(e,1)[0],n=pu(t);return r.mul(r,n,n).negate().exp().oneMinus()}),pd=tw(function(e,t){var r=E(e,2),n=r[0],i=r[1],a=pu(t),o=i.sub(ow.y).max(0).toConst().mul(a).toConst();return n.mul(n,o,o).negate().exp().oneMinus()}),ph=tw(function(e){var t=E(e,2),r=t[0];return tH(t[1].toFloat().mix(rh.rgb,r.toVec3()),rh.a)}),pf=null,pp=null,pv=tx(function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:tF(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF();return v(this,t),(e=p(this,t)).minNode=r,e.maxNode=n,e}return T(t,e),y(t,[{key:"getVectorLength",value:function(e){var t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),n=e.getTypeLength(Z(t.value)),i=e.getTypeLength(Z(r.value));return n>i?n:i}},{key:"generateNodeType",value:function(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}},{key:"getConstNode",value:function(e){var t=null;if(e.traverse(function(e){!0===e.isConstNode&&(t=e)}),null===t)throw new ab('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}},{key:"setup",value:function(e){var t=e.object,r=null;if(t.count>1){var n=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),a=n.value,o=i.value,s=e.getTypeLength(Z(a)),u=e.getTypeLength(Z(o));pf=pf||new c.Jc,pp=pp||new c.Jc,pf.setScalar(0),pp.setScalar(0),1===s?pf.setScalar(a):a.isColor?pf.set(a.r,a.g,a.b,1):pf.set(a.x,a.y,a.z||0,a.w||0),1===u?pp.setScalar(o):o.isColor?pp.set(o.r,o.g,o.b,1):pp.set(o.x,o.y,o.z||0,o.w||0);for(var l=4*t.count,d=new Float32Array(l),h=0;h<l;h++){var f=h%4,p=pf.getComponent(f),v=pp.getComponent(f);d[h]=c.Cc.lerp(p,v,Math.random())}var g=this.getNodeType(e);if(4*t.count*4<=e.getUniformBufferLimit())r=aw(d,"vec4",t.count).element(iQ).convert(g);else{var m=new c.pd(d,4);e.geometry.setAttribute("__range"+this.id,m),r=ij(m).convert(g)}}else r=tF(0);return r}}],[{key:"type",get:function(){return"RangeNode"}}]),t}(el)).setParameterLength(2),pg=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[r]))._builtinName=e,n}return T(t,e),y(t,[{key:"getHash",value:function(e){return this.getBuiltinName(e)}},{key:"generateNodeType",value:function(){return this.nodeType}},{key:"setBuiltinName",value:function(e){return this._builtinName=e,this}},{key:"getBuiltinName",value:function(){return this._builtinName}},{key:"hasBuiltin",value:function(e){return e.hasBuiltin(this._builtinName)}},{key:"generate",value:function(e,t){var r=this.getBuiltinName(e),n=this.getNodeType(e);return"compute"===e.shaderStage?e.format(r,n,t):((0,c.wc)("ComputeBuiltinNode: Compute built-in value ".concat(r," can not be accessed in the ").concat(e.shaderStage," stage")),e.generateConst(n))}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.global=this.global,e._builtinName=this._builtinName}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.global=e.global,this._builtinName=e._builtinName}}],[{key:"type",get:function(){return"ComputeBuiltinNode"}}]),t}(el),pm=function(e,t){return new pg(e,t)},py=pm("numWorkgroups","uvec3"),pb=pm("workgroupId","uvec3"),px=pm("globalId","uvec3"),p_=pm("localId","uvec3"),pT=pm("subgroupSize","uint"),pS=tx(function(e){function t(e){var r;return v(this,t),(r=p(this,t)).scope=e,r.isBarrierNode=!0,r}return T(t,e),y(t,[{key:"setup",value:function(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}},{key:"generate",value:function(e){var t=this.scope;!0===e.renderer.backend.isWebGLBackend?e.addFlowCode(" // ".concat(t,"Barrier \n")):e.addLineFlowCode("".concat(t,"Barrier()"),this)}}]),t}(el)),pN=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).isWorkgroupInfoElementNode=!0,n}return T(t,e),y(t,[{key:"generate",value:function(e,r){var n,i=e.isContextAssign();if(n=x(_(t.prototype),"generate",this).call(this,e),!0!==i){var a=this.getNodeType(e);n=e.format(n,a,r)}return n}}]),t}(ec),pk=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return v(this,t),(n=p(this,t,[r])).bufferType=r,n.bufferCount=i,n.isWorkgroupInfoNode=!0,n.elementType=r,n.scope=e,n.name="",n}return T(t,e),y(t,[{key:"setName",value:function(e){return this.name=e,this}},{key:"label",value:function(e){return(0,c.wc)('TSL: "label()" has been deprecated. Use "setName()" instead.',new z),this.setName(e)}},{key:"setScope",value:function(e){return this.scope=e,this}},{key:"getElementType",value:function(){return this.elementType}},{key:"getInputType",value:function(){return"".concat(this.scope,"Array")}},{key:"element",value:function(e){return new pN(this,e)}},{key:"generate",value:function(e){var t=""!==this.name?this.name:"".concat(this.scope,"Array_").concat(this.id);return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}]),t}(el),pw=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t,["uint"])).method=e,i.pointerNode=r,i.valueNode=n,i.parents=!0,i}return T(t,e),y(t,[{key:"getInputType",value:function(e){return this.pointerNode.getNodeType(e)}},{key:"generateNodeType",value:function(e){return this.getInputType(e)}},{key:"generate",value:function(e){var t=e.getNodeProperties(this),r=t.parents,n=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,u=[];u.push("&".concat(o.build(e,a))),null!==s&&u.push(s.build(e,a));var l="".concat(e.getMethod(n,i),"( ").concat(u.join(", ")," )");if(!r||1!==r.length||!0!==r[0].isStackNode)return void 0===t.constNode&&(t.constNode=at(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}],[{key:"type",get:function(){return"AtomicFunctionNode"}}]),t}(el);pw.ATOMIC_LOAD="atomicLoad",pw.ATOMIC_STORE="atomicStore",pw.ATOMIC_ADD="atomicAdd",pw.ATOMIC_SUB="atomicSub",pw.ATOMIC_MAX="atomicMax",pw.ATOMIC_MIN="atomicMin",pw.ATOMIC_AND="atomicAnd",pw.ATOMIC_OR="atomicOr",pw.ATOMIC_XOR="atomicXor";var pA=tx(pw),pE=function(e,t,r){return pA(e,t,r).toStack()},pR=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return v(this,t),(r=p(this,t)).method=e,r.aNode=n,r.bNode=i,r}return T(t,e),y(t,[{key:"getInputType",value:function(e){var t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}},{key:"generateNodeType",value:function(e){var t=this.method;return t===pR.SUBGROUP_ELECT?"bool":t===pR.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}},{key:"generate",value:function(e,t){var r=this.method,n=this.getNodeType(e),i=this.getInputType(e),a=this.aNode,o=this.bNode,s=[];if(r===pR.SUBGROUP_BROADCAST||r===pR.SUBGROUP_SHUFFLE||r===pR.QUAD_BROADCAST){var u=o.getNodeType(e);s.push(a.build(e,n),o.build(e,"float"===u?"int":n))}else r===pR.SUBGROUP_SHUFFLE_XOR||r===pR.SUBGROUP_SHUFFLE_DOWN||r===pR.SUBGROUP_SHUFFLE_UP?s.push(a.build(e,n),o.build(e,"uint")):(null!==a&&s.push(a.build(e,i)),null!==o&&s.push(o.build(e,i)));var l=0===s.length?"()":"( ".concat(s.join(", ")," )");return e.format("".concat(e.getMethod(r,n)).concat(l),n,t)}},{key:"serialize",value:function(e){x(_(t.prototype),"serialize",this).call(this,e),e.method=this.method}},{key:"deserialize",value:function(e){x(_(t.prototype),"deserialize",this).call(this,e),this.method=e.method}}],[{key:"type",get:function(){return"SubgroupFunctionNode"}}]),t}(eh);pR.SUBGROUP_ELECT="subgroupElect",pR.SUBGROUP_BALLOT="subgroupBallot",pR.SUBGROUP_ADD="subgroupAdd",pR.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",pR.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",pR.SUBGROUP_MUL="subgroupMul",pR.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",pR.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",pR.SUBGROUP_AND="subgroupAnd",pR.SUBGROUP_OR="subgroupOr",pR.SUBGROUP_XOR="subgroupXor",pR.SUBGROUP_MIN="subgroupMin",pR.SUBGROUP_MAX="subgroupMax",pR.SUBGROUP_ALL="subgroupAll",pR.SUBGROUP_ANY="subgroupAny",pR.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",pR.QUAD_SWAP_X="quadSwapX",pR.QUAD_SWAP_Y="quadSwapY",pR.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",pR.SUBGROUP_BROADCAST="subgroupBroadcast",pR.SUBGROUP_SHUFFLE="subgroupShuffle",pR.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",pR.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",pR.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",pR.QUAD_BROADCAST="quadBroadcast";var pC,pM=tT(pR,pR.SUBGROUP_ELECT).setParameterLength(0),pF=tT(pR,pR.SUBGROUP_BALLOT).setParameterLength(1),pB=tT(pR,pR.SUBGROUP_ADD).setParameterLength(1),pP=tT(pR,pR.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),pL=tT(pR,pR.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),pD=tT(pR,pR.SUBGROUP_MUL).setParameterLength(1),pU=tT(pR,pR.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),pO=tT(pR,pR.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),pI=tT(pR,pR.SUBGROUP_AND).setParameterLength(1),pV=tT(pR,pR.SUBGROUP_OR).setParameterLength(1),pG=tT(pR,pR.SUBGROUP_XOR).setParameterLength(1),pz=tT(pR,pR.SUBGROUP_MIN).setParameterLength(1),pW=tT(pR,pR.SUBGROUP_MAX).setParameterLength(1),pH=tT(pR,pR.SUBGROUP_ALL).setParameterLength(0),pq=tT(pR,pR.SUBGROUP_ANY).setParameterLength(0),pj=tT(pR,pR.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),pX=tT(pR,pR.QUAD_SWAP_X).setParameterLength(1),pK=tT(pR,pR.QUAD_SWAP_Y).setParameterLength(1),pY=tT(pR,pR.QUAD_SWAP_DIAGONAL).setParameterLength(1),pQ=tT(pR,pR.SUBGROUP_BROADCAST).setParameterLength(2),pZ=tT(pR,pR.SUBGROUP_SHUFFLE).setParameterLength(2),pJ=tT(pR,pR.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),p$=tT(pR,pR.SUBGROUP_SHUFFLE_UP).setParameterLength(2),p0=tT(pR,pR.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),p1=tT(pR,pR.QUAD_BROADCAST).setParameterLength(1);function p2(e){var t=(pC=pC||new WeakMap).get(e);return void 0===t&&pC.set(e,t={}),t}function p3(e){var t=p2(e);return t.shadowMatrix||(t.shadowMatrix=rC("mat4").setGroup(rA).onRenderUpdate(function(t){return(!0!==e.castShadow||!1===t.renderer.shadowMap.enabled)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix}))}function p4(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ow,r=p3(e).mul(t);return r.xyz.div(r.w)}function p5(e){var t=p2(e);return t.position||(t.position=rC(new c.Fc).setGroup(rA).onRenderUpdate(function(t,r){return r.value.setFromMatrixPosition(e.matrixWorld)}))}function p6(e){var t=p2(e);return t.targetPosition||(t.targetPosition=rC(new c.Fc).setGroup(rA).onRenderUpdate(function(t,r){return r.value.setFromMatrixPosition(e.target.matrixWorld)}))}function p8(e){var t=p2(e);return t.viewPosition||(t.viewPosition=rC(new c.Fc).setGroup(rA).onRenderUpdate(function(t,r){var n=t.camera;r.value=r.value||new c.Fc,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(n.matrixWorldInverse)}))}var p9=function(e){return a6.transformDirection(p5(e).sub(p6(e)))},p7=t0("vec3","totalDiffuse"),ve=t0("vec3","totalSpecular"),vt=t0("vec3","outgoingLight"),vr=function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;if(s.isAnalyticLightNode&&s.light.id===e)return s}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return null},vn=new WeakMap,vi=[],va=function(e){function t(){var e;return v(this,t),(e=p(this,t,["vec3"])).totalDiffuseNode=p7,e.totalSpecularNode=ve,e.outgoingLightNode=vt,e._lights=[],e.global=!0,e}return T(t,e),y(t,[{key:"customCacheKey",value:function(){for(var e=this._lights,t=0;t<e.length;t++){var r=e[t];if(vi.push(r.id),vi.push(+!!r.castShadow),!0===r.isSpotLight){var n=null!==r.map?r.map.id:-1,i=r.colorNode?r.colorNode.getCacheKey():-1;vi.push(n,i)}}var a=q(vi);return vi.length=0,a}},{key:"getHash",value:function(e){var t=e.getDataFromNode(this);if(void 0===t.lightNodesHash){var r=this.setupLightsNode(e);t.lightNodes=r;var n=[],i=!0,a=!1,o=void 0;try{for(var s,u=r[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n.push(l.getHash())}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}t.lightNodesHash="lights-"+n.join(",")}return t.lightNodesHash}},{key:"analyze",value:function(e){var t=e.getNodeProperties(this),r=!0,n=!1,i=void 0;try{for(var a,o=t.nodes[Symbol.iterator]();!(r=(a=o.next()).done);r=!0)a.value.build(e)}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}t.outputNode.build(e)}},{key:"setupLightsNode",value:function(e){var t=[],r=e.getDataFromNode(this).lightNodes||null,n=R(e.context.materialLightings).concat(R(this._lights)).sort(function(e,t){return e.id-t.id}),i=e.renderer.library,a=!0,o=!1,s=void 0;try{for(var u,l=n[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var d=u.value;if(d.isNode)t.push(d);else{var h=null;if(null!==r&&(h=vr(d.id,r)),null===h){var f=i.getLightNodeClass(d.constructor);if(null===f){(0,c.wc)("LightsNode.setupNodeLights: Light node not found for ".concat(d.constructor.name));continue}!1===vn.has(d)&&vn.set(d,new f(d)),h=vn.get(d)}t.push(h)}}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}return t}},{key:"setupDirectLight",value:function(e,t,r){var n=e.context,i=n.lightingModel,a=n.reflectedLight;i.direct(k(N({},r),{lightNode:t,reflectedLight:a}),e)}},{key:"setupDirectRectAreaLight",value:function(e,t,r){var n=e.context,i=n.lightingModel,a=n.reflectedLight;i.directRectArea(k(N({},r),{lightNode:t,reflectedLight:a}),e)}},{key:"setupLights",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0)a.value.build(e)}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}}},{key:"getLightNodes",value:function(e){var t=e.getDataFromNode(this);return void 0===t.lightNodes&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}},{key:"setup",value:function(e){var t=e.lightsNode;e.lightsNode=this;var r=this.outgoingLightNode,n=e.context,i=n.lightingModel,a=e.getNodeProperties(this);if(i){var o=this.totalDiffuseNode,s=this.totalSpecularNode;n.outgoingLight=r,a.nodes=e.addStack().nodes,i.start(e);var u=n.backdrop,l=n.backdropAlpha,c=n.reflectedLight,d=c.directDiffuse,h=c.directSpecular,f=c.indirectDiffuse,p=c.indirectSpecular,v=d.add(f);null!==u&&(v=tV(null!==l?l.mix(v,u):u)),o.assign(v),s.assign(h.add(p)),r.assign(o.add(s)),i.finish(e),r=r.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,r}},{key:"setLights",value:function(e){return this._lights=e,this}},{key:"getLights",value:function(){return this._lights}},{key:"hasLights",get:function(){return this._lights.length>0}}],[{key:"type",get:function(){return"LightsNode"}}]),t}(el),vo=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).light=e,r.updateBeforeType=et.RENDER,r.isShadowBaseNode=!0,r}return T(t,e),y(t,[{key:"setupShadowPosition",value:function(e){var t=e.context,r=e.material;vs.assign(r.receivedShadowPositionNode||t.shadowPositionWorld||ow)}}],[{key:"type",get:function(){return"ShadowBaseNode"}}]),t}(el),vs=t0("vec3","shadowPositionWorld");function vu(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new c.Tc),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function vl(e,t){return t=vu(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function vc(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function vd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vh(e,t){return t=vd(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function vf(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function vp(e,t,r){return vh(t,r=vl(e,r))}function vv(e,t,r){vc(e,r),vf(t,r)}var vg,vm=Object.freeze({__proto__:null,resetRendererAndSceneState:vp,resetRendererState:vl,resetSceneState:vh,restoreRendererAndSceneState:vv,restoreRendererState:vc,restoreSceneState:vf,saveRendererAndSceneState:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return vd(t,r=vu(e,r))},saveRendererState:vu,saveSceneState:vd}),vy=new WeakMap,vb=tw(function(e){var t=e.depthTexture,r=e.shadowCoord,n=e.depthLayer,i=aS(t,r.xy).setName("t_basic");return t.isArrayTexture&&(i=i.depth(n)),i.compare(r.z)}),vx=tw(function(e){var t=e.depthTexture,r=e.shadowCoord,n=e.shadow,i=e.depthLayer,a=function(e,r){var n=aS(t,e);return t.isArrayTexture&&(n=n.depth(i)),n.compare(r)},o=o5("mapSize","vec2",n).setGroup(rA),s=o5("radius","float",n).setGroup(rA),u=tD(1).div(o),l=s.mul(u.x),c=fb(aL.xy).mul(6.28318530718);return rO(a(r.xy.add(fx(0,5,c).mul(l)),r.z),a(r.xy.add(fx(1,5,c).mul(l)),r.z),a(r.xy.add(fx(2,5,c).mul(l)),r.z),a(r.xy.add(fx(3,5,c).mul(l)),r.z),a(r.xy.add(fx(4,5,c).mul(l)),r.z)).mul(.2)}),v_=tw(function(e){var t=e.depthTexture,r=e.shadowCoord,n=e.shadow,i=e.depthLayer,a=o5("mapSize","vec2",n).setGroup(rA),o=tD(1).div(a),s=r.xy,u=nb(s.mul(a).add(.5)).toConst();s.subAssign(u.sub(.5).mul(o));var l=function(e){var n=aS(t,s).offset(e).gather();return t.isArrayTexture&&(n=n.depth(i)),n.compare(r.z)},c=l(tU(-1,1)).toConst(),d=l(tU(1,1)).toConst(),h=l(tU(-1,-1)).toConst(),f=l(tU(1,-1)).toConst();return rO(n7(c.x,d.y,u.x).add(c.y).add(d.x).mul(u.y),n7(c.w,d.z,u.x).add(c.z).add(d.w),n7(h.x,f.y,u.x).add(h.y).add(f.x),n7(h.w,f.z,u.x).add(h.z).add(f.w).mul(u.y.oneMinus())).mul(1/9)}),vT=tw(function(e,t){var r=e.depthTexture,n=e.shadowCoord,i=e.depthLayer,a=aS(r).sample(n.xy);r.isArrayTexture&&(a=a.depth(i));var o=(a=a.rg).x,s=nX(1e-7,a.y.mul(a.y)),u=t.renderer.reversedDepthBuffer?nK(o,n.z):nK(n.z,o),l=tF(1).toVar();return tR(u.notEqual(1),function(){var e=n.z.sub(o),t=s.div(s.add(e.mul(e)));t=ie(rI(t,.3).div(.65)),l.assign(nX(u,t))}),l}),vS=function(e){var t=vy.get(e);return void 0===t&&((t=new lo).colorNode=tH(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=c.m,t.fog=!1,vy.set(e,t)),t},vN=function(e){var t=vy.get(e);void 0!==t&&(t.dispose(),vy.delete(e))},vk=new dP,vw=[],vA=function(e,t,r,n){vw[0]=e,vw[1]=t;var i=vk.get(vw);return(void 0===i||i.shadowType!==r||i.useVelocity!==n)&&((i=function(i,a,o,s,u,l,d,h,f){(!0===i.castShadow||i.receiveShadow&&r===c.i)&&(n&&($(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,u,l,d,h,f),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))}).shadowType=r,i.useVelocity=n,vk.set(vw,i)),vw[0]=null,vw[1]=null,i},vE=tw(function(e){var t=e.samples,r=e.radius,n=e.size,i=e.shadowPass,a=e.depthLayer,o=tF(0).toVar("meanVertical"),s=tF(0).toVar("squareMeanVertical"),u=t.lessThanEqual(tF(1)).select(tF(0),tF(2).div(t.sub(1))),l=t.lessThanEqual(tF(1)).select(tF(0),tF(-1));uP({start:tB(0),end:tB(t),type:"int",condition:"<"},function(e){var t=e.i,c=l.add(tF(t).mul(u)),d=i.sample(rO(aL.xy,tD(0,c).mul(r)).div(n));i.value.isArrayTexture&&(d=d.depth(a)),d=d.x,o.addAssign(d),s.addAssign(d.mul(d))}),o.divAssign(t),s.divAssign(t);var c=np(s.sub(o.mul(o)).max(0));return tD(o,c)}),vR=tw(function(e){var t=e.samples,r=e.radius,n=e.size,i=e.shadowPass,a=e.depthLayer,o=tF(0).toVar("meanHorizontal"),s=tF(0).toVar("squareMeanHorizontal"),u=t.lessThanEqual(tF(1)).select(tF(0),tF(2).div(t.sub(1))),l=t.lessThanEqual(tF(1)).select(tF(0),tF(-1));uP({start:tB(0),end:tB(t),type:"int",condition:"<"},function(e){var t=e.i,c=l.add(tF(t).mul(u)),d=i.sample(rO(aL.xy,tD(c,0).mul(r)).div(n));i.value.isArrayTexture&&(d=d.depth(a)),o.addAssign(d.x),s.addAssign(rO(d.y.mul(d.y),d.x.mul(d.x)))}),o.divAssign(t),s.divAssign(t);var c=np(s.sub(o.mul(o)).max(0));return tD(o,c)}),vC=[vb,vx,v_,vT],vM=new fh,vF=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e])).shadow=n||e.shadow,r.shadowMap=null,r.vsmShadowMapVertical=null,r.vsmShadowMapHorizontal=null,r.vsmMaterialVertical=null,r.vsmMaterialHorizontal=null,r._node=null,r._currentShadowType=null,r._cameraFrameId=new WeakMap,r.isShadowNode=!0,r.depthLayer=0,r}return T(t,e),y(t,[{key:"setupShadowFilter",value:function(e,t){var r=t.filterFn,n=t.depthTexture,i=t.shadowCoord,a=t.shadow,o=t.depthLayer,s=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),u=r({depthTexture:n,shadowCoord:i,shadow:a,depthLayer:o});return s.select(u,tF(1))}},{key:"setupShadowCoord",value:function(e,t){var r,n=this.shadow,i=e.renderer,a=n.biasNode||o5("bias","float",n).setGroup(rA),o=t;if(n.camera.isOrthographicCamera||!0!==i.logarithmicDepthBuffer)r=(o=o.xyz.div(o.w)).z;else{var s=o.w;o=o.xy.div(s);var u=o5("near","float",n.camera).setGroup(rA),l=o5("far","float",n.camera).setGroup(rA);r=u5(s.negate(),u,l)}return tV(o.x,o.y.oneMinus(),i.reversedDepthBuffer?r.sub(a):r.add(a))}},{key:"getShadowFilterFn",value:function(e){return vC[e]}},{key:"setupRenderTarget",value:function(e,t){var r=new c.Cd(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?c.jc:c.gc;var n=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return n.texture.name="ShadowMap",n.texture.type=e.mapType,n.depthTexture=r,{shadowMap:n,depthTexture:r}}},{key:"setupShadow",value:function(e){var t=this,r=e.renderer,n=e.camera,i=this.light,a=this.shadow,o=this.setupRenderTarget(a,e),s=o.depthTexture,u=o.shadowMap,l=r.shadowMap.type,d=r.hasCompatibility(c.rc.TEXTURE_COMPARE);if((l===c.g||l===c.h)&&d?(s.minFilter=c.qa,s.magFilter=c.qa):(s.minFilter=c.na,s.magFilter=c.na),a.camera.coordinateSystem=n.coordinateSystem,a.camera.updateProjectionMatrix(),l===c.i&&!0!==a.isPointLightShadow){s.compareFunction=null,u.depth>1?(u._vsmShadowMapVertical||(u._vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:c.Oa,type:c.Ba,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=u._vsmShadowMapVertical,u._vsmShadowMapHorizontal||(u._vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:c.Oa,type:c.Ba,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=u._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:c.Oa,type:c.Ba,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:c.Oa,type:c.Ba,depthBuffer:!1}));var h=aS(s);s.isArrayTexture&&(h=h.depth(this.depthLayer));var f=aS(this.vsmShadowMapVertical.texture);s.isArrayTexture&&(f=f.depth(this.depthLayer));var p=o5("blurSamples","float",a).setGroup(rA),v=o5("radius","float",a).setGroup(rA),g=o5("mapSize","vec2",a).setGroup(rA),m=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lo);m.fragmentNode=vE({samples:p,radius:v,size:g,shadowPass:h,depthLayer:this.depthLayer}).context(e.getSharedContext()),m.name="VSMVertical",(m=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lo)).fragmentNode=vR({samples:p,radius:v,size:g,shadowPass:f,depthLayer:this.depthLayer}).context(e.getSharedContext()),m.name="VSMHorizontal"}var y,b=o5("intensity","float",a).setGroup(rA),x=o5("normalBias","float",a).setGroup(rA),_=p3(i),T=oI.mul(x);y=!r.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?_.mul(vs.add(T)):rC("mat4").onObjectUpdate(function(e,t){var r=e.object;return t.value.multiplyMatrices(_.value,r.matrixWorld)}).mul(oN).add(_.mul(tH(T,0)));var S=this.setupShadowCoord(e,y),N=r.shadowFilterHook,k=N&&N(a,this.light)||a.filterNode||this.getShadowFilterFn(r.shadowMap.type)||null;if(null===k)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");var w,A,E=l===c.i&&!0!==a.isPointLightShadow?this.vsmShadowMapHorizontal.texture:s,R=this.setupShadowFilter(e,{filterFn:k,shadowTexture:u.texture,depthTexture:E,shadowCoord:S,shadow:a,depthLayer:this.depthLayer});!0===r.shadowMap.transmitted&&(u.texture.isCubeTexture?w=o2(u.texture,S.xyz):(w=aS(u.texture,S),s.isArrayTexture&&(w=w.depth(this.depthLayer)))),A=w?n7(1,R.rgb.mix(w,1),b.mul(w.a)).toVar():n7(1,R,b).toVar(),this.shadowMap=u,this.shadow.map=u;var C="".concat(this.light.type," Shadow [ ").concat(this.light.name||"ID: "+this.light.id," ]");return w&&A.toInspector("".concat(C," / Color"),function(){return t.shadowMap.texture.isCubeTexture?o2(t.shadowMap.texture,lN()):aS(t.shadowMap.texture)}),A.toInspector("".concat(C," / Depth"),function(){var e,r=o5("near","float",t.shadow.camera),n=o5("far","float",t.shadow.camera);return e=t.shadowMap.texture.isCubeTexture?o2(t.shadowMap.depthTexture,lN()).r:aS(t.shadowMap.depthTexture).r,u0(t.shadow.camera.isPerspectiveCamera?u4(e,r,n):u1(e,r,n),r,n).oneMinus()})}},{key:"setup",value:function(e){var t=this;if(!1!==e.renderer.shadowMap.enabled)return tw(function(){var r=e.renderer.shadowMap.type;t._currentShadowType!==r&&(t._reset(),t._node=null);var n=t._node;return t.setupShadowPosition(e),null===n&&(t._node=n=t.setupShadow(e),t._currentShadowType=r),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}},{key:"renderShadow",value:function(e){var t=this.shadow,r=this.shadowMap,n=this.light,i=e.renderer,a=e.scene;t.updateMatrices(n),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);var o=a.name;a.name="Shadow Map [ ".concat(n.name||"ID: "+n.id," ]"),i.render(a,t.camera),a.name=o}},{key:"updateShadow",value:function(e){var t=this.shadowMap,r=this.light,n=this.shadow,i=e.renderer,a=e.scene,o=e.camera,s=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;var l=n.camera.layers.mask;0xfffffffe&n.camera.layers.mask||(n.camera.layers.mask=o.layers.mask);var d=i.getRenderObjectFunction(),h=i.getMRT(),f=!!h&&h.has("velocity");vg=vp(i,a,vg),a.overrideMaterial=vS(r),i.setRenderObjectFunction(vA(i,n,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),s===c.i&&!0!==n.isPointLightShadow&&this.vsmPass(i),n.camera.layers.mask=l,vv(i,a,vg)}},{key:"vsmPass",value:function(e){var t=this.shadow,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),vM.material=this.vsmMaterialVertical,vM.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),vM.material=this.vsmMaterialHorizontal,vM.render(e)}},{key:"dispose",value:function(){this._reset(),x(_(t.prototype),"dispose",this).call(this)}},{key:"_reset",value:function(){this._currentShadowType=null,vN(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}},{key:"updateBefore",value:function(e){var t=this.shadow,r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}],[{key:"type",get:function(){return"ShadowNode"}}]),t}(vo),vB=function(e,t){return new vF(e,t)},vP=new c.Tc,vL=new c.Oc,vD=new c.Fc,vU=new c.Fc,vO=[new c.Fc(1,0,0),new c.Fc(-1,0,0),new c.Fc(0,-1,0),new c.Fc(0,1,0),new c.Fc(0,0,1),new c.Fc(0,0,-1)],vI=[new c.Fc(0,-1,0),new c.Fc(0,-1,0),new c.Fc(0,0,-1),new c.Fc(0,0,1),new c.Fc(0,-1,0),new c.Fc(0,-1,0)],vV=[new c.Fc(1,0,0),new c.Fc(-1,0,0),new c.Fc(0,1,0),new c.Fc(0,-1,0),new c.Fc(0,0,1),new c.Fc(0,0,-1)],vG=[new c.Fc(0,-1,0),new c.Fc(0,-1,0),new c.Fc(0,0,1),new c.Fc(0,0,-1),new c.Fc(0,-1,0),new c.Fc(0,-1,0)],vz=tw(function(e){var t=e.depthTexture,r=e.bd3D,n=e.dp;return o2(t,r).compare(n)}),vW=tw(function(e){var t=e.depthTexture,r=e.bd3D,n=e.dp,i=e.shadow,a=o5("radius","float",i).setGroup(rA),o=o5("mapSize","vec2",i).setGroup(rA),s=a.div(o.x),u=nF(r),l=ny(n$(r,u.x.greaterThan(u.z).select(tV(0,1,0),tV(1,0,0)))),c=n$(r,l),d=fb(aL.xy).mul(6.28318530718),h=fx(0,5,d),f=fx(1,5,d),p=fx(2,5,d),v=fx(3,5,d),g=fx(4,5,d);return o2(t,r.add(l.mul(h.x).add(c.mul(h.y)).mul(s))).compare(n).add(o2(t,r.add(l.mul(f.x).add(c.mul(f.y)).mul(s))).compare(n)).add(o2(t,r.add(l.mul(p.x).add(c.mul(p.y)).mul(s))).compare(n)).add(o2(t,r.add(l.mul(v.x).add(c.mul(v.y)).mul(s))).compare(n)).add(o2(t,r.add(l.mul(g.x).add(c.mul(g.y)).mul(s))).compare(n)).mul(.2)}),vH=tw(function(e,t){var r=e.filterFn,n=e.depthTexture,i=e.shadowCoord,a=e.shadow,o=i.xyz.toConst(),s=o.abs().toConst(),u=s.x.max(s.y).max(s.z),l=rC("float").setGroup(rA).onRenderUpdate(function(){return a.camera.near}),c=rC("float").setGroup(rA).onRenderUpdate(function(){return a.camera.far}),d=o5("bias","float",a).setGroup(rA),h=tF(1).toVar();return tR(u.sub(c).lessThanEqual(0).and(u.sub(l).greaterThanEqual(0)),function(){t.renderer.reversedDepthBuffer?(e=u3(u.negate(),l,c)).subAssign(d):t.renderer.logarithmicDepthBuffer?(e=u5(u.negate(),l,c)).addAssign(d):(e=u2(u.negate(),l,c)).addAssign(d);var e,i=o.normalize();h.assign(r({depthTexture:n,bd3D:i,dp:e,shadow:a}))}),h}),vq=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),p(this,t,[e,r])}return T(t,e),y(t,[{key:"getShadowFilterFn",value:function(e){return e===c.f?vz:vW}},{key:"setupShadowCoord",value:function(e,t){return t}},{key:"setupShadowFilter",value:function(e,t){return vH({filterFn:t.filterFn,depthTexture:t.depthTexture,shadowCoord:t.shadowCoord,shadow:t.shadow})}},{key:"setupRenderTarget",value:function(e,t){var r=new c.Dd(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?c.jc:c.gc;var n=t.createCubeRenderTarget(e.mapSize.width);return n.texture.name="PointShadowMap",n.depthTexture=r,{shadowMap:n,depthTexture:r}}},{key:"renderShadow",value:function(e){var t=this.shadow,r=this.shadowMap,n=this.light,i=e.renderer,a=e.scene,o=t.camera,s=t.matrix,u=i.coordinateSystem===c.pc,l=u?vO:vV,d=u?vI:vG;r.setSize(t.mapSize.width,t.mapSize.width);var h=i.autoClear,f=i.getClearColor(vP),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(var v=0;v<6;v++){i.setRenderTarget(r,v),i.clear();var g=n.distance||o.far;g!==o.far&&(o.far=g,o.updateProjectionMatrix()),vD.setFromMatrixPosition(n.matrixWorld),o.position.copy(vD),vU.copy(o.position),vU.add(l[v]),o.up.copy(d[v]),o.lookAt(vU),o.updateMatrixWorld(),s.makeTranslation(-vD.x,-vD.y,-vD.z),vL.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(vL,o.coordinateSystem,o.reversedDepth);var m=a.name;a.name="Point Light Shadow [ ".concat(n.name||"ID: "+n.id," ] - Face ").concat(v+1),i.render(a,o),a.name=m}i.autoClear=h,i.setClearColor(f,p)}}],[{key:"type",get:function(){return"PointShadowNode"}}]),t}(vF),vj=function(e,t){return new vq(e,t)},vX=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t)).light=r,e.color=new c.Tc,e.colorNode=r&&r.colorNode||rC(e.color).setGroup(rA),e.baseColorNode=null,e.shadowNode=null,e.shadowColorNode=null,e.isAnalyticLightNode=!0,e.updateType=et.FRAME,r&&r.shadow&&(e._shadowDisposeListener=function(){e.disposeShadow()},r.addEventListener("dispose",e._shadowDisposeListener)),e}return T(t,e),y(t,[{key:"dispose",value:function(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),x(_(t.prototype),"dispose",this).call(this)}},{key:"disposeShadow",value:function(){void 0!==this._spParkedShadowNode&&null!==this._spParkedShadowNode&&(this._spParkedShadowNode.dispose(),this._spParkedShadowNode=null,this._spParkedShadowColorNode=null),null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}},{key:"getHash",value:function(){return this.light.uuid}},{key:"getLightVector",value:function(e){return p8(this.light).sub(e.context.positionView||oE)}},{key:"setupDirect",value:function(){}},{key:"setupDirectRectArea",value:function(){}},{key:"setupShadowNode",value:function(){return vB(this.light)}},{key:"setupShadow",value:function(e){if(!1!==e.renderer.shadowMap.enabled){var t=this.shadowColorNode;if(null===t){var r,n=this.light.shadow.shadowNode;void 0!==this._spParkedShadowNode&&null!==this._spParkedShadowNode&&void 0===n?(this.shadowNode=this._spParkedShadowNode,this.shadowColorNode=t=this._spParkedShadowColorNode,this._spParkedShadowNode=null,this._spParkedShadowColorNode=null):(r=void 0!==n?tg(n):this.setupShadowNode(),this.shadowNode=r,this.shadowColorNode=t=this.colorNode.mul(r),this.baseColorNode=this.colorNode)}e.context.getShadow&&(t=e.context.getShadow(this,e)),this.colorNode=t}}},{key:"setup",value:function(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this._spParkedShadowNode=this.shadowNode,this._spParkedShadowColorNode=this.shadowColorNode,this.shadowNode=null,this.shadowColorNode=null);var t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}},{key:"update",value:function(){var e=this.light;this.color.copy(e.color).multiplyScalar(e.intensity)}}],[{key:"type",get:function(){return"AnalyticLightNode"}}]),t}(uG),vK=tw(function(e){var t=e.lightDistance,r=e.cutoffDistance,n=e.decayExponent,i=t.pow(n).max(.01).reciprocal();return r.greaterThan(0).select(i.mul(t.div(r).pow4().oneMinus().clamp().pow2()),i)}),vY=function(e){var t=e.color,r=e.lightVector,n=e.cutoffDistance,i=e.decayExponent,a=r.normalize(),o=vK({lightDistance:r.length(),cutoffDistance:n,decayExponent:i});return{lightDirection:a,lightColor:t.mul(o)}},vQ=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r])).cutoffDistanceNode=rC(0).setGroup(rA),e.decayExponentNode=rC(2).setGroup(rA),e}return T(t,e),y(t,[{key:"update",value:function(e){var r=this.light;x(_(t.prototype),"update",this).call(this,e),this.cutoffDistanceNode.value=r.distance,this.decayExponentNode.value=r.decay}},{key:"setupShadowNode",value:function(){return vj(this.light)}},{key:"setupDirect",value:function(e){return vY({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}],[{key:"type",get:function(){return"PointLightNode"}}]),t}(vX),vZ=tw(function(e){var t=E(e,1)[0],r=(void 0===t?ag():t).mul(2),n=r.x.floor(),i=r.y.floor();return n.add(i).mod(2).sign()}),vJ=tw(function(e,t){var r,n=E(e,1)[0],i=void 0===n?ag():n,a=t.renderer,o=t.material,s=n9(i.mul(2).sub(1));if(o.alphaToCoverage&&a.currentSamples>0){var u=tF(s.fwidth()).toVar();r=ii(u.oneMinus(),u.add(1),s).oneMinus()}else r=ic(s.greaterThan(1),0,1);return r}),v$=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tF(t[2]).toVar(),a=tF(n).toVar();return ic(tL(r).toVar(),a,i).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),v0=tw(function(e){var t=E(e,2),r=t[0],n=tL(t[1]).toVar(),i=tF(r).toVar();return ic(n,i.negate(),i).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),v1=tw(function(e){return tB(ng(tF(E(e,1)[0]).toVar()))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),v2=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=tF(r).toVar();return n.assign(v1(i)),i.sub(tF(n))}),v3=hK([tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=tF(t[5]).toVar(),u=tF(o).toVar(),l=tF(a).toVar(),c=tF(i).toVar(),d=tF(n).toVar(),h=tF(r).toVar(),f=tF(rI(1,u)).toVar();return rI(1,s).mul(h.mul(f).add(d.mul(u))).add(s.mul(c.mul(f).add(l.mul(u))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),tw(function(e){var t=E(e,6),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=tF(t[5]).toVar(),u=tF(o).toVar(),l=tV(a).toVar(),c=tV(i).toVar(),d=tV(n).toVar(),h=tV(r).toVar(),f=tF(rI(1,u)).toVar();return rI(1,s).mul(h.mul(f).add(d.mul(u))).add(s.mul(c.mul(f).add(l.mul(u))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),v4=hK([tw(function(e){var t=E(e,11),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],d=t[9],h=tF(t[10]).toVar(),f=tF(d).toVar(),p=tF(c).toVar(),v=tF(l).toVar(),g=tF(u).toVar(),m=tF(s).toVar(),y=tF(o).toVar(),b=tF(a).toVar(),x=tF(i).toVar(),_=tF(n).toVar(),T=tF(r).toVar(),S=tF(rI(1,p)).toVar(),N=tF(rI(1,f)).toVar();return tF(rI(1,h)).toVar().mul(N.mul(T.mul(S).add(_.mul(p))).add(f.mul(x.mul(S).add(b.mul(p))))).add(h.mul(N.mul(y.mul(S).add(m.mul(p))).add(f.mul(g.mul(S).add(v.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),tw(function(e){var t=E(e,11),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],d=t[9],h=tF(t[10]).toVar(),f=tF(d).toVar(),p=tF(c).toVar(),v=tV(l).toVar(),g=tV(u).toVar(),m=tV(s).toVar(),y=tV(o).toVar(),b=tV(a).toVar(),x=tV(i).toVar(),_=tV(n).toVar(),T=tV(r).toVar(),S=tF(rI(1,p)).toVar(),N=tF(rI(1,f)).toVar();return tF(rI(1,h)).toVar().mul(N.mul(T.mul(S).add(_.mul(p))).add(f.mul(x.mul(S).add(b.mul(p))))).add(h.mul(N.mul(y.mul(S).add(m.mul(p))).add(f.mul(g.mul(S).add(v.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),v5=hK([tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tF(t[2]).toVar(),a=tF(n).toVar(),o=tP(r).toVar(),s=tP(o.bitAnd(tP(7))).toVar(),u=tF(v$(s.lessThan(tP(4)),a,i)).toVar(),l=tF(rV(2,v$(s.lessThan(tP(4)),i,a))).toVar();return v0(u,tL(s.bitAnd(tP(1)))).add(v0(l,tL(s.bitAnd(tP(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tF(n).toVar(),u=tP(r).toVar(),l=tP(u.bitAnd(tP(15))).toVar(),c=tF(v$(l.lessThan(tP(8)),s,o)).toVar(),d=tF(v$(l.lessThan(tP(4)),o,v$(l.equal(tP(12)).or(l.equal(tP(14))),s,a))).toVar();return v0(c,tL(l.bitAnd(tP(1)))).add(v0(d,tL(l.bitAnd(tP(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),v6=hK([tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tF(t[2]).toVar(),a=tF(n).toVar(),o=tz(r).toVar();return tV(v5(o.x,a,i),v5(o.y,a,i),v5(o.z,a,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tF(n).toVar(),u=tz(r).toVar();return tV(v5(u.x,s,o,a),v5(u.y,s,o,a),v5(u.z,s,o,a))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),v8=tw(function(e){return rV(.6616,tF(E(e,1)[0]).toVar())}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),v9=tw(function(e){return rV(.982,tF(E(e,1)[0]).toVar())}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),v7=hK([v8,tw(function(e){return rV(.6616,tV(E(e,1)[0]).toVar())}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),ge=hK([v9,tw(function(e){return rV(.982,tV(E(e,1)[0]).toVar())}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),gt=tw(function(e){var t=E(e,2),r=t[0],n=tB(t[1]).toVar(),i=tP(r).toVar();return i.shiftLeft(n).bitOr(i.shiftRight(tB(32).sub(n)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),gr=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2];r.subAssign(i),r.bitXorAssign(gt(i,tB(4))),i.addAssign(n),n.subAssign(r),n.bitXorAssign(gt(r,tB(6))),r.addAssign(i),i.subAssign(n),i.bitXorAssign(gt(n,tB(8))),n.addAssign(r),r.subAssign(i),r.bitXorAssign(gt(i,tB(16))),i.addAssign(n),n.subAssign(r),n.bitXorAssign(gt(r,tB(19))),r.addAssign(i),i.subAssign(n),i.bitXorAssign(gt(n,tB(4))),n.addAssign(r)}),gn=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tP(t[2]).toVar(),a=tP(n).toVar(),o=tP(r).toVar();return i.bitXorAssign(a),i.subAssign(gt(a,tB(14))),o.bitXorAssign(i),o.subAssign(gt(i,tB(11))),a.bitXorAssign(o),a.subAssign(gt(o,tB(25))),i.bitXorAssign(a),i.subAssign(gt(a,tB(16))),o.bitXorAssign(i),o.subAssign(gt(i,tB(4))),a.bitXorAssign(o),a.subAssign(gt(o,tB(14))),i.bitXorAssign(a),i.subAssign(gt(a,tB(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),gi=tw(function(e){return tF(tP(E(e,1)[0]).toVar()).div(tF(tP(tB(0xffffffff))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ga=tw(function(e){var t=tF(E(e,1)[0]).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),go=hK([tw(function(e){var t=tB(E(e,1)[0]).toVar(),r=tP(tP(1)).toVar(),n=tP(tP(tB(0xdeadbeef)).add(r.shiftLeft(tP(2))).add(tP(13))).toVar();return gn(n.add(tP(t)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),tw(function(e){var t=E(e,2),r=t[0],n=tB(t[1]).toVar(),i=tB(r).toVar(),a=tP(tP(2)).toVar(),o=tP().toVar(),s=tP().toVar(),u=tP().toVar();return o.assign(s.assign(u.assign(tP(tB(0xdeadbeef)).add(a.shiftLeft(tP(2))).add(tP(13))))),o.addAssign(tP(i)),s.addAssign(tP(n)),gn(o,s,u)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tB(n).toVar(),o=tB(r).toVar(),s=tP(tP(3)).toVar(),u=tP().toVar(),l=tP().toVar(),c=tP().toVar();return u.assign(l.assign(c.assign(tP(tB(0xdeadbeef)).add(s.shiftLeft(tP(2))).add(tP(13))))),u.addAssign(tP(o)),l.addAssign(tP(a)),c.addAssign(tP(i)),gn(u,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tB(t[3]).toVar(),o=tB(i).toVar(),s=tB(n).toVar(),u=tB(r).toVar(),l=tP(tP(4)).toVar(),c=tP().toVar(),d=tP().toVar(),h=tP().toVar();return c.assign(d.assign(h.assign(tP(tB(0xdeadbeef)).add(l.shiftLeft(tP(2))).add(tP(13))))),c.addAssign(tP(u)),d.addAssign(tP(s)),h.addAssign(tP(o)),gr(c,d,h),c.addAssign(tP(a)),gn(c,d,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),tw(function(e){var t=E(e,5),r=t[0],n=t[1],i=t[2],a=t[3],o=tB(t[4]).toVar(),s=tB(a).toVar(),u=tB(i).toVar(),l=tB(n).toVar(),c=tB(r).toVar(),d=tP(tP(5)).toVar(),h=tP().toVar(),f=tP().toVar(),p=tP().toVar();return h.assign(f.assign(p.assign(tP(tB(0xdeadbeef)).add(d.shiftLeft(tP(2))).add(tP(13))))),h.addAssign(tP(c)),f.addAssign(tP(l)),p.addAssign(tP(u)),gr(h,f,p),h.addAssign(tP(s)),f.addAssign(tP(o)),gn(h,f,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),gs=hK([tw(function(e){var t=E(e,2),r=t[0],n=tB(t[1]).toVar(),i=tP(go(tB(r).toVar(),n)).toVar(),a=tz().toVar();return a.x.assign(i.bitAnd(tB(255))),a.y.assign(i.shiftRight(tB(8)).bitAnd(tB(255))),a.z.assign(i.shiftRight(tB(16)).bitAnd(tB(255))),a}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tB(n).toVar(),o=tP(go(tB(r).toVar(),a,i)).toVar(),s=tz().toVar();return s.x.assign(o.bitAnd(tB(255))),s.y.assign(o.shiftRight(tB(8)).bitAnd(tB(255))),s.z.assign(o.shiftRight(tB(16)).bitAnd(tB(255))),s}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),gu=hK([tw(function(e){var t=tD(E(e,1)[0]).toVar(),r=tB().toVar(),n=tB().toVar(),i=tF(v2(t.x,r)).toVar(),a=tF(v2(t.y,n)).toVar(),o=tF(ga(i)).toVar(),s=tF(ga(a)).toVar();return v7(tF(v3(v5(go(r,n),i,a),v5(go(r.add(tB(1)),n),i.sub(1),a),v5(go(r,n.add(tB(1))),i,a.sub(1)),v5(go(r.add(tB(1)),n.add(tB(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tB().toVar(),n=tB().toVar(),i=tB().toVar(),a=tF(v2(t.x,r)).toVar(),o=tF(v2(t.y,n)).toVar(),s=tF(v2(t.z,i)).toVar(),u=tF(ga(a)).toVar(),l=tF(ga(o)).toVar(),c=tF(ga(s)).toVar();return ge(tF(v4(v5(go(r,n,i),a,o,s),v5(go(r.add(tB(1)),n,i),a.sub(1),o,s),v5(go(r,n.add(tB(1)),i),a,o.sub(1),s),v5(go(r.add(tB(1)),n.add(tB(1)),i),a.sub(1),o.sub(1),s),v5(go(r,n,i.add(tB(1))),a,o,s.sub(1)),v5(go(r.add(tB(1)),n,i.add(tB(1))),a.sub(1),o,s.sub(1)),v5(go(r,n.add(tB(1)),i.add(tB(1))),a,o.sub(1),s.sub(1)),v5(go(r.add(tB(1)),n.add(tB(1)),i.add(tB(1))),a.sub(1),o.sub(1),s.sub(1)),u,l,c)).toVar())}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),gl=hK([tw(function(e){var t=tD(E(e,1)[0]).toVar(),r=tB().toVar(),n=tB().toVar(),i=tF(v2(t.x,r)).toVar(),a=tF(v2(t.y,n)).toVar(),o=tF(ga(i)).toVar(),s=tF(ga(a)).toVar();return v7(tV(v3(v6(gs(r,n),i,a),v6(gs(r.add(tB(1)),n),i.sub(1),a),v6(gs(r,n.add(tB(1))),i,a.sub(1)),v6(gs(r.add(tB(1)),n.add(tB(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tB().toVar(),n=tB().toVar(),i=tB().toVar(),a=tF(v2(t.x,r)).toVar(),o=tF(v2(t.y,n)).toVar(),s=tF(v2(t.z,i)).toVar(),u=tF(ga(a)).toVar(),l=tF(ga(o)).toVar(),c=tF(ga(s)).toVar();return ge(tV(v4(v6(gs(r,n,i),a,o,s),v6(gs(r.add(tB(1)),n,i),a.sub(1),o,s),v6(gs(r,n.add(tB(1)),i),a,o.sub(1),s),v6(gs(r.add(tB(1)),n.add(tB(1)),i),a.sub(1),o.sub(1),s),v6(gs(r,n,i.add(tB(1))),a,o,s.sub(1)),v6(gs(r.add(tB(1)),n,i.add(tB(1))),a.sub(1),o,s.sub(1)),v6(gs(r,n.add(tB(1)),i.add(tB(1))),a,o.sub(1),s.sub(1)),v6(gs(r.add(tB(1)),n.add(tB(1)),i.add(tB(1))),a.sub(1),o.sub(1),s.sub(1)),u,l,c)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),gc=hK([tw(function(e){return gi(go(tB(v1(tF(E(e,1)[0]).toVar())).toVar()))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),tw(function(e){var t=tD(E(e,1)[0]).toVar();return gi(go(tB(v1(t.x)).toVar(),tB(v1(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),tw(function(e){var t=tV(E(e,1)[0]).toVar();return gi(go(tB(v1(t.x)).toVar(),tB(v1(t.y)).toVar(),tB(v1(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),tw(function(e){var t=tH(E(e,1)[0]).toVar();return gi(go(tB(v1(t.x)).toVar(),tB(v1(t.y)).toVar(),tB(v1(t.z)).toVar(),tB(v1(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),gd=hK([tw(function(e){var t=tB(v1(tF(E(e,1)[0]).toVar())).toVar();return tV(gi(go(t,tB(0))),gi(go(t,tB(1))),gi(go(t,tB(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),tw(function(e){var t=tD(E(e,1)[0]).toVar(),r=tB(v1(t.x)).toVar(),n=tB(v1(t.y)).toVar();return tV(gi(go(r,n,tB(0))),gi(go(r,n,tB(1))),gi(go(r,n,tB(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tB(v1(t.x)).toVar(),n=tB(v1(t.y)).toVar(),i=tB(v1(t.z)).toVar();return tV(gi(go(r,n,i,tB(0))),gi(go(r,n,i,tB(1))),gi(go(r,n,i,tB(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),tw(function(e){var t=tH(E(e,1)[0]).toVar(),r=tB(v1(t.x)).toVar(),n=tB(v1(t.y)).toVar(),i=tB(v1(t.z)).toVar(),a=tB(v1(t.w)).toVar();return tV(gi(go(r,n,i,a,tB(0))),gi(go(r,n,i,a,tB(1))),gi(go(r,n,i,a,tB(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),gh=tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tB(n).toVar(),u=tV(r).toVar(),l=tF(0).toVar(),c=tF(1).toVar();return uP(s,function(){l.addAssign(c.mul(gu(u))),c.mulAssign(a),u.mulAssign(o)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gf=tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tB(n).toVar(),u=tV(r).toVar(),l=tV(0).toVar(),c=tF(1).toVar();return uP(s,function(){l.addAssign(c.mul(gl(u))),c.mulAssign(a),u.mulAssign(o)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gp=tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tB(n).toVar(),u=tV(r).toVar();return tD(gh(u,s,o,a),gh(u.add(tV(tB(19),tB(193),tB(17))),s,o,a))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gv=tw(function(e){var t=E(e,4),r=t[0],n=t[1],i=t[2],a=tF(t[3]).toVar(),o=tF(i).toVar(),s=tB(n).toVar(),u=tV(r).toVar();return tH(tV(gf(u,s,o,a)).toVar(),tF(gh(u.add(tV(tB(19),tB(193),tB(17))),s,o,a)).toVar())}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gg=hK([tw(function(e){var t=E(e,7),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=tB(t[6]).toVar(),l=tF(s).toVar(),c=tB(o).toVar(),d=tB(a).toVar(),h=tB(i).toVar(),f=tB(n).toVar(),p=tD(r).toVar(),v=tV(gd(tD(f.add(d),h.add(c)))).toVar(),g=tD(v.x,v.y).toVar();g.subAssign(.5),g.mulAssign(l),g.addAssign(.5);var m=tD(tD(tF(f),tF(h)).add(g)).toVar(),y=tD(m.sub(p)).toVar();return tR(u.equal(tB(2)),function(){return nF(y.x).add(nF(y.y))}),tR(u.equal(tB(3)),function(){return nX(nF(y.x),nF(y.y))}),nJ(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),tw(function(e){var t=E(e,9),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=tB(t[8]).toVar(),d=tF(l).toVar(),h=tB(u).toVar(),f=tB(s).toVar(),p=tB(o).toVar(),v=tB(a).toVar(),g=tB(i).toVar(),m=tB(n).toVar(),y=tV(r).toVar(),b=tV(gd(tV(m.add(p),g.add(f),v.add(h)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);var x=tV(tV(tF(m),tF(g),tF(v)).add(b)).toVar(),_=tV(x.sub(y)).toVar();return tR(c.equal(tB(2)),function(){return nF(_.x).add(nF(_.y)).add(nF(_.z))}),tR(c.equal(tB(3)),function(){return nX(nF(_.x),nF(_.y),nF(_.z))}),nJ(_,_)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gm=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tD(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tD(v2(o.x,s),v2(o.y,u)).toVar(),c=tF(1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=tF(gg(l,t,e.y,s,u,a,i)).toVar();c.assign(nj(c,r))})}),tR(i.equal(tB(0)),function(){c.assign(np(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gy=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tD(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tD(v2(o.x,s),v2(o.y,u)).toVar(),c=tD(1e6,1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=tF(gg(l,t,e.y,s,u,a,i)).toVar();tR(r.lessThan(c.x),function(){c.y.assign(c.x),c.x.assign(r)}).ElseIf(r.lessThan(c.y),function(){c.y.assign(r)})})}),tR(i.equal(tB(0)),function(){c.assign(np(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gb=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tD(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tD(v2(o.x,s),v2(o.y,u)).toVar(),c=tV(1e6,1e6,1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=tF(gg(l,t,e.y,s,u,a,i)).toVar();tR(r.lessThan(c.x),function(){c.z.assign(c.y),c.y.assign(c.x),c.x.assign(r)}).ElseIf(r.lessThan(c.y),function(){c.z.assign(c.y),c.y.assign(r)}).ElseIf(r.lessThan(c.z),function(){c.z.assign(r)})})}),tR(i.equal(tB(0)),function(){c.assign(np(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gx=hK([gm,tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tV(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tB().toVar(),c=tV(v2(o.x,s),v2(o.y,u),v2(o.z,l)).toVar(),d=tF(1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=e.y;uP({start:-1,end:tB(1),name:"z",condition:"<="},function(e){var n=tF(gg(c,t,r,e.z,s,u,l,a,i)).toVar();d.assign(nj(d,n))})})}),tR(i.equal(tB(0)),function(){d.assign(np(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),g_=hK([gy,tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tV(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tB().toVar(),c=tV(v2(o.x,s),v2(o.y,u),v2(o.z,l)).toVar(),d=tD(1e6,1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=e.y;uP({start:-1,end:tB(1),name:"z",condition:"<="},function(e){var n=tF(gg(c,t,r,e.z,s,u,l,a,i)).toVar();tR(n.lessThan(d.x),function(){d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),function(){d.y.assign(n)})})})}),tR(i.equal(tB(0)),function(){d.assign(np(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gT=hK([gb,tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=tB(t[2]).toVar(),a=tF(n).toVar(),o=tV(r).toVar(),s=tB().toVar(),u=tB().toVar(),l=tB().toVar(),c=tV(v2(o.x,s),v2(o.y,u),v2(o.z,l)).toVar(),d=tV(1e6,1e6,1e6).toVar();return uP({start:-1,end:tB(1),name:"x",condition:"<="},function(e){var t=e.x;uP({start:-1,end:tB(1),name:"y",condition:"<="},function(e){var r=e.y;uP({start:-1,end:tB(1),name:"z",condition:"<="},function(e){var n=tF(gg(c,t,r,e.z,s,u,l,a,i)).toVar();tR(n.lessThan(d.x),function(){d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),function(){d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),function(){d.z.assign(n)})})})}),tR(i.equal(tB(0)),function(){d.assign(np(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gS=tw(function(e){var t=E(e,11),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],d=t[9],h=t[10],f=tB(r).toVar(),p=tD(n).toVar(),v=tD(i).toVar(),g=tD(a).toVar(),m=tF(o).toVar(),y=tF(s).toVar(),b=tF(u).toVar(),x=tL(l).toVar(),_=tB(c).toVar(),T=tF(d).toVar(),S=tF(h).toVar(),N=p.mul(v).add(g),k=tF(0).toVar();return tR(f.equal(tB(0)),function(){k.assign(gl(N))}),tR(f.equal(tB(1)),function(){k.assign(gd(N))}),tR(f.equal(tB(2)),function(){k.assign(gT(N,m,tB(0)))}),tR(f.equal(tB(3)),function(){k.assign(gf(tV(N,0),_,T,S))}),k.assign(k.mul(b.sub(y)).add(y)),tR(x,function(){k.assign(ie(k,y,b))}),k}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gN=tw(function(e){var t=E(e,11),r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],d=t[9],h=t[10],f=tB(r).toVar(),p=tV(n).toVar(),v=tV(i).toVar(),g=tV(a).toVar(),m=tF(o).toVar(),y=tF(s).toVar(),b=tF(u).toVar(),x=tL(l).toVar(),_=tB(c).toVar(),T=tF(d).toVar(),S=tF(h).toVar(),N=p.mul(v).add(g),k=tF(0).toVar();return tR(f.equal(tB(0)),function(){k.assign(gl(N))}),tR(f.equal(tB(1)),function(){k.assign(gd(N))}),tR(f.equal(tB(2)),function(){k.assign(gT(N,m,tB(0)))}),tR(f.equal(tB(3)),function(){k.assign(gf(N,_,T,S))}),k.assign(k.mul(b.sub(y)).add(y)),tR(x,function(){k.assign(ie(k,y,b))}),k}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gk=tw(function(e){var t=E(e,1)[0],r=t.y,n=t.z,i=tV().toVar();return tR(r.lessThan(1e-4),function(){i.assign(tV(n,n,n))}).Else(function(){var e=t.x,a=tB(nG(e=e.sub(ng(e)).mul(6).toVar())),o=e.sub(tF(a)),s=n.mul(r.oneMinus()),u=n.mul(r.mul(o).oneMinus()),l=n.mul(r.mul(o.oneMinus()).oneMinus());tR(a.equal(tB(0)),function(){i.assign(tV(n,l,s))}).ElseIf(a.equal(tB(1)),function(){i.assign(tV(u,n,s))}).ElseIf(a.equal(tB(2)),function(){i.assign(tV(s,n,l))}).ElseIf(a.equal(tB(3)),function(){i.assign(tV(s,u,n))}).ElseIf(a.equal(tB(4)),function(){i.assign(tV(l,s,n))}).Else(function(){i.assign(tV(n,s,u))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),gw=tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tF(t.x).toVar(),n=tF(t.y).toVar(),i=tF(t.z).toVar(),a=tF(nj(r,nj(n,i))).toVar(),o=tF(nX(r,nX(n,i))).toVar(),s=tF(o.sub(a)).toVar(),u=tF().toVar(),l=tF().toVar(),c=tF().toVar();return c.assign(o),tR(o.greaterThan(0),function(){l.assign(s.div(o))}).Else(function(){l.assign(0)}),tR(l.lessThanEqual(0),function(){u.assign(0)}).Else(function(){tR(r.greaterThanEqual(o),function(){u.assign(n.sub(i).div(s))}).ElseIf(n.greaterThanEqual(o),function(){u.assign(rO(2,i.sub(r).div(s)))}).Else(function(){u.assign(rO(4,r.sub(n).div(s)))}),u.mulAssign(1/6),tR(u.lessThan(0),function(){u.addAssign(1)})}),tV(u,l,c)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),gA=tw(function(e){var t=tV(E(e,1)[0]).toVar(),r=tW(rj(t,tV(.04045))).toVar();return n7(tV(t.div(12.92)).toVar(),tV(n0(nX(t.add(tV(.055)),tV(0)).div(1.055),tV(2.4))).toVar(),r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),gE=function(e,t){e=tF(e);var r=tD((t=tF(t)).dFdx(),t.dFdy()).length().mul(.7071067811865476);return ii(e.sub(r),e.add(r),t)},gR=function(e,t,r,n){return n7(e,t,r[n].clamp())},gC=function(e,t,r,n,i){return n7(e,t,gE(r,n[i]))},gM=tw(function(e){var t=E(e,3),r=t[0],n=t[1],i=t[2],a=ny(r).toVar(),o=rI(tF(.5).mul(n.sub(i)),ow).div(a).toVar(),s=rI(tF(-.5).mul(n.sub(i)),ow).div(a).toVar(),u=tV().toVar();u.x=a.x.greaterThan(tF(0)).select(o.x,s.x),u.y=a.y.greaterThan(tF(0)).select(o.y,s.y),u.z=a.z.greaterThan(tF(0)).select(o.z,s.z);var l=nj(u.x,u.y,u.z).toVar();return ow.add(a.mul(l)).toVar().sub(i)}),gF=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=r.x,a=r.y,o=r.z,s=n.element(0).mul(.886227);return(s=(s=(s=(s=(s=(s=(s=s.add(n.element(1).mul(1.023328).mul(a))).add(n.element(2).mul(1.023328).mul(o))).add(n.element(3).mul(1.023328).mul(i))).add(n.element(4).mul(.858086).mul(i).mul(a))).add(n.element(5).mul(.858086).mul(a).mul(o))).add(n.element(6).mul(o.mul(o).mul(.743125).sub(.247708)))).add(n.element(7).mul(.858086).mul(i).mul(o))).add(n.element(8).mul(.429043).mul(rV(i,i).sub(rV(a,a))))}),gB=Object.freeze({__proto__:null,BRDF_GGX:lJ,BRDF_Lambert:lU,BasicPointShadowFilter:vz,BasicShadowFilter:vb,Break:uL,Const:iT,Continue:function(){return at("continue").toStack()},DFGLUT:l1,D_GGX:lY,Discard:ar,EPSILON:ne,F_Schlick:lD,Fn:tw,HALF_PI:na,INFINITY:nt,If:tR,Loop:uP,NodeAccess:er,NodeShaderStage:ee,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:et,OnBeforeFrameUpdate:function(e){return ul(uu.BEFORE_FRAME,e)},OnBeforeMaterialUpdate:function(e){return ul(uu.BEFORE_MATERIAL,e)},OnBeforeObjectUpdate:function(e){return ul(uu.BEFORE_OBJECT,e)},OnFrameUpdate:ud,OnMaterialUpdate:function(e){return ul(uu.MATERIAL,e)},OnObjectUpdate:uc,PCFShadowFilter:vx,PCFSoftShadowFilter:v_,PI:nr,PI2:nn,PointShadowFilter:vW,Return:function(){return at("return").toStack()},Schlick_to_F0:l4,ShaderNode:tv,Stack:tC,Switch:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(te=eT).Switch.apply(te,R(t))},TBNViewMatrix:s_,TWO_PI:ni,VSMShadowFilter:vT,V_GGX_SmithCorrelated:lX,Var:i_,VarIntent:iS,abs:nF,acesFilmicToneMapping:f9,acos:nE,acosh:nR,add:rO,addMethodChaining:eN,addNodeElement:function(e){(0,c.wc)("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:pr,all:no,alphaT:ri,ambientOcclusion:rT,and:rY,anisotropy:ra,anisotropyB:rs,anisotropyT:ro,any:ns,append:function(e){return(0,c.wc)("TSL: append() has been renamed to Stack().",new z),tC(e)},array:rF,asin:nw,asinh:nA,assign:rB,atan:nC,atanh:nM,atomicAdd:function(e,t){return pE(pw.ATOMIC_ADD,e,t)},atomicAnd:function(e,t){return pE(pw.ATOMIC_AND,e,t)},atomicFunc:pE,atomicLoad:function(e){return pE(pw.ATOMIC_LOAD,e,null)},atomicMax:function(e,t){return pE(pw.ATOMIC_MAX,e,t)},atomicMin:function(e,t){return pE(pw.ATOMIC_MIN,e,t)},atomicOr:function(e,t){return pE(pw.ATOMIC_OR,e,t)},atomicStore:function(e,t){return pE(pw.ATOMIC_STORE,e,t)},atomicSub:function(e,t){return pE(pw.ATOMIC_SUB,e,t)},atomicXor:function(e,t){return pE(pw.ATOMIC_XOR,e,t)},attenuationColor:rx,attenuationDistance:rb,attribute:av,attributeArray:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float";return!0===n.isStructTypeNode?(t=n.getLength(),r=Y("float")):(t=Q(n),r=Y(n)),up(new fS(e,t,r),n,e)},backgroundBlurriness:fw,backgroundIntensity:fA,backgroundRotation:fE,batch:uk,batchColor:uN,bentNormalView:sS,billboarding:h0,bitAnd:r$,bitNot:r0,bitOr:r1,bitXor:r2,bitangentGeometry:sm,bitangentLocal:sy,bitangentView:sb,bitangentWorld:sx,bitcast:hA,blendBurn:fI,blendColor:fW,blendDodge:fV,blendOverlay:fz,blendScreen:fG,blur:cX,bool:tL,buffer:aw,bufferAttribute:iq,builtin:aC,builtinAOContext:im,builtinShadowContext:ig,bumpMap:sC,bvec2:tI,bvec3:tW,bvec4:tX,bypass:i8,cache:i6,call:rL,cameraFar:a3,cameraIndex:a1,cameraNear:a2,cameraNormalMatrix:a9,cameraPosition:a7,cameraProjectionMatrix:a4,cameraProjectionMatrixInverse:a5,cameraViewMatrix:a6,cameraViewport:oe,cameraWorldMatrix:a8,cbrt:n8,cdl:fY,ceil:nm,checker:vZ,cineonToneMapping:f6,clamp:ie,clearcoat:t8,clearcoatNormalView:oV,clearcoatRoughness:t9,clipSpace:oT,code:pa,color:tM,colorSpaceToWorking:iB,colorToDirection:function(e){return(0,c.yc)('TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".'),sk(e)},compute:i3,computeKernel:i2,computeSkinning:uF,context:ih,convert:tJ,convertColorSpace:function(e,t,r){return new iM(tg(e),t,r)},convertToTexture:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():fv.apply(void 0,[e].concat(R(r)))},cos:nT,cosh:nS,countLeadingZeros:hF,countOneBits:hB,countTrailingZeros:hM,cross:n$,cubeTexture:o2,cubeTextureBase:o1,dFdx:nU,dFdy:nO,dashSize:rf,debug:au,decrement:r9,decrementBefore:r6,defaultBuildStages:ei,defaultShaderStages:en,defined:tf,degrees:nl,deltaTime:hQ,densityFogFactor:pc,depth:u8,depthPass:function(e,t,r){return new f2(f2.DEPTH,e,t,r)},determinant:nH,difference:nZ,diffuseColor:t2,diffuseContribution:t3,directPointLight:vY,directionToColor:function(e){return(0,c.yc)('TSL: "directionToColor()" has been renamed to "packNormalToRGB()".'),sN(e)},directionToFaceDirection:function(e){return(0,c.yc)('TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".'),oF(e)},dispersion:r_,disposeShadowMaterial:vN,distance:nQ,div:rG,dot:nJ,drawIndex:i0,dynamicBufferAttribute:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return iH(e,t,r,n,c.mc)},element:tZ,emissive:t4,equal:rW,equirectDirection:lN,equirectUV:lS,exp:nc,exp2:nd,exponentialHeightFogFactor:pd,expression:at,faceDirection:oM,faceForward:ia,faceforward:ia,float:tF,floatBitsToInt:function(e){return new hw(e,"int","float")},floatBitsToUint:hE,floor:ng,fog:ph,fract:nb,frameGroup:rw,frameId:hZ,frontFacing:oC,fwidth:nz,gain:function(e,t){return e.lessThan(.5)?hL(e.mul(2),t).div(2):rI(1,hL(rV(rI(1,e),2),t).div(2))},gapSize:rp,getConstNodeType:tp,getCurrentStack:tE,getDirection:cW,getDistanceAttenuation:vK,getGeometryRoughness:lq,getNormalFromDepth:fy,getParallaxCorrectNormal:gM,getRoughness:lj,getScreenPosition:fm,getShIrradianceAt:gF,getShadowMaterial:vS,getShadowRenderObjectFunction:vA,getTextureIndex:hN,getViewPosition:fg,ggxConvolution:cZ,globalId:px,glsl:function(e,t){return pa(e,t,"glsl")},glslFn:function(e,t){return ps(e,t,"glsl")},grayscale:fH,greaterThan:rj,greaterThanEqual:rK,hash:hP,highpModelNormalViewMatrix:o_,highpModelViewMatrix:ox,hue:fX,increment:r8,incrementBefore:r5,inspector:ad,instance:ux,instanceColor:ub,instanceIndex:iQ,instancedArray:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float";!0===n.isStructTypeNode?(t=n.getLength(),r=Y("float")):(t=Q(n),r=Y(n));var i=new fT(e,t,r);return up(i,n,i.count)},instancedBufferAttribute:ij,instancedDynamicBufferAttribute:iX,instancedMesh:u_,int:tB,intBitsToFloat:function(e){return new hw(e,"float","int")},interleavedGradientNoise:fb,inverse:nq,inverseSqrt:nv,inversesqrt:nv,invocationLocalIndex:i$,invocationSubgroupIndex:iJ,ior:rg,iridescence:rt,iridescenceIOR:rr,iridescenceThickness:rn,isolate:i5,ivec2:tU,ivec3:tG,ivec4:tq,js:function(e,t){return pa(e,t,"js")},label:iy,length:nP,lengthSq:n9,lessThan:rq,lessThanEqual:rX,lightPosition:p5,lightProjectionUV:p4,lightShadowMatrix:p3,lightTargetDirection:p9,lightTargetPosition:p6,lightViewPosition:p8,lightingContext:uW,lights:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(new va).setLights(e)},linearDepth:u9,linearToneMapping:f4,localId:p_,log:nh,log2:nf,logarithmicDepthToViewZ:function(e,t,r){var n=e.mul(nh(r.div(t)));return tF(Math.E).pow(n).mul(t).negate()},luminance:fK,mat2:tK,mat3:tY,mat4:tQ,matcapUV:dx,materialAO:ua,materialAlphaTest:sB,materialAnisotropy:sJ,materialAnisotropyVector:uo,materialAttenuationColor:s6,materialAttenuationDistance:s5,materialClearcoat:sj,materialClearcoatNormal:sK,materialClearcoatRoughness:sX,materialColor:sP,materialDispersion:un,materialEmissive:sD,materialEnvIntensity:oK,materialEnvRotation:oY,materialIOR:s4,materialIridescence:s$,materialIridescenceIOR:s0,materialIridescenceThickness:s1,materialLightMap:ui,materialLineDashOffset:ut,materialLineDashSize:s9,materialLineGapSize:s7,materialLineScale:s8,materialLineWidth:ue,materialMetalness:sH,materialNormal:sq,materialOpacity:sU,materialPointSize:ur,materialReference:o9,materialReflectivity:sz,materialRefractionRatio:oX,materialRotation:sY,materialRoughness:sW,materialSheen:sQ,materialSheenRoughness:sZ,materialShininess:sL,materialSpecular:sO,materialSpecularColor:sV,materialSpecularIntensity:sI,materialSpecularStrength:sG,materialThickness:s3,materialTransmission:s2,max:nX,maxMipLevel:ay,mediumpModelViewMatrix:ob,metalness:t6,min:nj,mix:n7,mixElement:is,mod:rz,modelDirection:oc,modelNormalMatrix:og,modelPosition:oh,modelRadius:ov,modelScale:of,modelViewMatrix:oy,modelViewPosition:op,modelViewProjection:us,modelWorldMatrix:od,modelWorldMatrixInverse:om,morphReference:uV,mrt:hk,mul:rV,mx_aastep:gE,mx_add:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(0);return rO(e,t)},mx_atan2:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:tF(0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return nC(e,t)},mx_cell_noise_float:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag();return gc(e.convert("vec2|vec3"))},mx_contrast:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;return tF(e).sub(r).mul(t).add(r)},mx_divide:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return rG(e,t)},mx_fractal_noise_float:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return gh(e,tB(t),r,n).mul(i)},mx_fractal_noise_vec2:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return gp(e,tB(t),r,n).mul(i)},mx_fractal_noise_vec3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return gf(e,tB(t),r,n).mul(i)},mx_fractal_noise_vec4:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return gv(e,tB(t),r,n).mul(i)},mx_frame:function(){return hZ},mx_heighttonormal:function(e,t){return sC(e=tV(e),t=tF(t))},mx_hsvtorgb:gk,mx_ifequal:function(e,t,r,n){return e.equal(t).mix(r,n)},mx_ifgreater:function(e,t,r,n){return e.greaterThan(t).mix(r,n)},mx_ifgreatereq:function(e,t,r,n){return e.greaterThanEqual(t).mix(r,n)},mx_invert:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return rI(t,e)},mx_modulo:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return rz(e,t)},mx_multiply:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return rV(e,t)},mx_noise_float:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return gu(e.convert("vec2|vec3")).mul(t).add(r)},mx_noise_vec3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return gl(e.convert("vec2|vec3")).mul(t).add(r)},mx_noise_vec4:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return tH(gl(e=e.convert("vec2|vec3")),gu(e.add(tD(19,73)))).mul(t).add(r)},mx_place2d:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tD(.5,.5),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tD(1,1),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tF(0),i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:tD(0,0),a=e;if(t&&(a=a.sub(t)),r&&(a=a.mul(r)),n){var o=n.mul(Math.PI/180),s=o.cos(),u=o.sin();a=tD(a.x.mul(s).sub(a.y.mul(u)),a.x.mul(u).add(a.y.mul(s)))}return t&&(a=a.add(t)),i&&(a=a.add(i)),a},mx_power:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(1);return n0(e,t)},mx_ramp4:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:ag(),a=i.x.clamp(),o=i.y.clamp(),s=n7(e,t,a),u=n7(r,n,a);return n7(s,u,o)},mx_ramplr:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ag();return gR(e,t,r,"x")},mx_ramptb:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ag();return gR(e,t,r,"y")},mx_rgbtohsv:gw,mx_rotate2d:function(e,t){return dS(e=tD(e),(t=tF(t)).mul(Math.PI/180))},mx_rotate3d:function(e,t,r){e=tV(e),t=tF(t),r=tV(r);var n=t.mul(Math.PI/180),i=r.normalize(),a=n.cos(),o=n.sin(),s=tF(1).sub(a);return e.mul(a).add(i.cross(e).mul(o)).add(i.mul(i.dot(e)).mul(s))},mx_safepower:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(e=tF(e)).abs().pow(t).mul(e.sign())},mx_separate:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof t){var r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},n=t.replace(/^out/,"").toLowerCase();if(void 0!==r[n])return e.element(r[n])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){var i={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==i[t])return e.element(i[t])}return e},mx_splitlr:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ag();return gC(e,t,r,n,"x")},mx_splittb:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ag();return gC(e,t,r,n,"y")},mx_srgb_texture_to_lin_rec709:gA,mx_subtract:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tF(0);return rI(e,t)},mx_timer:function(){return hY},mx_transform_uv:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ag();return r.mul(e).add(t)},mx_unifiednoise2d:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ag(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tD(1,1),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tD(0,0),i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,s=arguments.length>7&&void 0!==arguments[7]&&arguments[7],u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:1,l=arguments.length>9&&void 0!==arguments[9]?arguments[9]:2,c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:.5;return gS(e,t.convert("vec2|vec3"),r,n,i,a,o,s,u,l,c)},mx_unifiednoise3d:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ag(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tD(1,1),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tD(0,0),i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,s=arguments.length>7&&void 0!==arguments[7]&&arguments[7],u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:1,l=arguments.length>9&&void 0!==arguments[9]?arguments[9]:2,c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:.5;return gN(e,t.convert("vec2|vec3"),r,n,i,a,o,s,u,l,c)},mx_worley_noise_float:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return gx(e.convert("vec2|vec3"),t,tB(1))},mx_worley_noise_vec2:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return g_(e.convert("vec2|vec3"),t,tB(1))},mx_worley_noise_vec3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ag(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return gT(e.convert("vec2|vec3"),t,tB(1))},negate:nL,negateOnBackSide:oF,neutralToneMapping:pn,nodeArray:tb,nodeImmutable:t_,nodeObject:tg,nodeObjectIntent:tm,nodeObjects:ty,nodeProxy:tx,nodeProxyConstructor:tS,nodeProxyIntent:tT,normalFlat:oL,normalGeometry:oB,normalLocal:oP,normalMap:sA,normalView:oO,normalViewGeometry:oD,normalWorld:oI,normalWorldGeometry:oU,normalize:ny,not:rZ,notEqual:rH,numWorkgroups:py,objectDirection:on,objectGroup:rE,objectPosition:oa,objectRadius:ou,objectScale:oo,objectViewPosition:os,objectWorldMatrix:oi,oneMinus:nD,or:rQ,orthographicDepthToViewZ:u1,oscSawtooth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:hY;return e.fract()},oscSine:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:hY;return e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5)},oscSquare:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:hY;return e.fract().round()},oscTriangle:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:hY;return e.add(.5).fract().mul(2).sub(1).abs()},output:rh,outputStruct:hx,overloadingFn:hK,overrideNode:hf,overrideNodes:hp,packHalf2x16:hI,packNormalToRGB:sN,packSnorm2x16:hU,packUnorm2x16:hO,parabola:hL,parallaxDirection:sT,parallaxUV:function(e,t){return e.sub(sT.mul(t))},parameter:function(e,t){return new hv(e,t)},pass:function(e,t,r){return new f2(f2.COLOR,e,t,r)},passTexture:function(e,t){return new f0(e,t)},pcurve:function(e,t,r){return n0(rG(n0(e,t),rO(n0(e,t),n0(rI(1,e),r))),1/t)},perspectiveDepthToViewZ:u4,pmremTexture:ds,pointShadow:vj,pointUV:fN,pointWidth:rv,positionGeometry:oS,positionLocal:oN,positionPrevious:ok,positionView:oE,positionViewDirection:oR,positionWorld:ow,positionWorldDirection:oA,posterize:fQ,pow:n0,pow2:n1,pow3:n2,pow4:n3,premultiplyAlpha:an,property:t0,quadBroadcast:p1,quadSwapDiagonal:pY,quadSwapX:pX,quadSwapY:pK,radians:nu,rand:io,range:pv,rangeFogFactor:pl,reciprocal:nV,reference:o5,referenceBuffer:o6,reflect:nY,reflectVector:oJ,reflectView:oQ,reflector:function(e){return new fu(e)},refract:ir,refractVector:o$,refractView:oZ,reinhardToneMapping:f5,remap:i9,remapClamp:i7,renderGroup:rA,renderOutput:ao,rendererReference:iU,replaceDefaultUV:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return ih(t,{getUV:"function"==typeof e?e:function(){return e}})},rotate:dS,rotateUV:hJ,roughness:t5,round:nI,rtt:fv,sRGBTransferEOTF:iE,sRGBTransferOETF:iR,sample:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new f_(e,tg(t))},sampler:function(e){return(!0===e.isNode?e:aS(e)).convert("sampler")},samplerComparison:function(e){return(!0===e.isNode?e:aS(e)).convert("samplerComparison")},saturate:it,saturation:fq,screenCoordinate:aL,screenDPR:aF,screenSize:aP,screenUV:aB,select:ic,setCurrentStack:tA,setName:iv,shaderStages:ea,shadow:vB,shadowPositionWorld:vs,shapeCircle:vJ,sharedUniformGroup:rk,sheen:t7,sheenRoughness:re,shiftLeft:r3,shiftRight:r4,shininess:rd,sign:nB,sin:nx,sinc:function(e,t){return nx(nr.mul(t.mul(e).sub(1))).div(nr.mul(t.mul(e).sub(1)))},sinh:n_,skinning:uM,smoothstep:ii,smoothstepElement:iu,specularColor:ru,specularColorBlended:rl,specularF90:rc,spherizeUV:h$,split:function(e,t){return new ev(tg(e),t)},spritesheetUV:h2,sqrt:np,stack:hg,step:nK,stepElement:il,storage:up,storageBarrier:function(){return pS("storage").toStack()},storageTexture:fC,storageTexture3D:fM,struct:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=new hm(e,t);return tS(function(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];var a=null;if(n.length>0)if(n[0].isNode){a={};for(var o=Object.keys(e),s=0;s<n.length;s++)a[o[s]]=n[s]}else a=n[0];return new hy(r,a)},r)},sub:rI,subBuild:ik,subgroupAdd:pB,subgroupAll:pH,subgroupAnd:pI,subgroupAny:pq,subgroupBallot:pF,subgroupBroadcast:pQ,subgroupBroadcastFirst:pj,subgroupElect:pM,subgroupExclusiveAdd:pL,subgroupExclusiveMul:pO,subgroupInclusiveAdd:pP,subgroupInclusiveMul:pU,subgroupIndex:iZ,subgroupMax:pW,subgroupMin:pz,subgroupMul:pD,subgroupOr:pV,subgroupShuffle:pZ,subgroupShuffleDown:p0,subgroupShuffleUp:p$,subgroupShuffleXor:pJ,subgroupSize:pT,subgroupXor:pG,tan:nN,tangentGeometry:sh,tangentLocal:sf,tangentView:sp,tangentWorld:sv,tanh:nk,texture:aS,texture3D:fB,texture3DLevel:function(e,t,r){return fB(e,t).level(r)},texture3DLoad:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fB.apply(void 0,R(t)).setSampler(!1)},textureBarrier:function(){return pS("texture").toStack()},textureBicubic:cf,textureBicubicLevel:ch,textureCubeUV:cH,textureLevel:function(e,t,r){return aS(e,t).level(r)},textureLoad:aN,textureSize:am,textureStore:function(e,t,r){var n;return!0===e.isStorageTextureNode?n=e.store(t,r):(n=fC(e,t,r),null!==r&&n.toStack()),n},thickness:ry,time:hY,toneMapping:iI,toneMappingExposure:iV,toonOutlinePass:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new c.Tc(0,0,0),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.003,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return new f3(e,t,tg(r),tg(n),tg(i))},transformDirection:n4,transformNormal:oG,transformNormalByInverseViewMatrix:n6,transformNormalByViewMatrix:n5,transformNormalToView:oz,transformedClearcoatNormalView:oq,transformedNormalView:oW,transformedNormalWorld:oH,transmission:rm,transpose:nW,triNoise3D:hj,triplanarTexture:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return h3.apply(void 0,R(t))},triplanarTextures:h3,trunc:nG,uint:tP,uintBitsToFloat:function(e){return new hw(e,"float","uint")},uniform:rC,uniformArray:aR,uniformCubeTexture:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o0;return o1(e)},uniformFlow:ip,uniformGroup:rN,uniformTexture:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ax;return aS(e)},unpackHalf2x16:hW,unpackNormal:sw,unpackRGBToNormal:sk,unpackSnorm2x16:hG,unpackUnorm2x16:hz,unpremultiplyAlpha:ai,userData:function(e,t,r){return new fP(e,t,r)},uv:ag,uvec2:tO,uvec3:tz,uvec4:tj,varying:iw,varyingProperty:t1,vec2:tD,vec3:tV,vec4:tH,vectorComponents:eo,velocity:fO,vertexColor:la,vertexIndex:iY,vertexStage:iA,vibrance:fj,viewZToLogarithmicDepth:u5,viewZToOrthographicDepth:u0,viewZToPerspectiveDepth:u2,viewZToReversedOrthographicDepth:function(e,t,r){return e.add(r).div(r.sub(t))},viewZToReversedPerspectiveDepth:u3,viewport:aD,viewportCoordinate:aO,viewportDepthTexture:uJ,viewportLinearDepth:u7,viewportMipTexture:uK,viewportOpaqueMipTexture:uQ,viewportResolution:aV,viewportSafeUV:h1,viewportSharedTexture:fJ,viewportSize:aU,viewportTexture:uX,viewportUV:aI,vogelDiskSample:fx,wgsl:function(e,t){return pa(e,t,"wgsl")},wgslFn:function(e,t){return ps(e,t,"wgsl")},workgroupArray:function(e,t){return new pk("Workgroup",e,t)},workgroupBarrier:function(){return pS("workgroup").toStack()},workgroupId:pb,workingToColorSpace:iF,xor:rJ}),gP=new hd,gL=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).renderer=e,n.nodes=r,n}return T(t,e),y(t,[{key:"update",value:function(e,t,r){var n=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(null===i)n._clearColor.getRGB(gP),gP.a=n._clearColor.a;else if(!0===i.isColor)i.getRGB(gP),gP.a=1,a=!0;else if(!0===i.isNode){var o=this.get(e);gP.copy(n._clearColor);var s=o.backgroundMesh;if(void 0===s){var u=function(){i.removeEventListener("dispose",u),s.material.dispose(),s.geometry.dispose()},l=tH(i).mul(fA).context({getUV:function(){return fE.mul(oU)},getTextureLevel:function(){return fw}}),d=a4.element(3).element(3).equal(1),h=rG(1,a4.element(1).element(1)).mul(3),f=d.select(oN.mul(h),oN),p=oy.mul(tH(f,0)),v=a4.mul(tH(p.xyz,1));v=v.setZ(v.w);var g=new lo;g.name="Background.material",g.side=c.k,g.depthTest=!1,g.depthWrite=!1,g.allowOverride=!1,g.fog=!1,g.lights=!1,g.vertexNode=v,g.colorNode=l,o.backgroundMeshNode=l,o.backgroundMesh=s=new c.ld(new c.Wd(1,32,32),g),s.frustumCulled=!1,s.name="Background.mesh",i.addEventListener("dispose",u)}var m=i.getCacheKey();o.backgroundCacheKey!==m&&(o.backgroundMeshNode.node=tH(i).mul(fA),o.backgroundMeshNode.needsUpdate=!0,s.material.needsUpdate=!0,o.backgroundCacheKey=m),t.unshift(s,s.geometry,s.material,0,0,null,null)}else(0,c.xc)("Renderer: Unsupported background configuration.",i);var y=n.xr.getEnvironmentBlendMode();if("additive"===y?gP.set(0,0,0,1):"alpha-blend"===y&&gP.set(0,0,0,0),!0===n.autoClear||!0===a){var b=r.clearColorValue;b.r=gP.r,b.g=gP.g,b.b=gP.b,b.a=gP.a,(!0===n.backend.isWebGLBackend||!0===n.alpha)&&(b.r*=b.a,b.g*=b.a,b.b*=b.a),r.depthClearValue=n.getClearDepth(),r.stencilClearValue=n.getClearStencil(),r.clearColor=!0===n.autoClearColor,r.clearDepth=!0===n.autoClearDepth,r.clearStencil=!0===n.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}]),t}(dj),gD=0,gU=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];v(this,e),this.name=t,this.bindings=r,this.id=gD++},gO=function(){function e(t,r,n,i,a,o,s,u,l,c){var d=arguments.length>10&&void 0!==arguments[10]?arguments[10]:[];v(this,e),this.vertexShader=t,this.fragmentShader=r,this.computeShader=n,this.transforms=d,this.nodeAttributes=i,this.bindings=a,this.updateNodes=o,this.updateBeforeNodes=s,this.updateAfterNodes=u,this.observer=l,this.hardwareClipping=c,this.usedTimes=0}return y(e,[{key:"createBindings",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,a=this.bindings[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(!0!==o.bindings[0].groupNode.shared){var s=new gU(o.name,[]);e.push(s);var u=!0,l=!1,c=void 0;try{for(var d,h=o.bindings[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;s.bindings.push(f.clone())}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}}else e.push(o)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return e}}]),e}(),gI=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;v(this,e),this.isNodeAttribute=!0,this.name=t,this.type=r,this.node=n},gV=function(){function e(t,r,n){v(this,e),this.isNodeUniform=!0,this.name=t,this.type=r,this.node=n}return y(e,[{key:"value",get:function(){return this.node.value},set:function(e){this.node.value=e}},{key:"id",get:function(){return this.node.id}},{key:"groupNode",get:function(){return this.node.groupNode}}]),e}(),gG=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;v(this,e),this.isNodeVar=!0,this.name=t,this.type=r,this.readOnly=n,this.count=i},gz=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(n=p(this,t,[e,r])).needsInterpolation=!1,n.isNodeVarying=!0,n.interpolationType=i,n.interpolationSampling=a,n}return T(t,e),t}(gG),gW=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";v(this,e),this.name=t,this.type=r,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})},gH=0,gq=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(this,e),this.id=gH++,this.nodesData=new WeakMap,this.parent=t}return y(e,[{key:"getData",value:function(e){var t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}},{key:"setData",value:function(e,t){this.nodesData.set(e,t)}}]),e}(),gj=function e(t,r){v(this,e),this.name=t,this.members=r,this.output=!1},gX=function(){function e(t,r){v(this,e),this.name=t,this.value=r,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}return y(e,[{key:"setValue",value:function(e){this.value=e}},{key:"getValue",value:function(){return this.value}}]),e}(),gK=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return v(this,t),(r=p(this,t,[e,n])).isNumberUniform=!0,r.boundary=4,r.itemSize=1,r}return T(t,e),t}(gX),gY=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Dc;return v(this,t),(r=p(this,t,[e,n])).isVector2Uniform=!0,r.boundary=8,r.itemSize=2,r}return T(t,e),t}(gX),gQ=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Fc;return v(this,t),(r=p(this,t,[e,n])).isVector3Uniform=!0,r.boundary=16,r.itemSize=3,r}return T(t,e),t}(gX),gZ=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Jc;return v(this,t),(r=p(this,t,[e,n])).isVector4Uniform=!0,r.boundary=16,r.itemSize=4,r}return T(t,e),t}(gX),gJ=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Tc;return v(this,t),(r=p(this,t,[e,n])).isColorUniform=!0,r.boundary=16,r.itemSize=3,r}return T(t,e),t}(gX),g$=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Pe;return v(this,t),(r=p(this,t,[e,n])).isMatrix2Uniform=!0,r.boundary=8,r.itemSize=4,r}return T(t,e),t}(gX),g0=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Gc;return v(this,t),(r=p(this,t,[e,n])).isMatrix3Uniform=!0,r.boundary=48,r.itemSize=12,r}return T(t,e),t}(gX),g1=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new c.Oc;return v(this,t),(r=p(this,t,[e,n])).isMatrix4Uniform=!0,r.boundary=64,r.itemSize=16,r}return T(t,e),t}(gX),g2=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(gK),g3=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(gY),g4=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(gQ),g5=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(gZ),g6=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(gJ),g8=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(g$),g9=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(g0),g7=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e.name,e.value])).nodeUniform=e,r}return T(t,e),y(t,[{key:"getValue",value:function(){return this.nodeUniform.value}},{key:"getType",value:function(){return this.nodeUniform.type}}]),t}(g1),me=0,mt=new WeakMap,mr=new WeakMap,mn=new WeakMap,mi=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),ma=function(e){return/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0")},mo=function(e){if(e.writeUsageCount>0)return!0;if(void 0!==e.subBuildsCache){for(var t in e.subBuildsCache)if(mo(e.subBuildsCache[t]))return!0}return!1},ms=function(){function e(t,r,n){v(this,e),this.object=t,this.material=t&&t.material||null,this.geometry=t&&t.geometry||null,this.renderer=r,this.parser=n,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=hg(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new gq,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:me++})}return y(e,[{key:"isFlatShading",value:function(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}},{key:"isOpaque",value:function(){var e=this.material;return!1===e.transparent&&e.blending===c.n&&!1===e.alphaToCoverage}},{key:"createRenderTarget",value:function(e,t,r){return new c.Kc(e,t,r)}},{key:"createCubeRenderTarget",value:function(e,t){return new lk(e,t)}},{key:"includes",value:function(e){return this.nodes.has(e)}},{key:"getOutputType",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t="vec4",r=this.renderer.getRenderTarget();if(null!==r){var n=r.textures[e].type,i=r.textures[e].format,a="vec";n===c.ya?a="ivec":n===c.za&&(a="uvec"),t=i===c.Ma||i===c.Na?n===c.ya?"int":n===c.za?"uint":"float":i===c.Oa||i===c.Pa?"".concat(a,"2"):i===c.Ia||i===c.Qa?"".concat(a,"3"):"".concat(a,"4")}return t}},{key:"getOutputStructName",value:function(){}},{key:"_getBindGroup",value:function(e,t){var r,n=t[0].groupNode,i=n.shared;if(i)for(var a=1;a<t.length;a++)n!==t[a].groupNode&&(i=!1);if(i){var o="",s=!0,u=!1,l=void 0;try{for(var c,d=t[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value;if(h.isNodeUniformsGroup){h.uniforms.sort(function(e,t){return e.nodeUniform.node.id-t.nodeUniform.node.id});var f=!0,p=!1,v=void 0;try{for(var g,m=h.uniforms[Symbol.iterator]();!(f=(g=m.next()).done);f=!0){var y=g.value;o+=y.nodeUniform.node.id}}catch(e){p=!0,v=e}finally{try{f||null==m.return||m.return()}finally{if(p)throw v}}}else o+=h.nodeUniform.id}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}var b=this.renderer._currentRenderContext||this.renderer,x=mt.get(b);void 0===x&&(x=new Map,mt.set(b,x));var _=H(o);void 0===(r=x.get(_))&&(r=new gU(e,t),x.set(_,r))}else r=new gU(e,t);return r}},{key:"getBindGroupArray",value:function(e,t){var r=this.bindings[t],n=r[e];return void 0===n&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=n=[]),n}},{key:"getBindings",value:function(){var e=this.bindGroups;if(null===e){var t={},r=this.bindings,n=!0,i=!1,a=void 0;try{for(var o,s=ea[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;for(var l in r[u]){var c=r[u][l],d=t[l]||(t[l]=[]),h=!0,f=!1,p=void 0;try{for(var v,g=c[Symbol.iterator]();!(h=(v=g.next()).done);h=!0){var m=v.value;!1===d.includes(m)&&d.push(m)}}catch(e){f=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(f)throw p}}}}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}for(var y in e=[],t){var b=t[y],x=this._getBindGroup(y,b);e.push(x)}this.bindGroups=e}return e}},{key:"sortBindingGroups",value:function(){var e=this.getBindings();e.sort(function(e,t){return e.bindings[0].groupNode.order-t.bindings[0].groupNode.order});for(var t=0;t<e.length;t++){var r=e[t];this.bindingsIndexes[r.name].group=t}}},{key:"setHashNode",value:function(e,t){this.hashNodes[t]=e}},{key:"addNode",value:function(e){!1===this.nodes.has(e)&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}},{key:"addSequentialNode",value:function(e){var t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();(t!==et.NONE||r!==et.NONE)&&this.sequentialNodes.add(e)}},{key:"buildUpdateNodes",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this.nodes[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=n.value;a.getUpdateType()!==et.NONE&&this.updateNodes.push(a)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}var o=!0,s=!1,u=void 0;try{for(var l,c=this.sequentialNodes[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var d=l.value,h=d.getUpdateBeforeType(),f=d.getUpdateAfterType();h!==et.NONE&&this.updateBeforeNodes.push(d),f!==et.NONE&&this.updateAfterNodes.push(d)}}catch(e){s=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw u}}}},{key:"currentNode",get:function(){return this.chaining[this.chaining.length-1]}},{key:"isFilteredTexture",value:function(e){return e.magFilter===c.qa||e.magFilter===c.ra||e.magFilter===c.pa||e.magFilter===c.sa||e.minFilter===c.qa||e.minFilter===c.ra||e.minFilter===c.pa||e.minFilter===c.sa}},{key:"getUniformBufferLimit",value:function(){return this.renderer.backend.capabilities.getUniformBufferLimit()}},{key:"addChain",value:function(e){this.chaining.push(e)}},{key:"removeChain",value:function(e){if(this.chaining.pop()!==e)throw Error("THREE.NodeBuilder: Invalid node chaining!")}},{key:"getMethod",value:function(e){return e}},{key:"getTernary",value:function(){return null}},{key:"getNodeFromHash",value:function(e){return this.hashNodes[e]}},{key:"addFlow",value:function(e,t){return this.flowNodes[e].push(t),t}},{key:"setContext",value:function(e){this.context=e}},{key:"getContext",value:function(){return this.context}},{key:"addContext",value:function(e){var t=this.getContext();return this.setContext(N({},this.context,e)),t}},{key:"getSharedContext",value:function(){var e=N({},this.context);return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}},{key:"setCache",value:function(e){this.cache=e}},{key:"getCache",value:function(){return this.cache}},{key:"getCacheFromNode",value:function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=this.getDataFromNode(e);return void 0===r.cache&&(r.cache=new gq(t?this.getCache():null)),r.cache}},{key:"isAvailable",value:function(){return!1}},{key:"getVertexIndex",value:function(){(0,c.wc)("Abstract function.")}},{key:"getInstanceIndex",value:function(){(0,c.wc)("Abstract function.")}},{key:"getDrawIndex",value:function(){(0,c.wc)("Abstract function.")}},{key:"getFrontFacing",value:function(){(0,c.wc)("Abstract function.")}},{key:"getFragCoord",value:function(){(0,c.wc)("Abstract function.")}},{key:"isFlipY",value:function(){return!1}},{key:"isContextAssign",value:function(){return!0===this.context.assign}},{key:"increaseUsage",value:function(e){var t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=void 0===t.writeUsageCount?1:t.writeUsageCount+1:t.readUsageCount=void 0===t.readUsageCount?1:t.readUsageCount+1,t.usageCount}},{key:"hasWriteUsage",value:function(e){var t=e.getShared(this),r=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);if(void 0!==r){for(var n in r)if(mo(r[n]))return!0}return!1}},{key:"generateTexture",value:function(){(0,c.wc)("Abstract function.")}},{key:"generateTextureLod",value:function(){(0,c.wc)("Abstract function.")}},{key:"generateArrayDeclaration",value:function(e,t){return this.getType(e)+"[ "+t+" ]"}},{key:"generateArray",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.generateArrayDeclaration(e,t)+"( ",i=0;i<t;i++){var a=r?r[i]:null;n+=null!==a?a.build(this,e):this.generateConst(e),i<t-1&&(n+=", ")}return n+" )"}},{key:"generateStruct",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=[],i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,c=l.name,d=l.type;r&&r[c]&&r[c].isNode?n.push(r[c].build(this,d)):n.push(this.generateConst(d))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return e+"( "+n.join(", ")+" )"}},{key:"generateConst",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===r&&("float"===e||"int"===e||"uint"===e?r=0:"bool"===e?r=!1:"color"===e?r=new c.Tc:"vec2"===e||"uvec2"===e||"ivec2"===e?r=new c.Dc:"vec3"===e||"uvec3"===e||"ivec3"===e?r=new c.Fc:("vec4"===e||"uvec4"===e||"ivec4"===e)&&(r=new c.Jc)),"float"===e)return ma(r);if("int"===e)return"".concat(Math.round(r));if("uint"===e)return r>=0?"".concat(Math.round(r),"u"):"0u";if("bool"===e)return r?"true":"false";if("color"===e)return"".concat(this.getType("vec3"),"( ").concat(ma(r.r),", ").concat(ma(r.g),", ").concat(ma(r.b)," )");var n=this.getTypeLength(e),i=this.getComponentType(e),a=function(e){return t.generateConst(i,e)};if(2===n)return"".concat(this.getType(e),"( ").concat(a(r.x),", ").concat(a(r.y)," )");if(3===n)return"".concat(this.getType(e),"( ").concat(a(r.x),", ").concat(a(r.y),", ").concat(a(r.z)," )");if(4===n&&"mat2"!==e)return"".concat(this.getType(e),"( ").concat(a(r.x),", ").concat(a(r.y),", ").concat(a(r.z),", ").concat(a(r.w)," )");if(n>=4&&r&&(r.isMatrix2||r.isMatrix3||r.isMatrix4))return"".concat(this.getType(e),"( ").concat(r.elements.map(a).join(", ")," )");if(n>4)return"".concat(this.getType(e),"()");throw Error("THREE.NodeBuilder: Type '".concat(e,"' not found in generate constant attempt."))}},{key:"getType",value:function(e){return"color"===e?"vec3":e}},{key:"hasGeometryAttribute",value:function(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}},{key:"getAttribute",value:function(e,t){var r=this.attributes,n=!0,i=!1,a=void 0;try{for(var o,s=r[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;if(u.name===e)return u}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}var l=new gI(e,t);return this.registerDeclaration(l),r.push(l),l}},{key:"getPropertyName",value:function(e){return e.name}},{key:"isVector",value:function(e){return/vec\d/.test(e)}},{key:"isMatrix",value:function(e){return/mat\d/.test(e)}},{key:"isReference",value:function(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}},{key:"needsToWorkingColorSpace",value:function(){return!1}},{key:"getComponentTypeFromTexture",value:function(e){var t=e.type;return!0===e.isDepthTexture?"float":t===c.ya?"int":t===c.za?"uint":"float"}},{key:"getElementType",value:function(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}},{key:"getComponentType",value:function(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;var t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}},{key:"getVectorType",value:function(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}},{key:"getTypeFromLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float";if(1===e)return t;var r=X.get(e),n="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),n+r}},{key:"getTypeFromArray",value:function(e){return mi.get(e.constructor)}},{key:"isInteger",value:function(e){return/int|uint|(i|u)vec/.test(e)}},{key:"getTypeFromAttribute",value:function(e){var t=e;e.isInterleavedBufferAttribute&&(t=e.data);var r,n=t.array,i=e.itemSize,a=e.normalized;return S(e,c.ad)||!0===a||(r=this.getTypeFromArray(n)),this.getTypeFromLength(i,r)}},{key:"getTypeLength",value:function(e){var t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:16*(!0===/mat4/.test(e))}},{key:"getVectorFromMatrix",value:function(e){return e.replace("mat","vec")}},{key:"changeComponentType",value:function(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}},{key:"getIntegerType",value:function(e){var t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}},{key:"setActiveStack",value:function(e){this.activeStacks.push(e)}},{key:"removeActiveStack",value:function(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}},{key:"getActiveStack",value:function(){return this.activeStacks[this.activeStacks.length-1]}},{key:"getBaseStack",value:function(){return this.activeStacks[0]}},{key:"addStack",value:function(){this.stack=hg(this.stack);var e=tE();return this.stacks.push(e),tA(this.stack),this.stack}},{key:"removeStack",value:function(){var e=this.stack,t=!0,r=!1,n=void 0;try{for(var i,a=e.nodes[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this.getDataFromNode(o).stack=e}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return this.stack=e.parent,tA(this.stacks.pop()),e}},{key:"getDataFromNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===n&&(n={},r.setData(e,n)),void 0===n[t]&&(n[t]={});var i=n[t];if(0===this.subBuildLayers.length)return i;var a=n.any?n.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(void 0===i.subBuildsCache&&(i.subBuildsCache={}),(i=i.subBuildsCache[o]||(i.subBuildsCache[o]={})).subBuilds=a),i}},{key:"getNodeProperties",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any",r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}},{key:"getBufferAttributeFromNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.getDataFromNode(e,"vertex"),i=n.bufferAttribute;if(void 0===i){var a=this.uniforms.index++;null===r&&(r="nodeAttribute"+a),i=new gI(r,t,e),this.bufferAttributes.push(i),n.bufferAttribute=i}return i}},{key:"getStructTypeNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage;return this.types[t][e]||null}},{key:"getStructTypeFromNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.shaderStage,i=this.getDataFromNode(e,n,this.globalCache),a=i.structType;if(void 0===a){var o=this.structs.index++;null===r&&(r="StructType"+o),a=new gj(r,t),this.structs[n].push(a),this.types[n][r]=e,i.structType=a}return a}},{key:"getOutputStructTypeFromNode",value:function(e,t){var r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}},{key:"getUniformFromNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.shaderStage,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=this.getDataFromNode(e,r,this.globalCache),a=i.uniform;if(void 0===a){var o=this.uniforms.index++;a=new gV(n||"nodeUniform"+o,t,e),this.uniforms[r].push(a),this.registerDeclaration(a),i.uniform=a}return a}},{key:"getVarFromNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.getNodeType(this),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.shaderStage,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=this.getDataFromNode(e,n),o=this.getSubBuildProperty("variable",a.subBuilds),s=a[o];if(void 0===s){var u=i?"_const":"_var",l=this.vars[n]||(this.vars[n]=[]),c=this.vars[u]||(this.vars[u]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+c,this.vars[u]++),"variable"!==o&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new gG(t,r,i,e.getArrayCount(this)),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}},{key:"isDeterministic",value:function(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values){var t=!0,r=!1,n=void 0;try{for(var i,a=e.values[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(!this.isDeterministic(o))return!1}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}return!0}return!!e.isConstNode}},{key:"getVaryingFromNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.getNodeType(this),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=this.getDataFromNode(e,"any"),o=this.getSubBuildProperty("varying",a.subBuilds),s=a[o];if(void 0===s){var u=this.varyings,l=u.length;null===t&&(t="nodeVarying"+l),"varying"!==o&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new gz(t,r,n,i),u.push(s),this.registerDeclaration(s),a[o]=s}return s}},{key:"registerDeclaration",value:function(e){for(var t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),n=e.name,i=n,a=this.getPropertyName(e),o=1;void 0!==r[a];)e.name=i=n+"_"+o++,a=this.getPropertyName(e);i!==n&&(0,c.wc)("TSL: Declaration name '".concat(n,"' of '").concat(e.type,"' already in use. Renamed to '").concat(i,"'.")),r[a]=e}},{key:"getCodeFromNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.shaderStage,n=this.getDataFromNode(e),i=n.code;if(void 0===i){var a=this.codes[r]||(this.codes[r]=[]);i=new gW("nodeCode"+a.length,t),a.push(i),n.code=i}return i}},{key:"addFlowCodeHierarchy",value:function(e,t){for(var r=this.getDataFromNode(e),n=r.flowCodes,i=r.flowCodeBlock,a=!0,o=t;o;){if(!0===i.get(o)){a=!1;break}o=this.getDataFromNode(o).parentNodeBlock}var s=!0,u=!1,l=void 0;if(a)try{for(var c,d=n[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value;this.addLineFlowCode(h)}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}}},{key:"addLineFlowCodeBlock",value:function(e,t,r){var n=this.getDataFromNode(e),i=n.flowCodes||(n.flowCodes=[]),a=n.flowCodeBlock||(n.flowCodeBlock=new WeakMap);i.push(t),a.set(r,!0)}},{key:"addLineFlowCode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}},{key:"addFlowCode",value:function(e){return this.flow.code+=e,this}},{key:"addFlowTab",value:function(){return this.tab+=" ",this}},{key:"removeFlowTab",value:function(){return this.tab=this.tab.slice(0,-1),this}},{key:"getFlowData",value:function(e){return this.flowsData.get(e)}},{key:"flowNode",value:function(e){var t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}},{key:"addInclude",value:function(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}},{key:"buildFunctionNode",value:function(e){var t=this.renderer.backend,r=mr.get(t);void 0===r&&(r=new WeakMap,mr.set(t,r));var n=r.get(e);if(void 0===n){n=new po;var i=this.currentFunctionNode;this.currentFunctionNode=n,n.code=this.buildFunctionCode(e),this.currentFunctionNode=i,r.set(e,n)}return n}},{key:"flowShaderNode",value:function(e){var t=e.layout,r=b({},Symbol.iterator,function(){var e=0,t=Object.values(this);return{next:function(){return{value:t[e],done:e++>=t.length}}}}),n=!0,i=!1,a=void 0;try{for(var o,s=t.inputs[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;r[u.name]=new hv(u.type,u.name)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}e.layout=null;var l=e.call(r),c=this.flowStagesNode(l,t.type);return e.layout=t,c}},{key:"flowBuildStage",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.getBuildStage();this.setBuildStage(t);var i=e.build(this,r);return this.setBuildStage(n),i}},{key:"flowStagesNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.flow,n=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new gq,this.stack=hg();var l=!0,c=!1,d=void 0;try{for(var h,f=ei[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var p=h.value;this.setBuildStage(p),u.result=e.build(this,t)}}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=n,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),u}},{key:"getFunctionOperator",value:function(){return null}},{key:"buildFunctionCode",value:function(){(0,c.wc)("Abstract function.")}},{key:"flowChildNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.flow,n={code:""};return this.flow=n,n.result=e.build(this,t),this.flow=r,n}},{key:"flowNodeFromShaderStage",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);var u=N({},this.context);delete u.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=u;var l=null;if("generate"===this.buildStage){var c=this.flowChildNode(t,r);null!==n&&(c.code+="".concat(this.tab+n," = ").concat(c.result,";\n")),this.flowCode[e]=this.flowCode[e]+c.code,l=c}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}},{key:"getAttributesArray",value:function(){return this.attributes.concat(this.bufferAttributes)}},{key:"getAttributes",value:function(){(0,c.wc)("Abstract function.")}},{key:"getVaryings",value:function(){(0,c.wc)("Abstract function.")}},{key:"getVar",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"".concat(null!==r?this.generateArrayDeclaration(e,r):this.getType(e)," ").concat(t)}},{key:"getVars",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],n=this.vars[e],i=!0,a=!1,o=void 0;if(void 0!==n)try{for(var s,u=n[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;r.push("".concat(this.getVar(l.type,l.name,l.count),";"))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return r.join(t?"\n":"\n ")}},{key:"getUniforms",value:function(){(0,c.wc)("Abstract function.")}},{key:"getCodes",value:function(e){var t=this.codes[e],r="",n=!0,i=!1,a=void 0;if(void 0!==t)try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;r+=u.code+"\n"}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return r}},{key:"getHash",value:function(){return this.vertexShader+this.fragmentShader+this.computeShader}},{key:"setShaderStage",value:function(e){this.shaderStage=e}},{key:"getShaderStage",value:function(){return this.shaderStage}},{key:"setBuildStage",value:function(e){this.buildStage=e}},{key:"getBuildStage",value:function(){return this.buildStage}},{key:"buildCode",value:function(){(0,c.wc)("Abstract function.")}},{key:"subBuild",get:function(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}},{key:"addSubBuild",value:function(e){this.subBuildLayers.push(e)}},{key:"removeSubBuild",value:function(){return this.subBuildLayers.pop()}},{key:"getClosestSubBuild",value:function(e){if(!(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:S(e,Set)?R(e):e))return null;for(var t,r=this.subBuildLayers,n=t.length-1;n>=0;n--){var i=t[n];if(r.includes(i))return i}return null}},{key:"getSubBuildOutput",value:function(e){return this.getSubBuildProperty("outputNode",e)}},{key:"getSubBuildProperty",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(e=null!==r?this.getClosestSubBuild(r):this.subBuildFn)?t?e+"_"+t:e:t}},{key:"prebuild",value:function(){var e=this.object,t=this.renderer,r=this.material;if(!0===t.contextNode.isContextNode?this.context=N({},this.context,t.contextNode.getFlowContextData()):(0,c.xc)('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context=N({},this.context,r.contextNode.getFlowContextData()):(0,c.xc)('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){var n=t.library.fromMaterial(r);null===n&&((0,c.xc)('NodeBuilder: Material "'.concat(r.type,'" is not compatible.')),n=new lo),n.build(this)}else this.addFlow("compute",e)}},{key:"build",value:function(){return this.buildStep(1/0),this}},{key:"buildStep",value:function(e){var t=this._buildStepState;if(null==t&&(this.prebuild(),t=this._buildStepState={stage:0,shader:0,node:0,positionFlowed:!1},performance.now()>=e))return!1;for(;t.stage<ei.length;){var r=ei[t.stage];if(this.setBuildStage(r),!1===t.positionFlowed&&(this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),t.positionFlowed=!0,performance.now()>=e))return!1;for(;t.shader<ea.length;){var n=ea[t.shader];this.setShaderStage(n);for(var i=this.flowNodes[n];t.node<i.length;){var a=i[t.node];if(t.node++,"generate"===r?this.flowNode(a):a.build(this),performance.now()>=e)return!1}t.node=0,t.shader++}t.shader=0,t.positionFlowed=!1,t.stage++}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this._buildStepState=null,!0}},{key:"getSharedDataFromNode",value:function(e){var t=mn.get(e);return void 0===t&&(t={}),t}},{key:"getNodeUniform",value:function(e,t){var r=this.getSharedDataFromNode(e),n=r.cache;if(void 0===n){if("float"===t||"int"===t||"uint"===t)n=new g2(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)n=new g3(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)n=new g4(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)n=new g5(e);else if("color"===t)n=new g6(e);else if("mat2"===t)n=new g8(e);else if("mat3"===t)n=new g9(e);else{if("mat4"!==t)throw Error('THREE.NodeBuilder: Uniform "'.concat(t,'" not implemented.'));n=new g7(e)}r.cache=n}return n}},{key:"format",value:function(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;var n=this.getTypeLength(t),i=this.getTypeLength(r);return 16===n&&9===i?"".concat(this.getType(r),"( ").concat(e,"[ 0 ].xyz, ").concat(e,"[ 1 ].xyz, ").concat(e,"[ 2 ].xyz )"):9===n&&4===i?"".concat(this.getType(r),"( ").concat(e,"[ 0 ].xy, ").concat(e,"[ 1 ].xy )"):n>4||i>4||0===i?e:n===i?"".concat(this.getType(r),"( ").concat(e," )"):n>i?(e="bool"===r?"all( ".concat(e," )"):"".concat(e,".").concat("xyz".slice(0,i)),this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&n>1?"".concat(this.getType(r),"( ").concat(this.format(e,t,"vec3"),", 1.0 )"):2===n?"".concat(this.getType(r),"( ").concat(this.format(e,t,"vec2"),", 0.0 )"):(1===n&&i>1&&t!==this.getComponentType(r)&&(e="".concat(this.getType(this.getComponentType(r)),"( ").concat(e," )")),"".concat(this.getType(r),"( ").concat(e," )"))}},{key:"getSignature",value:function(){return"// Three.js r".concat(c.a," - Node System\n")}},{key:"needsPreviousData",value:function(){var e=this.renderer.getMRT();return e&&e.has("velocity")||!0===$(this.object).useVelocity}}]),e}(),mu=function(){function e(){v(this,e),this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}return y(e,[{key:"_getMaps",value:function(e,t){var r=e.get(t);return void 0===r&&(r={renderId:0,frameId:0},e.set(t,r)),r}},{key:"updateBeforeNode",value:function(e){var t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===et.FRAME){var n=this._getMaps(this.updateBeforeMap,r);if(n.frameId!==this.frameId){var i=n.frameId;n.frameId=this.frameId,!1===e.updateBefore(this)&&(n.frameId=i)}}else if(t===et.RENDER){var a=this._getMaps(this.updateBeforeMap,r);if(a.renderId!==this.renderId){var o=a.renderId;a.renderId=this.renderId,!1===e.updateBefore(this)&&(a.renderId=o)}}else t===et.OBJECT&&e.updateBefore(this)}},{key:"updateAfterNode",value:function(e){var t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===et.FRAME){var n=this._getMaps(this.updateAfterMap,r);n.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(n.frameId=this.frameId)}else if(t===et.RENDER){var i=this._getMaps(this.updateAfterMap,r);i.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(i.renderId=this.renderId)}else t===et.OBJECT&&e.updateAfter(this)}},{key:"updateNode",value:function(e){var t=e.getUpdateType(),r=e.updateReference(this);if(t===et.FRAME){var n=this._getMaps(this.updateMap,r);n.frameId!==this.frameId&&!1!==e.update(this)&&(n.frameId=this.frameId)}else if(t===et.RENDER){var i=this._getMaps(this.updateMap,r);i.renderId!==this.renderId&&!1!==e.update(this)&&(i.renderId=this.renderId)}else t===et.OBJECT&&e.update(this)}},{key:"update",value:function(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}]),e}(),ml=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];v(this,e),this.type=t,this.name=r,this.count=n,this.qualifier=i,this.isConst=a};ml.isNodeFunctionInput=!0;var mc=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),p(this,t,[e])}return T(t,e),y(t,[{key:"setup",value:function(e){e.context.irradiance.addAssign(this.colorNode)}}],[{key:"type",get:function(){return"AmbientLightNode"}}]),t}(vX),md=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),p(this,t,[e])}return T(t,e),y(t,[{key:"setupDirect",value:function(){var e=this.colorNode;return{lightDirection:p9(this.light),lightColor:e}}}],[{key:"type",get:function(){return"DirectionalLightNode"}}]),t}(vX),mh=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r])).lightPositionNode=p5(r),e.lightDirectionNode=e.lightPositionNode.normalize(),e.groundColorNode=rC(new c.Tc).setGroup(rA),e}return T(t,e),y(t,[{key:"update",value:function(e){var r=this.light;x(_(t.prototype),"update",this).call(this,e),this.lightPositionNode.object3d=r,this.groundColorNode.value.copy(r.groundColor).multiplyScalar(r.intensity)}},{key:"setup",value:function(e){var t=this.colorNode,r=this.groundColorNode,n=this.lightDirectionNode,i=n7(r,t,oI.dot(n).mul(.5).add(.5));e.context.irradiance.addAssign(i)}}],[{key:"type",get:function(){return"HemisphereLightNode"}}]),t}(vX),mf=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r])).coneCosNode=rC(0).setGroup(rA),e.penumbraCosNode=rC(0).setGroup(rA),e.cutoffDistanceNode=rC(0).setGroup(rA),e.decayExponentNode=rC(0).setGroup(rA),e.colorNode=rC(e.color).setGroup(rA),e}return T(t,e),y(t,[{key:"update",value:function(e){x(_(t.prototype),"update",this).call(this,e);var r=this.light;this.coneCosNode.value=Math.cos(r.angle),this.penumbraCosNode.value=Math.cos(r.angle*(1-r.penumbra)),this.cutoffDistanceNode.value=r.distance,this.decayExponentNode.value=r.decay}},{key:"getSpotAttenuation",value:function(e,t){return ii(this.coneCosNode,this.penumbraCosNode,t)}},{key:"getLightCoord",value:function(e){var t=e.getNodeProperties(this),r=t.projectionUV;return void 0===r&&(t.projectionUV=r=p4(this.light,e.context.positionWorld)),r}},{key:"setupDirect",value:function(e){var t,r,n=this.colorNode,i=this.cutoffDistanceNode,a=this.decayExponentNode,o=this.light,s=this.getLightVector(e),u=s.normalize(),l=u.dot(p9(o)),c=this.getSpotAttenuation(e,l),d=vK({lightDistance:s.length(),cutoffDistance:i,decayExponent:a}),h=n.mul(c).mul(d);return o.colorNode?(r=this.getLightCoord(e),t=o.colorNode(r)):o.map&&(r=this.getLightCoord(e),t=aS(o.map,r.xy).onRenderUpdate(function(){return o.map})),t&&(h=r.mul(2).sub(1).abs().lessThan(1).all().select(h.mul(t),h)),{lightColor:h,lightDirection:u}}}],[{key:"type",get:function(){return"SpotLightNode"}}]),t}(vX),mp=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r]))._iesTextureNode=null,e}return T(t,e),y(t,[{key:"getSpotAttenuation",value:function(e,r){var n=this.light.iesMap,i=null;if(n&&!0===n.isTexture){var a=r.acos().mul(1/Math.PI);this._iesTextureNode=aS(n,tD(a,0),0),i=this._iesTextureNode.r}else i=x(_(t.prototype),"getSpotAttenuation",this).call(this,e,r);return i}},{key:"update",value:function(e){x(_(t.prototype),"update",this).call(this,e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}],[{key:"type",get:function(){return"IESSpotLightNode"}}]),t}(mf),mv=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(this,t),e=p(this,t,[r]);for(var n=[],i=0;i<9;i++)n.push(new c.Fc);return e.lightProbe=aR(n),e}return T(t,e),y(t,[{key:"update",value:function(e){var r=this.light;x(_(t.prototype),"update",this).call(this,e);for(var n=0;n<9;n++)this.lightProbe.array[n].copy(r.sh.coefficients[n]).multiplyScalar(r.intensity)}},{key:"setup",value:function(e){var t=gF(oI,this.lightProbe);e.context.irradiance.addAssign(t)}}],[{key:"type",get:function(){return"LightProbeNode"}}]),t}(vX),mg=tw(function(e){var t=E(e,2),r=t[0],n=t[1],i=r.abs().sub(n);return nP(nX(i,0)).add(nj(nX(i.x,i.y),0))}),mm=function(e){function t(){return v(this,t),p(this,t,arguments)}return T(t,e),y(t,[{key:"update",value:function(e){x(_(t.prototype),"update",this).call(this,e);var r=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(r.angle*(1-r.penumbra)),.99999),null===r.aspect){var n=1;null!==r.map&&(n=r.map.width/r.map.height),r.shadow.aspect=n}else r.shadow.aspect=r.aspect}},{key:"getSpotAttenuation",value:function(e){var t=tF(0),r=this.penumbraCosNode,n=p3(this.light).mul(e.context.positionWorld||ow);return tR(n.w.greaterThan(0),function(){var e=mg(n.xyz.div(n.w).xy.sub(tD(.5)),tD(.5)),i=rG(-1,rI(1,nE(r)).sub(1));t.assign(it(e.mul(-2).mul(i)))}),t}}],[{key:"type",get:function(){return"ProjectorLightNode"}}]),t}(mf),my=new c.Oc,mb=new c.Oc,mx=null,m_=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return v(this,t),(e=p(this,t,[r])).halfHeight=rC(new c.Fc).setGroup(rA),e.halfWidth=rC(new c.Fc).setGroup(rA),e.updateType=et.RENDER,e}return T(t,e),y(t,[{key:"update",value:function(e){x(_(t.prototype),"update",this).call(this,e);var r=this.light,n=e.camera.matrixWorldInverse;mb.identity(),my.copy(r.matrixWorld),my.premultiply(n),mb.extractRotation(my),this.halfWidth.value.set(.5*r.width,0,0),this.halfHeight.value.set(0,.5*r.height,0),this.halfWidth.value.applyMatrix4(mb),this.halfHeight.value.applyMatrix4(mb)}},{key:"setupDirectRectArea",value:function(e){var t,r;return e.isAvailable("float32Filterable")?(t=aS(mx.LTC_FLOAT_1),r=aS(mx.LTC_FLOAT_2)):(t=aS(mx.LTC_HALF_1),r=aS(mx.LTC_HALF_2)),{lightColor:this.colorNode,lightPosition:p8(this.light),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}}],[{key:"type",get:function(){return"RectAreaLightNode"}},{key:"setLTC",value:function(e){mx=e}}]),t}(vX),mT=function(){function e(){v(this,e)}return y(e,[{key:"parseFunction",value:function(){(0,c.wc)("Abstract function.")}}]),e}(),mS=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";v(this,e),this.type=t,this.inputs=r,this.name=n,this.precision=i}return y(e,[{key:"getCode",value:function(){(0,c.wc)("Abstract function.")}}]),e}();mS.isNodeFunction=!0;var mN=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,mk=/[a-z_0-9]+/gi,mw=function(e){function t(e){v(this,t);var r,n=function(e){var t=(e=e.trim()).indexOf("#pragma main"),r=-1!==t?e.slice(t+12):e,n=r.match(mN);if(null!==n&&5===n.length){for(var i=n[4],a=[],o=null;null!==(o=mk.exec(i));)a.push(o);for(var s=[],u=0;u<a.length;){var l="const"===a[u][0];!0===l&&u++;var c=a[u][0];"in"===c||"out"===c||"inout"===c?u++:c="";var d=a[u++][0],h=Number.parseInt(a[u][0]);!1===Number.isNaN(h)?u++:h=null;var f=a[u++][0];s.push(new ml(d,f,h,c,l))}var p=r.substring(n[0].length),v=void 0!==n[3]?n[3]:"";return{type:n[2],inputs:s,name:v,precision:void 0!==n[1]?n[1]:"",inputsCode:i,blockCode:p,headerCode:-1!==t?e.slice(0,t):""}}throw Error("THREE.FunctionNode: Function is not a GLSL code.")}(e),i=n.type,a=n.inputs,o=n.name,s=n.precision,u=n.inputsCode,l=n.blockCode,c=n.headerCode;return(r=p(this,t,[i,a,o,s])).inputsCode=u,r.blockCode=l,r.headerCode=c,r}return T(t,e),y(t,[{key:"getCode",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.name,r=this.blockCode;if(""!==r){var n=this.type,i=this.inputsCode,a=this.headerCode,o=this.precision,s="".concat(n," ").concat(t," ( ").concat(i.trim()," )");""!==o&&(s="".concat(o," ").concat(s)),e=a+s+r}else e="";return e}}]),t}(mS),mA=function(e){function t(){return v(this,t),p(this,t,arguments)}return T(t,e),y(t,[{key:"parseFunction",value:function(e){return new mw(e)}}]),t}(mT),mE=[],mR=[],mC=rC(0,"int").setGroup(rA),mM=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t)).renderer=e,n.backend=r,n.nodeFrame=new mu,n.nodeBuilderCache=new Map,n.callHashCache=new dP,n.groupsData=new dP,n.cacheLib={},n}return T(t,e),y(t,[{key:"updateGroup",value:function(e){var t=e.groupNode;if(t.updateType===et.OBJECT)return!0;mE[0]=t,mE[1]=e;var r=this.groupsData.get(mE);return void 0===r&&this.groupsData.set(mE,r={}),mE[0]=null,mE[1]=null,r.version!==t.version&&(r.version=t.version,!0)}},{key:"getForRenderCacheKey",value:function(e){return e.initialCacheKey}},{key:"_createNodeBuilder",value:function(e,t){var r=this.backend.createNodeBuilder(e.object,this.renderer);return r.scene=e.scene,r.material=t,r.camera=e.camera,r.context.material=t,r.lightsNode=e.lightsNode,r.environmentNode=this.getEnvironmentNode(e.scene),r.fogNode=this.getFogNode(e.scene),r.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&r.enableMultiview(),r}},{key:"getForRender",value:function(e){var t=this.get(e),r=t.nodeBuilderState;if(void 0===r){var n=this.nodeBuilderCache,i=this.getForRenderCacheKey(e);if(void 0===(r=n.get(i))&&(r=this._spResurrectRetired(i)),void 0===r){var a=this._createNodeBuilder(e,e.material);try{a.build()}catch(t){(a=this._createNodeBuilder(e,new lo)).build();var o=t.stackTrace;!o&&t.stack&&(o=new z(t.stack)),(0,c.xc)("TSL: "+t,o)}r=this.adoptNodeBuilder(i,a)}r.usedTimes++,t.nodeBuilderState=r,t.cacheKey=i}return r}},{key:"adoptNodeBuilder",value:function(e,t){var r=this.nodeBuilderCache.get(e);return void 0===r&&(r=this._createNodeBuilderState(t),this.nodeBuilderCache.set(e,r)),r}},{key:"_spResurrectRetired",value:function(e){if(void 0!==this._spRetiredNodeStates){var t=this._spRetiredNodeStates.get(e);return void 0!==t&&(this._spRetiredNodeStates.delete(e),this.nodeBuilderCache.set(e,t),this._spResurrections=(this._spResurrections||0)+1),t}}},{key:"releaseBuilderState",value:function(e,t){if(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.get(e)===t){this.nodeBuilderCache.delete(e);var r=this._spRetiredNodeStates||(this._spRetiredNodeStates=new Map);r.delete(e),r.set(e,t),r.size>256&&r.delete(r.keys().next().value)}}},{key:"delete",value:function(e){if(e.isRenderObject){var r=this.get(e),n=r.nodeBuilderState;if(null!=n){var i=void 0!==r.cacheKey?r.cacheKey:this.getForRenderCacheKey(e);this.releaseBuilderState(i,n)}}return x(_(t.prototype),"delete",this).call(this,e)}},{key:"getForCompute",value:function(e){var t=this.get(e),r=t.nodeBuilderState;if(void 0===r||t.version!==e.version){var n=this.backend.createNodeBuilder(e,this.renderer);n.build(),t.nodeBuilderState=r=this._createNodeBuilderState(n),t.version=e.version}return r}},{key:"_createNodeBuilderState",value:function(e){return new gO(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}},{key:"getEnvironmentNode",value:function(e){if(!1===this.renderer.lighting.enabled)return null;this.updateEnvironment(e);var t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{var r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}},{key:"getBackgroundNode",value:function(e){this.updateBackground(e);var t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{var r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}},{key:"getFogNode",value:function(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}},{key:"getCacheKey",value:function(e,t){mE[0]=e,mE[1]=t;var r=this.renderer.info.calls,n=this.callHashCache.get(mE)||{};if(n.callId!==r){if(mR.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),mR.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){mR.push(t.getCacheKey(!0)),mR.push(+!!this.renderer.shadowMap.enabled),mR.push(this.renderer.shadowMap.type);var i=this.getEnvironmentNode(e);i&&mR.push(i.getCacheKey())}var a=this.getFogNode(e);a&&mR.push(a.getCacheKey()),n.callId=r,n.cacheKey=q(mR),this.callHashCache.set(mE,n),mR.length=0}return mE[0]=null,mE[1]=null,n.cacheKey}},{key:"isToneMappingState",get:function(){return!this.renderer.getRenderTarget()}},{key:"updateBackground",value:function(e){var t=this.get(e),r=e.background;if(r){var n=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;(t.background!==r||n)&&(t.backgroundNode=this.getCacheNode("background",r,function(){return!0===r.isCubeTexture||r.mapping===c.ha||r.mapping===c.ia||r.mapping===c.ja?e.backgroundBlurriness>0||r.mapping===c.ja?ds(r):lR(!0===r.isCubeTexture?o2(r):aS(r)):!0===r.isTexture?aS(r,aB.flipY()).setUpdateMatrix(!0):void(!0!==r.isColor&&(0,c.xc)("WebGPUNodes: Unsupported background configuration.",r))},n),t.background=r,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}},{key:"getCacheNode",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(void 0===a||n)&&(a=r(),i.set(t,a)),a}},{key:"updateFog",value:function(e){var t=this.get(e),r=e.fog;r?t.fog!==r&&(t.fogNode=this.getCacheNode("fog",r,function(){return r.isFogExp2?ph(o5("color","color",r).setGroup(rA),pc(o5("density","float",r).setGroup(rA))):r.isFog?ph(o5("color","color",r).setGroup(rA),pl(o5("near","float",r).setGroup(rA),o5("far","float",r).setGroup(rA))):void(0,c.xc)("Renderer: Unsupported fog configuration.",r)}),t.fog=r):(delete t.fogNode,delete t.fog)}},{key:"updateEnvironment",value:function(e){var t=this.get(e),r=e.environment;r?t.environment!==r&&(t.environmentNode=this.getCacheNode("environment",r,function(){return!0===r.isCubeTexture?o2(r):!0===r.isTexture?aS(r):void(0,c.xc)("Nodes: Unsupported environment configuration.",r)}),t.environment=r):t.environmentNode&&(delete t.environmentNode,delete t.environment)}},{key:"getNodeFrame",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.renderer,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=r,a.camera=n,a.material=i,a}},{key:"getNodeFrameForRender",value:function(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}},{key:"getOutputCacheKey",value:function(){var e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}},{key:"getOutputNode",value:function(e){var t=this.renderer;return e.isArrayTexture?this.backend.isWebGLBackend?aS(e,aB).depth(aC("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):aS(e,aB).depth(mC).renderOutput(t.toneMapping,t.currentColorSpace):aS(e,aB).renderOutput(t.toneMapping,t.currentColorSpace)}},{key:"setOutputLayerIndex",value:function(e){mC.value=e}},{key:"updateBefore",value:function(e){var t=e.getNodeBuilderState(),r=!0,n=!1,i=void 0;try{for(var a,o=t.updateBeforeNodes[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;this.getNodeFrameForRender(e).updateBeforeNode(s)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}}},{key:"updateAfter",value:function(e){var t=e.getNodeBuilderState(),r=!0,n=!1,i=void 0;try{for(var a,o=t.updateAfterNodes[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;this.getNodeFrameForRender(e).updateAfterNode(s)}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}}},{key:"updateForCompute",value:function(e){var t=this.getNodeFrame(),r=this.getForCompute(e),n=!0,i=!1,a=void 0;try{for(var o,s=r.updateNodes[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;t.updateNode(u)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"updateForRender",value:function(e){var t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState(),n=!0,i=!1,a=void 0;try{for(var o,s=r.updateNodes[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;t.updateNode(u)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"needsRefresh",value:function(e){var t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}},{key:"dispose",value:function(){x(_(t.prototype),"dispose",this).call(this),this.nodeFrame=new mu,this.nodeBuilderCache=new Map,this._spRetiredNodeStates=void 0,this.cacheLib={}}}]),t}(dj),mF=new c.rd,mB=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(this,e),this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new c.Oc,this.viewNormalMatrix=new c.Gc,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==t&&(this.viewMatrix=t.viewMatrix,this.viewNormalMatrix=t.viewNormalMatrix,this.clippingGroupContexts=t.clippingGroupContexts,this.shadowPass=t.shadowPass)}return y(e,[{key:"projectPlanes",value:function(e,t,r){for(var n=e.length,i=0;i<n;i++){mF.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);var a=t[r+i],o=mF.normal;a.x=-o.x,a.y=-o.y,a.z=-o.z,a.w=mF.constant}}},{key:"updateGlobal",value:function(e,t){this.shadowPass=null!==e.overrideMaterial&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(t.matrixWorldInverse),this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}},{key:"update",value:function(e,t){var r=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);var n,i,a=t.clippingPlanes,o=a.length;if(this.clipIntersection?(n=this.intersectionPlanes,i=e.intersectionPlanes.length):(n=this.unionPlanes,i=e.unionPlanes.length),n.length!==i+o){n.length=i+o;for(var s=0;s<o;s++)n[i+s]=new c.Jc;r=!0}this.projectPlanes(a,n,i),r&&(this.version++,this.cacheKey="".concat(this.intersectionPlanes.length,":").concat(this.unionPlanes.length))}},{key:"getGroupContext",value:function(e){if(this.shadowPass&&!e.clipShadows)return this;var t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new mB(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}},{key:"unionClippingCount",get:function(){return this.unionPlanes.length}}]),e}(),mP=function e(t,r,n){v(this,e),this.bundleGroup=t,this.camera=r,this.renderContext=n},mL=[],mD=function(){function e(){v(this,e),this.bundles=new dP}return y(e,[{key:"get",value:function(e,t,r){var n=this.bundles;mL[0]=e,mL[1]=t,mL[2]=r;var i=n.get(mL);return void 0===i&&(i=new mP(e,t,r),n.set(mL,i)),mL[0]=null,mL[1]=null,mL[2]=null,i}},{key:"dispose",value:function(){this.bundles=new dP}}]),e}(),mU=function(){function e(){v(this,e),this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}return y(e,[{key:"fromMaterial",value:function(e){if(e.isNodeMaterial)return e;var t=null,r=this.getMaterialNodeClass(e.type);if(null!==r)for(var n in t=new r,e)t[n]=e[n];return t}},{key:"addToneMapping",value:function(e,t){this.addType(e,t,this.toneMappingNodes)}},{key:"getToneMappingFunction",value:function(e){return this.toneMappingNodes.get(e)||null}},{key:"getMaterialNodeClass",value:function(e){return this.materialNodes.get(e)||null}},{key:"addMaterial",value:function(e,t){this.addType(e,t,this.materialNodes)}},{key:"getLightNodeClass",value:function(e){return this.lightNodes.get(e)||null}},{key:"addLight",value:function(e,t){this.addClass(e,t,this.lightNodes)}},{key:"addType",value:function(e,t,r){if(r.has(t))(0,c.wc)("Redefinition of node ".concat(t));else{if("function"!=typeof e)throw Error("THREE.NodeLibrary: Node class ".concat(e.name," is not a class."));if("function"==typeof t||"object"==(void 0===t?"undefined":C(t)))throw Error("THREE.NodeLibrary: Base class ".concat(t," is not a class."));r.set(t,e)}}},{key:"addClass",value:function(e,t,r){if(r.has(t))(0,c.wc)("Redefinition of node ".concat(t.name));else{if("function"!=typeof e)throw Error("THREE.NodeLibrary: Node class ".concat(e.name," is not a class."));if("function"!=typeof t)throw Error("THREE.NodeLibrary: Base class ".concat(t.name," is not a class."));r.set(t,e)}}}]),e}(),mO=new va,mI=new WeakMap,mV=function(){function e(){v(this,e),this.enabled=!0,this._cache=[]}return y(e,[{key:"createNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(new va).setLights(e)}},{key:"getNode",value:function(e){if(!0!==e.isScene&&!0!==e.isGroup)return mO;var t=mI.get(e);return void 0===t&&(t=this.createNode(),mI.set(e,t)),t}},{key:"beginRender",value:function(e){this._cache.push(this.getNode(e).getLights())}},{key:"finishRender",value:function(e){this.getNode(e).setLights(this._cache.pop())}}]),e}(),mG=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).domElement=e,r._pixelRatio=1,r._width=r.domElement.width,r._height=r.domElement.height,r._viewport=new c.Jc(0,0,r._width,r._height),r._scissor=new c.Jc(0,0,r._width,r._height),r._scissorTest=!1,r.colorTexture=new c.zd,r.depthTexture=new c.Cd,r}return T(t,e),y(t,[{key:"getPixelRatio",value:function(){return this._pixelRatio}},{key:"getDrawingBufferSize",value:function(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}},{key:"getSize",value:function(e){return e.set(this._width,this._height)}},{key:"setPixelRatio",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}},{key:"setDrawingBufferSize",value:function(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._dispatchResize())}},{key:"setSize",value:function(e,t){var r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}},{key:"getScissor",value:function(e){var t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}},{key:"setScissor",value:function(e,t,r,n){var i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,n)}},{key:"getScissorTest",value:function(){return this._scissorTest}},{key:"setScissorTest",value:function(e){this._scissorTest=e}},{key:"getViewport",value:function(e){return e.copy(this._viewport)}},{key:"setViewport",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,r,n),o.minDepth=i,o.maxDepth=a}},{key:"_dispatchResize",value:function(){this.dispatchEvent({type:"resize"})}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}}]),t}(c.Bc),mz=new c.Vc,mW=new c.Dc,mH=new c.Jc,mq=new c.sd,mj=new c.td,mX=new c.Oc,mK=new c.Jc,mY=(b(yt={},c.j,c.k),b(yt,c.k,c.j),b(yt,c.l,c.l),yt),mQ=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v(this,e),this.isRenderer=!0;var i=n.logarithmicDepthBuffer,a=n.reversedDepthBuffer,o=n.alpha,s=n.depth,u=n.stencil,l=n.antialias,d=n.samples,h=n.getFallback,p=n.outputBufferType,g=void 0===p?c.Ba:p,m=(n.multiview,n.asyncCompilation);this.backend=t,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=void 0===o||o,this.logarithmicDepthBuffer=void 0!==i&&i,this.reversedDepthBuffer=void 0!==a&&a,this.outputColorSpace=c.Ib,this.toneMapping=c.Y,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=void 0===s||s,this.stencil=void 0!==u&&u,this.info=new dJ,this.contextNode=ih(),this.library=new mU,this.lighting=new mV,this._samples=(void 0===d?0:d)||!0===(void 0!==l&&l)?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new mG(t.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new al,this._inspector.setRenderer(this),this._getFallback=void 0===h?null:h,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;var y=+(!0!==this.alpha);this._clearColor=new hd(0,0,0,y),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.onError=this._onError,this._outputBufferType=g,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._asyncCompilation=!0===(void 0!==m&&m),this._compilationBurst=!1,this._compilation=null,this.onBackgroundWorkReady=null,this._compilationPromises=null,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:c.g},this.xr={enabled:!1,isPresenting:!1,cameraAutoUpdate:!0,updateCamera:function(){},getCamera:function(){return null},getEnvironmentBlendMode:function(){return null},getSession:function(){return null},setSession:function(){return f(function(){return P(this,function(e){throw Error("WebXR is not supported by the Spline runtime")})})()},getController:function(){return null},getControllerGrip:function(){return null},getHand:function(){return null},addEventListener:function(){},removeEventListener:function(){},hasEventListener:function(){return!1},dispatchEvent:function(){},dispose:function(){}},this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:function(e,t,n){return f(function(){var r,i,a,o,s;return P(this,function(u){switch(u.label){case 0:return[4,this.compileAsync(n,t,e)];case 1:return u.sent(),r=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,i=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),o=e.overrideMaterial||n.material,[2,{fragmentShader:(s=this._objects.get(n,o,e,t,i.lightsNode,a,a.clippingContext).getNodeBuilderState()).fragmentShader,vertexShader:s.vertexShader}]}})}).call(r)}}}return y(e,[{key:"init",value:function(){return f(function(){var e;return P(this,function(t){return e=this,[2,(null!==this._initPromise||(this._initPromise=new Promise(function(t,r){return f(function(){var e,n;return P(this,function(i){switch(i.label){case 0:e=this.backend,i.label=1;case 1:return i.trys.push([1,3,,8]),[4,e.init(this)];case 2:return i.sent(),[3,8];case 3:if(n=i.sent(),null===this._getFallback)return[2,void r(n)];i.label=4;case 4:return i.trys.push([4,6,,7]),this.backend=e=this._getFallback(n),[4,e.init(this)];case 5:return i.sent(),[3,7];case 6:return[2,void r(i.sent())];case 7:return[3,8];case 8:return this._nodes=new mM(this,e),this._animation=new dB(this,this._nodes,this.info),this._attributes=new dX(e,this.info),this._background=new gL(this,this._nodes),this._geometries=new dZ(this._attributes,this.info),this._textures=new hc(this,e,this.info),this._pipelines=new d4(e,this._nodes,this.info),this._bindings=new d5(e,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new dq(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new hi(this.lighting,this._objects),this._bundles=new mD,this._renderContexts=new hu(this),this._compilation=new dG(this),this._compilation.burst=this._compilationBurst,this._animation.start(),this._initialized=!0,this._inspector.init(),t(this),[2]}})}).call(e)})),this._initPromise)]})}).call(this)}},{key:"domElement",get:function(){return this._canvasTarget.domElement}},{key:"coordinateSystem",get:function(){return this.backend.coordinateSystem}},{key:"setAsyncCompilation",value:function(e){!0==(e=!0===e)&&!1===this._asyncCompilation&&null!==this._objects&&this._objects.resetClassifications(),this._asyncCompilation=e}},{key:"setCompilationBurst",value:function(e){e=!0===e,this._compilationBurst=e,null!==this._compilation&&(this._compilation.burst=e)}},{key:"compileAsync",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return f(function(){var n,i,a,o,s,u,l,c,d,h,f,p,v,g,m,y,b,x;return P(this,function(_){switch(_.label){case 0:if(!0===this._isDeviceLost)return[2];if(!1!==this._initialized)return[3,2];return[4,this.init()];case 1:_.sent(),_.label=2;case 2:return i=(n=this._nodes.nodeFrame).renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,u=this._compilationPromises,null===r&&(r=e),l=!0===e.isScene?e:!0===r.isScene?r:mz,c=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(c,this._mrt),h=this._activeMipmapLevel,d.renderTarget=c,d.activeCubeFace=this._activeCubeFace,d.activeMipmapLevel=h,f=[],this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=f,n.renderId++,n.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new mB),d.clippingContext.updateGlobal(l,t),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t),l.onBeforeRender(this,e,t,c),p=t.isArrayCamera?mj:mq,t.isArrayCamera?p.setFromArrayCamera(t):(mX.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),p.setFromProjectionMatrix(mX,t.coordinateSystem,t.reversedDepth)),((v=this._renderLists.get(l,t)).begin(),this._projectObject(e,t,0,v,d.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&v.pushLight(e)}),v.finish(),null!==c)?(this._textures.updateRenderTarget(c,h),d.textures=(g=this._textures.get(c)).textures,d.depthTexture=g.depthTexture):(d.textures=null,d.depthTexture=null),r!==e?this._background.update(r,v,d):this._background.update(l,v,d),m=v.opaque,y=v.transparent,b=v.transparentDoublePass,x=v.lightsNode,!0===this.opaque&&m.length>0&&this._renderObjects(m,t,l,x),!0===this.transparent&&y.length>0&&this._renderTransparents(y,b,t,l,x),n.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=u,[4,Promise.all(f)];case 3:return _.sent(),[2]}})}).call(this)}},{key:"renderAsync",value:function(e,t){return f(function(){return P(this,function(r){switch(r.label){case 0:return(0,c.yc)('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),[4,this.init()];case 1:return r.sent(),this.render(e,t),[2]}})}).call(this)}},{key:"waitForGPU",value:function(){return f(function(){return P(this,function(e){return(0,c.xc)("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information."),[2]})})()}},{key:"inspector",get:function(){return this._inspector},set:function(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}},{key:"highPrecision",get:function(){var e=this.contextNode.value;return e.modelViewMatrix===ox&&e.modelNormalViewMatrix===o_},set:function(e){var t=this.contextNode.value;!0===e?(t.modelViewMatrix=ox,t.modelNormalViewMatrix=o_):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}},{key:"setMRT",value:function(e){return this._mrt=e,this}},{key:"getMRT",value:function(){return this._mrt}},{key:"getOutputBufferType",value:function(){return this._outputBufferType}},{key:"getColorBufferType",value:function(){return(0,c.yc)('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}},{key:"_onDeviceLost",value:function(e){var t="THREE.WebGPURenderer: ".concat(e.api," Device Lost:\n\nMessage: ").concat(e.message);e.reason&&(t+="\nReason: ".concat(e.reason)),(0,c.xc)(t),this._isDeviceLost=!0,null!==this._compilation&&this._compilation.clear("cancelled")}},{key:"_onError",value:function(e){var t="WebGPURenderer: Uncaptured ".concat(e.api," ").concat(e.type);e.message&&(t+=": ".concat(e.message)),(0,c.xc)(t)}},{key:"_bundleNeedsUpdate",value:function(e,t){return void 0===t.bundleGPU||e.version!==t.version}},{key:"_renderBundle",value:function(e,t,r){var n=e.bundleGroup,i=e.camera,a=e.renderList,o=this._currentRenderContext,s=this._bundles.get(n,i,o),u=this.backend.get(s),l=this._bundleNeedsUpdate(n,u);if(void 0===this._bundleDebug&&(this._bundleDebug={records:0,replays:0}),l){this._bundleDebug.records++,u.incompleteRecord=!1,this.backend.beginBundle(o),this._currentRenderBundle=s;var c=a.transparentDoublePass,d=a.transparent,h=a.opaque;!0===this.opaque&&h.length>0&&this._renderObjects(h,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,c,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(o,s),!0===u.incompleteRecord?this._bundleDebug.incompleteRecords=(this._bundleDebug.incompleteRecords||0)+1:u.version=n.version}else{this._bundleDebug.replays++;for(var f=u.renderObjects,p=0,v=f.length;p<v;p++){var g=f[p];this._nodes.updateBefore(g),this._geometries.updateForRender(g),this._nodes.updateForRender(g),this._bindings.updateForRender(g),this._nodes.updateAfter(g)}}this.backend.addBundle(o,s)}},{key:"render",value:function(e,t){if(!1===this._initialized)throw Error('THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t),null!==this._compilation&&-1===this._callDepth&&this._compilation.update()}},{key:"initialized",get:function(){return this._initialized}},{key:"_renderOutputLayers",value:function(e,t){if(!0!==t.texture.isArrayTexture||t.texture.image.depth<=1)return void this._renderScene(e,e.camera,!1);var r=this._activeCubeFace;try{for(var n=0;n<t.texture.image.depth;n++)this._nodes.setOutputLayerIndex(n),this._activeCubeFace=n,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=r}}},{key:"_getFrameBufferTarget",value:function(){var e=this,t=this.currentToneMapping,r=this.currentColorSpace,n=t!==c.Y,i=r!==c.Hc.workingColorSpace;if(!1===n&&!1===i)return null;var a=this.getDrawingBufferSize(mW),o=a.width,s=a.height,u=this.depth,l=this.stencil,d=this._outputRenderTarget||this._canvasTarget,h=this._frameBufferTargets.get(d);if(void 0===h){(h=new c.Kc(o,s,{depthBuffer:u,stencilBuffer:l,type:this._outputBufferType,format:c.Ja,colorSpace:c.Hc.workingColorSpace,generateMipmaps:!1,minFilter:c.qa,magFilter:c.qa,samples:this.samples})).isPostProcessingRenderTarget=!0;var f=function(){d.removeEventListener("dispose",f),h.dispose(),e._frameBufferTargets.delete(d)};d.addEventListener("dispose",f),this._frameBufferTargets.set(d,h)}var p=this.getOutputRenderTarget();h.depthBuffer=u,h.stencilBuffer=l,null!==p?h.setSize(p.width,p.height,p.depth):h.setSize(o,s,1);var v=this._outputRenderTarget?this._outputRenderTarget.viewport:d._viewport,g=this._outputRenderTarget?this._outputRenderTarget.scissor:d._scissor,m=this._outputRenderTarget?1:d._pixelRatio,y=this._outputRenderTarget?this._outputRenderTarget.scissorTest:d._scissorTest;return h.viewport.copy(v),h.scissor.copy(g),h.viewport.multiplyScalar(m),h.scissor.multiplyScalar(m),h.scissorTest=y,h.multiview=null!==p&&p.multiview,h.useArrayDepthTexture=null!==p&&p.useArrayDepthTexture,h.resolveDepthBuffer=null===p||p.resolveDepthBuffer,h._autoAllocateDepthBuffer=null!==p&&p._autoAllocateDepthBuffer,h}},{key:"_renderScene",value:function(e,t){var r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(!0!==this._isDeviceLost){null!==this._compilation&&-1===this._callDepth&&this._compilation.applyPromotions();var n=r?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,u=this._handleObjectFunction,l=this._currentRenderBundle;this._currentRenderBundle=null,this.lighting.beginRender(e),this._callDepth++;var c,d=!0===e.isScene?e:mz,h=this._renderTarget||this._outputRenderTarget,f=this._activeCubeFace,p=this._activeMipmapLevel;if(null!==n?(c=n,this.setRenderTarget(c)):c=h,null!==c&&!0===c.depthBuffer){var v=this._textures.get(c);!0!==v.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),v.depthInitialized=!0)}var g=this._renderContexts.get(c,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,c),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t);var m=this._canvasTarget,y=m._viewport,b=m._scissor,x=m._pixelRatio;null!==c&&(y=c.viewport,b=c.scissor,x=1),this.getDrawingBufferSize(mW),mH.set(0,0,mW.width,mW.height);var _=void 0===y.minDepth?0:y.minDepth,T=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(x).floor(),g.viewportValue.width>>=p,g.viewportValue.height>>=p,g.viewportValue.minDepth=_,g.viewportValue.maxDepth=T,g.viewport=!1===g.viewportValue.equals(mH),g.scissorValue.copy(b).multiplyScalar(x).floor(),g.scissor=m._scissorTest&&!1===g.scissorValue.equals(mH),g.scissorValue.width>>=p,g.scissorValue.height>>=p,g.clippingContext||(g.clippingContext=new mB),g.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,c);var S=t.isArrayCamera?mj:mq;t.isArrayCamera?S.setFromArrayCamera(t):(mX.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),S.setFromProjectionMatrix(mX,t.coordinateSystem,t.reversedDepth));var N=this._renderLists.get(e,t);if(N.begin(),this._projectObject(e,t,0,N,g.clippingContext),N.finish(),!0===this.sortObjects&&N.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),null!==c){this._textures.updateRenderTarget(c,p);var k=this._textures.get(c);g.textures=k.textures,g.depthTexture=k.depthTexture,g.width=k.width,g.height=k.height,g.renderTarget=c,g.depth=c.depthBuffer,g.stencil=c.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=mW.width,g.height=mW.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=p,g.height>>=p,g.activeCubeFace=f,g.activeMipmapLevel=p,g.occlusionQueryCount=N.occlusionQueryCount,g.scissorValue.max(mK.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(d,N,g),g.camera=t,this.backend.beginRender(g);var w=N.bundles,A=N.lightsNode,E=N.transparentDoublePass,R=N.transparent,C=N.opaque;return w.length>0&&this._renderBundles(w,d,A),!0===this.opaque&&C.length>0&&this._renderObjects(C,t,d,A),!0===this.transparent&&R.length>0&&this._renderTransparents(R,E,t,d,A),this.backend.finishRender(g),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=u,this._currentRenderBundle=l,this.lighting.finishRender(e),this._callDepth--,null!==n&&(this.setRenderTarget(h,f,p),this._renderOutput(c)),d.onAfterRender(this,e,t,c),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}}},{key:"_setXRLayerSize",value:function(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}},{key:"_renderOutput",value:function(e){var t,r=this,n=this._nodes.getOutputCacheKey(),i=this._quadCache.get(e.texture);if(void 0===i){(t=new fh(new lo)).name="Output Color Transform",t.material.name="outputColorTransform",t.material.fragmentNode=this._nodes.getOutputNode(e.texture),i={quad:t,cacheKey:n},this._quadCache.set(e.texture,i);var a=function(){t.material.dispose(),r._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",a)};e.texture.addEventListener("dispose",a)}else t=i.quad,i.cacheKey!==n&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0,i.cacheKey=n);var o=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(t,e),this.autoClear=o,this.xr.enabled=s}},{key:"getMaxAnisotropy",value:function(){return this.backend.capabilities.getMaxAnisotropy()}},{key:"getActiveCubeFace",value:function(){return this._activeCubeFace}},{key:"getActiveMipmapLevel",value:function(){return this._activeMipmapLevel}},{key:"setAnimationLoop",value:function(e){return f(function(){return P(this,function(t){switch(t.label){case 0:if(!1!==this._initialized)return[3,2];return[4,this.init()];case 1:t.sent(),t.label=2;case 2:return this._animation.setAnimationLoop(e),[2]}})}).call(this)}},{key:"getAnimationLoop",value:function(){return this._animation.getAnimationLoop()}},{key:"getArrayBufferAsync",value:function(e){return f(function(e){var t,r,n,i,a,o=arguments;return P(this,function(s){switch(s.label){case 0:if(t=this,r=o.length>1&&void 0!==o[1]?o[1]:null,n=o.length>2&&void 0!==o[2]?o[2]:0,i=o.length>3&&void 0!==o[3]?o[3]:-1,null!==r&&r.isReadbackBuffer&&!1===this.info.memoryMap.has(r)&&(this.info.createReadbackBuffer(r),a=function(){r.removeEventListener("dispose",a),t.info.destroyReadbackBuffer(r)},r.addEventListener("dispose",a)),n%4!=0||i>0&&i%4!=0)throw Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return[4,this.backend.getArrayBufferAsync(e,r,n,i)];case 1:return[2,s.sent()]}})}).apply(this,arguments)}},{key:"getContext",value:function(){return this.backend.getContext()}},{key:"getPixelRatio",value:function(){return this._canvasTarget.getPixelRatio()}},{key:"getDrawingBufferSize",value:function(e){return this._canvasTarget.getDrawingBufferSize(e)}},{key:"getSize",value:function(e){return this._canvasTarget.getSize(e)}},{key:"setPixelRatio",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this._canvasTarget.setPixelRatio(e)}},{key:"setDrawingBufferSize",value:function(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}},{key:"setSize",value:function(e,t){var r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}},{key:"setOpaqueSort",value:function(e){this._opaqueSort=e}},{key:"setTransparentSort",value:function(e){this._transparentSort=e}},{key:"getScissor",value:function(e){return this._canvasTarget.getScissor(e)}},{key:"setScissor",value:function(e,t,r,n){this._canvasTarget.setScissor(e,t,r,n)}},{key:"getScissorTest",value:function(){return this._canvasTarget.getScissorTest()}},{key:"setScissorTest",value:function(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}},{key:"getViewport",value:function(e){return this._canvasTarget.getViewport(e)}},{key:"setViewport",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;this._canvasTarget.setViewport(e,t,r,n,i,a)}},{key:"getClearColor",value:function(e){return e.copy(this._clearColor)}},{key:"setClearColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this._clearColor.set(e),this._clearColor.a=t}},{key:"getClearAlpha",value:function(){return this._clearColor.a}},{key:"setClearAlpha",value:function(e){this._clearColor.a=e}},{key:"getClearDepth",value:function(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}},{key:"setClearDepth",value:function(e){this._clearDepth=e}},{key:"getClearStencil",value:function(){return this._clearStencil}},{key:"setClearStencil",value:function(e){this._clearStencil=e}},{key:"isOccluded",value:function(e){var t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}},{key:"clear",value:function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(!1===this._initialized)throw Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');var n=this._renderTarget||this._getFrameBufferTarget(),i=null;if(null!==n){this._textures.updateRenderTarget(n);var a=this._textures.get(n);(i=this._renderContexts.get(n,null,-1)).textures=a.textures,i.depthTexture=a.depthTexture,i.width=a.width,i.height=a.height,i.renderTarget=n,i.depth=n.depthBuffer,i.stencil=n.stencilBuffer;var o=this.backend.getClearColor();i.clearColorValue.r=o.r,i.clearColorValue.g=o.g,i.clearColorValue.b=o.b,i.clearColorValue.a=o.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),!0===n.depthBuffer&&(a.depthInitialized=!0)}this.backend.clear(e,t,r,i),null!==n&&null===this._renderTarget&&this._renderOutput(n)}},{key:"clearColor",value:function(){this.clear(!0,!1,!1)}},{key:"clearDepth",value:function(){this.clear(!1,!0,!1)}},{key:"clearStencil",value:function(){this.clear(!1,!1,!0)}},{key:"clearAsync",value:function(){return f(function(){var e,t,r,n=arguments;return P(this,function(i){switch(i.label){case 0:return e=!(n.length>0)||void 0===n[0]||n[0],t=!(n.length>1)||void 0===n[1]||n[1],r=!(n.length>2)||void 0===n[2]||n[2],(0,c.yc)('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),[4,this.init()];case 1:return i.sent(),this.clear(e,t,r),[2]}})}).apply(this,arguments)}},{key:"clearColorAsync",value:function(){return f(function(){return P(this,function(e){return(0,c.yc)('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1),[2]})}).call(this)}},{key:"clearDepthAsync",value:function(){return f(function(){return P(this,function(e){return(0,c.yc)('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1),[2]})}).call(this)}},{key:"clearStencilAsync",value:function(){return f(function(){return P(this,function(e){return(0,c.yc)('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0),[2]})}).call(this)}},{key:"needsFrameBufferTarget",get:function(){var e=this.currentToneMapping!==c.Y,t=this.currentColorSpace!==c.Hc.workingColorSpace;return e||t}},{key:"samples",get:function(){return this._samples}},{key:"currentSamples",get:function(){var e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}},{key:"currentToneMapping",get:function(){return this.isOutputTarget?this.toneMapping:c.Y}},{key:"currentColorSpace",get:function(){return this.isOutputTarget?this.outputColorSpace:c.Hc.workingColorSpace}},{key:"isOutputTarget",get:function(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}},{key:"dispose",value:function(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._compilation.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();var e=!0,t=!1,r=void 0;try{for(var n,i=this._frameBufferTargets.keys()[Symbol.iterator]();!(e=(n=i.next()).done);e=!0)n.value.dispose()}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}Object.values(this.backend.timestampQueryPool).forEach(function(e){null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}},{key:"setRenderTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}},{key:"getRenderTarget",value:function(){return this._renderTarget}},{key:"setOutputRenderTarget",value:function(e){this._outputRenderTarget=e}},{key:"getOutputRenderTarget",value:function(){return this._outputRenderTarget}},{key:"setCanvasTarget",value:function(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}},{key:"getCanvasTarget",value:function(){return this._canvasTarget}},{key:"_resetXRState",value:function(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);var e=!0,t=!1,r=void 0;try{for(var n,i=this._frameBufferTargets.keys()[Symbol.iterator]();!(e=(n=i.next()).done);e=!0)n.value.dispose()}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"setRenderObjectFunction",value:function(e){this._renderObjectFunction=e}},{key:"getRenderObjectFunction",value:function(){return this._renderObjectFunction}},{key:"compute",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!0!==this._isDeviceLost){if(!1===this._initialized)return(0,c.wc)("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);var r=this._nodes.nodeFrame,n=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);var i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,u=Array.isArray(e)?e:[e];if(void 0===u[0]||!0!==u[0].isComputeNode)throw Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);var l=!0,d=!1,h=void 0;try{for(var f,p,v=u[Symbol.iterator]();!(l=(p=v.next()).done);l=!0)f=this,function(){var r=p.value;if(!1===a.has(r)){var n=function(){r.removeEventListener("dispose",n),a.delete(r),o.deleteForCompute(r),s.delete(r)};r.addEventListener("dispose",n);var u=r.onInitFunction;null!==u&&u.call(r,{renderer:f})}s.updateForCompute(r),o.updateForCompute(r);var l=o.getForCompute(r),c=a.getForCompute(r,l);i.compute(e,r,l,c,t)}()}catch(e){d=!0,h=e}finally{try{l||null==v.return||v.return()}finally{if(d)throw h}}i.finishCompute(e),r.renderId=n,this.inspector.finishCompute(this.backend.getTimestampUID(e))}}},{key:"computeAsync",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return f(function(){return P(this,function(r){switch(r.label){case 0:if(!1!==this._initialized)return[3,2];return[4,this.init()];case 1:r.sent(),r.label=2;case 2:return this.compute(e,t),[2]}})}).call(this)}},{key:"hasFeatureAsync",value:function(e){return f(function(){return P(this,function(t){switch(t.label){case 0:return(0,c.yc)('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),[4,this.init()];case 1:return[2,(t.sent(),this.hasFeature(e))]}})}).call(this)}},{key:"resolveTimestampsAsync",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render";return f(function(){return P(this,function(t){switch(t.label){case 0:if(!1!==this._initialized)return[3,2];return[4,this.init()];case 1:t.sent(),t.label=2;case 2:return[2,this.backend.resolveTimestampsAsync(e)]}})}).call(this)}},{key:"hasFeature",value:function(e){if(!1===this._initialized)throw Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}},{key:"hasInitialized",value:function(){return this._initialized}},{key:"initTextureAsync",value:function(e){return f(function(){return P(this,function(t){switch(t.label){case 0:return(0,c.yc)('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),[4,this.init()];case 1:return t.sent(),this.initTexture(e),[2]}})}).call(this)}},{key:"initTexture",value:function(e){if(!1===this._initialized)throw Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}},{key:"initRenderTarget",value:function(e){if(!1===this._initialized)throw Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);var t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}},{key:"copyFramebufferToTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!==t)if(t.isVector2)t=mK.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void(0,c.xc)("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=mK.copy(t).floor()}else t=mK.set(0,0,e.image.width,e.image.height);var r,n=this._currentRenderContext;null!==n?r=n.renderTarget:null!==(r=this._renderTarget||this._getFrameBufferTarget())&&(this._textures.updateRenderTarget(r),n=this._textures.get(r)),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}},{key:"copyTextureToTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,n,i,a),this._inspector.copyTextureToTexture(e,t)}},{key:"readRenderTargetPixelsAsync",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;return f(function(){return P(this,function(s){return[2,this.backend.copyTextureToBuffer(e.textures[a],t,r,n,i,o)]})}).call(this)}},{key:"_projectObject",value:function(e,t,r,n,i){if(!1!==e.visible){if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)n.pushLight(e);else if(e.isSprite){var a=t.isArrayCamera?mj:mq;if(!e.frustumCulled||a.intersectsSprite(e)){!0===this.sortObjects&&mK.setFromMatrixPosition(e.matrixWorld).applyMatrix4(mX);var o=e.geometry,s=e.material;s.visible&&n.push(e,o,s,r,mK.z,null,i)}}else if(e.isLineLoop)(0,c.xc)("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&!0!==e.isDrawSuppressed){var u=t.isArrayCamera?mj:mq;if(!e.frustumCulled||u.intersectsObject(e)){var l=e.geometry,d=e.material;if(!0===this.sortObjects&&(null===l.boundingSphere&&l.computeBoundingSphere(),mK.copy(l.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(mX)),Array.isArray(d))for(var h=l.groups,f=0,p=h.length;f<p;f++){var v=h[f],g=d[v.materialIndex];g&&g.visible&&n.push(e,l,g,r,mK.z,v,i)}else d.visible&&n.push(e,l,d,r,mK.z,null,i)}}}if(!0===e.isBundleGroup&&void 0!==this.backend.beginBundle){var m=n;n=this._renderLists.get(e,t);var y=this._bundles.get(e,t,this._currentRenderContext),b=this.backend.get(y);if(this._bundleNeedsUpdate(e,b)){n.begin(),void 0===b.renderObjects?b.renderObjects=[]:b.renderObjects.length=0;for(var x=e.children,_=0,T=x.length;_<T;_++)this._projectObject(x[_],t,r,n,i);n.finish()}for(var S=n.lightsArray,N=0,k=S.length;N<k;N++)m.pushLight(S[N]);return void m.pushBundle({bundleGroup:e,camera:t,renderList:n})}for(var w=e.children,A=0,E=w.length;A<E;A++)this._projectObject(w[A],t,r,n,i)}}},{key:"_renderBundles",value:function(e,t,r){var n=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;this._renderBundle(u,t,r)}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"_renderTransparents",value:function(e,t,r,n,i){if(t.length>0){var a=!0,o=!1,s=void 0;try{for(var u,l=t[Symbol.iterator]();!(a=(u=l.next()).done);a=!0)u.value.material.side=c.k}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}this._renderObjects(t,r,n,i,"backSide");var d=!0,h=!1,f=void 0;try{for(var p,v=t[Symbol.iterator]();!(d=(p=v.next()).done);d=!0)p.value.material.side=c.j}catch(e){h=!0,f=e}finally{try{d||null==v.return||v.return()}finally{if(h)throw f}}this._renderObjects(e,r,n,i);var g=!0,m=!1,y=void 0;try{for(var b,x=t[Symbol.iterator]();!(g=(b=x.next()).done);g=!0)b.value.material.side=c.l}catch(e){m=!0,y=e}finally{try{g||null==x.return||x.return()}finally{if(m)throw y}}}else this._renderObjects(e,r,n,i)}},{key:"_renderObjects",value:function(e,t,r,n){for(var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=0,o=e.length;a<o;a++){var s=e[a],u=s.object,l=s.geometry,c=s.material,d=s.group,h=s.clippingContext;this._currentRenderObjectFunction(u,r,t,l,c,d,n,h,i)}}},{key:"_getShadowNodes",value:function(e){var t=e.version,r=this._cacheShadowNodes.get(e);if(void 0===r||r.version!==t){var n,i,a=e.castShadowNode&&e.castShadowNode.isNode,o=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,s=e.alphaTest>0||!0===this.shadowMap.transmitted||a||o,u=s&&e.map&&e.map.isTexture,l=s&&e.colorNode&&e.colorNode.isNode,d=null,h=null,f=null;if((u||l||a||o)&&(a?(n=e.castShadowNode.rgb,i=e.castShadowNode.a,!0!==this.shadowMap.transmitted&&(0,c.yc)("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(n=tV(0),i=tF(1)),u&&(i=i.mul(o5("map","texture",e).a)),l&&(i=i.mul(e.colorNode.a)),h=tH(n,i),o)){var p=e.maskShadowNode||e.maskNode;h=tw(function(e){var t=E(e,1)[0];return p.not().discard(),t})(h)}e.depthNode&&e.depthNode.isNode&&(f=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?d=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(d=e.positionNode),r={version:t,colorNode:h,depthNode:f,positionNode:d},this._cacheShadowNodes.set(e,r)}return r}},{key:"_updateCamera",value:function(e){var t=this.xr;if(!1===t.isPresenting){var r=!1;if(!0===this.reversedDepthBuffer&&!0!==e.reversedDepth){var n=!0,i=!1,a=void 0;if(e._reversedDepth=!0,e.isArrayCamera)try{for(var o,s=e.cameras[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)o.value._reversedDepth=!0}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}r=!0}var u=this.coordinateSystem;if(e.coordinateSystem!==u){var l=!0,c=!1,d=void 0;if(e.coordinateSystem=u,e.isArrayCamera)try{for(var h,f=e.cameras[Symbol.iterator]();!(l=(h=f.next()).done);l=!0)h.value.coordinateSystem=u}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}r=!0}var p=!0,v=!1,g=void 0;if(!0===r&&(e.updateProjectionMatrix(),e.isArrayCamera))try{for(var m,y=e.cameras[Symbol.iterator]();!(p=(m=y.next()).done);p=!0)m.value.updateProjectionMatrix()}catch(e){v=!0,g=e}finally{try{p||null==y.return||y.return()}finally{if(v)throw g}}}return null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===t.enabled&&!0===t.isPresenting&&(!0===t.cameraAutoUpdate&&t.updateCamera(e),e=t.getCamera()),e}},{key:"renderObject",value:function(e,t,r,n,i,a,o){var s,u,l,d,h,f,p,v=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,g=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,m=!1,y=this._currentSourceMaterial;if(e.onBeforeRender(this,t,r,n,i,a),!0===i.allowOverride&&null!==t.overrideMaterial){this._currentSourceMaterial=i;var b=t.overrideMaterial;if(m=!0,s=b.isNodeMaterial?b.colorNode:null,u=b.isNodeMaterial?b.depthNode:null,l=b.isNodeMaterial?b.positionNode:null,d=t.overrideMaterial.side,h=b.displacementMap,f=b.displacementScale,p=b.displacementBias,i.positionNode&&i.positionNode.isNode&&(b.positionNode=i.positionNode),b.alphaTest=i.alphaTest,b.alphaMap=i.alphaMap,b.displacementMap=i.displacementMap,b.displacementScale=i.displacementScale,b.displacementBias=i.displacementBias,b.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,b.isShadowPassMaterial){var x=this._getShadowNodes(i),_=x.colorNode,T=x.depthNode,S=x.positionNode;this.shadowMap.type===c.i?b.side=null!==i.shadowSide?i.shadowSide:i.side:b.side=null!==i.shadowSide?i.shadowSide:mY[i.side],null!==_&&(b.colorNode=_),null!==T&&(b.depthNode=T),null!==S&&(b.positionNode=S)}i=b}!0===i.transparent&&i.side===c.l&&!1===i.forceSinglePass?(i.side=c.k,this._handleObjectFunction(e,i,t,r,o,a,v,"backSide"),i.side=c.j,this._handleObjectFunction(e,i,t,r,o,a,v,g),i.side=c.l):this._handleObjectFunction(e,i,t,r,o,a,v,g),m&&(t.overrideMaterial.colorNode=s,t.overrideMaterial.depthNode=u,t.overrideMaterial.positionNode=l,t.overrideMaterial.side=d,t.overrideMaterial.displacementMap=h,t.overrideMaterial.displacementScale=f,t.overrideMaterial.displacementBias=p),this._currentSourceMaterial=y,e.onAfterRender(this,t,r,n,i,a)}},{key:"hasCompatibility",value:function(e){if(!1===this._initialized)throw Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}},{key:"_renderObjectDirect",value:function(e,t,r,n,i,a,o,s){var u=this._objects.get(e,t,r,n,i,this._currentRenderContext,o,s,a);u.drawRange=e.geometry.drawRange,u.group=a,null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup);var l=!0===this._asyncCompilation&&!1===this._compilation._updating&&!0!==e.isQuadMesh;if(!0===l){if(!0===this._pipelines.isReady(u)){var c=this.backend.detectAttachmentMismatch(u);if((!0===this.backend.detectStructuralChange(u)||!0===c)&&this._objects.requestPending(u,u.getCacheKey(),!0,s),!0===c)return void this._spNoteSkippedAsyncDraw()}if(!1===this._pipelines.isReady(u))return void this._spNoteSkippedAsyncDraw()}var d=this._nodes.needsRefresh(u)||!0===u._spBindingsFresh;d&&(u._spBindingsFresh=!1,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),!1!==l||(this._pipelines.updateForRender(u),!1!==this._pipelines.isReady(u))?(this.backend.draw(u,this.info),d&&this._nodes.updateAfter(u)):this._spNoteSkippedAsyncDraw()}},{key:"_spNoteSkippedAsyncDraw",value:function(){this._skippedAsyncDraws=(this._skippedAsyncDraws||0)+1,null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).incompleteRecord=!0)}},{key:"_createObjectPipeline",value:function(e,t,r,n,i,a,o,s){var u=this._objects.get(e,t,r,n,i,this._currentRenderContext,o,s,a);u.drawRange=e.geometry.drawRange,u.group=a;var l=this._compilation.request(u,s);null!==l&&null!==this._compilationPromises&&this._compilationPromises.push(new Promise(function(e){return l.onSettled(e)}))}},{key:"_onCanvasTargetResize",value:function(){this._initialized&&this.backend.updateSize()}},{key:"compile",get:function(){return this.compileAsync}}]),e}(),mZ=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";v(this,e),this.name=t,this.visibility=0}return y(e,[{key:"setVisibility",value:function(e){this.visibility|=e}},{key:"getVisibility",value:function(){return this.visibility}},{key:"clone",value:function(){return Object.assign(new this.constructor,this)}}]),e}();function mJ(e){return e+(16-e%16)%16}var m$=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e])).isBuffer=!0,r.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,r._buffer=n,r._updateRanges=[],r}return T(t,e),y(t,[{key:"updateRanges",get:function(){return this._updateRanges}},{key:"addUpdateRange",value:function(e,t){this.updateRanges.push({start:e,count:t})}},{key:"clearUpdateRanges",value:function(){this.updateRanges.length=0}},{key:"byteLength",get:function(){return mJ(this._buffer.byteLength)}},{key:"buffer",get:function(){return this._buffer}},{key:"update",value:function(){return!0}},{key:"release",value:function(){this._buffer=null}}]),t}(mZ),m0=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return v(this,t),(r=p(this,t,[e,n])).isUniformBuffer=!0,r}return T(t,e),t}(m$),m1=0,m2=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,["UniformBuffer_"+m1++,e?e.value:null])).nodeUniform=e,n.groupNode=r,n.isNodeUniformBuffer=!0,n}return T(t,e),y(t,[{key:"updateRanges",get:function(){return this.nodeUniform.updateRanges},set:function(e){this.nodeUniform.updateRanges=e}},{key:"addUpdateRange",value:function(e,t){this.nodeUniform.addUpdateRange(e,t)}},{key:"clearUpdateRanges",value:function(){this.nodeUniform.clearUpdateRanges()}},{key:"byteLength",get:function(){return mJ(this.buffer.byteLength)}},{key:"buffer",get:function(){return this.nodeUniform.value}}]),t}(m0),m3=function(e){function t(e){var r;return v(this,t),(r=p(this,t,[e])).isUniformsGroup=!0,r._values=null,r.uniforms=[],r._updateRangeCache=new Map,r._addedIndices=new Set,r}return T(t,e),y(t,[{key:"addUniformUpdateRange",value:function(e){var t=e.index;if(!this._addedIndices.has(t)){var r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}}},{key:"clearUpdateRanges",value:function(){this._addedIndices.clear(),x(_(t.prototype),"clearUpdateRanges",this).call(this)}},{key:"clone",value:function(){var e=x(_(t.prototype),"clone",this).call(this);return e._buffer=null,e._values=null,e._updateRanges=[],e._updateRangeCache=new Map,e._addedIndices=new Set,e}},{key:"addUniform",value:function(e){return this.uniforms.push(e),this}},{key:"removeUniform",value:function(e){var t=this.uniforms.indexOf(e);return -1!==t&&this.uniforms.splice(t,1),this}},{key:"values",get:function(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}},{key:"buffer",get:function(){var e=this._buffer;return null===e&&(e=new Float32Array(new ArrayBuffer(this.byteLength)),this._buffer=e),e}},{key:"byteLength",get:function(){for(var e=this.bytesPerElement,t=0,r=0,n=this.uniforms.length;r<n;r++){var i=this.uniforms[r],a=i.boundary,o=i.itemSize*e,s=t%16,u=s%a,l=s+u;t+=u,0!==l&&16-l<o&&(t+=16-l),i.offset=t/e,i.index=r,t+=o}return 16*Math.ceil(t/16)}},{key:"update",value:function(){var e=!1,t=!0,r=!1,n=void 0;try{for(var i,a=this.uniforms[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;!0===this.updateByType(o)&&(e=!0)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}return e}},{key:"release",value:function(){x(_(t.prototype),"release",this).call(this),this._values=null}},{key:"updateByType",value:function(e){return e.isNumberUniform?this.updateNumber(e):e.isVector2Uniform?this.updateVector2(e):e.isVector3Uniform?this.updateVector3(e):e.isVector4Uniform?this.updateVector4(e):e.isColorUniform?this.updateColor(e):e.isMatrix3Uniform?this.updateMatrix3(e):e.isMatrix4Uniform?this.updateMatrix4(e):void(0,c.xc)("WebGPUUniformsGroup: Unsupported uniform type.",e)}},{key:"updateNumber",value:function(e){var t=!1,r=this.values,n=e.getValue(),i=e.offset,a=e.getType();return r[i]!==n&&(this._getBufferForType(a)[i]=r[i]=n,t=!0,this.addUniformUpdateRange(e)),t}},{key:"updateVector2",value:function(e){var t=!1,r=this.values,n=e.getValue(),i=e.offset,a=e.getType();if(r[i+0]!==n.x||r[i+1]!==n.y){var o=this._getBufferForType(a);o[i+0]=r[i+0]=n.x,o[i+1]=r[i+1]=n.y,t=!0,this.addUniformUpdateRange(e)}return t}},{key:"updateVector3",value:function(e){var t=!1,r=this.values,n=e.getValue(),i=e.offset,a=e.getType();if(r[i+0]!==n.x||r[i+1]!==n.y||r[i+2]!==n.z){var o=this._getBufferForType(a);o[i+0]=r[i+0]=n.x,o[i+1]=r[i+1]=n.y,o[i+2]=r[i+2]=n.z,t=!0,this.addUniformUpdateRange(e)}return t}},{key:"updateVector4",value:function(e){var t=!1,r=this.values,n=e.getValue(),i=e.offset,a=e.getType();if(r[i+0]!==n.x||r[i+1]!==n.y||r[i+2]!==n.z||r[i+3]!==n.w){var o=this._getBufferForType(a);o[i+0]=r[i+0]=n.x,o[i+1]=r[i+1]=n.y,o[i+2]=r[i+2]=n.z,o[i+3]=r[i+3]=n.w,t=!0,this.addUniformUpdateRange(e)}return t}},{key:"updateColor",value:function(e){var t=!1,r=this.values,n=e.getValue(),i=e.offset;if(r[i+0]!==n.r||r[i+1]!==n.g||r[i+2]!==n.b){var a=this.buffer;a[i+0]=r[i+0]=n.r,a[i+1]=r[i+1]=n.g,a[i+2]=r[i+2]=n.b,t=!0,this.addUniformUpdateRange(e)}return t}},{key:"updateMatrix3",value:function(e){var t=!1,r=this.values,n=e.getValue().elements,i=e.offset;if(r[i+0]!==n[0]||r[i+1]!==n[1]||r[i+2]!==n[2]||r[i+4]!==n[3]||r[i+5]!==n[4]||r[i+6]!==n[5]||r[i+8]!==n[6]||r[i+9]!==n[7]||r[i+10]!==n[8]){var a=this.buffer;a[i+0]=r[i+0]=n[0],a[i+1]=r[i+1]=n[1],a[i+2]=r[i+2]=n[2],a[i+4]=r[i+4]=n[3],a[i+5]=r[i+5]=n[4],a[i+6]=r[i+6]=n[5],a[i+8]=r[i+8]=n[6],a[i+9]=r[i+9]=n[7],a[i+10]=r[i+10]=n[8],t=!0,this.addUniformUpdateRange(e)}return t}},{key:"updateMatrix4",value:function(e){var t=!1,r=this.values,n=e.getValue().elements,i=e.offset;return!1===function(e,t,r){for(var n=0,i=t.length;n<i;n++)if(e[r+n]!==t[n])return!1;return!0}(r,n,i)&&(this.buffer.set(n,i),function(e,t,r){for(var n=0,i=t.length;n<i;n++)e[r+n]=t[n]}(r,n,i),t=!0,this.addUniformUpdateRange(e)),t}},{key:"_getBufferForType",value:function(e){return"int"===e||"ivec2"===e||"ivec3"===e||"ivec4"===e?new Int32Array(this.buffer.buffer):"uint"===e||"uvec2"===e||"uvec3"===e||"uvec4"===e?new Uint32Array(this.buffer.buffer):this.buffer}}]),t}(m0),m4=0,m5=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e])).id=m4++,n.groupNode=r,n.isNodeUniformsGroup=!0,n}return T(t,e),t}(m3),m6=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e]))._texture=r,n.version=-1,n.generation=null,n.samplerKey="",n.isSampler=!0,n}return T(t,e),y(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this.reset())}},{key:"update",value:function(){var e=this.texture;return this.version!==e.version&&(this.version=e.version,!0)}},{key:"reset",value:function(){this.generation=null,this.version=-1}},{key:"release",value:function(){this._texture=null}}]),t}(mZ),m8=0,m9=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r])).id=m8++,n.store=!1,n.mipLevel=0,n.isSampledTexture=!0,n}return T(t,e),t}(m6),m7=null;function ye(){return null===m7&&((m7=new c.nd(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),m7}var yt,yr,yn,yi,ya,yo,ys=function(e){function t(e,r,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(i=p(this,t,[e,(r?r.value:null)||ye()])).textureNode=r,i.groupNode=n,i.access=a,i}return T(t,e),y(t,[{key:"update",value:function(){var e=this.textureNode.value;if(null==e){if(null!==this.texture&&void 0!==this.texture)return!1;e=ye()}return this.texture!==e?(this.texture=e,!0):x(_(t.prototype),"update",this).call(this)}}]),t}(m9),yu=function(e){function t(e,r,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(i=p(this,t,[e,r,n,a])).isSampledCubeTexture=!0,i}return T(t,e),t}(ys),yl=function(e){function t(e,r,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return v(this,t),(i=p(this,t,[e,r,n,a])).isSampledTexture3D=!0,i}return T(t,e),t}(ys),yc={bitcast_int_uint:new pi("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new pi("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }"),textureGather:new pi("\nvec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {\n if ( flipY ) offset.y = - offset.y;\n vec2 size = vec2( textureSize( map, 0 ) );\n vec2 st = floor( coord * size + vec2( offset ) - 0.5 );\n vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n vec4 ret = vec4(\n textureLod( map, ij.xw, 0.0 )[ comp ],\n textureLod( map, ij.zw, 0.0 )[ comp ],\n textureLod( map, ij.zy, 0.0 )[ comp ],\n textureLod( map, ij.xy, 0.0 )[ comp ]\n );\n return flipY ? ret.wzyx : ret;\n}\n"),textureGatherArray:new pi("\nvec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {\n if ( flipY ) offset.y = - offset.y;\n vec2 size = vec2( textureSize( map, 0 ).xy );\n vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );\n vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n vec4 ret = vec4(\n textureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ],\n textureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ],\n textureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ],\n textureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ]\n );\n return flipY ? ret.wzyx : ret;\n}\n"),textureGatherCompare:new pi("\nvec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {\n if ( flipY ) offset.y = - offset.y;\n vec2 size = vec2( textureSize( map, 0 ) );\n vec2 st = floor( coord * size + vec2( offset ) - 0.5 );\n vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n vec4 ret = vec4(\n textureLod( map, vec3( ij.xw, ref ), 0.0 ),\n textureLod( map, vec3( ij.zw, ref ), 0.0 ),\n textureLod( map, vec3( ij.zy, ref ), 0.0 ),\n textureLod( map, vec3( ij.xy, ref ), 0.0 )\n );\n return flipY ? ret.wzyx : ret;\n}\n"),textureGatherCompareArray:new pi("\nvec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {\n if ( flipY ) offset.y = - offset.y;\n vec2 size = vec2( textureSize( map, 0 ).xy );\n vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );\n vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n vec4 ret = vec4(\n texture( map, vec4( ij.xw, coord.z, ref ) ),\n texture( map, vec4( ij.zw, coord.z, ref ) ),\n texture( map, vec4( ij.zy, coord.z, ref ) ),\n texture( map, vec4( ij.xy, coord.z, ref ) )\n );\n return flipY ? ret.wzyx : ret;\n}\n")},yd={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},yh={low:"lowp",medium:"mediump",high:"highp"},yf={swizzleAssign:!0,storageBuffer:!1},yp={perspective:"smooth",linear:"noperspective"},yv={centroid:"centroid"},yg="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\nprecision highp sampler3D;\nprecision highp samplerCube;\nprecision highp sampler2DArray;\n\nprecision highp usampler2D;\nprecision highp usampler3D;\nprecision highp usamplerCube;\nprecision highp usampler2DArray;\n\nprecision highp isampler2D;\nprecision highp isampler3D;\nprecision highp isamplerCube;\nprecision highp isampler2DArray;\n\nprecision highp sampler2DShadow;\nprecision highp sampler2DArrayShadow;\nprecision highp samplerCubeShadow;\n",ym=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r,new mA])).uniformGroups={},n.transforms=[],n.extensions={},n.builtins={vertex:[],fragment:[],compute:[]},n}return T(t,e),y(t,[{key:"needsToWorkingColorSpace",value:function(e){return!0===e.isVideoTexture&&e.colorSpace!==c.Hb}},{key:"_include",value:function(e){var t=yc[e];return t.build(this),this.addInclude(t),t}},{key:"getMethod",value:function(e){return void 0!==yc[e]&&this._include(e),yd[e]||e}},{key:"getBitcastMethod",value:function(e,t){return this.getMethod("bitcast_".concat(t,"_").concat(e))}},{key:"getFloatPackingMethod",value:function(e){return this.getMethod("floatpack_".concat(e,"_2x16"))}},{key:"getFloatUnpackingMethod",value:function(e){return this.getMethod("floatunpack_".concat(e,"_2x16"))}},{key:"getTernary",value:function(e,t,r){return"".concat(e," ? ").concat(t," : ").concat(r)}},{key:"getOutputStructName",value:function(){return""}},{key:"buildFunctionCode",value:function(e){var t=e.layout,r=this.flowShaderNode(e),n=[],i=!0,a=!1,o=void 0;try{for(var s,u=t.inputs[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n.push(this.getType(l.type)+" "+l.name)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return"".concat(this.getType(t.type)," ").concat(t.name,"( ").concat(n.join(", ")," ) {\n\n ").concat(r.vars,"\n\n").concat(r.code,"\n return ").concat(r.result,";\n\n}")}},{key:"setupPBO",value:function(e){var t=e.value;if(void 0===t.pbo){var r=t.array,n=t.count*t.itemSize,i=t.itemSize,a=t.array.constructor.name.toLowerCase().includes("int"),o=a?c.Na:c.Ma;2===i?o=a?c.Pa:c.Oa:3===i?o=a?c.Qa:c.Ia:4===i&&(o=a?c.Ra:c.Ja);var s={Float32Array:c.Aa,Uint8Array:c.ua,Uint16Array:c.xa,Uint32Array:c.za,Int8Array:c.va,Int16Array:c.wa,Int32Array:c.ya,Uint8ClampedArray:c.ua},u=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(n/i)))),l=Math.ceil(n/i/u);u*l*i<n&&l++;var d=u*l*i,h=new r.constructor(d);h.set(r,0),t.array=h;var f=new c.nd(t.array,u,l,o,s[t.array.constructor.name]||c.Aa);f.needsUpdate=!0,f.isPBOTexture=!0;var p=new a_(f,null,null);p.setPrecision("high"),t.pboNode=p,t.pbo=p.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}},{key:"getPropertyName",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage;return e.isNodeUniform&&!0!==e.node.isTextureNode&&!0!==e.node.isBufferNode?e.name:x(_(t.prototype),"getPropertyName",this).call(this,e,r)}},{key:"generatePBO",value:function(e){var t=e.node,r=e.indexNode,n=t.value;this.renderer.backend.has(n)&&(this.renderer.backend.get(n).pbo=n.pbo);var i=this.getUniformFromNode(n.pboNode,"texture",this.shaderStage,this.context.nodeName),a=this.getPropertyName(i);this.increaseUsage(r);var o=r.build(this,"uint"),s=this.getDataFromNode(e),u=s.propertyName;if(void 0===u){var l=this.getVarFromNode(e);u=this.getPropertyName(l);var d=this.getDataFromNode(t),h=d.propertySizeName;void 0===h&&(h=u+"Size",this.getVarFromNode(t,h,"uint"),this.addLineFlowCode("".concat(h," = uint( textureSize( ").concat(a,", 0 ).x )"),e),d.propertySizeName=h);var f=n.itemSize,p="."+eo.join("").slice(0,f),v="ivec2(".concat(o," % ").concat(h,", ").concat(o," / ").concat(h,")"),g=this.generateTextureLoad(null,a,v,"0",null,null),m="vec4";n.pbo.type===c.za?m="uvec4":n.pbo.type===c.ya&&(m="ivec4"),this.addLineFlowCode("".concat(u," = ").concat(m,"(").concat(g,")").concat(p),e),s.propertyName=u}return u}},{key:"generateTextureLoad",value:function(e,t,r,n,i,a){var o;return null===n&&(n="0"),o=i?a?"texelFetchOffset( ".concat(t,", ivec3( ").concat(r,", ").concat(i," ), int( ").concat(n," ), ").concat(a," )"):"texelFetch( ".concat(t,", ivec3( ").concat(r,", ").concat(i," ), int( ").concat(n," ) )"):a?"texelFetchOffset( ".concat(t,", ").concat(r,", int( ").concat(n," ), ").concat(a," )"):"texelFetch( ".concat(t,", ").concat(r,", int( ").concat(n," ) )"),null!==e&&e.isDepthTexture&&(o+=".x"),o}},{key:"generateTexture",value:function(e,t,r,n,i){return n&&(r="vec3( ".concat(r,", ").concat(n," )")),e.isDepthTexture?i?"textureOffset( ".concat(t,", ").concat(r,", ").concat(i," ).x"):"texture( ".concat(t,", ").concat(r," ).x"):i?"textureOffset( ".concat(t,", ").concat(r,", ").concat(i," )"):"texture( ".concat(t,", ").concat(r," )")}},{key:"generateTextureLevel",value:function(e,t,r,n,i,a){return i&&(r="vec3( ".concat(r,", ").concat(i," )")),a?"textureLodOffset( ".concat(t,", ").concat(r,", ").concat(n,", ").concat(a," )"):"textureLod( ".concat(t,", ").concat(r,", ").concat(n," )")}},{key:"generateTextureBias",value:function(e,t,r,n,i,a){return i&&(r="vec3( ".concat(r,", ").concat(i," )")),a?"textureOffset( ".concat(t,", ").concat(r,", ").concat(a,", ").concat(n," )"):"texture( ".concat(t,", ").concat(r,", ").concat(n," )")}},{key:"generateTextureGrad",value:function(e,t,r,n,i,a){return i&&(r="vec3( ".concat(r,", ").concat(i," )")),a?"textureGradOffset( ".concat(t,", ").concat(r,", ").concat(n[0],", ").concat(n[1],", ").concat(a," )"):"textureGrad( ".concat(t,", ").concat(r,", ").concat(n[0],", ").concat(n[1]," )")}},{key:"generateTextureCompare",value:function(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.shaderStage;if("fragment"===o)return e.isCubeTexture?"texture( ".concat(t,", vec4( ").concat(r,", ").concat(n," ) )"):i?a?"textureOffset( ".concat(t,", vec4( ").concat(r,", ").concat(i,", ").concat(n," ), ").concat(a," )"):"texture( ".concat(t,", vec4( ").concat(r,", ").concat(i,", ").concat(n," ) )"):a?"textureOffset( ".concat(t,", vec3( ").concat(r,", ").concat(n," ), ").concat(a," )"):"texture( ".concat(t,", vec3( ").concat(r,", ").concat(n," ) )");(0,c.xc)("WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ".concat(o," shader."))}},{key:"generateTextureGather",value:function(e,t,r,n,i,a,o){return e.isDepthTexture&&(n="0"),null===a&&(a="ivec2( 0 )"),null===o&&(o="false"),i?(this._include("textureGatherArray"),"tsl_textureGather_array( ".concat(n,", ").concat(t,", vec3( ").concat(r,", ").concat(i," ), ").concat(a,", ").concat(o," )")):(this._include("textureGather"),"tsl_textureGather( ".concat(n,", ").concat(t,", ").concat(r,", ").concat(a,", ").concat(o," )"))}},{key:"generateTextureGatherCompare",value:function(e,t,r,n,i,a,o){return null===a&&(a="ivec2( 0 )"),null===o&&(o="false"),i?(this._include("textureGatherCompareArray"),"tsl_textureGatherCompare_array( ".concat(t,", vec3( ").concat(r,", ").concat(i," ), ").concat(a,", ").concat(n,", ").concat(o," )")):(this._include("textureGatherCompare"),"tsl_textureGatherCompare( ".concat(t,", ").concat(r,", ").concat(a,", ").concat(n,", ").concat(o," )"))}},{key:"getUniforms",value:function(e){var t=this.uniforms[e],r=[],n={},i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,d=null,h=!1;if("texture"===l.type||"texture3D"===l.type){var f=l.node,p=f.value,v="";(!0===p.isDataTexture||!0===p.isData3DTexture)&&(p.type===c.za?v="u":p.type===c.ya&&(v="i")),d="texture3D"===l.type&&!1===p.isArrayTexture?"".concat(v,"sampler3D ").concat(l.name,";"):p.compareFunction&&null!==f.compareNode?!0===p.isArrayTexture?"sampler2DArrayShadow ".concat(l.name,";"):"sampler2DShadow ".concat(l.name,";"):!0===p.isArrayTexture||!0===p.isDataArrayTexture||!0===p.isCompressedArrayTexture?"".concat(v,"sampler2DArray ").concat(l.name,";"):"".concat(v,"sampler2D ").concat(l.name,";")}else if("cubeTexture"===l.type)d="samplerCube ".concat(l.name,";");else if("cubeDepthTexture"===l.type)d=l.node.value.compareFunction?"samplerCubeShadow ".concat(l.name,";"):"samplerCube ".concat(l.name,";");else if("buffer"===l.type){var g=l.node,m=this.getType(g.bufferType),y=g.bufferCount,b=y>0?y:"";d="".concat(g.name," {\n ").concat(m," ").concat(l.name,"[").concat(b,"];\n};\n")}else{var x=l.groupNode.name;if(void 0===n[x]){var _=this.uniformGroups[x];if(void 0!==_){var T=[],S=!0,N=!1,k=void 0;try{for(var w,A=_.uniforms[Symbol.iterator]();!(S=(w=A.next()).done);S=!0){var E=w.value,R=E.getType(),C=this.getVectorType(R),M=E.nodeUniform.node.precision,F="".concat(C," ").concat(E.name,";");null!==M&&(F=yh[M]+" "+F),T.push(" "+F)}}catch(e){N=!0,k=e}finally{try{S||null==A.return||A.return()}finally{if(N)throw k}}n[x]=T}}h=!0}if(!h){var B=l.node.precision;null!==B&&(d=yh[B]+" "+d),d="uniform "+d,r.push(d)}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}var P="";for(var L in n){var D=n[L];P+=this._getGLSLUniformStruct(L,D.join("\n"))+"\n"}return P+r.join("\n")}},{key:"getTypeFromAttribute",value:function(e){var r=x(_(t.prototype),"getTypeFromAttribute",this).call(this,e);if(/^[iu]/.test(r)&&e.gpuType!==c.ya){var n=e;e.isInterleavedBufferAttribute&&(n=e.data);var i=n.array;S(i,Uint32Array)||S(i,Int32Array)||(r=r.slice(1))}return r}},{key:"getAttributes",value:function(e){var t="";if("vertex"===e||"compute"===e){var r=this.getAttributesArray(),n=0,i=!0,a=!1,o=void 0;try{for(var s,u=r[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;t+="layout( location = ".concat(n++," ) in ").concat(l.type," ").concat(l.name,";\n")}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}return t}},{key:"getStructMembers",value:function(e){var t=[],r=!0,n=!1,i=void 0;try{for(var a,o=e.members[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value;t.push(" ".concat(s.type," ").concat(s.name,";"))}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t.join("\n")}},{key:"getStructs",value:function(e){var t=[],r=this.structs[e],n=[],i=!0,a=!1,o=void 0,s=!0,u=!1,l=void 0;try{for(var c,d=r[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value;if(h.output)try{for(var f,p=h.members[Symbol.iterator]();!(i=(f=p.next()).done);i=!0){var v=f.value;n.push("layout( location = ".concat(v.index," ) out ").concat(v.type," ").concat(v.name,";"))}}catch(e){a=!0,o=e}finally{try{i||null==p.return||p.return()}finally{if(a)throw o}}else{var g="struct "+h.name+" {\n";g+=this.getStructMembers(h),g+="\n};\n",t.push(g)}}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}return"fragment"===e&&0===n.length&&n.push("layout( location = 0 ) out ".concat(this.getOutputType()," fragColor;")),"\n"+n.join("\n")+"\n\n"+t.join("\n")}},{key:"getVaryings",value:function(e){var t="",r=this.varyings,n=!0,i=!1,a=void 0;if("vertex"===e||"compute"===e)try{for(var o,s=r[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;"compute"===e&&(u.needsInterpolation=!0);var l=this.getType(u.type);u.needsInterpolation?u.interpolationType?t+="".concat(yp[u.interpolationType]||u.interpolationType," ").concat(yv[u.interpolationSampling]||""," out ").concat(l," ").concat(u.name,";\n"):t+="".concat(l.includes("int")||l.includes("uv")||l.includes("iv")?"flat ":"","out ").concat(l," ").concat(u.name,";\n"):t+="".concat(l," ").concat(u.name,";\n")}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}else if("fragment"===e){var c=!0,d=!1,h=void 0;try{for(var f,p=r[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var v=f.value;if(v.needsInterpolation){var g=this.getType(v.type);v.interpolationType?t+="".concat(yp[v.interpolationType]||v.interpolationType," ").concat(yv[v.interpolationSampling]||""," in ").concat(g," ").concat(v.name,";\n"):t+="".concat(g.includes("int")||g.includes("uv")||g.includes("iv")?"flat ":"","in ").concat(g," ").concat(v.name,";\n")}}}catch(e){d=!0,h=e}finally{try{c||null==p.return||p.return()}finally{if(d)throw h}}}var m=!0,y=!1,b=void 0;try{for(var x,_=this.builtins[e][Symbol.iterator]();!(m=(x=_.next()).done);m=!0){var T=x.value;t+="".concat(T,";\n")}}catch(e){y=!0,b=e}finally{try{m||null==_.return||_.return()}finally{if(y)throw b}}return t}},{key:"getVertexIndex",value:function(){return"uint( gl_VertexID )"}},{key:"getInstanceIndex",value:function(){return"uint( gl_InstanceID )"}},{key:"getInvocationLocalIndex",value:function(){return"uint( gl_InstanceID ) % ".concat(this.object.workgroupSize.reduce(function(e,t){return e*t},1),"u")}},{key:"getSubgroupSize",value:function(){(0,c.xc)("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}},{key:"getInvocationSubgroupIndex",value:function(){(0,c.xc)("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}},{key:"getSubgroupIndex",value:function(){(0,c.xc)("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}},{key:"getDrawIndex",value:function(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}},{key:"getFrontFacing",value:function(){return"gl_FrontFacing"}},{key:"getFragCoord",value:function(){return"gl_FragCoord.xy"}},{key:"getFragDepth",value:function(){return"gl_FragDepth"}},{key:"enableExtension",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.shaderStage,n=this.extensions[r]||(this.extensions[r]=new Map);!1===n.has(e)&&n.set(e,{name:e,behavior:t})}},{key:"getExtensions",value:function(e){var t=[];if("vertex"===e){var r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}var n=this.extensions[e],i=!0,a=!1,o=void 0;if(void 0!==n)try{for(var s,u=n.values()[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,c=l.name,d=l.behavior;t.push("#extension ".concat(c," : ").concat(d))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return t.join("\n")}},{key:"getClipDistance",value:function(){return"gl_ClipDistance"}},{key:"isAvailable",value:function(e){var t,r=yf[e];if(void 0===r){switch(r=!1,e){case"float32Filterable":t="OES_texture_float_linear";break;case"clipDistance":t="WEBGL_clip_cull_distance"}if(void 0!==t){var n=this.renderer.backend.extensions;n.has(t)&&(n.get(t),r=!0)}yf[e]=r}return r}},{key:"isFlipY",value:function(){return!0}},{key:"enableHardwareClipping",value:function(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push("out float gl_ClipDistance[ ".concat(e," ]"))}},{key:"enableMultiview",value:function(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}},{key:"registerTransform",value:function(e,t){this.transforms.push({varyingName:e,attributeNode:t})}},{key:"getTransforms",value:function(){for(var e=this.transforms,t="",r=0;r<e.length;r++){var n=e[r],i=this.getPropertyName(n.attributeNode);i&&(t+="".concat(n.varyingName," = ").concat(i,";\n "))}return t}},{key:"_getGLSLUniformStruct",value:function(e,t){return"\nlayout( std140 ) uniform ".concat(e," {\n").concat(t,"\n};")}},{key:"_getGLSLVertexCode",value:function(e){return"#version 300 es\n\n".concat(this.getSignature(),"\n\n// extensions\n").concat(e.extensions,"\n\n// precision\n").concat(yg,"\n\n// structs\n").concat(e.structs,"\n\n// uniforms\n").concat(e.uniforms,"\n\n// varyings\n").concat(e.varyings,"\n\n// attributes\n").concat(e.attributes,"\n\n// vars\n").concat(e.vars,"\n\n// codes\n").concat(e.codes,"\n\nvoid main() {\n\n // transforms\n ").concat(e.transforms,"\n\n // flow\n ").concat(e.flow,"\n\n gl_PointSize = 1.0;\n\n}\n")}},{key:"_getGLSLFragmentCode",value:function(e){return"#version 300 es\n\n".concat(this.getSignature(),"\n\n// extensions\n").concat(e.extensions,"\n\n// precision\n").concat(yg,"\n\n// structs\n").concat(e.structs,"\n\n// uniforms\n").concat(e.uniforms,"\n\n// varyings\n").concat(e.varyings,"\n\n// vars\n").concat(e.vars,"\n\n// codes\n").concat(e.codes,"\n\nvoid main() {\n\n // flow\n ").concat(e.flow,"\n\n}\n")}},{key:"buildCode",value:function(){var e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(var t in this.sortBindingGroups(),e){var r="// code\n\n";r+=this.flowCode[t];var n=this.flowNodes[t],i=n[n.length-1],a=!0,o=!1,s=void 0;try{for(var u,l=n[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value,d=this.getFlowData(c),h=c.name;h&&(r.length>0&&(r+="\n"),r+=" // flow -> ".concat(h,"\n ")),r+="".concat(d.code,"\n "),c===i&&"compute"!==t&&(r+="// result\n ","vertex"===t?(r+="gl_Position = ",r+="".concat(this.format(d.result,i.getNodeType(this),"vec4"),";")):"fragment"===t&&(c.outputNode.isOutputStructNode||(r+="fragColor = ",r+="".concat(this.format(d.result,i.getNodeType(this),this.getOutputType()),";"))))}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}var f=e[t];if(f.extensions=this.getExtensions(t),f.uniforms=this.getUniforms(t),f.attributes=this.getAttributes(t),f.varyings=this.getVaryings(t),f.vars=this.getVars(t,!0),f.structs=this.getStructs(t),f.codes=this.getCodes(t),f.transforms=this.getTransforms(t),f.flow=r,"vertex"===t){var p=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===p.has("WEBGL_multi_draw")&&(f.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}},{key:"getUniformFromNode",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=x(_(t.prototype),"getUniformFromNode",this).call(this,e,r,n,i),o=this.getDataFromNode(e,n,this.globalCache),s=o.uniformGPU;if(void 0===s){var u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,n);if("texture"===r)s=new ys(a.name,a.node,u),c.push(s);else if("cubeTexture"===r||"cubeDepthTexture"===r)s=new yu(a.name,a.node,u),c.push(s);else if("texture3D"===r)s=new yl(a.name,a.node,u),c.push(s);else if("buffer"===r){a.name="buffer".concat(e.id);var d=this.getSharedDataFromNode(e),h=d.buffer;void 0===h&&(e.name="NodeBuffer_".concat(e.id),(h=new m2(e,u)).name=e.name,d.buffer=h),c.push(h),s=h}else{var f=this.uniformGroups[l];void 0===f?(f=new m5(l,u),this.uniformGroups[l]=f,c.push(f)):-1===c.indexOf(f)&&c.push(f);var p=(s=this.getNodeUniform(a,r)).name;f.uniforms.some(function(e){return e.name===p})||f.addUniform(s)}o.uniformGPU=s}return a}}]),t}(ms),yy=null,yb=null,yx=function(){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,e),this.parameters=Object.assign({},r),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool=(b(t={},c.qc.RENDER,null),b(t,c.qc.COMPUTE,null),t),this.trackTimestamp=!0===r.trackTimestamp}return y(e,[{key:"init",value:function(e){return f(function(){return P(this,function(t){return this.renderer=e,[2]})}).call(this)}},{key:"coordinateSystem",get:function(){}},{key:"beginRender",value:function(){}},{key:"finishRender",value:function(){}},{key:"setXRTarget",value:function(){}},{key:"beginCompute",value:function(){}},{key:"finishCompute",value:function(){}},{key:"draw",value:function(){}},{key:"compute",value:function(){}},{key:"createProgram",value:function(){}},{key:"destroyProgram",value:function(){}},{key:"createBindings",value:function(){}},{key:"updateBindings",value:function(){}},{key:"updateBinding",value:function(){}},{key:"createRenderPipeline",value:function(){}},{key:"createComputePipeline",value:function(){}},{key:"needsRenderUpdate",value:function(){}},{key:"syncRenderUpdateState",value:function(){}},{key:"detectStructuralChange",value:function(){return!1}},{key:"getAttachmentStateKey",value:function(){return""}},{key:"detectAttachmentMismatch",value:function(e){var t=this.get(e).compiledAttachmentKey;return void 0!==t&&t!==this.getAttachmentStateKey(e)}},{key:"getRenderCacheKey",value:function(){}},{key:"createNodeBuilder",value:function(){}},{key:"updateSampler",value:function(){}},{key:"destroySampler",value:function(){}},{key:"createDefaultTexture",value:function(){}},{key:"createTexture",value:function(){}},{key:"updateTexture",value:function(){}},{key:"generateMipmaps",value:function(){}},{key:"destroyTexture",value:function(){}},{key:"copyTextureToBuffer",value:function(){return f(function(){return P(this,function(e){return[2]})})()}},{key:"copyTextureToTexture",value:function(){}},{key:"copyFramebufferToTexture",value:function(){}},{key:"createAttribute",value:function(){}},{key:"createIndexAttribute",value:function(){}},{key:"createStorageAttribute",value:function(){}},{key:"createUniformBuffer",value:function(){}},{key:"destroyUniformBuffer",value:function(){}},{key:"updateAttribute",value:function(){}},{key:"destroyAttribute",value:function(){}},{key:"getContext",value:function(){}},{key:"updateSize",value:function(){}},{key:"updateViewport",value:function(){}},{key:"updateTimeStampUID",value:function(e){var t=this.get(e),r=this.renderer.info.frame;t.timestampUID=(!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls)+":"+e.id+":f"+r}},{key:"getTimestampUID",value:function(e){return this.get(e).timestampUID}},{key:"getTimestampFrames",value:function(e){var t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}},{key:"_getQueryPool",value:function(e){var t=e.startsWith("c:")?c.qc.COMPUTE:c.qc.RENDER;return this.timestampQueryPool[t]}},{key:"getTimestamp",value:function(e){return this._getQueryPool(e).getTimestamp(e)}},{key:"hasTimestamp",get:function(){return!1}},{key:"hasTimestampQuery",value:function(e){return this._getQueryPool(e).hasTimestampQuery(e)}},{key:"isOccluded",value:function(){}},{key:"resolveTimestampsAsync",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render";return f(function(){var t,r;return P(this,function(n){switch(n.label){case 0:if(!this.trackTimestamp)return[2,void(0,c.yc)("WebGPURenderer: Timestamp tracking is disabled.")];if(!(t=this.timestampQueryPool[e]))return[2];return[4,t.resolveQueriesAsync()];case 1:return r=n.sent(),[2,(this.renderer.info[e].timestamp=r,r)]}})}).call(this)}},{key:"getArrayBufferAsync",value:function(){return f(function(){return P(this,function(e){return[2]})})()}},{key:"hasFeatureAsync",value:function(){return f(function(){return P(this,function(e){return[2]})})()}},{key:"hasFeature",value:function(){}},{key:"getDrawingBufferSize",value:function(){return yy=yy||new c.Dc,this.renderer.getDrawingBufferSize(yy)}},{key:"setScissorTest",value:function(){}},{key:"getClearColor",value:function(){var e=this.renderer;return yb=yb||new hd,e.getClearColor(yb),yb.getRGB(yb),yb}},{key:"getDomElement",value:function(){var e=this.domElement;return null===e&&("setAttribute"in(e=void 0!==this.parameters.canvas?this.parameters.canvas:(0,c.uc)())&&e.setAttribute("data-engine","three.js r".concat(c.a," webgpu")),this.domElement=e),e}},{key:"hasCompatibility",value:function(){return!1}},{key:"initRenderTarget",value:function(){}},{key:"set",value:function(e,t){this.data.set(e,t)}},{key:"get",value:function(e){var t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}},{key:"has",value:function(e){return this.data.has(e)}},{key:"delete",value:function(e){this.data.delete(e)}},{key:"deleteBindGroupData",value:function(){}},{key:"dispose",value:function(){}}]),e}(),y_=0,yT=function(){function e(t,r){v(this,e),this.buffers=[t.bufferGPU,r],this.type=t.type,this.bufferType=t.bufferType,this.pbo=t.pbo,this.byteLength=t.byteLength,this.bytesPerElement=t.BYTES_PER_ELEMENT,this.version=t.version,this.isInteger=t.isInteger,this.activeBufferIndex=0,this.baseId=t.id}return y(e,[{key:"id",get:function(){return"".concat(this.baseId,"|").concat(this.activeBufferIndex)}},{key:"bufferGPU",get:function(){return this.buffers[this.activeBufferIndex]}},{key:"transformBuffer",get:function(){return this.buffers[1^this.activeBufferIndex]}},{key:"switchBuffers",value:function(){this.activeBufferIndex^=1}}]),e}(),yS=function(){function e(t){v(this,e),this.backend=t}return y(e,[{key:"createAttribute",value:function(e,t){var r,n=this.backend,i=n.gl,a=e.array,o=e.usage||i.STATIC_DRAW,s=e.isInterleavedBufferAttribute?e.data:e,u=n.get(s),l=u.bufferGPU;if(void 0===l&&(u.bufferGPU=l=this._createBuffer(i,t,a,o),u.bufferType=t,u.version=s.version),S(a,Float32Array))r=i.FLOAT;else if(("u"<typeof Float16Array?"undefined":C(Float16Array))<"u"&&S(a,Float16Array))r=i.HALF_FLOAT;else if(S(a,Uint16Array))r=e.isFloat16BufferAttribute?i.HALF_FLOAT:i.UNSIGNED_SHORT;else if(S(a,Int16Array))r=i.SHORT;else if(S(a,Uint32Array))r=i.UNSIGNED_INT;else if(S(a,Int32Array))r=i.INT;else if(S(a,Int8Array))r=i.BYTE;else if(S(a,Uint8Array))r=i.UNSIGNED_BYTE;else{if(!S(a,Uint8ClampedArray))throw Error("THREE.WebGLBackend: Unsupported buffer data format: "+a);r=i.UNSIGNED_BYTE}var d={bufferGPU:l,bufferType:t,type:r,byteLength:a.byteLength,bytesPerElement:a.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:r===i.INT||r===i.UNSIGNED_INT||e.gpuType===c.ya,id:y_++};(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(d=new yT(d,this._createBuffer(i,t,a,o))),n.set(e,d)}},{key:"updateAttribute",value:function(e){var t=this.backend,r=t.gl,n=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(o,a.bufferGPU),0===s.length)r.bufferSubData(o,0,n);else{for(var u=0,l=s.length;u<l;u++){var c=s[u];r.bufferSubData(o,c.start*n.BYTES_PER_ELEMENT,n,c.start,c.count)}i.clearUpdateRanges()}r.bindBuffer(o,null),a.version=i.version}},{key:"destroyAttribute",value:function(e){var t=this.backend,r=t.gl;e.isInterleavedBufferAttribute&&t.delete(e.data);var n=t.get(e);r.deleteBuffer(n.bufferGPU),t.delete(e)}},{key:"getArrayBufferAsync",value:function(e){return f(function(e){var t,r,n,i,a,o,s,u,l,c,d,h=arguments;return P(this,function(f){if(t=h.length>1&&void 0!==h[1]?h[1]:null,r=h.length>2&&void 0!==h[2]?h[2]:0,n=h.length>3&&void 0!==h[3]?h[3]:-1,o=(a=this.backend).gl,s=e.isInterleavedBufferAttribute?e.data:e,l=(u=a.get(s)).bufferGPU,c=-1===n?u.byteLength-r:n,null===t)i=new Uint8Array(new ArrayBuffer(c));else if(t.isReadbackBuffer){if(!0===t._mapped)throw Error("THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.");d=function(){t.buffer=null,t._mapped=!1,t.removeEventListener("release",d),t.removeEventListener("dispose",d)},t.addEventListener("release",d),t.addEventListener("dispose",d),t.buffer=(i=new Uint8Array(new ArrayBuffer(c))).buffer}else i=new Uint8Array(t);return[2,(o.bindBuffer(o.COPY_READ_BUFFER,l),o.getBufferSubData(o.COPY_READ_BUFFER,r,i),o.bindBuffer(o.COPY_READ_BUFFER,null),o.bindBuffer(o.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:i.buffer)]})}).apply(this,arguments)}},{key:"_createBuffer",value:function(e,t,r,n){var i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,r,n),e.bindBuffer(t,null),i}}]),e}(),yN=function(){function e(t){v(this,e),this.backend=t,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}return y(e,[{key:"_init",value:function(){var e,t,r=this.gl;b(e={},c.t,r.FUNC_ADD),b(e,c.u,r.FUNC_SUBTRACT),b(e,c.v,r.FUNC_REVERSE_SUBTRACT),yr=e,b(t={},c.y,r.ZERO),b(t,c.z,r.ONE),b(t,c.A,r.SRC_COLOR),b(t,c.C,r.SRC_ALPHA),b(t,c.I,r.SRC_ALPHA_SATURATE),b(t,c.G,r.DST_COLOR),b(t,c.E,r.DST_ALPHA),b(t,c.B,r.ONE_MINUS_SRC_COLOR),b(t,c.D,r.ONE_MINUS_SRC_ALPHA),b(t,c.H,r.ONE_MINUS_DST_COLOR),b(t,c.F,r.ONE_MINUS_DST_ALPHA),yn=t;var n=r.getParameter(r.SCISSOR_BOX),i=r.getParameter(r.VIEWPORT);this.currentScissor=(new c.Jc).fromArray(n),this.currentViewport=(new c.Jc).fromArray(i),this._tempVec4=new c.Jc}},{key:"enable",value:function(e){var t=this.enabled;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}},{key:"disable",value:function(e){var t=this.enabled;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}},{key:"setFlipSided",value:function(e){if(this.currentFlipSided!==e){var t=this.gl;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}},{key:"setCullFace",value:function(e){var t=this.gl;e!==c.c?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===c.d?t.cullFace(t.BACK):e===c.e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}},{key:"setLineWidth",value:function(e){var t=this.currentLineWidth,r=this.gl;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}},{key:"setMRTBlending",value:function(e,t,r){var n=this.gl,i=this.backend.drawBuffersIndexedExt;if(i)for(var a=0;a<e.length;a++){var o=e[a],s=null;if(null!==t){var u=t.getBlendMode(o.name);u.blending===c.s?s=r:u.blending!==c.m&&(s=u)}else s=r;null!==s?this._setMRTBlendingIndex(a,s):i.blendFuncSeparateiOES(a,n.ONE,n.ZERO,n.ONE,n.ZERO)}else(0,c.yc)("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.")}},{key:"_setMRTBlendingIndex",value:function(e,t){var r=this.gl,n=this.backend.drawBuffersIndexedExt,i=t.blending,a=t.blendSrc,o=t.blendDst,s=t.blendEquation,u=t.premultipliedAlpha;if(i===c.r){var l=null!==t.blendSrcAlpha?t.blendSrcAlpha:a,d=null!==t.blendDstAlpha?t.blendDstAlpha:o,h=null!==t.blendEquationAlpha?t.blendEquationAlpha:s;n.blendEquationSeparateiOES(e,yr[s],yr[h]),n.blendFuncSeparateiOES(e,yn[a],yn[o],yn[l],yn[d])}else if(n.blendEquationSeparateiOES(e,r.FUNC_ADD,r.FUNC_ADD),u)switch(i){case c.n:n.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case c.o:n.blendFuncSeparateiOES(e,r.ONE,r.ONE,r.ONE,r.ONE);break;case c.p:n.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case c.q:n.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:n.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}else switch(i){case c.n:n.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case c.o:n.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case c.p:n.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case c.q:n.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:n.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}}},{key:"setBlending",value:function(e,t,r,n,i,a,o,s){var u=this.gl;if(e!==c.m){if(!1===this.currentBlendingEnabled&&(this.enable(u.BLEND),this.currentBlendingEnabled=!0),e===c.r)i=i||t,a=a||r,o=o||n,(t!==this.currentBlendEquation||i!==this.currentBlendEquationAlpha)&&(u.blendEquationSeparate(yr[t],yr[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(r!==this.currentBlendSrc||n!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(u.blendFuncSeparate(yn[r],yn[n],yn[a],yn[o]),this.currentBlendSrc=r,this.currentBlendDst=n,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=o),this.currentBlending=e,this.currentPremultipledAlpha=!1;else if(e!==this.currentBlending||s!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==c.t||this.currentBlendEquationAlpha!==c.t)&&(u.blendEquation(u.FUNC_ADD),this.currentBlendEquation=c.t,this.currentBlendEquationAlpha=c.t),s)switch(e){case c.n:u.blendFuncSeparate(u.ONE,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA);break;case c.o:u.blendFunc(u.ONE,u.ONE);break;case c.p:u.blendFuncSeparate(u.ZERO,u.ONE_MINUS_SRC_COLOR,u.ZERO,u.ONE);break;case c.q:u.blendFuncSeparate(u.DST_COLOR,u.ONE_MINUS_SRC_ALPHA,u.ZERO,u.ONE);break;default:(0,c.xc)("WebGLState: Invalid blending: ",e)}else switch(e){case c.n:u.blendFuncSeparate(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA);break;case c.o:u.blendFuncSeparate(u.SRC_ALPHA,u.ONE,u.ONE,u.ONE);break;case c.p:(0,c.xc)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case c.q:(0,c.xc)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,c.xc)("WebGLState: Invalid blending: ",e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=s}}else!0===this.currentBlendingEnabled&&(this.disable(u.BLEND),this.currentBlendingEnabled=!1)}},{key:"setColorMask",value:function(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}},{key:"setDepthTest",value:function(e){var t=this.gl;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}},{key:"setReversedDepth",value:function(e){if(this.currentDepthReversed!==e){var t=this.backend.extensions.get("EXT_clip_control");e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}},{key:"setDepthMask",value:function(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}},{key:"setDepthFunc",value:function(e){if(this.currentDepthReversed&&(e=c.Ac[e]),this.currentDepthFunc!==e){var t=this.gl;switch(e){case c.N:t.depthFunc(t.NEVER);break;case c.O:t.depthFunc(t.ALWAYS);break;case c.P:t.depthFunc(t.LESS);break;case c.Q:t.depthFunc(t.LEQUAL);break;case c.R:t.depthFunc(t.EQUAL);break;case c.S:t.depthFunc(t.GEQUAL);break;case c.T:t.depthFunc(t.GREATER);break;case c.U:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}},{key:"scissor",value:function(e,t,r,n){var i=this._tempVec4.set(e,t,r,n);!1===this.currentScissor.equals(i)&&(this.gl.scissor(i.x,i.y,i.z,i.w),this.currentScissor.copy(i))}},{key:"viewport",value:function(e,t,r,n){var i=this._tempVec4.set(e,t,r,n);!1===this.currentViewport.equals(i)&&(this.gl.viewport(i.x,i.y,i.z,i.w),this.currentViewport.copy(i))}},{key:"setScissorTest",value:function(e){var t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}},{key:"setStencilTest",value:function(e){var t=this.gl;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}},{key:"setStencilMask",value:function(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}},{key:"setStencilFunc",value:function(e,t,r){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==r)&&(this.gl.stencilFunc(e,t,r),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=r)}},{key:"setStencilOp",value:function(e,t,r){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==r)&&(this.gl.stencilOp(e,t,r),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=r)}},{key:"setMaterial",value:function(e,t,r){var n=this.gl;e.side===c.l?this.disable(n.CULL_FACE):this.enable(n.CULL_FACE);var i=e.side===c.k;t&&(i=!i),this.setFlipSided(i),e.blending===c.n&&!1===e.transparent?this.setBlending(c.m):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);var a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage&&this.backend.renderer.currentSamples>0?this.enable(n.SAMPLE_ALPHA_TO_COVERAGE):this.disable(n.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(var o=0;o<8;o++)o<r?this.enable(12288+o):this.disable(12288+o)}},{key:"setPolygonOffset",value:function(e,t,r){var n=this.gl;e?(this.enable(n.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==r)&&(n.polygonOffset(t,r),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=r)):this.disable(n.POLYGON_OFFSET_FILL)}},{key:"useProgram",value:function(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}},{key:"setVertexState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.gl;return(this.currentVAO!==e||this.currentIndex!==t)&&(r.bindVertexArray(e),null!==t&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0)}},{key:"resetVertexState",value:function(){var e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}},{key:"bindFramebuffer",value:function(e,t){var r=this.gl,n=this.currentBoundFramebuffers;return n[e]!==t&&(r.bindFramebuffer(e,t),n[e]=t,e===r.DRAW_FRAMEBUFFER&&(n[r.FRAMEBUFFER]=t),e===r.FRAMEBUFFER&&(n[r.DRAW_FRAMEBUFFER]=t),!0)}},{key:"drawBuffers",value:function(e,t){var r=this.gl,n=[],i=!1;if(null!==e.textures){void 0===(n=this.currentDrawbuffers.get(t))&&(n=[],this.currentDrawbuffers.set(t,n));var a=e.textures;if(n.length!==a.length||n[0]!==r.COLOR_ATTACHMENT0){for(var o=0,s=a.length;o<s;o++)n[o]=r.COLOR_ATTACHMENT0+o;n.length=a.length,i=!0}}else n[0]!==r.BACK&&(n[0]=r.BACK,i=!0);i&&r.drawBuffers(n)}},{key:"activeTexture",value:function(e){var t=this.gl,r=this.currentTextureSlot,n=this.maxTextures;void 0===e&&(e=t.TEXTURE0+n-1),r!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}},{key:"bindTexture",value:function(e,t,r){var n=this.gl,i=this.currentTextureSlot,a=this.currentBoundTextures,o=this.maxTextures;void 0===r&&(r=null===i?n.TEXTURE0+o-1:i);var s=a[r];void 0===s&&(s={type:void 0,texture:void 0},a[r]=s),(s.type!==e||s.texture!==t)&&(i!==r&&(n.activeTexture(r),this.currentTextureSlot=r),n.bindTexture(e,t),s.type=e,s.texture=t)}},{key:"bindBufferBase",value:function(e,t,r){var n=this.gl,i="".concat(e,"-").concat(t);return this.currentBoundBufferBases[i]!==r&&(n.bindBufferBase(e,t,r),this.currentBoundBufferBases[i]=r,!0)}},{key:"unbindTexture",value:function(){var e=this.gl,t=this.currentTextureSlot,r=this.currentBoundTextures[t];void 0!==r&&void 0!==r.type&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}},{key:"getParameter",value:function(e){var t=this.gl,r=this.parameters;return void 0!==r[e]?r[e]:t.getParameter(e)}},{key:"pixelStorei",value:function(e,t){var r=this.gl,n=this.parameters;n[e]!==t&&(r.pixelStorei(e,t),n[e]=t)}}]),e}(),yk=function(){function e(t){v(this,e),this.backend=t,this.gl=this.backend.gl,this.extensions=t.extensions}return y(e,[{key:"convert",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.Hb,n=this.gl,i=this.extensions,a=c.Hc.getTransfer(r);if(e===c.ua)return n.UNSIGNED_BYTE;if(e===c.Ca)return n.UNSIGNED_SHORT_4_4_4_4;if(e===c.Da)return n.UNSIGNED_SHORT_5_5_5_1;if(e===c.Fa)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===c.Ga)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===c.va)return n.BYTE;if(e===c.wa)return n.SHORT;if(e===c.xa)return n.UNSIGNED_SHORT;if(e===c.ya)return n.INT;if(e===c.za)return n.UNSIGNED_INT;if(e===c.Aa)return n.FLOAT;if(e===c.Ba)return n.HALF_FLOAT;if(e===c.Ha)return n.ALPHA;if(e===c.Ia)return n.RGB;if(e===c.Ja)return n.RGBA;if(e===c.Ka)return n.DEPTH_COMPONENT;if(e===c.La)return n.DEPTH_STENCIL;if(e===c.Ma)return n.RED;if(e===c.Na)return n.RED_INTEGER;if(e===c.Oa)return n.RG;if(e===c.Pa)return n.RG_INTEGER;if(e===c.Ra)return n.RGBA_INTEGER;if(e===c.Sa||e===c.Ta||e===c.Ua||e===c.Va)if(a===c.Lb){if(null===(t=i.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(e===c.Sa)return t.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===c.Ta)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===c.Ua)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===c.Va)return t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(t=i.get("WEBGL_compressed_texture_s3tc")))return null;if(e===c.Sa)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===c.Ta)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===c.Ua)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===c.Va)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===c.Wa||e===c.Xa||e===c.Ya||e===c.Za){if(null===(t=i.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===c.Wa)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===c.Xa)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===c.Ya)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===c.Za)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===c._a||e===c.$a||e===c.ab||e===c.bb||e===c.cb||e===c.db||e===c.eb){if(null===(t=i.get("WEBGL_compressed_texture_etc")))return null;if(e===c._a||e===c.$a)return a===c.Lb?t.COMPRESSED_SRGB8_ETC2:t.COMPRESSED_RGB8_ETC2;if(e===c.ab)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:t.COMPRESSED_RGBA8_ETC2_EAC;if(e===c.bb)return t.COMPRESSED_R11_EAC;if(e===c.cb)return t.COMPRESSED_SIGNED_R11_EAC;if(e===c.db)return t.COMPRESSED_RG11_EAC;if(e===c.eb)return t.COMPRESSED_SIGNED_RG11_EAC}if(e===c.fb||e===c.gb||e===c.hb||e===c.ib||e===c.jb||e===c.kb||e===c.lb||e===c.mb||e===c.nb||e===c.ob||e===c.pb||e===c.qb||e===c.rb||e===c.sb){if(null===(t=i.get("WEBGL_compressed_texture_astc")))return null;if(e===c.fb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:t.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===c.gb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:t.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===c.hb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:t.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===c.ib)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:t.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===c.jb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:t.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===c.kb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:t.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===c.lb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:t.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===c.mb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:t.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===c.nb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:t.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===c.ob)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:t.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===c.pb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:t.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===c.qb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:t.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===c.rb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:t.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===c.sb)return a===c.Lb?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:t.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===c.tb||e===c.ub||e===c.vb){if(null===(t=i.get("EXT_texture_compression_bptc")))return null;if(e===c.tb)return a===c.Lb?t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:t.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===c.ub)return t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===c.vb)return t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(e===c.wb||e===c.xb||e===c.yb||e===c.zb){if(null===(t=i.get("EXT_texture_compression_rgtc")))return null;if(e===c.wb)return t.COMPRESSED_RED_RGTC1_EXT;if(e===c.xb)return t.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===c.yb)return t.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===c.zb)return t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return e===c.Ea?n.UNSIGNED_INT_24_8:void 0!==n[e]?n[e]:null}},{key:"_clientWaitAsync",value:function(){var e=this.gl,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise(function(r,n){!function i(){var a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);a===e.WAIT_FAILED?(e.deleteSync(t),n()):a!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()})}}]),e}(),yw=!1,yA=function(){function e(t){v(this,e),this.backend=t,this.gl=t.gl,this.extensions=t.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===yw&&(this._init(),yw=!0)}return y(e,[{key:"_init",value:function(){var e,t,r,n=this.gl;b(e={},c.ka,n.REPEAT),b(e,c.la,n.CLAMP_TO_EDGE),b(e,c.ma,n.MIRRORED_REPEAT),yi=e,b(t={},c.na,n.NEAREST),b(t,c.oa,n.NEAREST_MIPMAP_NEAREST),b(t,c.pa,n.NEAREST_MIPMAP_LINEAR),b(t,c.qa,n.LINEAR),b(t,c.ra,n.LINEAR_MIPMAP_NEAREST),b(t,c.sa,n.LINEAR_MIPMAP_LINEAR),ya=t,b(r={},c.dc,n.NEVER),b(r,c.kc,n.ALWAYS),b(r,c.ec,n.LESS),b(r,c.gc,n.LEQUAL),b(r,c.fc,n.EQUAL),b(r,c.jc,n.GEQUAL),b(r,c.hc,n.GREATER),b(r,c.ic,n.NOTEQUAL),yo=r}},{key:"getGLTextureType",value:function(e){var t=this.gl;return!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D}},{key:"getInternalFormat",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=this.gl,s=this.extensions;if(null!==e){if(void 0!==o[e])return o[e];(0,c.wc)("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}var u=null;n&&((u=s.get("EXT_texture_norm16"))||(0,c.wc)("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));var l=t;if(t===o.RED&&(r===o.FLOAT&&(l=o.R32F),r===o.HALF_FLOAT&&(l=o.R16F),r===o.UNSIGNED_BYTE&&(l=o.R8),r===o.BYTE&&(l=o.R8_SNORM),r===o.UNSIGNED_SHORT&&u&&(l=u.R16_EXT),r===o.SHORT&&u&&(l=u.R16_SNORM_EXT)),t===o.RED_INTEGER&&(r===o.UNSIGNED_BYTE&&(l=o.R8UI),r===o.UNSIGNED_SHORT&&(l=o.R16UI),r===o.UNSIGNED_INT&&(l=o.R32UI),r===o.BYTE&&(l=o.R8I),r===o.SHORT&&(l=o.R16I),r===o.INT&&(l=o.R32I)),t===o.RG&&(r===o.FLOAT&&(l=o.RG32F),r===o.HALF_FLOAT&&(l=o.RG16F),r===o.UNSIGNED_BYTE&&(l=o.RG8),r===o.BYTE&&(l=o.RG8_SNORM),r===o.UNSIGNED_SHORT&&u&&(l=u.RG16_EXT),r===o.SHORT&&u&&(l=u.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(r===o.UNSIGNED_BYTE&&(l=o.RG8UI),r===o.UNSIGNED_SHORT&&(l=o.RG16UI),r===o.UNSIGNED_INT&&(l=o.RG32UI),r===o.BYTE&&(l=o.RG8I),r===o.SHORT&&(l=o.RG16I),r===o.INT&&(l=o.RG32I)),t===o.RGB){var d=a?c.Kb:c.Hc.getTransfer(i);r===o.FLOAT&&(l=o.RGB32F),r===o.HALF_FLOAT&&(l=o.RGB16F),r===o.UNSIGNED_BYTE&&(l=d===c.Lb?o.SRGB8:o.RGB8),r===o.BYTE&&(l=o.RGB8_SNORM),r===o.UNSIGNED_SHORT&&u&&(l=u.RGB16_EXT),r===o.SHORT&&u&&(l=u.RGB16_SNORM_EXT),r===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),r===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),r===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),r===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),r===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(r===o.UNSIGNED_BYTE&&(l=o.RGB8UI),r===o.UNSIGNED_SHORT&&(l=o.RGB16UI),r===o.UNSIGNED_INT&&(l=o.RGB32UI),r===o.BYTE&&(l=o.RGB8I),r===o.SHORT&&(l=o.RGB16I),r===o.INT&&(l=o.RGB32I)),t===o.RGBA){var h=a?c.Kb:c.Hc.getTransfer(i);r===o.FLOAT&&(l=o.RGBA32F),r===o.HALF_FLOAT&&(l=o.RGBA16F),r===o.UNSIGNED_BYTE&&(l=h===c.Lb?o.SRGB8_ALPHA8:o.RGBA8),r===o.BYTE&&(l=o.RGBA8_SNORM),r===o.UNSIGNED_SHORT&&u&&(l=u.RGBA16_EXT),r===o.SHORT&&u&&(l=u.RGBA16_SNORM_EXT),r===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),r===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(r===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),r===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),r===o.UNSIGNED_INT&&(l=o.RGBA32UI),r===o.BYTE&&(l=o.RGBA8I),r===o.SHORT&&(l=o.RGBA16I),r===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(r===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),r===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),r===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&r===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&s.get("EXT_color_buffer_float"),l}},{key:"setTextureParameters",value:function(e,t){var r=this.gl,n=this.extensions,i=this.backend,a=this.backend.state,o=c.Hc.getPrimaries(c.Hc.workingColorSpace),s=t.colorSpace===c.Hb?null:c.Hc.getPrimaries(t.colorSpace),u=t.colorSpace===c.Hb||o===s?r.NONE:r.BROWSER_DEFAULT_WEBGL;a.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),r.texParameteri(e,r.TEXTURE_WRAP_S,yi[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,yi[t.wrapT]),(e===r.TEXTURE_3D||e===r.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,yi[t.wrapR])),r.texParameteri(e,r.TEXTURE_MAG_FILTER,ya[t.magFilter]);var l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===c.qa&&l?c.sa:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,ya[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,yo[t.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")){if(t.magFilter===c.na||t.minFilter!==c.pa&&t.minFilter!==c.sa||t.type===c.Aa&&!1===n.has("OES_texture_float_linear"))return;if(t.anisotropy>1){var h=n.get("EXT_texture_filter_anisotropic");r.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}},{key:"createDefaultTexture",value:function(e){var t=this.gl,r=this.backend,n=this.defaultTextures,i=this.getGLTextureType(e),a=n[i];void 0===a&&(a=t.createTexture(),r.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),n[i]=a),r.set(e,{textureGPU:a,glTextureType:i})}},{key:"createTexture",value:function(e,t){var r,n,i,a,o,s=this.gl,u=this.backend;if(!0===e.isExternalTexture)r=e.sourceTexture,n=this.getGLTextureType(e);else{var l=t.levels,c=t.width,d=t.height,h=t.depth;i=u.utils.convert(e.format,e.colorSpace),a=u.utils.convert(e.type),o=this.getInternalFormat(e.internalFormat,i,a,e.normalized,e.colorSpace,e.isVideoTexture),r=s.createTexture(),n=this.getGLTextureType(e),u.state.bindTexture(n,r),this.setTextureParameters(n,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,l,o,c,d,h):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,l,o,c,d,h):e.isVideoTexture||s.texStorage2D(n,l,o,c,d)}u.set(e,{textureGPU:r,glTextureType:n,glFormat:i,glType:a,glInternalFormat:o})}},{key:"copyBufferToTexture",value:function(e,t){var r=this.gl,n=this.backend,i=n.state,a=n.get(t),o=a.textureGPU,s=a.glTextureType,u=a.glFormat,l=a.glType,c=t.source.data,d=c.width,h=c.height;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),n.state.bindTexture(s,o),i.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(s,0,0,0,d,h,u,l,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),n.state.unbindTexture()}},{key:"updateTexture",value:function(e,t){var r=this.gl,n=t.width,i=t.height,a=this.backend.get(e),o=a.textureGPU,s=a.glTextureType,u=a.glFormat,l=a.glType,d=a.glInternalFormat;if(!e.isRenderTargetTexture&&void 0!==o)if(this.backend.state.bindTexture(s,o),this.setTextureParameters(s,e),e.isCompressedTexture)for(var h=e.mipmaps,f=t.image,p=0;p<h.length;p++){var v=h[p];e.isCompressedArrayTexture?e.format!==r.RGBA?null!==u?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,p,0,0,0,v.width,v.height,f.depth,u,v.data):(0,c.wc)("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texSubImage3D(r.TEXTURE_2D_ARRAY,p,0,0,0,v.width,v.height,f.depth,u,l,v.data):null!==u?r.compressedTexSubImage2D(r.TEXTURE_2D,p,0,0,v.width,v.height,u,v.data):(0,c.wc)("WebGLBackend: Unsupported compressed texture format")}else if(e.isCubeTexture)for(var g=t.images,m=e.mipmaps,y=0;y<6;y++){var b=yE(g[y]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,0,0,n,i,u,l,b);for(var x=0;x<m.length;x++){var _=yE(m[x].images[y]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+y,x+1,0,0,_.width,_.height,u,l,_)}}else if(e.isDataArrayTexture||e.isArrayTexture){var T=t.image;if(e.layerUpdates.size>0){var S=(0,c.Ye)(T.width,T.height,e.format,e.type),N=!0,k=!1,w=void 0;try{for(var A,E=e.layerUpdates[Symbol.iterator]();!(N=(A=E.next()).done);N=!0){var R=A.value,C=T.data.subarray(R*S/T.data.BYTES_PER_ELEMENT,(R+1)*S/T.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,R,T.width,T.height,1,u,l,C)}}catch(e){k=!0,w=e}finally{try{N||null==E.return||E.return()}finally{if(k)throw w}}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,T.width,T.height,T.depth,u,l,T.data)}else if(e.isData3DTexture){var M=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,M.width,M.height,M.depth,u,l,M.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(s,0,d,u,l,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&(3===r.texElementImage2D.length?r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,t.image):r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image));else{var F=e.mipmaps;if(F.length>0)for(var B=0,P=F.length;B<P;B++){var L=F[B],D=yE(L);r.texSubImage2D(s,B,0,0,L.width,L.height,u,l,D)}else{var U=yE(t.image);r.texSubImage2D(s,0,0,0,n,i,u,l,U)}}}},{key:"generateMipmaps",value:function(e){var t=this.gl,r=this.backend,n=r.get(e),i=n.textureGPU,a=n.glTextureType;r.state.bindTexture(a,i),t.generateMipmap(a)}},{key:"deallocateRenderBuffers",value:function(e){var t=this.gl,r=this.backend;if(e){var n=r.get(e);if(n.renderBufferStorageSetup=void 0,n.framebuffers){for(var i in n.framebuffers)t.deleteFramebuffer(n.framebuffers[i]);delete n.framebuffers}if(n.depthRenderbuffer&&(t.deleteRenderbuffer(n.depthRenderbuffer),delete n.depthRenderbuffer),n.stencilRenderbuffer&&(t.deleteRenderbuffer(n.stencilRenderbuffer),delete n.stencilRenderbuffer),n.msaaFrameBuffer&&(t.deleteFramebuffer(n.msaaFrameBuffer),delete n.msaaFrameBuffer),n.msaaRenderbuffers){for(var a=0;a<n.msaaRenderbuffers.length;a++)t.deleteRenderbuffer(n.msaaRenderbuffers[a]);delete n.msaaRenderbuffers}}}},{key:"destroyTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.gl,n=this.backend,i=n.get(e),a=i.textureGPU,o=i.renderTarget;this.deallocateRenderBuffers(o),!1===t&&!0!==e.isExternalTexture&&r.deleteTexture(a),n.delete(e)}},{key:"copyTextureToTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=this.gl,s=this.backend,u=this.backend.state,l=s.get(t),c=l.textureGPU,d=l.glTextureType,h=l.glType,f=l.glFormat;u.bindTexture(d,c);var p,v,g,m,y,b,x,_,T,S=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==r)p=r.max.x-r.min.x,v=r.max.y-r.min.y,g=r.isBox3?r.max.z-r.min.z:1,m=r.min.x,y=r.min.y,b=r.isBox3?r.min.z:0;else{var N=Math.pow(2,-i);p=Math.floor(S.width*N),v=Math.floor(S.height*N),g=e.isDataArrayTexture||e.isArrayTexture?S.depth:e.isData3DTexture?Math.floor(S.depth*N):1,m=0,y=0,b=0}null!==n?(x=n.x,_=n.y,T=n.z):(x=0,_=0,T=0),u.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),u.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),u.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);var k=u.getParameter(o.UNPACK_ROW_LENGTH),w=u.getParameter(o.UNPACK_IMAGE_HEIGHT),A=u.getParameter(o.UNPACK_SKIP_PIXELS),E=u.getParameter(o.UNPACK_SKIP_ROWS),R=u.getParameter(o.UNPACK_SKIP_IMAGES);u.pixelStorei(o.UNPACK_ROW_LENGTH,S.width),u.pixelStorei(o.UNPACK_IMAGE_HEIGHT,S.height),u.pixelStorei(o.UNPACK_SKIP_PIXELS,m),u.pixelStorei(o.UNPACK_SKIP_ROWS,y),u.pixelStorei(o.UNPACK_SKIP_IMAGES,b);var C=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,M=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){var F,B,P=s.get(e),L=s.get(t),D=s.get(P.renderTarget),U=s.get(L.renderTarget),O=D.framebuffers[P.cacheKey],I=U.framebuffers[L.cacheKey],V=null!=(F=u.currentBoundFramebuffers[o.READ_FRAMEBUFFER])?F:null,G=null!=(B=u.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER])?B:null;u.bindFramebuffer(o.READ_FRAMEBUFFER,O),u.bindFramebuffer(o.DRAW_FRAMEBUFFER,I);for(var z=0;z<g;z++)C&&(o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,P.textureGPU,i,b+z),o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a,T+z)),o.blitFramebuffer(m,y,p,v,x,_,p,v,o.DEPTH_BUFFER_BIT,o.NEAREST);u.bindFramebuffer(o.READ_FRAMEBUFFER,V),u.bindFramebuffer(o.DRAW_FRAMEBUFFER,G)}else if(0!==i||e.isRenderTargetTexture||s.has(e)){var W,H,q=s.get(e);null===this._srcFramebuffer&&(this._srcFramebuffer=o.createFramebuffer()),null===this._dstFramebuffer&&(this._dstFramebuffer=o.createFramebuffer());var j=null!=(W=u.currentBoundFramebuffers[o.READ_FRAMEBUFFER])?W:null,X=null!=(H=u.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER])?H:null;u.bindFramebuffer(o.READ_FRAMEBUFFER,this._srcFramebuffer),u.bindFramebuffer(o.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(var K=0;K<g;K++)C?o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,q.textureGPU,i,b+K):o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,q.textureGPU,i),M?o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a,T+K):o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,c,a),0!==i?o.blitFramebuffer(m,y,p,v,x,_,p,v,o.COLOR_BUFFER_BIT,o.NEAREST):M?o.copyTexSubImage3D(d,a,x,_,T+K,m,y,p,v):o.copyTexSubImage2D(d,a,x,_,m,y,p,v);u.bindFramebuffer(o.READ_FRAMEBUFFER,j),u.bindFramebuffer(o.DRAW_FRAMEBUFFER,X)}else M?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(d,a,x,_,T,p,v,g,f,h,S.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(d,a,x,_,T,p,v,g,f,S.data):o.texSubImage3D(d,a,x,_,T,p,v,g,f,h,S):e.isDataTexture?o.texSubImage2D(o.TEXTURE_2D,a,x,_,p,v,f,h,S.data):e.isCompressedTexture?o.compressedTexSubImage2D(o.TEXTURE_2D,a,x,_,S.width,S.height,f,S.data):o.texSubImage2D(o.TEXTURE_2D,a,x,_,p,v,f,h,S);u.pixelStorei(o.UNPACK_ROW_LENGTH,k),u.pixelStorei(o.UNPACK_IMAGE_HEIGHT,w),u.pixelStorei(o.UNPACK_SKIP_PIXELS,A),u.pixelStorei(o.UNPACK_SKIP_ROWS,E),u.pixelStorei(o.UNPACK_SKIP_IMAGES,R),0===a&&t.generateMipmaps&&o.generateMipmap(d),u.unbindTexture()}},{key:"copyFramebufferToTexture",value:function(e,t,r){var n=this.gl,i=this.backend.state,a=this.backend.get(e).textureGPU,o=r.x,s=r.y,u=r.z,l=r.w,c=!0===e.isDepthTexture||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(c){var h,f,p=0!==o||0!==s;if(!0===e.isDepthTexture?(h=n.DEPTH_BUFFER_BIT,f=n.DEPTH_ATTACHMENT,t.stencil&&(h|=n.STENCIL_BUFFER_BIT)):(h=n.COLOR_BUFFER_BIT,f=n.COLOR_ATTACHMENT0),p){var v=this.backend.get(t.renderTarget),g=v.framebuffers[t.getCacheKey()],m=v.msaaFrameBuffer;i.bindFramebuffer(n.DRAW_FRAMEBUFFER,g),i.bindFramebuffer(n.READ_FRAMEBUFFER,m);var y=d-s-l;n.blitFramebuffer(o,y,o+u,y+l,o,y,o+u,y+l,h,n.NEAREST),i.bindFramebuffer(n.READ_FRAMEBUFFER,g),i.bindTexture(n.TEXTURE_2D,a),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,o,y,u,l),i.unbindTexture()}else{var b=n.createFramebuffer();i.bindFramebuffer(n.DRAW_FRAMEBUFFER,b),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,f,n.TEXTURE_2D,a,0),n.blitFramebuffer(0,0,u,l,0,0,u,l,h,n.NEAREST),n.deleteFramebuffer(b)}}else i.bindTexture(n.TEXTURE_2D,a),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,o,d-l-s,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}},{key:"setupRenderBufferStorage",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this.gl,a=t.renderTarget,o=a.depthTexture,s=a.depthBuffer,u=a.stencilBuffer,l=a.width,c=a.height;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!u){var d=i.DEPTH_COMPONENT24;!0===n?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,d,l,c):r>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(d=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,d,l,c)):i.renderbufferStorage(i.RENDERBUFFER,d,l,c),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,c):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,c),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}},{key:"copyTextureToBuffer",value:function(e,t,r,n,i,a){return f(function(){var o,s,u,l,c,d,h,f,p,v,g,m,y;return P(this,function(b){switch(b.label){case 0:return o=this,s=o.backend,u=o.gl,c=(l=this.backend.get(e)).textureGPU,d=l.glFormat,h=l.glType,f=u.createFramebuffer(),s.state.bindFramebuffer(u.READ_FRAMEBUFFER,f),p=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D,u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,p,c,0),v=this._getTypedArrayType(h),g=n*i*this._getBytesPerTexel(h,d),m=u.createBuffer(),u.bindBuffer(u.PIXEL_PACK_BUFFER,m),u.bufferData(u.PIXEL_PACK_BUFFER,g,u.STREAM_READ),u.readPixels(t,r,n,i,d,h,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),[4,s.utils._clientWaitAsync()];case 1:return b.sent(),y=new v(g/v.BYTES_PER_ELEMENT),[2,(u.bindBuffer(u.PIXEL_PACK_BUFFER,m),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,y),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),s.state.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.deleteFramebuffer(f),y)]}})}).call(this)}},{key:"_getTypedArrayType",value:function(e){var t=this.gl;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error("THREE.WebGLTextureUtils: Unsupported WebGL type: ".concat(e))}},{key:"_getBytesPerTexel",value:function(e,t){var r=this.gl,n=0;return e===r.UNSIGNED_BYTE&&(n=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(n=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(n=4),t===r.RGBA?4*n:t===r.RGB?3*n:t===r.ALPHA?n:void 0}},{key:"dispose",value:function(){var e=this.gl;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}]),e}();function yE(e){return e.isDataTexture?e.image.data:("u"<typeof HTMLImageElement?"undefined":C(HTMLImageElement))<"u"&&S(e,HTMLImageElement)||("u"<typeof HTMLCanvasElement?"undefined":C(HTMLCanvasElement))<"u"&&S(e,HTMLCanvasElement)||("u"<typeof ImageBitmap?"undefined":C(ImageBitmap))<"u"&&S(e,ImageBitmap)||("u"<typeof OffscreenCanvas?"undefined":C(OffscreenCanvas))<"u"&&S(e,OffscreenCanvas)?e:e.data}var yR=function(){function e(t){v(this,e),this.backend=t,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}return y(e,[{key:"get",value:function(e){var t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}},{key:"has",value:function(e){return this.availableExtensions.includes(e)}}]),e}(),yC=function(){function e(t){v(this,e),this.backend=t,this.maxAnisotropy=null,this.maxUniformBlockSize=null}return y(e,[{key:"getMaxAnisotropy",value:function(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;var e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){var r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}},{key:"getUniformBufferLimit",value:function(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;var e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}]),e}(),yM={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"},yF=function(){function e(t){v(this,e),this.gl=t.gl,this.extensions=t.extensions,this.info=t.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}return y(e,[{key:"render",value:function(e,t){var r=this.gl,n=this.mode,i=this.object,a=this.type,o=this.info;0!==this.index?r.drawElements(n,t,a,e):r.drawArrays(n,e,t),o.update(i,t,1)}},{key:"renderInstances",value:function(e,t,r){var n=this.gl,i=this.mode,a=this.type,o=this.index,s=this.object,u=this.info;0!==r&&(0!==o?n.drawElementsInstanced(i,t,a,e,r):n.drawArraysInstanced(i,e,t,r),u.update(s,t,r))}},{key:"renderMultiDraw",value:function(e,t,r){var n=this.extensions,i=this.mode,a=this.object,o=this.info;if(0!==r){var s=n.get("WEBGL_multi_draw");if(null===s)for(var u=0;u<r;u++)this.render(e[u],t[u]);else{0!==this.index?s.multiDrawElementsWEBGL(i,t,0,this.type,e,0,r):s.multiDrawArraysWEBGL(i,e,0,t,0,r);for(var l=0,c=0;c<r;c++)l+=t[c];o.update(a,l,1)}}}}]),e}(),yB=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;v(this,e),this.trackTimestamp=!0,this.maxQueries=t,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}return y(e,[{key:"getTimestampFrames",value:function(){return this.frames}},{key:"getTimestamp",value:function(e){var t=this.timestamps.get(e);return void 0===t&&((0,c.wc)("TimestampQueryPool: No timestamp available for uid ".concat(e,".")),t=0),t}},{key:"hasTimestampQuery",value:function(e){return this.timestamps.has(e)}},{key:"allocateQueriesForContext",value:function(){}},{key:"resolveQueriesAsync",value:function(){return f(function(){return P(this,function(e){return[2]})})()}},{key:"dispose",value:function(){}}]),e}(),yP=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2048;if(v(this,t),(n=p(this,t,[i])).gl=e,n.type=r,n.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!n.ext)return w(n,((0,c.wc)("EXT_disjoint_timer_query not supported; timestamps will be disabled."),void(n.trackTimestamp=!1)));n.queries=[];for(var a=0;a<n.maxQueries;a++)n.queries.push(e.createQuery());return n.activeQuery=null,n.queryStates=new Map,n}return T(t,e),y(t,[{key:"allocateQueriesForContext",value:function(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,c.yc)("WebGLTimestampQueryPool [".concat(this.type,"]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.").concat(this.type.toUpperCase()," ).")),null;var t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}},{key:"beginQuery",value:function(e){if(this.trackTimestamp&&!this.isDisposed){var t=this.queryOffsets.get(e);if(null!=t&&null===this.activeQuery){var r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){(0,c.xc)("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}}}},{key:"endQuery",value:function(e){if(this.trackTimestamp&&!this.isDisposed){var t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){(0,c.xc)("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}}},{key:"resolveQueriesAsync",value:function(){return f(function(){var e,t,r,n,i,a,o,s,u,l,d,h,f,p,v,g,m,y,b,x,_,T,S,N,k;return P(this,function(w){switch(w.label){case 0:if(!this.trackTimestamp||this.pendingResolve)return[2,this.lastValue];this.pendingResolve=!0,w.label=1;case 1:w.trys.push([1,10,11,12]),e=new Map,t=!0,r=!1,n=void 0;try{for(i=this.queryOffsets[Symbol.iterator]();!(t=(a=i.next()).done);t=!0)s=(o=E(a.value,2))[0],u=o[1],"ended"===this.queryStates.get(u)&&(l=this.queries[u],e.set(s,this.resolveQuery(l)))}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}if(0===e.size)return[2,this.lastValue];d={},h=[],f=!0,p=!1,v=void 0,w.label=2;case 2:w.trys.push([2,7,8,9]),g=e[Symbol.iterator](),w.label=3;case 3:if(f=(m=g.next()).done)return[3,6];return b=(y=E(m.value,2))[0],x=y[1],_=parseInt(b.match(/^(.*):f(\d+)$/)[2]),!1===h.includes(_)&&h.push(_),void 0===d[_]&&(d[_]=0),[4,x];case 4:T=w.sent(),this.timestamps.set(b,T),d[_]+=T,w.label=5;case 5:return f=!0,[3,3];case 6:return[3,9];case 7:return S=w.sent(),p=!0,v=S,[3,9];case 8:try{f||null==g.return||g.return()}finally{if(p)throw v}return[7];case 9:return N=d[h[h.length-1]],[2,(this.lastValue=N,this.frames=h,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,N)];case 10:return k=w.sent(),[2,((0,c.xc)("Error resolving queries:",k),this.lastValue)];case 11:return this.pendingResolve=!1,[7];case 12:return[2]}})}).call(this)}},{key:"resolveQuery",value:function(e){return f(function(){var t;return P(this,function(r){return t=this,[2,new Promise(function(r){if(t.isDisposed)return void r(t.lastValue);var n,i=!1,a=function(e){i||(i=!0,n&&(clearTimeout(n),n=null),r(e))},o=function(){if(t.isDisposed)a(t.lastValue);else try{if(t.gl.getParameter(t.ext.GPU_DISJOINT_EXT))return void a(t.lastValue);if(!t.gl.getQueryParameter(e,t.gl.QUERY_RESULT_AVAILABLE))return void(n=setTimeout(o,1));var i=t.gl.getQueryParameter(e,t.gl.QUERY_RESULT);r(Number(i)/1e6)}catch(e){(0,c.xc)("Error checking query:",e),r(t.lastValue)}};o()})]})}).call(this)}},{key:"dispose",value:function(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){var e=!0,t=!1,r=void 0;try{for(var n,i=this.queries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=n.value;this.gl.deleteQuery(a)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}]),t}(yB),yL=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this,t),(e=p(this,t,[r])).isWebGLBackend=!0,e.attributeUtils=null,e.extensions=null,e.capabilities=null,e.textureUtils=null,e.bufferRenderer=null,e.gl=null,e.state=null,e.utils=null,e.vaoCache={},e.transformFeedbackCache={},e.discard=!1,e.disjoint=null,e.parallel=null,e._currentContext=null,e._knownBindings=new WeakSet,e._supportsInvalidateFramebuffer=!(("u"<typeof navigator?"undefined":C(navigator))>"u")&&/OculusBrowser/g.test(navigator.userAgent),e._xrFramebuffer=null,e}return T(t,e),y(t,[{key:"init",value:function(e){x(_(t.prototype),"init",this).call(this,e);var r=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},i=void 0!==r.context?r.context:e.domElement.getContext("webgl2",n);function a(t){t.preventDefault();var r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=a,e.domElement.addEventListener("webglcontextlost",a,!1),this.gl=i,this.extensions=new yR(this),this.capabilities=new yC(this),this.attributeUtils=new yS(this),this.textureUtils=new yA(this),this.bufferRenderer=new yF(this),this.state=new yN(this),this.utils=new yk(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),r.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:((0,c.wc)("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}},{key:"coordinateSystem",get:function(){return c.oc}},{key:"hasTimestamp",get:function(){return null!==this.disjoint}},{key:"getArrayBufferAsync",value:function(e){return f(function(e){var t,r,n,i=arguments;return P(this,function(a){switch(a.label){case 0:return t=i.length>1&&void 0!==i[1]?i[1]:null,r=i.length>2&&void 0!==i[2]?i[2]:0,n=i.length>3&&void 0!==i[3]?i[3]:-1,[4,this.attributeUtils.getArrayBufferAsync(e,t,r,n)];case 1:return[2,a.sent()]}})}).apply(this,arguments)}},{key:"makeXRCompatible",value:function(){return f(function(){return P(this,function(e){switch(e.label){case 0:if(!0===this.gl.getContextAttributes().xrCompatible)return[3,2];return[4,this.gl.makeXRCompatible()];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(this)}},{key:"setXRTarget",value:function(e){this._xrFramebuffer=e}},{key:"setXRRenderTargetTextures",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:n.RGBA8}),null!==r){var i=e.stencilBuffer?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:i}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&(0,c.wc)("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}},{key:"initTimestampQuery",value:function(e,t){if(this.disjoint&&this.trackTimestamp){this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new yP(this.gl,e,2048));var r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}}},{key:"prepareTimestampBuffer",value:function(e,t){this.disjoint&&this.trackTimestamp&&this.timestampQueryPool[e].endQuery(t)}},{key:"getContext",value:function(){return this.gl}},{key:"beginRender",value:function(e){var t=this.state,r=this.get(e);if(e.viewport)this.updateViewport(e);else{var n=this.getDrawingBufferSize(),i=n.width,a=n.height;t.viewport(0,0,i,a)}if(e.scissor)this.updateScissor(e);else{var o=this.getDrawingBufferSize(),s=o.width,u=o.height;t.scissor(0,0,s,u)}this.initTimestampQuery(c.qc.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);var l=e.occlusionQueryCount;l>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=Array(l),r.occlusionQueryObjects=Array(l),r.occlusionQueryIndex=0)}},{key:"finishRender",value:function(e){var t=this.gl,r=this.state,n=this.get(e),i=n.previousContext;r.resetVertexState();var a=e.occlusionQueryCount;a>0&&(a>n.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));var o=e.textures;if(null!==o)for(var s=0;s<o.length;s++){var u=o[s];u.generateMipmaps&&this.generateMipmaps(u)}if(this._currentContext=i,this._resolveRenderTarget(e),null!==i){if(this._setFramebuffer(i),i.viewport)this.updateViewport(i);else{var l=this.getDrawingBufferSize(),d=l.width,h=l.height;r.viewport(0,0,d,h)}if(i.scissor)this.updateScissor(i);else{var f=this.getDrawingBufferSize(),p=f.width,v=f.height;r.scissor(0,0,p,v)}}this.prepareTimestampBuffer(c.qc.RENDER,this.getTimestampUID(e))}},{key:"resolveOccludedAsync",value:function(e){var t=this.get(e),r=t.currentOcclusionQueries,n=t.currentOcclusionQueryObjects;if(r&&n){var i=new WeakSet,a=this.gl;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;var o=function(){for(var e=0,s=0;s<r.length;s++){var u=r[s];null!==u&&a.getQueryParameter(u,a.QUERY_RESULT_AVAILABLE)&&(0===a.getQueryParameter(u,a.QUERY_RESULT)&&i.add(n[s]),r[s]=null,a.deleteQuery(u),e++)}e<r.length?requestAnimationFrame(o):t.occluded=i};o()}}},{key:"isOccluded",value:function(e,t){var r=this.get(e);return r.occluded&&r.occluded.has(t)}},{key:"updateViewport",value:function(e){var t=this.state,r=e.viewportValue,n=r.x,i=r.y,a=r.width,o=r.height;t.viewport(n,e.height-o-i,a,o)}},{key:"updateScissor",value:function(e){var t=this.state,r=e.scissorValue,n=r.x,i=r.y,a=r.width,o=r.height;t.scissor(n,e.height-o-i,a,o)}},{key:"setScissorTest",value:function(e){this.state.setScissorTest(e)}},{key:"getClearColor",value:function(){var e=x(_(t.prototype),"getClearColor",this).call(this);return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}},{key:"clear",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=!(arguments.length>4)||void 0===arguments[4]||arguments[4],a=!(arguments.length>5)||void 0===arguments[5]||arguments[5],o=this.gl,s=this.renderer;null===n&&(n={textures:null,clearColorValue:this.getClearColor()});var u=0;if(e&&(u|=o.COLOR_BUFFER_BIT),t&&(u|=o.DEPTH_BUFFER_BIT),r&&(u|=o.STENCIL_BUFFER_BIT),0!==u){var l=n.clearColorValue?n.clearColorValue:this.getClearColor(),c=s.getClearDepth(),d=s.getClearStencil();if(t&&this.state.setDepthMask(!0),null===n.textures)o.clearColor(l.r,l.g,l.b,l.a),o.clear(u);else{if(i&&this._setFramebuffer(n),e)for(var h=0;h<n.textures.length;h++)0===h?o.clearBufferfv(o.COLOR,h,[l.r,l.g,l.b,l.a]):o.clearBufferfv(o.COLOR,h,[0,0,0,1]);t&&r?o.clearBufferfi(o.DEPTH_STENCIL,0,c,d):t?o.clearBufferfv(o.DEPTH,0,[c]):r&&o.clearBufferiv(o.STENCIL,0,[d]),i&&a&&this._resolveRenderTarget(n),i&&null!==this._currentContext&&this._currentContext!==n&&this._setFramebuffer(this._currentContext)}}}},{key:"beginCompute",value:function(e){var t=this.state,r=this.gl;t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(c.qc.COMPUTE,this.getTimestampUID(e))}},{key:"compute",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=this.state,o=this.gl;!1===this.discard&&(a.enable(o.RASTERIZER_DISCARD),this.discard=!0);var s=this.get(n),u=s.programGPU,l=s.transformBuffers,d=s.attributes,h=this._getVaoKey(d),f=this.vaoCache[h];void 0===f?this.vaoCache[h]=this._createVao(d):a.setVertexState(f),a.useProgram(u),this._bindUniforms(r);var p=this._getTransformFeedback(l);o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,p),o.beginTransformFeedback(o.POINTS),Array.isArray(i=null!==i?i:t.count)?((0,c.yc)("WebGLBackend.compute(): The count parameter must be a single number, not an array."),i=i[0]):i&&"object"==(void 0===i?"undefined":C(i))&&i.isIndirectStorageBufferAttribute&&((0,c.yc)("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),i=t.count),d[0].isStorageInstancedBufferAttribute?o.drawArraysInstanced(o.POINTS,0,1,i):o.drawArrays(o.POINTS,0,i),o.endTransformFeedback(),o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,null);for(var v=0;v<l.length;v++){var g=l[v];g.pbo&&this.has(g.pbo)&&this.textureUtils.copyBufferToTexture(g.transformBuffer,g.pbo),g.switchBuffers()}}},{key:"finishCompute",value:function(e){var t=this.state,r=this.gl;this.discard=!1,t.disable(r.RASTERIZER_DISCARD),this.prepareTimestampBuffer(c.qc.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}},{key:"_isRenderCameraDepthArray",value:function(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}},{key:"_draw",value:function(e,t,r,n,i,a){if(e.isBatchedMesh)if(!1===this.hasFeature("WEBGL_multi_draw"))for(var o=this.gl,s=o.getUniformLocation(a,"nodeUniformDrawId"),u=e._multiDrawStarts,l=e._multiDrawCounts,c=e._multiDrawCount,d=0;d<c;d++)o.uniform1ui(s,d),t.render(u[d],l[d]);else t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount);else i>1?t.renderInstances(r,n,i):t.render(r,n)}},{key:"draw",value:function(e){var t=e.object,r=e.pipeline,n=e.material,i=e.context,a=e.hardwareClippingPlanes,o=this.get(r).programGPU,s=this.gl,u=this.state,l=this.get(i),c=e.getDrawParameters();if(null!==c){this._bindUniforms(e.getBindings());var d=t.isMesh&&0>t.matrixWorld.determinantAffine();u.setMaterial(n,d,a),null!==i.mrt&&null!==i.textures&&u.setMRTBlending(i.textures,i.mrt,n),u.useProgram(o);var h=e.getAttributes(),f=this.get(h),p=f.vaoGPU;if(void 0===p){var v=this._getVaoKey(h);void 0===(p=this.vaoCache[v])&&(p=this._createVao(h),this.vaoCache[v]=p,f.vaoGPU=p)}var g=e.getIndex(),m=null!==g?this.get(g).bufferGPU:null;u.setVertexState(p,m);var y=l.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.occlusionTest&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),!0===t.occlusionTest){var b=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,b),l.occlusionQueries[l.occlusionQueryIndex]=b,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}var x=this.bufferRenderer;t.isPoints?x.mode=s.POINTS:t.isLineSegments?x.mode=s.LINES:t.isLine?x.mode=s.LINE_STRIP:t.isLineLoop?x.mode=s.LINE_LOOP:!0===n.wireframe?(u.setLineWidth(n.wireframeLinewidth*this.renderer.getPixelRatio()),x.mode=s.LINES):x.mode=s.TRIANGLES;var _=c.vertexCount,T=c.instanceCount,S=c.firstVertex;if(x.object=t,null!==g){S*=g.array.BYTES_PER_ELEMENT;var N=this.get(g);x.index=g.count,x.type=N.type}else x.index=0;if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){var k=this.get(e.camera),w=e.camera.cameras,A=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===k.indexesGPU||k.indexesGPU.length!==w.length){for(var E=new Uint32Array([0,0,0,0]),R=[],C=0,M=w.length;C<M;C++){var F=s.createBuffer();E[0]=C,s.bindBuffer(s.UNIFORM_BUFFER,F),s.bufferData(s.UNIFORM_BUFFER,E,s.STATIC_DRAW),R.push(F)}k.indexesGPU=R}var B=0,P=!0,L=!1,D=void 0,U=!0,O=!1,I=void 0;try{e:for(var V,G=e.getBindings()[Symbol.iterator]();!(U=(V=G.next()).done);U=!0){var z=V.value;try{for(var W,H=z.bindings[Symbol.iterator]();!(P=(W=H.next()).done);P=!0){var q=W.value;if(q===A)break e;(q.isUniformsGroup||q.isUniformBuffer)&&B++}}catch(e){L=!0,D=e}finally{try{P||null==H.return||H.return()}finally{if(L)throw D}}}}catch(e){O=!0,I=e}finally{try{U||null==G.return||G.return()}finally{if(O)throw I}}var j=this.renderer.getPixelRatio(),X=this._currentContext.renderTarget,K=this._isRenderCameraDepthArray(this._currentContext),Y=this._currentContext.activeCubeFace;if(K){var Q=this.get(X.depthTexture);if(Q.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){Q.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;for(var Z=X.stencilBuffer,J=0,$=w.length;J<$;J++)this.renderer._activeCubeFace=J,this._currentContext.activeCubeFace=J,this._setFramebuffer(this._currentContext),this.clear(!1,!0,Z,this._currentContext,!1,!1);this.renderer._activeCubeFace=Y,this._currentContext.activeCubeFace=Y}}for(var ee=0,et=w.length;ee<et;ee++){var er=w[ee];if(t.layers.test(er.layers)){K&&(this.renderer._activeCubeFace=ee,this._currentContext.activeCubeFace=ee,this._setFramebuffer(this._currentContext));var en=er.viewport;if(void 0!==en){var ei=en.x*j,ea=en.y*j,eo=en.width*j,es=en.height*j;u.viewport(Math.floor(ei),Math.floor(e.context.height-es-ea),Math.floor(eo),Math.floor(es))}u.bindBufferBase(s.UNIFORM_BUFFER,B,k.indexesGPU[ee]),this._draw(t,x,S,_,T,o)}this._currentContext.activeCubeFace=Y,this.renderer._activeCubeFace=Y}}else this._draw(t,x,S,_,T,o)}}},{key:"needsRenderUpdate",value:function(){return!1}},{key:"getRenderCacheKey",value:function(){return""}},{key:"createDefaultTexture",value:function(e){this.textureUtils.createDefaultTexture(e)}},{key:"createTexture",value:function(e,t){this.textureUtils.createTexture(e,t)}},{key:"updateTexture",value:function(e,t){this.textureUtils.updateTexture(e,t)}},{key:"generateMipmaps",value:function(e){this.textureUtils.generateMipmaps(e)}},{key:"destroyTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.textureUtils.destroyTexture(e,t)}},{key:"copyTextureToBuffer",value:function(e,t,r,n,i,a){return f(function(){return P(this,function(o){return[2,this.textureUtils.copyTextureToBuffer(e,t,r,n,i,a)]})}).call(this)}},{key:"updateSampler",value:function(){return""}},{key:"createNodeBuilder",value:function(e,t){return new ym(e,t)}},{key:"createProgram",value:function(e){var t=this.gl,r=e.stage,n=e.code,i="fragment"===r?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,n),t.compileShader(i),this.set(e,{shaderGPU:i})}},{key:"destroyProgram",value:function(e){this.delete(e)}},{key:"createRenderPipeline",value:function(e,t){var r=this,n=this.gl,i=e.pipeline,a=i.fragmentProgram,o=i.vertexProgram,s=n.createProgram(),u=this.get(a).shaderGPU,l=this.get(o).shaderGPU;if(n.attachShader(s,u),n.attachShader(s,l),n.linkProgram(s),this.set(i,{programGPU:s,fragmentShader:u,vertexShader:l}),null!==t&&this.parallel){var c=new Promise(function(t){var a=r.parallel,o=function(){n.getProgramParameter(s,a.COMPLETION_STATUS_KHR)?(r._completeCompile(e,i),t()):requestAnimationFrame(o)};o()});return void t.push(c)}this._completeCompile(e,i)}},{key:"_handleSource",value:function(e,t){for(var r=e.split("\n"),n=[],i=Math.max(t-6,0),a=Math.min(t+6,r.length),o=i;o<a;o++){var s=o+1;n.push("".concat(s===t?">":" "," ").concat(s,": ").concat(r[o]))}return n.join("\n")}},{key:"_getShaderErrors",value:function(e,t,r){var n=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(n&&""===i)return"";var a=/ERROR: 0:(\d+)/.exec(i);if(a){var o=parseInt(a[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),o)}return i}},{key:"_logProgramError",value:function(e,t,r){if(this.renderer.debug.checkShaderErrors){var n=this.gl,i=(n.getProgramInfoLog(e)||"").trim();if(!1===n.getProgramParameter(e,n.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(n,e,r,t);else{var a=this._getShaderErrors(n,r,"vertex"),o=this._getShaderErrors(n,t,"fragment");(0,c.xc)("WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(e,n.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+a+"\n"+o)}else""!==i&&(0,c.wc)("WebGLProgram: Program Info Log:",i)}}},{key:"_completeCompile",value:function(e,t){var r=this.state,n=this.gl,i=this.get(t),a=i.programGPU,o=i.fragmentShader,s=i.vertexShader;!1===n.getProgramParameter(a,n.LINK_STATUS)&&this._logProgramError(a,o,s),r.useProgram(a);var u=e.getBindings();this._setupBindings(u,a),this.set(t,{programGPU:a,pipeline:a})}},{key:"createComputePipeline",value:function(e,t){var r=this.state,n=this.gl,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);for(var a=e.computeProgram,o=n.createProgram(),s=this.get(i).shaderGPU,u=this.get(a).shaderGPU,l=a.transforms,c=[],d=[],h=0;h<l.length;h++){var f=l[h];c.push(f.varyingName),d.push(f.attributeNode)}n.attachShader(o,s),n.attachShader(o,u),n.transformFeedbackVaryings(o,c,n.SEPARATE_ATTRIBS),n.linkProgram(o),!1===n.getProgramParameter(o,n.LINK_STATUS)&&this._logProgramError(o,s,u),r.useProgram(o),this._setupBindings(t,o);for(var p=a.attributes,v=[],g=[],m=0;m<p.length;m++){var y=p[m].node.attribute;v.push(y),this.has(y)||this.attributeUtils.createAttribute(y,n.ARRAY_BUFFER)}for(var b=0;b<d.length;b++){var x=d[b].attribute;this.has(x)||this.attributeUtils.createAttribute(x,n.ARRAY_BUFFER);var _=this.get(x);g.push(_)}this.set(e,{programGPU:o,transformBuffers:g,attributes:v})}},{key:"createBindings",value:function(e,t){if(!1===this._knownBindings.has(t)){this._knownBindings.add(t);var r=0,n=0,i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;this.set(l,{textures:n,uniformBuffers:r});var c=!0,d=!1,h=void 0;try{for(var f,p=l.bindings[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var v=f.value;v.isUniformBuffer&&r++,v.isSampledTexture&&n++}}catch(e){d=!0,h=e}finally{try{c||null==p.return||p.return()}finally{if(d)throw h}}}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}this.updateBindings(e,t)}},{key:"updateBindings",value:function(e){var t=this.gl,r=!0,n=!1,i=void 0;try{for(var a,o=e.bindings[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=this.get(s);if(s.isUniformsGroup||s.isUniformBuffer){var l=s.buffer,d=u.bufferGPU;t.bindBuffer(t.UNIFORM_BUFFER,d);var h=s.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,d),0===h.length)t.bufferData(t.UNIFORM_BUFFER,l,t.DYNAMIC_DRAW);else for(var f=(0,c.sc)(l),p=f?1:l.BYTES_PER_ELEMENT,v=0,g=h.length;v<g;v++){var m=h[v],y=m.start*p,b=m.count*p,x=y*(f?l.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,x,l,y,b)}this.set(s,u)}else if(s.isSampledTexture){var _=this.get(s.texture),T=_.textureGPU,S=_.glTextureType;u.textureGPU=T,u.glTextureType=S,this.set(s,u)}}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}}},{key:"updateBinding",value:function(e){var t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){var r=this.get(e).bufferGPU,n=e.buffer,i=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,r),0===i.length)t.bufferData(t.UNIFORM_BUFFER,n,t.DYNAMIC_DRAW);else for(var a=(0,c.sc)(n),o=a?1:n.BYTES_PER_ELEMENT,s=i[0].start,u=0,l=i.length;u<l;u++){var d=i[u],h=i[u+1],f=d.start+d.count;if(void 0===h||h.start!==f){var p=s*o,v=(f-s)*o,g=p*(a?n.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,g,n,p,v),void 0!==h&&(s=h.start)}}}}},{key:"createUniformBuffer",value:function(e){var t=this.get(e);if(void 0===t.bufferGPU){var r=this.gl,n=e.buffer;t.bufferGPU=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,t.bufferGPU),r.bufferData(r.UNIFORM_BUFFER,n.byteLength,r.DYNAMIC_DRAW)}}},{key:"destroyUniformBuffer",value:function(e){var t=this.get(e);this.gl.deleteBuffer(t.bufferGPU),this.delete(e)}},{key:"createIndexAttribute",value:function(e){var t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}},{key:"createAttribute",value:function(e){if(!this.has(e)){var t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}}},{key:"createStorageAttribute",value:function(e){if(!this.has(e)){var t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}}},{key:"updateAttribute",value:function(e){this.attributeUtils.updateAttribute(e)}},{key:"destroyAttribute",value:function(e){this.attributeUtils.destroyAttribute(e)}},{key:"hasFeature",value:function(e){for(var t=Object.keys(yM).filter(function(t){return yM[t]===e}),r=this.extensions,n=0;n<t.length;n++)if(r.has(t[n]))return!0;return!1}},{key:"copyTextureToTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.textureUtils.copyTextureToTexture(e,t,r,n,i,a)}},{key:"copyFramebufferToTexture",value:function(e,t,r){this.textureUtils.copyFramebufferToTexture(e,t,r)}},{key:"hasCompatibility",value:function(e){return e===c.rc.TEXTURE_COMPARE||x(_(t.prototype),"hasCompatibility",this).call(this,e)}},{key:"initRenderTarget",value:function(e){var t=this.gl,r=this.state;this._setFramebuffer(e),r.bindFramebuffer(t.FRAMEBUFFER,null)}},{key:"_setFramebuffer",value:function(e){var t=this.gl,r=this.state,n=null;if(null!==e.textures){var i,a=e.renderTarget,o=this.get(a),s=a.samples,u=a.depthBuffer,l=a.stencilBuffer,c=!0===a.isCubeRenderTarget,d=!0===a.isRenderTarget3D,h=a.depth>1,f=!0===a.isXRRenderTarget,p=!0===f&&!0===a._hasExternalTextures,v=o.msaaFrameBuffer,g=o.depthRenderbuffer,m=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(a),x=hs(e);if(c?(o.cubeFramebuffers||(o.cubeFramebuffers={}),i=o.cubeFramebuffers[x]):f&&!1===p?i=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),i=o.framebuffers[x]),void 0===i){i=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,i);var _=e.textures,T=[];if(c){o.cubeFramebuffers[x]=i;var S=this.get(_[0]).textureGPU,N=this.renderer._activeCubeFace,k=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+N,S,k)}else{o.framebuffers[x]=i;for(var w=0;w<_.length;w++){var A=_[w],E=this.get(A);E.renderTarget=e.renderTarget,E.cacheKey=x;var R=t.COLOR_ATTACHMENT0+w;if(a.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,R,E.textureGPU,0,s,0,2);else if(d||h){var C=this.renderer._activeCubeFace,M=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,R,E.textureGPU,M,C)}else if(b)m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,R,t.TEXTURE_2D,E.textureGPU,0,s);else{var F=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,R,t.TEXTURE_2D,E.textureGPU,F)}}}var B=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===a._autoAllocateDepthBuffer){var P=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(P,e,0,b),o.xrDepthRenderbuffer=P,T.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,P),t.framebufferRenderbuffer(t.FRAMEBUFFER,B,t.RENDERBUFFER,P)}else if(null!==e.depthTexture){T.push(l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);var L=this.get(e.depthTexture);if(L.renderTarget=e.renderTarget,L.cacheKey=x,a.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,B,L.textureGPU,0,s,0,2);else if(p&&b)m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,B,t.TEXTURE_2D,L.textureGPU,0,s);else if(e.depthTexture.isArrayTexture){var D=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,B,L.textureGPU,0,D)}else if(e.depthTexture.isCubeTexture){var U=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,B,t.TEXTURE_CUBE_MAP_POSITIVE_X+U,L.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,B,t.TEXTURE_2D,L.textureGPU,0)}o.depthInvalidationArray=T}else{if(this._isRenderCameraDepthArray(e)){r.bindFramebuffer(t.FRAMEBUFFER,i);var O=this.renderer._activeCubeFace,I=this.get(e.depthTexture),V=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,V,I.textureGPU,0,O)}if((f||b||a.multiview)&&!0!==a._isOpaqueFramebuffer){r.bindFramebuffer(t.FRAMEBUFFER,i);var G=this.get(e.textures[0]);a.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,G.textureGPU,0,s,0,2):b?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,G.textureGPU,0,s):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,G.textureGPU,0);var z=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===a._autoAllocateDepthBuffer){var W=o.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,W),t.framebufferRenderbuffer(t.FRAMEBUFFER,z,t.RENDERBUFFER,W)}else{var H=this.get(e.depthTexture);a.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,z,H.textureGPU,0,s,0,2):b?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,z,t.TEXTURE_2D,H.textureGPU,0,s):t.framebufferTexture2D(t.FRAMEBUFFER,z,t.TEXTURE_2D,H.textureGPU,0)}}}if(s>0&&!1===b&&!a.multiview){if(void 0===v){var q=[];v=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,v);for(var j=[],X=e.textures,K=0;K<X.length;K++){j[K]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,j[K]),q.push(t.COLOR_ATTACHMENT0+K);var Y=e.textures[K],Q=this.get(Y);t.renderbufferStorageMultisample(t.RENDERBUFFER,s,Q.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+K,t.RENDERBUFFER,j[K])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),o.msaaFrameBuffer=v,o.msaaRenderbuffers=j,u&&void 0===g){g=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(g,e,s),o.depthRenderbuffer=g;var Z=l?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;q.push(Z)}o.invalidationArray=q}n=o.msaaFrameBuffer}else n=i;r.drawBuffers(e,i)}r.bindFramebuffer(t.FRAMEBUFFER,n)}},{key:"_getVaoKey",value:function(e){for(var t="",r=0;r<e.length;r++)t+=":"+this.get(e[r]).id;return t}},{key:"_createVao",value:function(e){var t=this.gl,r=t.createVertexArray();t.bindVertexArray(r);for(var n=0;n<e.length;n++){var i=void 0,a=void 0,o=e[n],s=this.get(o);t.bindBuffer(t.ARRAY_BUFFER,s.bufferGPU),t.enableVertexAttribArray(n),!0===o.isInterleavedBufferAttribute?(i=o.data.stride*s.bytesPerElement,a=o.offset*s.bytesPerElement):(i=0,a=0),s.isInteger?t.vertexAttribIPointer(n,o.itemSize,s.type,i,a):t.vertexAttribPointer(n,o.itemSize,s.type,o.normalized,i,a),o.isInstancedBufferAttribute&&!o.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,o.meshPerAttribute):o.isInterleavedBufferAttribute&&o.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,o.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),r}},{key:"_getTransformFeedback",value:function(e){for(var t="",r=0;r<e.length;r++)t+=":"+e[r].id;var n=this.transformFeedbackCache[t];if(void 0!==n)return n;var i=this.gl;n=i.createTransformFeedback(),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,n);for(var a=0;a<e.length;a++){var o=e[a];i.bindBufferBase(i.TRANSFORM_FEEDBACK_BUFFER,a,o.transformBuffer)}return i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}},{key:"_setupBindings",value:function(e,t){var r=this.gl,n=0,i=0,a=!0,o=!1,s=void 0,u=!0,l=!1,c=void 0;try{for(var d,h=e[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;try{for(var p,v=f.bindings[Symbol.iterator]();!(a=(p=v.next()).done);a=!0){var g=p.value;if(g.isUniformsGroup||g.isUniformBuffer){var m=n++,y=r.getUniformBlockIndex(t,g.name);r.uniformBlockBinding(t,y,m)}else if(g.isSampledTexture){var b=i++,x=r.getUniformLocation(t,g.name);r.uniform1i(x,b)}}}catch(e){o=!0,s=e}finally{try{a||null==v.return||v.return()}finally{if(o)throw s}}}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}}},{key:"_bindUniforms",value:function(e){var t=this.gl,r=this.state,n=0,i=0,a=!0,o=!1,s=void 0,u=!0,l=!1,c=void 0;try{for(var d,h=e[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;try{for(var p,v=f.bindings[Symbol.iterator]();!(a=(p=v.next()).done);a=!0){var g=p.value,m=this.get(g);if(g.isUniformsGroup||g.isUniformBuffer){var y=n++;r.bindBufferBase(t.UNIFORM_BUFFER,y,m.bufferGPU)}else if(g.isSampledTexture){var b=i++;r.bindTexture(m.glTextureType,m.textureGPU,t.TEXTURE0+b)}}}catch(e){o=!0,s=e}finally{try{a||null==v.return||v.return()}finally{if(o)throw s}}}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}}},{key:"_resolveRenderTarget",value:function(e){var t=this.gl,r=this.state,n=e.renderTarget;if(null!==e.textures&&n){var i=this.get(n);if(n.samples>0&&!1===this._useMultisampledExtension(n)){var a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;n.resolveDepthBuffer&&(n.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),n.stencilBuffer&&n.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));var s=i.msaaFrameBuffer,u=i.msaaRenderbuffers,l=e.textures,c=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,s),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),c)for(var d=0;d<l.length;d++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.TEXTURE_2D,null,0);for(var h=0;h<l.length;h++){if(c){var f=this.get(l[h]).textureGPU;t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u[h]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,f,0)}if(e.scissor){var p=e.scissorValue,v=p.x,g=p.y,m=p.width,y=p.height,b=e.height-y-g;t.blitFramebuffer(v,b,v+m,b+y,v,b,v+m,b+y,o,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o,t.NEAREST)}if(c)for(var x=0;x<l.length;x++){var _=this.get(l[x]).textureGPU;t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+x,t.RENDERBUFFER,u[x]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+x,t.TEXTURE_2D,_,0)}!0===this._supportsInvalidateFramebuffer&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,i.invalidationArray)}else if(!1===n.resolveDepthBuffer&&i.framebuffers){var T=i.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,T),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}}},{key:"_useMultisampledExtension",value:function(e){return!0===e.multiview||e.samples>0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}},{key:"dispose",value:function(){null!==this.textureUtils&&this.textureUtils.dispose();var e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}]),t}(yx),yD="triangle-list",yU=("u"<typeof self?"undefined":C(self))<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},yO="never",yI="less",yV="equal",yG="less-equal",yz="greater",yW="not-equal",yH="greater-equal",yq="always",yj="store",yX="load",yK="clear",yY="uint32",yQ="r8unorm",yZ="r8snorm",yJ="r8uint",y$="r8sint",y0="r16uint",y1="r16sint",y2="r16float",y3="rg8unorm",y4="rg8snorm",y5="rg8uint",y6="rg8sint",y8="r16unorm",y9="r16snorm",y7="r32uint",be="r32sint",bt="r32float",br="rg16uint",bn="rg16sint",bi="rg16float",ba="rgba8unorm",bo="rgba8unorm-srgb",bs="rgba8snorm",bu="rgba8uint",bl="rgba8sint",bc="bgra8unorm",bd="bgra8unorm-srgb",bh="rg16unorm",bf="rg16snorm",bp="rgb9e5ufloat",bv="rgb10a2unorm",bg="rg11b10ufloat",bm="rg32uint",by="rg32sint",bb="rg32float",bx="rgba16uint",b_="rgba16sint",bT="rgba16float",bS="rgba16unorm",bN="rgba16snorm",bk="rgba32uint",bw="rgba32sint",bA="rgba32float",bE="depth24plus",bR="depth24plus-stencil8",bC="depth32float",bM="depth32float-stencil8",bF="bc1-rgba-unorm",bB="bc1-rgba-unorm-srgb",bP="bc2-rgba-unorm",bL="bc2-rgba-unorm-srgb",bD="bc3-rgba-unorm",bU="bc3-rgba-unorm-srgb",bO="bc4-r-unorm",bI="bc4-r-snorm",bV="bc5-rg-unorm",bG="bc5-rg-snorm",bz="bc6h-rgb-ufloat",bW="bc6h-rgb-float",bH="bc7-rgba-unorm",bq="bc7-rgba-unorm-srgb",bj="etc2-rgb8unorm",bX="etc2-rgb8unorm-srgb",bK="etc2-rgba8unorm",bY="etc2-rgba8unorm-srgb",bQ="eac-r11unorm",bZ="eac-r11snorm",bJ="eac-rg11unorm",b$="eac-rg11snorm",b0="astc-4x4-unorm",b1="astc-4x4-unorm-srgb",b2="astc-5x4-unorm",b3="astc-5x4-unorm-srgb",b4="astc-5x5-unorm",b5="astc-5x5-unorm-srgb",b6="astc-6x5-unorm",b8="astc-6x5-unorm-srgb",b9="astc-6x6-unorm",b7="astc-6x6-unorm-srgb",xe="astc-8x5-unorm",xt="astc-8x5-unorm-srgb",xr="astc-8x6-unorm",xn="astc-8x6-unorm-srgb",xi="astc-8x8-unorm",xa="astc-8x8-unorm-srgb",xo="astc-10x5-unorm",xs="astc-10x5-unorm-srgb",xu="astc-10x6-unorm",xl="astc-10x6-unorm-srgb",xc="astc-10x8-unorm",xd="astc-10x8-unorm-srgb",xh="astc-10x10-unorm",xf="astc-10x10-unorm-srgb",xp="astc-12x10-unorm",xv="astc-12x10-unorm-srgb",xg="astc-12x12-unorm",xm="astc-12x12-unorm-srgb",xy="linear",xb="nearest",xx="zero",x_="one-minus-src",xT="src-alpha",xS="one-minus-src-alpha",xN="unfilterable-float",xk="2d-array",xw="cube",xA="vertex",xE="instance",xR={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},xC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"},xM=function(e){function t(e,r,n){var i;return v(this,t),(i=p(this,t,[e,(r?r.value:null)||ye()])).textureNode=r,i.groupNode=n,i}return T(t,e),y(t,[{key:"update",value:function(){var e=this.textureNode.value;if(null==e){if(null!==this.texture&&void 0!==this.texture)return!1;e=ye()}return this.texture!==e?(this.texture=e,!0):x(_(t.prototype),"update",this).call(this)}}]),t}(m6),xF=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r?r.array:null]))._attribute=r,n.isStorageBuffer=!0,n}return T(t,e),y(t,[{key:"attribute",get:function(){return this._attribute}}]),t}(m$),xB=0,xP=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,["StorageBuffer_"+xB++,e?e.value:null])).nodeUniform=e,n.access=e?e.access:er.READ_WRITE,n.groupNode=r,n}return T(t,e),y(t,[{key:"attribute",get:function(){return this.nodeUniform.value}},{key:"buffer",get:function(){return this.nodeUniform.value.array}}]),t}(xF),xL=[null],xD=function(){function e(t){v(this,e),this.backend=t,this._preferredCanvasFormat=null}return y(e,[{key:"getCurrentDepthStencilFormat",value:function(e){var t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?bM:bR:!0===this.backend.renderer.reversedDepthBuffer?bC:bE),t}},{key:"getTextureFormatGPU",value:function(e){return this.backend.get(e).format}},{key:"getTextureSampleData",value:function(e){if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){var t,r=this.backend.renderer,n=r.getRenderTarget();t=n?n.samples:r.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);var i=(t=this.getSampleCount(t||1))>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:i?1:t,isMSAA:i}}},{key:"getCurrentColorFormat",value:function(e){return null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat()}},{key:"getCurrentColorFormats",value:function(e){var t=this;return null!==e.textures?e.textures.map(function(e){return t.getTextureFormatGPU(e)}):[this.getPreferredCanvasFormat()]}},{key:"getCurrentColorSpace",value:function(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}},{key:"getPrimitiveTopology",value:function(e,t){return e.isPoints?"point-list":e.isLineSegments||e.isMesh&&!0===t.wireframe?"line-list":e.isLine?"line-strip":e.isMesh?yD:void 0}},{key:"getSampleCount",value:function(e){return e>=4?4:1}},{key:"getSampleCountRenderContext",value:function(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}},{key:"getPreferredCanvasFormat",value:function(){var e=this.backend.parameters.outputType;if(void 0===e)return null===this._preferredCanvasFormat&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===c.ua)return bc;if(e===c.Ba)return bT;throw Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}]),e}();function xU(e,t){xL[0]=t,e.queue.submit(xL),xL[0]=null}var xO=function(){function e(){v(this,e),this.label="",this.layout=null,this.entries=[]}return y(e,[{key:"reset",value:function(){this.label="",this.layout=null,this.entries.length=0}}]),e}(),xI=function(){function e(){v(this,e),this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}return y(e,[{key:"reset",value:function(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}]),e}(),xV=function(){function e(){v(this,e),this.label=""}return y(e,[{key:"reset",value:function(){this.label=""}}]),e}(),xG=function(){function e(){v(this,e),this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}return y(e,[{key:"reset",value:function(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}]),e}(),xz=function(){function e(){v(this,e),this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}return y(e,[{key:"reset",value:function(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}]),e}(),xW=function(){function e(){v(this,e),this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}return y(e,[{key:"reset",value:function(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}]),e}(),xH=function(){function e(){v(this,e),this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new xq,this.fragment=null}return y(e,[{key:"reset",value:function(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}]),e}(),xq=function(){function e(){v(this,e),this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}return y(e,[{key:"reset",value:function(){this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}}]),e}(),xj=function(){function e(){v(this,e),this.label="",this.code="",this.compilationHints=[]}return y(e,[{key:"reset",value:function(){this.label="",this.code="",this.compilationHints.length=0}}]),e}(),xX=function(){function e(){v(this,e),this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}return y(e,[{key:"reset",value:function(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}]),e}(),xK=function(){function e(){v(this,e),this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=void 0}return y(e,[{key:"reset",value:function(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=void 0}}]),e}(),xY=new xO,xQ=new xI,xZ=new xV,xJ=new xG,x$=new xW,x0=new xH,x1=new xz,x2=new xj,x3=new xX,x4=new xK,x5=function(e){function t(e){var r;return v(this,t),(r=p(this,t)).device=e,r.mipmapSampler=e.createSampler({minFilter:xy}),r.flipYSampler=e.createSampler({minFilter:xb}),xQ.size=4,xQ.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,r.flipUniformBuffer=e.createBuffer(xQ),xQ.reset(),e.queue.writeBuffer(r.flipUniformBuffer,0,new Uint32Array([1])),xQ.size=4,xQ.usage=GPUBufferUsage.UNIFORM,r.noFlipUniformBuffer=e.createBuffer(xQ),xQ.reset(),r.transferPipelines={},x2.label="mipmap",x2.code="\nstruct VarysStruct {\n @builtin( position ) Position: vec4f,\n @location( 0 ) vTex : vec2f,\n @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar<uniform> flipY: u32;\n\n@vertex\nfn mainVS(\n @builtin( vertex_index ) vertexIndex : u32,\n @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n var Varys : VarysStruct;\n\n var pos = array(\n vec2f( -1, -1 ),\n vec2f( -1, 3 ),\n vec2f( 3, -1 ),\n );\n\n let p = pos[ vertexIndex ];\n let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n Varys.vTex = p * mult + vec2f( 0.5 );\n Varys.Position = vec4f( p, 0, 1 );\n Varys.vBaseArrayLayer = instanceIndex;\n\n return Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d<f32>;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n return textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array<f32>;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), \n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), \n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), \n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), \n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), \n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), \n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube<f32>;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",r.mipmapShaderModule=e.createShaderModule(x2),x2.reset(),r}return T(t,e),y(t,[{key:"getTransferPipeline",value:function(e,t){var r="".concat(e,"-").concat(t=t||"2d-array"),n=this.transferPipelines[r];return void 0===n&&(x0.label="mipmap-".concat(e,"-").concat(t),x0.vertex={module:this.mipmapShaderModule},x0.fragment={module:this.mipmapShaderModule,entryPoint:"main_".concat(t.replace("-","_")),targets:[{format:e}]},x0.layout="auto",n=this.device.createRenderPipeline(x0),x0.reset(),this.transferPipelines[r]=n),n}},{key:"flipY",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=t.format,a=t.size,o=a.width,s=a.height;x3.size.width=o,x3.size.height=s,x3.format=i,x3.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;var u=this.device.createTexture(x3);x3.reset();var l=this.getTransferPipeline(i,e.textureBindingViewDimension),c=this.getTransferPipeline(i,u.textureBindingViewDimension),d=this.device.createCommandEncoder(xZ),h=function(e,t,n,i,a,o){var s=e.getBindGroupLayout(0);x4.dimension=t.textureBindingViewDimension||"2d-array",x4.mipLevelCount=1;var u=t.createView(x4);x4.reset(),xY.layout=s,xY.entries.push({binding:0,resource:r.flipYSampler},{binding:1,resource:u},{binding:2,resource:{buffer:o?r.flipUniformBuffer:r.noFlipUniformBuffer}});var l=r.device.createBindGroup(xY);xY.reset(),x4.dimension="2d",x4.mipLevelCount=1,x4.baseArrayLayer=a,x4.arrayLayerCount=1;var c=i.createView(x4);x4.reset(),x1.view=c,x1.loadOp=yK,x1.storeOp=yj,x$.colorAttachments.push(x1);var h=d.beginRenderPass(x$);x$.reset(),x1.reset(),h.setPipeline(e),h.setBindGroup(0,l),h.draw(3,1,0,n),h.end()};h(l,e,n,u,0,!1),h(c,u,0,e,n,!0),xU(this.device,d.finish()),u.destroy()}},{key:"generateMipmaps",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.get(e),n=r.layers||this._mipmapCreateBundles(e),i=t;null===i&&(xZ.label="mipmapEncoder",i=this.device.createCommandEncoder(xZ),xZ.reset()),this._mipmapRunBundles(i,n),null===t&&xU(this.device,i.finish()),r.layers=n}},{key:"_mipmapCreateBundles",value:function(e){for(var t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),n=r.getBindGroupLayout(0),i=[],a=1;a<e.mipLevelCount;a++)for(var o=0;o<e.depthOrArrayLayers;o++){x4.dimension=t,x4.baseMipLevel=a-1,x4.mipLevelCount=1;var s=e.createView(x4);x4.reset(),xY.layout=n,xY.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:s},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});var u=this.device.createBindGroup(xY);xY.reset(),x4.dimension="2d",x4.baseMipLevel=a,x4.mipLevelCount=1,x4.baseArrayLayer=o,x4.arrayLayerCount=1;var l=e.createView(x4);x4.reset();var c=new xz;c.view=l,c.loadOp=yK,c.storeOp=yj;var d=new xW;d.colorAttachments.push(c),xJ.colorFormats=[e.format];var h=this.device.createRenderBundleEncoder(xJ);xJ.reset(),h.setPipeline(r),h.setBindGroup(0,u),h.draw(3,1,0,o),i.push({renderBundles:[h.finish()],passDescriptor:d})}return i}},{key:"_mipmapRunBundles",value:function(e,t){for(var r=t.length,n=0;n<r;n++){var i=t[n],a=e.beginRenderPass(i.passDescriptor);a.executeBundles(i.renderBundles),a.end()}}}]),t}(dj),x6=function(){function e(){v(this,e),this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect="all"}return y(e,[{key:"reset",value:function(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect="all"}}]),e}(),x8=function(){function e(){v(this,e),this.width=0,this.height=1,this.depthOrArrayLayers=1}return y(e,[{key:"reset",value:function(){this.width=0,this.height=1,this.depthOrArrayLayers=1}}]),e}(),x9=new xI,x7=new xV,_e=new(function(){function e(){v(this,e),this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}return y(e,[{key:"reset",value:function(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}}]),e}()),_t=new x6,_r=new(function(){function e(){v(this,e),this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}return y(e,[{key:"reset",value:function(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}}]),e}()),_n=new(function(){function e(){v(this,e),this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}return y(e,[{key:"reset",value:function(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}}]),e}()),_i=new(function(){function e(){v(this,e),this.source=null,this.origin={x:0,y:0},this.flipY=!1}return y(e,[{key:"reset",value:function(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}}]),e}()),_a=new(function(e){function t(){var e;return v(this,t),(e=p(this,t)).colorSpace="srgb",e.premultipliedAlpha=!1,e}return T(t,e),y(t,[{key:"reset",value:function(){x(_(t.prototype),"reset",this).call(this),this.colorSpace="srgb",this.premultipliedAlpha=!1}}]),t}(x6)),_o=new xX,_s=new x8,_u=(b(s={},c.dc,"never"),b(s,c.ec,"less"),b(s,c.fc,"equal"),b(s,c.gc,"less-equal"),b(s,c.hc,"greater"),b(s,c.jc,"greater-equal"),b(s,c.kc,"always"),b(s,c.ic,"not-equal"),s),_l=[0,1,3,2,4,5];function _c(e,t,r,n,i,a,o,s,u,l){_t.texture=t,_t.mipLevel=r,_t.origin.z=n,_n.offset=n*a,_n.bytesPerRow=o,_n.rowsPerImage=s,_s.width=u,_s.height=l,e.queue.writeTexture(_t,i.data,_n,_s),_t.reset(),_n.reset(),_s.reset()}var _d=function(){function e(t){v(this,e),this.backend=t,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}return y(e,[{key:"updateSampler",value:function(e){var t=this.backend,r=e.texture;null==r&&(r=e.textureNode&&e.textureNode.value||ye(),e.texture=r),e.textureNode;var n=r.minFilter+"-"+r.magFilter+"-"+r.wrapS+"-"+r.wrapT+"-"+(r.wrapR||"0")+"-"+r.anisotropy+"-"+ +(!0===r.isDepthTexture)+"-"+(null!==r.compareFunction?r.compareFunction:0),i=this._samplerCache.get(n);if(void 0===i){_e.addressModeU=this._convertAddressMode(r.wrapS),_e.addressModeV=this._convertAddressMode(r.wrapT),_e.addressModeW=this._convertAddressMode(r.wrapR),_e.magFilter=this._convertFilterMode(r.magFilter),_e.minFilter=this._convertFilterMode(r.minFilter),_e.mipmapFilter=this._convertMipmapFilterMode(r.minFilter),r.isDepthTexture&&null===r.compareFunction&&(_e.magFilter=xb,_e.minFilter=xb,_e.mipmapFilter=xb),_e.magFilter===xy&&_e.minFilter===xy&&_e.mipmapFilter===xy&&(_e.maxAnisotropy=r.anisotropy),r.isDepthTexture&&null!==r.compareFunction&&t.hasCompatibility(c.rc.TEXTURE_COMPARE)&&(_e.compare=_u[r.compareFunction]);var a=t.device.createSampler(_e);_e.reset(),i={sampler:a,usedTimes:0},this._samplerCache.set(n,i)}var o=t.get(e);return o.sampler!==i.sampler&&(this._releaseSampler(o),o.samplerKey=n,o.sampler=i.sampler,i.usedTimes++),n}},{key:"destroySampler",value:function(e){this._releaseSampler(this.backend.get(e))}},{key:"_releaseSampler",value:function(e){if(void 0!==e.sampler){var t=this._samplerCache.get(e.samplerKey);t.usedTimes--,0===t.usedTimes&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}},{key:"createDefaultTexture",value:function(e){var t,r=_h(e,this.backend.device);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(r):this._getDefaultTextureGPU(r),this.backend.get(e).texture=t}},{key:"createTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.backend,n=r.get(e);if(n.initialized){if(!0===n.externalTexture)return;throw Error("THREE.WebGPUTextureUtils: Texture already initialized.")}if(e.isExternalTexture)return n.texture=e.sourceTexture,void(n.initialized=!0);void 0===t.needsMipmaps&&(t.needsMipmaps=!1),void 0===t.levels&&(t.levels=1),void 0===t.depth&&(t.depth=1);var i=t.width,a=t.height,o=t.depth,s=t.levels;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());var u=this._getDimension(e),l=e.internalFormat||t.format||_h(e,r.device);n.format=l;var d=r.utils.getTextureSampleData(e),h=d.samples,f=d.primarySamples,p=d.isMSAA,v=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(v|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&l!==bp&&!0!==e.is3DTexture&&!0!==e.isData3DTexture&&(v|=GPUTextureUsage.RENDER_ATTACHMENT);var g=new xX;if(g.label=e.name,g.size.width=i,g.size.height=a,g.size.depthOrArrayLayers=o,g.mipLevelCount=s,g.sampleCount=f,g.dimension=u,g.format=l,g.usage=v,void 0===l)return(0,c.wc)("WebGPURenderer: Texture format not supported."),void this.createDefaultTexture(e);e.isCubeTexture&&(g.textureBindingViewDimension=xw);try{n.texture=r.device.createTexture(g)}catch(t){return(0,c.wc)("WebGPURenderer: Failed to create texture with descriptor:",g),void this.createDefaultTexture(e)}if(p){var m=Object.assign({},g);m.label=m.label+"-msaa",m.sampleCount=h,m.mipLevelCount=1,n.msaaTexture=r.device.createTexture(m)}n.initialized=!0,n.textureDescriptorGPU=g}},{key:"destroyTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.backend,n=r.get(e);void 0!==n.texture&&!1===t&&!0!==e.isExternalTexture&&n.texture.destroy(),void 0!==n.msaaTexture&&n.msaaTexture.destroy(),r.delete(e)}},{key:"generateMipmaps",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.backend.get(e);this._generateMipmaps(r.texture,t)}},{key:"getColorBuffer",value:function(){var e=this.backend,t=e.renderer.getCanvasTarget(),r=e.getDrawingBufferSize(),n=r.width,i=r.height,a=e.renderer.currentSamples,o=t.colorTexture,s=e.get(o);if(o.width===n&&o.height===i&&o.samples===a)return s.texture;var u=s.texture;return u&&u.destroy(),_o.label="colorBuffer",_o.size.width=n,_o.size.height=i,_o.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),_o.format=e.utils.getPreferredCanvasFormat(),_o.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,u=e.device.createTexture(_o),_o.reset(),o.source.width=n,o.source.height=i,o.samples=a,s.texture=u,u}},{key:"getDepthBuffer",value:function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.backend,n=r.renderer.getCanvasTarget(),i=r.getDrawingBufferSize(),a=i.width,o=i.height,s=r.renderer.currentSamples,u=n.depthTexture;if(u.width===a&&u.height===o&&u.samples===s&&u.depth===e&&u.stencil===t)return r.get(u).texture;var l,d,h=r.get(u).texture;if(t?(l=c.La,d=!0===r.renderer.reversedDepthBuffer?c.Aa:c.Ea):e&&(l=c.Ka,d=!0===r.renderer.reversedDepthBuffer?c.Aa:c.za),void 0!==h){if(u.image.width===a&&u.image.height===o&&u.format===l&&u.type===d&&u.samples===s)return h;this.destroyTexture(u)}return u.name="depthBuffer",u.format=l,u.type=d,u.image.width=a,u.image.height=o,u.samples=s,this.createTexture(u,{width:a,height:o}),r.get(u).texture}},{key:"updateTexture",value:function(e,t){var r=this.backend.get(e),n=e.mipmaps,i=r.textureDescriptorGPU;if(!e.isRenderTargetTexture&&void 0!==i){if(e.isDataTexture)if(n.length>0)for(var a=0,o=n.length;a<o;a++){var s=n[a];this._copyBufferToTexture(s,r.texture,i,0,e.flipY,0,a)}else this._copyBufferToTexture(t.image,r.texture,i,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)if(e.layerUpdates&&e.layerUpdates.size>0){var u=!0,l=!1,c=void 0;try{for(var d,h=e.layerUpdates[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var f=d.value;this._copyBufferToTexture(t.image,r.texture,i,f,e.flipY,f)}}catch(e){l=!0,c=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw c}}e.clearLayerUpdates()}else for(var p=0;p<t.image.depth;p++)this._copyBufferToTexture(t.image,r.texture,i,p,e.flipY,p);else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,i);else if(e.isHTMLTexture){var v=this.backend.device,g=this.backend.renderer.domElement,m=e.image;if("function"!=typeof v.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback)return r.hasPaintCallback=!0,void g.requestPaint();var y=i.size.width,b=i.size.height;2===v.queue.copyElementImageToTexture.length?v.queue.copyElementImageToTexture({source:m},{destination:{texture:r.texture},width:y,height:b}):v.queue.copyElementImageToTexture(m,y,b,{texture:r.texture}),e.flipY&&this._flipY(r.texture,i)}else if(n.length>0)for(var x=0,_=n.length;x<_;x++){var T=n[x];this._copyImageToTexture(T,r.texture,i,0,e.flipY,e.premultiplyAlpha,x)}else this._copyImageToTexture(t.image,r.texture,i,0,e.flipY,e.premultiplyAlpha);r.version=e.version}}},{key:"copyTextureToBuffer",value:function(e,t,r,n,i,a){return f(function(){var o,s,u,l,c,d,h,f,p,v;return P(this,function(g){switch(g.label){case 0:return o=this.backend.device,u=(s=this.backend.get(e)).texture,l=s.textureDescriptorGPU.format,x9.size=(i-1)*(d=256*Math.ceil((d=n*(c=this._getBytesPerTexel(l)))/256))+n*c,x9.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,h=o.createBuffer(x9),x9.reset(),f=o.createCommandEncoder(x7),_t.texture=u,_t.origin.x=t,_t.origin.y=r,_t.origin.z=a,_r.buffer=h,_r.bytesPerRow=d,_s.width=n,_s.height=i,f.copyTextureToBuffer(_t,_r,_s),_t.reset(),_r.reset(),_s.reset(),p=this._getTypedArrayType(l),xU(o,f.finish()),[4,h.mapAsync(GPUMapMode.READ)];case 1:return g.sent(),v=h.getMappedRange().slice(),[2,(h.destroy(),new p(v))]}})}).call(this)}},{key:"dispose",value:function(){this._samplerCache.clear()}},{key:"_getDefaultTextureGPU",value:function(e){var t=this.defaultTexture[e];if(void 0===t){var r=new c.Ic;r.minFilter=c.na,r.magFilter=c.na,this.createTexture(r,{width:1,height:1,format:e}),this.defaultTexture[e]=t=r}return this.backend.get(t).texture}},{key:"_getDefaultCubeTextureGPU",value:function(e){var t=this.defaultCubeTexture[e];if(void 0===t){var r=new c.Ad;r.minFilter=c.na,r.magFilter=c.na,this.createTexture(r,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=r}return this.backend.get(t).texture}},{key:"_copyCubeMapToTexture",value:function(e,t,r){for(var n=e.images,i=e.mipmaps,a=0;a<6;a++){var o=n[a],s=!0===e.flipY?_l[a]:a;o.isDataTexture?this._copyBufferToTexture(o.image,t,r,s,e.flipY):this._copyImageToTexture(o,t,r,s,e.flipY,e.premultiplyAlpha);for(var u=0;u<i.length;u++){var l=i[u].images[a];l.isDataTexture?this._copyBufferToTexture(l.image,t,r,s,e.flipY,0,u+1):this._copyImageToTexture(l,t,r,s,e.flipY,e.premultiplyAlpha,u+1)}}}},{key:"_copyImageToTexture",value:function(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=this.backend.device,u=o>0?e.width:r.size.width,l=o>0?e.height:r.size.height;_i.source=e,_i.flipY=i,_a.texture=t,_a.mipLevel=o,_a.origin.z=n,_a.premultipliedAlpha=a,_s.width=u,_s.height=l;try{s.queue.copyExternalImageToTexture(_i,_a,_s)}catch(e){}finally{_i.reset(),_a.reset(),_s.reset()}}},{key:"_getPassUtils",value:function(){var e=this._passUtils;return null===e&&(this._passUtils=e=new x5(this.backend.device)),e}},{key:"_generateMipmaps",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._getPassUtils().generateMipmaps(e,t)}},{key:"_flipY",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._getPassUtils().flipY(e,t,r)}},{key:"_copyBufferToTexture",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=this.backend.device,u=e.data,l=this._getBytesPerTexel(r.format),c=e.width*l;_t.texture=t,_t.mipLevel=o,_t.origin.z=n,_n.offset=e.width*e.height*l*a,_n.bytesPerRow=c,_s.width=e.width,_s.height=e.height,s.queue.writeTexture(_t,u,_n,_s),_t.reset(),_n.reset(),_s.reset(),!0===i&&this._flipY(t,r,n)}},{key:"_copyCompressedBufferToTexture",value:function(e,t,r){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=this.backend.device,a=this._getBlockData(r.format),o=r.size.depthOrArrayLayers>1,s=n&&n.size>0?n:null,u=0;u<e.length;u++){var l=e[u],c=l.width,d=l.height,h=o?r.size.depthOrArrayLayers:1,f=Math.ceil(c/a.width)*a.byteLength,p=Math.ceil(d/a.height),v=f*p,g=Math.ceil(c/a.width)*a.width,m=p*a.height,y=!0,b=!1,x=void 0;if(null!==s)try{for(var _,T=s[Symbol.iterator]();!(y=(_=T.next()).done);y=!0){var S=_.value;_c(i,t,u,S,l,v,f,p,g,m)}}catch(e){b=!0,x=e}finally{try{y||null==T.return||T.return()}finally{if(b)throw x}}else for(var N=0;N<h;N++)_c(i,t,u,N,l,v,f,p,g,m)}}},{key:"_getBlockData",value:function(e){return e===bF||e===bB?{byteLength:8,width:4,height:4}:e===bP||e===bL||e===bD||e===bU?{byteLength:16,width:4,height:4}:e===bO||e===bI?{byteLength:8,width:4,height:4}:e===bV||e===bG||e===bz||e===bW||e===bH||e===bq?{byteLength:16,width:4,height:4}:e===bj||e===bX||"etc2-rgb8a1unorm"===e||"etc2-rgb8a1unorm-srgb"===e?{byteLength:8,width:4,height:4}:e===bK||e===bY?{byteLength:16,width:4,height:4}:e===bQ||e===bZ?{byteLength:8,width:4,height:4}:e===bJ||e===b$||e===b0||e===b1?{byteLength:16,width:4,height:4}:e===b2||e===b3?{byteLength:16,width:5,height:4}:e===b4||e===b5?{byteLength:16,width:5,height:5}:e===b6||e===b8?{byteLength:16,width:6,height:5}:e===b9||e===b7?{byteLength:16,width:6,height:6}:e===xe||e===xt?{byteLength:16,width:8,height:5}:e===xr||e===xn?{byteLength:16,width:8,height:6}:e===xi||e===xa?{byteLength:16,width:8,height:8}:e===xo||e===xs?{byteLength:16,width:10,height:5}:e===xu||e===xl?{byteLength:16,width:10,height:6}:e===xc||e===xd?{byteLength:16,width:10,height:8}:e===xh||e===xf?{byteLength:16,width:10,height:10}:e===xp||e===xv?{byteLength:16,width:12,height:10}:e===xg||e===xm?{byteLength:16,width:12,height:12}:void 0}},{key:"_convertAddressMode",value:function(e){var t="clamp-to-edge";return e===c.ka?t="repeat":e===c.ma&&(t="mirror-repeat"),t}},{key:"_convertFilterMode",value:function(e){var t=xy;return(e===c.na||e===c.oa||e===c.pa)&&(t=xb),t}},{key:"_convertMipmapFilterMode",value:function(e){return e===c.pa||e===c.sa?xy:xb}},{key:"_getBytesPerTexel",value:function(e){return e===yQ||e===yZ||e===yJ||e===y$?1:e===y0||e===y1||e===y2||e===y3||e===y4||e===y5||e===y6||e===y8||e===y9?2:e===y7||e===be||e===bt||e===br||e===bn||e===bi||e===ba||e===bo||e===bs||e===bu||e===bl||e===bc||e===bd||e===bh||e===bf||e===bp||e===bv||e===bg||e===bC||e===bE||e===bR||e===bM?4:e===bm||e===by||e===bb||e===bx||e===b_||e===bT||e===bS||e===bN?8:e===bk||e===bw||e===bA?16:void 0}},{key:"_getTypedArrayType",value:function(e){return e===yJ?Uint8Array:e===y$?Int8Array:e===yQ?Uint8Array:e===yZ?Int8Array:e===y5?Uint8Array:e===y6?Int8Array:e===y3?Uint8Array:e===y4?Int8Array:e===bu?Uint8Array:e===bl?Int8Array:e===ba||e===bo?Uint8Array:e===bs?Int8Array:e===y0?Uint16Array:e===y1?Int16Array:e===br?Uint16Array:e===bn?Int16Array:e===bx?Uint16Array:e===b_?Int16Array:e===y2||e===bi||e===bT||e===y8?Uint16Array:e===y9?Int16Array:e===bh?Uint16Array:e===bf?Int16Array:e===bS?Uint16Array:e===bN?Int16Array:e===y7?Uint32Array:e===be?Int32Array:e===bt?Float32Array:e===bm?Uint32Array:e===by?Int32Array:e===bb?Float32Array:e===bk?Uint32Array:e===bw?Int32Array:e===bA?Float32Array:e===bc||e===bd?Uint8Array:e===bv||e===bp||e===bg?Uint32Array:e===bC?Float32Array:e===bE||e===bR?Uint32Array:e===bM?Float32Array:void 0}},{key:"_getDimension",value:function(e){return e.is3DTexture||e.isData3DTexture?"3d":"2d"}}]),e}();function _h(e,t){var r,n=e.format,i=e.type,a=e.normalized,o=e.colorSpace,s=c.Hc.getTransfer(o),u=!1;if(a&&!1===(u=t.features.has(xR.TextureFormatsTier1))&&(0,c.wc)("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature."),!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(n){case c.Sa:case c.Ta:r=s===c.Lb?bB:bF;break;case c.Ua:r=s===c.Lb?bL:bP;break;case c.Va:r=s===c.Lb?bU:bD;break;case c.wb:r=bO;break;case c.xb:r=bI;break;case c.yb:r=bV;break;case c.zb:r=bG;break;case c.tb:r=s===c.Lb?bq:bH;break;case c.ub:r=bW;break;case c.vb:r=bz;break;case c.$a:case c._a:r=s===c.Lb?bX:bj;break;case c.ab:r=s===c.Lb?bY:bK;break;case c.bb:r=bQ;break;case c.cb:r=bZ;break;case c.db:r=bJ;break;case c.eb:r=b$;break;case c.fb:r=s===c.Lb?b1:b0;break;case c.gb:r=s===c.Lb?b3:b2;break;case c.hb:r=s===c.Lb?b5:b4;break;case c.ib:r=s===c.Lb?b8:b6;break;case c.jb:r=s===c.Lb?b7:b9;break;case c.kb:r=s===c.Lb?xt:xe;break;case c.lb:r=s===c.Lb?xn:xr;break;case c.mb:r=s===c.Lb?xa:xi;break;case c.nb:r=s===c.Lb?xs:xo;break;case c.ob:r=s===c.Lb?xl:xu;break;case c.pb:r=s===c.Lb?xd:xc;break;case c.qb:r=s===c.Lb?xf:xh;break;case c.rb:r=s===c.Lb?xv:xp;break;case c.sb:r=s===c.Lb?xm:xg;break;case c.Ja:r=s===c.Lb?bo:ba;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture format.",n)}else switch(n){case c.Ja:switch(i){case c.va:r=bs;break;case c.wa:r=u?bN:b_;break;case c.xa:r=u?bS:bx;break;case c.za:r=bk;break;case c.ya:r=bw;break;case c.ua:r=s===c.Lb?bo:ba;break;case c.Ba:r=bT;break;case c.Aa:r=bA;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RGBAFormat.",i)}break;case c.Ia:switch(i){case c.Fa:r=bp;break;case c.Ga:r=bg;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RGBFormat.",i)}break;case c.Ma:switch(i){case c.va:r=yZ;break;case c.wa:r=u?y9:y1;break;case c.xa:r=u?y8:y0;break;case c.za:r=y7;break;case c.ya:r=be;break;case c.ua:r=yQ;break;case c.Ba:r=y2;break;case c.Aa:r=bt;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RedFormat.",i)}break;case c.Oa:switch(i){case c.va:r=y4;break;case c.wa:r=u?bf:bn;break;case c.xa:r=u?bh:br;break;case c.za:r=bm;break;case c.ya:r=by;break;case c.ua:r=y3;break;case c.Ba:r=bi;break;case c.Aa:r=bb;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RGFormat.",i)}break;case c.Ka:switch(i){case c.xa:r="depth16unorm";break;case c.za:r=bE;break;case c.Aa:r=bC;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with DepthFormat.",i)}break;case c.La:switch(i){case c.Ea:r=bR;break;case c.Aa:t&&!1===t.features.has(xR.Depth32FloatStencil8)&&(0,c.xc)('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=bM;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",i)}break;case c.Na:switch(i){case c.ya:r=be;break;case c.za:r=y7;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",i)}break;case c.Pa:switch(i){case c.ya:r=by;break;case c.za:r=bm;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",i)}break;case c.Ra:switch(i){case c.ya:r=bw;break;case c.za:r=bk;break;default:(0,c.xc)("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",i)}break;default:(0,c.xc)("WebGPURenderer: Unsupported texture format.",n)}return r}var _f=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,_p=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,_v={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},_g=function(e){function t(e){v(this,t);var r,n=function(e){var t=(e=e.trim()).match(_f);if(null!==t&&4===t.length){for(var r=t[2],n=[],i=null;null!==(i=_p.exec(r));)n.push({name:i[1],type:i[2]});for(var a=[],o=0;o<n.length;o++){var s=n[o],u=s.name,l=s.type,c=l;c.startsWith("ptr")?c="pointer":(c.startsWith("texture")&&(c=l.split("<")[0]),c=_v[c]),a.push(new ml(c,u))}var d=e.substring(t[0].length),h=t[3]||"void",f=void 0!==t[1]?t[1]:"";return{type:_v[h]||h,inputs:a,name:f,inputsCode:r,blockCode:d,outputType:h}}throw Error("THREE.WGSLNodeFunction: Function is not a WGSL code.")}(e),i=n.type,a=n.inputs,o=n.name,s=n.inputsCode,u=n.blockCode,l=n.outputType;return(r=p(this,t,[i,a,o])).inputsCode=s,r.blockCode=u,r.outputType=l,r}return T(t,e),y(t,[{key:"getCode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.name,t="void"!==this.outputType?"-> "+this.outputType:"";return"fn ".concat(e," ( ").concat(this.inputsCode.trim()," ) ").concat(t)+this.blockCode}}]),t}(mS),_m=function(e){function t(){return v(this,t),p(this,t,arguments)}return T(t,e),y(t,[{key:"parseFunction",value:function(e){return new _g(e)}}]),t}(mT),_y=(b(u={},er.READ_ONLY,"read"),b(u,er.WRITE_ONLY,"write"),b(u,er.READ_WRITE,"read_write"),u),_b=(b(l={},c.ka,"repeat"),b(l,c.la,"clamp"),b(l,c.ma,"mirror"),l),_x={vertex:yU.VERTEX,fragment:yU.FRAGMENT,compute:yU.COMPUTE},__={instance:!0,swizzleAssign:!1,storageBuffer:!0},_T={"^^":"tsl_xor"},_S={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},_N={},_k={tsl_xor:new pi("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new pi("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new pi("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new pi("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new pi("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new pi("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new pi("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new pi("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new pi("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new pi("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new pi("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new pi("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new pi("\nfn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {\n\n let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];\n\n return mat2x2<f32>(\n m[ 1 ][ 1 ], - m[ 0 ][ 1 ],\n - m[ 1 ][ 0 ], m[ 0 ][ 0 ]\n ) * ( 1.0 / det );\n\n}\n"),inverse_mat3:new pi("\nfn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {\n\n let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ];\n let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ];\n let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ];\n\n let b01 = a22 * a11 - a12 * a21;\n let b11 = - a22 * a10 + a12 * a20;\n let b21 = a21 * a10 - a11 * a20;\n\n let det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3x3<f32>(\n b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ),\n b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ),\n b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 )\n ) * ( 1.0 / det );\n\n}\n"),inverse_mat4:new pi("\nfn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {\n\n let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ];\n let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ];\n let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ];\n let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ];\n\n let b00 = a00 * a11 - a01 * a10;\n let b01 = a00 * a12 - a02 * a10;\n let b02 = a00 * a13 - a03 * a10;\n let b03 = a01 * a12 - a02 * a11;\n let b04 = a01 * a13 - a03 * a11;\n let b05 = a02 * a13 - a03 * a12;\n let b06 = a20 * a31 - a21 * a30;\n let b07 = a20 * a32 - a22 * a30;\n let b08 = a20 * a33 - a23 * a30;\n let b09 = a21 * a32 - a22 * a31;\n let b10 = a21 * a33 - a23 * a31;\n let b11 = a22 * a33 - a23 * a32;\n\n let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4x4<f32>(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00\n ) * ( 1.0 / det );\n\n}\n"),biquadraticTexture:new pi("\nfn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n let res = vec2f( iRes );\n\n let uvScaled = coord * res;\n let uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n \n\n let uv = uvWrapping - 0.5;\n let iuv = floor( uv );\n let f = fract( uv );\n\n let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new pi("\nfn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n let res = vec2f( iRes );\n\n let uvScaled = coord * res;\n let uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n \n\n let uv = uvWrapping - 0.5;\n let iuv = floor( uv );\n let f = fract( uv );\n\n let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},_w={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},_A="";!0!==(("u"<typeof navigator?"undefined":C(navigator))<"u"&&/Firefox|Deno/g.test(navigator.userAgent))&&(_A+="diagnostic( off, derivative_uniformity );\n");var _E=function(e){function t(e,r){var n;return v(this,t),(n=p(this,t,[e,r,new _m])).uniformGroups={},n.uniformGroupsBindings={},n.builtins={},n.directives={},n.scopedArrays=new Map,n.allowEarlyReturns=!0,n.allowGlobalVariables=!0,n}return T(t,e),y(t,[{key:"_generateTextureSample",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.shaderStage;return"fragment"===a?n?i?"textureSample( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(i," )"):"textureSample( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n," )"):i?"textureSample( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i," )"):"textureSample( ".concat(t,", ").concat(t,"_sampler, ").concat(r," )"):this.generateTextureSampleLevel(e,t,r,"0",n)}},{key:"generateTextureSampleLevel",value:function(e,t,r,n,i,a){return!1===this.isUnfilterable(e)?i?a?"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,", ").concat(a," )"):"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n," )"):a?"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(a," )"):"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n," )"):this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,n,i):this.generateTextureLod(e,t,r,i,a,n)}},{key:"generateWrapFunction",value:function(e){var t="tsl_coord_".concat(_b[e.wrapS],"S_").concat(_b[e.wrapT],"T_").concat(e.is3DTexture||e.isData3DTexture?"3d":"2d"),r=_N[t];if(void 0===r){var n=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",a="fn ".concat(t,"( coord : ").concat(i," ) -> ").concat(i," {\n\n return ").concat(i,"(\n"),o=function(e,t){e===c.ka?(n.push(_k.repeatWrapping_float),a+=" tsl_repeatWrapping_float( coord.".concat(t," )")):e===c.la?(n.push(_k.clampWrapping_float),a+=" tsl_clampWrapping_float( coord.".concat(t," )")):e===c.ma?(n.push(_k.mirrorWrapping_float),a+=" tsl_mirrorWrapping_float( coord.".concat(t," )")):(a+=" coord.".concat(t),(0,c.wc)('WebGPURenderer: Unsupported texture wrap type "'.concat(e,'" for vertex shader.')))};o(e.wrapS,"x"),a+=",\n",o(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(a+=",\n",o(e.wrapR,"z")),a+="\n );\n\n}\n",_N[t]=r=new pi(a,n)}return r.build(this),t}},{key:"generateArrayDeclaration",value:function(e,t){return"array< ".concat(this.getType(e),", ").concat(t," >")}},{key:"generateTextureDimension",value:function(e,t,r){var n=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===n.dimensionsSnippet&&(n.dimensionsSnippet={});var i=n.dimensionsSnippet[r];if(void 0===n.dimensionsSnippet[r]){var a,o,s=this.renderer.backend.utils.getTextureSampleData(e).primarySamples;o=e.is3DTexture||e.isData3DTexture?"vec3<u32>":"vec2<u32>",a=s>1||e.isStorageTexture?t:"".concat(t).concat(r?", u32( ".concat(r," )"):""),i=new ib(new ae("textureDimensions( ".concat(a," )"),o)),n.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(n.arrayLayerCount=new ib(new ae("textureNumLayers(".concat(t,")"),"u32"))),e.isTextureCube&&(n.cubeFaceCount=new ib(new ae("6u","u32")))}return i.build(this)}},{key:"generateFilteredTexture",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"0u",a=arguments.length>5?arguments[5]:void 0,o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,i);return n&&(r="".concat(r," + vec2<f32>(").concat(n,") / ").concat(s)),a?(this._include("biquadraticTextureArray"),"tsl_biquadraticTexture_array( ".concat(t,", ").concat(o,"( ").concat(r," ), ").concat(s,", u32( ").concat(a," ), u32( ").concat(i," ) )")):(this._include("biquadraticTexture"),"tsl_biquadraticTexture( ".concat(t,", ").concat(o,"( ").concat(r," ), ").concat(s,", u32( ").concat(i," ) )"))}},{key:"generateTextureLod",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"0u";if(!0===e.isCubeTexture)return i&&(r="".concat(r," + vec3<f32>(").concat(i,")")),"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(e.isDepthTexture?"u32":"f32","( ").concat(a," ) )");var o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,a),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";return i&&(r="".concat(r," + ").concat(u,"<f32>(").concat(i,") / ").concat(u,"<f32>( ").concat(s," )")),r="".concat(u,"<u32>( clamp( floor( ").concat(o,"( ").concat(r," ) * ").concat(u,"<f32>( ").concat(s," ) ), ").concat(u,"<f32>( 0 ), ").concat(u,"<f32>( ").concat(s," - ").concat("vec3"===u?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )"," ) ) )"),this.generateTextureLoad(e,t,r,a,n,null)}},{key:"generateStorageTextureLoad",value:function(e,t,r,n,i,a){return a&&(r="".concat(r," + ").concat(a)),i?"textureLoad( ".concat(t,", ").concat(r,", ").concat(i," )"):"textureLoad( ".concat(t,", ").concat(r," )")}},{key:"generateTextureLoad",value:function(e,t,r,n,i,a){var o;return null===n&&(n="0u"),a&&(r="".concat(r," + ").concat(a)),i?o="textureLoad( ".concat(t,", ").concat(r,", ").concat(i,", u32( ").concat(n," ) )"):(o="textureLoad( ".concat(t,", ").concat(r,", u32( ").concat(n," ) )"),this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=".x")),o}},{key:"generateTextureStore",value:function(e,t,r,n,i){return n?"textureStore( ".concat(t,", ").concat(r,", ").concat(n,", ").concat(i," )"):"textureStore( ".concat(t,", ").concat(r,", ").concat(i," )")}},{key:"isSampleCompare",value:function(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(c.rc.TEXTURE_COMPARE)}},{key:"isUnfilterable",value:function(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===c.Aa||!1===this.isSampleCompare(e)&&e.minFilter===c.na&&e.magFilter===c.na||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}},{key:"generateTexture",value:function(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.shaderStage;return this.isUnfilterable(e)?this.generateTextureLod(e,t,r,n,i,"0",a):this._generateTextureSample(e,t,r,n,i,a)}},{key:"generateTextureGrad",value:function(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.shaderStage;if("fragment"===o)return i?a?"textureSampleGrad( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n[0],", ").concat(n[1],", ").concat(a," )"):"textureSampleGrad( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n[0],", ").concat(n[1]," )"):a?"textureSampleGrad( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n[0],", ").concat(n[1],", ").concat(a," )"):"textureSampleGrad( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n[0],", ").concat(n[1]," )");(0,c.xc)("WebGPURenderer: THREE.TextureNode.gradient() does not support ".concat(o," shader."))}},{key:"generateTextureCompare",value:function(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.shaderStage;if("fragment"===o)return!0===e.isDepthTexture&&!0===e.isArrayTexture?a?"textureSampleCompareLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,", ").concat(a," )"):"textureSampleCompareLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n," )"):a?"textureSampleCompareLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(a," )"):"textureSampleCompareLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n," )");(0,c.xc)("WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ".concat(o," shader."))}},{key:"generateTextureGather",value:function(e,t,r,n,i,a){var o=!0===e.isDepthTexture?"":"".concat(n,", ");return i?a?"textureGather( ".concat(o).concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(a," )"):"textureGather( ".concat(o).concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i," )"):a?"textureGather( ".concat(o).concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(a," )"):"textureGather( ".concat(o).concat(t,", ").concat(t,"_sampler, ").concat(r,")")}},{key:"generateTextureGatherCompare",value:function(e,t,r,n,i,a){return i?a?"textureGatherCompare( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,", ").concat(a," )"):"textureGatherCompare( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,")"):a?"textureGatherCompare( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(a," )"):"textureGatherCompare( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,")")}},{key:"generateTextureLevel",value:function(e,t,r,n,i,a){return!1===this.isUnfilterable(e)?i?a?"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,", ").concat(a," )"):"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n," )"):a?"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(a," )"):"textureSampleLevel( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n," )"):this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,n,i):this.generateTextureLod(e,t,r,i,a,n)}},{key:"generateTextureBias",value:function(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.shaderStage;if("fragment"===o)return i?a?"textureSampleBias( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n,", ").concat(a," )"):"textureSampleBias( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(i,", ").concat(n," )"):a?"textureSampleBias( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n,", ").concat(a," )"):"textureSampleBias( ".concat(t,", ").concat(t,"_sampler, ").concat(r,", ").concat(n," )");(0,c.xc)("WebGPURenderer: THREE.TextureNode.biasNode does not support ".concat(o," shader."))}},{key:"getPropertyName",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage;if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===r)return"varyings.".concat(e.name)}else if(!0===e.isNodeUniform){var n=e.name,i=e.type;return"texture"===i||"cubeTexture"===i||"cubeDepthTexture"===i||"storageTexture"===i||"texture3D"===i?n:"buffer"===i||"storageBuffer"===i||"indirectStorageBuffer"===i?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return x(_(t.prototype),"getPropertyName",this).call(this,e)}},{key:"getOutputStructName",value:function(){return"output"}},{key:"getFunctionOperator",value:function(e){var t=_T[e];return void 0!==t?(this._include(t),t):null}},{key:"getNodeAccess",value:function(e,t){return"compute"!==t?!0===e.isAtomic?((0,c.wc)("WebGPURenderer: Atomic operations are only supported in compute shaders."),er.READ_WRITE):er.READ_ONLY:e.access}},{key:"getStorageAccess",value:function(e,t){return _y[this.getNodeAccess(e,t)]}},{key:"getUniformFromNode",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=x(_(t.prototype),"getUniformFromNode",this).call(this,e,r,n,i),o=this.getDataFromNode(e,n,this.globalCache);if(void 0===o.uniformGPU){var s,u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,n);if("texture"===r||"cubeTexture"===r||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r){var d=null,h=this.getNodeAccess(e,n);if("texture"===r||"storageTexture"===r?d=!0===e.value.is3DTexture?new yl(a.name,a.node,u,h):new ys(a.name,a.node,u,h):"cubeTexture"===r||"cubeDepthTexture"===r?d=new yu(a.name,a.node,u,h):"texture3D"===r&&(d=new yl(a.name,a.node,u,h)),d.store=!0===e.isStorageTextureNode,d.mipLevel=d.store?e.mipLevel:0,d.setVisibility(_x[n]),!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===d.store||null!==e.gatherNode){var f=new xM("".concat(a.name,"_sampler"),a.node,u);f.setVisibility(_x[n]),c.push(f,d),s=[f,d]}else c.push(d),s=[d]}else if("buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r){var p=this.getSharedDataFromNode(e),v=p.buffer;void 0===v&&(p.buffer=v=new("buffer"===r?m2:xP)(e,u)),v.setVisibility(v.getVisibility()|_x[n]),c.push(v),s=v,a.name=i||"NodeBuffer_"+a.id}else{var g=this.uniformGroups[l];void 0===g&&((g=new m5(l,u)).setVisibility(yU.VERTEX|yU.FRAGMENT|yU.COMPUTE),this.uniformGroups[l]=g),-1===c.indexOf(g)&&c.push(g);var m=(s=this.getNodeUniform(a,r)).name;g.uniforms.some(function(e){return e.name===m})||g.addUniform(s)}o.uniformGPU=s}return a}},{key:"getBuiltin",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.shaderStage,i=this.builtins[n]||(this.builtins[n]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}},{key:"hasBuiltin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage;return void 0!==this.builtins[t]&&this.builtins[t].has(e)}},{key:"getVertexIndex",value:function(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}},{key:"buildFunctionCode",value:function(e){var t=e.layout,r=this.flowShaderNode(e),n=[],i=!0,a=!1,o=void 0;try{for(var s,u=t.inputs[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n.push(l.name+" : "+this.getType(l.type))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}var c="fn ".concat(t.name,"( ").concat(n.join(", ")," ) -> ").concat(this.getType(t.type)," {\n").concat(r.vars,"\n").concat(r.code,"\n");return r.result&&(c+=" return ".concat(r.result,";\n")),c+="\n}\n"}},{key:"getInstanceIndex",value:function(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}},{key:"getInvocationLocalIndex",value:function(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}},{key:"getSubgroupSize",value:function(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}},{key:"getInvocationSubgroupIndex",value:function(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}},{key:"getSubgroupIndex",value:function(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}},{key:"getDrawIndex",value:function(){return null}},{key:"getFrontFacing",value:function(){return this.getBuiltin("front_facing","isFront","bool")}},{key:"getFragCoord",value:function(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}},{key:"getFragDepth",value:function(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}},{key:"getClipDistance",value:function(){return"varyings.hw_clip_distances"}},{key:"isFlipY",value:function(){return!1}},{key:"enableDirective",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.shaderStage;(this.directives[t]||(this.directives[t]=new Set)).add(e)}},{key:"getDirectives",value:function(e){var t=[],r=this.directives[e],n=!0,i=!1,a=void 0;if(void 0!==r)try{for(var o,s=r[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value;t.push("enable ".concat(u,";"))}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return t.join("\n")}},{key:"enableSubGroups",value:function(){this.enableDirective("subgroups")}},{key:"enableSubgroupsF16",value:function(){this.enableDirective("subgroups-f16")}},{key:"enableClipDistances",value:function(){this.enableDirective("clip_distances")}},{key:"enableShaderF16",value:function(){this.enableDirective("f16")}},{key:"enableDualSourceBlending",value:function(){this.enableDirective("dual_source_blending")}},{key:"enableHardwareClipping",value:function(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances","array<f32, ".concat(e," >"),"vertex")}},{key:"getBuiltins",value:function(e){var t=[],r=this.builtins[e],n=!0,i=!1,a=void 0;if(void 0!==r)try{for(var o,s=r.values()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=u.name,c=u.property,d=u.type;t.push("@builtin( ".concat(l," ) ").concat(c," : ").concat(d))}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return t.join(",\n ")}},{key:"getScopedArray",value:function(e,t,r,n){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:n}),e}},{key:"getScopedArrays",value:function(e){if("compute"===e){var t=[],r=!0,n=!1,i=void 0;try{for(var a,o=this.scopedArrays.values()[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=s.name,l=s.scope,c=s.bufferType,d=s.bufferCount,h=this.getType(c);t.push("var<".concat(l,"> ").concat(u,": array< ").concat(h,", ").concat(d," >;"))}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t.join("\n")}}},{key:"getAttributes",value:function(e){var t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){var r=this.getBuiltins("attribute");r&&t.push(r);for(var n=this.getAttributesArray(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.name,u=this.getType(o.type);t.push("@location( ".concat(i," ) ").concat(s," : ").concat(u))}}return t.join(",\n ")}},{key:"getStructMembers",value:function(e){var t=[],r=!0,n=!1,i=void 0;try{for(var a,o=e.members[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var s=a.value,u=e.output?"@location( "+s.index+" ) ":"",l=this.getType(s.type);s.atomic&&(l="atomic< "+l+" >"),t.push(" ".concat(u+s.name," : ").concat(l))}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return e.output&&t.push(" ".concat(this.getBuiltins("output"))),t.join(",\n")}},{key:"getStructs",value:function(e){var t="",r=this.structs[e];if(r.length>0){var n=[],i=!0,a=!1,o=void 0;try{for(var s,u=r[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,c="struct ".concat(l.name," {\n");c+=this.getStructMembers(l),c+="\n};",n.push(c)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}t="\n"+n.join("\n\n")+"\n"}return t}},{key:"getVar",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return"var".concat(n," ").concat(t," : ")+(null!==r?this.generateArrayDeclaration(e,r):this.getType(e))}},{key:"getVars",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="";t&&(r="<private>");var n=[],i=this.vars[e],a=!0,o=!1,s=void 0;if(void 0!==i)try{for(var u,l=i[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;n.push("".concat(this.getVar(c.type,c.name,c.count,r),";"))}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}return t?n.join("\n"):"\n ".concat(n.join("\n "),"\n")}},{key:"getVaryings",value:function(e){var t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),"vertex"===e||"fragment"===e)for(var r=this.varyings,n=this.vars[e],i=0,a=0;a<r.length;a++){var o=r[a];if(o.needsInterpolation){var s="@location( ".concat(i++," )");if(o.interpolationType){var u=null!==o.interpolationSampling?", ".concat(o.interpolationSampling," )"):" )";s+=" @interpolate( ".concat(o.interpolationType).concat(u)}else/^(int|uint|ivec|uvec)/.test(o.type)&&(s+=" @interpolate(flat, either)");t.push("".concat(s," ").concat(o.name," : ").concat(this.getType(o.type)))}else"vertex"===e&&!1===n.includes(o)&&n.push(o)}var l=this.getBuiltins(e);l&&t.push(l);var c=t.join(",\n ");return"vertex"===e?this._getWGSLStruct("VaryingsStruct"," "+c):c}},{key:"isCustomStruct",value:function(e){var t=e.value,r=e.node,n=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&null!==r.structTypeNode,i=r.value&&r.value.array&&"number"==typeof r.value.itemSize&&r.value.array.length>r.value.itemSize;return n&&!i}},{key:"getUniforms",value:function(e){var t=this.renderer.backend,r=this.uniforms[e],n=[],i=[],a=[],o={},s=!0,u=!1,l=void 0;try{for(var c,d=r[Symbol.iterator]();!(s=(c=d.next()).done);s=!0){var h=c.value,f=h.groupNode.name,p=this.bindingsIndexes[f];if("texture"===h.type||"cubeTexture"===h.type||"cubeDepthTexture"===h.type||"storageTexture"===h.type||"texture3D"===h.type){var v=h.node,g=v.value;(!0===g.isCubeTexture||!1===this.isUnfilterable(g)&&!0!==v.isStorageTextureNode||null!==v.gatherNode)&&(this.isSampleCompare(g)?n.push("@binding( ".concat(p.binding++," ) @group( ").concat(p.group," ) var ").concat(h.name,"_sampler : sampler_comparison;")):n.push("@binding( ".concat(p.binding++," ) @group( ").concat(p.group," ) var ").concat(h.name,"_sampler : sampler;")));var m=void 0,y="";if(t.utils.getTextureSampleData(g).primarySamples>1&&(y="_multisampled"),!0===g.isCubeTexture&&!0===g.isDepthTexture)m="texture_depth_cube";else if(!0===g.isCubeTexture)m="texture_cube<f32>";else if(!0===g.isDepthTexture)m=t.compatibilityMode&&null===g.compareFunction?"texture".concat(y,"_2d<f32>"):"texture_depth".concat(y,"_2d").concat(!0===g.isArrayTexture?"_array":"");else if(!0===h.node.isStorageTextureNode){var b=_h(g,t.device),x=this.getStorageAccess(h.node,e),_=h.node.value.is3DTexture,T=h.node.value.isArrayTexture;m="texture_storage_".concat(_?"3d":"2d"+(T?"_array":""),"<").concat(b,", ").concat(x,">")}else m=!0===g.isArrayTexture||!0===g.isDataArrayTexture||!0===g.isCompressedArrayTexture?"texture_2d_array<f32>":!0===g.is3DTexture||!0===g.isData3DTexture?"texture_3d<f32>":"texture".concat(y,"_2d<").concat(this.getComponentTypeFromTexture(g).charAt(0),"32>");n.push("@binding( ".concat(p.binding++," ) @group( ").concat(p.group," ) var ").concat(h.name," : ").concat(m,";"))}else if("buffer"===h.type||"storageBuffer"===h.type||"indirectStorageBuffer"===h.type){var S=h.node,N=this.getType(S.getNodeType(this)),k=S.bufferCount,w=k>0&&"buffer"===h.type?", "+k:"",A=S.isStorageBufferNode?"storage, ".concat(this.getStorageAccess(S,e)):"uniform";if(this.isCustomStruct(h))i.push("@binding( ".concat(p.binding++," ) @group( ").concat(p.group," ) var<").concat(A,"> ").concat(h.name," : ").concat(N,";"));else{var E=" value : array< ".concat(S.isAtomic?"atomic<".concat(N,">"):"".concat(N)).concat(w," >");i.push(this._getWGSLStructBinding(h.name,E,A,p.binding++,p.group))}}else{var C=h.groupNode.name;if(void 0===o[C]){var M=this.uniformGroups[C];if(void 0!==M){var F=[],B=!0,P=!1,L=void 0;try{for(var D,U=M.uniforms[Symbol.iterator]();!(B=(D=U.next()).done);B=!0){var O=D.value,I=O.getType(),V=this.getType(this.getVectorType(I));F.push(" ".concat(O.name," : ").concat(V))}}catch(e){P=!0,L=e}finally{try{B||null==U.return||U.return()}finally{if(P)throw L}}var G=this.uniformGroupsBindings[C];void 0===G&&(G={index:p.binding++,id:p.group},this.uniformGroupsBindings[C]=G),o[C]={index:G.index,id:G.id,snippets:F}}}}}}catch(e){u=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(u)throw l}}for(var z in o){var W=o[z];a.push(this._getWGSLStructBinding(z,W.snippets.join(",\n"),"uniform",W.index,W.id))}return R(n).concat(R(i),R(a)).join("\n")}},{key:"buildCode",value:function(){var e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(var t in this.sortBindingGroups(),e){this.shaderStage=t;var r=this.allowGlobalVariables,n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t,r),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);var i="// code\n\n";i+=this.flowCode[t];var a=this.flowNodes[t],o=a[a.length-1],s=o.outputNode,u=void 0!==s&&!0===s.isOutputStructNode,l=!0,c=!1,d=void 0;try{for(var h,f=a[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var p=h.value,v=this.getFlowData(p),g=p.name;if(g&&(i.length>0&&(i+="\n"),i+=" // flow -> ".concat(g,"\n")),i+="".concat(v.code,"\n "),p===o&&"compute"!==t){if(i+="// result\n\n ","vertex"===t)i+="varyings.builtinClipSpace = ".concat(v.result,";");else if("fragment"===t)if(u)n.returnType=s.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",i+="return ".concat(v.result,";");else{var m=" @location( 0 ) color: ".concat(this.getType(this.getOutputType())),y=this.getBuiltins("output");y&&(m+=",\n "+y),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",m),n.structs+="\nvar<private> output : OutputStruct;",i+="output.color = ".concat(this.format(v.result,o.getNodeType(this),this.getOutputType()),";\n\n return output;")}}}}catch(e){c=!0,d=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw d}}n.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{var b=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,b)}}},{key:"getMethod",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==r&&(t=this._getWGSLMethod(e+"_"+r)),void 0===t&&(t=this._getWGSLMethod(e)),t||e}},{key:"getBitcastMethod",value:function(e){return"bitcast<".concat(this.getType(e),">")}},{key:"getFloatPackingMethod",value:function(e){return this.getMethod("floatpack_".concat(e,"_2x16"))}},{key:"getFloatUnpackingMethod",value:function(e){return this.getMethod("floatunpack_".concat(e,"_2x16"))}},{key:"getTernary",value:function(e,t,r){return"select( ".concat(r,", ").concat(t,", ").concat(e," )")}},{key:"getType",value:function(e){return _S[e]||e}},{key:"isAvailable",value:function(e){var t=__[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),__[e]=t),t}},{key:"_getWGSLMethod",value:function(e){return void 0!==_k[e]&&this._include(e),_w[e]}},{key:"_include",value:function(e){var t=_k[e];return t.build(this),this.addInclude(t),t}},{key:"_getWGSLVertexCode",value:function(e){return"".concat(this.getSignature(),"\n// directives\n").concat(e.directives,"\n\n// structs\n").concat(e.structs,"\n\n// uniforms\n").concat(e.uniforms,"\n\n// varyings\n").concat(e.varyings,"\nvar<private> varyings : VaryingsStruct;\n\n// vars\n").concat(e.vars,"\n\n// codes\n").concat(e.codes,"\n\n@vertex\nfn main( ").concat(e.attributes," ) -> VaryingsStruct {\n\n // flow\n ").concat(e.flow,"\n\n return varyings;\n\n}\n")}},{key:"_getWGSLFragmentCode",value:function(e){return"".concat(this.getSignature(),"\n// global\n").concat(_A,"\n\n// structs\n").concat(e.structs,"\n\n// uniforms\n").concat(e.uniforms,"\n\n// vars\n").concat(e.vars,"\n\n// codes\n").concat(e.codes,"\n\n@fragment\nfn main( ").concat(e.varyings," ) -> ").concat(e.returnType," {\n\n // flow\n ").concat(e.flow,"\n\n}\n")}},{key:"_getWGSLComputeCode",value:function(e,t){var r=E(t,3),n=r[0],i=r[1],a=r[2];return"".concat(this.getSignature(),"\n// directives\n").concat(e.directives,"\n\n// system\nvar<private> instanceIndex : u32;\n\n// locals\n").concat(e.scopedArrays,"\n\n// structs\n").concat(e.structs,"\n\n// uniforms\n").concat(e.uniforms,"\n\n// vars\n").concat(this.allowGlobalVariables?e.vars:"","\n\n// codes\n").concat(e.codes,"\n\n@compute @workgroup_size( ").concat(n,", ").concat(i,", ").concat(a," )\nfn main( ").concat(e.attributes," ) {\n\n // local vars\n ").concat(this.allowGlobalVariables?"":e.vars,"\n\n // system\n instanceIndex = globalId.x\n + globalId.y * ( ").concat(n," * numWorkgroups.x )\n + globalId.z * ( ").concat(n," * numWorkgroups.x ) * ( ").concat(i," * numWorkgroups.y );\n\n // flow\n ").concat(e.flow,"\n\n}\n")}},{key:"_getWGSLStruct",value:function(e,t){return"\nstruct ".concat(e," {\n").concat(t,"\n};")}},{key:"_getWGSLStructBinding",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=e+"Struct";return"".concat(this._getWGSLStruct(a,t),"\n@binding( ").concat(n," ) @group( ").concat(i," )\nvar<").concat(r,"> ").concat(e," : ").concat(a,";")}}]),t}(ms),_R=new xI,_C=new xV,_M=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);("u"<typeof Float16Array?"undefined":C(Float16Array))<"u"&&_M.set(Float16Array,["float16"]);var _F=new Map([[c.ad,["float16"]]]),_B=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]),_P=function(){function e(t){v(this,e),this.backend=t}return y(e,[{key:"createAttribute",value:function(e,t){var r=this._getBufferAttribute(e),n=this.backend,i=n.get(r),a=i.buffer;if(void 0===a){var o,s=n.device,u=r.array;if(!1===e.normalized){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(var l=0;l<u.length;l++)65535===u[l]&&(u[l]=0xffffffff)}if((r.array=u,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&3===r.itemSize)?o=4:r.itemSize>1&&r.itemSize*u.BYTES_PER_ELEMENT%4!=0&&(o=4*Math.floor((r.itemSize*u.BYTES_PER_ELEMENT+3)/4)/u.BYTES_PER_ELEMENT),void 0!==o){for(var c=r.itemSize,d=new u.constructor(r.count*o),h=0;h<r.count;h++)d.set(u.subarray(h*c,h*c+c),h*o);(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&(r.itemSize=o,r.array=d),u=d,i._itemSize=c,i._paddedItemSize=o}var f=u.byteLength;_R.label=r.name,_R.size=f+(4-f%4)%4,_R.usage=t,_R.mappedAtCreation=!0,a=s.createBuffer(_R),_R.reset(),new u.constructor(a.getMappedRange()).set(u),a.unmap(),i.buffer=a}}},{key:"updateAttribute",value:function(e){var t=this._getBufferAttribute(e),r=this.backend,n=r.device,i=r.get(t),a=r.get(t).buffer,o=t.array,s=i._itemSize,u=i._paddedItemSize;if(void 0!==u){o=new o.constructor(t.count*u);for(var l=0;l<t.count;l++)o.set(t.array.subarray(l*s,l*s+s),l*u);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=o)}var d=t.updateRanges;if(0===d.length)n.queue.writeBuffer(a,0,o,0);else{for(var h=(0,c.sc)(o),f=h?1:o.BYTES_PER_ELEMENT,p=0,v=d.length;p<v;p++){var g=void 0,m=void 0,y=d[p];if(void 0!==u){var b=Math.floor(y.start/s);g=b*u*f,m=(Math.ceil((y.start+y.count)/s)-b)*u*f}else g=y.start*f,m=y.count*f;var x=g*(h?o.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(a,x,o,g,m)}t.clearUpdateRanges()}}},{key:"createShaderVertexBuffers",value:function(e){for(var t=e.getAttributes(),r=new Map,n=0;n<t.length;n++){var i=t[n],a=this._getUploadedArrayType(i).BYTES_PER_ELEMENT,o=this._getBufferAttribute(i),s=r.get(o);if(void 0===s){var u=void 0,l=void 0;!0===i.isInterleavedBufferAttribute?(u=i.data.stride*a,l=i.data.isInstancedInterleavedBuffer?xE:xA):(u=i.itemSize*a,l=i.isInstancedBufferAttribute?xE:xA,i.itemSize>1&&u%4!=0&&(u=4*Math.floor((u+3)/4))),s={arrayStride:u,attributes:[],stepMode:l},r.set(o,s)}var c=this._getVertexFormat(i),d=!0===i.isInterleavedBufferAttribute?i.offset*a:0;s.attributes.push({shaderLocation:n,offset:d,format:c})}return Array.from(r.values())}},{key:"destroyAttribute",value:function(e){var t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}},{key:"getArrayBufferAsync",value:function(e){return f(function(e){var t,r,n,i,a,o,s,u,l,c,d,h,f,p,v=arguments;return P(this,function(g){switch(g.label){case 0:if(t=v.length>1&&void 0!==v[1]?v[1]:null,r=v.length>2&&void 0!==v[2]?v[2]:0,n=v.length>3&&void 0!==v[3]?v[3]:-1,o=(a=this.backend).device,s=a.get(this._getBufferAttribute(e)).buffer,u=-1===n?s.size-r:n,null!==t&&t.isReadbackBuffer){if(l=a.get(t),!0===t._mapped)throw Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");(t._mapped=!0,void 0===l.readBufferGPU)?(_R.label="".concat(t.name,"_readback"),_R.size=t.maxByteLength,_R.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,i=o.createBuffer(_R),_R.reset(),c=function(){t.buffer=null,t._mapped=!1,i.unmap()},d=function(){t.buffer=null,t._mapped=!1,i.destroy(),a.delete(t),t.removeEventListener("release",c),t.removeEventListener("dispose",d)},t.addEventListener("release",c),t.addEventListener("dispose",d),l.readBufferGPU=i):i=l.readBufferGPU}else _R.label="".concat(e.name,"_readback"),_R.size=u,_R.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,i=o.createBuffer(_R),_R.reset();return _C.label="readback_encoder_".concat(e.name),h=o.createCommandEncoder(_C),_C.reset(),h.copyBufferToBuffer(s,r,i,0,u),xU(o,h.finish()),[4,i.mapAsync(GPUMapMode.READ,0,u)];case 1:if(g.sent(),null===t)return f=i.getMappedRange(0,u).slice(),[2,(i.destroy(),f)];if(t.isReadbackBuffer)return[2,(t.buffer=i.getMappedRange(0,u),t)];return p=i.getMappedRange(0,u),[2,(new Uint8Array(t).set(new Uint8Array(p)),i.destroy(),t)]}})}).apply(this,arguments)}},{key:"_getVertexFormat",value:function(e){var t,r=e.itemSize,n=e.normalized,i=this._getUploadedArrayType(e),a=e.constructor;if(1===r)t=_B.get(i);else{var o=(_F.get(a)||_M.get(i))[+!!n];if(o){var s=4*Math.floor((i.BYTES_PER_ELEMENT*r+3)/4)/i.BYTES_PER_ELEMENT;if(s%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");t="".concat(o,"x").concat(s)}}return t||(0,c.xc)("WebGPUAttributeUtils: Vertex format not supported yet."),t}},{key:"_getUploadedArrayType",value:function(e){var t=e.array.constructor;if(!1===e.normalized&&!0!==e.isFloat16BufferAttribute){if(t===Int16Array||t===Int8Array)return Int32Array;if(t===Uint16Array||t===Uint8Array)return Uint32Array}return t}},{key:"_getBufferAttribute",value:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}]),e}(),_L=new xO,_D=new xI,_U=new xK,_O=function e(t){v(this,e),this.layoutGPU=t,this.usedTimes=0},_I=function(){function e(t){v(this,e),this.backend=t,this._bindGroupLayoutCache=new Map}return y(e,[{key:"createBindingsLayout",value:function(e){var t=this.backend,r=t.device,n=t.get(e);if(n.layout)return n.layout.layoutGPU;var i=this._createLayoutEntries(e),a=H(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return void 0===o&&(o=new _O(r.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,n.layout=o,n.layoutKey=a,o.layoutGPU}},{key:"createBindings",value:function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=this.backend.get(e),o=this.createBindingsLayout(e);0!==r&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===i&&(n=a.groups[r])),void 0===n&&(n=this.createBindGroup(e,o),0!==r&&(a.groups[r]=n,a.versions[r]=i)),a.group=n}},{key:"updateBinding",value:function(e){var t=this.backend,r=t.device,n=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(0===a.length)r.queue.writeBuffer(i,0,n,0);else for(var o=(0,c.sc)(n),s=o?1:n.BYTES_PER_ELEMENT,u=a[0].start,l=0,d=a.length;l<d;l++){var h=a[l],f=a[l+1],p=h.start+h.count;if(void 0===f||f.start!==p){var v=u*s,g=(p-u)*s,m=v*(o?n.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(i,m,n,v,g),void 0!==f&&(u=f.start)}}}},{key:"createBindGroupIndex",value:function(e,t){var r=this.backend.device,n=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0];_D.label="bindingCameraIndex_"+i,_D.size=16,_D.usage=n;var a=r.createBuffer(_D);_D.reset(),r.queue.writeBuffer(a,0,e,0),_L.reset(),_L.label="bindGroupCameraIndex_"+i,_L.layout=t,_L.entries.push({binding:0,resource:{buffer:a}});var o=r.createBindGroup(_L);return _L.reset(),o}},{key:"createBindGroup",value:function(e,t){var r=this.backend,n=r.device,i=0;_L.reset(),_L.label="bindGroup_"+e.name,_L.layout=t;var a=!0,o=!1,s=void 0;try{for(var u,l=e.bindings[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;if(c.isUniformBuffer){var d=r.get(c);_L.entries.push({binding:i,resource:{buffer:d.buffer}})}else if(c.isStorageBuffer){var h=r.get(c.attribute).buffer;_L.entries.push({binding:i,resource:{buffer:h}})}else if(c.isSampledTexture){var f=void 0,p=r.get(c.texture);if(void 0!==p.externalTexture)f=n.importExternalTexture({source:p.externalTexture});else{var v=c.store?1:p.texture.mipLevelCount,g=c.store?c.mipLevel:0,m="view-".concat(p.texture.width,"-").concat(p.texture.height);if(p.texture.depthOrArrayLayers>1&&(m+="-".concat(p.texture.depthOrArrayLayers)),m+="-".concat(v,"-").concat(g),f=p[m],void 0===f){var y=void 0;y=c.isSampledCubeTexture?xw:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?xk:c.isSampledTexture3D||c.texture.is3DTexture?"3d":"2d",_U.aspect="all",_U.dimension=y,_U.mipLevelCount=v,_U.baseMipLevel=g,f=p[m]=p.texture.createView(_U),_U.reset()}}_L.entries.push({binding:i,resource:f})}else if(c.isSampler){var b=r.get(c);_L.entries.push({binding:i,resource:b.sampler})}i++}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}var x=n.createBindGroup(_L);return _L.reset(),x}},{key:"_createLayoutEntries",value:function(e){var t=[],r=0,n=!0,i=!1,a=void 0;try{for(var o,s=e.bindings[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var u=o.value,l=this.backend,d={binding:r,visibility:u.visibility};if(u.isUniformBuffer||u.isStorageBuffer){var h={};u.isStorageBuffer&&(u.visibility&yU.COMPUTE&&(u.access===er.READ_WRITE||u.access===er.WRITE_ONLY)?h.type="storage":h.type="read-only-storage"),d.buffer=h}else if(u.isSampledTexture&&u.store){var f={};f.format=this.backend.get(u.texture).texture.format;var p=u.access;f.access=p===er.READ_WRITE?"read-write":p===er.WRITE_ONLY?"write-only":"read-only",u.texture.isArrayTexture?f.viewDimension=xk:u.texture.is3DTexture&&(f.viewDimension="3d"),d.storageTexture=f}else if(u.isSampledTexture){var v={};if(l.utils.getTextureSampleData(u.texture).primarySamples>1&&(v.multisampled=!0,u.texture.isDepthTexture||(v.sampleType=xN)),u.texture.isDepthTexture)l.compatibilityMode&&null===u.texture.compareFunction?v.sampleType=xN:v.sampleType="depth";else{var g=u.texture.type;g===c.ya?v.sampleType="sint":g===c.za?v.sampleType="uint":g===c.Aa&&(this.backend.hasFeature("float32-filterable")?v.sampleType="float":v.sampleType=xN)}u.isSampledCubeTexture?v.viewDimension=xw:u.texture.isArrayTexture||u.texture.isDataArrayTexture||u.texture.isCompressedArrayTexture?v.viewDimension=xk:u.isSampledTexture3D&&(v.viewDimension="3d"),d.texture=v}else if(u.isSampler){var m={};u.texture.isDepthTexture&&(null!==u.texture.compareFunction&&l.hasCompatibility(c.rc.TEXTURE_COMPARE)?m.type="comparison":m.type="non-filtering"),d.sampler=m}else(0,c.xc)('WebGPUBindingUtils: Unsupported binding "'.concat(u,'".'));t.push(d),r++}}catch(e){i=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw a}}return t}},{key:"deleteBindGroupData",value:function(e){var t=this.backend.get(e);t.layout&&(t.layout.usedTimes--,0===t.layout.usedTimes&&this._bindGroupLayoutCache.delete(t.layoutKey),t.layout=void 0,t.layoutKey=void 0)}},{key:"dispose",value:function(){this._bindGroupLayoutCache.clear()}}]),e}(),_V=function(){function e(t){v(this,e),this.backend=t}return y(e,[{key:"getMaxAnisotropy",value:function(){return 16}},{key:"getUniformBufferLimit",value:function(){return this.backend.device.limits.maxUniformBufferBindingSize}}]),e}(),_G=new(function(){function e(){v(this,e),this.label="",this.layout=null,this.compute=null}return y(e,[{key:"reset",value:function(){this.label="",this.layout=null,this.compute=null}}]),e}()),_z=new(function(){function e(){v(this,e),this.label="",this.bindGroupLayouts=null}return y(e,[{key:"reset",value:function(){this.label="",this.bindGroupLayouts=null}}]),e}()),_W=new xG,_H=new xH,_q=function(){function e(t){v(this,e),this.backend=t}return y(e,[{key:"_getSampleCount",value:function(e){return this.backend.utils.getSampleCountRenderContext(e)}},{key:"createRenderPipeline",value:function(e,t){var r=this,n=e.object,i=e.geometry,a=e.pipeline,o=e.drawMaterial,s=a.vertexProgram,u=a.fragmentProgram,l=this.backend,d=l.device,h=l.utils,p=l.get(a),v=[],g=!0,m=!1,y=void 0;try{for(var b,x=e.getBindings()[Symbol.iterator]();!(g=(b=x.next()).done);g=!0){var _=b.value,T=l.get(_).layout.layoutGPU;v.push(T)}}catch(e){m=!0,y=e}finally{try{g||null==x.return||x.return()}finally{if(m)throw y}}var S,N=l.attributeUtils.createShaderVertexBuffers(e);o.blending!==c.m&&(o.blending!==c.n||!1!==o.transparent)&&(S=this._getBlending(o));var k={};!0===o.stencilWrite&&(k={compare:this._getStencilCompare(o),failOp:this._getStencilOperation(o.stencilFail),depthFailOp:this._getStencilOperation(o.stencilZFail),passOp:this._getStencilOperation(o.stencilZPass)});var w=this._getColorWriteMask(o),A=[];if(null!==e.context.textures)for(var E=e.context.textures,R=e.context.mrt,C=0;C<E.length;C++){var M=void 0,F=E[C],B=h.getTextureFormatGPU(F);if(null!==R)if(!0!==this.backend.compatibilityMode){var L=R.getBlendMode(F.name);L.blending===c.s?M=S:L.blending!==c.m&&(M=this._getBlending(L))}else(0,c.yc)("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),M=S;else M=S;A.push({format:B,blend:M,writeMask:w})}else{var D=h.getCurrentColorFormat(e.context);A.push({format:D,blend:S,writeMask:w})}var U=l.get(s).module,O=l.get(u).module,I=this._getPrimitiveState(n,i,o),V=this._getDepthCompare(o),G=h.getCurrentDepthStencilFormat(e.context),z=this._getSampleCount(e.context);_z.bindGroupLayouts=v;var W=d.createPipelineLayout(_z);_z.reset(),_H.label="renderPipeline_".concat(o.name||o.type,"_").concat(o.id),_H.vertex=Object.assign({},U,{buffers:N}),_H.fragment=Object.assign({},O,{targets:A}),_H.primitive=I,_H.multisample.count=z,_H.multisample.alphaToCoverageEnabled=o.alphaToCoverage&&z>1,_H.layout=W;var H={},q=e.context.depth,j=e.context.stencil;(!0===q||!0===j)&&(!0===q&&(H.format=G,H.depthWriteEnabled=o.depthWrite,H.depthCompare=V),!0===j&&(H.stencilFront=k,H.stencilBack=k,H.stencilReadMask=o.stencilFuncMask,H.stencilWriteMask=o.stencilWriteMask),!0===o.polygonOffset&&I.topology===yD&&(H.depthBias=o.polygonOffsetUnits,H.depthBiasSlopeScale=o.polygonOffsetFactor,H.depthBiasClamp=0),_H.depthStencil=H),d.pushErrorScope("validation");var X=[{program:s,module:U.module},{program:u,module:O.module}],K=_H.label;if(null===t)p.pipeline=d.createRenderPipeline(_H),_H.reset(),d.popErrorScope().then(function(e){null!==e&&(p.error=!0,(0,c.xc)("WebGPURenderer: Render pipeline creation failed (".concat(K,"): ").concat(e.message)),r._reportShaderDiagnostics(X,K))});else{var Y=d.createRenderPipelineAsync(_H),Q=d.popErrorScope();_H.reset();var Z=new Promise(function(e){return f(function(){var t,r,n;return P(this,function(i){switch(i.label){case 0:i.trys.push([0,,8,9]),t=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,Y];case 2:return p.pipeline=i.sent(),[3,4];case 3:return t=i.sent(),[3,4];case 4:return[4,Q];case 5:if(null===(r=i.sent())&&null===t)return[3,7];return p.error=!0,n=r&&r.message||t&&t.message||"unknown",(0,c.xc)("WebGPURenderer: Async render pipeline creation failed (".concat(K,"): ").concat(n)),[4,this._reportShaderDiagnostics(X,K)];case 6:i.sent(),i.label=7;case 7:return[3,9];case 8:return e(),[7];case 9:return[2]}})}).call(r)});t.push(Z)}}},{key:"createBundleEncoder",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"renderBundleEncoder",r=this.backend,n=r.utils,i=r.device,a=n.getCurrentDepthStencilFormat(e),o=n.getCurrentColorFormats(e),s=this._getSampleCount(e);_W.label=t,_W.colorFormats=o,_W.depthStencilFormat=a,_W.sampleCount=s;var u=i.createRenderBundleEncoder(_W);return _W.reset(),u}},{key:"createComputePipeline",value:function(e,t){var r=this,n=this.backend,i=n.device,a=n.get(e.computeProgram).module,o=n.get(e),s=[],u=!0,l=!1,d=void 0;try{for(var h,f=t[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var p=h.value,v=n.get(p).layout.layoutGPU;s.push(v)}}catch(e){l=!0,d=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw d}}var g=e.computeProgram,m="computePipeline_".concat(g.stage).concat(g.name?"_".concat(g.name):"");i.pushErrorScope("validation"),_z.bindGroupLayouts=s;var y=i.createPipelineLayout(_z);_z.reset(),_G.label=m,_G.compute=a,_G.layout=y,o.pipeline=i.createComputePipeline(_G),_G.reset(),i.popErrorScope().then(function(e){null!==e&&(o.error=!0,(0,c.xc)("WebGPURenderer: Compute pipeline creation failed (".concat(m,"): ").concat(e.message)),r._reportShaderDiagnostics([{program:g,module:a.module}],m))})}},{key:"_reportShaderDiagnostics",value:function(e,t){return f(function(){var r,n,i,a,o,s,u,l,d,h,f,p,v,g,m,y,b,x,_;return P(this,function(T){switch(T.label){case 0:r=!0,n=!1,i=void 0,T.label=1;case 1:T.trys.push([1,6,7,8]),a=e[Symbol.iterator](),T.label=2;case 2:if(r=(o=a.next()).done)return[3,5];return u=(s=o.value).program,[4,s.module.getCompilationInfo()];case 3:if(0===(l=T.sent()).messages.length)return[3,4];d=u.code.split("\n"),h=!0,f=!1,p=void 0;try{for(v=l.messages[Symbol.iterator]();!(h=(g=v.next()).done);h=!0)y=(m=g.value).lineNum>0?" at line ".concat(m.lineNum).concat(m.linePos>0?":".concat(m.linePos):""):"",b="WebGPURenderer [".concat(t," / ").concat(u.stage," ").concat(m.type,"]").concat(y,": ").concat(m.message),x="",m.lineNum>0&&m.lineNum<=d.length&&(x="\n ".concat(d[m.lineNum-1]),m.linePos>0&&(x+="\n ".concat(" ".repeat(m.linePos-1),"^"))),("error"===m.type?c.xc:c.wc)(b+x)}catch(e){f=!0,p=e}finally{try{h||null==v.return||v.return()}finally{if(f)throw p}}T.label=4;case 4:return r=!0,[3,2];case 5:return[3,8];case 6:return _=T.sent(),n=!0,i=_,[3,8];case 7:try{r||null==a.return||a.return()}finally{if(n)throw i}return[7];case 8:return[2]}})})()}},{key:"_getBlending",value:function(e){var t,r,n=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(n===c.r){var s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,u=null!==e.blendDstAlpha?e.blendDstAlpha:a,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:o;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(u),operation:this._getBlendOperation(l)}}else{var d=function(e,n,i,a){t={srcFactor:e,dstFactor:n,operation:"add"},r={srcFactor:i,dstFactor:a,operation:"add"}};if(e.premultipliedAlpha)switch(n){case c.n:d("one",xS,"one",xS);break;case c.o:d("one","one","one","one");break;case c.p:d(xx,x_,xx,"one");break;case c.q:d("dst",xS,xx,"one")}else switch(n){case c.n:d(xT,xS,"one",xS);break;case c.o:d(xT,"one","one","one");break;case c.p:(0,c.xc)('WebGPURenderer: "SubtractiveBlending" requires "'.concat(e.isMaterial?"material":"blendMode",'.premultipliedAlpha = true".'));break;case c.q:(0,c.xc)('WebGPURenderer: "MultiplyBlending" requires "'.concat(e.isMaterial?"material":"blendMode",'.premultipliedAlpha = true".'))}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};(0,c.xc)("WebGPURenderer: Invalid blending: ",n)}},{key:"_getBlendFactor",value:function(e){var t;switch(e){case c.y:t=xx;break;case c.z:t="one";break;case c.A:t="src";break;case c.B:t=x_;break;case c.C:t=xT;break;case c.D:t=xS;break;case c.G:t="dst";break;case c.H:t="one-minus-dst";break;case c.E:t="dst-alpha";break;case c.F:t="one-minus-dst-alpha";break;case c.I:t="src-alpha-saturated";break;case 211:t="constant";break;case 212:t="one-minus-constant";break;default:(0,c.xc)("WebGPURenderer: Blend factor not supported.",e)}return t}},{key:"_getStencilCompare",value:function(e){var t,r=e.stencilFunc;switch(r){case c.Xb:t=yO;break;case c.cc:t=yq;break;case c.Yb:t=yI;break;case c._b:t=yG;break;case c.Zb:t=yV;break;case c.bc:t=yH;break;case c.$b:t=yz;break;case c.ac:t=yW;break;default:(0,c.xc)("WebGPURenderer: Invalid stencil function.",r)}return t}},{key:"_getStencilOperation",value:function(e){var t;switch(e){case c.Qb:t="keep";break;case c.Pb:t="zero";break;case c.Rb:t="replace";break;case c.Wb:t="invert";break;case c.Sb:t="increment-clamp";break;case c.Tb:t="decrement-clamp";break;case c.Ub:t="increment-wrap";break;case c.Vb:t="decrement-wrap";break;default:(0,c.xc)("WebGPURenderer: Invalid stencil operation.",t)}return t}},{key:"_getBlendOperation",value:function(e){var t;switch(e){case c.t:t="add";break;case c.u:t="subtract";break;case c.v:t="reverse-subtract";break;case c.w:t="min";break;case c.x:t="max";break;default:(0,c.xc)("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}},{key:"_getPrimitiveState",value:function(e,t,r){var n={};n.topology=this.backend.utils.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(n.stripIndexFormat=yY);var i=r.side===c.k;return e.isMesh&&0>e.matrixWorld.determinantAffine()&&(i=!i),n.frontFace=!0===i?"cw":"ccw",n.cullMode=r.side===c.l?"none":"back",n}},{key:"_getColorWriteMask",value:function(e){return 15*(!0===e.colorWrite)}},{key:"_getDepthCompare",value:function(e){var t;if(!1===e.depthTest)t=yq;else{var r=this.backend.parameters.reversedDepthBuffer?c.Ac[e.depthFunc]:e.depthFunc;switch(r){case c.N:t=yO;break;case c.O:t=yq;break;case c.P:t=yI;break;case c.Q:t=yG;break;case c.R:t=yV;break;case c.S:t=yH;break;case c.T:t=yz;break;case c.U:t=yW;break;default:(0,c.xc)("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}]),e}(),_j=function(){function e(){v(this,e),this.label="",this.type=void 0,this.count=0}return y(e,[{key:"reset",value:function(){this.label="",this.type=void 0,this.count=0}}]),e}(),_X=new xI,_K=new xV,_Y=new _j,_Q=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2048;v(this,t),(n=p(this,t,[i])).device=e,n.type=r,_Y.label="queryset_global_timestamp_".concat(r),_Y.type="timestamp",_Y.count=n.maxQueries,n.querySet=n.device.createQuerySet(_Y),_Y.reset();var a=8*n.maxQueries;return _X.label="buffer_timestamp_resolve_".concat(r),_X.size=a,_X.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,n.resolveBuffer=n.device.createBuffer(_X),_X.reset(),_X.label="buffer_timestamp_result_".concat(r),_X.size=a,_X.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,n.resultBuffer=n.device.createBuffer(_X),_X.reset(),n}return T(t,e),y(t,[{key:"allocateQueriesForContext",value:function(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,c.yc)("WebGPUTimestampQueryPool [".concat(this.type,"]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.").concat(this.type.toUpperCase()," ).")),null;var t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}},{key:"resolveQueriesAsync",value:function(){return f(function(){return P(this,function(e){switch(e.label){case 0:if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return[2,this.lastValue];if(this.pendingResolve)return[2,this.pendingResolve];this.pendingResolve=this._resolveQueries(),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,this.pendingResolve];case 2:return[2,e.sent()];case 3:return this.pendingResolve=null,[7];case 4:return[2]}})}).call(this)}},{key:"_resolveQueries",value:function(){return f(function(){var e,t,r,n,i,a,o,s,u,l,d,h,f,p,v,g,m,y,b,x,_,T,S;return P(this,function(N){switch(N.label){case 0:if(this.isDisposed)return[2,this.lastValue];N.label=1;case 1:if(N.trys.push([1,3,,4]),"unmapped"!==this.resultBuffer.mapState||(e=new Map(this.queryOffsets),r=8*(t=this.currentQueryIndex),this.currentQueryIndex=0,this.queryOffsets.clear(),(n=this.device.createCommandEncoder(_K)).resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),n.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r),i=n.finish(),xU(this.device,i),"unmapped"!==this.resultBuffer.mapState))return[2,this.lastValue];return[4,this.resultBuffer.mapAsync(GPUMapMode.READ,0,r)];case 2:if(N.sent(),this.isDisposed)return[2,("mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue)];a=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),o={},s=[],u=!0,l=!1,d=void 0;try{for(h=e[Symbol.iterator]();!(u=(f=h.next()).done);u=!0)v=(p=E(f.value,2))[0],g=p[1],m=v.match(/^(.*):f(\d+)$/),y=parseInt(m[2]),!1===s.includes(y)&&s.push(y),void 0===o[y]&&(o[y]=0),b=a[g],x=a[g+1],_=Number(x-b)/1e6,this.timestamps.set(v,_),o[y]+=_}catch(e){l=!0,d=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw d}}return T=o[s[s.length-1]],[2,(this.resultBuffer.unmap(),this.lastValue=T,this.frames=s,T)];case 3:return S=N.sent(),[2,((0,c.xc)("Error resolving queries:",S),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue)];case 4:return[2]}})}).call(this)}},{key:"dispose",value:function(){return f(function(){var e;return P(this,function(t){switch(t.label){case 0:if(this.isDisposed)return[3,5];if(this.isDisposed=!0,!this.pendingResolve)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.pendingResolve];case 2:return t.sent(),[3,4];case 3:return e=t.sent(),(0,c.xc)("Error waiting for pending resolve:",e),[3,4];case 4:if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){(0,c.xc)("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null,t.label=5;case 5:return[2]}})}).call(this)}}]),t}(yB),_Z=function(){function e(){v(this,e),this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}return y(e,[{key:"reset",value:function(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}]),e}(),_J={r:0,g:0,b:0,a:1},_$=new xI,_0=new xV,_1=new(function(){function e(){v(this,e),this.label="",this.timestampWrites=void 0}return y(e,[{key:"reset",value:function(){this.label="",this.timestampWrites=void 0}}]),e}()),_2=new _j,_3=new xj,_4=new(function(){function e(){v(this,e),this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}return y(e,[{key:"reset",value:function(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}}]),e}()),_5=new x6,_6=new x6,_8=new xK,_9=new x8,_7=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v(this,t),(e=p(this,t,[r])).isWebGPUBackend=!0,e.parameters.alpha=void 0===r.alpha||r.alpha,e.parameters.requiredLimits=void 0===r.requiredLimits?{}:r.requiredLimits,e.compatibilityMode=null,e.device=null,e.defaultRenderPassdescriptor=null,e.utils=new xD(e),e.attributeUtils=new _P(e),e.bindingUtils=new _I(e),e.capabilities=new _V(e),e.pipelineUtils=new _q(e),e.textureUtils=new _d(e),e.occludedResolveCache=new Map;var n=("u"<typeof navigator?"undefined":C(navigator))>"u"||!1===/Android/.test(navigator.userAgent);return e._compatibility=b({},c.rc.TEXTURE_COMPARE,n),e}return T(t,e),y(t,[{key:"init",value:function(e){var r=this,n=this;return f(function(){var i,a,o,s,u,l,c,d,h,f,p,v,g,m;return P(this,function(y){switch(y.label){case 0:return[4,x(_(t.prototype),"init",r).call(n,e)];case 1:if(y.sent(),void 0!==(a=this.parameters).device)return[3,6];if(o={powerPreference:a.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},!(("u"<typeof navigator?"undefined":C(navigator))<"u"))return[3,3];return[4,navigator.gpu.requestAdapter(o)];case 2:return u=y.sent(),[3,4];case 3:u=null,y.label=4;case 4:if(null===(s=u))throw Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");l=Object.values(xR),c=[],d=!0,h=!1,f=void 0;try{for(p=l[Symbol.iterator]();!(d=(v=p.next()).done);d=!0)g=v.value,s.features.has(g)&&c.push(g)}catch(e){h=!0,f=e}finally{try{d||null==p.return||p.return()}finally{if(h)throw f}}return m={requiredFeatures:c,requiredLimits:a.requiredLimits},this.adapter=s,[4,s.requestDevice(m)];case 5:return i=y.sent(),[3,7];case 6:i=a.device,y.label=7;case 7:return this.compatibilityMode=!i.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),i.lost.then(function(t){if("destroyed"!==t.reason){var r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}}),i.onuncapturederror=function(t){var r=t.error,n=r&&r.constructor?r.constructor.name:"GPUError",i=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:n,message:i,originalEvent:t})},this.device=i,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(xR.TimestampQuery),this.updateSize(),[2]}})}).call(this)}},{key:"setXRRenderTargetTextures",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}},{key:"context",get:function(){var e=this.renderer.getCanvasTarget(),t=this.get(e),r=t.context;if(void 0===r){var n=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==n.context?n.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine","three.js r".concat(c.a," webgpu"));var i=n.alpha?"premultiplied":"opaque",a=n.outputType===c.Ba?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,colorSpace:n.canvasColorSpace||"srgb",toneMapping:{mode:a}}),t.context=r}return r}},{key:"coordinateSystem",get:function(){return c.pc}},{key:"hasTimestamp",get:function(){return!0}},{key:"getArrayBufferAsync",value:function(e){return f(function(e){var t,r,n,i=arguments;return P(this,function(a){switch(a.label){case 0:return t=i.length>1&&void 0!==i[1]?i[1]:null,r=i.length>2&&void 0!==i[2]?i[2]:0,n=i.length>3&&void 0!==i[3]?i[3]:-1,[4,this.attributeUtils.getArrayBufferAsync(e,t,r,n)];case 1:return[2,a.sent()]}})}).apply(this,arguments)}},{key:"getContext",value:function(){return this.context}},{key:"_getDefaultRenderPassDescriptor",value:function(){var e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),n=e.currentSamples,i=r.descriptor;if(void 0===i||r.samples!==n){if((i=new xW).colorAttachments.push(new xz),!0===e.depth||!0===e.stencil){var a=new _Z;a.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=a}var o=i.colorAttachments[0];n>0?o.view=this.textureUtils.getColorBuffer().createView():o.resolveTarget=void 0,r.descriptor=i,r.samples=n}var s=i.colorAttachments[0];return n>0?s.resolveTarget=this.context.getCurrentTexture().createView():s.view=this.context.getCurrentTexture().createView(),i}},{key:"_isRenderCameraDepthArray",value:function(e){var t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}},{key:"_hasExternalTexture",value:function(e){var t=e.textures;if(null===t)return!1;for(var r=0;r<t.length;r++)if(!0===this.get(t[r]).externalTexture)return!0;return!1}},{key:"_createExternalTextureViews",value:function(e,t){var r=[],n=e.camera;if(t.xrViewDescriptors&&null!==n&&!0===n.isArrayCamera)for(var i=0;i<t.xrViewDescriptors.length;i++)r.push({view:t.texture.createView(t.xrViewDescriptors[i]),resolveTarget:void 0,depthSlice:void 0});else r.push({view:t.texture.createView({dimension:"2d",baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return r}},{key:"_getRenderPassDescriptor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.renderTarget,n=this.get(r),i=this._hasExternalTexture(e),a=n.descriptors;(void 0===a||n.width!==r.width||n.height!==r.height||n.samples!==r.samples||i)&&(n.descriptors=a={});var o=e.getCacheKey(),s=a[o];if(void 0===s||i){for(var u,l=e.textures,c=[],d=this._isRenderCameraDepthArray(e),h=0;h<l.length;h++){var f=this.get(l[h]);if(!0!==f.externalTexture){if(_8.label="colorAttachment_".concat(h),_8.baseMipLevel=e.activeMipmapLevel,_8.mipLevelCount=1,_8.baseArrayLayer=e.activeCubeFace,_8.arrayLayerCount=1,_8.dimension="2d",r.isRenderTarget3D)u=e.activeCubeFace,_8.baseArrayLayer=0,_8.dimension="3d";else if(r.isRenderTarget&&l[h].image.depth>1)if(!0===d)for(var p=e.camera.cameras,v=0;v<p.length;v++){_8.baseArrayLayer=v,_8.arrayLayerCount=1,_8.dimension="2d";var g=f.texture.createView(_8);c.push({view:g,resolveTarget:void 0,depthSlice:void 0})}else _8.dimension=xk;if(!0!==d){var m=void 0,y=void 0,b=f.texture.createView(_8);void 0!==f.msaaTexture?(m=f.msaaTexture.createView(),y=b):(m=b,y=void 0),c.push({view:m,resolveTarget:y,depthSlice:u})}_8.reset()}else c.push.apply(c,R(this._createExternalTextureViews(e,f)))}for(var x=[],_=0;_<c.length;_++){var T=c[_],S=new xz;S.view=T.view,S.depthSlice=T.depthSlice,S.resolveTarget=T.resolveTarget,x.push(S)}if(s={textureViews:c,colorAttachments:x,descriptor:new xW},e.depth){var N=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(_8.dimension="2d",_8.arrayLayerCount=1,_8.baseArrayLayer=e.activeCubeFace);var k=new _Z;k.view=N.texture.createView(_8),s.depthStencilAttachment=k,_8.reset()}a[o]=s,n.width=r.width,n.height=r.height,n.samples=r.samples,n.activeMipmapLevel=e.activeMipmapLevel,n.activeCubeFace=e.activeCubeFace}var w=s.descriptor;w.reset();for(var A=0;A<s.colorAttachments.length;A++){var E=s.colorAttachments[A],C={r:0,g:0,b:0,a:1};0===A&&t.clearValue&&(C=t.clearValue),E.loadOp=t.loadOp||yX,E.storeOp=t.storeOp||yj,E.clearValue=C,w.colorAttachments.push(E)}return s.depthStencilAttachment&&(w.depthStencilAttachment=s.depthStencilAttachment),w}},{key:"beginRender",value:function(e){var t,r,n=this.get(e),i=this.device,a=e.occlusionQueryCount;a>0&&(n.currentOcclusionQuerySet&&n.currentOcclusionQuerySet.destroy(),n.currentOcclusionQueryBuffer&&n.currentOcclusionQueryBuffer.destroy(),n.currentOcclusionQuerySet=n.occlusionQuerySet,n.currentOcclusionQueryBuffer=n.occlusionQueryBuffer,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,_2.label="occlusionQuerySet_".concat(e.id),_2.type="occlusion",_2.count=a,t=i.createQuerySet(_2),_2.reset(),n.occlusionQuerySet=t,n.occlusionQueryIndex=0,n.occlusionQueryObjects=Array(a),n.lastOcclusionObject=null),r=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:yX}),this.initTimestampQuery(c.qc.RENDER,this.getTimestampUID(e),r),r.occlusionQuerySet=t;var o=r.depthStencilAttachment;if(null!==e.textures)for(var s=r.colorAttachments,u=0;u<s.length;u++){var l=s[u];e.clearColor?(0===u?l.clearValue=e.clearColorValue:(_J.r=0,_J.g=0,_J.b=0,_J.a=1,l.clearValue=_J),l.loadOp=yK):l.loadOp=yX,l.storeOp=yj}else{var d=r.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=yK):d.loadOp=yX,d.storeOp=yj}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=yK):o.depthLoadOp=yX,o.depthStoreOp=yj),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=yK):o.stencilLoadOp=yX,o.stencilStoreOp=yj),_0.label="renderContext_"+e.id;var h=i.createCommandEncoder(_0);if(_0.reset(),!0===this._isRenderCameraDepthArray(e)){var f=e.camera.cameras;n.layerDescriptors&&n.layerDescriptors.length===f.length?this._updateArrayCameraLayerDescriptors(e,n,f):this._createArrayCameraLayerDescriptors(e,n,r,f),n.bundleEncoders=[],n.bundleSets=[];for(var p=0;p<f.length;p++){var v=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+p),g={attributes:{},bindingGroups:[],pipeline:null,index:null};n.bundleEncoders.push(v),n.bundleSets.push(g)}n.currentPass=null}else n.currentPass=h.beginRenderPass(r),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);n.descriptor=r,n.encoder=h,n.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},n.renderBundles=[]}},{key:"_createArrayCameraLayerDescriptors",value:function(e,t,r,n){var i=r.depthStencilAttachment;t.layerDescriptors=[];var a=this.get(e.depthTexture);a.viewCache||(a.viewCache=[]);for(var o=0;o<n.length;o++){var s=r.colorAttachments[0],u=new xz;u.view=r.colorAttachments[o].view,u.depthSlice=s.depthSlice,u.resolveTarget=s.resolveTarget,u.loadOp=s.loadOp,u.storeOp=s.storeOp,u.clearValue=s.clearValue;var l=new xW;if(l.label=r.label,l.occlusionQuerySet=r.occlusionQuerySet,l.timestampWrites=r.timestampWrites,l.colorAttachments.push(u),r.depthStencilAttachment){var c=o;a.viewCache[c]||(_8.dimension="2d",_8.baseArrayLayer=o,_8.arrayLayerCount=1,a.viewCache[c]=a.texture.createView(_8),_8.reset());var d=new _Z;d.view=a.viewCache[c],d.depthLoadOp=i.depthLoadOp||yK,d.depthStoreOp=i.depthStoreOp||yj,d.depthClearValue=i.depthClearValue||1,e.stencil&&(d.stencilLoadOp=i.stencilLoadOp,d.stencilStoreOp=i.stencilStoreOp,d.stencilClearValue=i.stencilClearValue),l.depthStencilAttachment=d}else{var h=new _Z;h.view=i.view,h.depthLoadOp=i.depthLoadOp,h.depthStoreOp=i.depthStoreOp,h.depthClearValue=i.depthClearValue,h.depthReadOnly=i.depthReadOnly,h.stencilLoadOp=i.stencilLoadOp,h.stencilStoreOp=i.stencilStoreOp,h.stencilClearValue=i.stencilClearValue,h.stencilReadOnly=i.stencilReadOnly,l.depthStencilAttachment=h}t.layerDescriptors.push(l)}}},{key:"_updateArrayCameraLayerDescriptors",value:function(e,t,r){for(var n=0;n<r.length;n++){var i=t.layerDescriptors[n];if(i.depthStencilAttachment){var a=i.depthStencilAttachment;e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=yK):a.depthLoadOp=yX),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=yK):a.stencilLoadOp=yX)}}}},{key:"finishRender",value:function(e){var t=this.get(e),r=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();var n=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){for(var i=[],a=0;a<t.bundleEncoders.length;a++){var o=t.bundleEncoders[a];i.push(o.finish())}for(var s=0;s<t.layerDescriptors.length;s++)if(s<i.length){var u=t.layerDescriptors[s],l=n.beginRenderPass(u);if(e.viewport){var c=e.viewportValue,d=c.x,h=c.y,f=c.width,p=c.height,v=c.minDepth,g=c.maxDepth;l.setViewport(d,h,f,p,v,g)}if(e.scissor){var m=e.scissorValue,y=m.x,b=m.y,x=m.width,_=m.height;l.setScissorRect(y,b,x,_)}l.executeBundles([i[s]]),l.end()}}else t.currentPass&&t.currentPass.end();if(r>0){var T=8*r,S=this.occludedResolveCache.get(T);void 0===S&&(_$.size=T,_$.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,S=this.device.createBuffer(_$),_$.reset(),this.occludedResolveCache.set(T,S)),_$.size=T,_$.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;var N=this.device.createBuffer(_$);_$.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,S,0),t.encoder.copyBufferToBuffer(S,0,N,0,T),t.occlusionQueryBuffer=N,this.resolveOccludedAsync(e)}if(xU(this.device,t.encoder.finish()),null!==e.textures)for(var k=e.textures,w=0;w<k.length;w++){var A=k[w];!0===A.generateMipmaps&&this.textureUtils.generateMipmaps(A)}}},{key:"isOccluded",value:function(e,t){var r=this.get(e);return r.occluded&&r.occluded.has(t)}},{key:"resolveOccludedAsync",value:function(e){return f(function(){var t,r,n,i,a,o;return P(this,function(s){switch(s.label){case 0:if(r=(t=this.get(e)).currentOcclusionQueryBuffer,n=t.currentOcclusionQueryObjects,!(r&&n))return[3,2];return i=new WeakSet,t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,[4,r.mapAsync(GPUMapMode.READ)];case 1:for(s.sent(),a=new BigUint64Array(r.getMappedRange()),o=0;o<n.length;o++)a[o]===BigInt(0)&&i.add(n[o]);r.destroy(),t.occluded=i,s.label=2;case 2:return[2]}})}).call(this)}},{key:"updateViewport",value:function(e){var t=this.get(e).currentPass,r=e.viewportValue,n=r.x,i=r.y,a=r.width,o=r.height,s=r.minDepth,u=r.maxDepth;t.setViewport(n,i,a,o,s,u)}},{key:"updateScissor",value:function(e){var t=this.get(e).currentPass,r=e.scissorValue,n=r.x,i=r.y,a=r.width,o=r.height;t.setScissorRect(n,i,a,o)}},{key:"getClearColor",value:function(){var e=x(_(t.prototype),"getClearColor",this).call(this);return!0===this.renderer.alpha&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}},{key:"clear",value:function(e,t,r){var n,i,a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=this.device,u=this.renderer,l=[];if(e){var c=this.getClearColor();_J.r=c.r,_J.g=c.g,_J.b=c.b,_J.a=c.a}if(null===o){i=u.depth,a=u.stencil;var d=this._getDefaultRenderPassDescriptor();if(e){var h=(l=d.colorAttachments)[0];h.clearValue=_J,h.loadOp=yK,h.storeOp=yj}(i||a)&&(n=d.depthStencilAttachment)}else{i=o.depth,a=o.stencil;var f={loadOp:e?yK:yX,clearValue:e?_J:void 0};i&&(f.depthLoadOp=t?yK:yX,f.depthClearValue=t?u.getClearDepth():void 0,f.depthStoreOp=yj),a&&(f.stencilLoadOp=r?yK:yX,f.stencilClearValue=r?u.getClearStencil():void 0,f.stencilStoreOp=yj);var p=this._getRenderPassDescriptor(o,f);l=p.colorAttachments,n=p.depthStencilAttachment}i&&n&&(t?(n.depthLoadOp=yK,n.depthClearValue=u.getClearDepth()):n.depthLoadOp=yX,n.depthStoreOp=yj),a&&n&&(r?(n.stencilLoadOp=yK,n.stencilClearValue=u.getClearStencil()):n.stencilLoadOp=yX,n.stencilStoreOp=yj),_0.label="clear";var v=s.createCommandEncoder(_0);_0.reset(),v.beginRenderPass({colorAttachments:l,depthStencilAttachment:n}).end(),xU(s,v.finish())}},{key:"beginCompute",value:function(e){var t=this.get(e),r="computeGroup_"+e.id;_1.label=r,_0.label=r,this.initTimestampQuery(c.qc.COMPUTE,this.getTimestampUID(e),_1),t.cmdEncoderGPU=this.device.createCommandEncoder(_0),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(_1),t.currentPipeline=null,_0.reset(),_1.reset()}},{key:"compute",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=this.get(t),o=this.get(e),s=o.passEncoderGPU,u=this.get(n).pipeline;o.currentPipeline!==u&&(s.setPipeline(u),o.currentPipeline=u);for(var l=0,c=r.length;l<c;l++){var d=r[l],h=this.get(d);s.setBindGroup(l,h.group)}if(null===i&&(i=t.dispatchSize||t.count),i&&i.isIndirectStorageBufferAttribute){var f=this.get(i).buffer;return void s.dispatchWorkgroupsIndirect(f,0)}if("number"==typeof i){var p=i;if(void 0===a.dispatchSize||a.count!==p){a.dispatchSize=[0,1,1],a.count=p;for(var v=t.workgroupSize,g=v[0],m=1;m<v.length;m++)g*=v[m];var y=Math.ceil(p/g),b=this.device.limits.maxComputeWorkgroupsPerDimension;i=[y,1,1],y>b&&(i[0]=Math.min(y,b),i[1]=Math.ceil(y/b)),a.dispatchSize=i}i=a.dispatchSize}s.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}},{key:"finishCompute",value:function(e){var t=this.get(e);t.passEncoderGPU.end(),xU(this.device,t.cmdEncoderGPU.finish())}},{key:"_draw",value:function(e,t,r,n,i,a,o,s,u){var l=e.object,c=e.context,d=e.drawMaterial,h=e.getIndex(),f=null!==h;u.pipeline!==n&&(s.setPipeline(n),u.pipeline=n);for(var p=u.bindingGroups,v=0,g=i.length;v<g;v++){var m=i[v];if(p[v]!==m.id){var y=this.get(m);s.setBindGroup(v,y.group),p[v]=m.id}}if(!0===f&&u.index!==h){var b=this.get(h).buffer,x=S(h.array,Uint16Array)?"uint16":yY;s.setIndexBuffer(b,x),u.index=h}for(var _=0,T=a.length;_<T;_++){var N=a[_];if(u.attributes[_]!==N){var k=this.get(N).buffer;s.setVertexBuffer(_,k),u.attributes[_]=N}}if(!0===c.stencil&&!0===d.stencilWrite&&r.currentStencilRef!==d.stencilRef&&(s.setStencilReference(d.stencilRef),r.currentStencilRef=d.stencilRef),!0===l.isBatchedMesh){var w=l._multiDrawStarts,A=l._multiDrawCounts,E=l._multiDrawCount,R=!0===f?h.array.BYTES_PER_ELEMENT:1;d.wireframe&&(R=l.geometry.attributes.position.count>65535?4:2);for(var C=0;C<E;C++)!0===f?s.drawIndexed(A[C],1,w[C]/R,0,C):s.draw(A[C],1,w[C],C),t.update(l,A[C],1)}else if(!0===f){var M=o.vertexCount,F=o.instanceCount,B=o.firstVertex,P=e.getIndirect();if(null!==P)for(var L=this.get(P).buffer,D=e.getIndirectOffset(),U=Array.isArray(D)?D:[D],O=0;O<U.length;O++)s.drawIndexedIndirect(L,U[O]);else s.drawIndexed(M,F,B,0,0);t.update(l,M,F)}else{var I=o.vertexCount,V=o.instanceCount,G=o.firstVertex,z=e.getIndirect();if(null!==z)for(var W=this.get(z).buffer,H=e.getIndirectOffset(),q=Array.isArray(H)?H:[H],j=0;j<q.length;j++)s.drawIndirect(W,q[j]);else s.draw(I,V,G,0);t.update(l,I,V)}}},{key:"draw",value:function(e,t){var r=e.object,n=e.context,i=e.pipeline,a=this.get(n),o=this.get(i),s=o.pipeline;if(!0!==o.error){var u=e.getDrawParameters();if(null!==u){var l=e.getBindings(),c=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){var d=this.get(e.camera),h=e.camera.cameras,f=e.getBindingGroup("cameraIndex");if(void 0===d.indexesGPU||d.indexesGPU.length!==h.length){for(var p=this.get(f),v=[],g=new Uint32Array([0,0,0,0]),m=0,y=h.length;m<y;m++){g[0]=m;var b=p.layout.layoutGPU,x=this.bindingUtils.createBindGroupIndex(g,b);v.push(x)}d.indexesGPU=v}for(var _=this.renderer.getPixelRatio(),T=0,S=h.length;T<S;T++){var N=h[T];if(r.layers.test(N.layers)){var k=N.viewport,w=a.currentPass,A=a.currentSets,E=void 0!==a.bundleEncoders;if(E&&(w=a.bundleEncoders[T],A=a.bundleSets[T]),k&&!E&&w.setViewport(Math.floor(k.x*_),Math.floor(k.y*_),Math.floor(k.width*_),Math.floor(k.height*_),n.viewportValue.minDepth,n.viewportValue.maxDepth),f&&d.indexesGPU){var R=l.indexOf(f);w.setBindGroup(R,d.indexesGPU[T]),A.bindingGroups[R]=f.id}this._draw(e,t,a,s,l,c,u,w,A)}}}else if(a.currentPass){if(void 0!==a.occlusionQuerySet){var C=a.lastOcclusionObject;C!==r&&(null!==C&&!0===C.occlusionTest&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),!0===r.occlusionTest&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=r),a.lastOcclusionObject=r)}this._draw(e,t,a,s,l,c,u,a.currentPass,a.currentSets)}}}}},{key:"needsRenderUpdate",value:function(e){var t=this.get(e),r=e.material,n=!1;return(t.material!==r||t.materialVersion!==r.version)&&(t.material=r,t.materialVersion=r.version,n=!0),this._syncStructuralState(t,e,r)||n}},{key:"_syncStructuralState",value:function(e,t,r){var n=t.object,i=this.utils,a=i.getSampleCountRenderContext(t.context),o=i.getCurrentColorSpace(t.context),s=i.getCurrentColorFormat(t.context),u=i.getCurrentDepthStencilFormat(t.context),l=i.getPrimitiveTopology(n,r),c=n.isMesh&&0>n.matrixWorld.determinantAffine(),d=!1;return(e.transparent!==r.transparent||e.blending!==r.blending||e.premultipliedAlpha!==r.premultipliedAlpha||e.blendSrc!==r.blendSrc||e.blendDst!==r.blendDst||e.blendEquation!==r.blendEquation||e.blendSrcAlpha!==r.blendSrcAlpha||e.blendDstAlpha!==r.blendDstAlpha||e.blendEquationAlpha!==r.blendEquationAlpha||e.colorWrite!==r.colorWrite||e.depthWrite!==r.depthWrite||e.depthTest!==r.depthTest||e.depthFunc!==r.depthFunc||e.stencilWrite!==r.stencilWrite||e.stencilFunc!==r.stencilFunc||e.stencilFail!==r.stencilFail||e.stencilZFail!==r.stencilZFail||e.stencilZPass!==r.stencilZPass||e.stencilFuncMask!==r.stencilFuncMask||e.stencilWriteMask!==r.stencilWriteMask||e.side!==r.side||e.alphaToCoverage!==r.alphaToCoverage||e.polygonOffset!==r.polygonOffset||e.polygonOffsetFactor!==r.polygonOffsetFactor||e.polygonOffsetUnits!==r.polygonOffsetUnits||e.sampleCount!==a||e.colorSpace!==o||e.colorFormat!==s||e.depthStencilFormat!==u||e.primitiveTopology!==l||e.frontFaceCW!==c||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.transparent=r.transparent,e.blending=r.blending,e.premultipliedAlpha=r.premultipliedAlpha,e.blendSrc=r.blendSrc,e.blendDst=r.blendDst,e.blendEquation=r.blendEquation,e.blendSrcAlpha=r.blendSrcAlpha,e.blendDstAlpha=r.blendDstAlpha,e.blendEquationAlpha=r.blendEquationAlpha,e.colorWrite=r.colorWrite,e.depthWrite=r.depthWrite,e.depthTest=r.depthTest,e.depthFunc=r.depthFunc,e.stencilWrite=r.stencilWrite,e.stencilFunc=r.stencilFunc,e.stencilFail=r.stencilFail,e.stencilZFail=r.stencilZFail,e.stencilZPass=r.stencilZPass,e.stencilFuncMask=r.stencilFuncMask,e.stencilWriteMask=r.stencilWriteMask,e.side=r.side,e.alphaToCoverage=r.alphaToCoverage,e.polygonOffset=r.polygonOffset,e.polygonOffsetFactor=r.polygonOffsetFactor,e.polygonOffsetUnits=r.polygonOffsetUnits,e.sampleCount=a,e.colorSpace=o,e.colorFormat=s,e.depthStencilFormat=u,e.primitiveTopology=l,e.frontFaceCW=c,e.clippingContextCacheKey=t.clippingContextCacheKey,d=!0),d}},{key:"detectStructuralChange",value:function(e){return this._syncStructuralState(this.get(e),e,e.material)}},{key:"getAttachmentStateKey",value:function(e){var t=this.utils,r=e.context;return t.getSampleCountRenderContext(r)+","+t.getCurrentColorSpace(r)+","+t.getCurrentColorFormat(r)+","+t.getCurrentDepthStencilFormat(r)}},{key:"syncRenderUpdateState",value:function(e,t){var r=this.get(e);r.material=e.material,r.materialVersion=e.material.version,this._syncStructuralState(r,e,t)}},{key:"getVertexLayoutCacheKey",value:function(e){var t=e.object,r=e.geometry,n="",i=!0,a=!1,o=void 0;try{for(var s,u=this.attributeUtils.createShaderVertexBuffers(e)[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n+=l.stepMode+":"+l.arrayStride+":";var c=!0,d=!1,h=void 0;try{for(var f,p=l.attributes[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var v=f.value;n+=v.shaderLocation+"-"+v.offset+"-"+v.format+","}}catch(e){d=!0,h=e}finally{try{c||null==p.return||p.return()}finally{if(d)throw h}}n+=";"}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return null!==r.index&&!0===t.isLine&&!0!==t.isLineSegments&&(n+=S(r.index.array,Uint16Array)?"index-u16":"index-u32"),n}},{key:"getRenderCacheKey",value:function(e){var t=e.object,r=e.drawMaterial,n=this.utils,i=e.context,a=t.isMesh&&0>t.matrixWorld.determinantAffine(),o=n.getSampleCountRenderContext(i),s=r.blending!==c.m&&(r.blending!==c.n||!1!==r.transparent),u=s&&r.blending===c.r,l=!0===i.depth,d=!0===i.stencil,h=d&&!0===r.stencilWrite,f=n.getPrimitiveTopology(t,r),p=(l||d)&&!0===r.polygonOffset&&f===yD;return[s?r.blending:-1,s&&!1===u?r.premultipliedAlpha:-1,u?r.blendSrc:-1,u?r.blendDst:-1,u?r.blendEquation:-1,u?null!==r.blendSrcAlpha?r.blendSrcAlpha:r.blendSrc:-1,u?null!==r.blendDstAlpha?r.blendDstAlpha:r.blendDst:-1,u?null!==r.blendEquationAlpha?r.blendEquationAlpha:r.blendEquation:-1,r.colorWrite,l?r.depthWrite:-1,l&&!0===r.depthTest?r.depthFunc:-1,h?r.stencilFunc:-1,h?r.stencilFail:-1,h?r.stencilZFail:-1,h?r.stencilZPass:-1,d?r.stencilFuncMask:-1,d?r.stencilWriteMask:-1,p?r.polygonOffsetUnits:0,p?r.polygonOffsetFactor:0,!0===r.alphaToCoverage&&o>1,r.side,a,o,n.getCurrentColorSpace(i),n.getCurrentColorFormat(i),n.getCurrentDepthStencilFormat(i),f,this.getVertexLayoutCacheKey(e),e.clippingContextCacheKey].join()}},{key:"updateSampler",value:function(e){return this.textureUtils.updateSampler(e)}},{key:"destroySampler",value:function(e){this.textureUtils.destroySampler(e)}},{key:"createDefaultTexture",value:function(e){return this.textureUtils.createDefaultTexture(e)}},{key:"createTexture",value:function(e,t){this.textureUtils.createTexture(e,t)}},{key:"updateTexture",value:function(e,t){this.textureUtils.updateTexture(e,t)}},{key:"generateMipmaps",value:function(e){this.textureUtils.generateMipmaps(e)}},{key:"destroyTexture",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.textureUtils.destroyTexture(e,t)}},{key:"copyTextureToBuffer",value:function(e,t,r,n,i,a){return f(function(){return P(this,function(o){return[2,this.textureUtils.copyTextureToBuffer(e,t,r,n,i,a)]})}).call(this)}},{key:"initTimestampQuery",value:function(e,t,r){if(this.trackTimestamp){this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new _Q(this.device,e,2048));var n=this.timestampQueryPool[e],i=n.allocateQueriesForContext(t);_4.querySet=n.querySet,_4.beginningOfPassWriteIndex=i,_4.endOfPassWriteIndex=i+1,r.timestampWrites=_4}}},{key:"createNodeBuilder",value:function(e,t){return new _E(e,t)}},{key:"createProgram",value:function(e){var t=this.get(e);_3.label=e.stage+(""!==e.name?"_".concat(e.name):""),_3.code=e.code,t.module={module:this.device.createShaderModule(_3),entryPoint:"main"},_3.reset()}},{key:"destroyProgram",value:function(e){this.delete(e)}},{key:"createRenderPipeline",value:function(e,t){this.pipelineUtils.createRenderPipeline(e,t)}},{key:"createComputePipeline",value:function(e,t){this.pipelineUtils.createComputePipeline(e,t)}},{key:"beginBundle",value:function(e){var t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}},{key:"finishBundle",value:function(e,t){var r=this.get(e),n=r.currentPass.finish();this.get(t).bundleGPU=n,r.currentSets=r._currentSets,r.currentPass=r._currentPass}},{key:"addBundle",value:function(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}},{key:"createUniformBuffer",value:function(e){var t=this.get(e);if(void 0===t.buffer){var r=e.byteLength,n=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=[];e.visibility&yU.VERTEX&&i.push("vertex"),e.visibility&yU.FRAGMENT&&i.push("fragment"),e.visibility&yU.COMPUTE&&i.push("compute");var a="(".concat(i.join(","),")");_$.label="bindingBuffer".concat(e.id,"_").concat(e.name,"_").concat(a),_$.size=r,_$.usage=n;var o=this.device.createBuffer(_$);_$.reset(),t.buffer=o}}},{key:"destroyUniformBuffer",value:function(e){this.get(e).buffer.destroy(),this.delete(e)}},{key:"createBindings",value:function(e,t,r,n){this.bindingUtils.createBindings(e,t,r,n)}},{key:"updateBindings",value:function(e,t,r,n){this.bindingUtils.createBindings(e,t,r,n)}},{key:"updateBinding",value:function(e){this.bindingUtils.updateBinding(e)}},{key:"deleteBindGroupData",value:function(e){this.bindingUtils.deleteBindGroupData(e)}},{key:"createIndexAttribute",value:function(e){var t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}},{key:"createAttribute",value:function(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}},{key:"createStorageAttribute",value:function(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}},{key:"createIndirectStorageAttribute",value:function(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}},{key:"updateAttribute",value:function(e){this.attributeUtils.updateAttribute(e)}},{key:"destroyAttribute",value:function(e){this.attributeUtils.destroyAttribute(e)}},{key:"updateSize",value:function(){this.delete(this.renderer.getCanvasTarget())}},{key:"hasFeature",value:function(e){return void 0!==xC[e]&&(e=xC[e]),this.device.features.has(e)}},{key:"copyTextureToTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=0,s=0,u=0,l=0,c=0,d=0,h=e.image.width,f=e.image.height,p=1;null!==r&&(!0===r.isBox3?(l=r.min.x,c=r.min.y,d=r.min.z,h=r.max.x-r.min.x,f=r.max.y-r.min.y,p=r.max.z-r.min.z):(l=r.min.x,c=r.min.y,h=r.max.x-r.min.x,f=r.max.y-r.min.y,p=1)),null!==n&&(o=n.x,s=n.y,u=n.z||0),_0.label="copyTextureToTexture_"+e.id+"_"+t.id;var v=this.device.createCommandEncoder(_0);_0.reset();var g=this.get(e).texture,m=this.get(t).texture;_5.texture=g,_5.mipLevel=i,_5.origin.x=l,_5.origin.y=c,_5.origin.z=d,_6.texture=m,_6.mipLevel=a,_6.origin.x=o,_6.origin.y=s,_6.origin.z=u,_9.width=h,_9.height=f,_9.depthOrArrayLayers=p,v.copyTextureToTexture(_5,_6,_9),_5.reset(),_6.reset(),_9.reset(),xU(this.device,v.finish()),0===a&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}},{key:"copyFramebufferToTexture",value:function(e,t,r){var n=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();var a,o=this.get(e).texture;if(i.format===o.format)if(n.currentPass?(n.currentPass.end(),a=n.encoder):(_0.label="copyFramebufferToTexture_"+e.id,a=this.device.createCommandEncoder(_0),_0.reset()),_5.texture=i,_5.origin.x=r.x,_5.origin.y=r.y,_6.texture=o,_9.width=r.z,_9.height=r.w,a.copyTextureToTexture(_5,_6,_9),_5.reset(),_6.reset(),_9.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,a),n.currentPass){for(var s=n.descriptor,u=0;u<s.colorAttachments.length;u++)s.colorAttachments[u].loadOp=yX;t.depth&&(s.depthStencilAttachment.depthLoadOp=yX),t.stencil&&(s.depthStencilAttachment.stencilLoadOp=yX),n.currentPass=a.beginRenderPass(s),n.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else xU(this.device,a.finish());else(0,c.xc)("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,o.format)}},{key:"hasCompatibility",value:function(e){return void 0!==this._compatibility[e]?this._compatibility[e]:x(_(t.prototype),"hasCompatibility",this).call(this,e)}},{key:"dispose",value:function(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){var e=!0,t=!1,r=void 0;try{for(var n,i=this.occludedResolveCache.values()[Symbol.iterator]();!(e=(n=i.next()).done);e=!0)n.value.destroy()}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}this.occludedResolveCache.clear()}var a=!0,o=!1,s=void 0;if(this.timestampQueryPool)try{for(var u,l=Object.values(this.timestampQueryPool)[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;null!==c&&c.dispose()}}catch(e){o=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(o)throw s}}void 0===this.parameters.device&&null!==this.device&&this.device.destroy()}}]),t}(yx),Te=function(e){function t(e,r,n,i,a,o){var s;return v(this,t),(s=p(this,t,[e,r,n,i,a,o])).iesMap=null,s}return T(t,e),y(t,[{key:"copy",value:function(e,r){return x(_(t.prototype),"copy",this).call(this,e,r),this.iesMap=e.iesMap,this}}]),t}(c.ye),Tt=function(e){function t(e,r,n,i,a,o){var s;return v(this,t),(s=p(this,t,[e,r,n,i,a,o])).aspect=null,s}return T(t,e),y(t,[{key:"copy",value:function(e,r){return x(_(t.prototype),"copy",this).call(this,e,r),this.aspect=e.aspect,this}}]),t}(c.ye),Tr=function(e){function t(){var e;return v(this,t),(e=p(this,t)).addMaterial(lH,"MeshPhongMaterial"),e.addMaterial(df,"MeshStandardMaterial"),e.addMaterial(dv,"MeshPhysicalMaterial"),e.addMaterial(db,"MeshToonMaterial"),e.addMaterial(lL,"MeshBasicMaterial"),e.addMaterial(lz,"MeshLambertMaterial"),e.addMaterial(lT,"MeshNormalMaterial"),e.addMaterial(dT,"MeshMatcapMaterial"),e.addMaterial(lu,"LineBasicMaterial"),e.addMaterial(lc,"LineDashedMaterial"),e.addMaterial(dE,"PointsMaterial"),e.addMaterial(dk,"SpriteMaterial"),e.addMaterial(dF,"ShadowMaterial"),e.addLight(vQ,c.ze),e.addLight(md,c.Be),e.addLight(m_,c.De),e.addLight(mf,c.ye),e.addLight(mc,c.Ce),e.addLight(mh,c.ve),e.addLight(mv,c.Ee),e.addLight(mp,Te),e.addLight(mm,Tt),e.addToneMapping(f4,c.Z),e.addToneMapping(f5,c._),e.addToneMapping(f6,c.$),e.addToneMapping(f9,c.aa),e.addToneMapping(pr,c.ca),e.addToneMapping(pn,c.da),e}return T(t,e),t}(mU),Tn=function(e){function t(){var e,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this,t),n.forceWebGL?r=yL:(r=_7,n.getFallback=function(){return(0,c.wc)("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new yL(n)}),(e=p(this,t,[new r(n),n])).library=new Tr,e.isWebGPURenderer=!0,("u"<typeof __THREE_DEVTOOLS__?"undefined":C(__THREE_DEVTOOLS__))<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:e})),e}return T(t,e),t}(mQ),Ti=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tH(0,0,1,1);v(this,e),this.renderer=t,this.outputNode=r,this.outputColorTransform=!0,this.needsUpdate=!0;var n=new lo;n.name="RenderPipeline",this._quadMesh=new fh(n),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=t.toneMapping,this._outputColorSpace=t.outputColorSpace}return y(e,[{key:"render",value:function(){var e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();var t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=c.Y,e.outputColorSpace=c.Hc.workingColorSpace;var n=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=n,e.toneMapping=t,e.outputColorSpace=r,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}},{key:"context",get:function(){return this._context}},{key:"dispose",value:function(){this._quadMesh.material.dispose()}},{key:"_update",value:function(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){var e=this._toneMapping,t=this._outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null},n=this.outputNode;!0===this.outputColorTransform?n=ao(n=n.context(r),e,t):(r.toneMapping=e,r.outputColorSpace=t,n=n.context(r)),this._context=r,this._quadMesh.material.fragmentNode=n,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}},{key:"renderAsync",value:function(){return f(function(){return P(this,function(e){switch(e.label){case 0:return(0,c.yc)('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),[4,this.renderer.init()];case 1:return e.sent(),this.render(),[2]}})}).call(this)}}]),e}(),Ta=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return v(this,t),(e=p(this,t)).image={width:r,height:n},e.magFilter=c.qa,e.minFilter=c.qa,e.isStorageTexture=!0,e.mipmapsAutoUpdate=!0,e}return T(t,e),y(t,[{key:"setSize",value:function(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}}]),t}(c.Ic),To=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return v(this,t),(e=p(this,t)).isArrayTexture=!1,e.image={width:r,height:n,depth:i},e.magFilter=c.qa,e.minFilter=c.qa,e.wrapR=c.la,e.isStorageTexture=!0,e.is3DTexture=!0,e}return T(t,e),y(t,[{key:"setSize",value:function(e,t,r){(this.image.width!==e||this.image.height!==t||this.image.depth!==r)&&(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}]),t}(c.Ic),Ts=(gB.BRDF_GGX,gB.BRDF_Lambert,gB.BasicPointShadowFilter,gB.BasicShadowFilter,gB.Break),Tu=(gB.Const,gB.Continue,gB.DFGLUT,gB.D_GGX,gB.Discard),Tl=(gB.EPSILON,gB.F_Schlick,gB.Fn),Tc=(gB.INFINITY,gB.If),Td=gB.Loop,Th=(gB.NodeAccess,gB.NodeShaderStage,gB.NodeType,gB.NodeUpdateType),Tf=(gB.PCFShadowFilter,gB.PCFSoftShadowFilter,gB.PI),Tp=(gB.PI2,gB.TWO_PI,gB.HALF_PI,gB.PointShadowFilter),Tv=gB.Return,Tg=(gB.Schlick_to_F0,gB.ShaderNode,gB.Stack,gB.Switch,gB.TBNViewMatrix,gB.VSMShadowFilter,gB.V_GGX_SmithCorrelated,gB.Var,gB.VarIntent,gB.abs),Tm=(gB.acesFilmicToneMapping,gB.acos),Ty=(gB.acosh,gB.add,gB.addMethodChaining,gB.addNodeElement,gB.agxToneMapping,gB.all,gB.alphaT,gB.ambientOcclusion,gB.and,gB.anisotropy,gB.anisotropyB,gB.anisotropyT,gB.any),Tb=(gB.append,gB.array,gB.asin),Tx=(gB.asinh,gB.assign,gB.atan),T_=(gB.atanh,gB.atomicAdd),TT=(gB.atomicAnd,gB.atomicFunc,gB.atomicLoad),TS=(gB.atomicMax,gB.atomicMin,gB.atomicOr,gB.atomicStore),TN=gB.atomicSub,Tk=(gB.atomicXor,gB.attenuationColor,gB.attenuationDistance,gB.attribute),Tw=(gB.attributeArray,gB.backgroundBlurriness,gB.backgroundIntensity,gB.backgroundRotation,gB.batch,gB.bentNormalView,gB.billboarding,gB.bitAnd,gB.bitNot,gB.bitOr,gB.bitXor,gB.bitangentGeometry,gB.bitangentLocal,gB.bitangentView,gB.bitangentWorld,gB.bitcast),TA=(gB.blendBurn,gB.blendColor,gB.blendDodge,gB.blendOverlay,gB.blendScreen,gB.blur,gB.bool),TE=gB.buffer,TR=(gB.bufferAttribute,gB.bumpMap,gB.builtin,gB.builtinAOContext,gB.builtinShadowContext,gB.bvec2,gB.bvec3,gB.bvec4,gB.bypass,gB.cache,gB.call,gB.cameraFar,gB.cameraIndex,gB.cameraNear),TC=(gB.cameraNormalMatrix,gB.cameraPosition),TM=gB.cameraProjectionMatrix,TF=gB.cameraProjectionMatrixInverse,TB=gB.cameraViewMatrix,TP=(gB.cameraViewport,gB.cameraWorldMatrix),TL=(gB.cbrt,gB.cdl,gB.ceil,gB.checker,gB.cineonToneMapping,gB.clamp),TD=gB.clearcoat,TU=gB.clearcoatNormalView,TO=gB.clearcoatRoughness,TI=(gB.clipSpace,gB.code,gB.color),TV=(gB.colorSpaceToWorking,gB.colorToDirection,gB.compute,gB.computeKernel,gB.computeSkinning,gB.context,gB.convert,gB.convertColorSpace,gB.convertToTexture),TG=(gB.countLeadingZeros,gB.countOneBits,gB.countTrailingZeros,gB.cos),Tz=(gB.cosh,gB.cross),TW=gB.cubeTexture,TH=(gB.cubeTextureBase,gB.dFdx),Tq=gB.dFdy,Tj=(gB.dashSize,gB.debug,gB.decrement,gB.decrementBefore,gB.defaultBuildStages,gB.defaultShaderStages,gB.defined,gB.degrees,gB.deltaTime,gB.densityFog,gB.densityFogFactor,gB.depth),TX=(gB.depthPass,gB.determinant,gB.difference,gB.diffuseColor),TK=(gB.directPointLight,gB.directionToColor,gB.directionToFaceDirection,gB.dispersion,gB.distance),TY=(gB.div,gB.dot),TQ=(gB.drawIndex,gB.dynamicBufferAttribute,gB.element,gB.emissive),TZ=(gB.equal,gB.equirectDirection,gB.equirectUV,gB.exp),TJ=gB.exp2,T$=(gB.exponentialHeightFogFactor,gB.expression,gB.faceDirection),T0=(gB.faceForward,gB.faceforward,gB.float),T1=(gB.floatBitsToInt,gB.floatBitsToUint,gB.floor),T2=gB.fog,T3=gB.fract,T4=(gB.frameGroup,gB.frameId,gB.frontFacing),T5=gB.fwidth,T6=(gB.gain,gB.gapSize,gB.getConstNodeType,gB.getCurrentStack,gB.getDirection,gB.getDistanceAttenuation,gB.getGeometryRoughness,gB.getNormalFromDepth,gB.interleavedGradientNoise),T8=gB.vogelDiskSample,T9=(gB.getParallaxCorrectNormal,gB.getRoughness,gB.getScreenPosition,gB.getShIrradianceAt,gB.getShadowMaterial,gB.getShadowRenderObjectFunction,gB.getTextureIndex,gB.getViewPosition),T7=gB.globalId,Se=(gB.glsl,gB.glslFn,gB.grayscale,gB.greaterThan,gB.greaterThanEqual,gB.hash,gB.highpModelNormalViewMatrix,gB.highpModelViewMatrix,gB.hue,gB.increment,gB.incrementBefore,gB.instance,gB.instanceIndex),St=gB.instancedArray,Sr=gB.instancedBufferAttribute,Sn=gB.instancedDynamicBufferAttribute,Si=(gB.instancedMesh,gB.int),Sa=(gB.intBitsToFloat,gB.inverse,gB.inverseSqrt),So=(gB.inversesqrt,gB.invocationLocalIndex,gB.invocationSubgroupIndex,gB.ior),Ss=gB.iridescence,Su=gB.iridescenceIOR,Sl=gB.iridescenceThickness,Sc=gB.ivec2,Sd=gB.ivec3,Sh=(gB.ivec4,gB.js,gB.label,gB.length),Sf=(gB.lengthSq,gB.lessThan,gB.lessThanEqual,gB.lightPosition,gB.lightProjectionUV,gB.lightShadowMatrix,gB.lightTargetDirection),Sp=(gB.lightTargetPosition,gB.lightViewPosition,gB.lightingContext),Sv=(gB.lights,gB.linearDepth,gB.linearToneMapping,gB.localId),Sg=(gB.log,gB.log2),Sm=(gB.logarithmicDepthToViewZ,gB.luminance),Sy=(gB.mat2,gB.mat3),Sb=gB.mat4,Sx=(gB.matcapUV,gB.materialAO,gB.materialAlphaTest,gB.materialAnisotropy,gB.materialAnisotropyVector,gB.materialAttenuationColor,gB.materialAttenuationDistance,gB.materialClearcoat,gB.materialClearcoatNormal,gB.materialClearcoatRoughness,gB.materialColor),S_=(gB.materialDispersion,gB.materialEmissive,gB.materialEnvIntensity),ST=(gB.materialEnvRotation,gB.materialIOR,gB.materialIridescence,gB.materialIridescenceIOR,gB.materialIridescenceThickness,gB.materialLightMap,gB.materialLineDashOffset,gB.materialLineDashSize,gB.materialLineGapSize,gB.materialLineScale,gB.materialLineWidth,gB.materialMetalness,gB.materialNormal,gB.materialOpacity,gB.materialPointSize,gB.materialReference),SS=(gB.materialReflectivity,gB.materialRefractionRatio,gB.materialRotation,gB.materialRoughness,gB.materialSheen,gB.materialSheenRoughness,gB.materialShininess,gB.materialSpecular,gB.materialSpecularColor,gB.materialSpecularIntensity,gB.materialSpecularStrength,gB.materialThickness,gB.materialTransmission,gB.max),SN=(gB.maxMipLevel,gB.mediumpModelViewMatrix,gB.metalness),Sk=gB.min,Sw=gB.mix,SA=(gB.mixElement,gB.mod),SE=(gB.modelDirection,gB.modelNormalMatrix),SR=(gB.modelPosition,gB.modelRadius,gB.modelScale),SC=gB.modelViewMatrix,SM=(gB.modelViewPosition,gB.modelViewProjection),SF=gB.modelWorldMatrix,SB=gB.modelWorldMatrixInverse,SP=(gB.morphReference,gB.mrt),SL=gB.mul,SD=(gB.mx_aastep,gB.mx_add,gB.mx_atan2,gB.mx_cell_noise_float,gB.mx_contrast,gB.mx_divide,gB.mx_fractal_noise_float,gB.mx_fractal_noise_vec2,gB.mx_fractal_noise_vec3,gB.mx_fractal_noise_vec4,gB.mx_frame,gB.mx_heighttonormal,gB.mx_hsvtorgb,gB.mx_ifequal,gB.mx_ifgreater,gB.mx_ifgreatereq,gB.mx_invert,gB.mx_modulo,gB.mx_multiply,gB.mx_noise_float,gB.mx_noise_vec3,gB.mx_noise_vec4,gB.mx_place2d,gB.mx_power,gB.mx_ramp4,gB.mx_ramplr,gB.mx_ramptb,gB.mx_rgbtohsv,gB.mx_rotate2d,gB.mx_rotate3d,gB.mx_safepower,gB.mx_separate,gB.mx_splitlr,gB.mx_splittb,gB.mx_srgb_texture_to_lin_rec709,gB.mx_subtract,gB.mx_timer,gB.mx_transform_uv,gB.mx_unifiednoise2d,gB.mx_unifiednoise3d,gB.mx_worley_noise_float,gB.mx_worley_noise_vec2,gB.mx_worley_noise_vec3,gB.negate,gB.negateOnBackSide),SU=(gB.neutralToneMapping,gB.nodeArray,gB.nodeImmutable,gB.nodeObject,gB.nodeObjectIntent,gB.nodeObjects,gB.nodeProxy,gB.nodeProxyIntent,gB.normalFlat,gB.normalGeometry),SO=gB.normalLocal,SI=(gB.normalMap,gB.normalView),SV=(gB.normalViewGeometry,gB.normalWorld),SG=gB.normalWorldGeometry,Sz=gB.normalize,SW=(gB.not,gB.notEqual),SH=(gB.numWorkgroups,gB.objectDirection,gB.objectGroup,gB.objectPosition,gB.objectRadius,gB.objectScale,gB.objectViewPosition,gB.objectWorldMatrix,gB.OnBeforeObjectUpdate,gB.OnBeforeMaterialUpdate,gB.OnObjectUpdate,gB.OnMaterialUpdate,gB.oneMinus),Sq=(gB.or,gB.orthographicDepthToViewZ),Sj=(gB.oscSawtooth,gB.oscSine,gB.oscSquare,gB.oscTriangle,gB.output),SX=(gB.outputStruct,gB.overloadingFn,gB.overrideNode,gB.overrideNodes,gB.packHalf2x16,gB.packSnorm2x16,gB.packUnorm2x16,gB.packNormalToRGB),SK=(gB.parabola,gB.parallaxDirection,gB.parallaxUV,gB.parameter,gB.pass),SY=gB.passTexture,SQ=(gB.pcurve,gB.perspectiveDepthToViewZ),SZ=gB.pmremTexture,SJ=(gB.pointShadow,gB.pointUV,gB.pointWidth,gB.positionGeometry),S$=gB.positionLocal,S0=gB.positionPrevious,S1=gB.positionView,S2=gB.positionViewDirection,S3=gB.positionWorld,S4=(gB.positionWorldDirection,gB.posterize,gB.pow),S5=gB.pow2,S6=(gB.pow3,gB.pow4),S8=(gB.premultiplyAlpha,gB.property,gB.radians,gB.rand),S9=(gB.range,gB.rangeFog,gB.rangeFogFactor),S7=(gB.reciprocal,gB.reference,gB.referenceBuffer,gB.reflect),Ne=(gB.reflectVector,gB.reflectView,gB.reflector,gB.refract),Nt=(gB.refractVector,gB.refractView,gB.reinhardToneMapping,gB.remap,gB.remapClamp,gB.renderGroup),Nr=(gB.renderOutput,gB.rendererReference,gB.replaceDefaultUV,gB.rotate,gB.rotateUV,gB.roughness),Nn=gB.round,Ni=(gB.rtt,gB.sRGBTransferEOTF,gB.sRGBTransferOETF,gB.sample,gB.sampler),Na=(gB.samplerComparison,gB.saturate,gB.saturation,gB.screen,gB.screenCoordinate),No=(gB.screenDPR,gB.screenSize,gB.screenUV),Ns=gB.select,Nu=(gB.setCurrentStack,gB.setName,gB.shaderStages,gB.shadow,gB.shadowPositionWorld,gB.shapeCircle,gB.sharedUniformGroup,gB.sheen),Nl=gB.sheenRoughness,Nc=(gB.shiftLeft,gB.shiftRight,gB.shininess),Nd=gB.sign,Nh=gB.sin,Nf=(gB.sinh,gB.sinc,gB.skinning,gB.smoothstep),Np=(gB.smoothstepElement,gB.specularColor),Nv=gB.specularF90,Ng=(gB.spherizeUV,gB.split,gB.spritesheetUV,gB.sqrt),Nm=(gB.stack,gB.step),Ny=(gB.stepElement,gB.storage),Nb=(gB.storageBarrier,gB.storageTexture,gB.storageTexture3D),Nx=(gB.struct,gB.sub),N_=(gB.subgroupAdd,gB.subgroupAll,gB.subgroupAnd,gB.subgroupAny,gB.subgroupBallot,gB.subgroupBroadcast,gB.subgroupBroadcastFirst,gB.subBuild),NT=(gB.subgroupElect,gB.subgroupExclusiveAdd,gB.subgroupExclusiveMul,gB.subgroupInclusiveAdd,gB.subgroupInclusiveMul,gB.subgroupIndex,gB.subgroupMax,gB.subgroupMin,gB.subgroupMul,gB.subgroupOr,gB.subgroupShuffle,gB.subgroupShuffleDown,gB.subgroupShuffleUp,gB.subgroupShuffleXor,gB.subgroupSize,gB.subgroupXor,gB.tan),NS=(gB.tanh,gB.tangentGeometry,gB.tangentLocal,gB.tangentView,gB.tangentWorld,gB.texture),NN=gB.texture3D,Nk=(gB.textureBarrier,gB.textureBicubic,gB.textureBicubicLevel,gB.textureCubeUV,gB.textureLoad,gB.textureSize),Nw=(gB.textureLevel,gB.textureStore,gB.thickness,gB.time),NA=(gB.toneMapping,gB.toneMappingExposure,gB.toonOutlinePass,gB.transformDirection),NE=(gB.transformNormal,gB.transformNormalByInverseViewMatrix,gB.transformNormalByViewMatrix,gB.transformNormalToView),NR=(gB.transformedClearcoatNormalView,gB.transformedNormalView,gB.transformedNormalWorld,gB.transmission,gB.transpose,gB.triNoise3D,gB.triplanarTexture,gB.triplanarTextures,gB.trunc,gB.uint),NC=(gB.uintBitsToFloat,gB.uniform),NM=gB.uniformArray,NF=(gB.uniformCubeTexture,gB.uniformGroup,gB.uniformFlow,gB.uniformTexture,gB.unpackHalf2x16,gB.unpackSnorm2x16,gB.unpackUnorm2x16,gB.unpackRGBToNormal,gB.unpremultiplyAlpha,gB.userData),NB=gB.uv,NP=(gB.uvec2,gB.uvec3),NL=(gB.uvec4,gB.varying,gB.varyingProperty),ND=gB.vec2,NU=gB.vec3,NO=gB.vec4,NI=(gB.vectorComponents,gB.velocity),NV=gB.vertexColor,NG=gB.vertexIndex,Nz=gB.vertexStage,NW=(gB.vibrance,gB.viewZToLogarithmicDepth,gB.viewZToOrthographicDepth),NH=(gB.viewZToPerspectiveDepth,gB.viewZToReversedOrthographicDepth,gB.viewZToReversedPerspectiveDepth,gB.viewport,gB.viewportCoordinate,gB.viewportDepthTexture,gB.viewportLinearDepth,gB.viewportMipTexture,gB.viewportOpaqueMipTexture,gB.viewportResolution,gB.viewportSafeUV,gB.viewportSharedTexture,gB.viewportSize,gB.viewportTexture,gB.viewportUV,gB.wgsl),Nq=gB.wgslFn,Nj=gB.workgroupArray,NX=gB.workgroupBarrier,NK=gB.workgroupId,NY=(gB.workingToColorSpace,gB.xor,8),NQ=new c.Ic,NZ=((n=new c.nd(new Uint8Array([0,0,0,255]),1,1)).minFilter=c.qa,n.magFilter=c.qa,n.needsUpdate=!0,n),NJ=((i=new c.nd(new Uint8Array([0,0,0,255]),1,1)).minFilter=c.qa,i.magFilter=c.qa,i.needsUpdate=!0,i),N$=((a=new c.nd(new Uint8Array([255,255,255,255]),1,1)).minFilter=c.qa,a.magFilter=c.qa,a.needsUpdate=!0,a),N0=((o=new c.nd(new Uint8Array([0,0,0,0]),1,1)).minFilter=c.qa,o.magFilter=c.qa,o.needsUpdate=!0,o);function N1(){try{return"0"!==new URLSearchParams(window.location.search).get("dbgsrgb8")}catch(e){return!0}}function N2(){try{return"0"!==new URLSearchParams(window.location.search).get("dbgoutguard")}catch(e){return!0}}var N3={chainBuilds:0,lastChainBuildReason:"",taaResolves:0,taaJitterIndex:0,taaJitterApplies:0,taaHistoryValid:!1,taaResolveSize:"",helperOverlayMode:"",deviceLost:"",outputInterpositions:0,bundleChecks:0,bundleRebuilds:0,bundleDisabled:!1,bundleResourceRebuilds:0,bundleIncompleteRecords:0,bundleRecords:0,bundleReplays:0,instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{},skippedAsyncDraws:0,stalledSkipFrames:0,compilationBurst:!1,pcssLights:0,pcssInstalled:0,pcssForeignFilter:0,pcssPyramidBuilds:0,pcssPyramidActive:0,shadowMaskResolves:0,shadowMaskActive:0,pcssHookServes:0,pcssRadius0:0,pcssPenumbra0:0,nodeResurrections:0,shadowTypeSoft:!0,depthPrepassDraws:0};("u"<typeof window?"undefined":C(window))<"u"&&(window.__SPLINE_WEBGPU_STATS=N3);var N4={resolution:NC(new c.Dc(1,1)),pixelRatio:NC(1),frameIndex:NC(0),aspectRatio:NC(new c.Dc(1,1)),transmissionRenderTarget:NS(NQ),normalRenderTarget:NS(NQ),normalRenderTargetDepth:NS(NQ),normalViewRenderTarget:NS(NQ),aoRenderTarget:NS(NQ),reflectionRenderTarget:NS(NZ),reflectionDepthPyramid:NS(NZ),reflectionDepthSize:NC(new c.Dc(1,1)),reflectionDepthLevels:NC(1,"int"),reflectionEnvMap:NS(NZ),reflectionEnvEnabled:NC(0),reflectionPlanarTarget:NS(NZ),reflectionPlanarEnabled:NC(0),reflectionMissColor:NC(new c.Fc(0,0,0)),reflectionResolveTarget:NS(NJ),reflectionResolveEnabled:NC(0),shadowMaskTexture:NS(N$),shadowMaskGBuffer:NS(N0),shadowMaskEnabled:NC(0),shadowMaskResolution:NC(new c.Dc(1,1)),shadowMaskFullResolution:NC(new c.Dc(1,1)),transmissionSamplerSize:NC(new c.Dc(2048,2048)),transmissionActualSize:NC(new c.Dc(1,1)),orthographicUniform:NC(0),unjitteredProjection:NC(new c.Oc),aoEnabledUniform:NC(0),pcssHalton:NC(new c.Dc(0,-.333334)),tapAngle:NC(0),tapAngle2:NC(0),cameraJitterPx:NC(new c.Dc(0,0)),toonLightData:NM(Array.from({length:8},function(){return new c.Jc}),"vec4"),toonLightCount:NC(0,"int"),taaEnabled:{value:!1},aoEnabled:{value:!1},transmissionLod:{value:2}}},9616(e,t,r){r.d(t,{a:()=>i,b:()=>a,c:()=>o,d:()=>u,e:()=>l,f:()=>d});var n=new Map;function i(e,t){n.set(e,t)}function a(e){return n.get(e)}function o(){return n}var s=new Map;function u(e,t){s.set(e,t)}function l(e){return s.get(e)}var c=new Set;function d(e,t){var r="".concat(t,":").concat(e);c.has(r)||c.add(r)}}}]);
|