@egen-civitas/esm-app-shell 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -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/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/5905268ff5778527.js +20 -0
- package/dist/5905268ff5778527.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/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/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.092645d8fcc83793.js} +4 -4
- package/dist/egen.092645d8fcc83793.js.map +1 -0
- 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/index.html +1 -1
- package/package.json +3 -3
- package/dist/eb27d690cf45cd5e.js +0 -20
- package/dist/eb27d690cf45cd5e.js.map +0 -1
- package/dist/egen.f35ccbd9a7ae43e2.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_egen_civitas_esm_app_shell=self.webpackChunk_egen_civitas_esm_app_shell||[]).push([["5704"],{9900(e,n,t){t.d(n,{a:()=>p,b:()=>v,c:()=>m,d:()=>_,e:()=>S,f:()=>y});var a=t(9968),r=t(909),i=t(3027);function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}function s(e,n,t){return(s=f()?Reflect.construct:function(e,n,t){var a=[null];a.push.apply(a,n);var r=new(Function.bind.apply(e,a));return t&&u(r,t.prototype),r}).apply(null,arguments)}function l(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(n){var a;a=t[n],n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a})}return e}function c(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n.push.apply(n,t)}return n})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function u(e,n){return(u=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function d(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return o(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,void 0)}}(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 f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function p(e){return!0===(null==e?void 0:e.depthPrepass)}var h=!0;try{h="0"!==new URLSearchParams(window.location.search).get("dbgdepthprepass")}catch(e){}function v(e){return h&&e.transparent&&e.depthTest&&!e.wireframe&&!e.shapeBlend&&!function(e){var n=null==e?void 0:e.layers;if(!n)return!1;var t=!0,a=!1,r=void 0;try{for(var i,o=n[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;if("transmission"===s.data.type&&s.data.visible)return!0}}catch(e){a=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(a)throw r}}return!1}(e.data)}var m={enabled:!1},g=new WeakMap;function _(e){if(!m.enabled)return e;var n=g.get(e);return n||(n=c(l({},e),{bloom:c(l({},e.bloom),{kernelSize:0}),depthOfField:c(l({},e.depthOfField),{enabled:!1})}),g.set(e,n)),n}var x=new WeakSet;function S(e){if(!e.isPointLight&&!e.isSpotLight&&!e.isDirectionalLight)return!1;if(m.enabled){if(!0===e.castShadow)return e.castShadow=!1,x.add(e),!0}else if(x.has(e)&&(x.delete(e),!1===e.castShadow))return e.castShadow=!0,!0;return!1}function y(e,n){var t,o,u,f,p,h,v,m,g,_,x,S,y,w,T,E,M,C,R,A,P,D,L,U,N,I,O,F,z,k,B,V,G;switch(e.type){case"cavity":return c(l({},b(e,n)),{ridge:e.ridge,valley:e.valley});case"dust":return c(l({},b(e,n)),{color:(0,a.a)(e.color,n),coverage:null!=(t=(0,r._)(e.coverage,n))?t:.2,softness:null!=(o=(0,r._)(e.softness,n))?o:.2,noiseStrength:null!=(u=(0,r._)(e.noiseStrength,n))?u:.2,noiseScale:null!=(f=(0,r._)(e.noiseScale,n))?f:1});case"fresnel":return p=e.bias,h=e.scale,v=e.intensity,m=e.factor,g=e.color,c(l({},b(e,n)),{color:(0,a.a)(g,n),bias:p,scale:h,intensity:v,factor:m});case"gradient":return _=e.gradientType,x=e.smooth,S=e.colors,y=e.steps,w=e.angle,T=e.offset,E=e.morph,c(l({},b(e,n)),{gradientType:_,smooth:x,colors:S.map(function(e){return new i.Jc(e[0],e[1],e[2],e[3])}),num:S.length,steps:y,offset:s(i.Dc,d(T.map(function(e){return"number"==typeof e?e:0}))),morph:s(i.Dc,d(E.map(function(e){return"number"==typeof e?e:0}))),angle:w});case"depth":return M=e.gradientType,C=e.near,R=e.far,A=e.isVector,P=e.isWorldSpace,D=e.origin,L=e.direction,U=e.colors,N=e.steps,I=e.smooth,c(l({},b(e,n)),{gradientType:M,near:C,far:R,isVector:A,isWorldSpace:P,origin:s(i.Fc,d(D)),direction:L?s(i.Fc,d(L)):new i.Fc(1,0,0),colors:U.map(function(e){return void 0!==e?new i.Jc(e[0],e[1],e[2],e[3]):new i.Jc(0,0,0,0)}),steps:N.slice(0,U.length),smooth:I});case"normal":return O=e.cnormal,c(l({},b(e,n)),{cnormal:new i.Fc(O[0],O[1],O[2])});case"noise":return c(l({},b(e,n)),{scale:e.scale,move:e.move,fA:s(i.Dc,d(e.fA.map(function(e){return"number"==typeof e?e:0}))),fB:s(i.Dc,d(e.fB.map(function(e){return"number"==typeof e?e:0}))),size:s(i.Fc,d(e.size)),distortion:s(i.Dc,d(e.distortion.map(function(e){return"number"==typeof e?e:0}))),colorA:(0,a.a)(e.colorA,n),colorB:(0,a.a)(e.colorB,n),colorC:(0,a.a)(e.colorC,n),colorD:(0,a.a)(e.colorD,n),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality});case"rainbow":return c(l({},b(e,n)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:s(i.Fc,d(e.wavelengths)),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:s(i.Fc,d(e.offset))});case"toon":return c(l({},b(e,n)),{positioning:e.positioning,colors:e.colors.map(function(e){return new i.Jc(e[0],e[1],e[2],e[3])}),num:e.colors.length,steps:e.steps,source:s(i.Fc,d(e.source)),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:(0,a.a)(e.shadowColor,n),offset:s(i.Fc,d(e.offset))});case"outline":return c(l({},b(e,n)),{outlineColor:(0,a.a)(e.outlineColor,n),contourColor:(0,a.a)(e.contourColor,n),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:s(i.Fc,d(e.contourDirection)),positionalLines:e.positionalLines,compensation:e.compensation});case"transmission":return c(l({},b(e,n)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,attenuationColor:void 0!==e.attenuationColor?(0,a.a)(e.attenuationColor,n):{r:1,g:1,b:1,a:1},attenuationDistance:null!=(F=e.attenuationDistance)?F:0});case"reflection":return c(l({},b(e,n)),{blur:null!=(z=(0,r._)(e.blur,n))?z:0,thickness:null!=(k=(0,r._)(e.thickness,n))?k:.001,steps:null!=(B=(0,r._)(e.steps,n))?B:60,stepSize:null!=(V=(0,r._)(e.stepSize,n))?V:.005,tracingMode:e.tracingMode,mirror:null!=(G=e.mirror)?G:0});case"pattern":return c(l({},b(e,n)),{style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:s(i.Dc,d(e.offset.map(function(e){return"number"==typeof e?e:0}))),colorA:(0,a.a)(e.colorA,n),colorB:(0,a.a)(e.colorB,n),frequency:s(i.Dc,d(e.frequency.map(function(e){return"number"==typeof e?e:0}))),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:s(i.Dc,d(e.vertical.map(function(e){return"number"==typeof e?e:0}))),horizontal:s(i.Dc,d(e.horizontal.map(function(e){return"number"==typeof e?e:0}))),sides:e.sides});case"vertexColor":return b(e,n);default:return c(l({},b(e,n)),{color:(0,a.a)(e.color,n)})}}function b(e,n){var t,a=e.alpha,r=e.mode,i=e.isMask,o="string"==typeof a?Number(null!=(t=n.getVariable(a))?t:100)/100:a;return c(l({},{type:e.type}),{alpha:o,mode:r,isMask:i})}},5672(e,n,t){t.d(n,{a:()=>r,b:()=>i});var a=new Set;function r(e){a.add(e)}function i(e){if(0!==a.size){var n=Array.from(a);a.clear();var t=!0,r=!1,i=void 0;try{for(var o,s=n[Symbol.iterator]();!(t=(o=s.next()).done);t=!0)o.value.render(e)}catch(e){r=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(r)throw i}}}}},479(e,n,t){t.d(n,{a:()=>i,b:()=>o,c:()=>s,d:()=>l,e:()=>c});var a=null,r=null;function i(e){a=e}function o(){return a}function s(e){r=e}function l(){if(null===r)throw Error('[spe] Classic (WebGL) particles are not available in this build — it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return r}function c(e){return!0===(null==e?void 0:e.isWebGPUSplineRenderer)}},8283(e,n,t){t.r(n),t.d(n,{SplineRenderer:()=>iu,rendererGlobals:()=>aZ});var a=t(9900),r=t(5672),i=t(479),o=t(5963);t(8005),t(6679),t(8526),t(3227),t(2995),t(3763);var s=t(2769),l=t(7295);t(7913),t(1955),t(7173),t(1483),t(5181);var c=t(909);t(6259);var u=t(843);t(3486),t(461);var d=t(3940),f=t(9588),p=t(9616),h=t(3027);function v(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}function m(e,n,t,a,r,i,o){try{var s=e[i](o),l=s.value}catch(e){t(e);return}s.done?n(l):Promise.resolve(l).then(a,r)}function g(e){return function(){var n=this,t=arguments;return new Promise(function(a,r){var i=e.apply(n,t);function o(e){m(i,a,r,o,s,"next",e)}function s(e){m(i,a,r,o,s,"throw",e)}o(void 0)})}}function _(e,n,t){return n=E(n),function(e,n){if(n&&("object"===I(n)||"function"==typeof n))return n;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,F()?Reflect.construct(n,t||[],E(e).constructor):n.apply(e,t))}function x(e,n){if(!(e instanceof n))throw TypeError("Cannot call a class as a function")}function S(e,n,t){return(S=F()?Reflect.construct:function(e,n,t){var a=[null];a.push.apply(a,n);var r=new(Function.bind.apply(e,a));return t&&D(r,t.prototype),r}).apply(null,arguments)}function y(e,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function b(e,n,t){return n&&y(e.prototype,n),t&&y(e,t),e}function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function T(e,n,t){return(T="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,n,t){var a=U(e,n);if(a){var r=Object.getOwnPropertyDescriptor(a,n);return r.get?r.get.call(t||e):r.value}})(e,n,t||e)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(e,n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&D(e,n)}function C(e,n){return null!=n&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n}function R(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(n){w(e,n,t[n])})}return e}function A(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n.push.apply(n,t)}return n})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function P(e,n,t,a){return(P="u">typeof Reflect&&Reflect.set?Reflect.set:function(e,n,t,a){var r,i=U(e,n);if(i){if((r=Object.getOwnPropertyDescriptor(i,n)).set)return r.set.call(a,t),!0;if(!r.writable)return!1}if(r=Object.getOwnPropertyDescriptor(a,n)){if(!r.writable)return!1;r.value=t,Object.defineProperty(a,n,r)}else w(a,n,t);return!0})(e,n,t,a)}function D(e,n){return(D=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function L(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t,a,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],o=!0,s=!1;try{for(r=r.call(e);!(o=(t=r.next()).done)&&(i.push(t.value),!n||i.length!==n);o=!0);}catch(e){s=!0,a=e}finally{try{o||null==r.return||r.return()}finally{if(s)throw a}}return i}}(e,n)||O(e,n)||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 U(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=E(e)););return e}function N(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(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 I(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function O(e,n){if(e){if("string"==typeof e)return v(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,n)}}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function z(e,n){var t,a,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(o,"next",{value:l(0)}),s(o,"throw",{value:l(1)}),s(o,"return",{value:l(2)}),"function"==typeof Symbol&&s(o,Symbol.iterator,{value:function(){return this}}),o;function l(s){return function(l){var c=[s,l];if(t)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(i=0)),i;)try{if(t=1,a&&(r=2&c[0]?a.return:c[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,c[1])).done)return r;switch(a=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,a=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],a=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}t(2784);var k=function(){function e(n){if(x(this,e),this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},null===k.uuidContext)throw Error("plz startContext");k.uuidContext===k.globalContext?this.uuid="_gid"+k.uuidContext.nodeContextUuid++:this.uuid="_uid"+k.uuidContext.nodeContextUuid++,this.type=n,this.name=""}return b(e,[{key:"analyze",value:function(e,n){n=null!=n?n:{},e.analyzing=!0,this.build(e.addFlow(n.slot,n.cache,n.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}},{key:"analyzeAndFlow",value:function(e,n,t){return t=null!=t?t:{},this.analyze(e,t),this.flow(e,n,t)}},{key:"flow",value:function(e,n,t){t=null!=t?t:{},e.addFlow(t.slot,t.cache,t.context);var a={result:this.build(e,n),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),a}},{key:"build",value:function(e,n,t){n=null!=n?n:this.getType(e,n);var a=e.getNodeData(null!=t?t:this);return e.analyzing&&this.appendDepsNode(e,a,n),-1===e.nodes.indexOf(this)&&e.nodes.push(this),void 0!==this.updateFrame&&-1===e.updaters.indexOf(this)&&e.updaters.push(this),this.generate(e,n,t)}},{key:"updateFrame",value:function(e){}},{key:"generateReadonly",value:function(e,n,t,a,r,i){return""}},{key:"generate",value:function(e,n,t,a,r){return""}},{key:"parse",value:function(e,n,t,a){}},{key:"appendDepsNode",value:function(e,n,t){n.deps=(n.deps||0)+1;var a=e.getTypeLength(t);(a>(n.outputMax||0)||this.getType(e,t))&&(n.outputMax=a,n.output=t)}},{key:"setName",value:function(e){this.name=e}},{key:"getName",value:function(){return this.name}},{key:"getType",value:function(e,n){return"sampler2D"===n||"samplerCube"===n?n:this.type}}],[{key:"startContext",value:function(e){null===this.uuidContext||this.uuidContext===k.globalContext?this.uuidContext=e:console.error("Can't start context twice")}},{key:"endContext",value:function(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}}]),e}();k.globalContext={nodeContextUuid:0},k.uuidContext=k.globalContext;var B=function(){function e(n){x(this,e),n=null!=n?n:{},this.name=n.name,this.type=n.type,this.node=n.node,this.size=n.size,this.needsUpdate=n.needsUpdate}return b(e,[{key:"value",get:function(){return this.node.value},set:function(e){this.node.value=e}}]),e}(),V=new(function(){function e(){x(this,e),this.nodes={},this.keywords={}}return b(e,[{key:"add",value:function(e){this.nodes[e.name]=e}},{key:"addKeyword",value:function(e,n,t){t=void 0===t||t,this.keywords[e]={callback:n,cache:t}}},{key:"remove",value:function(e){delete this.nodes[e.name]}},{key:"removeKeyword",value:function(e){delete this.keywords[e]}},{key:"get",value:function(e){return this.nodes[e]}},{key:"getKeyword",value:function(e,n){return this.keywords[e].callback(n)}},{key:"getKeywordData",value:function(e){return this.keywords[e]}},{key:"contains",value:function(e){return void 0!==this.nodes[e]}},{key:"containsKeyword",value:function(e){return void 0!==this.keywords[e]}}]),e}()),G=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n,[e])).scope="",a.shared=void 0===(t=null!=t?t:{}).shared||t.shared,a.unique=void 0!==t.unique&&t.unique,a}return M(n,e),b(n,[{key:"build",value:function(e,t,a,r){if(t=null!=t?t:this.getType(e),this.getShared(e,t)){var i=this.getUnique(e,t);i&&void 0===this.uuid&&(this.uuid=h.Cc.generateUUID()),a=e.getUUID(null!=a?a:this.getUUID(),!i);var o=e.getNodeData(a),s=o.output||this.getType(e);if(e.analyzing)return(o.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,o,t),this.generate(e,t,a)):T(E(n.prototype),"build",this).call(this,e,t,a);if(i)return o.name=o.name||T(E(n.prototype),"build",this).call(this,e,t,a),o.name;if(!this.getLabel()&&(!this.getShared(e,s)||e.context.ignoreCache||1===o.deps))return T(E(n.prototype),"build",this).call(this,e,t,a);a=this.getUUID(!1);var l=this.getTemp(e,a);if(l)return e.format(l,s,t);l=T(E(n.prototype),"generate",this).call(this,e,t,a,o.output,r);var c=this.generate(e,s,a);return e.addNodeCode(l+" = "+c+";"),e.format(l,s,t)}return T(E(n.prototype),"build",this).call(this,e,t,a)}},{key:"getShared",value:function(e,n){return"sampler2D"!==n&&"samplerCube"!==n&&this.shared}},{key:"getUnique",value:function(e,n){return this.unique}},{key:"setLabel",value:function(e){return this.label=e,this}},{key:"getLabel",value:function(){return this.label}},{key:"getUUID",value:function(e){var n=this.uuid;return"string"==typeof this.scope&&(n=this.scope+"-"+n),n}},{key:"getTemp",value:function(e,n){n=n||this.uuid;var t=e.getVars()[n];return t?t.name:void 0}},{key:"generate",value:function(e,n,t,a,r){return this.getShared(e,n)||console.error("TempNode is not shared"),t=null!=t?t:this.uuid,e.getTempVar(t,null!=a?a:this.getType(e),r,this.getLabel()).name}}]),n}(k),H=function(e){function n(e,t){var a;return x(this,n),(t=null!=t?t:{}).shared=void 0!==t.shared&&t.shared,(a=_(this,n,[e,t])).readonly=!1,a}return M(n,e),b(n,[{key:"setReadonly",value:function(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}},{key:"getReadonly",value:function(){return this.readonly}},{key:"generate",value:function(e,n,t,a,r,i){t=e.getUUID(null!=t?t:this.getUUID()),a=null!=a?a:this.getType(e);var o=e.getNodeData(t);return this.getReadonly()&&void 0!==this.generateReadonly?this.generateReadonly(e,n,t,a,r,i):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(a,this,r,i,this.getLabel())),e.format(o.vertex.name,a,n)):(o.fragment||(o.fragment=e.createFragmentUniform(a,this,r,i,this.getLabel())),e.format(o.fragment.name,a,n))}}]),n}(G),W=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0;return x(this,n),(e=_(this,n,["v2"])).nodeType="Vector2",e.value=C(t,h.Dc)?t:new h.Dc(t,a),e}return M(n,e),b(n,[{key:"x",get:function(){return this.value.x},set:function(e){this.value.x=e}},{key:"y",get:function(){return this.value.y},set:function(e){this.value.y=e}},{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("vec2("+this.value.x+", "+this.value.y+")",a,n)}}]),n}(H),X=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return x(this,n),(e=_(this,n,["v3"])).nodeType="Vector3",e.value=C(t,h.Fc)?t:new h.Fc(t,a,r),e}return M(n,e),b(n,[{key:"x",get:function(){return this.value.x},set:function(e){this.value.x=e}},{key:"y",get:function(){return this.value.y},set:function(e){this.value.y=e}},{key:"z",get:function(){return this.value.z},set:function(e){this.value.z=e}},{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",a,n)}}]),n}(H),j=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v4"])).nodeType="Vector4",t.value=C(e,c.i)?e:new c.i(e.r,e.g,e.b,e.a),t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",a,n)}}]),n}(H),q=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["f"])).nodeType="Float",t.value=null!=e?e:0,t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format(this.value+(this.value%1?"":".0"),a,n)}}]),n}(H),Y=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,K=/[a-z_0-9]+/gi,Z=function(e){function n(e,t,a,r,i){var o;return x(this,n),(o=_(this,n,[i])).src="",o.nodeType="Function",o.useKeywords=!0,o.includes=[],o.extensions={},o.keywords={},o.isMethod=void 0===i,o.isInterface=!1,o.parse(e,t,a,r),o}return M(n,e),b(n,[{key:"getShared",value:function(e,n){return!this.isMethod}},{key:"getType",value:function(e){return e.getTypeByFormat(this.type)}},{key:"getInputByName",value:function(e){if(this.inputs){for(var n=this.inputs.length;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}},{key:"getIncludeByName",value:function(e){if(this.includes){for(var n=this.includes.length;n--;)if(this.includes[n].name===e)return this.includes[n]}}},{key:"generate",value:function(e,n,t,a,r){var i,o=0,s=this.src;if(this.includes)for(var l=0;l<this.includes.length;l++)e.include(this.includes[l],this);for(var c in this.extensions)e.extensions[c]=!0;for(var u=[];i=K.exec(this.src);)u.push(i);for(var d=0;d<u.length;d++){var f=u[d],p=f[0],h=!this.isMethod||!this.getInputByName(p),v=p;if(this.keywords[p]||this.useKeywords&&h&&V.containsKeyword(p)){var m=this.keywords[p];if(!m){var g=V.getKeywordData(p);g.cache&&(m=e.keywords[p]),m=m||V.getKeyword(p,e),g.cache&&(e.keywords[p]=m)}v=m.build(e)}p!==v&&"."!==s[f.index+o-1]&&(s=s.substring(0,f.index+o)+v+s.substring(f.index+p.length+o),o+=v.length-p.length),void 0===this.getIncludeByName(v)&&V.contains(v)&&e.include(V.get(v))}return"source"===n?s:this.isMethod?(this.isInterface||e.include(this,void 0,s),this.name):e.format("( "+s+" )",this.getType(e),n)}},{key:"parse",value:function(e,n,t,a){if(this.src=e||"",this.includes=null!=n?n:[],this.extensions=null!=t?t:{},this.keywords=null!=a?a:{},this.isMethod){var r=Y.exec(this.src);if(this.inputs=[],r&&4==r.length){this.type=r[1],this.name=r[2];var i=r[3].match(K);if(i)for(var o=0;o<i.length;){var s=void 0,l=i[o++];"in"===l||"out"===l||"inout"===l?s=i[o++]:(s=l,l="");var c=i[o++];this.inputs.push({name:c,type:s,qualifier:l})}this.isInterface=-1===this.src.indexOf("{")}else this.type="",this.name=""}}}]),n}(G),J=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?=?\s?(.*?)(;|$)/i,Q=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1?arguments[1]:void 0;return x(this,n),(e=_(this,n)).src="",e.useDefine=!1,e.nodeType="Const",e.parse(t||Q.PI,void 0,void 0,void 0,a),e}return M(n,e),b(n,[{key:"getType",value:function(e){return e.getTypeByFormat(this.type)}},{key:"parse",value:function(e,n,t,a,r){this.src=e||"";var i,o,s="",l=J.exec(e);this.useDefine=null!=r?r:"#"===this.src.charAt(0),l&&l.length>1?(o=l[1],i=l[2],s=l[3]):(i=this.src,o="f"),this.name=i,this.type=o,this.value=s}},{key:"build",value:function(e,n){if("source"===n){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}},{key:"generate",value:function(e,n,t,a,r){return e.format(this.name,this.getType(e),n)}}]),n}(G);Q.PI="PI",Q.PI2="PI2",Q.RECIPROCAL_PI="RECIPROCAL_PI",Q.RECIPROCAL_PI2="RECIPROCAL_PI2",Q.LOG2="LOG2",Q.EPSILON="EPSILON";var $=RegExp("^structs*([a-z_0-9]+)s*{s*((.|\n)*?)}","gim"),ee=RegExp("s*(w*?)s*(w*?)(=|;)","gim"),en=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return x(this,n),(e=_(this,n)).inputs=[],e.src="",e.nodeType="Struct",e.parse(t),e}return M(n,e),b(n,[{key:"getType",value:function(e){return e.getTypeByFormat(this.name)}},{key:"getInputByName",value:function(e){for(var n=this.inputs.length;n--;)if(this.inputs[n].name===e)return this.inputs[n]}},{key:"generate",value:function(e,n,t,a,r){return"source"===n?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}},{key:"parse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.src=e,this.inputs=[];var n=$.exec(e);if(n){for(var t,a=n[2];t=ee.exec(a);)this.inputs.push({type:t[1],name:t[2]});this.name=n[1]}else this.name="";this.type=this.name}}]),n}(G),et=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v2",{shared:!1}])).nodeType="UV",t.index=null!=e?e:0,t}return M(n,e),b(n,[{key:"generate",value:function(e,n){e.requires.uv[this.index]=!0;var t=this.index>0?this.index+1:"",a=e.isShader("vertex")?"uv"+t:"vUv"+t;return e.format(a,this.getType(e),n)}}]),n}(G);V.addKeyword("uv",function(){return new et}),V.addKeyword("uv2",function(){return new et(1)});var ea=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n,["v4"])).nodeType="ColorSpace",a.input=e,a.method=null!=t?t:ea.LINEAR_TO_LINEAR,a.hashProperties=["method"],a}return M(n,e),b(n,[{key:"generate",value:function(e,n){var t,a=this.input.build(e,"v4"),r=this.getType(e),i=ea.Nodes[this.method],o=e.include(i);if(o===ea.LINEAR_TO_LINEAR)return e.format(a,r,n);if(2===(null==(t=i.inputs)?void 0:t.length)){var s=this.factor.build(e,"f");return e.format(o+"( "+a+", "+s+" )",r,n)}return e.format(o+"( "+a+" )",r,n)}},{key:"fromEncoding",value:function(e){var n=ea.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}},{key:"fromDecoding",value:function(e){var n=ea.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}}],[{key:"getEncodingComponents",value:function(e){switch(e){case 3e3:return["Linear"];case 3001:return["sRGB"];default:return[]}}}]),n}(G);ea.Nodes={LinearToLinear:new Z("vec4 LinearToLinear( in vec4 value ) {\n return value;\n}"),sRGBToLinear:new Z("vec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}"),LinearTosRGB:new Z("vec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}")},ea.LINEAR_TO_LINEAR="LinearToLinear",ea.SRGB_TO_LINEAR="sRGBToLinear",ea.LINEAR_TO_SRGB="LinearTosRGB";var er=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;return x(this,n),(e=_(this,n,[t,o,i,r,a])).nodeType="Expression",e}return M(n,e),n}(Z),ei=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new h.Ic,a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return x(this,n),(e=_(this,n,["v4",{shared:!0}])).nodeType="Texture",e.value=t,e.uv=null!=a?a:new et,e.bias=r,e.project=void 0!==i&&i,e}return M(n,e),b(n,[{key:"getTexture",value:function(e,t){return T(E(n.prototype),"generate",this).call(this,e,t,this.value.uuid,"t")}},{key:"generate",value:function(e,n){if("sampler2D"===n)return this.getTexture(e,n);var t,a,r,i=this.getTexture(e,n),o=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;void 0===s&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f")),a=this.project?"texture2DProj":s?"tex2DBias":"tex2D",r=s?a+"( "+i+", "+o+", "+s+" )":a+"( "+i+", "+o+" )";var l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=null!=(t=this.colorSpace)?t:new ea(new er("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(r),r=this.colorSpace.build(e,c),e.removeContext(),e.format(r,c,n)}}]),n}(H),eo=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n)).inputs=[],a.nodeType="FunctionCall",a.value=e,a.inputs=null!=t?t:[],a}return M(n,e),b(n,[{key:"getFunction",value:function(){return this.value}},{key:"getType",value:function(e){return this.value.getType(e)}},{key:"generate",value:function(e,n,t,a,r){a=this.getType(e);var i=this.value,o=i.build(e,n)+"( ",s=[];if(i.inputs){for(var l=0;l<i.inputs.length;l++){var c=i.inputs[l],u=this.inputs[l]||this.inputs[c.name];s.push(u.build(e,e.getTypeByFormat(c.type)))}o+=s.join(", ")+" )"}return e.format(o,a,n)}}]),n}(G),es=function(e){function n(e,t){var a,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:es.ADD;return x(this,n),(a=_(this,n)).nodeType="Operator",a.type=e.type,a.a=e,a.b=t,a.op=r,a}return M(n,e),b(n,[{key:"getType",value:function(e){var n=this.a.getType(e),t=this.b.getType(e);return e.isTypeMatrix(n)?"v4":e.getTypeLength(t)>e.getTypeLength(n)?t:n}},{key:"generate",value:function(e,n){var t=this.getType(e);this.type=t;var a=this.a.build(e,t),r=this.b.build(e,t);return e.format("( "+a+" "+this.op+" "+r+" )",t,n)}}]),n}(G);es.ADD="+",es.SUB="-",es.MUL="*",es.DIV="/";var el=function(e){function n(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:el.ABS,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return x(this,n),(t=_(this,n)).nodeType="Math",t.a=e,"string"!=typeof a?t.b=a:i=a,"string"!=typeof r?t.c=r:i=r,t.method=i,t.hashProperties=["method"],t}return M(n,e),b(n,[{key:"getNumInputs",value:function(e){switch(this.method){case el.MIX:case el.CLAMP:case el.REFRACT:case el.SMOOTHSTEP:case el.FACEFORWARD:return 3;case el.MIN:case el.MAX:case el.MOD:case el.STEP:case el.REFLECT:case el.DISTANCE:case el.DOT:case el.CROSS:case el.POW:return 2;default:return 1}}},{key:"getInputType",value:function(e){var n=e.getTypeLength(this.a.getType(e)),t=this.b?e.getTypeLength(this.b.getType(e)):0,a=this.c?e.getTypeLength(this.c.getType(e)):0;return n>t&&n>a?this.a.getType(e):t>a?this.b.getType(e):this.c.getType(e)}},{key:"getType",value:function(e){switch(this.method){case el.LENGTH:case el.DISTANCE:case el.DOT:return"f";case el.CROSS:return"v3"}return this.getInputType(e)}},{key:"generate",value:function(e,n){var t,a,r,i=this.a?e.getTypeLength(this.a.getType(e)):0,o=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),c=this.getType(e);switch(this.type=c,this.method){case el.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,n);case el.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,n);case el.CROSS:t=this.a.build(e,"v3"),a=this.b.build(e,"v3");break;case el.STEP:t=this.a.build(e,1===i?"f":l),a=this.b.build(e,l);break;case el.MIN:case el.MAX:case el.MOD:t=this.a.build(e,l),a=this.b.build(e,1===o?"f":l);break;case el.REFRACT:t=this.a.build(e,l),a=this.b.build(e,l),r=this.c.build(e,"f");break;case el.MIX:t=this.a.build(e,l),a=this.b.build(e,l),r=this.c.build(e,1===s?"f":l);break;default:t=this.a.build(e,l),this.b&&(a=this.b.build(e,l)),this.c&&(r=this.c.build(e,l))}var u=[];u.push(t),a&&u.push(a),r&&u.push(r);var d=this.getNumInputs(e);if(u.length!==d)throw Error('Arguments not match used in "'.concat(this.method,'". Require ').concat(d,", currently ").concat(u.length,"."));return e.format(this.method+"( "+u.join(", ")+" )",c,n)}}]),n}(G);el.RAD="radians",el.DEG="degrees",el.EXP="exp",el.EXP2="exp2",el.LOG="log",el.LOG2="log2",el.SQRT="sqrt",el.INV_SQRT="inversesqrt",el.FLOOR="floor",el.CEIL="ceil",el.NORMALIZE="normalize",el.FRACT="fract",el.SATURATE="saturate",el.SIN="sin",el.COS="cos",el.TAN="tan",el.ASIN="asin",el.ACOS="acos",el.ARCTAN="atan",el.ABS="abs",el.SIGN="sign",el.LENGTH="length",el.NEGATE="negate",el.INVERT="invert",el.MIN="min",el.MAX="max",el.MOD="mod",el.STEP="step",el.REFLECT="reflect",el.DISTANCE="distance",el.DOT="dot",el.CROSS="cross",el.POW="pow",el.MIX="mix",el.CLAMP="clamp",el.REFRACT="refract",el.SMOOTHSTEP="smoothstep",el.FACEFORWARD="faceforward";var ec=function(e){function n(e,t,a){var r;return x(this,n),(r=_(this,n,["v4"])).nodeType="TextureCubeUV",r.value=e,r.uv=t,r.bias=a,r}return M(n,e),b(n,[{key:"bilinearCubeUV",value:function(e,n,t,a){var r,i,o,s,l=new eo(ec.Nodes.bilinearCubeUV,[n,t,a]);this.colorSpaceTL=null!=(r=this.colorSpaceTL)?r:new ea(new er("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(l.build(e)+".tl"),this.colorSpaceTR=null!=(i=this.colorSpaceTR)?i:new ea(new er("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(l.build(e)+".tr"),this.colorSpaceBL=null!=(o=this.colorSpaceBL)?o:new ea(new er("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(l.build(e)+".bl"),this.colorSpaceBR=null!=(s=this.colorSpaceBR)?s:new ea(new er("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(l.build(e)+".br");var c={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(c),this.colorSpaceTLExp=new er(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new er(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new er(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new er(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();var u=new er("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return u.keywords.cubeUV_TL=this.colorSpaceTLExp,u.keywords.cubeUV_TR=this.colorSpaceTRExp,u.keywords.cubeUV_BL=this.colorSpaceBLExp,u.keywords.cubeUV_BR=this.colorSpaceBRExp,u.keywords.cubeUV=l,u}},{key:"generate",value:function(e,n){if(e.isShader("fragment")){var t=this.uv,a=this.bias||e.context.roughness,r=new el(new eo(ec.Nodes.roughnessToMip,[a]),ec.Nodes.m0,ec.Nodes.cubeUV_maxMipLevel,el.CLAMP),i=new el(r,el.FLOOR),o=new el(r,el.FRACT),s=new el(this.bilinearCubeUV(e,this.value,t,i),this.bilinearCubeUV(e,this.value,t,new es(i,new q(1).setReadonly(!0),es.ADD)),o,el.MIX);return e.format(s.build(e),"v4",n)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),n)}}]),n}(G);t2=new en("struct TextureCubeUVData {\n vec4 tl;\n vec4 tr;\n vec4 br;\n vec4 bl;\n vec2 f;\n }"),t4=new Q("float cubeUV_maxMipLevel 8.0",!0),t5=new Q("float cubeUV_minMipLevel 4.0",!0),t6=new Q("float cubeUV_maxTileSize 256.0",!0),t8=new Q("float cubeUV_minTileSize 16.0",!0),(t9=new Z("float getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }")).useKeywords=!1,(t7=new Z("vec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); \n } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); \n } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); \n } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); \n } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); \n } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); \n }\n return 0.5 * (uv + 1.0);\n }")).useKeywords=!1,(ae=new Z("TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec4 tl = texture2D(envMap, uv);\n uv.x += texelSize;\n vec4 tr = texture2D(envMap, uv);\n uv.y += texelSize;\n vec4 br = texture2D(envMap, uv);\n uv.x -= texelSize;\n vec4 bl = texture2D(envMap, uv);\n return TextureCubeUVData( tl, tr, br, bl, f );\n }",[t2,t9,t7,t4,t5,t6,t8])).useKeywords=!1,an=new Q("float r0 1.0",!0),ec.Nodes={bilinearCubeUV:ae,roughnessToMip:new Z("float roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n }",[an,new Q("float v0 0.339",!0),at=new Q("float m0 -2.0",!0),new Q("float r1 0.8",!0),new Q("float v1 0.276",!0),new Q("float m1 -1.0",!0),new Q("float r4 0.4",!0),new Q("float v4 0.046",!0),new Q("float m4 2.0",!0),new Q("float r5 0.305",!0),new Q("float v5 0.016",!0),new Q("float m5 3.0",!0),new Q("float r6 0.21",!0),new Q("float v6 0.0038",!0),new Q("float m6 4.0",!0)]),m0:at,cubeUV_maxMipLevel:t4};var eu=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v3"])).nodeType="Normal",t.scope=null!=e?e:eu.VIEW,t}return M(n,e),b(n,[{key:"getShared",value:function(){return this.scope===eu.WORLD}},{key:"build",value:function(e,t,a,r){var i=e.context[this.scope+"Normal"];return i?i.build(e,t,a,r):T(E(n.prototype),"build",this).call(this,e,t,a)}},{key:"generate",value:function(e,n,t,a,r){var i;switch(this.scope){case eu.VIEW:i=e.isShader("vertex")?"transformedNormal":"geometryNormal";break;case eu.LOCAL:e.isShader("vertex")?i="objectNormal":(e.requires.normal=!0,i="vObjectNormal");break;case eu.WORLD:e.isShader("vertex")?i="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,i="vWNormal")}return e.format(i,this.getType(e),n)}}]),n}(G);eu.LOCAL="local",eu.WORLD="world",eu.VIEW="view",eu.NORMAL="normal",V.addKeyword("viewNormal",function(){return new eu(eu.VIEW)}),V.addKeyword("localNormal",function(){return new eu(eu.NORMAL)}),V.addKeyword("worldNormal",function(){return new eu(eu.WORLD)});var ed=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v3"])).nodeType="Position",t.scope=null!=e?e:ed.LOCAL,t}return M(n,e),b(n,[{key:"getType",value:function(){return this.scope===ed.PROJECTION?"v4":this.type}},{key:"getShader",value:function(){switch(this.scope){case ed.LOCAL:case ed.WORLD:return!1}return!0}},{key:"generate",value:function(e,n,t,a,r){var i;switch(this.scope){case ed.LOCAL:e.isShader("vertex")?i="transformed":(e.requires.position=!0,i="vPosition");break;case ed.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,i="vWPosition";break;case ed.VIEW:i=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ed.PROJECTION:i=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )"}return e.format(i,this.getType(),n)}}]),n}(G);ed.LOCAL="local",ed.WORLD="world",ed.VIEW="view",ed.PROJECTION="projection",V.addKeyword("position",function(){return new ed}),V.addKeyword("worldPosition",function(){return new ed(ed.WORLD)}),V.addKeyword("viewPosition",function(){return new ed(ed.VIEW)});var ef=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v3"])).nodeType="Reflect",t.scope=null!=e?e:ef.CUBE,t}return M(n,e),b(n,[{key:"getUnique",value:function(e){return!e.context.viewNormal}},{key:"getType",value:function(){return this.scope===ef.SPHERE?"v2":this.type}},{key:"generate",value:function(e,n){var t,a=this.getUnique(e);if(e.isShader("fragment")){switch(this.scope){case ef.VECTOR:var r=new eu(eu.VIEW),i=e.context.roughness,o=r.build(e,"v3"),s=new ed(ed.VIEW).build(e,"v3"),l=i?i.build(e,"f"):void 0,c="reflect( -normalize( ".concat(s," ), ").concat(o," )");l&&(c="normalize( mix( ".concat(c,", ").concat(o,", ").concat(l," * ").concat(l," ) )"));var u="inverseTransformDirection( ".concat(c,", viewMatrix )");a?(e.addNodeCode("vec3 reflectVec = ".concat(u,";")),t="reflectVec"):t=u;break;case ef.CUBE:var d=new ef(ef.VECTOR).build(e,"v3"),f="vec3( -"+d+".x, "+d+".yz )";a?(e.addNodeCode("vec3 reflectCubeVec = ".concat(f,";")),t="reflectCubeVec"):t=f;break;case ef.SPHERE:var p="normalize( ( viewMatrix * vec4( "+new ef(ef.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";a?(e.addNodeCode("vec2 reflectSphereVec = ".concat(p,";")),t="reflectSphereVec"):t=p}return e.format(t,this.getType(),n)}return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,n)}}]),n}(G);ef.CUBE="cube",ef.SPHERE="sphere",ef.VECTOR="vector";var ep=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ei,a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return x(this,n),(e=_(this,n,["v4"])).nodeType="TextureCube",e.value=t,e.radianceNode=new ec(e.value,null!=a?a:new ef(ef.VECTOR),r),e.irradianceNode=new ec(e.value,new eu(eu.WORLD),new q(1).setReadonly(!0)),e}return M(n,e),b(n,[{key:"generate",value:function(e,n){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),("irradiance"===e.slot?this.irradianceNode:this.radianceNode).build(e,n)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),n))}}]),n}(G),eh=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new h.Ad,a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return x(this,n),(e=_(this,n,["v4",{shared:!0}])).nodeType="CubeTexture",e.value=t,e.uv=null!=a?a:new ef,e.bias=r,e}return M(n,e),b(n,[{key:"getTexture",value:function(e,t){return T(E(n.prototype),"generate",this).call(this,e,t,this.value.uuid,"tc")}},{key:"generate",value:function(e,n){if("samplerCube"===n)return this.getTexture(e,n);var t,a,r,i=this.getTexture(e,n),o=null==(a=this.uv)?void 0:a.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;void 0===s&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f")),r=s?"texCubeBias( "+i+", "+o+", "+s+" )":"texCube( "+i+", "+o+" )";var l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=null!=(t=this.colorSpace)?t:new ea(new er("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(r),r=this.colorSpace.build(e,c),e.removeContext(),e.format(r,c,n)}}]),n}(H),ev=["x","y","z","w"],em=["float","vec2","vec3","vec4"],eg={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},e_={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},ex=function(){function e(){x(this,e),this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function e(e,n){return e.deps.length-n.deps.length}return function(n,t){var a=this.getIncludes(n,t);if(!a)return"";var r="";a=a.sort(e);for(var i=0;i<a.length;i++)a[i].src&&(r+=a[i].src+"\n");return r}}(),this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode="#ifdef TEXTURE_LOD_EXT\n #define texCube(a, b) textureCube(a, b)\n #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)\n #define tex2D(a, b) texture2D(a, b)\n #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)\n#else\n #define texCube(a, b) textureCube(a, b)\n #define texCubeBias(a, b, c) textureCube(a, b, c)\n #define tex2D(a, b) texture2D(a, b)\n #define tex2DBias(a, b, c) texture2D(a, b, c)\n#endif\n\n \n #define SPE_BLENDING_NORMAL 0\n #define SPE_BLENDING_MULTIPLY 1\n #define SPE_BLENDING_SCREEN 2\n #define SPE_BLENDING_OVERLAY 3\n\n vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {\n return mix( a, b, alpha );\n }\n\n vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {\n return mix( a, a * b, alpha );\n }\n\n vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {\n vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );\n return mix( a, tmp, alpha );\n }\n\n vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {\n vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );\n return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );\n }\n\n vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {\n if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );\n else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );\n else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );\n else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );\n return vec3( 1.0 );\n }\n \n#include <packing>\n#include <common>",this.parsCode={vertex:"float neighbor_offset = 0.0001;\n",fragment:"float accumAlpha = 0.0;\nvoid accumulateAlpha(float alpha) {\n accumAlpha += (1.0 - accumAlpha) * alpha;\n }\n"},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}return b(e,[{key:"build",value:function(e,n){this.addVertexParsCode("\nuniform int frameIndex;\nuniform vec2 resolution;\nuniform mat4 previousModelViewMatrix;\nuniform mat4 previousProjectionMatrix;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n"),this.addFragmentParsCode('\nlayout(location = 1) out vec4 gVelocity;\n\nuniform int frameIndex;\nuniform vec2 resolution;\n// Transparent depth ordering (COM-1866): 0 for the color draw (the legacy\n// "discard fully transparent pixels"), TRANSPARENT_DEPTH_ALPHA_CUTOFF on a\n// material\'s depth twin — see materials/depthPrepass.ts.\nuniform float alphaDiscardCutoff;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\nvec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; // radians\n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n}\n\n// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso\nfloat getNoiseInterleavedGradient(vec2 screenPos) {\n vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);\n return fract(magic.z * fract(dot(screenPos, magic.xy)));\n}\n\n'),this.mergeUniform({alphaDiscardCutoff:new q(0)}),this.buildShader("vertex",e),this.buildShader("fragment",n);for(var t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){var a=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+a+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+a+";"),this.addVertexFinalCode("vUv"+a+" = uv"+a+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexFinalCode("\n #if defined( USE_COLOR_ALPHA )\n vColor = color;\n #elif defined( USE_COLOR )\n vColor = vec4( color, 1.0 );\n #else\n vColor = vec4( 1.0 );\n #endif\n ")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("\n #ifndef SHAPEBLEND \n vObjectNormal = normal;\n #else\n vObjectNormal = objectNormal;\n #endif\n ")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode("\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\n\nvec2 offset = haltonSequence[frameIndex];\noffset.x /= resolution.x;\noffset.y /= resolution.y;\n\nvec4 currentPosition = gl_Position;\nvec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);\n\n\n\nvCurrentPosition = currentPosition;\nvec4 previousLocalPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\n\n\n\npreviousLocalPosition = instanceMatrix * previousLocalPosition;\n#endif\nvPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * previousLocalPosition;\n#ifdef OUTLINE_COMPENSATION\nvPreviousPosition.xy += OUTLINE_COMPENSATION;\n#endif\ngl_Position = currentPositionJittered;\n\n"),this.addFragmentFinalCode("\nvec2 oldPos = vPreviousPosition.xy;\n oldPos /= vPreviousPosition.w;\n oldPos.xy = (oldPos.xy+1.)/2.0;\n\nvec2 newPos = vCurrentPosition.xy;\n newPos /= vCurrentPosition.w;\n newPos.xy = (newPos.xy+1.)/2.0;\n\nvec2 velocity = (newPos - oldPos);\n\n\n\nif (gl_FragColor.a <= alphaDiscardCutoff) discard;\n\ngVelocity = vec4(velocity, 0.0, 1.0);\n")),this}},{key:"buildShader",value:function(e,n){this.resultCode[e]=n.build(this.setShader(e),"v4")}},{key:"setMaterial",value:function(e,n){return this.defines={},this}},{key:"addFlow",value:function(e,n,t){return this.addSlot(e).addCache(n).addContext(t)}},{key:"removeFlow",value:function(){return this.removeSlot().removeCache().removeContext()}},{key:"addCache",value:function(e){return this.cache=null!=e?e:"",this.caches.push(this.cache),this}},{key:"removeCache",value:function(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}},{key:"addContext",value:function(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}},{key:"removeContext",value:function(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}},{key:"addSlot",value:function(e){return this.slot=e||"",this.slots.push(this.slot),this}},{key:"removeSlot",value:function(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}},{key:"addFragmentVariable",value:function(e,n){void 0===this.fragmentVariables[e]&&(this.addFragmentCode("".concat(n," ").concat(e,";")),this.fragmentVariables[e]="")}},{key:"addFragmentParsVariable",value:function(e,n){void 0===this.fragmentParsVariables[e]&&(this.addFragmentParsCode("".concat(n," ").concat(e,";")),this.fragmentParsVariables[e]="")}},{key:"addVertexParsVariable",value:function(e,n){void 0===this.vertexParsVariables[e]&&(this.addVertexParsCode("".concat(n," ").concat(e,";")),this.vertexParsVariables[e]="")}},{key:"addVertexCode",value:function(e){this.addCode(e,"vertex")}},{key:"addFragmentCode",value:function(e){this.addCode(e,"fragment")}},{key:"addCode",value:function(e,n){this.code[null!=n?n:this.shader]+=e+"\n"}},{key:"addVertexNodeCode",value:function(e){this.addNodeCode(e,"vertex")}},{key:"addFragmentNodeCode",value:function(e){this.addNodeCode(e,"fragment")}},{key:"addNodeCode",value:function(e,n){this.nodeCode[null!=n?n:this.shader]+=e+"\n"}},{key:"clearNodeCode",value:function(e){e=null!=e?e:this.shader;var n=this.nodeCode[e];return this.nodeCode[e]="",n}},{key:"clearVertexNodeCode",value:function(){return this.clearNodeCode("vertex")}},{key:"clearFragmentNodeCode",value:function(){return this.clearNodeCode("fragment")}},{key:"addVertexFinalCode",value:function(e){this.addFinalCode(e,"vertex")}},{key:"addFragmentFinalCode",value:function(e){this.addFinalCode(e,"fragment")}},{key:"addFinalCode",value:function(e,n){this.finalCode[null!=n?n:this.shader]+=e+"\n"}},{key:"addVertexParsCode",value:function(e){this.addParsCode(e,"vertex")}},{key:"addFragmentParsCode",value:function(e){this.addParsCode(e,"fragment")}},{key:"addParsCode",value:function(e,n){this.parsCode[null!=n?n:this.shader]+=e+"\n"}},{key:"addVaryCode",value:function(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}},{key:"isCache",value:function(e){return -1!==this.caches.indexOf(e)}},{key:"isSlot",value:function(e){return -1!==this.slots.indexOf(e)}},{key:"define",value:function(e,n){this.defines[e]=void 0===n?1:n}},{key:"require",value:function(e){this.requires[e]=!0}},{key:"isDefined",value:function(e){return void 0!==this.defines[e]}},{key:"getVar",value:function(e,n,t){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"varying",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"V",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",o=this.getVars(a),s=o[e];if(!s){var l=o.length;s={name:t||"node"+r+l+(i?"_"+i:""),type:n},o.push(s),o[e]=s}return s}},{key:"getTempVar",value:function(e,n,t,a){return this.getVar(e,n,t,this.shader,"T",a)}},{key:"getAttribute",value:function(e,n){if(!this.attributes[e]){var t=this.getVar(e,n);this.addVertexParsCode("attribute "+n+" "+e+";"),this.addVertexFinalCode(t.name+" = "+e+";"),this.attributes[e]={varying:t,name:e,type:n}}return this.attributes[e]}},{key:"getCode",value:function(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")}},{key:"getVarListCode",value:function(e,n){n=null!=n?n:"";for(var t="",a=0,r=e.length;a<r;++a){var i=e[a],o=i.type,s=i.name,l=i.size,c=this.getFormatByType(o);if(void 0===c)throw Error("Node pars "+c+" not found.");c.includes("[]")?t+=n+" "+c.substring(0,c.length-2)+" "+s+"[".concat(l,"];\n"):t+=n+" "+c+" "+s+";\n"}return t}},{key:"getVars",value:function(e){return this.inputs.vars[null!=e?e:this.shader]}},{key:"getNodeData",value:function(e){var n=C(e,k)?e.uuid:e;return this.nodeData[n]=this.nodeData[n]||{}}},{key:"createUniform",value:function(e,n,t,a,r,i){if(n.includes("[]")){var o=this.inputs.arrayUniforms,s=o.list.length,l=new B({type:n,size:t.size,name:a||"nodeUA"+s+(i?"_"+i:""),node:t,needsUpdate:r});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}var c=this.inputs.uniforms,u=c.list.length,d=new B({type:n,name:a||"nodeU"+u+(i?"_"+i:""),node:t,needsUpdate:r});return c.list.push(d),c[e].push(d),c[e][d.name]=d,this.uniforms[d.name]=d,d}},{key:"createVertexUniform",value:function(e,n,t,a,r){return this.createUniform("vertex",e,n,t,a,r)}},{key:"createFragmentUniform",value:function(e,n,t,a,r){return this.createUniform("fragment",e,n,t,a,r)}},{key:"include",value:function(e,n,t){if(e="string"==typeof e?V.get(e):e,!1===this.context.include)return e.name;C(e,Z)?r=this.includes.functions:C(e,Q)?r=this.includes.consts:C(e,en)&&(r=this.includes.structs);var a=r[this.shader]=r[this.shader]||[];if(e){var r,i,o=a[e.name];if(o||(o=a[e.name]={node:e,deps:[]},a.push(o),o.src=e.build(this,"source")),C(e,Z)&&n&&a[n.name]&&-1===a[n.name].deps.indexOf(e)&&(a[n.name].deps.push(e),null==(i=e.includes)?void 0:i.length)){var s=0;do this.include(e.includes[s++],n);while(s<e.includes.length)}return t&&(o.src=t),e.name}throw Error("Include not found.")}},{key:"colorToVectorProperties",value:function(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}},{key:"colorToVector",value:function(e){return e.replace(/c/g,"v3")}},{key:"getIncludes",value:function(e,n){return this.includes[e][n||this.shader]}},{key:"getConstructorFromLength",value:function(e){return em[e-1]}},{key:"isTypeMatrix",value:function(e){return/^m/.test(e)}},{key:"getTypeLength",value:function(e){return"f"===e?1:parseInt(this.colorToVector(e).substr(1))}},{key:"getTypeFromLength",value:function(e){return 1===e?"f":"v"+e}},{key:"findNode",value:function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];for(var a=0;a<arguments.length;a++){var r=n[a];if(null==r?void 0:r.isNode)return r}}},{key:"resolve",value:function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];for(var a=0;a<arguments.length;a++){var r=n[a];if(void 0!==r){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case h.fa:case h.ga:return new eh(r);case h.ja:return new ep(new ei(r));default:return new ei(r)}if(r.isVector2)return new W(r);if(r.isVector3)return new X(r);if(r.isVector4)return new j(r)}}}},{key:"format",value:function(e,n,t){switch(this.colorToVector(t+" <- "+n)){case"f <- v2":case"f <- v3":case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":case"i <- v3":case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}},{key:"getTypeByFormat",value:function(e){return eg[e]||e}},{key:"getFormatByType",value:function(e){return e_[e]||e}},{key:"getUUID",value:function(e,n){return(n=void 0===n||n)&&this.cache&&(e=this.cache+"-"+e),e}},{key:"getElementByIndex",value:function(e){return ev[e]}},{key:"getIndexByElement",value:function(e){return ev.indexOf(e)}},{key:"isShader",value:function(e){return this.shader===e}},{key:"setShader",value:function(e){return this.shader=e,this}},{key:"mergeDefines",value:function(e){for(var n in e)this.defines[n]=e[n];return this.defines}},{key:"mergeUniform",value:function(e){for(var n in e)this.uniforms[n]=e[n];return this.uniforms}},{key:"getTextureEncodingFromMap",value:function(e){var n;return e?e.isTexture&&(n=e.colorSpace===h.Ib?3001:3e3):n=3e3,3e3===n&&this.context.gamma&&(n=3001),n}}]),e}(),eS=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return x(this,n),(e=_(this,n,["c"])).nodeType="Color",e.value=C(t,c.i)?t:new c.i(t||0,a,r,i),e}return M(n,e),b(n,[{key:"setRGBA",value:function(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}},{key:"generate",value:function(e,n,t,a,r,i){t=e.getUUID(null!=t?t:this.getUUID()),a=null!=a?a:this.getType(e);var o=e.getNodeData(t),s=this.getReadonly()&&void 0!==this.generateReadonly;if(this.alpha){var l=this.alpha.build(e,"f");e.addFragmentNodeCode("accumAlpha += ( 1.0 - accumAlpha ) * ".concat(l,";"))}return s?this.generateReadonly(e,n,t,a,r,i):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(a,this,r,i,this.getLabel())),e.format(o.vertex.name,a,n)):(o.fragment||(o.fragment=e.createFragmentUniform(a,this,r,i,this.getLabel())),e.format(o.fragment.name,a,n))}},{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",a,n)}}]),n}(H),ey=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["i"])).nodeType="Int",t.value=Math.floor(null!=e?e:0),t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format(this.value.toString(),a,n)}}]),n}(H);function eb(){var e=null,n=!1,t=null,a=null;function r(n,i){t(n,i),a=e.requestAnimationFrame(r)}return{start:function(){!0!==n&&null!==t&&null!==e&&(a=e.requestAnimationFrame(r),n=!0)},stop:function(){null!==e&&e.cancelAnimationFrame(a),n=!1},setAnimationLoop:function(e){t=e},setContext:function(n){e=n}}}function ew(e){var n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var a=n.get(t);a&&(e.deleteBuffer(a.buffer),n.delete(t))},update:function(t,a){if(t.isInterleavedBufferAttribute&&(t=t.data),t.isGLBufferAttribute){var r=n.get(t);return void((!r||r.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}var i=n.get(t);if(void 0===i)n.set(t,function(n,t){var a,r=n.array,i=n.usage,o=r.byteLength,s=e.createBuffer();if(e.bindBuffer(t,s),e.bufferData(t,r,i),n.onUploadCallback(),C(r,Float32Array))a=e.FLOAT;else if(("u"<typeof Float16Array?"undefined":I(Float16Array))<"u"&&C(r,Float16Array))a=e.HALF_FLOAT;else if(C(r,Uint16Array))a=n.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(C(r,Int16Array))a=e.SHORT;else if(C(r,Uint32Array))a=e.UNSIGNED_INT;else if(C(r,Int32Array))a=e.INT;else if(C(r,Int8Array))a=e.BYTE;else if(C(r,Uint8Array))a=e.UNSIGNED_BYTE;else{if(!C(r,Uint8ClampedArray))throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);a=e.UNSIGNED_BYTE}return{buffer:s,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:n.version,size:o}}(t,a));else if(i.version<t.version){if(i.size!==t.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");(function(n,t,a){var r=t.array,i=t.updateRanges;if(e.bindBuffer(a,n),0===i.length)e.bufferSubData(a,0,r);else{i.sort(function(e,n){return e.start-n.start});for(var o=0,s=1;s<i.length;s++){var l=i[o],c=i[s];c.start<=l.start+l.count+1?l.count=Math.max(l.count,c.start+c.count-l.start):i[++o]=c}i.length=o+1;for(var u=0,d=i.length;u<d;u++){var f=i[u];e.bufferSubData(a,f.start*r.BYTES_PER_ELEMENT,r,f.start,f.count)}t.clearUpdateRanges()}t.onUploadCallback()})(i.buffer,t,a),i.version=t.version}}}}var eT={alphahash_fragment:"#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec4 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n }\n#endif",batching_vertex:"#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} ",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n vColor *= color;\n#elif defined( USE_COLOR )\n vColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} ",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #ifdef DOUBLE_SIDED\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #ifdef DOUBLE_SIDED\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #ifdef FLIP_SIDED\n vBitangent = - vBitangent;\n #endif\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n \n return depth * ( far - near ) - far;\n #else\n return depth * ( near - far ) - near;\n #endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n \n #ifdef USE_REVERSED_DEPTH_BUFFER\n return ( near * far ) / ( ( near - far ) * depth - near );\n #else\n return ( near * far ) / ( ( far - near ) * depth - far );\n #endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <logdepthbuf_fragment>\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vLineDistance = scale * lineDistance;\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n #include <logdepthbuf_fragment>\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}"},eE={common:{diffuse:{value:new h.Tc(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new h.Gc},alphaMap:{value:null},alphaMapTransform:{value:new h.Gc},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new h.Gc}},envmap:{envMap:{value:null},envMapRotation:{value:new h.Gc},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new h.Gc}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new h.Gc}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new h.Gc},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new h.Gc},normalScale:{value:new h.Dc(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new h.Gc},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new h.Gc}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new h.Gc}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new h.Gc}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new h.Tc(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new h.Fc},probesMax:{value:new h.Fc},probesResolution:{value:new h.Fc}},points:{diffuse:{value:new h.Tc(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new h.Gc},alphaTest:{value:0},uvTransform:{value:new h.Gc}},sprite:{diffuse:{value:new h.Tc(0xffffff)},opacity:{value:1},center:{value:new h.Dc(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new h.Gc},alphaMap:{value:null},alphaMapTransform:{value:new h.Gc},alphaTest:{value:0}}},eM={basic:{uniforms:(0,h.$d)([eE.common,eE.specularmap,eE.envmap,eE.aomap,eE.lightmap,eE.fog]),vertexShader:eT.meshbasic_vert,fragmentShader:eT.meshbasic_frag},lambert:{uniforms:(0,h.$d)([eE.common,eE.specularmap,eE.envmap,eE.aomap,eE.lightmap,eE.emissivemap,eE.bumpmap,eE.normalmap,eE.displacementmap,eE.fog,eE.lights,{emissive:{value:new h.Tc(0)},envMapIntensity:{value:1}}]),vertexShader:eT.meshlambert_vert,fragmentShader:eT.meshlambert_frag},phong:{uniforms:(0,h.$d)([eE.common,eE.specularmap,eE.envmap,eE.aomap,eE.lightmap,eE.emissivemap,eE.bumpmap,eE.normalmap,eE.displacementmap,eE.fog,eE.lights,{emissive:{value:new h.Tc(0)},specular:{value:new h.Tc(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:eT.meshphong_vert,fragmentShader:eT.meshphong_frag},standard:{uniforms:(0,h.$d)([eE.common,eE.envmap,eE.aomap,eE.lightmap,eE.emissivemap,eE.bumpmap,eE.normalmap,eE.displacementmap,eE.roughnessmap,eE.metalnessmap,eE.fog,eE.lights,{emissive:{value:new h.Tc(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:eT.meshphysical_vert,fragmentShader:eT.meshphysical_frag},toon:{uniforms:(0,h.$d)([eE.common,eE.aomap,eE.lightmap,eE.emissivemap,eE.bumpmap,eE.normalmap,eE.displacementmap,eE.gradientmap,eE.fog,eE.lights,{emissive:{value:new h.Tc(0)}}]),vertexShader:eT.meshtoon_vert,fragmentShader:eT.meshtoon_frag},matcap:{uniforms:(0,h.$d)([eE.common,eE.bumpmap,eE.normalmap,eE.displacementmap,eE.fog,{matcap:{value:null}}]),vertexShader:eT.meshmatcap_vert,fragmentShader:eT.meshmatcap_frag},points:{uniforms:(0,h.$d)([eE.points,eE.fog]),vertexShader:eT.points_vert,fragmentShader:eT.points_frag},dashed:{uniforms:(0,h.$d)([eE.common,eE.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:eT.linedashed_vert,fragmentShader:eT.linedashed_frag},depth:{uniforms:(0,h.$d)([eE.common,eE.displacementmap]),vertexShader:eT.depth_vert,fragmentShader:eT.depth_frag},normal:{uniforms:(0,h.$d)([eE.common,eE.bumpmap,eE.normalmap,eE.displacementmap,{opacity:{value:1}}]),vertexShader:eT.meshnormal_vert,fragmentShader:eT.meshnormal_frag},sprite:{uniforms:(0,h.$d)([eE.sprite,eE.fog]),vertexShader:eT.sprite_vert,fragmentShader:eT.sprite_frag},background:{uniforms:{uvTransform:{value:new h.Gc},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:eT.background_vert,fragmentShader:eT.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new h.Gc}},vertexShader:eT.backgroundCube_vert,fragmentShader:eT.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:eT.cube_vert,fragmentShader:eT.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:eT.equirect_vert,fragmentShader:eT.equirect_frag},distance:{uniforms:(0,h.$d)([eE.common,eE.displacementmap,{referencePosition:{value:new h.Fc},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:eT.distance_vert,fragmentShader:eT.distance_frag},shadow:{uniforms:(0,h.$d)([eE.lights,eE.fog,{color:{value:new h.Tc(0)},opacity:{value:1}}]),vertexShader:eT.shadow_vert,fragmentShader:eT.shadow_frag}};eM.physical={uniforms:(0,h.$d)([eM.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new h.Gc},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new h.Gc},clearcoatNormalScale:{value:new h.Dc(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new h.Gc},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new h.Gc},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new h.Gc},sheen:{value:0},sheenColor:{value:new h.Tc(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new h.Gc},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new h.Gc},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new h.Gc},transmissionSamplerSize:{value:new h.Dc},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new h.Gc},attenuationDistance:{value:0},attenuationColor:{value:new h.Tc(0)},specularColor:{value:new h.Tc(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new h.Gc},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new h.Gc},anisotropyVector:{value:new h.Dc},anisotropyMap:{value:null},anisotropyMapTransform:{value:new h.Gc}}]),vertexShader:eT.meshphysical_vert,fragmentShader:eT.meshphysical_frag};var eC={r:0,b:0,g:0},eR=new h.Oc,eA=new h.Gc;function eP(e,n,t,a,r,i){var o,s,l=new h.Tc(0),c=+(!0!==r),u=null,d=0,f=null;function p(e){var t=!0===e.isScene?e.background:null;if(t&&t.isTexture){var a=e.backgroundBlurriness>0;t=n.get(t,a)}return t}function v(n,a){n.getRGB(eC,(0,h.ae)(e)),t.buffers.color.setClear(eC.r,eC.g,eC.b,a,i)}return{getClearColor:function(){return l},setClearColor:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;l.set(e),v(l,c=n)},getClearAlpha:function(){return c},setClearAlpha:function(e){v(l,c=e)},render:function(n){var a=!1,r=p(n);null===r?v(l,c):r&&r.isColor&&(v(r,1),a=!0);var o=e.xr.getEnvironmentBlendMode();"additive"===o?t.buffers.color.setClear(0,0,0,1,i):"alpha-blend"===o&&t.buffers.color.setClear(0,0,0,0,i),(e.autoClear||a)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(n,t){var r=p(t);r&&(r.isCubeTexture||r.mapping===h.ja)?(void 0===s&&((s=new h.ld(new h.Ed(1,1,1),new h.ce({name:"BackgroundCubeMaterial",uniforms:(0,h._d)(eM.backgroundCube.uniforms),vertexShader:eM.backgroundCube.vertexShader,fragmentShader:eM.backgroundCube.fragmentShader,side:h.k,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,n,t){this.matrixWorld.copyPosition(t.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(s)),s.material.uniforms.envMap.value=r,s.material.uniforms.backgroundBlurriness.value=t.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,s.material.uniforms.backgroundRotation.value.setFromMatrix4(eR.makeRotationFromEuler(t.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&s.material.uniforms.backgroundRotation.value.premultiply(eA),s.material.toneMapped=h.Hc.getTransfer(r.colorSpace)!==h.Lb,(u!==r||d!==r.version||f!==e.toneMapping)&&(s.material.needsUpdate=!0,u=r,d=r.version,f=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null)):r&&r.isTexture&&(void 0===o&&((o=new h.ld(new h.Vd(2,2),new h.ce({name:"BackgroundMaterial",uniforms:(0,h._d)(eM.background.uniforms),vertexShader:eM.background.vertexShader,fragmentShader:eM.background.fragmentShader,side:h.j,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,o.material.toneMapped=h.Hc.getTransfer(r.colorSpace)!==h.Lb,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),(u!==r||d!==r.version||f!==e.toneMapping)&&(o.material.needsUpdate=!0,u=r,d=r.version,f=e.toneMapping),o.layers.enableAll(),n.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==s&&(s.geometry.dispose(),s.material.dispose(),s=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function eD(e,n){var t=e.getParameter(e.MAX_VERTEX_ATTRIBS),a={},r=c(null),i=r,o=!1;function s(n){return e.bindVertexArray(n)}function l(n){return e.deleteVertexArray(n)}function c(e){for(var n=[],a=[],r=[],i=0;i<t;i++)n[i]=0,a[i]=0,r[i]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:n,enabledAttributes:a,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){for(var e=i.newAttributes,n=0,t=e.length;n<t;n++)e[n]=0}function d(e){f(e,0)}function f(n,t){var a=i.newAttributes,r=i.enabledAttributes,o=i.attributeDivisors;a[n]=1,0===r[n]&&(e.enableVertexAttribArray(n),r[n]=1),o[n]!==t&&(e.vertexAttribDivisor(n,t),o[n]=t)}function p(){for(var n=i.newAttributes,t=i.enabledAttributes,a=0,r=t.length;a<r;a++)t[a]!==n[a]&&(e.disableVertexAttribArray(a),t[a]=0)}function v(n,t,a,r,i,o,s){!0===s?e.vertexAttribIPointer(n,t,a,i,o):e.vertexAttribPointer(n,t,a,r,i,o)}function m(){g(),o=!0,i!==r&&s((i=r).object)}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(t,r,l,m,g){var _,x,S,y,b,w,T=!1,E=(_=!0===r.wireframe,void 0===(x=a[m.id])&&(x={},a[m.id]=x),void 0===(y=x[S=!0===t.isInstancedMesh?t.id:0])&&(y={},x[S]=y),void 0===(b=y[l.id])&&(b={},y[l.id]=b),void 0===(w=b[_])&&(w=c(e.createVertexArray()),b[_]=w),w);i!==E&&s((i=E).object),(T=function(e,n,t,a){var r=i.attributes,o=n.attributes,s=0,l=t.getAttributes();for(var c in l)if(l[c].location>=0){var u=r[c],d=o[c];if(void 0===d&&("instanceMatrix"===c&&e.instanceMatrix&&(d=e.instanceMatrix),"instanceColor"===c&&e.instanceColor&&(d=e.instanceColor)),void 0===u||u.attribute!==d||d&&u.data!==d.data)return!0;s++}return i.attributesNum!==s||i.index!==a}(t,m,l,g))&&function(e,n,t,a){var r={},o=n.attributes,s=0,l=t.getAttributes();for(var c in l)if(l[c].location>=0){var u=o[c];void 0===u&&("instanceMatrix"===c&&e.instanceMatrix&&(u=e.instanceMatrix),"instanceColor"===c&&e.instanceColor&&(u=e.instanceColor));var d={};d.attribute=u,u&&u.data&&(d.data=u.data),r[c]=d,s++}i.attributes=r,i.attributesNum=s,i.index=a}(t,m,l,g),null!==g&&n.update(g,e.ELEMENT_ARRAY_BUFFER),(T||o)&&(o=!1,function(t,a,r,i){u();var o=i.attributes,s=r.getAttributes(),l=a.defaultAttributeValues;for(var c in s){var m=s[c];if(m.location>=0){var g=o[c];if(void 0===g&&("instanceMatrix"===c&&t.instanceMatrix&&(g=t.instanceMatrix),"instanceColor"===c&&t.instanceColor&&(g=t.instanceColor)),void 0!==g){var _=g.normalized,x=g.itemSize,S=n.get(g);if(void 0===S)continue;var y=S.buffer,b=S.type,w=S.bytesPerElement,T=b===e.INT||b===e.UNSIGNED_INT||g.gpuType===h.ya;if(g.isInterleavedBufferAttribute){var E=g.data,M=E.stride,C=g.offset;if(E.isInstancedInterleavedBuffer){for(var R=0;R<m.locationSize;R++)f(m.location+R,E.meshPerAttribute);!0!==t.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=E.meshPerAttribute*E.count)}else for(var A=0;A<m.locationSize;A++)d(m.location+A);e.bindBuffer(e.ARRAY_BUFFER,y);for(var P=0;P<m.locationSize;P++)v(m.location+P,x/m.locationSize,b,_,M*w,(C+x/m.locationSize*P)*w,T)}else{if(g.isInstancedBufferAttribute){for(var D=0;D<m.locationSize;D++)f(m.location+D,g.meshPerAttribute);!0!==t.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=g.meshPerAttribute*g.count)}else for(var L=0;L<m.locationSize;L++)d(m.location+L);e.bindBuffer(e.ARRAY_BUFFER,y);for(var U=0;U<m.locationSize;U++)v(m.location+U,x/m.locationSize,b,_,x*w,x/m.locationSize*U*w,T)}}else if(void 0!==l){var N=l[c];if(void 0!==N)switch(N.length){case 2:e.vertexAttrib2fv(m.location,N);break;case 3:e.vertexAttrib3fv(m.location,N);break;case 4:e.vertexAttrib4fv(m.location,N);break;default:e.vertexAttrib1fv(m.location,N)}}}}p()}(t,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){for(var e in m(),a){var n=a[e];for(var t in n){var r=n[t];for(var i in r){var o=r[i];for(var s in o)l(o[s].object),delete o[s];delete r[i]}}delete a[e]}},releaseStatesOfGeometry:function(e){if(void 0!==a[e.id]){var n=a[e.id];for(var t in n){var r=n[t];for(var i in r){var o=r[i];for(var s in o)l(o[s].object),delete o[s];delete r[i]}}delete a[e.id]}},releaseStatesOfObject:function(e){for(var n in a){var t=a[n],r=!0===e.isInstancedMesh?e.id:0,i=t[r];if(void 0!==i){for(var o in i){var s=i[o];for(var c in s)l(s[c].object),delete s[c];delete i[o]}delete t[r],0===Object.keys(t).length&&delete a[n]}}},releaseStatesOfProgram:function(e){for(var n in a){var t=a[n];for(var r in t){var i=t[r];if(void 0!==i[e.id]){var o=i[e.id];for(var s in o)l(o[s].object),delete o[s];delete i[e.id]}}}},initAttributes:u,enableAttribute:d,disableUnusedAttributes:p}}function eL(e,n,t){var a;this.setMode=function(e){a=e},this.render=function(n,r){e.drawArrays(a,n,r),t.update(r,a,1)},this.renderInstances=function(n,r,i){0!==i&&(e.drawArraysInstanced(a,n,r,i),t.update(r,a,i))},this.renderMultiDraw=function(e,r,i){if(0!==i){n.get("WEBGL_multi_draw").multiDrawArraysWEBGL(a,e,0,r,0,i);for(var o=0,s=0;s<i;s++)o+=r[s];t.update(o,a,1)}}}function eU(e,n,t,a){function r(n){if("highp"===n){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";n="mediump"}return"mediump"===n&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var i,o=void 0!==t.precision?t.precision:"highp",s=r(o);s!==o&&((0,h.wc)("WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===t.logarithmicDepthBuffer,c=!0===t.reversedDepthBuffer&&n.has("EXT_clip_control");return!0===t.reversedDepthBuffer&&!1===c&&(0,h.wc)("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===n.has("EXT_texture_filter_anisotropic")){var t=n.get("EXT_texture_filter_anisotropic");i=e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,textureFormatReadable:function(n){return n===h.Ja||a.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(t){var r=t===h.Ba&&(n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float"));return!(t!==h.ua&&a.convert(t)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&t!==h.Aa&&!r)},precision:o,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function eN(e){var n=this,t=null,a=0,r=!1,i=!1,o=new h.rd,s=new h.Gc,l={value:null,needsUpdate:!1};function c(e,t,a,r){var i=null!==e?e.length:0,c=null;if(0!==i){if(c=l.value,!0!==r||null===c){var u=a+4*i,d=t.matrixWorldInverse;s.getNormalMatrix(d),(null===c||c.length<u)&&(c=new Float32Array(u));for(var f=0,p=a;f!==i;++f,p+=4)o.copy(e[f]).applyMatrix4(d,s),o.normal.toArray(c,p),c[p+3]=o.constant}l.value=c,l.needsUpdate=!0}return n.numPlanes=i,n.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,n){var t=0!==e.length||n||0!==a||r;return r=n,a=e.length,t},this.beginShadows=function(){i=!0,c(null)},this.endShadows=function(){i=!1},this.setGlobalState=function(e,n){t=c(e,n,0)},this.setState=function(o,s,u){var d=o.clippingPlanes,f=o.clipIntersection,p=o.clipShadows,h=e.get(o);if(r&&null!==d&&0!==d.length&&(!i||p)){var v=i?0:a,m=4*v,g=h.clippingState||null;l.value=g,g=c(d,s,m,u);for(var _=0;_!==m;++_)g[_]=t[_];h.clippingState=g,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=v}else i?c(null):(l.value!==t&&(l.value=t,l.needsUpdate=a>0),n.numPlanes=a,n.numIntersection=0)}}eA.set(-1,0,0,0,1,0,0,0,1);var eI=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,n),(e=_(this,n,[t,t,a])).isWebGLCubeRenderTarget=!0;var r={width:t,height:t,depth:1};return e.texture=new h.Ad([r,r,r,r,r,r]),e._setTextureOptions(a),e.texture.isRenderTargetTexture=!0,e}return M(n,e),b(n,[{key:"fromEquirectangularTexture",value:function(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;var t=new h.Ed(5,5,5),a=new h.ce({name:"CubemapFromEquirect",uniforms:(0,h._d)({tEquirect:{value:null}}),vertexShader:"\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection( position, modelMatrix );\n\n #include <begin_vertex>\n #include <project_vertex>\n\n }\n ",fragmentShader:"\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include <common>\n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n ",side:h.k,blending:h.m});a.uniforms.tEquirect.value=n;var r=new h.ld(t,a),i=n.minFilter;return n.minFilter===h.sa&&(n.minFilter=h.qa),(function(){throw Error("fromEquirectangularTexture is not supported by the Spline runtime")})().update(e,r),n.minFilter=i,r.geometry.dispose(),r.material.dispose(),this}},{key:"clear",value:function(e){for(var n=!(arguments.length>1)||void 0===arguments[1]||arguments[1],t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=!(arguments.length>3)||void 0===arguments[3]||arguments[3],r=e.getRenderTarget(),i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(n,t,a);e.setRenderTarget(r)}}]),n}(h.Lc);function eO(e){var n=new WeakMap,t=new WeakMap,a=null;function r(e,n){return n===h.ha?e.mapping=h.fa:n===h.ia&&(e.mapping=h.ga),e}function i(e){var t=e.target;t.removeEventListener("dispose",i);var a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}function o(e){var n=e.target;n.removeEventListener("dispose",o);var a=t.get(n);void 0!==a&&(t.delete(n),a.dispose())}return{get:function(s){var l=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return null==s?null:l?function(e){if(e&&e.isTexture){var n=e.mapping,r=n===h.ha||n===h.ia,i=n===h.fa||n===h.ga;if(r||i){var s=t.get(e),l=void 0!==s?s.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==l){if(null===a)throw Error("PMREM environment-map conversion is not supported by the Spline runtime");return(s=r?a.fromEquirectangular(e,s):a.fromCubemap(e,s)).texture.pmremVersion=e.pmremVersion,t.set(e,s),s.texture}if(void 0!==s)return s.texture;var c=e.image;if(r&&c&&c.height>0||i&&c&&function(e){for(var n=0,t=0;t<6;t++)void 0!==e[t]&&n++;return 6===n}(c)){if(null===a)throw Error("PMREM environment-map conversion is not supported by the Spline runtime");return(s=r?a.fromEquirectangular(e):a.fromCubemap(e)).texture.pmremVersion=e.pmremVersion,t.set(e,s),e.addEventListener("dispose",o),s.texture}return null}}return e}(s):function(t){if(t&&t.isTexture){var a=t.mapping;if(a===h.ha||a===h.ia){if(n.has(t))return r(n.get(t).texture,t.mapping);var o=t.image;if(o&&o.height>0){var s=new eI(o.height);return s.fromEquirectangularTexture(e,t),n.set(t,s),t.addEventListener("dispose",i),r(s.texture,t.mapping)}return null}}return t}(s)},dispose:function(){n=new WeakMap,t=new WeakMap,null!==a&&(a.dispose(),a=null)}}}function eF(e){var n={};function t(t){if(void 0!==n[t])return n[t];var a=e.getExtension(t);return n[t]=a,a}return{has:function(e){return null!==t(e)},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(e){var n=t(e);return null===n&&(0,h.yc)("WebGLRenderer: "+e+" extension not supported."),n}}}function ez(e,n,t,a){var r={},i=new WeakMap;function o(e){var s=e.target;for(var l in null!==s.index&&n.remove(s.index),s.attributes)n.remove(s.attributes[l]);s.removeEventListener("dispose",o),delete r[s.id];var c=i.get(s);c&&(n.remove(c),i.delete(s)),a.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,t.memory.geometries--}function s(e){var t=[],a=e.index,r=e.attributes.position,o=0;if(void 0!==r){if(null!==a){var s=a.array;o=a.version;for(var l=0,c=s.length;l<c;l+=3){var u=s[l+0],d=s[l+1],f=s[l+2];t.push(u,d,d,f,f,u)}}else{var p=r.array;o=r.version;for(var v=0,m=p.length/3-1;v<m;v+=3){var g=v+0,_=v+1,x=v+2;t.push(g,_,_,x,x,g)}}var S=new(r.count>=65535?h.$c:h._c)(t,1);S.version=o;var y=i.get(e);y&&n.remove(y),i.set(e,S)}}return{get:function(e,n){return!0===r[n.id]||(n.addEventListener("dispose",o),r[n.id]=!0,t.memory.geometries++),n},update:function(t){var a=t.attributes;for(var r in a)n.update(a[r],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){var n=i.get(e);if(n){var t=e.index;null!==t&&n.version<t.version&&s(e)}else s(e);return i.get(e)}}}function ek(e,n,t){var a,r,i;this.setMode=function(e){a=e},this.setIndex=function(e){r=e.type,i=e.bytesPerElement},this.render=function(n,o){e.drawElements(a,o,r,n*i),t.update(o,a,1)},this.renderInstances=function(n,o,s){0!==s&&(e.drawElementsInstanced(a,o,r,n*i,s),t.update(o,a,s))},this.renderMultiDraw=function(e,i,o){if(0!==o){n.get("WEBGL_multi_draw").multiDrawElementsWEBGL(a,i,0,r,e,0,o);for(var s=0,l=0;l<o;l++)s+=i[l];t.update(s,a,1)}}}function eB(e){var n={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:n,programs:null,autoReset:!0,reset:function(){n.calls=0,n.triangles=0,n.points=0,n.lines=0},update:function(t,a,r){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=t/3*r;break;case e.LINES:n.lines+=t/2*r;break;case e.LINE_STRIP:n.lines+=r*(t-1);break;case e.LINE_LOOP:n.lines+=r*t;break;case e.POINTS:n.points+=r*t;break;default:(0,h.xc)("WebGLInfo: Unknown draw mode:",a)}}}}function eV(e,n,t){var a=new WeakMap,r=new h.Jc;return{update:function(i,o,s){var l=i.morphTargetInfluences,c=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=void 0!==c?c.length:0,d=a.get(o);if(void 0===d||d.count!==u){var f=function(){T.dispose(),a.delete(o),o.removeEventListener("dispose",f)};void 0!==d&&d.texture.dispose();var p=void 0!==o.morphAttributes.position,v=void 0!==o.morphAttributes.normal,m=void 0!==o.morphAttributes.color,g=o.morphAttributes.position||[],_=o.morphAttributes.normal||[],x=o.morphAttributes.color||[],S=0;!0===p&&(S=1),!0===v&&(S=2),!0===m&&(S=3);var y=o.attributes.position.count*S,b=1;y>n.maxTextureSize&&(b=Math.ceil(y/n.maxTextureSize),y=n.maxTextureSize);var w=new Float32Array(y*b*4*u),T=new h.Mc(w,y,b,u);T.type=h.Aa,T.needsUpdate=!0;for(var E=4*S,M=0;M<u;M++)for(var C=g[M],R=_[M],A=x[M],P=y*b*4*M,D=0;D<C.count;D++){var L=D*E;!0===p&&(r.fromBufferAttribute(C,D),w[P+L+0]=r.x,w[P+L+1]=r.y,w[P+L+2]=r.z,w[P+L+3]=0),!0===v&&(r.fromBufferAttribute(R,D),w[P+L+4]=r.x,w[P+L+5]=r.y,w[P+L+6]=r.z,w[P+L+7]=0),!0===m&&(r.fromBufferAttribute(A,D),w[P+L+8]=r.x,w[P+L+9]=r.y,w[P+L+10]=r.z,w[P+L+11]=4===A.itemSize?r.w:1)}d={count:u,texture:T,size:new h.Dc(y,b)},a.set(o,d),o.addEventListener("dispose",f)}if(!0===i.isInstancedMesh&&null!==i.morphTexture)s.getUniforms().setValue(e,"morphTexture",i.morphTexture,t);else{for(var U=0,N=0;N<l.length;N++)U+=l[N];var I=o.morphTargetsRelative?1:1-U;s.getUniforms().setValue(e,"morphTargetBaseInfluence",I),s.getUniforms().setValue(e,"morphTargetInfluences",l)}s.getUniforms().setValue(e,"morphTargetsTexture",d.texture,t),s.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}}}function eG(e,n,t,a,r){var i=new WeakMap;function o(e){var n=e.target;n.removeEventListener("dispose",o),a.releaseStatesOfObject(n),t.remove(n.instanceMatrix),null!==n.instanceColor&&t.remove(n.instanceColor)}return{update:function(a){var s=r.render.frame,l=a.geometry,c=n.get(a,l);if(i.get(c)!==s&&(n.update(c),i.set(c,s)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",o)&&a.addEventListener("dispose",o),i.get(a)!==s&&(t.update(a.instanceMatrix,e.ARRAY_BUFFER),null!==a.instanceColor&&t.update(a.instanceColor,e.ARRAY_BUFFER),i.set(a,s))),a.isSkinnedMesh){var u=a.skeleton;i.get(u)!==s&&(u.update(),i.set(u,s))}return c},dispose:function(){i=new WeakMap}}}var eH=(w(aG={},h.Z,"LINEAR_TONE_MAPPING"),w(aG,h._,"REINHARD_TONE_MAPPING"),w(aG,h.$,"CINEON_TONE_MAPPING"),w(aG,h.aa,"ACES_FILMIC_TONE_MAPPING"),w(aG,h.ca,"AGX_TONE_MAPPING"),w(aG,h.da,"NEUTRAL_TONE_MAPPING"),w(aG,h.ba,"CUSTOM_TONE_MAPPING"),aG);function eW(e,n,t,a,r,i){var o=new h.Lc(n,t,{type:e,depthBuffer:r,stencilBuffer:i,samples:4*!!a,depthTexture:r?new h.Cd(n,t):void 0}),s=new h.Lc(n,t,{type:h.Ba,depthBuffer:!1,stencilBuffer:!1}),l=new h.dd;l.setAttribute("position",new h.bd([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new h.bd([0,2,0,0,2,0],2));var c,u=new h.de({uniforms:{tDiffuse:{value:null}},vertexShader:"\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n #ifdef LINEAR_TONE_MAPPING\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n #elif defined( REINHARD_TONE_MAPPING )\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n #elif defined( CINEON_TONE_MAPPING )\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n #elif defined( AGX_TONE_MAPPING )\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n #elif defined( NEUTRAL_TONE_MAPPING )\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n #elif defined( CUSTOM_TONE_MAPPING )\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n #endif\n\n #ifdef SRGB_TRANSFER\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n #endif\n }",depthTest:!1,depthWrite:!1}),d=new h.ld(l,u),f=new h.Ae(-1,1,1,-1,0,1),p=null,v=null,m=!1,g=null,_=[],x=!1;this.setSize=function(e,n){o.setSize(e,n),s.setSize(e,n);for(var t=0;t<_.length;t++){var a=_[t];a.setSize&&a.setSize(e,n)}},this.setEffects=function(e){x=(_=e).length>0&&!0===_[0].isRenderPass;for(var n=o.width,t=o.height,a=0;a<_.length;a++){var r=_[a];r.setSize&&r.setSize(n,t)}},this.begin=function(e,n){if(m||e.toneMapping===h.Y&&0===_.length)return!1;if(g=n,null!==n){var t=n.width,a=n.height;(o.width!==t||o.height!==a)&&this.setSize(t,a)}return!1===x&&e.setRenderTarget(o),c=e.toneMapping,e.toneMapping=h.Y,!0},this.hasRenderPass=function(){return x},this.end=function(e,n){e.toneMapping=c,m=!0;for(var t=o,a=s,r=0;r<_.length;r++){var i=_[r];if(!1!==i.enabled&&(i.render(e,a,t,n),!1!==i.needsSwap)){var l=t;t=a,a=l}}if(p!==e.outputColorSpace||v!==e.toneMapping){p=e.outputColorSpace,v=e.toneMapping,u.defines={},h.Hc.getTransfer(p)===h.Lb&&(u.defines.SRGB_TRANSFER="");var x=eH[v];x&&(u.defines[x]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=t.texture,e.setRenderTarget(g),e.render(d,f),g=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),l.dispose(),u.dispose()}}var eX=new h.Ic,ej=new h.Cd(1,1),eq=new h.Mc,eY=new h.Nc,eK=new h.Ad,eZ=[],eJ=[],eQ=new Float32Array(16),e$=new Float32Array(9),e0=new Float32Array(4);function e1(e,n,t){var a=e[0];if(null==a||a<=0||a>0)return e;var r=n*t,i=eZ[r];if(void 0===i&&(i=new Float32Array(r),eZ[r]=i),0!==n){a.toArray(i,0);for(var o=1,s=0;o!==n;++o)s+=t,e[o].toArray(i,s)}return i}function e3(e,n){if(e.length!==n.length)return!1;for(var t=0,a=e.length;t<a;t++)if(e[t]!==n[t])return!1;return!0}function e2(e,n){for(var t=0,a=n.length;t<a;t++)e[t]=n[t]}function e4(e,n){var t=eJ[n];void 0===t&&(t=new Int32Array(n),eJ[n]=t);for(var a=0;a!==n;++a)t[a]=e.allocateTextureUnit();return t}function e5(e,n){var t=this.cache;t[0]!==n&&(e.uniform1f(this.addr,n),t[0]=n)}function e6(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y)&&(e.uniform2f(this.addr,n.x,n.y),t[0]=n.x,t[1]=n.y);else{if(e3(t,n))return;e.uniform2fv(this.addr,n),e2(t,n)}}function e8(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z)&&(e.uniform3f(this.addr,n.x,n.y,n.z),t[0]=n.x,t[1]=n.y,t[2]=n.z);else if(void 0!==n.r)(t[0]!==n.r||t[1]!==n.g||t[2]!==n.b)&&(e.uniform3f(this.addr,n.r,n.g,n.b),t[0]=n.r,t[1]=n.g,t[2]=n.b);else{if(e3(t,n))return;e.uniform3fv(this.addr,n),e2(t,n)}}function e9(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z||t[3]!==n.w)&&(e.uniform4f(this.addr,n.x,n.y,n.z,n.w),t[0]=n.x,t[1]=n.y,t[2]=n.z,t[3]=n.w);else{if(e3(t,n))return;e.uniform4fv(this.addr,n),e2(t,n)}}function e7(e,n){var t=this.cache,a=n.elements;if(void 0===a){if(e3(t,n))return;e.uniformMatrix2fv(this.addr,!1,n),e2(t,n)}else{if(e3(t,a))return;e0.set(a),e.uniformMatrix2fv(this.addr,!1,e0),e2(t,a)}}function ne(e,n){var t=this.cache,a=n.elements;if(void 0===a){if(e3(t,n))return;e.uniformMatrix3fv(this.addr,!1,n),e2(t,n)}else{if(e3(t,a))return;e$.set(a),e.uniformMatrix3fv(this.addr,!1,e$),e2(t,a)}}function nn(e,n){var t=this.cache,a=n.elements;if(void 0===a){if(e3(t,n))return;e.uniformMatrix4fv(this.addr,!1,n),e2(t,n)}else{if(e3(t,a))return;eQ.set(a),e.uniformMatrix4fv(this.addr,!1,eQ),e2(t,a)}}function nt(e,n){var t=this.cache;t[0]!==n&&(e.uniform1i(this.addr,n),t[0]=n)}function na(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y)&&(e.uniform2i(this.addr,n.x,n.y),t[0]=n.x,t[1]=n.y);else{if(e3(t,n))return;e.uniform2iv(this.addr,n),e2(t,n)}}function nr(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z)&&(e.uniform3i(this.addr,n.x,n.y,n.z),t[0]=n.x,t[1]=n.y,t[2]=n.z);else{if(e3(t,n))return;e.uniform3iv(this.addr,n),e2(t,n)}}function ni(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z||t[3]!==n.w)&&(e.uniform4i(this.addr,n.x,n.y,n.z,n.w),t[0]=n.x,t[1]=n.y,t[2]=n.z,t[3]=n.w);else{if(e3(t,n))return;e.uniform4iv(this.addr,n),e2(t,n)}}function no(e,n){var t=this.cache;t[0]!==n&&(e.uniform1ui(this.addr,n),t[0]=n)}function ns(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y)&&(e.uniform2ui(this.addr,n.x,n.y),t[0]=n.x,t[1]=n.y);else{if(e3(t,n))return;e.uniform2uiv(this.addr,n),e2(t,n)}}function nl(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z)&&(e.uniform3ui(this.addr,n.x,n.y,n.z),t[0]=n.x,t[1]=n.y,t[2]=n.z);else{if(e3(t,n))return;e.uniform3uiv(this.addr,n),e2(t,n)}}function nc(e,n){var t=this.cache;if(void 0!==n.x)(t[0]!==n.x||t[1]!==n.y||t[2]!==n.z||t[3]!==n.w)&&(e.uniform4ui(this.addr,n.x,n.y,n.z,n.w),t[0]=n.x,t[1]=n.y,t[2]=n.z,t[3]=n.w);else{if(e3(t,n))return;e.uniform4uiv(this.addr,n),e2(t,n)}}function nu(e,n,t){var a,r=this.cache,i=t.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),this.type===e.SAMPLER_2D_SHADOW?(ej.compareFunction=t.isReversedDepthBuffer()?h.jc:h.gc,a=ej):a=eX,t.setTexture2D(n||a,i)}function nd(e,n,t){var a=this.cache,r=t.allocateTextureUnit();a[0]!==r&&(e.uniform1i(this.addr,r),a[0]=r),t.setTexture3D(n||eY,r)}function nf(e,n,t){var a=this.cache,r=t.allocateTextureUnit();a[0]!==r&&(e.uniform1i(this.addr,r),a[0]=r),t.setTextureCube(n||eK,r)}function np(e,n,t){var a=this.cache,r=t.allocateTextureUnit();a[0]!==r&&(e.uniform1i(this.addr,r),a[0]=r),t.setTexture2DArray(n||eq,r)}function nh(e,n){e.uniform1fv(this.addr,n)}function nv(e,n){var t=e1(n,this.size,2);e.uniform2fv(this.addr,t)}function nm(e,n){var t=e1(n,this.size,3);e.uniform3fv(this.addr,t)}function ng(e,n){var t=e1(n,this.size,4);e.uniform4fv(this.addr,t)}function n_(e,n){var t=e1(n,this.size,4);e.uniformMatrix2fv(this.addr,!1,t)}function nx(e,n){var t=e1(n,this.size,9);e.uniformMatrix3fv(this.addr,!1,t)}function nS(e,n){var t=e1(n,this.size,16);e.uniformMatrix4fv(this.addr,!1,t)}function ny(e,n){e.uniform1iv(this.addr,n)}function nb(e,n){e.uniform2iv(this.addr,n)}function nw(e,n){e.uniform3iv(this.addr,n)}function nT(e,n){e.uniform4iv(this.addr,n)}function nE(e,n){e.uniform1uiv(this.addr,n)}function nM(e,n){e.uniform2uiv(this.addr,n)}function nC(e,n){e.uniform3uiv(this.addr,n)}function nR(e,n){e.uniform4uiv(this.addr,n)}function nA(e,n,t){var a,r=this.cache,i=n.length,o=e4(t,i);e3(r,o)||(e.uniform1iv(this.addr,o),e2(r,o)),a=this.type===e.SAMPLER_2D_SHADOW?ej:eX;for(var s=0;s!==i;++s)t.setTexture2D(n[s]||a,o[s])}function nP(e,n,t){var a=this.cache,r=n.length,i=e4(t,r);e3(a,i)||(e.uniform1iv(this.addr,i),e2(a,i));for(var o=0;o!==r;++o)t.setTexture3D(n[o]||eY,i[o])}function nD(e,n,t){var a=this.cache,r=n.length,i=e4(t,r);e3(a,i)||(e.uniform1iv(this.addr,i),e2(a,i));for(var o=0;o!==r;++o)t.setTextureCube(n[o]||eK,i[o])}function nL(e,n,t){var a=this.cache,r=n.length,i=e4(t,r);e3(a,i)||(e.uniform1iv(this.addr,i),e2(a,i));for(var o=0;o!==r;++o)t.setTexture2DArray(n[o]||eq,i[o])}var nU=function e(n,t,a){x(this,e),this.id=n,this.addr=a,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return e5;case 35664:return e6;case 35665:return e8;case 35666:return e9;case 35674:return e7;case 35675:return ne;case 35676:return nn;case 5124:case 35670:return nt;case 35667:case 35671:return na;case 35668:case 35672:return nr;case 35669:case 35673:return ni;case 5125:return no;case 36294:return ns;case 36295:return nl;case 36296:return nc;case 35678:case 36198:case 36298:case 36306:case 35682:return nu;case 35679:case 36299:case 36307:return nd;case 35680:case 36300:case 36308:case 36293:return nf;case 36289:case 36303:case 36311:case 36292:return np}}(t.type)},nN=function e(n,t,a){x(this,e),this.id=n,this.addr=a,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return nh;case 35664:return nv;case 35665:return nm;case 35666:return ng;case 35674:return n_;case 35675:return nx;case 35676:return nS;case 5124:case 35670:return ny;case 35667:case 35671:return nb;case 35668:case 35672:return nw;case 35669:case 35673:return nT;case 5125:return nE;case 36294:return nM;case 36295:return nC;case 36296:return nR;case 35678:case 36198:case 36298:case 36306:case 35682:return nA;case 35679:case 36299:case 36307:return nP;case 35680:case 36300:case 36308:case 36293:return nD;case 36289:case 36303:case 36311:case 36292:return nL}}(t.type)},nI=function(){function e(n){x(this,e),this.id=n,this.seq=[],this.map={}}return b(e,[{key:"setValue",value:function(e,n,t){if(void 0!==n)for(var a=this.seq,r=0,i=a.length;r!==i;++r){var o=a[r];o.setValue(e,n[o.id],t)}}}]),e}(),nO=/(\w+)(\])?(\[|\.)?/g;function nF(e,n){e.seq.push(n),e.map[n.id]=n}var nz=function(){function e(n,t){x(this,e),this.seq=[],this.map={};for(var a=n.getProgramParameter(t,n.ACTIVE_UNIFORMS),r=0;r<a;++r){var i=n.getActiveUniform(t,r);!function(e,n,t){var a=e.name,r=a.length;for(nO.lastIndex=0;;){var i=nO.exec(a),o=nO.lastIndex,s=i[1],l="]"===i[2],c=i[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===r){nF(t,void 0===c?new nU(s,e,n):new nN(s,e,n));break}var u=t.map[s];void 0===u&&nF(t,u=new nI(s)),t=u}}(i,n.getUniformLocation(t,i.name),this)}var o=[],s=[],l=!0,c=!1,u=void 0;try{for(var d,f=this.seq[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var p=d.value;p.type===n.SAMPLER_2D_SHADOW||p.type===n.SAMPLER_CUBE_SHADOW||p.type===n.SAMPLER_2D_ARRAY_SHADOW?o.push(p):s.push(p)}}catch(e){c=!0,u=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw u}}o.length>0&&(this.seq=o.concat(s))}return b(e,[{key:"setValue",value:function(e,n,t,a){var r=this.map[n];void 0!==r&&r.setValue(e,t,a)}},{key:"setOptional",value:function(e,n,t){var a=n[t];void 0!==a&&this.setValue(e,t,a)}}],[{key:"upload",value:function(e,n,t,a){for(var r=0,i=n.length;r!==i;++r){var o=n[r],s=t[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,a)}}},{key:"seqWithValue",value:function(e,n){for(var t=[],a=0,r=e.length;a!==r;++a){var i=e[a];i.id in n&&t.push(i)}return t}}]),e}();function nk(e,n,t){var a=e.createShader(n);return e.shaderSource(a,t),e.compileShader(a),a}var nB=0,nV=new h.Gc;function nG(e,n,t){var a=e.getShaderParameter(n,e.COMPILE_STATUS),r=(e.getShaderInfoLog(n)||"").trim();if(a&&""===r)return"";var i=/ERROR: 0:(\d+)/.exec(r);if(i){var o=parseInt(i[1]);return t.toUpperCase()+"\n\n"+r+"\n\n"+function(e,n){for(var t=e.split("\n"),a=[],r=Math.max(n-6,0),i=Math.min(n+6,t.length),o=r;o<i;o++){var s=o+1;a.push("".concat(s===n?">":" "," ").concat(s,": ").concat(t[o]))}return a.join("\n")}(e.getShaderSource(n),o)}return r}var nH=(w(aH={},h.Z,"Linear"),w(aH,h._,"Reinhard"),w(aH,h.$,"Cineon"),w(aH,h.aa,"ACESFilmic"),w(aH,h.ca,"AgX"),w(aH,h.da,"Neutral"),w(aH,h.ba,"Custom"),aH),nW=new h.Fc;function nX(e){return""!==e}function nj(e,n){var t=n.numSpotLightShadows+n.numSpotLightMaps-n.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,n.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,n.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function nq(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}var nY=/^[ \t]*#include +<([\w\d./]+)>/gm;function nK(e){return e.replace(nY,nJ)}var nZ=new Map;function nJ(e,n){var t=eT[n];if(void 0===t){var a=nZ.get(n);if(void 0===a)throw Error("THREE.WebGLProgram: Can not resolve #include <"+n+">");t=eT[a],(0,h.wc)('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,a)}return nK(t)}var nQ=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function n$(e){return e.replace(nQ,n0)}function n0(e,n,t,a){for(var r="",i=parseInt(n);i<parseInt(t);i++)r+=a.replace(/\[\s*i\s*\]/g,"[ "+i+" ]").replace(/UNROLLED_LOOP_INDEX/g,i);return r}function n1(e){var n="precision ".concat(e.precision," float;\n precision ").concat(e.precision," int;\n precision ").concat(e.precision," sampler2D;\n precision ").concat(e.precision," samplerCube;\n precision ").concat(e.precision," sampler3D;\n precision ").concat(e.precision," sampler2DArray;\n precision ").concat(e.precision," sampler2DShadow;\n precision ").concat(e.precision," samplerCubeShadow;\n precision ").concat(e.precision," sampler2DArrayShadow;\n precision ").concat(e.precision," isampler2D;\n precision ").concat(e.precision," isampler3D;\n precision ").concat(e.precision," isamplerCube;\n precision ").concat(e.precision," isampler2DArray;\n precision ").concat(e.precision," usampler2D;\n precision ").concat(e.precision," usampler3D;\n precision ").concat(e.precision," usamplerCube;\n precision ").concat(e.precision," usampler2DArray;\n ");return"highp"===e.precision?n+="\n#define HIGH_PRECISION":"mediump"===e.precision?n+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(n+="\n#define LOW_PRECISION"),n}var n3=(w(aW={},h.g,"SHADOWMAP_TYPE_PCF"),w(aW,h.i,"SHADOWMAP_TYPE_VSM"),aW),n2=(w(aX={},h.fa,"ENVMAP_TYPE_CUBE"),w(aX,h.ga,"ENVMAP_TYPE_CUBE"),w(aX,h.ja,"ENVMAP_TYPE_CUBE_UV"),aX),n4=w({},h.ga,"ENVMAP_MODE_REFRACTION"),n5=(w(aj={},h.V,"ENVMAP_BLENDING_MULTIPLY"),w(aj,h.W,"ENVMAP_BLENDING_MIX"),w(aj,h.X,"ENVMAP_BLENDING_ADD"),aj);function n6(e,n,t,a){var r,i,o=e.getContext(),s=t.defines,l=t.vertexShader,c=t.fragmentShader,u=n3[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC",d=!1===t.envMap?"ENVMAP_TYPE_CUBE":n2[t.envMapMode]||"ENVMAP_TYPE_CUBE",f=!1===t.envMap?"ENVMAP_MODE_REFLECTION":n4[t.envMapMode]||"ENVMAP_MODE_REFLECTION",p=!1===t.envMap?"ENVMAP_BLENDING_NONE":n5[t.combine]||"ENVMAP_BLENDING_NONE",v=function(e){var n=e.envMapCubeUVHeight;if(null===n)return null;var t=Math.log2(n)-2;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:1/n,maxMip:t}}(t),m=[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(nX).join("\n"),g=function(e){var n=[];for(var t in e){var a=e[t];!1!==a&&n.push("#define "+t+" "+a)}return n.join("\n")}(s),_=o.createProgram(),x=t.glslVersion?"#version "+t.glslVersion+"\n":"";t.isRawShaderMaterial?((r=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(nX).join("\n")).length>0&&(r+="\n"),(i=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(nX).join("\n")).length>0&&(i+="\n")):(r=[n1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&!1===t.flatShading?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(nX).join("\n"),i=[n1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.envMap?"#define "+f:"",t.envMap?"#define "+p:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==h.Y?"#define TONE_MAPPING":"",t.toneMapping!==h.Y?eT.tonemapping_pars_fragment:"",t.toneMapping!==h.Y?(S="toneMapping",void 0===(b=nH[y=t.toneMapping])?((0,h.wc)("WebGLProgram: Unsupported toneMapping:",y),"vec3 "+S+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+S+"( vec3 color ) { return "+b+"ToneMapping( color ); }"):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",eT.colorspace_pars_fragment,(w=function(e){h.Hc._getMatrix(nV,h.Hc.workingColorSpace,e);var n="mat3( ".concat(nV.elements.map(function(e){return e.toFixed(4)})," )");switch(h.Hc.getTransfer(e)){case h.Kb:return[n,"LinearTransferOETF"];case h.Lb:return[n,"sRGBTransferOETF"];default:return(0,h.wc)("WebGLProgram: Unsupported color space: ",e),[n,"LinearTransferOETF"]}}(t.outputColorSpace),["vec4 ".concat("linearToOutputTexel","( vec4 value ) {")," return ".concat(w[1],"( vec4( value.rgb * ").concat(w[0],", value.a ) );"),"}"].join("\n")),(h.Hc.getLuminanceCoefficients(nW),["float luminance( const in vec3 rgb ) {"," const vec3 weights = vec3( ".concat(nW.x.toFixed(4),", ").concat(nW.y.toFixed(4),", ").concat(nW.z.toFixed(4)," );")," return dot( weights, rgb );\n}"].join("\n")),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"","\n"].filter(nX).join("\n")),l=nq(l=nj(l=nK(l),t),t),c=nq(c=nj(c=nK(c),t),t),l=n$(l),c=n$(c),!0!==t.isRawShaderMaterial&&(x="#version 300 es\n",r=[m,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+r,i=["#define varying in",t.glslVersion===h.nc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===h.nc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+i);var S,y,b,w,T,E,M=x+r+l,C=x+i+c,R=nk(o,o.VERTEX_SHADER,M),A=nk(o,o.FRAGMENT_SHADER,C);function P(n){if(e.debug.checkShaderErrors){var t=o.getProgramInfoLog(_)||"",a=o.getShaderInfoLog(R)||"",s=o.getShaderInfoLog(A)||"",l=t.trim(),c=a.trim(),u=s.trim(),d=!0,f=!0;if(!1===o.getProgramParameter(_,o.LINK_STATUS))if(d=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(o,_,R,A);else{var p=nG(o,R,"vertex"),v=nG(o,A,"fragment");(0,h.xc)("WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(_,o.VALIDATE_STATUS)+"\n\nMaterial Name: "+n.name+"\nMaterial Type: "+n.type+"\n\nProgram Info Log: "+l+"\n"+p+"\n"+v)}else""!==l?(0,h.wc)("WebGLProgram: Program Info Log:",l):(""===c||""===u)&&(f=!1);f&&(n.diagnostics={runnable:d,programLog:l,vertexShader:{log:c,prefix:r},fragmentShader:{log:u,prefix:i}})}o.deleteShader(R),o.deleteShader(A),T=new nz(o,_),E=function(e,n){for(var t={},a=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES),r=0;r<a;r++){var i=e.getActiveAttrib(n,r),o=i.name,s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),t[o]={type:i.type,location:e.getAttribLocation(n,o),locationSize:s}}return t}(o,_)}o.attachShader(_,R),o.attachShader(_,A),void 0!==t.index0AttributeName?o.bindAttribLocation(_,0,t.index0AttributeName):!0===t.hasPositionAttribute&&o.bindAttribLocation(_,0,"position"),o.linkProgram(_),this.getUniforms=function(){return void 0===T&&P(this),T},this.getAttributes=function(){return void 0===E&&P(this),E};var D=!1===t.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===D&&(D=o.getProgramParameter(_,37297)),D},this.destroy=function(){a.releaseStatesOfProgram(this),o.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=nB++,this.cacheKey=n,this.usedTimes=1,this.program=_,this.vertexShader=R,this.fragmentShader=A,this}var n8=0,n9=function(){function e(){x(this,e),this.shaderCache=new Map,this.materialCache=new Map}return b(e,[{key:"update",value:function(e,n,t){var a=this._getShaderCacheForMaterial(e);return!1===a.has(n)&&(a.add(n),n.usedTimes++),!1===a.has(t)&&(a.add(t),t.usedTimes++),this}},{key:"remove",value:function(e){var n=this.materialCache.get(e),t=!0,a=!1,r=void 0;try{for(var i,o=n[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;s.usedTimes--,0===s.usedTimes&&this.shaderCache.delete(s.code)}}catch(e){a=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(a)throw r}}return this.materialCache.delete(e),this}},{key:"getVertexShaderStage",value:function(e){return this._getShaderStage(e.vertexShader)}},{key:"getFragmentShaderStage",value:function(e){return this._getShaderStage(e.fragmentShader)}},{key:"dispose",value:function(){this.shaderCache.clear(),this.materialCache.clear()}},{key:"_getShaderCacheForMaterial",value:function(e){var n=this.materialCache,t=n.get(e);return void 0===t&&(t=new Set,n.set(e,t)),t}},{key:"_getShaderStage",value:function(e){var n=this.shaderCache,t=n.get(e);return void 0===t&&(t=new n7(e),n.set(e,t)),t}}]),e}(),n7=function e(n){x(this,e),this.id=n8++,this.code=n,this.usedTimes=0};function te(e,n,t,a,r,i){var o=new h.Qc,s=new n9,l=new Set,c=[],u=new Map,d=a.logarithmicDepthBuffer,f=a.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(e){return l.add(e),0===e?"uv":"uv".concat(e)}return{getParameters:function(r,o,c,u,m,g){var _,x=u.fog,S=m.geometry,y=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?u.environment:null,b=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,w=n.get(r.envMap||y,b),T=w&&w.mapping===h.ja?w.image.height:null,E=p[r.type];null!==r.precision&&(f=a.getMaxPrecision(r.precision))!==r.precision&&(0,h.wc)("WebGLProgram.getParameters:",r.precision,"not supported, using",f,"instead.");var M,C,R,A,P=S.morphAttributes.position||S.morphAttributes.normal||S.morphAttributes.color,D=void 0!==P?P.length:0,L=0;if(void 0!==S.morphAttributes.position&&(L=1),void 0!==S.morphAttributes.normal&&(L=2),void 0!==S.morphAttributes.color&&(L=3),E){var U=eM[E];M=U.vertexShader,C=U.fragmentShader}else{M=r.vertexShader,C=r.fragmentShader;var N=s.getVertexShaderStage(r),I=s.getFragmentShaderStage(r);s.update(r,N,I),R=N.id,A=I.id}var O=e.getRenderTarget(),F=e.state.buffers.depth.getReversed(),z=!0===m.isInstancedMesh,k=!0===m.isBatchedMesh,B=!!r.map,V=!!r.matcap,G=!!w,H=!!r.aoMap,W=!!r.lightMap,X=!!r.bumpMap&&!1===r.wireframe,j=!!r.normalMap,q=!!r.displacementMap,Y=!!r.emissiveMap,K=!!r.metalnessMap,Z=!!r.roughnessMap,J=r.anisotropy>0,Q=r.clearcoat>0,$=r.dispersion>0,ee=r.iridescence>0,en=r.sheen>0,et=r.transmission>0,ea=J&&!!r.anisotropyMap,er=Q&&!!r.clearcoatMap,ei=Q&&!!r.clearcoatNormalMap,eo=Q&&!!r.clearcoatRoughnessMap,es=ee&&!!r.iridescenceMap,el=ee&&!!r.iridescenceThicknessMap,ec=en&&!!r.sheenColorMap,eu=en&&!!r.sheenRoughnessMap,ed=!!r.specularMap,ef=!!r.specularColorMap,ep=!!r.specularIntensityMap,eh=et&&!!r.transmissionMap,ev=et&&!!r.thicknessMap,em=!!r.gradientMap,eg=!!r.alphaMap,e_=r.alphaTest>0,ex=!!r.alphaHash,eS=!!r.extensions,ey=h.Y;r.toneMapped&&(null===O||!0===O.isXRRenderTarget)&&(ey=e.toneMapping);var eb={shaderID:E,shaderType:r.type,shaderName:r.name,vertexShader:M,fragmentShader:C,defines:r.defines,customVertexShaderID:R,customFragmentShaderID:A,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:f,batching:k,batchingColor:k&&null!==m._colorsTexture,instancing:z,instancingColor:z&&null!==m.instanceColor,instancingMorph:z&&null!==m.morphTexture,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:h.Hc.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:B,matcap:V,envMap:G,envMapMode:G&&w.mapping,envMapCubeUVHeight:T,aoMap:H,lightMap:W,bumpMap:X,normalMap:j,displacementMap:q,emissiveMap:Y,normalMapObjectSpace:j&&r.normalMapType===h.Gb,normalMapTangentSpace:j&&r.normalMapType===h.Fb,packedNormalMap:j&&r.normalMapType===h.Fb&&((_=r.normalMap.format)===h.Oa||_===h.db||_===h.yb),metalnessMap:K,roughnessMap:Z,anisotropy:J,anisotropyMap:ea,clearcoat:Q,clearcoatMap:er,clearcoatNormalMap:ei,clearcoatRoughnessMap:eo,dispersion:$,iridescence:ee,iridescenceMap:es,iridescenceThicknessMap:el,sheen:en,sheenColorMap:ec,sheenRoughnessMap:eu,specularMap:ed,specularColorMap:ef,specularIntensityMap:ep,transmission:et,transmissionMap:eh,thicknessMap:ev,gradientMap:em,opaque:!1===r.transparent&&r.blending===h.n&&!1===r.alphaToCoverage,alphaMap:eg,alphaTest:e_,alphaHash:ex,combine:r.combine,mapUv:B&&v(r.map.channel),aoMapUv:H&&v(r.aoMap.channel),lightMapUv:W&&v(r.lightMap.channel),bumpMapUv:X&&v(r.bumpMap.channel),normalMapUv:j&&v(r.normalMap.channel),displacementMapUv:q&&v(r.displacementMap.channel),emissiveMapUv:Y&&v(r.emissiveMap.channel),metalnessMapUv:K&&v(r.metalnessMap.channel),roughnessMapUv:Z&&v(r.roughnessMap.channel),anisotropyMapUv:ea&&v(r.anisotropyMap.channel),clearcoatMapUv:er&&v(r.clearcoatMap.channel),clearcoatNormalMapUv:ei&&v(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:eo&&v(r.clearcoatRoughnessMap.channel),iridescenceMapUv:es&&v(r.iridescenceMap.channel),iridescenceThicknessMapUv:el&&v(r.iridescenceThicknessMap.channel),sheenColorMapUv:ec&&v(r.sheenColorMap.channel),sheenRoughnessMapUv:eu&&v(r.sheenRoughnessMap.channel),specularMapUv:ed&&v(r.specularMap.channel),specularColorMapUv:ef&&v(r.specularColorMap.channel),specularIntensityMapUv:ep&&v(r.specularIntensityMap.channel),transmissionMapUv:eh&&v(r.transmissionMap.channel),thicknessMapUv:ev&&v(r.thicknessMap.channel),alphaMapUv:eg&&v(r.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(j||J),vertexNormals:!!S.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!S.attributes.uv&&(B||eg),fog:!!x,useFog:!0===r.fog,fogExp2:!!x&&x.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===S.attributes.normal&&!1===j&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:F,skinning:!0===m.isSkinnedMesh,hasPositionAttribute:void 0!==S.attributes.position,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:D,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:i.numPlanes,numClipIntersection:i.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ey,decodeVideoTexture:B&&!0===r.map.isVideoTexture&&h.Hc.getTransfer(r.map.colorSpace)===h.Lb,decodeVideoTextureEmissive:Y&&!0===r.emissiveMap.isVideoTexture&&h.Hc.getTransfer(r.emissiveMap.colorSpace)===h.Lb,premultipliedAlpha:r.premultipliedAlpha,doubleSided:r.side===h.l,flipSided:r.side===h.k,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:eS&&!0===r.extensions.clipCullDistance&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(eS&&!0===r.extensions.multiDraw||k)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return eb.vertexUv1s=l.has(1),eb.vertexUv2s=l.has(2),eb.vertexUv3s=l.has(3),l.clear(),eb},getProgramCacheKey:function(n){var t=[];if(n.shaderID?t.push(n.shaderID):(t.push(n.customVertexShaderID),t.push(n.customFragmentShaderID)),void 0!==n.defines)for(var a in n.defines)t.push(a),t.push(n.defines[a]);return!1===n.isRawShaderMaterial&&(t.push(n.precision),t.push(n.outputColorSpace),t.push(n.envMapMode),t.push(n.envMapCubeUVHeight),t.push(n.mapUv),t.push(n.alphaMapUv),t.push(n.lightMapUv),t.push(n.aoMapUv),t.push(n.bumpMapUv),t.push(n.normalMapUv),t.push(n.displacementMapUv),t.push(n.emissiveMapUv),t.push(n.metalnessMapUv),t.push(n.roughnessMapUv),t.push(n.anisotropyMapUv),t.push(n.clearcoatMapUv),t.push(n.clearcoatNormalMapUv),t.push(n.clearcoatRoughnessMapUv),t.push(n.iridescenceMapUv),t.push(n.iridescenceThicknessMapUv),t.push(n.sheenColorMapUv),t.push(n.sheenRoughnessMapUv),t.push(n.specularMapUv),t.push(n.specularColorMapUv),t.push(n.specularIntensityMapUv),t.push(n.transmissionMapUv),t.push(n.thicknessMapUv),t.push(n.combine),t.push(n.fogExp2),t.push(n.sizeAttenuation),t.push(n.morphTargetsCount),t.push(n.morphAttributeCount),t.push(n.numDirLights),t.push(n.numPointLights),t.push(n.numSpotLights),t.push(n.numSpotLightMaps),t.push(n.numHemiLights),t.push(n.numRectAreaLights),t.push(n.numDirLightShadows),t.push(n.numPointLightShadows),t.push(n.numSpotLightShadows),t.push(n.numSpotLightShadowsWithMaps),t.push(n.numLightProbes),t.push(n.shadowMapType),t.push(n.toneMapping),t.push(n.numClippingPlanes),t.push(n.numClipIntersection),t.push(n.depthPacking),o.disableAll(),n.instancing&&o.enable(0),n.instancingColor&&o.enable(1),n.instancingMorph&&o.enable(2),n.matcap&&o.enable(3),n.envMap&&o.enable(4),n.normalMapObjectSpace&&o.enable(5),n.normalMapTangentSpace&&o.enable(6),n.clearcoat&&o.enable(7),n.iridescence&&o.enable(8),n.alphaTest&&o.enable(9),n.vertexColors&&o.enable(10),n.vertexAlphas&&o.enable(11),n.vertexUv1s&&o.enable(12),n.vertexUv2s&&o.enable(13),n.vertexUv3s&&o.enable(14),n.vertexTangents&&o.enable(15),n.anisotropy&&o.enable(16),n.alphaHash&&o.enable(17),n.batching&&o.enable(18),n.dispersion&&o.enable(19),n.batchingColor&&o.enable(20),n.gradientMap&&o.enable(21),n.packedNormalMap&&o.enable(22),n.vertexNormals&&o.enable(23),t.push(o.mask),o.disableAll(),n.fog&&o.enable(0),n.useFog&&o.enable(1),n.flatShading&&o.enable(2),n.logarithmicDepthBuffer&&o.enable(3),n.reversedDepthBuffer&&o.enable(4),n.skinning&&o.enable(5),n.morphTargets&&o.enable(6),n.morphNormals&&o.enable(7),n.morphColors&&o.enable(8),n.premultipliedAlpha&&o.enable(9),n.shadowMapEnabled&&o.enable(10),n.doubleSided&&o.enable(11),n.flipSided&&o.enable(12),n.useDepthPacking&&o.enable(13),n.dithering&&o.enable(14),n.transmission&&o.enable(15),n.sheen&&o.enable(16),n.opaque&&o.enable(17),n.pointsUvs&&o.enable(18),n.decodeVideoTexture&&o.enable(19),n.decodeVideoTextureEmissive&&o.enable(20),n.alphaToCoverage&&o.enable(21),n.numLightProbeGrids>0&&o.enable(22),n.hasPositionAttribute&&o.enable(23),t.push(o.mask),t.push(e.outputColorSpace)),t.push(n.customProgramCacheKey),t.join()},getUniforms:function(e){var n,t=p[e.type];if(t){var a=eM[t];n=h.be.clone(a.uniforms)}else n=e.uniforms;return n},acquireProgram:function(n,t){var a=u.get(t);return void 0!==a?++a.usedTimes:(a=new n6(e,t,n,r),c.push(a),u.set(t,a)),a},releaseProgram:function(e){if(0==--e.usedTimes){var n=c.indexOf(e);c[n]=c[c.length-1],c.pop(),u.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:c,dispose:function(){s.dispose()}}}function tn(){var e=new WeakMap;return{has:function(n){return e.has(n)},get:function(n){var t=e.get(n);return void 0===t&&(t={},e.set(n,t)),t},remove:function(n){e.delete(n)},update:function(n,t,a){e.get(n)[t]=a},dispose:function(){e=new WeakMap}}}function tt(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.material.id!==n.material.id?e.material.id-n.material.id:e.materialVariant!==n.materialVariant?e.materialVariant-n.materialVariant:e.z!==n.z?e.z-n.z:e.id-n.id}function ta(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.z!==n.z?n.z-e.z:e.id-n.id}function tr(){var e=[],n=0,t=[],a=[],r=[];function i(e){var n=0;return e.isInstancedMesh&&(n+=2),e.isSkinnedMesh&&(n+=1),n}function o(t,a,r,o,s,l){var c=e[n];return void 0===c?(c={id:t.id,object:t,geometry:a,material:r,materialVariant:i(t),groupOrder:o,renderOrder:t.renderOrder,z:s,group:l},e[n]=c):(c.id=t.id,c.object=t,c.geometry=a,c.material=r,c.materialVariant=i(t),c.groupOrder=o,c.renderOrder=t.renderOrder,c.z=s,c.group=l),n++,c}return{opaque:t,transmissive:a,transparent:r,init:function(){n=0,t.length=0,a.length=0,r.length=0},push:function(e,n,i,s,l,c){var u=o(e,n,i,s,l,c);i.transmission>0?a.push(u):!0===i.transparent?r.push(u):t.push(u)},unshift:function(e,n,i,s,l,c){var u=o(e,n,i,s,l,c);i.transmission>0?a.unshift(u):!0===i.transparent?r.unshift(u):t.unshift(u)},finish:function(){for(var t=n,a=e.length;t<a;t++){var r=e[t];if(null===r.id)break;r.id=null,r.object=null,r.geometry=null,r.material=null,r.group=null}},sort:function(e,n,i){t.length>1&&t.sort(e||tt),a.length>1&&a.sort(n||ta),r.length>1&&r.sort(n||ta),i&&(t.reverse(),a.reverse(),r.reverse())}}}function ti(){var e=new WeakMap;return{get:function(n,t){var a,r=e.get(n);return void 0===r?(a=new tr,e.set(n,[a])):t>=r.length?(a=new tr,r.push(a)):a=r[t],a},dispose:function(){e=new WeakMap}}}function to(){var e={};return{get:function(n){var t;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":t={direction:new h.Fc,color:new h.Tc};break;case"SpotLight":t={position:new h.Fc,direction:new h.Fc,color:new h.Tc,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new h.Fc,color:new h.Tc,distance:0,decay:0};break;case"HemisphereLight":t={direction:new h.Fc,skyColor:new h.Tc,groundColor:new h.Tc};break;case"RectAreaLight":t={color:new h.Tc,position:new h.Fc,halfWidth:new h.Fc,halfHeight:new h.Fc}}return e[n.id]=t,t}}}var ts=0;function tl(e,n){return 2*!!n.castShadow-2*!!e.castShadow+ +!!n.map-!!e.map}function tc(e){for(var n,t=new to,a=(n={},{get:function(e){var t;if(void 0!==n[e.id])return n[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new h.Dc};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new h.Dc,shadowCameraNear:1,shadowCameraFar:1e3}}return n[e.id]=t,t}}),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0},i=0;i<9;i++)r.probe.push(new h.Fc);var o=new h.Fc,s=new h.Oc,l=new h.Oc;return{setup:function(n){for(var i=0,o=0,s=0,l=0;l<9;l++)r.probe[l].set(0,0,0);var c=0,u=0,d=0,f=0,p=0,v=0,m=0,g=0,_=0,x=0,S=0;n.sort(tl);for(var y=0,b=n.length;y<b;y++){var w=n[y],T=w.color,E=w.intensity,M=w.distance,C=null;if(w.shadow&&w.shadow.map&&(C=w.shadow.map.texture.format===h.Oa?w.shadow.map.texture:w.shadow.map.depthTexture||w.shadow.map.texture),w.isAmbientLight)i+=T.r*E,o+=T.g*E,s+=T.b*E;else if(w.isLightProbe){for(var R=0;R<9;R++)r.probe[R].addScaledVector(w.sh.coefficients[R],E);S++}else if(w.isDirectionalLight){var A=t.get(w);if(A.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){var P=w.shadow,D=a.get(w);D.shadowIntensity=P.intensity,D.shadowBias=P.bias,D.shadowNormalBias=P.normalBias,D.shadowRadius=P.radius,D.shadowMapSize=P.mapSize,r.directionalShadow[c]=D,r.directionalShadowMap[c]=C,r.directionalShadowMatrix[c]=w.shadow.matrix,v++}r.directional[c]=A,c++}else if(w.isSpotLight){var L=t.get(w);L.position.setFromMatrixPosition(w.matrixWorld),L.color.copy(T).multiplyScalar(E),L.distance=M,L.coneCos=Math.cos(w.angle),L.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),L.decay=w.decay,r.spot[d]=L;var U=w.shadow;if(w.map&&(r.spotLightMap[_]=w.map,_++,U.updateMatrices(w),w.castShadow&&x++),r.spotLightMatrix[d]=U.matrix,w.castShadow){var N=a.get(w);N.shadowIntensity=U.intensity,N.shadowBias=U.bias,N.shadowNormalBias=U.normalBias,N.shadowRadius=U.radius,N.shadowMapSize=U.mapSize,r.spotShadow[d]=N,r.spotShadowMap[d]=C,g++}d++}else if(w.isRectAreaLight){var I=t.get(w);I.color.copy(T).multiplyScalar(E),I.halfWidth.set(.5*w.width,0,0),I.halfHeight.set(0,.5*w.height,0),r.rectArea[f]=I,f++}else if(w.isPointLight){var O=t.get(w);if(O.color.copy(w.color).multiplyScalar(w.intensity),O.distance=w.distance,O.decay=w.decay,w.castShadow){var F=w.shadow,z=a.get(w);z.shadowIntensity=F.intensity,z.shadowBias=F.bias,z.shadowNormalBias=F.normalBias,z.shadowRadius=F.radius,z.shadowMapSize=F.mapSize,z.shadowCameraNear=F.camera.near,z.shadowCameraFar=F.camera.far,r.pointShadow[u]=z,r.pointShadowMap[u]=C,r.pointShadowMatrix[u]=w.shadow.matrix,m++}r.point[u]=O,u++}else if(w.isHemisphereLight){var k=t.get(w);k.skyColor.copy(w.color).multiplyScalar(E),k.groundColor.copy(w.groundColor).multiplyScalar(E),r.hemi[p]=k,p++}}f>0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=eE.LTC_FLOAT_1,r.rectAreaLTC2=eE.LTC_FLOAT_2):(r.rectAreaLTC1=eE.LTC_HALF_1,r.rectAreaLTC2=eE.LTC_HALF_2)),r.ambient[0]=i,r.ambient[1]=o,r.ambient[2]=s;var B=r.hash;(B.directionalLength!==c||B.pointLength!==u||B.spotLength!==d||B.rectAreaLength!==f||B.hemiLength!==p||B.numDirectionalShadows!==v||B.numPointShadows!==m||B.numSpotShadows!==g||B.numSpotMaps!==_||B.numLightProbes!==S)&&(r.directional.length=c,r.spot.length=d,r.rectArea.length=f,r.point.length=u,r.hemi.length=p,r.directionalShadow.length=v,r.directionalShadowMap.length=v,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=v,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=g+_-x,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=x,r.numLightProbes=S,B.directionalLength=c,B.pointLength=u,B.spotLength=d,B.rectAreaLength=f,B.hemiLength=p,B.numDirectionalShadows=v,B.numPointShadows=m,B.numSpotShadows=g,B.numSpotMaps=_,B.numLightProbes=S,r.version=ts++)},setupView:function(e,n){for(var t=0,a=0,i=0,c=0,u=0,d=n.matrixWorldInverse,f=0,p=e.length;f<p;f++){var h=e[f];if(h.isDirectionalLight){var v=r.directional[t];v.direction.setFromMatrixPosition(h.matrixWorld),o.setFromMatrixPosition(h.target.matrixWorld),v.direction.sub(o),v.direction.transformDirection(d),t++}else if(h.isSpotLight){var m=r.spot[i];m.position.setFromMatrixPosition(h.matrixWorld),m.position.applyMatrix4(d),m.direction.setFromMatrixPosition(h.matrixWorld),o.setFromMatrixPosition(h.target.matrixWorld),m.direction.sub(o),m.direction.transformDirection(d),i++}else if(h.isRectAreaLight){var g=r.rectArea[c];g.position.setFromMatrixPosition(h.matrixWorld),g.position.applyMatrix4(d),l.identity(),s.copy(h.matrixWorld),s.premultiply(d),l.extractRotation(s),g.halfWidth.set(.5*h.width,0,0),g.halfHeight.set(0,.5*h.height,0),g.halfWidth.applyMatrix4(l),g.halfHeight.applyMatrix4(l),c++}else if(h.isPointLight){var _=r.point[a];_.position.setFromMatrixPosition(h.matrixWorld),_.position.applyMatrix4(d),a++}else if(h.isHemisphereLight){var x=r.hemi[u];x.direction.setFromMatrixPosition(h.matrixWorld),x.direction.transformDirection(d),u++}}},state:r}}function tu(e){var n=new tc(e),t=[],a=[],r=[],i={lightsArray:t,shadowsArray:a,lightProbeGridArray:r,camera:null,lights:n,transmissionRenderTarget:{},textureUnits:0};return{init:function(e){i.camera=e,t.length=0,a.length=0,r.length=0},state:i,setupLights:function(){n.setup(t)},setupLightsView:function(e){n.setupView(t,e)},pushLight:function(e){t.push(e)},pushShadow:function(e){a.push(e)},pushLightProbeGrid:function(e){r.push(e)}}}function td(e){var n=new WeakMap;return{get:function(t){var a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=n.get(t);return void 0===i?(a=new tu(e),n.set(t,[a])):r>=i.length?(a=new tu(e),i.push(a)):a=i[r],a},dispose:function(){n=new WeakMap}}}var tf=[new h.Fc(1,0,0),new h.Fc(-1,0,0),new h.Fc(0,1,0),new h.Fc(0,-1,0),new h.Fc(0,0,1),new h.Fc(0,0,-1)],tp=[new h.Fc(0,-1,0),new h.Fc(0,-1,0),new h.Fc(0,0,1),new h.Fc(0,0,-1),new h.Fc(0,-1,0),new h.Fc(0,-1,0)],th=new h.Oc,tv=new h.Fc,tm=new h.Fc;function tg(e,n,t){var a,r=new h.sd,i=new h.Dc,o=new h.Dc,s=new h.Jc,l=new h.ke,c=new h.le,u={},d=t.maxTextureSize,f=(w(a={},h.j,h.k),w(a,h.k,h.j),w(a,h.l,h.l),a),p=new h.ce({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new h.Dc},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),v=p.clone();v.defines.HORIZONTAL_PASS=1;var m=new h.dd;m.setAttribute("position",new h.Zc(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var g=new h.ld(m,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=h.g;var x=this.type;function S(n,t,a,r){var i=null,o=!0===a.isPointLight?n.customDistanceMaterial:n.customDepthMaterial;if(void 0!==o)i=o;else if(i=!0===a.isPointLight?c:l,e.localClippingEnabled&&!0===t.clipShadows&&Array.isArray(t.clippingPlanes)&&0!==t.clippingPlanes.length||t.displacementMap&&0!==t.displacementScale||t.alphaMap&&t.alphaTest>0||t.map&&t.alphaTest>0||!0===t.alphaToCoverage){var s=i.uuid,d=t.uuid,p=u[s];void 0===p&&(p={},u[s]=p);var v=p[d];void 0===v&&(v=i.clone(),p[d]=v,t.addEventListener("dispose",y)),i=v}return i.visible=t.visible,i.wireframe=t.wireframe,i.side=r===h.i?null!==t.shadowSide?t.shadowSide:t.side:null!==t.shadowSide?t.shadowSide:f[t.side],i.alphaMap=t.alphaMap,i.alphaTest=!0===t.alphaToCoverage?.5:t.alphaTest,i.map=t.map,i.clipShadows=t.clipShadows,i.clippingPlanes=t.clippingPlanes,i.clipIntersection=t.clipIntersection,i.displacementMap=t.displacementMap,i.displacementScale=t.displacementScale,i.displacementBias=t.displacementBias,i.wireframeLinewidth=t.wireframeLinewidth,i.linewidth=t.linewidth,!0===a.isPointLight&&!0===i.isMeshDistanceMaterial&&(e.properties.get(i).light=a),i}function y(e){for(var n in e.target.removeEventListener("dispose",y),u){var t=u[n],a=e.target.uuid;a in t&&(t[a].dispose(),delete t[a])}}this.render=function(t,a,l){if(!1!==_.enabled&&(!1!==_.autoUpdate||!1!==_.needsUpdate)&&0!==t.length){this.type===h.h&&((0,h.wc)("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=h.g);var c=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.state;m.setBlending(h.m),!0===m.buffers.depth.getReversed()?m.buffers.color.setClear(0,0,0,0):m.buffers.color.setClear(1,1,1,1),m.buffers.depth.setTest(!0),m.setScissorTest(!1);var y=x!==this.type;y&&a.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(function(e){return e.needsUpdate=!0}):e.material.needsUpdate=!0)});for(var b=0,w=t.length;b<w;b++){var T=t[b],E=T.shadow;if(void 0===E){(0,h.wc)("WebGLShadowMap:",T,"has no shadow.");continue}if(!1!==E.autoUpdate||!1!==E.needsUpdate){i.copy(E.mapSize);var M=E.getFrameExtents();i.multiply(M),o.copy(E.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(o.x=Math.floor(d/M.x),i.x=o.x*M.x,E.mapSize.x=o.x),i.y>d&&(o.y=Math.floor(d/M.y),i.y=o.y*M.y,E.mapSize.y=o.y));var C=e.state.buffers.depth.getReversed();if(E.camera._reversedDepth=C,null===E.map||!0===y){if(null!==E.map&&(null!==E.map.depthTexture&&(E.map.depthTexture.dispose(),E.map.depthTexture=null),E.map.dispose()),this.type===h.i){if(T.isPointLight){(0,h.wc)("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}E.map=new h.Lc(i.x,i.y,{format:h.Oa,type:h.Ba,minFilter:h.qa,magFilter:h.qa,generateMipmaps:!1}),E.map.texture.name=T.name+".shadowMap",E.map.depthTexture=new h.Cd(i.x,i.y,h.Aa),E.map.depthTexture.name=T.name+".shadowMapDepth",E.map.depthTexture.format=h.Ka,E.map.depthTexture.compareFunction=null,E.map.depthTexture.minFilter=h.na,E.map.depthTexture.magFilter=h.na}else T.isPointLight?(E.map=new eI(i.x),E.map.depthTexture=new h.Dd(i.x,h.za)):(E.map=new h.Lc(i.x,i.y),E.map.depthTexture=new h.Cd(i.x,i.y,h.za)),E.map.depthTexture.name=T.name+".shadowMap",E.map.depthTexture.format=h.Ka,this.type===h.g?(E.map.depthTexture.compareFunction=C?h.jc:h.gc,E.map.depthTexture.minFilter=h.qa,E.map.depthTexture.magFilter=h.qa):(E.map.depthTexture.compareFunction=null,E.map.depthTexture.minFilter=h.na,E.map.depthTexture.magFilter=h.na);E.camera.updateProjectionMatrix()}for(var R=E.map.isWebGLCubeRenderTarget?6:1,A=0;A<R;A++){if(E.map.isWebGLCubeRenderTarget)e.setRenderTarget(E.map,A),e.clear();else{0===A&&(e.setRenderTarget(E.map),e.clear());var P=E.getViewport(A);s.set(o.x*P.x,o.y*P.y,o.x*P.z,o.y*P.w),m.viewport(s)}if(T.isPointLight){var D=E.camera,L=E.matrix,U=T.distance||D.far;U!==D.far&&(D.far=U,D.updateProjectionMatrix()),tv.setFromMatrixPosition(T.matrixWorld),D.position.copy(tv),tm.copy(D.position),tm.add(tf[A]),D.up.copy(tp[A]),D.lookAt(tm),D.updateMatrixWorld(),L.makeTranslation(-tv.x,-tv.y,-tv.z),th.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),E._frustum.setFromProjectionMatrix(th,D.coordinateSystem,D.reversedDepth)}else E.updateMatrices(T);r=E.getFrustum(),function t(a,i,o,s,l){if(!1!==a.visible){if(a.layers.test(i.layers)&&(a.isMesh||a.isLine||a.isPoints)&&(a.castShadow||a.receiveShadow&&l===h.i)&&(!a.frustumCulled||r.intersectsObject(a))){a.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,a.matrixWorld);var c=n.update(a),u=a.material;if(Array.isArray(u))for(var d=c.groups,f=0,p=d.length;f<p;f++){var v=d[f],m=u[v.materialIndex];if(m&&m.visible){var g=S(a,m,s,l);a.onBeforeShadow(e,a,i,o,c,g,v),e.renderBufferDirect(o,null,c,g,a,v),a.onAfterShadow(e,a,i,o,c,g,v)}}else if(u.visible){var _=S(a,u,s,l);a.onBeforeShadow(e,a,i,o,c,_,null),e.renderBufferDirect(o,null,c,_,a,null),a.onAfterShadow(e,a,i,o,c,_,null)}}for(var x=a.children,y=0,b=x.length;y<b;y++)t(x[y],i,o,s,l)}}(a,l,E.camera,T,this.type)}!0!==E.isPointLightShadow&&this.type===h.i&&function(t,a){var r=n.update(g);p.defines.VSM_SAMPLES!==t.blurSamples&&(p.defines.VSM_SAMPLES=t.blurSamples,v.defines.VSM_SAMPLES=t.blurSamples,p.needsUpdate=!0,v.needsUpdate=!0),null===t.mapPass&&(t.mapPass=new h.Lc(i.x,i.y,{format:h.Oa,type:h.Ba})),p.uniforms.shadow_pass.value=t.map.depthTexture,p.uniforms.resolution.value=t.mapSize,p.uniforms.radius.value=t.radius,e.setRenderTarget(t.mapPass),e.clear(),e.renderBufferDirect(a,null,r,p,g,null),v.uniforms.shadow_pass.value=t.mapPass.texture,v.uniforms.resolution.value=t.mapSize,v.uniforms.radius.value=t.radius,e.setRenderTarget(t.map),e.clear(),e.renderBufferDirect(a,null,r,v,g,null)}(E,l),E.needsUpdate=!1}}x=this.type,_.needsUpdate=!1,e.setRenderTarget(c,u,f)}}}function t_(e,n){var t,a,r=new function(){var n=!1,t=new h.Jc,a=null,r=new h.Jc(0,0,0,0);return{setMask:function(t){a===t||n||(e.colorMask(t,t,t,t),a=t)},setLocked:function(e){n=e},setClear:function(n,a,i,o,s){!0===s&&(n*=o,a*=o,i*=o),t.set(n,a,i,o),!1===r.equals(t)&&(e.clearColor(n,a,i,o),r.copy(t))},reset:function(){n=!1,a=null,r.set(-1,0,0,0)}}},i=new function(){var t=!1,a=!1,r=null,i=null,o=null;return{setReversed:function(e){if(a!==e){var t=n.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),a=e;var r=o;o=null,this.setClear(r)}},getReversed:function(){return a},setTest:function(n){n?W(e.DEPTH_TEST):X(e.DEPTH_TEST)},setMask:function(n){r===n||t||(e.depthMask(n),r=n)},setFunc:function(n){if(a&&(n=h.Ac[n]),i!==n){switch(n){case h.N:e.depthFunc(e.NEVER);break;case h.O:e.depthFunc(e.ALWAYS);break;case h.P:e.depthFunc(e.LESS);break;case h.Q:e.depthFunc(e.LEQUAL);break;case h.R:e.depthFunc(e.EQUAL);break;case h.S:e.depthFunc(e.GEQUAL);break;case h.T:e.depthFunc(e.GREATER);break;case h.U:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}i=n}},setLocked:function(e){t=e},setClear:function(n){o!==n&&(o=n,a&&(n=1-n),e.clearDepth(n))},reset:function(){t=!1,r=null,i=null,o=null,a=!1}}},o=new function(){var n=!1,t=null,a=null,r=null,i=null,o=null,s=null,l=null,c=null;return{setTest:function(t){n||(t?W(e.STENCIL_TEST):X(e.STENCIL_TEST))},setMask:function(a){t===a||n||(e.stencilMask(a),t=a)},setFunc:function(n,t,o){(a!==n||r!==t||i!==o)&&(e.stencilFunc(n,t,o),a=n,r=t,i=o)},setOp:function(n,t,a){(o!==n||s!==t||l!==a)&&(e.stencilOp(n,t,a),o=n,s=t,l=a)},setLocked:function(e){n=e},setClear:function(n){c!==n&&(e.clearStencil(n),c=n)},reset:function(){n=!1,t=null,a=null,r=null,i=null,o=null,s=null,l=null,c=null}}},s=new WeakMap,l=new WeakMap,c={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,x=null,S=null,y=null,b=null,T=null,E=new h.Tc(0,0,0),M=0,C=!1,R=null,A=null,P=null,D=null,L=null,U=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,I=e.getParameter(e.VERSION);-1!==I.indexOf("WebGL")?N=parseFloat(/^WebGL (\d)/.exec(I)[1])>=1:-1!==I.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL ES (\d)/.exec(I)[1])>=2);var O=null,F={},z=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),B=(new h.Jc).fromArray(z),V=(new h.Jc).fromArray(k);function G(n,t,a,r){var i=new Uint8Array(4),o=e.createTexture();e.bindTexture(n,o),e.texParameteri(n,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(n,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var s=0;s<a;s++)n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY?e.texImage3D(t,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,i):e.texImage2D(t+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,i);return o}var H={};function W(n){!0!==c[n]&&(e.enable(n),c[n]=!0)}function X(n){!1!==c[n]&&(e.disable(n),c[n]=!1)}H[e.TEXTURE_2D]=G(e.TEXTURE_2D,e.TEXTURE_2D,1),H[e.TEXTURE_CUBE_MAP]=G(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),H[e.TEXTURE_2D_ARRAY]=G(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),H[e.TEXTURE_3D]=G(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),i.setClear(1),o.setClear(0),W(e.DEPTH_TEST),i.setFunc(h.Q),K(!1),Z(h.d),W(e.CULL_FACE),Y(h.m);var j=(w(t={},h.t,e.FUNC_ADD),w(t,h.u,e.FUNC_SUBTRACT),w(t,h.v,e.FUNC_REVERSE_SUBTRACT),t);j[h.w]=e.MIN,j[h.x]=e.MAX;var q=(w(a={},h.y,e.ZERO),w(a,h.z,e.ONE),w(a,h.A,e.SRC_COLOR),w(a,h.C,e.SRC_ALPHA),w(a,h.I,e.SRC_ALPHA_SATURATE),w(a,h.G,e.DST_COLOR),w(a,h.E,e.DST_ALPHA),w(a,h.B,e.ONE_MINUS_SRC_COLOR),w(a,h.D,e.ONE_MINUS_SRC_ALPHA),w(a,h.H,e.ONE_MINUS_DST_COLOR),w(a,h.F,e.ONE_MINUS_DST_ALPHA),w(a,h.J,e.CONSTANT_COLOR),w(a,h.K,e.ONE_MINUS_CONSTANT_COLOR),w(a,h.L,e.CONSTANT_ALPHA),w(a,h.M,e.ONE_MINUS_CONSTANT_ALPHA),a);function Y(n,t,a,r,i,o,s,l,c,u){if(n!==h.m){if(!1===m&&(W(e.BLEND),m=!0),n===h.r)i=i||t,o=o||a,s=s||r,(t!==_||i!==y)&&(e.blendEquationSeparate(j[t],j[i]),_=t,y=i),(a!==x||r!==S||o!==b||s!==T)&&(e.blendFuncSeparate(q[a],q[r],q[o],q[s]),x=a,S=r,b=o,T=s),(!1===l.equals(E)||c!==M)&&(e.blendColor(l.r,l.g,l.b,c),E.copy(l),M=c),g=n,C=!1;else if(n!==g||u!==C){if((_!==h.t||y!==h.t)&&(e.blendEquation(e.FUNC_ADD),_=h.t,y=h.t),u)switch(n){case h.n:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case h.o:e.blendFunc(e.ONE,e.ONE);break;case h.p:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case h.q:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:(0,h.xc)("WebGLState: Invalid blending: ",n)}else switch(n){case h.n:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case h.o:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case h.p:(0,h.xc)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case h.q:(0,h.xc)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,h.xc)("WebGLState: Invalid blending: ",n)}x=null,S=null,b=null,T=null,E.set(0,0,0),M=0,g=n,C=u}}else!0===m&&(X(e.BLEND),m=!1)}function K(n){R!==n&&(n?e.frontFace(e.CW):e.frontFace(e.CCW),R=n)}function Z(n){n!==h.c?(W(e.CULL_FACE),n!==A&&(n===h.d?e.cullFace(e.BACK):n===h.e?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):X(e.CULL_FACE),A=n}function J(n,t,a){n?(W(e.POLYGON_OFFSET_FILL),(D!==t||L!==a)&&(D=t,L=a,i.getReversed()&&(t=-t),e.polygonOffset(t,a))):X(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:i,stencil:o},enable:W,disable:X,bindFramebuffer:function(n,t){return d[n]!==t&&(e.bindFramebuffer(n,t),d[n]=t,n===e.DRAW_FRAMEBUFFER&&(d[e.FRAMEBUFFER]=t),n===e.FRAMEBUFFER&&(d[e.DRAW_FRAMEBUFFER]=t),!0)},drawBuffers:function(n,t){var a=p,r=!1;if(n){void 0===(a=f.get(t))&&(a=[],f.set(t,a));var i=n.textures;if(a.length!==i.length||a[0]!==e.COLOR_ATTACHMENT0){for(var o=0,s=i.length;o<s;o++)a[o]=e.COLOR_ATTACHMENT0+o;a.length=i.length,r=!0}}else a[0]!==e.BACK&&(a[0]=e.BACK,r=!0);r&&e.drawBuffers(a)},useProgram:function(n){return v!==n&&(e.useProgram(n),v=n,!0)},setBlending:Y,setMaterial:function(n,t){n.side===h.l?X(e.CULL_FACE):W(e.CULL_FACE);var a=n.side===h.k;t&&(a=!a),K(a),n.blending===h.n&&!1===n.transparent?Y(h.m):Y(n.blending,n.blendEquation,n.blendSrc,n.blendDst,n.blendEquationAlpha,n.blendSrcAlpha,n.blendDstAlpha,n.blendColor,n.blendAlpha,n.premultipliedAlpha),i.setFunc(n.depthFunc),i.setTest(n.depthTest),i.setMask(n.depthWrite),r.setMask(n.colorWrite);var s=n.stencilWrite;o.setTest(s),s&&(o.setMask(n.stencilWriteMask),o.setFunc(n.stencilFunc,n.stencilRef,n.stencilFuncMask),o.setOp(n.stencilFail,n.stencilZFail,n.stencilZPass)),J(n.polygonOffset,n.polygonOffsetFactor,n.polygonOffsetUnits),!0===n.alphaToCoverage?W(e.SAMPLE_ALPHA_TO_COVERAGE):X(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:K,setCullFace:Z,setLineWidth:function(n){n!==P&&(N&&e.lineWidth(n),P=n)},setPolygonOffset:J,setScissorTest:function(n){n?W(e.SCISSOR_TEST):X(e.SCISSOR_TEST)},activeTexture:function(n){void 0===n&&(n=e.TEXTURE0+U-1),O!==n&&(e.activeTexture(n),O=n)},bindTexture:function(n,t,a){void 0===a&&(a=null===O?e.TEXTURE0+U-1:O);var r=F[a];void 0===r&&(r={type:void 0,texture:void 0},F[a]=r),(r.type!==n||r.texture!==t)&&(O!==a&&(e.activeTexture(a),O=a),e.bindTexture(n,t||H[n]),r.type=n,r.texture=t)},unbindTexture:function(){var n=F[O];void 0!==n&&void 0!==n.type&&(e.bindTexture(n.type,null),n.type=void 0,n.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},pixelStorei:function(n,t){u[n]!==t&&(e.pixelStorei(n,t),u[n]=t)},getParameter:function(n){return void 0!==u[n]?u[n]:e.getParameter(n)},updateUBOMapping:function(n,t){var a=l.get(t);void 0===a&&(a=new WeakMap,l.set(t,a));var r=a.get(n);void 0===r&&(r=e.getUniformBlockIndex(t,n.name),a.set(n,r))},uniformBlockBinding:function(n,t){var a=l.get(t).get(n);s.get(t)!==a&&(e.uniformBlockBinding(t,a,n.__bindingPointIndex),s.set(t,a))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){(0,h.xc)("WebGLState:",e)}},scissor:function(n){!1===B.equals(n)&&(e.scissor(n.x,n.y,n.z,n.w),B.copy(n))},viewport:function(n){!1===V.equals(n)&&(e.viewport(n.x,n.y,n.z,n.w),V.copy(n))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(0xffffffff),e.stencilFunc(e.ALWAYS,0,0xffffffff),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),c={},u={},O=null,F={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,x=null,S=null,y=null,b=null,T=null,E=new h.Tc(0,0,0),M=0,C=!1,R=null,A=null,P=null,D=null,L=null,B.set(0,0,e.canvas.width,e.canvas.height),V.set(0,0,e.canvas.width,e.canvas.height),r.reset(),i.reset(),o.reset()}}}function tx(e,n,t,a,r,i,o){var s,l,c,u,d=n.has("WEBGL_multisampled_render_to_texture")?n.get("WEBGL_multisampled_render_to_texture"):null,f=!(("u"<typeof navigator?"undefined":I(navigator))>"u")&&/OculusBrowser/g.test(navigator.userAgent),p=new h.Dc,v=new WeakMap,m=new Set,g=new WeakMap,_=!1;try{_=("u"<typeof OffscreenCanvas?"undefined":I(OffscreenCanvas))<"u"&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function x(e,n){return _?new OffscreenCanvas(e,n):(0,h.tc)("canvas")}function S(e,n,t){var a=1,r=Z(e);if((r.width>t||r.height>t)&&(a=t/Math.max(r.width,r.height)),a<1){if(("u"<typeof HTMLImageElement?"undefined":I(HTMLImageElement))<"u"&&C(e,HTMLImageElement)||("u"<typeof HTMLCanvasElement?"undefined":I(HTMLCanvasElement))<"u"&&C(e,HTMLCanvasElement)||("u"<typeof ImageBitmap?"undefined":I(ImageBitmap))<"u"&&C(e,ImageBitmap)||("u"<typeof VideoFrame?"undefined":I(VideoFrame))<"u"&&C(e,VideoFrame)){var i=Math.floor(a*r.width),o=Math.floor(a*r.height);void 0===u&&(u=x(i,o));var s=n?x(i,o):u;return s.width=i,s.height=o,s.getContext("2d").drawImage(e,0,0,i,o),(0,h.wc)("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+o+")."),s}return"data"in e&&(0,h.wc)("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function y(e){return e.generateMipmaps}function b(n){e.generateMipmap(n)}function T(t,a,r,i,o){var s,l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(null!==t){if(void 0!==e[t])return e[t];(0,h.wc)("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}i&&((s=n.get("EXT_texture_norm16"))||(0,h.wc)("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));var c=a;if(a===e.RED&&(r===e.FLOAT&&(c=e.R32F),r===e.HALF_FLOAT&&(c=e.R16F),r===e.UNSIGNED_BYTE&&(c=e.R8),r===e.UNSIGNED_SHORT&&s&&(c=s.R16_EXT),r===e.SHORT&&s&&(c=s.R16_SNORM_EXT)),a===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.R8UI),r===e.UNSIGNED_SHORT&&(c=e.R16UI),r===e.UNSIGNED_INT&&(c=e.R32UI),r===e.BYTE&&(c=e.R8I),r===e.SHORT&&(c=e.R16I),r===e.INT&&(c=e.R32I)),a===e.RG&&(r===e.FLOAT&&(c=e.RG32F),r===e.HALF_FLOAT&&(c=e.RG16F),r===e.UNSIGNED_BYTE&&(c=e.RG8),r===e.UNSIGNED_SHORT&&s&&(c=s.RG16_EXT),r===e.SHORT&&s&&(c=s.RG16_SNORM_EXT)),a===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RG8UI),r===e.UNSIGNED_SHORT&&(c=e.RG16UI),r===e.UNSIGNED_INT&&(c=e.RG32UI),r===e.BYTE&&(c=e.RG8I),r===e.SHORT&&(c=e.RG16I),r===e.INT&&(c=e.RG32I)),a===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RGB8UI),r===e.UNSIGNED_SHORT&&(c=e.RGB16UI),r===e.UNSIGNED_INT&&(c=e.RGB32UI),r===e.BYTE&&(c=e.RGB8I),r===e.SHORT&&(c=e.RGB16I),r===e.INT&&(c=e.RGB32I)),a===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(c=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(c=e.RGBA16UI),r===e.UNSIGNED_INT&&(c=e.RGBA32UI),r===e.BYTE&&(c=e.RGBA8I),r===e.SHORT&&(c=e.RGBA16I),r===e.INT&&(c=e.RGBA32I)),a===e.RGB&&(r===e.UNSIGNED_SHORT&&s&&(c=s.RGB16_EXT),r===e.SHORT&&s&&(c=s.RGB16_SNORM_EXT),r===e.UNSIGNED_INT_5_9_9_9_REV&&(c=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(c=e.R11F_G11F_B10F)),a===e.RGBA){var u=l?h.Kb:h.Hc.getTransfer(o);r===e.FLOAT&&(c=e.RGBA32F),r===e.HALF_FLOAT&&(c=e.RGBA16F),r===e.UNSIGNED_BYTE&&(c=u===h.Lb?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT&&s&&(c=s.RGBA16_EXT),r===e.SHORT&&s&&(c=s.RGBA16_SNORM_EXT),r===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return(c===e.R16F||c===e.R32F||c===e.RG16F||c===e.RG32F||c===e.RGBA16F||c===e.RGBA32F)&&n.get("EXT_color_buffer_float"),c}function E(n,t){var a;return n?null===t||t===h.za||t===h.Ea?a=e.DEPTH24_STENCIL8:t===h.Aa?a=e.DEPTH32F_STENCIL8:t===h.xa&&(a=e.DEPTH24_STENCIL8,(0,h.wc)("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===t||t===h.za||t===h.Ea?a=e.DEPTH_COMPONENT24:t===h.Aa?a=e.DEPTH_COMPONENT32F:t===h.xa&&(a=e.DEPTH_COMPONENT16),a}function M(e,n){return!0===y(e)||e.isFramebufferTexture&&e.minFilter!==h.na&&e.minFilter!==h.qa?Math.log2(Math.max(n.width,n.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?n.mipmaps.length:1}function R(e){var n=e.target;n.removeEventListener("dispose",R),function(e){var n=a.get(e);if(void 0!==n.__webglInit){var t=e.source,r=g.get(t);if(r){var i=r[n.__cacheKey];i.usedTimes--,0===i.usedTimes&&P(e),0===Object.keys(r).length&&g.delete(t)}a.remove(e)}}(n),n.isVideoTexture&&v.delete(n),n.isHTMLTexture&&m.delete(n)}function A(n){var t=n.target;t.removeEventListener("dispose",A),function(n){var t=a.get(n);if(n.depthTexture&&(n.depthTexture.dispose(),a.remove(n.depthTexture)),n.isWebGLCubeRenderTarget)for(var r=0;r<6;r++){if(Array.isArray(t.__webglFramebuffer[r]))for(var i=0;i<t.__webglFramebuffer[r].length;i++)e.deleteFramebuffer(t.__webglFramebuffer[r][i]);else e.deleteFramebuffer(t.__webglFramebuffer[r]);t.__webglDepthbuffer&&e.deleteRenderbuffer(t.__webglDepthbuffer[r])}else{if(Array.isArray(t.__webglFramebuffer))for(var s=0;s<t.__webglFramebuffer.length;s++)e.deleteFramebuffer(t.__webglFramebuffer[s]);else e.deleteFramebuffer(t.__webglFramebuffer);if(t.__webglDepthbuffer&&e.deleteRenderbuffer(t.__webglDepthbuffer),t.__webglMultisampledFramebuffer&&e.deleteFramebuffer(t.__webglMultisampledFramebuffer),t.__webglColorRenderbuffer)for(var l=0;l<t.__webglColorRenderbuffer.length;l++)t.__webglColorRenderbuffer[l]&&e.deleteRenderbuffer(t.__webglColorRenderbuffer[l]);t.__webglDepthRenderbuffer&&e.deleteRenderbuffer(t.__webglDepthRenderbuffer)}for(var c=n.textures,u=0,d=c.length;u<d;u++){var f=a.get(c[u]);f.__webglTexture&&(e.deleteTexture(f.__webglTexture),o.memory.textures--),a.remove(c[u])}a.remove(n)}(t)}function P(n){var t=a.get(n);e.deleteTexture(t.__webglTexture);var r=n.source;delete g.get(r)[t.__cacheKey],o.memory.textures--}var D=0;function L(n,r){var i,s=a.get(n);if(n.isVideoTexture&&(i=o.render.frame,v.get(n)!==i&&(v.set(n,i),n.update())),!1===n.isRenderTargetTexture&&!0!==n.isExternalTexture&&n.version>0&&s.__version!==n.version){var l=n.image;if(null===l)(0,h.wc)("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==l.complete)return void B(s,n,r);(0,h.wc)("WebGLRenderer: Texture marked for update but image is incomplete")}}else n.isExternalTexture&&(s.__webglTexture=n.sourceTexture?n.sourceTexture:null);t.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}var U=(w(s={},h.ka,e.REPEAT),w(s,h.la,e.CLAMP_TO_EDGE),w(s,h.ma,e.MIRRORED_REPEAT),s),N=(w(l={},h.na,e.NEAREST),w(l,h.oa,e.NEAREST_MIPMAP_NEAREST),w(l,h.pa,e.NEAREST_MIPMAP_LINEAR),w(l,h.qa,e.LINEAR),w(l,h.ra,e.LINEAR_MIPMAP_NEAREST),w(l,h.sa,e.LINEAR_MIPMAP_LINEAR),l),O=(w(c={},h.dc,e.NEVER),w(c,h.kc,e.ALWAYS),w(c,h.ec,e.LESS),w(c,h.gc,e.LEQUAL),w(c,h.fc,e.EQUAL),w(c,h.jc,e.GEQUAL),w(c,h.hc,e.GREATER),w(c,h.ic,e.NOTEQUAL),c);function F(t,i){if(i.type===h.Aa&&!1===n.has("OES_texture_float_linear")&&(i.magFilter===h.qa||i.magFilter===h.ra||i.magFilter===h.pa||i.magFilter===h.sa||i.minFilter===h.qa||i.minFilter===h.ra||i.minFilter===h.pa||i.minFilter===h.sa)&&(0,h.wc)("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(t,e.TEXTURE_WRAP_S,U[i.wrapS]),e.texParameteri(t,e.TEXTURE_WRAP_T,U[i.wrapT]),(t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY)&&e.texParameteri(t,e.TEXTURE_WRAP_R,U[i.wrapR]),e.texParameteri(t,e.TEXTURE_MAG_FILTER,N[i.magFilter]),e.texParameteri(t,e.TEXTURE_MIN_FILTER,N[i.minFilter]),i.compareFunction&&(e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,O[i.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")&&i.magFilter!==h.na&&(i.minFilter===h.pa||i.minFilter===h.sa)&&(i.type!==h.Aa||!1!==n.has("OES_texture_float_linear"))&&(i.anisotropy>1||a.get(i).__currentAnisotropy)){var o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,r.getMaxAnisotropy())),a.get(i).__currentAnisotropy=i.anisotropy}}function z(n,t){var a,r=!1;void 0===n.__webglInit&&(n.__webglInit=!0,t.addEventListener("dispose",R));var i=t.source,s=g.get(i);void 0===s&&(s={},g.set(i,s));var l=((a=[]).push(t.wrapS),a.push(t.wrapT),a.push(t.wrapR||0),a.push(t.magFilter),a.push(t.minFilter),a.push(t.anisotropy),a.push(t.internalFormat),a.push(t.format),a.push(t.type),a.push(t.generateMipmaps),a.push(t.premultiplyAlpha),a.push(t.flipY),a.push(t.unpackAlignment),a.push(t.colorSpace),a.join());if(l!==n.__cacheKey){void 0===s[l]&&(s[l]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),s[l].usedTimes++;var c=s[n.__cacheKey];void 0!==c&&(s[n.__cacheKey].usedTimes--,0===c.usedTimes&&P(t)),n.__cacheKey=l,n.__webglTexture=s[l].texture}return r}function k(e,n,t){return Math.floor(Math.floor(e/t)/n)}function B(n,o,s){var l=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(l=e.TEXTURE_3D);var c=z(n,o),u=o.source;t.bindTexture(l,n.__webglTexture,e.TEXTURE0+s);var d=a.get(u);if(u.version!==d.__version||!0===c){if(t.activeTexture(e.TEXTURE0+s),0==(("u"<typeof ImageBitmap?"undefined":I(ImageBitmap))<"u"&&C(o.image,ImageBitmap))){var f=h.Hc.getPrimaries(h.Hc.workingColorSpace),p=o.colorSpace===h.Hb?null:h.Hc.getPrimaries(o.colorSpace),v=o.colorSpace===h.Hb||f===p?e.NONE:e.BROWSER_DEFAULT_WEBGL;t.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),t.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),t.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,v)}t.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);var g=S(o.image,!1,r.maxTextureSize);g=K(o,g);var _=i.convert(o.format,o.colorSpace),x=i.convert(o.type),w=T(o.internalFormat,_,x,o.normalized,o.colorSpace,o.isVideoTexture);F(l,o);var R,A=o.mipmaps,P=!0!==o.isVideoTexture,D=void 0===d.__version||!0===c,L=u.dataReady,U=M(o,g);if(o.isDepthTexture)w=E(o.format===h.La,o.type),D&&(P?t.texStorage2D(e.TEXTURE_2D,1,w,g.width,g.height):t.texImage2D(e.TEXTURE_2D,0,w,g.width,g.height,0,_,x,null));else if(o.isDataTexture)if(A.length>0){P&&D&&t.texStorage2D(e.TEXTURE_2D,U,w,A[0].width,A[0].height);for(var N=0,O=A.length;N<O;N++)R=A[N],P?L&&t.texSubImage2D(e.TEXTURE_2D,N,0,0,R.width,R.height,_,x,R.data):t.texImage2D(e.TEXTURE_2D,N,w,R.width,R.height,0,_,x,R.data);o.generateMipmaps=!1}else P?(D&&t.texStorage2D(e.TEXTURE_2D,U,w,g.width,g.height),L&&function(n,a,r,i){var o=n.updateRanges;if(0===o.length)t.texSubImage2D(e.TEXTURE_2D,0,0,0,a.width,a.height,r,i,a.data);else{o.sort(function(e,n){return e.start-n.start});for(var s=0,l=1;l<o.length;l++){var c=o[s],u=o[l],d=c.start+c.count,f=k(u.start,a.width,4),p=k(c.start,a.width,4);u.start<=d+1&&f===p&&k(u.start+u.count-1,a.width,4)===f?c.count=Math.max(c.count,u.start+u.count-c.start):o[++s]=u}o.length=s+1;var h=t.getParameter(e.UNPACK_ROW_LENGTH),v=t.getParameter(e.UNPACK_SKIP_PIXELS),m=t.getParameter(e.UNPACK_SKIP_ROWS);t.pixelStorei(e.UNPACK_ROW_LENGTH,a.width);for(var g=0,_=o.length;g<_;g++){var x=o[g],S=Math.floor(x.start/4),y=Math.ceil(x.count/4),b=S%a.width,w=Math.floor(S/a.width);t.pixelStorei(e.UNPACK_SKIP_PIXELS,b),t.pixelStorei(e.UNPACK_SKIP_ROWS,w),t.texSubImage2D(e.TEXTURE_2D,0,b,w,y,1,r,i,a.data)}n.clearUpdateRanges(),t.pixelStorei(e.UNPACK_ROW_LENGTH,h),t.pixelStorei(e.UNPACK_SKIP_PIXELS,v),t.pixelStorei(e.UNPACK_SKIP_ROWS,m)}}(o,g,_,x)):t.texImage2D(e.TEXTURE_2D,0,w,g.width,g.height,0,_,x,g.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){P&&D&&t.texStorage3D(e.TEXTURE_2D_ARRAY,U,w,A[0].width,A[0].height,g.depth);for(var B=0,V=A.length;B<V;B++)if(R=A[B],o.format!==h.Ja)if(null!==_)if(P){if(L)if(o.layerUpdates.size>0){var G=(0,h.Ye)(R.width,R.height,o.format,o.type),H=!0,W=!1,X=void 0;try{for(var j,q=o.layerUpdates[Symbol.iterator]();!(H=(j=q.next()).done);H=!0){var Y=j.value,J=R.data.subarray(Y*G/R.data.BYTES_PER_ELEMENT,(Y+1)*G/R.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,B,0,0,Y,R.width,R.height,1,_,J)}}catch(e){W=!0,X=e}finally{try{H||null==q.return||q.return()}finally{if(W)throw X}}o.clearLayerUpdates()}else t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,B,0,0,0,R.width,R.height,g.depth,_,R.data)}else t.compressedTexImage3D(e.TEXTURE_2D_ARRAY,B,w,R.width,R.height,g.depth,0,R.data,0,0);else(0,h.wc)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else P?L&&t.texSubImage3D(e.TEXTURE_2D_ARRAY,B,0,0,0,R.width,R.height,g.depth,_,x,R.data):t.texImage3D(e.TEXTURE_2D_ARRAY,B,w,R.width,R.height,g.depth,0,_,x,R.data)}else{P&&D&&t.texStorage2D(e.TEXTURE_2D,U,w,A[0].width,A[0].height);for(var Q=0,$=A.length;Q<$;Q++)R=A[Q],o.format!==h.Ja?null!==_?P?L&&t.compressedTexSubImage2D(e.TEXTURE_2D,Q,0,0,R.width,R.height,_,R.data):t.compressedTexImage2D(e.TEXTURE_2D,Q,w,R.width,R.height,0,R.data):(0,h.wc)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):P?L&&t.texSubImage2D(e.TEXTURE_2D,Q,0,0,R.width,R.height,_,x,R.data):t.texImage2D(e.TEXTURE_2D,Q,w,R.width,R.height,0,_,x,R.data)}else if(o.isDataArrayTexture)if(P){if(D&&t.texStorage3D(e.TEXTURE_2D_ARRAY,U,w,g.width,g.height,g.depth),L)if(o.layerUpdates.size>0){var ee=(0,h.Ye)(g.width,g.height,o.format,o.type),en=!0,et=!1,ea=void 0;try{for(var er,ei=o.layerUpdates[Symbol.iterator]();!(en=(er=ei.next()).done);en=!0){var eo=er.value,es=g.data.subarray(eo*ee/g.data.BYTES_PER_ELEMENT,(eo+1)*ee/g.data.BYTES_PER_ELEMENT);t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,eo,g.width,g.height,1,_,x,es)}}catch(e){et=!0,ea=e}finally{try{en||null==ei.return||ei.return()}finally{if(et)throw ea}}o.clearLayerUpdates()}else t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,g.width,g.height,g.depth,_,x,g.data)}else t.texImage3D(e.TEXTURE_2D_ARRAY,0,w,g.width,g.height,g.depth,0,_,x,g.data);else if(o.isData3DTexture)P?(D&&t.texStorage3D(e.TEXTURE_3D,U,w,g.width,g.height,g.depth),L&&t.texSubImage3D(e.TEXTURE_3D,0,0,0,0,g.width,g.height,g.depth,_,x,g.data)):t.texImage3D(e.TEXTURE_3D,0,w,g.width,g.height,g.depth,0,_,x,g.data);else if(o.isFramebufferTexture){if(D)if(P)t.texStorage2D(e.TEXTURE_2D,U,w,g.width,g.height);else for(var el=g.width,ec=g.height,eu=0;eu<U;eu++)t.texImage2D(e.TEXTURE_2D,eu,w,el,ec,0,_,x,null),el>>=1,ec>>=1}else if(o.isHTMLTexture){if("texElementImage2D"in e){var ed=e.canvas;if(ed.hasAttribute("layoutsubtree")||ed.setAttribute("layoutsubtree","true"),g.parentNode!==ed)return ed.appendChild(g),m.add(o),ed.onpaint=function(e){var n=e.changedElements,t=!0,a=!1,r=void 0;try{for(var i,o=m[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;n.includes(s.image)&&(s.needsUpdate=!0)}}catch(e){a=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(a)throw r}}},void ed.requestPaint();if(3===e.texElementImage2D.length)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,g);else{var ef=e.RGBA,ep=e.RGBA,eh=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,ef,ep,eh,g)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(A.length>0){if(P&&D){var ev=Z(A[0]);t.texStorage2D(e.TEXTURE_2D,U,w,ev.width,ev.height)}for(var em=0,eg=A.length;em<eg;em++)R=A[em],P?L&&t.texSubImage2D(e.TEXTURE_2D,em,0,0,_,x,R):t.texImage2D(e.TEXTURE_2D,em,w,_,x,R);o.generateMipmaps=!1}else if(P){if(D){var e_=Z(g);t.texStorage2D(e.TEXTURE_2D,U,w,e_.width,e_.height)}L&&t.texSubImage2D(e.TEXTURE_2D,0,0,0,_,x,g)}else t.texImage2D(e.TEXTURE_2D,0,w,_,x,g);y(o)&&b(l),d.__version=u.version,o.onUpdate&&o.onUpdate(o)}n.__version=o.version}function V(n,r,o,s,l,c){var u=i.convert(o.format,o.colorSpace),f=i.convert(o.type),p=T(o.internalFormat,u,f,o.normalized,o.colorSpace),h=a.get(r),v=a.get(o);if(v.__renderTarget=r,!h.__hasExternalTextures){var m=Math.max(1,r.width>>c),g=Math.max(1,r.height>>c);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?t.texImage3D(l,c,p,m,g,r.depth,0,u,f,null):t.texImage2D(l,c,p,m,g,0,u,f,null)}t.bindFramebuffer(e.FRAMEBUFFER,n),Y(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,l,v.__webglTexture,0,q(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,l,v.__webglTexture,c),t.bindFramebuffer(e.FRAMEBUFFER,null)}function G(n,t,a){if(e.bindRenderbuffer(e.RENDERBUFFER,n),t.depthBuffer){var r=t.depthTexture,o=r&&r.isDepthTexture?r.type:null,s=E(t.stencilBuffer,o),l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;Y(t)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,q(t),s,t.width,t.height):a?e.renderbufferStorageMultisample(e.RENDERBUFFER,q(t),s,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,s,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,n)}else for(var c=t.textures,u=0;u<c.length;u++){var f=c[u],p=i.convert(f.format,f.colorSpace),h=i.convert(f.type),v=T(f.internalFormat,p,h,f.normalized,f.colorSpace);Y(t)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,q(t),v,t.width,t.height):a?e.renderbufferStorageMultisample(e.RENDERBUFFER,q(t),v,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,v,t.width,t.height)}e.bindRenderbuffer(e.RENDERBUFFER,null)}function H(n,r,o){var s=!0===r.isWebGLCubeRenderTarget;if(t.bindFramebuffer(e.FRAMEBUFFER,n),!r.depthTexture||!r.depthTexture.isDepthTexture)throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");var l=a.get(r.depthTexture);if(l.__renderTarget=r,l.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),s){if(void 0===l.__webglInit&&(l.__webglInit=!0,r.depthTexture.addEventListener("dispose",R)),void 0===l.__webglTexture){l.__webglTexture=e.createTexture(),t.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),F(e.TEXTURE_CUBE_MAP,r.depthTexture);var c,u=i.convert(r.depthTexture.format),f=i.convert(r.depthTexture.type);r.depthTexture.format===h.Ka?c=e.DEPTH_COMPONENT24:r.depthTexture.format===h.La&&(c=e.DEPTH24_STENCIL8);for(var p=0;p<6;p++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,c,r.width,r.height,0,u,f,null)}}else L(r.depthTexture,0);var v=l.__webglTexture,m=q(r),g=s?e.TEXTURE_CUBE_MAP_POSITIVE_X+o:e.TEXTURE_2D,_=r.depthTexture.format===h.La?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(r.depthTexture.format===h.Ka)Y(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,_,g,v,0,m):e.framebufferTexture2D(e.FRAMEBUFFER,_,g,v,0);else{if(r.depthTexture.format!==h.La)throw Error("THREE.WebGLTextures: Unknown depthTexture format.");Y(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,_,g,v,0,m):e.framebufferTexture2D(e.FRAMEBUFFER,_,g,v,0)}}function W(n){var r=a.get(n),i=!0===n.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==n.depthTexture){var o=n.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),o){var s=function(){delete r.__boundDepthTexture,delete r.__depthDisposeCallback,o.removeEventListener("dispose",s)};o.addEventListener("dispose",s),r.__depthDisposeCallback=s}r.__boundDepthTexture=o}if(n.depthTexture&&!r.__autoAllocateDepthBuffer)if(i)for(var l=0;l<6;l++)H(r.__webglFramebuffer[l],n,l);else{var c=n.texture.mipmaps;c&&c.length>0?H(r.__webglFramebuffer[0],n,0):H(r.__webglFramebuffer,n,0)}else if(i){r.__webglDepthbuffer=[];for(var u=0;u<6;u++)if(t.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[u]),void 0===r.__webglDepthbuffer[u])r.__webglDepthbuffer[u]=e.createRenderbuffer(),G(r.__webglDepthbuffer[u],n,!1);else{var d=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,f=r.__webglDepthbuffer[u];e.bindRenderbuffer(e.RENDERBUFFER,f),e.framebufferRenderbuffer(e.FRAMEBUFFER,d,e.RENDERBUFFER,f)}}else{var p=n.texture.mipmaps;if(p&&p.length>0?t.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):t.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),G(r.__webglDepthbuffer,n,!1);else{var h=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,v=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,v),e.framebufferRenderbuffer(e.FRAMEBUFFER,h,e.RENDERBUFFER,v)}}t.bindFramebuffer(e.FRAMEBUFFER,null)}var X=[],j=[];function q(e){return Math.min(r.maxSamples,e.samples)}function Y(e){var t=a.get(e);return e.samples>0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==t.__useRenderToTexture}function K(e,n){var t=e.colorSpace,a=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||t!==h.Jb&&t!==h.Hb&&(h.Hc.getTransfer(t)===h.Lb?(a!==h.Ja||r!==h.ua)&&(0,h.wc)("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):(0,h.xc)("WebGLTextures: Unsupported texture color space:",t)),n}function Z(e){return("u"<typeof HTMLImageElement?"undefined":I(HTMLImageElement))<"u"&&C(e,HTMLImageElement)?(p.width=e.naturalWidth||e.width,p.height=e.naturalHeight||e.height):("u"<typeof VideoFrame?"undefined":I(VideoFrame))<"u"&&C(e,VideoFrame)?(p.width=e.displayWidth,p.height=e.displayHeight):(p.width=e.width,p.height=e.height),p}this.allocateTextureUnit=function(){var e=D;return e>=r.maxTextures&&(0,h.wc)("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),D+=1,e},this.resetTextureUnits=function(){D=0},this.getTextureUnits=function(){return D},this.setTextureUnits=function(e){D=e},this.setTexture2D=L,this.setTexture2DArray=function(n,r){var i=a.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?B(i,n,r):(n.isExternalTexture&&(i.__webglTexture=n.sourceTexture?n.sourceTexture:null),t.bindTexture(e.TEXTURE_2D_ARRAY,i.__webglTexture,e.TEXTURE0+r))},this.setTexture3D=function(n,r){var i=a.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?B(i,n,r):t.bindTexture(e.TEXTURE_3D,i.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(n,o){var s=a.get(n);!0!==n.isCubeDepthTexture&&n.version>0&&s.__version!==n.version?function(n,o,s){if(6===o.image.length){var l=z(n,o),c=o.source;t.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture,e.TEXTURE0+s);var u=a.get(c);if(c.version!==u.__version||!0===l){t.activeTexture(e.TEXTURE0+s);var d=h.Hc.getPrimaries(h.Hc.workingColorSpace),f=o.colorSpace===h.Hb?null:h.Hc.getPrimaries(o.colorSpace),p=o.colorSpace===h.Hb||d===f?e.NONE:e.BROWSER_DEFAULT_WEBGL;t.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),t.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),t.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),t.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);for(var v=o.isCompressedTexture||o.image[0].isCompressedTexture,m=o.image[0]&&o.image[0].isDataTexture,g=[],_=0;_<6;_++)g[_]=v||m?m?o.image[_].image:o.image[_]:S(o.image[_],!0,r.maxCubemapSize),g[_]=K(o,g[_]);var x,w=g[0],E=i.convert(o.format,o.colorSpace),C=i.convert(o.type),R=T(o.internalFormat,E,C,o.normalized,o.colorSpace),A=!0!==o.isVideoTexture,P=void 0===u.__version||!0===l,D=c.dataReady,L=M(o,w);if(F(e.TEXTURE_CUBE_MAP,o),v){A&&P&&t.texStorage2D(e.TEXTURE_CUBE_MAP,L,R,w.width,w.height);for(var U=0;U<6;U++){x=g[U].mipmaps;for(var N=0;N<x.length;N++){var I=x[N];o.format!==h.Ja?null!==E?A?D&&t.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+U,N,0,0,I.width,I.height,E,I.data):t.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+U,N,R,I.width,I.height,0,I.data):(0,h.wc)("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):A?D&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+U,N,0,0,I.width,I.height,E,C,I.data):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+U,N,R,I.width,I.height,0,E,C,I.data)}}}else{if(x=o.mipmaps,A&&P){x.length>0&&L++;var O=Z(g[0]);t.texStorage2D(e.TEXTURE_CUBE_MAP,L,R,O.width,O.height)}for(var k=0;k<6;k++)if(m){A?D&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,g[k].width,g[k].height,E,C,g[k].data):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,R,g[k].width,g[k].height,0,E,C,g[k].data);for(var B=0;B<x.length;B++){var V=x[B].image[k].image;A?D&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,B+1,0,0,V.width,V.height,E,C,V.data):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,B+1,R,V.width,V.height,0,E,C,V.data)}}else{A?D&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,E,C,g[k]):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,R,E,C,g[k]);for(var G=0;G<x.length;G++){var H=x[G];A?D&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,G+1,0,0,E,C,H.image[k]):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,G+1,R,E,C,H.image[k])}}}y(o)&&b(e.TEXTURE_CUBE_MAP),u.__version=c.version,o.onUpdate&&o.onUpdate(o)}n.__version=o.version}}(s,n,o):t.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+o)},this.rebindTextures=function(n,t,r){var i=a.get(n);void 0!==t&&V(i.__webglFramebuffer,n,n.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&W(n)},this.setupRenderTarget=function(n){var r=n.texture,s=a.get(n),l=a.get(r);n.addEventListener("dispose",A);var c=n.textures,u=!0===n.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)if(r.mipmaps&&r.mipmaps.length>0){s.__webglFramebuffer[f]=[];for(var p=0;p<r.mipmaps.length;p++)s.__webglFramebuffer[f][p]=e.createFramebuffer()}else s.__webglFramebuffer[f]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){s.__webglFramebuffer=[];for(var h=0;h<r.mipmaps.length;h++)s.__webglFramebuffer[h]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(var v=0,m=c.length;v<m;v++){var g=a.get(c[v]);void 0===g.__webglTexture&&(g.__webglTexture=e.createTexture(),o.memory.textures++)}if(n.samples>0&&!1===Y(n)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],t.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(var _=0;_<c.length;_++){var x=c[_];s.__webglColorRenderbuffer[_]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[_]);var S=i.convert(x.format,x.colorSpace),w=i.convert(x.type),E=T(x.internalFormat,S,w,x.normalized,x.colorSpace,!0===n.isXRRenderTarget),M=q(n);e.renderbufferStorageMultisample(e.RENDERBUFFER,M,E,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_,e.RENDERBUFFER,s.__webglColorRenderbuffer[_])}e.bindRenderbuffer(e.RENDERBUFFER,null),n.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),G(s.__webglDepthRenderbuffer,n,!0)),t.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){t.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),F(e.TEXTURE_CUBE_MAP,r);for(var C=0;C<6;C++)if(r.mipmaps&&r.mipmaps.length>0)for(var R=0;R<r.mipmaps.length;R++)V(s.__webglFramebuffer[C][R],n,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+C,R);else V(s.__webglFramebuffer[C],n,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+C,0);y(r)&&b(e.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(d){for(var P=0,D=c.length;P<D;P++){var L=c[P],U=a.get(L),N=e.TEXTURE_2D;(n.isWebGL3DRenderTarget||n.isWebGLArrayRenderTarget)&&(N=n.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),t.bindTexture(N,U.__webglTexture),F(N,L),V(s.__webglFramebuffer,n,L,e.COLOR_ATTACHMENT0+P,N,0),y(L)&&b(N)}t.unbindTexture()}else{var I=e.TEXTURE_2D;if((n.isWebGL3DRenderTarget||n.isWebGLArrayRenderTarget)&&(I=n.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),t.bindTexture(I,l.__webglTexture),F(I,r),r.mipmaps&&r.mipmaps.length>0)for(var O=0;O<r.mipmaps.length;O++)V(s.__webglFramebuffer[O],n,r,e.COLOR_ATTACHMENT0,I,O);else V(s.__webglFramebuffer,n,r,e.COLOR_ATTACHMENT0,I,0);y(r)&&b(I),t.unbindTexture()}n.depthBuffer&&W(n)},this.updateRenderTargetMipmap=function(n){for(var r=n.textures,i=0,o=r.length;i<o;i++){var s=r[i];if(y(s)){var l=n.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:n.isWebGL3DRenderTarget?e.TEXTURE_3D:n.isWebGLArrayRenderTarget||n.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D,c=a.get(s).__webglTexture;t.bindTexture(l,c),b(l),t.unbindTexture()}}},this.updateMultisampleRenderTarget=function(n){if(n.samples>0){if(!1===Y(n)){var r=n.textures,i=n.width,o=n.height,s=e.COLOR_BUFFER_BIT,l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=a.get(n),u=r.length>1;if(u)for(var d=0;d<r.length;d++)t.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+d,e.RENDERBUFFER,null),t.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+d,e.TEXTURE_2D,null,0);t.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);var p=n.texture.mipmaps;p&&p.length>0?t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(var h=0;h<r.length;h++){if(n.resolveDepthBuffer&&(n.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),n.stencilBuffer&&n.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[h]);var v=a.get(r[h]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,v,0)}e.blitFramebuffer(0,0,i,o,0,0,i,o,s,e.NEAREST),!0===f&&(X.length=0,j.length=0,X.push(e.COLOR_ATTACHMENT0+h),n.depthBuffer&&!1===n.resolveDepthBuffer&&(X.push(l),j.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,j)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,X))}if(t.bindFramebuffer(e.READ_FRAMEBUFFER,null),t.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(var m=0;m<r.length;m++){t.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+m,e.RENDERBUFFER,c.__webglColorRenderbuffer[m]);var g=a.get(r[m]).__webglTexture;t.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+m,e.TEXTURE_2D,g,0)}t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(n.depthBuffer&&!1===n.resolveDepthBuffer&&f){var _=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[_])}}},this.setupDepthRenderbuffer=W,this.setupFrameBufferTexture=V,this.useMultisampledRTT=Y,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function tS(e,n){return{convert:function(t){var a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.Hb,i=h.Hc.getTransfer(r);if(t===h.ua)return e.UNSIGNED_BYTE;if(t===h.Ca)return e.UNSIGNED_SHORT_4_4_4_4;if(t===h.Da)return e.UNSIGNED_SHORT_5_5_5_1;if(t===h.Fa)return e.UNSIGNED_INT_5_9_9_9_REV;if(t===h.Ga)return e.UNSIGNED_INT_10F_11F_11F_REV;if(t===h.va)return e.BYTE;if(t===h.wa)return e.SHORT;if(t===h.xa)return e.UNSIGNED_SHORT;if(t===h.ya)return e.INT;if(t===h.za)return e.UNSIGNED_INT;if(t===h.Aa)return e.FLOAT;if(t===h.Ba)return e.HALF_FLOAT;if(t===h.Ha)return e.ALPHA;if(t===h.Ia)return e.RGB;if(t===h.Ja)return e.RGBA;if(t===h.Ka)return e.DEPTH_COMPONENT;if(t===h.La)return e.DEPTH_STENCIL;if(t===h.Ma)return e.RED;if(t===h.Na)return e.RED_INTEGER;if(t===h.Oa)return e.RG;if(t===h.Pa)return e.RG_INTEGER;if(t===h.Ra)return e.RGBA_INTEGER;if(t===h.Sa||t===h.Ta||t===h.Ua||t===h.Va)if(i===h.Lb){if(null===(a=n.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(t===h.Sa)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(t===h.Ta)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(t===h.Ua)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(t===h.Va)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(a=n.get("WEBGL_compressed_texture_s3tc")))return null;if(t===h.Sa)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===h.Ta)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===h.Ua)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===h.Va)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===h.Wa||t===h.Xa||t===h.Ya||t===h.Za){if(null===(a=n.get("WEBGL_compressed_texture_pvrtc")))return null;if(t===h.Wa)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===h.Xa)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===h.Ya)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===h.Za)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===h._a||t===h.$a||t===h.ab||t===h.bb||t===h.cb||t===h.db||t===h.eb){if(null===(a=n.get("WEBGL_compressed_texture_etc")))return null;if(t===h._a||t===h.$a)return i===h.Lb?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(t===h.ab)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(t===h.bb)return a.COMPRESSED_R11_EAC;if(t===h.cb)return a.COMPRESSED_SIGNED_R11_EAC;if(t===h.db)return a.COMPRESSED_RG11_EAC;if(t===h.eb)return a.COMPRESSED_SIGNED_RG11_EAC}if(t===h.fb||t===h.gb||t===h.hb||t===h.ib||t===h.jb||t===h.kb||t===h.lb||t===h.mb||t===h.nb||t===h.ob||t===h.pb||t===h.qb||t===h.rb||t===h.sb){if(null===(a=n.get("WEBGL_compressed_texture_astc")))return null;if(t===h.fb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(t===h.gb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(t===h.hb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(t===h.ib)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(t===h.jb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(t===h.kb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(t===h.lb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(t===h.mb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(t===h.nb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(t===h.ob)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(t===h.pb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(t===h.qb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(t===h.rb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(t===h.sb)return i===h.Lb?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(t===h.tb||t===h.ub||t===h.vb){if(null===(a=n.get("EXT_texture_compression_bptc")))return null;if(t===h.tb)return i===h.Lb?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(t===h.ub)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(t===h.vb)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(t===h.wb||t===h.xb||t===h.yb||t===h.zb){if(null===(a=n.get("EXT_texture_compression_rgtc")))return null;if(t===h.wb)return a.COMPRESSED_RED_RGTC1_EXT;if(t===h.xb)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(t===h.yb)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(t===h.zb)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return t===h.Ea?e.UNSIGNED_INT_24_8:void 0!==e[t]?e[t]:null}}}var ty=new h.Oc,tb=new h.Gc;function tw(e,n){function t(e,n){!0===e.matrixAutoUpdate&&e.updateMatrix(),n.value.copy(e.matrix)}function a(e,a){e.opacity.value=a.opacity,a.color&&e.diffuse.value.copy(a.color),a.emissive&&e.emissive.value.copy(a.emissive).multiplyScalar(a.emissiveIntensity),a.map&&(e.map.value=a.map,t(a.map,e.mapTransform)),a.alphaMap&&(e.alphaMap.value=a.alphaMap,t(a.alphaMap,e.alphaMapTransform)),a.bumpMap&&(e.bumpMap.value=a.bumpMap,t(a.bumpMap,e.bumpMapTransform),e.bumpScale.value=a.bumpScale,a.side===h.k&&(e.bumpScale.value*=-1)),a.normalMap&&(e.normalMap.value=a.normalMap,t(a.normalMap,e.normalMapTransform),e.normalScale.value.copy(a.normalScale),a.side===h.k&&e.normalScale.value.negate()),a.displacementMap&&(e.displacementMap.value=a.displacementMap,t(a.displacementMap,e.displacementMapTransform),e.displacementScale.value=a.displacementScale,e.displacementBias.value=a.displacementBias),a.emissiveMap&&(e.emissiveMap.value=a.emissiveMap,t(a.emissiveMap,e.emissiveMapTransform)),a.specularMap&&(e.specularMap.value=a.specularMap,t(a.specularMap,e.specularMapTransform)),a.alphaTest>0&&(e.alphaTest.value=a.alphaTest);var r=n.get(a),i=r.envMap,o=r.envMapRotation;i&&(e.envMap.value=i,e.envMapRotation.value.setFromMatrix4(ty.makeRotationFromEuler(o)).transpose(),i.isCubeTexture&&!1===i.isRenderTargetTexture&&e.envMapRotation.value.premultiply(tb),e.reflectivity.value=a.reflectivity,e.ior.value=a.ior,e.refractionRatio.value=a.refractionRatio),a.lightMap&&(e.lightMap.value=a.lightMap,e.lightMapIntensity.value=a.lightMapIntensity,t(a.lightMap,e.lightMapTransform)),a.aoMap&&(e.aoMap.value=a.aoMap,e.aoMapIntensity.value=a.aoMapIntensity,t(a.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(n,t){t.color.getRGB(n.fogColor.value,(0,h.ae)(e)),t.isFog?(n.fogNear.value=t.near,n.fogFar.value=t.far):t.isFogExp2&&(n.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,r,i,o,s){var l;r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?a(e,r):r.isMeshLambertMaterial?(a(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(a(e,r),r.gradientMap&&(e.gradientMap.value=r.gradientMap)):r.isMeshPhongMaterial?(a(e,r),e.specular.value.copy(r.specular),e.shininess.value=Math.max(r.shininess,1e-4),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(a(e,r),e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,t(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,t(r.roughnessMap,e.roughnessMapTransform)),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity),r.isMeshPhysicalMaterial&&(e.ior.value=r.ior,r.sheen>0&&(e.sheenColor.value.copy(r.sheenColor).multiplyScalar(r.sheen),e.sheenRoughness.value=r.sheenRoughness,r.sheenColorMap&&(e.sheenColorMap.value=r.sheenColorMap,t(r.sheenColorMap,e.sheenColorMapTransform)),r.sheenRoughnessMap&&(e.sheenRoughnessMap.value=r.sheenRoughnessMap,t(r.sheenRoughnessMap,e.sheenRoughnessMapTransform))),r.clearcoat>0&&(e.clearcoat.value=r.clearcoat,e.clearcoatRoughness.value=r.clearcoatRoughness,r.clearcoatMap&&(e.clearcoatMap.value=r.clearcoatMap,t(r.clearcoatMap,e.clearcoatMapTransform)),r.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=r.clearcoatRoughnessMap,t(r.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),r.clearcoatNormalMap&&(e.clearcoatNormalMap.value=r.clearcoatNormalMap,t(r.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(r.clearcoatNormalScale),r.side===h.k&&e.clearcoatNormalScale.value.negate())),r.dispersion>0&&(e.dispersion.value=r.dispersion),r.iridescence>0&&(e.iridescence.value=r.iridescence,e.iridescenceIOR.value=r.iridescenceIOR,e.iridescenceThicknessMinimum.value=r.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=r.iridescenceThicknessRange[1],r.iridescenceMap&&(e.iridescenceMap.value=r.iridescenceMap,t(r.iridescenceMap,e.iridescenceMapTransform)),r.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=r.iridescenceThicknessMap,t(r.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),r.transmission>0&&(e.transmission.value=r.transmission,e.transmissionSamplerMap.value=s.texture,e.transmissionSamplerSize.value.set(s.width,s.height),r.transmissionMap&&(e.transmissionMap.value=r.transmissionMap,t(r.transmissionMap,e.transmissionMapTransform)),e.thickness.value=r.thickness,r.thicknessMap&&(e.thicknessMap.value=r.thicknessMap,t(r.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=r.attenuationDistance,e.attenuationColor.value.copy(r.attenuationColor)),r.anisotropy>0&&(e.anisotropyVector.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation)),r.anisotropyMap&&(e.anisotropyMap.value=r.anisotropyMap,t(r.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=r.specularIntensity,e.specularColor.value.copy(r.specularColor),r.specularColorMap&&(e.specularColorMap.value=r.specularColorMap,t(r.specularColorMap,e.specularColorMapTransform)),r.specularIntensityMap&&(e.specularIntensityMap.value=r.specularIntensityMap,t(r.specularIntensityMap,e.specularIntensityMapTransform)))):r.isMeshMatcapMaterial?(a(e,r),r.matcap&&(e.matcap.value=r.matcap)):r.isMeshDepthMaterial?a(e,r):r.isMeshDistanceMaterial?(a(e,r),l=n.get(r).light,e.referencePosition.value.setFromMatrixPosition(l.matrixWorld),e.nearDistance.value=l.shadow.camera.near,e.farDistance.value=l.shadow.camera.far):r.isMeshNormalMaterial?a(e,r):r.isLineBasicMaterial?(e.diffuse.value.copy(r.color),e.opacity.value=r.opacity,r.map&&(e.map.value=r.map,t(r.map,e.mapTransform)),r.isLineDashedMaterial&&(e.dashSize.value=r.dashSize,e.totalSize.value=r.dashSize+r.gapSize,e.scale.value=r.scale)):r.isPointsMaterial?(e.diffuse.value.copy(r.color),e.opacity.value=r.opacity,e.size.value=r.size*i,e.scale.value=.5*o,r.map&&(e.map.value=r.map,t(r.map,e.uvTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,t(r.alphaMap,e.alphaMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest)):r.isSpriteMaterial?(e.diffuse.value.copy(r.color),e.opacity.value=r.opacity,e.rotation.value=r.rotation,r.map&&(e.map.value=r.map,t(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,t(r.alphaMap,e.alphaMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest)):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}tb.set(-1,0,0,0,1,0,0,0,1);var tT=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]),tE=null,tM=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,e);var t,a=function(){return null===eq?e2:1},r=function(e,n){return w.getContext(e,n)},i=function(){(es=new eF(ns)).init(),eA=new tS(ns,es),el=new eU(ns,es,n,eA),ec=new t_(ns,es),el.reversedDepthBuffer&&G&&ec.buffers.depth.setReversed(!0),er=ns.createFramebuffer(),ei=ns.createFramebuffer(),eo=ns.createFramebuffer(),eu=new eB(ns),ed=new tn,ef=new tx(ns,es,ec,ed,el,eA,eu),ep=new eO(en),eh=new ew(ns),eI=new eD(ns,eh),ev=new ez(ns,eh,eu,eI),em=new eG(ns,ev,eh,eI,eu),eM=new eV(ns,el,ef),ey=new eN(ed),eg=new te(en,ep,es,el,eI,ey),e_=new tw(en,ed),ex=new ti,eS=new td(es),eE=new eP(en,ep,ec,em,t,O),eT=new tg(en,em,el),eH={update:function(){throw Error("UniformsGroups are not supported by the Spline runtime")},bind:function(){throw Error("UniformsGroups are not supported by the Spline runtime")},dispose:function(){}},eC=new eL(ns,es,eu),eR=new ek(ns,es,eu),eu.programs=eg.programs,en.capabilities=el,en.extensions=es,en.properties=ed,en.renderLists=ex,en.shadowMap=eT,en.state=ec,en.info=eu},o=function(e){e.preventDefault(),(0,h.vc)("WebGLRenderer: Context Lost."),et=!0},s=function(){(0,h.vc)("WebGLRenderer: Context Restored."),et=!1;var e=eu.autoReset,n=eT.enabled,t=eT.autoUpdate,a=eT.needsUpdate,r=eT.type;i(),eu.autoReset=e,eT.enabled=n,eT.autoUpdate=t,eT.needsUpdate=a,eT.type=r},l=function(e){(0,h.xc)("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)},c=function(e,n,t){!0===e.transparent&&e.side===h.l&&!1===e.forceSinglePass?(e.side=h.k,e.needsUpdate=!0,_(e,n,t),e.side=h.j,e.needsUpdate=!0,_(e,n,t),e.side=h.l):_(e,n,t)},u=function(){nf.stop()},d=function(){nf.start()},f=function(e,n,t,a){var r=e.opaque,i=e.transmissive,o=e.transparent;J.setupLightsView(t),!0===ne&&ey.setGlobalState(en.clippingPlanes,t),a&&ec.viewport(eZ.copy(a)),r.length>0&&v(r,n,t),i.length>0&&v(i,n,t),o.length>0&&v(o,n,t),ec.buffers.depth.setTest(!0),ec.buffers.depth.setMask(!0),ec.buffers.color.setMask(!0),ec.setPolygonOffset(!1)},p=function(e,n,t,a){if(null===(!0===t.isScene?t.overrideMaterial:null)){if(void 0===J.state.transmissionRenderTarget[a.id]){var r=es.has("EXT_color_buffer_half_float")||es.has("EXT_color_buffer_float");J.state.transmissionRenderTarget[a.id]=new h.Lc(1,1,{generateMipmaps:!0,type:r?h.Ba:h.ua,minFilter:h.sa,samples:Math.max(4,el.samples),stencilBuffer:P,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:h.Hc.workingColorSpace})}var i=J.state.transmissionRenderTarget[a.id],o=a.viewport||eZ;i.setSize(o.z*en.transmissionResolutionScale,o.w*en.transmissionResolutionScale);var s=en.getRenderTarget(),l=en.getActiveCubeFace(),c=en.getActiveMipmapLevel();en.setRenderTarget(i),en.getClearColor(e$),(e0=en.getClearAlpha())<1&&en.setClearColor(0xffffff,.5),en.clear(),no&&eE.render(t);var u=en.toneMapping;en.toneMapping=h.Y;var d=a.viewport;if(void 0!==a.viewport&&(a.viewport=void 0),J.setupLightsView(a),!0===ne&&ey.setGlobalState(en.clippingPlanes,a),v(e,t,a),ef.updateMultisampleRenderTarget(i),ef.updateRenderTargetMipmap(i),!1===es.has("WEBGL_multisampled_render_to_texture")){for(var f=!1,p=0,g=n.length;p<g;p++){var _=n[p],x=_.object,S=_.geometry,y=_.material,b=_.group;if(y.side===h.l&&x.layers.test(a.layers)){var w=y.side;y.side=h.k,y.needsUpdate=!0,m(x,t,a,S,y,b),y.side=w,y.needsUpdate=!0,f=!0}}!0===f&&(ef.updateMultisampleRenderTarget(i),ef.updateRenderTargetMipmap(i))}en.setRenderTarget(s,l,c),en.setClearColor(e$,e0),void 0!==d&&(a.viewport=d),en.toneMapping=u}},v=function(e,n,t){for(var a=!0===n.isScene?n.overrideMaterial:null,r=0,i=e.length;r<i;r++){var o=e[r],s=o.object,l=o.geometry,c=o.group,u=o.material;!0===u.allowOverride&&null!==a&&(u=a),s.layers.test(t.layers)&&m(s,n,t,l,u,c)}},m=function(e,n,t,a,r,i){e.onBeforeRender(en,n,t,a,r,i),e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(en,n,t,a,e,i),!0===r.transparent&&r.side===h.l&&!1===r.forceSinglePass?(r.side=h.k,r.needsUpdate=!0,en.renderBufferDirect(t,n,a,r,e,i),r.side=h.j,r.needsUpdate=!0,en.renderBufferDirect(t,n,a,r,e,i),r.side=h.l):en.renderBufferDirect(t,n,a,r,e,i),e.onAfterRender(en,n,t,a,r,i)},_=function(e,n,t){!0!==n.isScene&&(n=ni);var a=ed.get(e),r=J.state.lights,i=J.state.shadowsArray,o=r.state.version,s=eg.getParameters(e,r.state,i,n,t,J.state.lightProbeGridArray),l=eg.getProgramCacheKey(s),c=a.programs;a.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?n.environment:null,a.fog=n.fog;var u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;a.envMap=ep.get(e.envMap||a.environment,u),a.envMapRotation=null!==a.environment&&null===e.envMap?n.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",nu),a.programs=c=new Map);var d=c.get(l);if(void 0!==d){if(a.currentProgram===d&&a.lightsStateVersion===o)return y(e,s),d}else s.uniforms=eg.getUniforms(e),null!==ea&&e.isNodeMaterial&&ea.build(e,t,s),e.onBeforeCompile(s,en),d=eg.acquireProgram(s,l),c.set(l,d),a.uniforms=s.uniforms;var f=a.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(f.clippingPlanes=ey.uniform),y(e,s),a.needsLights=e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights,a.lightsStateVersion=o,a.needsLights&&(f.ambientLightColor.value=r.state.ambient,f.lightProbe.value=r.state.probe,f.directionalLights.value=r.state.directional,f.directionalLightShadows.value=r.state.directionalShadow,f.spotLights.value=r.state.spot,f.spotLightShadows.value=r.state.spotShadow,f.rectAreaLights.value=r.state.rectArea,f.ltc_1.value=r.state.rectAreaLTC1,f.ltc_2.value=r.state.rectAreaLTC2,f.pointLights.value=r.state.point,f.pointLightShadows.value=r.state.pointShadow,f.hemisphereLights.value=r.state.hemi,f.directionalShadowMatrix.value=r.state.directionalShadowMatrix,f.spotLightMatrix.value=r.state.spotLightMatrix,f.spotLightMap.value=r.state.spotLightMap,f.pointShadowMatrix.value=r.state.pointShadowMatrix),a.lightProbeGrid=J.state.lightProbeGridArray.length>0,a.currentProgram=d,a.uniformsList=null,d},S=function(e){if(null===e.uniformsList){var n=e.currentProgram.getUniforms();e.uniformsList=nz.seqWithValue(n.seq,e.uniforms)}return e.uniformsList},y=function(e,n){var t=ed.get(e);t.outputColorSpace=n.outputColorSpace,t.batching=n.batching,t.batchingColor=n.batchingColor,t.instancing=n.instancing,t.instancingColor=n.instancingColor,t.instancingMorph=n.instancingMorph,t.skinning=n.skinning,t.morphTargets=n.morphTargets,t.morphNormals=n.morphNormals,t.morphColors=n.morphColors,t.morphTargetsCount=n.morphTargetsCount,t.numClippingPlanes=n.numClippingPlanes,t.numIntersection=n.numClipIntersection,t.vertexAlphas=n.vertexAlphas,t.vertexTangents=n.vertexTangents,t.toneMapping=n.toneMapping},b=n.canvas,w=void 0===b?(0,h.uc)():b,T=n.context,E=void 0===T?null:T,M=n.depth,R=void 0===M||M,A=n.stencil,P=void 0!==A&&A,D=n.alpha,L=n.antialias,U=void 0!==L&&L,N=n.premultipliedAlpha,O=void 0===N||N,F=n.preserveDrawingBuffer,k=n.powerPreference,B=n.failIfMajorPerformanceCaveat,V=n.reversedDepthBuffer,G=void 0!==V&&V,H=n.outputBufferType,W=void 0===H?h.ua:H;if(this.isWebGLRenderer=!0,null!==E){if(("u"<typeof WebGLRenderingContext?"undefined":I(WebGLRenderingContext))<"u"&&C(E,WebGLRenderingContext))throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=E.getContextAttributes().alpha}else t=void 0!==D&&D;var X=new Set([h.Ra,h.Pa,h.Na]),j=new Set([h.ua,h.za,h.xa,h.Ea,h.Ca,h.Da]),q=new Uint32Array(4),Y=new Int32Array(4),K=new h.Fc,Z=null,J=null,Q=[],$=[],ee=null;this.domElement=w,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=h.Y,this.toneMappingExposure=1,this.transmissionResolutionScale=1;var en=this,et=!1,ea=null,er=null,ei=null,eo=null;this._outputColorSpace=h.Ib;var es,el,ec,eu,ed,ef,ep,eh,ev,em,eg,e_,ex,eS,ey,eT,eE,eM,eC,eR,eA,eI,eH,eX=0,ej=0,eq=null,eY=-1,eK=null,eZ=new h.Jc,eJ=new h.Jc,eQ=null,e$=new h.Tc(0),e0=0,e1=w.width,e3=w.height,e2=1,e4=null,e5=null,e6=new h.Jc(0,0,e1,e3),e8=new h.Jc(0,0,e1,e3),e9=!1,e7=new h.sd,ne=!1,nn=!1,nt=new h.Oc,na=new h.Fc,nr=new h.Jc,ni={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},no=!1,ns=E;try{if("setAttribute"in w&&w.setAttribute("data-engine","three.js r".concat(h.a)),w.addEventListener("webglcontextlost",o,!1),w.addEventListener("webglcontextrestored",s,!1),w.addEventListener("webglcontextcreationerror",l,!1),null===ns){var nl="webgl2";if(ns=r(nl,{alpha:!0,depth:R,stencil:P,antialias:U,premultipliedAlpha:O,preserveDrawingBuffer:void 0!==F&&F,powerPreference:void 0===k?"default":k,failIfMajorPerformanceCaveat:void 0!==B&&B}),null===ns)throw r(nl)?Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(e){throw(0,h.xc)("WebGLRenderer: "+e.message),e}i(),W!==h.ua&&(ee=new eW(W,w.width,w.height,U,R,P));var nc=Object.assign(new h.Bc,{enabled:!1,isPresenting:!1,cameraAutoUpdate:!0,setFramebufferScaleFactor:function(){},setReferenceSpaceType:function(){},getReferenceSpace:function(){return null},setReferenceSpace:function(){},getBaseLayer:function(){return null},getBinding:function(){return null},getFrame:function(){return null},getSession:function(){return null},setSession:function(){return g(function(){return z(this,function(e){throw Error("WebXR is not supported by the Spline runtime")})})()},getEnvironmentBlendMode:function(){},getDepthTexture:function(){return null},updateCamera:function(){},getCamera:function(){return null},getFoveation:function(){},setFoveation:function(){},hasDepthSensing:function(){return!1},getDepthSensingMesh:function(){return null},setAnimationLoop:function(){},getController:function(){return null},getControllerGrip:function(){return null},getHand:function(){return null},dispose:function(){}});function nu(e){var n,t=e.target;t.removeEventListener("dispose",nu),void 0!==(n=ed.get(t).programs)&&(n.forEach(function(e){eg.releaseProgram(e)}),t.isShaderMaterial&&eg.releaseShaderCache(t)),ed.remove(t)}this.xr=nc,this.getContext=function(){return ns},this.getContextAttributes=function(){return ns.getContextAttributes()},this.forceContextLoss=function(){var e=es.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=es.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return e2},this.setPixelRatio=function(e){void 0!==e&&(e2=e,this.setSize(e1,e3,!1))},this.getSize=function(e){return e.set(e1,e3)},this.setSize=function(e,n){var t=!(arguments.length>2)||void 0===arguments[2]||arguments[2];nc.isPresenting?(0,h.wc)("WebGLRenderer: Can't change size while VR device is presenting."):(e1=e,e3=n,w.width=Math.floor(e*e2),w.height=Math.floor(n*e2),!0===t&&(w.style.width=e+"px",w.style.height=n+"px"),null!==ee&&ee.setSize(w.width,w.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(e1*e2,e3*e2).floor()},this.setDrawingBufferSize=function(e,n,t){e1=e,e3=n,e2=t,w.width=Math.floor(e*t),w.height=Math.floor(n*t),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(W!==h.ua){if(e){for(var n=0;n<e.length;n++)if(!0===e[n].isOutputPass){(0,h.wc)("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}ee.setEffects(e||[])}else(0,h.xc)("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(e){return e.copy(eZ)},this.getViewport=function(e){return e.copy(e6)},this.setViewport=function(e,n,t,a){e.isVector4?e6.set(e.x,e.y,e.z,e.w):e6.set(e,n,t,a),ec.viewport(eZ.copy(e6).multiplyScalar(e2).round())},this.getScissor=function(e){return e.copy(e8)},this.setScissor=function(e,n,t,a){e.isVector4?e8.set(e.x,e.y,e.z,e.w):e8.set(e,n,t,a),ec.scissor(eJ.copy(e8).multiplyScalar(e2).round())},this.getScissorTest=function(){return e9},this.setScissorTest=function(e){ec.setScissorTest(e9=e)},this.setOpaqueSort=function(e){e4=e},this.setTransparentSort=function(e){e5=e},this.getClearColor=function(e){return e.copy(eE.getClearColor())},this.setClearColor=function(){var e;(e=eE).setClearColor.apply(e,arguments)},this.getClearAlpha=function(){return eE.getClearAlpha()},this.setClearAlpha=function(){var e;(e=eE).setClearAlpha.apply(e,arguments)},this.clear=function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],n=!(arguments.length>1)||void 0===arguments[1]||arguments[1],t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=0;if(e){var r=!1;if(null!==eq){var i=eq.texture.format;r=X.has(i)}if(r){var o=eq.texture.type,s=j.has(o),l=eE.getClearColor(),c=eE.getClearAlpha(),u=l.r,d=l.g,f=l.b;s?(q[0]=u,q[1]=d,q[2]=f,q[3]=c,ns.clearBufferuiv(ns.COLOR,0,q)):(Y[0]=u,Y[1]=d,Y[2]=f,Y[3]=c,ns.clearBufferiv(ns.COLOR,0,Y))}else a|=ns.COLOR_BUFFER_BIT}n&&(a|=ns.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),t&&(a|=ns.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(0xffffffff)),0!==a&&ns.clear(a)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),ea=e},this.dispose=function(){w.removeEventListener("webglcontextlost",o,!1),w.removeEventListener("webglcontextrestored",s,!1),w.removeEventListener("webglcontextcreationerror",l,!1),eE.dispose(),ex.dispose(),eS.dispose(),ed.dispose(),ep.dispose(),em.dispose(),eI.dispose(),eH.dispose(),eg.dispose(),nc.dispose(),nc.removeEventListener("sessionstart",u),nc.removeEventListener("sessionend",d),nf.stop()},this.renderBufferDirect=function(e,n,t,r,i,o){null===n&&(n=ni);var s=i.isMesh&&0>i.matrixWorld.determinantAffine(),l=function(e,n,t,a,r){!0!==n.isScene&&(n=ni),ef.resetTextureUnits();var i,o=n.fog,s=a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial?n.environment:null,l=null===eq?en.outputColorSpace:!0===eq.isXRRenderTarget?eq.texture.colorSpace:h.Hc.workingColorSpace,c=a.isMeshStandardMaterial||a.isMeshLambertMaterial&&!a.envMap||a.isMeshPhongMaterial&&!a.envMap,u=ep.get(a.envMap||s,c),d=!0===a.vertexColors&&!!t.attributes.color&&4===t.attributes.color.itemSize,f=!!t.attributes.tangent&&(!!a.normalMap||a.anisotropy>0),p=!!t.morphAttributes.position,v=!!t.morphAttributes.normal,m=!!t.morphAttributes.color,g=h.Y;a.toneMapped&&(null===eq||!0===eq.isXRRenderTarget)&&(g=en.toneMapping);var x=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,y=void 0!==x?x.length:0,b=ed.get(a),w=J.state.lights;if(!0===ne&&(!0===nn||e!==eK)){var T=e===eK&&a.id===eY;ey.setState(a,e,T)}var E=!1;a.version===b.__version?(b.needsLights&&b.lightsStateVersion!==w.state.version||b.outputColorSpace!==l||r.isBatchedMesh&&!1===b.batching||!r.isBatchedMesh&&!0===b.batching||r.isBatchedMesh&&!0===b.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===b.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===b.instancing||!r.isInstancedMesh&&!0===b.instancing||r.isSkinnedMesh&&!1===b.skinning||!r.isSkinnedMesh&&!0===b.skinning||r.isInstancedMesh&&!0===b.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===b.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===b.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===b.instancingMorph&&null!==r.morphTexture||b.envMap!==u||!0===a.fog&&b.fog!==o||void 0!==b.numClippingPlanes&&(b.numClippingPlanes!==ey.numPlanes||b.numIntersection!==ey.numIntersection)||b.vertexAlphas!==d||b.vertexTangents!==f||b.morphTargets!==p||b.morphNormals!==v||b.morphColors!==m||b.toneMapping!==g||b.morphTargetsCount!==y||!!b.lightProbeGrid!=J.state.lightProbeGridArray.length>0)&&(E=!0):(E=!0,b.__version=a.version);var M=b.currentProgram;!0===E&&(M=_(a,n,r),ea&&a.isNodeMaterial&&ea.onUpdateProgram(a,M,b));var C=!1,R=!1,A=!1,P=M.getUniforms(),D=b.uniforms;if(ec.useProgram(M.program)&&(C=!0,R=!0,A=!0),a.id!==eY&&(eY=a.id,R=!0),b.needsLights){var L=function(e,n){if(0===e.length)return null;if(1===e.length)return null!==e[0].texture?e[0]:null;K.setFromMatrixPosition(n.matrixWorld);for(var t=0,a=e.length;t<a;t++){var r=e[t];if(null!==r.texture&&r.boundingBox.containsPoint(K))return r}return null}(J.state.lightProbeGridArray,r);b.lightProbeGrid!==L&&(b.lightProbeGrid=L,R=!0)}if(C||eK!==e){ec.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),P.setValue(ns,"projectionMatrix",e.projectionMatrix),P.setValue(ns,"viewMatrix",e.matrixWorldInverse);var U=P.map.cameraPosition;void 0!==U&&U.setValue(ns,na.setFromMatrixPosition(e.matrixWorld)),el.logarithmicDepthBuffer&&P.setValue(ns,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)&&P.setValue(ns,"isOrthographic",!0===e.isOrthographicCamera),eK!==e&&(eK=e,R=!0,A=!0)}if(b.needsLights&&(w.state.directionalShadowMap.length>0&&P.setValue(ns,"directionalShadowMap",w.state.directionalShadowMap,ef),w.state.spotShadowMap.length>0&&P.setValue(ns,"spotShadowMap",w.state.spotShadowMap,ef),w.state.pointShadowMap.length>0&&P.setValue(ns,"pointShadowMap",w.state.pointShadowMap,ef)),r.isSkinnedMesh){P.setOptional(ns,r,"bindMatrix"),P.setOptional(ns,r,"bindMatrixInverse");var N=r.skeleton;N&&(null===N.boneTexture&&N.computeBoneTexture(),P.setValue(ns,"boneTexture",N.boneTexture,ef))}r.isBatchedMesh&&(P.setOptional(ns,r,"batchingTexture"),P.setValue(ns,"batchingTexture",r._matricesTexture,ef),P.setOptional(ns,r,"batchingIdTexture"),P.setValue(ns,"batchingIdTexture",r._indirectTexture,ef),P.setOptional(ns,r,"batchingColorTexture"),null!==r._colorsTexture&&P.setValue(ns,"batchingColorTexture",r._colorsTexture,ef));var I=t.morphAttributes;if((void 0!==I.position||void 0!==I.normal||void 0!==I.color)&&eM.update(r,t,M),(R||b.receiveShadow!==r.receiveShadow)&&(b.receiveShadow=r.receiveShadow,P.setValue(ns,"receiveShadow",r.receiveShadow)),(a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial)&&null===a.envMap&&null!==n.environment&&(D.envMapIntensity.value=n.environmentIntensity),void 0!==D.dfgLUT&&(D.dfgLUT.value=(null===tE&&((tE=new h.nd(tT,16,16,h.Oa,h.Ba)).name="DFG_LUT",tE.minFilter=h.qa,tE.magFilter=h.qa,tE.wrapS=h.la,tE.wrapT=h.la,tE.generateMipmaps=!1,tE.needsUpdate=!0),tE)),R){if(P.setValue(ns,"toneMappingExposure",en.toneMappingExposure),b.needsLights&&(i=A,D.ambientLightColor.needsUpdate=i,D.lightProbe.needsUpdate=i,D.directionalLights.needsUpdate=i,D.directionalLightShadows.needsUpdate=i,D.pointLights.needsUpdate=i,D.pointLightShadows.needsUpdate=i,D.spotLights.needsUpdate=i,D.spotLightShadows.needsUpdate=i,D.rectAreaLights.needsUpdate=i,D.hemisphereLights.needsUpdate=i),o&&!0===a.fog&&e_.refreshFogUniforms(D,o),e_.refreshMaterialUniforms(D,a,e2,e3,J.state.transmissionRenderTarget[e.id]),b.needsLights&&b.lightProbeGrid){var O=b.lightProbeGrid;D.probesSH.value=O.texture,D.probesMin.value.copy(O.boundingBox.min),D.probesMax.value.copy(O.boundingBox.max),D.probesResolution.value.copy(O.resolution)}nz.upload(ns,S(b),D,ef)}if(a.isShaderMaterial&&!0===a.uniformsNeedUpdate&&(nz.upload(ns,S(b),D,ef),a.uniformsNeedUpdate=!1),a.isSpriteMaterial&&P.setValue(ns,"center",r.center),P.setValue(ns,"modelViewMatrix",r.modelViewMatrix),P.setValue(ns,"normalMatrix",r.normalMatrix),P.setValue(ns,"modelMatrix",r.matrixWorld),r.previousModelViewMatrix&&P.setValue(ns,"previousModelViewMatrix",r.previousModelViewMatrix),e.previousProjectionMatrix&&P.setValue(ns,"previousProjectionMatrix",e.previousProjectionMatrix),void 0!==a.uniformsGroups)for(var F=a.uniformsGroups,z=0,k=F.length;z<k;z++){var B=F[z];eH.update(B,M),eH.bind(B,M)}return M}(e,n,t,r,i);ec.setMaterial(r,s);var c=t.index,u=1;if(!0===r.wireframe){if(void 0===(c=ev.getWireframeAttribute(t)))return;u=2}var d=t.drawRange,f=t.attributes.position,p=d.start*u,v=(d.start+d.count)*u;null!==o&&(p=Math.max(p,o.start*u),v=Math.min(v,(o.start+o.count)*u)),null!==c?(p=Math.max(p,0),v=Math.min(v,c.count)):null!=f&&(p=Math.max(p,0),v=Math.min(v,f.count));var m=v-p;if(!(m<0)&&m!==1/0){eI.setup(i,r,l,t,c);var g,x=eC;if(null!==c&&(g=eh.get(c),(x=eR).setIndex(g)),i.isMesh)!0===r.wireframe?(ec.setLineWidth(r.wireframeLinewidth*a()),x.setMode(ns.LINES)):x.setMode(ns.TRIANGLES);else if(i.isLine){var y=r.linewidth;void 0===y&&(y=1),ec.setLineWidth(y*a()),i.isLineSegments?x.setMode(ns.LINES):i.isLineLoop?x.setMode(ns.LINE_LOOP):x.setMode(ns.LINE_STRIP)}else i.isPoints?x.setMode(ns.POINTS):i.isSprite&&x.setMode(ns.TRIANGLES);if(i.isBatchedMesh)if(es.get("WEBGL_multi_draw"))x.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else for(var b=i._multiDrawStarts,w=i._multiDrawCounts,T=i._multiDrawCount,E=c?eh.get(c).bytesPerElement:1,M=ed.get(r).currentProgram.getUniforms(),C=0;C<T;C++)M.setValue(ns,"_gl_DrawID",C),x.render(b[C]/E,w[C]);else if(i.isInstancedMesh)x.renderInstances(p,m,i.count);else if(t.isInstancedBufferGeometry){var R=void 0!==t._maxInstanceCount?t._maxInstanceCount:1/0,A=Math.min(t.instanceCount,R);x.renderInstances(p,m,A)}else x.render(p,m)}},this.compile=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null===t&&(t=e),(J=eS.get(t)).init(n),$.push(J),t.traverseVisible(function(e){e.isLight&&e.layers.test(n.layers)&&(J.pushLight(e),e.castShadow&&J.pushShadow(e))}),e!==t&&e.traverseVisible(function(e){e.isLight&&e.layers.test(n.layers)&&(J.pushLight(e),e.castShadow&&J.pushShadow(e))}),J.setupLights();var a=new Set;return e.traverse(function(e){if(e.isMesh||e.isPoints||e.isLine||e.isSprite){var n=e.material;if(n)if(Array.isArray(n))for(var r=0;r<n.length;r++){var i=n[r];c(i,t,e),a.add(i)}else c(n,t,e),a.add(n)}}),J=$.pop(),a},this.compileAsync=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=this.compile(e,n,t);return new Promise(function(n){function t(){a.forEach(function(e){ed.get(e).currentProgram.isReady()&&a.delete(e)}),0!==a.size?setTimeout(t,10):n(e)}null!==es.get("KHR_parallel_shader_compile")?t():setTimeout(t,10)})};var nd=null,nf=new eb;function np(e,n,t,a){if(!1!==e.visible){if(e.layers.test(n.layers)){if(e.isGroup)t=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(n);else if(e.isLightProbeGrid)J.pushLightProbeGrid(e);else if(e.isLight)J.pushLight(e),e.castShadow&&J.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||e7.intersectsSprite(e)){a&&nr.setFromMatrixPosition(e.matrixWorld).applyMatrix4(nt);var r=em.update(e),i=e.material;i.visible&&Z.push(e,r,i,t,nr.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||e7.intersectsObject(e))){var o=em.update(e),s=e.material;if(a&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),nr.copy(e.boundingSphere.center)):(null===o.boundingSphere&&o.computeBoundingSphere(),nr.copy(o.boundingSphere.center)),nr.applyMatrix4(e.matrixWorld).applyMatrix4(nt)),Array.isArray(s))for(var l=o.groups,c=0,u=l.length;c<u;c++){var d=l[c],f=s[d.materialIndex];f&&f.visible&&Z.push(e,o,f,t,nr.z,d)}else s.visible&&Z.push(e,o,s,t,nr.z,null)}}for(var p=e.children,h=0,v=p.length;h<v;h++)np(p[h],n,t,a)}}nf.setAnimationLoop(function(e){nd&&nd(e)}),("u"<typeof self?"undefined":I(self))<"u"&&nf.setContext(self),this.setAnimationLoop=function(e){nd=e,nc.setAnimationLoop(e),null===e?nf.stop():nf.start()},nc.addEventListener("sessionstart",u),nc.addEventListener("sessionend",d),this.render=function(e,n){if(void 0!==n&&!0!==n.isCamera)return void(0,h.xc)("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0!==et){null!==ea&&ea.renderStart(e,n);var t=!0===nc.enabled&&!0===nc.isPresenting,a=null!==ee&&(null===eq||t)&&ee.begin(en,eq);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),!0===nc.enabled&&!0===nc.isPresenting&&(null===ee||!1===ee.isCompositing())&&(!0===nc.cameraAutoUpdate&&nc.updateCamera(n),n=nc.getCamera()),!0===e.isScene&&e.onBeforeRender(en,e,n,eq),(J=eS.get(e,$.length)).init(n),J.state.textureUnits=ef.getTextureUnits(),$.push(J),nt.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),e7.setFromProjectionMatrix(nt,h.oc,n.reversedDepth),nn=this.localClippingEnabled,ne=ey.init(this.clippingPlanes,nn),(Z=ex.get(e,Q.length)).init(),Q.push(Z),!0===nc.enabled&&!0===nc.isPresenting){var r=en.xr.getDepthSensingMesh();null!==r&&np(r,n,-1/0,en.sortObjects)}np(e,n,0,en.sortObjects),Z.finish(),!0===en.sortObjects&&Z.sort(e4,e5,n.reversedDepth),(no=!1===nc.enabled||!1===nc.isPresenting||!1===nc.hasDepthSensing())&&eE.addToRenderList(Z,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===ne&&ey.beginShadows();var i=J.state.shadowsArray;if(eT.render(i,e,n),!0===ne&&ey.endShadows(),!1===(a&&ee.hasRenderPass())){var o=Z.opaque,s=Z.transmissive;if(J.setupLights(),n.isArrayCamera){var l=n.cameras;if(s.length>0)for(var c=0,u=l.length;c<u;c++)p(o,s,e,l[c]);no&&eE.render(e);for(var d=0,v=l.length;d<v;d++){var m=l[d];f(Z,e,m,m.viewport)}}else s.length>0&&p(o,s,e,n),no&&eE.render(e),f(Z,e,n)}null!==eq&&0===ej&&(ef.updateMultisampleRenderTarget(eq),ef.updateRenderTargetMipmap(eq)),a&&ee.end(en),!0===e.isScene&&e.onAfterRender(en,e,n),eI.resetDefaultState(),eY=-1,eK=null,$.pop(),$.length>0?(J=$[$.length-1],ef.setTextureUnits(J.state.textureUnits),!0===ne&&ey.setGlobalState(en.clippingPlanes,J.state.camera)):J=null,Q.pop(),Z=Q.length>0?Q[Q.length-1]:null,null!==ea&&ea.renderEnd()}},this.getActiveCubeFace=function(){return eX},this.getActiveMipmapLevel=function(){return ej},this.getRenderTarget=function(){return eq},this.setRenderTargetTextures=function(e,n,t){var a=ed.get(e);a.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===a.__autoAllocateDepthBuffer&&(a.__useRenderToTexture=!1),ed.get(e.texture).__webglTexture=n,ed.get(e.depthTexture).__webglTexture=a.__autoAllocateDepthBuffer?void 0:t,a.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,n){var t=ed.get(e);t.__webglFramebuffer=n,t.__useDefaultFramebuffer=void 0===n},this.setRenderTarget=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;eq=e,eX=n,ej=t;var a=null,r=!1,i=!1;if(e){var o=ed.get(e);if(void 0!==o.__useDefaultFramebuffer)return ec.bindFramebuffer(ns.FRAMEBUFFER,o.__webglFramebuffer),eZ.copy(e.viewport),eJ.copy(e.scissor),eQ=e.scissorTest,ec.viewport(eZ),ec.scissor(eJ),ec.setScissorTest(eQ),void(eY=-1);if(void 0===o.__webglFramebuffer)ef.setupRenderTarget(e);else if(o.__hasExternalTextures)ef.rebindTextures(e,ed.get(e.texture).__webglTexture,ed.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){var s=e.depthTexture;if(o.__boundDepthTexture!==s){if(null!==s&&ed.has(s)&&(e.width!==s.image.width||e.height!==s.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");ef.setupDepthRenderbuffer(e)}}var l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(i=!0);var c=ed.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(a=Array.isArray(c[n])?c[n][t]:c[n],r=!0):a=e.samples>0&&!1===ef.useMultisampledRTT(e)?ed.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[t]:c,eZ.copy(e.viewport),eJ.copy(e.scissor),eQ=e.scissorTest}else eZ.copy(e6).multiplyScalar(e2).floor(),eJ.copy(e8).multiplyScalar(e2).floor(),eQ=e9;if(0!==t&&(a=er),ec.bindFramebuffer(ns.FRAMEBUFFER,a)&&ec.drawBuffers(e,a),ec.viewport(eZ),ec.scissor(eJ),ec.setScissorTest(eQ),r){var u=ed.get(e.texture);ns.framebufferTexture2D(ns.FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ns.TEXTURE_CUBE_MAP_POSITIVE_X+n,u.__webglTexture,t)}else if(i)for(var d=0;d<e.textures.length;d++){var f=ed.get(e.textures[d]);ns.framebufferTextureLayer(ns.FRAMEBUFFER,ns.COLOR_ATTACHMENT0+d,f.__webglTexture,t,n)}else if(null!==e&&0!==t){var p=ed.get(e.texture);ns.framebufferTexture2D(ns.FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ns.TEXTURE_2D,p.__webglTexture,t)}eY=-1},this.readRenderTargetPixels=function(e,n,t,a,r,i,o){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0;if(!e||!e.isWebGLRenderTarget)return void(0,h.xc)("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var l=ed.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){ec.bindFramebuffer(ns.FRAMEBUFFER,l);try{var c=e.textures[s],u=c.format,d=c.type;if(e.textures.length>1&&ns.readBuffer(ns.COLOR_ATTACHMENT0+s),!el.textureFormatReadable(u))return void(0,h.xc)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!el.textureTypeReadable(d))return void(0,h.xc)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");n>=0&&n<=e.width-a&&t>=0&&t<=e.height-r&&ns.readPixels(n,t,a,r,eA.convert(u),eA.convert(d),i)}finally{var f=null!==eq?ed.get(eq).__webglFramebuffer:null;ec.bindFramebuffer(ns.FRAMEBUFFER,f)}}},this.readRenderTargetPixelsAsync=function(e,n,t,a,r,i,o){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0;return g(function(){var l,c,u,d,f,p,v;return z(this,function(m){switch(m.label){case 0:if(!e||!e.isWebGLRenderTarget)throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");if(l=ed.get(e).__webglFramebuffer,e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),!l)return[3,3];if(!(n>=0&&n<=e.width-a&&t>=0&&t<=e.height-r))return[3,2];if(ec.bindFramebuffer(ns.FRAMEBUFFER,l),u=(c=e.textures[s]).format,d=c.type,e.textures.length>1&&ns.readBuffer(ns.COLOR_ATTACHMENT0+s),!el.textureFormatReadable(u))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!el.textureTypeReadable(d))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");return f=ns.createBuffer(),ns.bindBuffer(ns.PIXEL_PACK_BUFFER,f),ns.bufferData(ns.PIXEL_PACK_BUFFER,i.byteLength,ns.STREAM_READ),ns.readPixels(n,t,a,r,eA.convert(u),eA.convert(d),0),p=null!==eq?ed.get(eq).__webglFramebuffer:null,ec.bindFramebuffer(ns.FRAMEBUFFER,p),v=ns.fenceSync(ns.SYNC_GPU_COMMANDS_COMPLETE,0),ns.flush(),[4,(0,h.zc)(ns,v,4)];case 1:return[2,(m.sent(),ns.bindBuffer(ns.PIXEL_PACK_BUFFER,f),ns.getBufferSubData(ns.PIXEL_PACK_BUFFER,0,i),ns.deleteBuffer(f),ns.deleteSync(v),i)];case 2:throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");case 3:return[2]}})})()},this.copyFramebufferToTexture=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=Math.pow(2,-t),r=Math.floor(e.image.width*a),i=Math.floor(e.image.height*a),o=null!==n?n.x:0,s=null!==n?n.y:0;ef.setTexture2D(e,0),ns.copyTexSubImage2D(ns.TEXTURE_2D,t,0,0,o,s,r,i),ec.unbindTexture()},this.copyTextureToTexture=function(e,n){var t,a,r,i,o,s,l,c,u,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,v=e.isCompressedTexture?e.mipmaps[h]:e.image;if(null!==d)t=d.max.x-d.min.x,a=d.max.y-d.min.y,r=d.isBox3?d.max.z-d.min.z:1,i=d.min.x,o=d.min.y,s=d.isBox3?d.min.z:0;else{var m=Math.pow(2,-p);t=Math.floor(v.width*m),a=Math.floor(v.height*m),r=e.isDataArrayTexture?v.depth:e.isData3DTexture?Math.floor(v.depth*m):1,i=0,o=0,s=0}null!==f?(l=f.x,c=f.y,u=f.z):(l=0,c=0,u=0);var g,_=eA.convert(n.format),x=eA.convert(n.type);n.isData3DTexture?(ef.setTexture3D(n,0),g=ns.TEXTURE_3D):n.isDataArrayTexture||n.isCompressedArrayTexture?(ef.setTexture2DArray(n,0),g=ns.TEXTURE_2D_ARRAY):(ef.setTexture2D(n,0),g=ns.TEXTURE_2D),ec.activeTexture(ns.TEXTURE0),ec.pixelStorei(ns.UNPACK_FLIP_Y_WEBGL,n.flipY),ec.pixelStorei(ns.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),ec.pixelStorei(ns.UNPACK_ALIGNMENT,n.unpackAlignment);var S=ec.getParameter(ns.UNPACK_ROW_LENGTH),y=ec.getParameter(ns.UNPACK_IMAGE_HEIGHT),b=ec.getParameter(ns.UNPACK_SKIP_PIXELS),w=ec.getParameter(ns.UNPACK_SKIP_ROWS),T=ec.getParameter(ns.UNPACK_SKIP_IMAGES);ec.pixelStorei(ns.UNPACK_ROW_LENGTH,v.width),ec.pixelStorei(ns.UNPACK_IMAGE_HEIGHT,v.height),ec.pixelStorei(ns.UNPACK_SKIP_PIXELS,i),ec.pixelStorei(ns.UNPACK_SKIP_ROWS,o),ec.pixelStorei(ns.UNPACK_SKIP_IMAGES,s);var E=e.isDataArrayTexture||e.isData3DTexture,M=n.isDataArrayTexture||n.isData3DTexture;if(e.isDepthTexture){var C=ed.get(e),R=ed.get(n),A=ed.get(C.__renderTarget),P=ed.get(R.__renderTarget);ec.bindFramebuffer(ns.READ_FRAMEBUFFER,A.__webglFramebuffer),ec.bindFramebuffer(ns.DRAW_FRAMEBUFFER,P.__webglFramebuffer);for(var D=0;D<r;D++)E&&(ns.framebufferTextureLayer(ns.READ_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ed.get(e).__webglTexture,p,s+D),ns.framebufferTextureLayer(ns.DRAW_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ed.get(n).__webglTexture,h,u+D)),ns.blitFramebuffer(i,o,t,a,l,c,t,a,ns.DEPTH_BUFFER_BIT,ns.NEAREST);ec.bindFramebuffer(ns.READ_FRAMEBUFFER,null),ec.bindFramebuffer(ns.DRAW_FRAMEBUFFER,null)}else if(0!==p||e.isRenderTargetTexture||ed.has(e)){var L=ed.get(e),U=ed.get(n);ec.bindFramebuffer(ns.READ_FRAMEBUFFER,ei),ec.bindFramebuffer(ns.DRAW_FRAMEBUFFER,eo);for(var N=0;N<r;N++)E?ns.framebufferTextureLayer(ns.READ_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,L.__webglTexture,p,s+N):ns.framebufferTexture2D(ns.READ_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ns.TEXTURE_2D,L.__webglTexture,p),M?ns.framebufferTextureLayer(ns.DRAW_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,U.__webglTexture,h,u+N):ns.framebufferTexture2D(ns.DRAW_FRAMEBUFFER,ns.COLOR_ATTACHMENT0,ns.TEXTURE_2D,U.__webglTexture,h),0!==p?ns.blitFramebuffer(i,o,t,a,l,c,t,a,ns.COLOR_BUFFER_BIT,ns.NEAREST):M?ns.copyTexSubImage3D(g,h,l,c,u+N,i,o,t,a):ns.copyTexSubImage2D(g,h,l,c,i,o,t,a);ec.bindFramebuffer(ns.READ_FRAMEBUFFER,null),ec.bindFramebuffer(ns.DRAW_FRAMEBUFFER,null)}else M?e.isDataTexture||e.isData3DTexture?ns.texSubImage3D(g,h,l,c,u,t,a,r,_,x,v.data):n.isCompressedArrayTexture?ns.compressedTexSubImage3D(g,h,l,c,u,t,a,r,_,v.data):ns.texSubImage3D(g,h,l,c,u,t,a,r,_,x,v):e.isDataTexture?ns.texSubImage2D(ns.TEXTURE_2D,h,l,c,t,a,_,x,v.data):e.isCompressedTexture?ns.compressedTexSubImage2D(ns.TEXTURE_2D,h,l,c,v.width,v.height,_,v.data):ns.texSubImage2D(ns.TEXTURE_2D,h,l,c,t,a,_,x,v);ec.pixelStorei(ns.UNPACK_ROW_LENGTH,S),ec.pixelStorei(ns.UNPACK_IMAGE_HEIGHT,y),ec.pixelStorei(ns.UNPACK_SKIP_PIXELS,b),ec.pixelStorei(ns.UNPACK_SKIP_ROWS,w),ec.pixelStorei(ns.UNPACK_SKIP_IMAGES,T),0===h&&n.generateMipmaps&&ns.generateMipmap(g),ec.unbindTexture()},this.initRenderTarget=function(e){void 0===ed.get(e).__webglFramebuffer&&ef.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ef.setTextureCube(e,0):e.isData3DTexture?ef.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ef.setTexture2DArray(e,0):ef.setTexture2D(e,0),ec.unbindTexture()},this.resetState=function(){eX=0,ej=0,eq=null,ec.reset(),eI.reset()},("u"<typeof __THREE_DEVTOOLS__?"undefined":I(__THREE_DEVTOOLS__))<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}return b(e,[{key:"coordinateSystem",get:function(){return h.oc}},{key:"outputColorSpace",get:function(){return this._outputColorSpace},set:function(e){this._outputColorSpace=e;var n=this.getContext();n.drawingBufferColorSpace=h.Hc._getDrawingBufferColorSpace(e),n.unpackColorSpace=h.Hc._getUnpackColorSpace()}}]),e}(),tC=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["b"])).nodeType="Bool",t.value=null!=e&&e,t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a){return e.format(this.value?"true":"false",a,n)}}]),n}(H),tR=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1?arguments[1]:void 0;return x(this,n),(e=_(this,n,["f[]"])).nodeType="FloatArray",e.size=t,e.value=Array.isArray(a)?a:"number"==typeof a?Array(t).fill(a):Array(t).fill(0),e}return M(n,e),n}(H),tA=function(e){function n(){return x(this,n),_(this,n,arguments)}return M(n,e),n}(H),tP=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v3"])).image=e,t._value=new h.Fc,t}return M(n,e),b(n,[{key:"value",get:function(){var e,n;return this._value.x=this.image.isVideo?null!=(e=this.image.img.videoWidth)?e:0:this.image.img.width,this._value.y=this.image.isVideo?null!=(n=this.image.img.videoHeight)?n:0:this.image.img.height,this._value}}]),n}(tA),tD=function(e){function n(e,t){var a,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1008,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1006;return x(this,n),(a=_(this,n,["t"])).image=e,a.wrap=t,a.minFilter=r,a.magFilter=i,a}return M(n,e),b(n,[{key:"value",get:function(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}}]),n}(tA),tL=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["m3"])).nodeType="Matrix3",t.value=null!=e?e:new h.Gc,t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("mat3("+this.value.elements.join(", ")+")",a,n)}},{key:"elements",get:function(){return this.value.elements},set:function(e){this.value.fromArray(e)}}]),n}(H),tU=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["m4"])).nodeType="Matrix4",t.value=null!=e?e:new h.Oc,t}return M(n,e),b(n,[{key:"generateReadonly",value:function(e,n,t,a,r,i){return e.format("mat4("+this.value.elements.join(", ")+")",a,n)}},{key:"elements",get:function(){return this.value.elements},set:function(e){this.value.fromArray(e)}}]),n}(H);function tN(e,n,t){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;e.setUvTransform(t[0],t[1],n[0],n[1],0,0,0).premultiply((new h.Gc).makeRotation(a*h.Cc.DEG2RAD))}var tI=function(e){function n(e,t){var a,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return x(this,n),(a=_(this,n,[new h.Gc])).repeat=e,a.offset=t,a.rotation=r,tN(a.value,e,t,r),a}return M(n,e),b(n,[{key:"updateMatrix",value:function(){tN(this.value,this.repeat,this.offset,this.rotation)}}]),n}(tL),tO=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1?arguments[1]:void 0;return x(this,n),(e=_(this,n,["v4[]"])).nodeType="Vector4Array",e.size=t,e.value=Array.isArray(a)?a:C(a,h.Jc)?Array(t).fill(a):Array(t).fill(new h.Jc(0)),e}return M(n,e),n}(H),tF=function(e){function n(e,t,a,r){var i;return x(this,n),(i=_(this,n,["v3"])).nodeType="Blend",i.a=e,i.b=t,i.alpha=a,i.mode=r,i}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){var t=[];return t.push(this.a.build(e,"c")),t.push(this.b.build(e,"c")),t.push(this.alpha.build(e,"f")),t.push(this.mode.build(e,"i")),e.format("spe_blend("+t.join(",")+")",this.getType(e),n)}return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G),tz=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n,["v3"])).nodeType="CustomColor",a.color=e,a.alpha=t,a.calpha="g".concat(a.uuid.toString().replace(/-/g,""),"_calpha"),a}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){var t=e.include(tz.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");var a=[];return a.push(this.color.build(e,"v3")),a.push(this.mask?"luminance(".concat(this.mask.build(e,"v3"),")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tz.Nodes={customColor:new Z("vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {\n float lalpha = alpha * mask;\n calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n accumAlpha += (1.0 - accumAlpha) * lalpha;\n\n return color;\n }")};var tk=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n,["v3"])).nodeType="CustomNormal",a.cnormal=e,a.alpha=t,a.calpha="g".concat(a.uuid.toString().replace(/-/g,""),"_calpha"),a}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){var t=e.include(tk.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");var a=[];return a.push(this.cnormal.build(e,"v3")),a.push("normal"),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tk.Nodes={customNormal:new Z("vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {\n vec3 normal = packNormalToRGB( norm ).rgb;\n normal *= step( vec3(0.5), cnormal );\n\n float lalpha = alpha * mask;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\n return normal;\n }")};var tB=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],tV=function(e){function n(e,t,a,r,i,o,s,l,c,u,d,f){var p,h=arguments.length>12&&void 0!==arguments[12]?arguments[12]:-1;return x(this,n),(p=_(this,n,["v3"])).nodeType="CustomTexture",p.texture=e,p.textureSize=t,p.crop=a,p.projection=r,p.axis=i,p.projectionAxis=h,p.side=o,p.size=s,p.blending=l,p.mat=c,p.isMask=f,p.alpha=u,p.mode=d,p.calpha="g".concat(p.uuid.toString().replace(/-/g,""),"_calpha"),p}return M(n,e),b(n,[{key:"generate",value:function(e,n){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;var t,a="g".concat(this.uuid.toString().replace(/-/g,""));switch(this.projection.value){case 3:var r=this.projectionAxis;if(0===r||2===r){var i=tB[r],o=i.a,s=i.b,l=i.pole;t=e.include(new Z("\nvec3 ".concat(a,"_cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.").concat(o,", posN.").concat(s,") / (2.*3.1415);\n float scaledHeight = position.").concat(l," / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n #ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n #else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n #endif\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n\n lalpha *= mask;\n\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }\n")))}else t=e.include(tV.Nodes.cylindrical);break;case 2:var c=this.projectionAxis;if(0===c||2===c){var u=tB[c],d=u.a,f=u.b,p=u.pole;t=e.include(new Z("\nvec3 ".concat(a,"_sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.").concat(d,", posN.").concat(f,") / (2.*3.1415);\n float v = 0.5 + asin(posN.").concat(p,") / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n #ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n #else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n #endif\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n\n lalpha *= mask;\n\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }\n")))}else t=e.include(tV.Nodes.spherical);break;case 1:var h=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],v=["zy","xz","xy"][this.axis.value],m=new Z("\n vec3 ".concat(a,"_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec2 projected = (1. + (position.").concat(v,")) / 2.;\n vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n vec4 tmp = texture2D( tex, uvs );\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n ").concat(2===this.side.value?"":"lalpha *= step(0.0, ".concat(1===this.side.value?"-1.0 * ":"","dot(vObjectNormal, ").concat(h,"));"),"\n\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n \n lalpha *= mask;\n\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }"));t=e.include(m);break;case 4:t=e.include(tV.Nodes.triplanar);break;case 0:var g=new Z(tV.Nodes.uv.src.replace("uvTexture","".concat(a,"_uvTexture")));t=e.include(g);break;default:t=e.include(tV.Nodes.uv)}e.addFragmentVariable(this.calpha,"float");var _=[];if(_.push("normal"),_.push(this.texture.generate(e,"t")),_.push(this.textureSize.build(e,"v2")),_.push(this.crop.build(e,"f")),_.push(this.mat.build(e,"mat3")),_.push(this.size.build(e,"v2")),_.push(this.blending.build(e,"f")),_.push(this.isMask.build(e,"b")),_.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),_.push(this.alpha.build(e,"f")),_.push(this.mode.build(e,"i")),_.push(this.calpha),4===this.projection.value){var x="".concat(a,"_writeUvs"),S=x+"0",y=x+"1",b=x+"2",w="".concat(a,"_triplanarWeights");e.addFragmentVariable(S,"vec2"),e.addFragmentVariable(y,"vec2"),e.addFragmentVariable(b,"vec2"),e.addFragmentVariable(w,"vec3"),_.push(S),_.push(y),_.push(b),_.push(w)}else{var T="".concat(a,"_writeUvs");e.addFragmentVariable(T,"vec2"),_.push(T)}return e.format(t+"("+_.join(",")+")",this.getType(e),n)}}]),n}(G);tV.Nodes={cylindrical:new Z("\nvec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float scaledHeight = position.y / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n #ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n #else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n #endif\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n\n lalpha *= mask;\n \n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }\n"),spherical:new Z("\nvec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float v = 0.5 + asin(posN.y) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n #ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n #else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n #endif\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n\n lalpha *= mask;\n\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }\n"),uv:new Z("vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n writeUv = uvs;\n\n vec4 tmp = texture2D( tex, uvs );\n\n vec3 col = tmp.rgb;\n\n float lalpha = alpha * tmp.a;\n if ( crop > 0.5 ) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n \n lalpha *= mask;\n\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;\n }"),triplanar:new Z("vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {\n vec3 p = position;\n vec2 uv0 = (1.0 + p.xy) / 2.0; \n vec2 uv1 = (1.0 + p.zy) / 2.0; \n vec2 uv2 = (1.0 + p.xz) / 2.0; \n \n uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\n // Range from 3 to 128 seems to be good\n float exponent = (1.0 - blending) * 125.0 + 3.0;\n\n vec3 n = vObjectNormal;\n vec3 weights = abs(normalize(n));\n weights = pow(weights, vec3(exponent));\n weights /= dot(weights, vec3(1.0));\n\n // Write out all sets of UVs that we generated\n writeUvs0 = uv0;\n writeUvs1 = uv1;\n writeUvs2 = uv2;\n writeWeights = weights;\n\n // Plain filtered samples: triplanar UVs are continuous (no wrap\n // seam), so implicit derivatives are already correct — the\n // forced-LOD sample this replaces bypassed the layer's Sharpness\n // filters and over-blurred by up to a mip (fwidth overestimates\n // the footprint; see the spherical/cylindrical variants).\n vec4 tmp = \n texture2D(tex, uv0) * weights.z + \n texture2D(tex, uv1) * weights.x + \n texture2D(tex, uv2) * weights.y;\n\n vec3 col = tmp.rgb;\n float lalpha = alpha * tmp.a;\n\n // Apply cropping across all 3 planes\n if ( crop > 0.5 ) {\n if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {\n lalpha = 0.0;\n }\n if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {\n lalpha = 0.0;\n }\n if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {\n lalpha = 0.0;\n }\n }\n\n lalpha *= mask;\n calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return col;//n * 0.5 + 0.5;\n } \n ")};var tG=function(e){function n(e,t,a,r,i,o,s,l,c,u,d,f){var p;return x(this,n),(p=_(this,n,["v3"])).nodeType="Depth",p.gradientType=e,p.smooth=t,p.near=a,p.far=r,p.isVector=i,p.isWorldSpace=o,p.origin=s,p.direction=l,p.colors=c,p.steps=u,p.isMask=f,p.alpha=d,p.calpha="g".concat(p.uuid.toString().replace(/-/g,""),"_calpha"),p}return M(n,e),b(n,[{key:"generate",value:function(e,n){var t="g".concat(this.uuid.toString().replace(/-/g,"")),a=new Z("vec3 ".concat(t,"_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[").concat(t,"_MAX_COLORS], float steps[").concat(t,"_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {\n vec4 color = colors[0];\n #ifdef ").concat(t,"_IS_VECTOR\n #ifdef ").concat(t,"_LINEAR\n #ifdef ").concat(t,"_WORLDSPACE\n float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);\n #else\n float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);\n #endif\n #else\n #ifdef ").concat(t,"_WORLDSPACE\n float depth = vectorSphericalWorldSpaceDepth(origin, near, far);\n #else\n float depth = vectorSphericalObjectSpaceDepth(origin, near, far);\n #endif\n #endif\n #else\n float dist = length(vWPosition - cameraPosition);\n float depth = ( dist - near ) / ( far - near );\n #endif\n\n\n float p;\n #ifdef ").concat(t,"_SMOOTH\n for ( int i = 1; i < ").concat(t,"_MAX_COLORS; i++ ) {\n p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n color = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n }\n #else\n for ( int i = 1; i < ").concat(t,"_MAX_COLORS; i++ ) {\n p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);\n color = mix(color, colors[i], p);\n }\n #endif\n\n float lalpha = alpha * color.a * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n \n return color.rgb;\n }"),[tG.Nodes.vectorLinearWorldSpaceDepth,tG.Nodes.vectorLinearObjectSpaceDepth,tG.Nodes.vectorSphericalObjectSpaceDepth,tG.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define("".concat(t,"_MAX_COLORS"),this.colors.value.length),this.smooth.value&&e.define("".concat(t,"_SMOOTH")),this.isVector.value>.5&&e.define("".concat(t,"_IS_VECTOR")),0===this.gradientType.value&&e.define("".concat(t,"_LINEAR")),this.isWorldSpace.value>.5&&e.define("".concat(t,"_WORLDSPACE")),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");var r=e.include(a),i=[];return i.push(this.near.build(e,"f")),i.push(this.far.build(e,"f")),i.push(this.origin.build(e,"v3")),i.push(this.direction.build(e,"v3")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.isMask.build(e,"b")),i.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(r+"("+i.join(",")+")",this.getType(e),n)}return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tG.Nodes={vectorLinearWorldSpaceDepth:new Z("float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorLinearObjectSpaceDepth:new Z("float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalWorldSpaceDepth:new Z("float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(vWPosition - origin);\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalObjectSpaceDepth:new Z("float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(position - origin);\n return ( dist - near ) / ( far - near );\n }")};var tH=function(e){function n(e,t,a,r,i,o,s){var l;return x(this,n),(l=_(this,n,["v3"])).nodeType="Cavity",l.firstTime=!0,l.ridge=e,l.valley=t,l.normalViewMap=a,l.resolution=r,l.isMask=s,l.alpha=i,l.mode=o,l.calpha="g".concat(l.uuid.toString().replace(/-/g,""),"_calpha"),l}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(this.firstTime&&(e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode("\n vID = randomColor.r;\n ")),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");var t=e.include(tH.Nodes.cavity),a=[];return a.push(this.normalViewMap.getTexture(e,"t")),a.push(this.resolution.build(e,"v2")),a.push(this.ridge.build(e,"f")),a.push(this.valley.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("CavityNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);aa=new Z("float cavitySoftClamp(float c, float control) {\n if (c < 0.5 / control) return c * (1.0 - c * control);\n return 0.25 / control;\n }"),tH.Nodes={cavity:new Z("vec3 cavity(sampler2D normalViewMap, vec2 resolution, float ridge, float valley, bool isMask, float mask, float alpha, int mode, out float calpha) {\n // The factors saturate the soft clamp by 2 — beyond that the\n // response is visually identical, so 2 is the ceiling\n // everywhere (panel, DSL, variables, old files).\n ridge = clamp(ridge, 0.0, 2.0);\n valley = clamp(valley, 0.0, 2.0);\n\n vec2 nuv = gl_FragCoord.xy / resolution;\n vec2 texel = vec2(1.0) / resolution;\n\n vec4 nUp = texture2D(normalViewMap, nuv + vec2(0.0, texel.y));\n vec4 nDown = texture2D(normalViewMap, nuv - vec2(0.0, texel.y));\n vec4 nLeft = texture2D(normalViewMap, nuv - vec2(texel.x, 0.0));\n vec4 nRight = texture2D(normalViewMap, nuv + vec2(texel.x, 0.0));\n\n float curv = 0.0;\n if (nUp.a == vID && nDown.a == vID && nLeft.a == vID && nRight.a == vID &&\n dot(nUp.xyz, nUp.xyz) > 0.5 && dot(nDown.xyz, nDown.xyz) > 0.5 &&\n dot(nLeft.xyz, nLeft.xyz) > 0.5 && dot(nRight.xyz, nRight.xyz) > 0.5) {\n float ndiff = (nUp.y - nDown.y) + (nRight.x - nLeft.x);\n // Blender's control mapping (workbench_data.c): a bigger\n // factor lowers the control, which raises both the linear\n // range and the clamp ceiling of the soft clamp — the\n // factors get a real O(1) signal to scale.\n float ridgeControl = 0.5 / max(ridge * ridge, 0.0001);\n float valleyControl = 0.7 / max(valley * valley, 0.0001);\n curv = ndiff > 0.0\n ? 2.0 * cavitySoftClamp(ndiff, ridgeControl)\n : -2.0 * cavitySoftClamp(-ndiff, valleyControl);\n // Dead-zone: sub-visible curvature (buffer quantization\n // noise, near-zero factors) is no curvature.\n if (abs(curv) < 0.001) curv = 0.0;\n }\n\n // Where there is no curvature the layer says NOTHING: composite\n // with weight 0 (the outline layer's pattern) so flat pixels are\n // a bit-exact passthrough. Compositing the identity mid-grey at\n // full alpha instead perturbs the frame by float ulps\n // (1-2(1-b)(1-o) != b exactly), which downstream edge-AA\n // amplified into visible silhouette speckles. Mask mode keeps\n // the full-coverage grey — the mask IS the color output.\n // (\"active\" is a GLSL ES reserved word — hence cavityOn.)\n float cavityOn = curv != 0.0 ? 1.0 : 0.0;\n float lalpha = alpha * mask * mix(cavityOn, 1.0, float(isMask));\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return vec3(clamp(0.5 + 0.5 * curv, 0.0, 1.0));\n }",[aa])};var tW=(ar=new Z("vec3 random3(vec3 c) {\n float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n vec3 r;\n r.z = fract(512.0*j);\n j *= .125;\n r.x = fract(512.0*j);\n j *= .125;\n r.y = fract(512.0*j);\n return r-0.5;\n }"),(ai=new Z("float simplexFast(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n mediump vec3 x = p - s + dot(s, vec3(G3));\n mediump vec3 hs = s;\n \n mediump vec3 e = step(vec3(0.0), x - x.yzx);\n mediump vec3 i1 = e*(1.0 - e.zxy);\n mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n \n mediump vec3 x1 = x - i1 + G3;\n mediump vec3 x2 = x - i2 + 2.0*G3;\n mediump vec3 x3 = x - 1.0 + 3.0*G3;\n \n mediump vec4 w, d;\n \n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n \n w = max(0.6 - w, 0.0);\n \n d.x = dot(random3(hs), x);\n d.y = dot(random3(hs + i1), x1);\n d.z = dot(random3(hs + i2), x2);\n d.w = dot(random3(hs + 1.0), x3);\n \n w *= w;\n w *= w;\n d *= w;\n \n return dot(d, vec4(52.0));\n }",[ar])).keywords.F3=new Q("float F3 0.3333333"),ai.keywords.G3=new Q("float G3 0.1666667"),(ao=new Z("float simplexPrecise(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n vec3 x = p - s + dot(s, vec3(G3));\n \n vec3 e = step(vec3(0.0), x - x.yzx);\n vec3 i1 = e*(1.0 - e.zxy);\n vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n \n vec3 x1 = x - i1 + G3;\n vec3 x2 = x - i2 + 2.0*G3;\n vec3 x3 = x - 1.0 + 3.0*G3;\n \n vec4 w, d;\n \n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n \n w = max(0.6 - w, 0.0);\n \n d.x = dot(random3(s), x);\n d.y = dot(random3(s + i1), x1);\n d.z = dot(random3(s + i2), x2);\n d.w = dot(random3(s + 1.0), x3);\n \n w *= w;\n w *= w;\n d *= w;\n \n return dot(d, vec4(52.0));\n }",[ar])).keywords.F3=new Q("float F3 0.3333333"),ao.keywords.G3=new Q("float G3 0.1666667"),as=new Z("float simplexFractal(vec3 m) {\n mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);\n mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);\n mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);\n return 0.5333333 * simplexFast(m * rot1)\n + 0.2666667 * simplexFast(2.0 * m * rot2)\n + 0.1333333 * simplexFast(4.0 * m * rot3)\n + 0.0666667 * simplexFast(8.0 * m);\n }",[ai]),al=new Z("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),ac=new Z("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),au=new Z("float simplexAshima(vec3 v) {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n vec3 x3 = x0 - 1. + 3.0 * C.xxx;\n i = mod(i, 289.0 ); \n vec4 p = permute( permute( permute( \n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) \n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n float n_ = 1.0/7.0; \n vec3 ns = n_ * D.wyz - D.xzx;\n vec4 j = p - 49.0 * floor(p * ns.z *ns.z); \n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); \n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), \n dot(p2,x2), dot(p3,x3) ) );\n }",[al,ac]),ad=new Z("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),af=new Z("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[ad]),ap=new Z("float noise(vec3 p){\n vec3 a = floor(p);\n vec3 d = p - a;\n d = d * d * (3.0 - 2.0 * d);\n vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);\n vec4 k1 = perm(b.xyxy);\n vec4 k2 = perm(k1.xyxy + b.zzww);\n vec4 c = k2 + a.zzzz;\n vec4 k3 = perm(c);\n vec4 k4 = perm(c + 1.0);\n vec4 o1 = fract(k3 * (1.0 / 41.0));\n vec4 o2 = fract(k4 * (1.0 / 41.0));\n vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);\n vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);\n return o4.y * d.y + o4.x * (1.0 - d.y);\n }",[af]),(ah=new Z("float fbm(vec3 x) {\n float v = 0.0;\n float a = 0.5;\n vec3 shift = vec3(100);\n for (int i = 0; i < NUM_OCTAVES; ++i) {\n v += a * noise(x);\n x = x * 2.0 + shift;\n a *= 0.5;\n }\n return v;\n }",[ap])).keywords.NUM_OCTAVES=new Q("int NUM_OCTAVES 5"),av=new Z("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),am=new Z("float perlin(vec3 P){\n vec3 Pi0 = floor(P);\n vec3 Pi1 = Pi0 + vec3(1.0);\n Pi0 = mod(Pi0, 289.0);\n Pi1 = mod(Pi1, 289.0);\n vec3 Pf0 = fract(P);\n vec3 Pf1 = Pf0 - vec3(1.0);\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 gx0 = ixy0 / 7.0;\n vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n vec4 gx1 = ixy1 / 7.0;\n vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n return 2.2 * n_xyz;\n }",[al,ac,av]),ag=new Z("float hashwithoutsine13(vec3 p3)\n {\n p3 = fract(p3 * .1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n }"),a_=new Z("vec3 hashwithoutsine33(vec3 p3)\n {\n p3 = fract(p3 * vec3(.1031, .1030, .0973));\n p3 += dot(p3, p3.yxz+33.33);\n return fract((p3.xxy + p3.yxx)*p3.zyx);\n }"),ax=new Z("float metric(in vec3 p)\n {\n \n return length(p);\n\n \n \n \n }"),aS=new Z("float smin( float a, float b, float k )\n {\n float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);\n float correction = k * h * (1.0 - h);\n return mix(b, a, h) - correction;\n }"),ay=new Z("float smax( float a, float b, float k )\n {\n float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);\n float correction = k * h * (1.0 - h);\n return mix(a, b, h) + correction;\n }"),ab=new Z("float remap(float value, float input_min, float input_max, float output_min, float output_max) {\n // Compute width of each interval\n float input_width = input_max - input_min;\n float output_width = output_max - output_min;\n \n // Convert input range into a 0-1 range \n float scaled = (value - input_min) / input_width;\n \n // Convert the 0-1 range into a value in output range\n return output_min + (scaled * output_width);\n }"),{simplexFast:ai,simplexPrecise:ao,simplexFractal:as,simplexAshima:au,fbm:ah,perlin:am,voronoi:new Z("float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) \n {\n \n ivec3 p = ivec3(floor(x));\n vec3 f = fract(x);\n\n \n \n \n \n \n \n \n \n float f1_smooth = 8.0;\n float f1 = 8.0;\n float f2_smooth = 8.0;\n float f2 = 8.0;\n float e_smooth = 8.0;\n float e = 8.0;\n\n \n ivec3 mb;\n vec3 mr; \n\n int steps = quality;\n \n for (int x = -steps; x <= steps; x++) \n for (int y = -steps; y <= steps; y++)\n for (int z = -steps; z <= steps; z++)\n {\n ivec3 b = ivec3(x, y, z);\n vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n float d = length(r);\n \n f1_smooth = smin(d, f1_smooth, smoothness);\n\n \n if (d < f1) \n {\n f2 = f1;\n f1 = d;\n\n mb = ivec3(x, y, z);\n mr = r;\n } \n else if (d < f2) \n {\n f2 = d;\n }\n } \n \n \n \n if (style != 0 && style != 5 && style != 7)\n for (int x = -steps; x <= steps; x++) \n for (int y = -steps; y <= steps; y++)\n for (int z = -steps; z <= steps; z++)\n {\n \n ivec3 b = mb + ivec3(x, y, z);\n vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n float d1 = dot(0.5 * (mr + r), (r - mr)); \n float d2 = dot(0.5 * (mr + r), normalize(r - mr));\n\n e_smooth = smin(d1, e_smooth, smoothness);\n\n e = min(e, d2);\n\n \n {\n ivec3 b = ivec3(x, y, z);\n if (b != mb) \n {\n vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n float d = length(r);\n\n f2_smooth = smin(d, f2_smooth, smoothness);\n }\n }\n }\n\n \n if (style == 0) \n {\n return f1_smooth;\n }\n if (style == 1) \n {\n return f2_smooth;\n }\n if (style == 2) \n {\n return f2_smooth - f1_smooth;\n \n \n \n }\n if (style == 3) \n {\n \n float a = f1; \n float b = f2;\n float k = 3.0;\n float h = max(k - abs(a - b), 0.0) / k;\n float final = min(a, b) - h * h * k * (1.0 / 4.0);\n return final;\n }\n if (style == 4) \n {\n \n return exp(5.0 * e_smooth);\n }\n if (style == 5) \n {\n return pow(f1_smooth, 3.0);\n }\n if (style == 6) \n { \n const float eps = 0.0125;\n\n \n float thickness = smoothness * 0.25 + eps;\n\n \n float blur = pow(smoothness, 3.0) * 0.25 + eps;\n\n return smoothstep(\n thickness - thickness * blur, \n thickness + thickness * blur, \n e\n );\n }\n if (style == 7) \n {\n return hashwithoutsine13(vec3(p + mb) + seed);\n }\n }\n ",[ag,a_,ax,aS,ay,ab])}),tX=function(e){function n(e,t,a,r,i,o,s){var l;return x(this,n),(l=_(this,n,["v3"])).nodeType="Dust",l.color=e,l.coverage=t,l.softness=a,l.noiseStrength=r,l.noiseScale=i,l.isMask=s,l.alpha=o,l.calpha="g".concat(l.uuid.toString().replace(/-/g,""),"_calpha"),l}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");var t=e.include(tX.Nodes.dust),a=[];return a.push(this.color.build(e,"c")),a.push(this.coverage.build(e,"f")),a.push(this.softness.build(e,"f")),a.push(this.noiseStrength.build(e,"f")),a.push(this.noiseScale.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("DustNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tX.Nodes={dust:new Z("vec3 dust(vec3 color, float coverage, float softness, float noiseStrength, float noiseScale, bool isMask, float mask, float alpha, out float calpha) {\n float facingUp = dot(normalize(vWNormal), vec3(0.0, 1.0, 0.0));\n\n float breakup = 0.0;\n if (noiseStrength != 0.0) {\n vec3 st = position / noiseScale;\n float noise = simplexFast(st + vec3(1.7, 9.2, 1.0));\n breakup = noise * noiseStrength;\n }\n\n float soft = max(softness, 0.0001);\n float settle = mix(1.0 + soft, -1.0 - soft, clamp(coverage, 0.0, 1.0));\n float amount = smoothstep(settle - soft, settle + soft, facingUp + breakup);\n\n float lalpha = amount * alpha * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return color;\n }",[tW.simplexFast])};var tj=function(e){function n(e,t,a,r,i,o,s,l){var c;return x(this,n),(c=_(this,n,["v3"])).nodeType="Fresnel",c.color=e,c.bias=t,c.scale=a,c.intensity=r,c.factor=i,c.isMask=l,c.alpha=o,c.mode=s,c.calpha="g".concat(c.uuid.toString().replace(/-/g,""),"_calpha"),c}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");var t=new Z("vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {\n float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );\n\n float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return color;\n }"),a=e.include(t),r=[];return r.push(this.color.build(e,"c")),r.push(this.bias.build(e,"f")),r.push(this.scale.build(e,"f")),r.push(this.intensity.build(e,"f")),r.push(this.factor.build(e,"f")),r.push(this.isMask.build(e,"b")),r.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),r.push(this.calpha),e.format(a+"("+r.join(",")+")",this.getType(e),n)}return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G),tq=function(e){function n(e,t,a,r,i,o,s,l,c){var u;return x(this,n),(u=_(this,n,["v3"])).nodeType="Gradient",u.gradientType=e,u.smooth=t,u.colors=a,u.steps=r,u.offset=i,u.morph=o,u.angle=s,u.isMask=c,u.alpha=l,u.calpha="g".concat(u.uuid.toString().replace(/-/g,""),"_calpha"),u}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");var t=e.include(tq.Nodes.gradient),a=[];return a.push(this.gradientType.build(e,"i")),a.push(this.smooth.build(e,"b")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.offset.build(e,"v2")),a.push(this.morph.build(e,"v2")),a.push(this.angle.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tq.Nodes={gradient:new Z("vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {\n vec4 color = colors[0];\n vec2 m = morph / vUv.xy;\n vec2 rot = vec2( 0.5 + m.x, m.y );\n vec2 dt = vec2(\n cos( angle ) * rot.x - sin( angle ) * rot.y,\n sin( angle ) * rot.x + cos( angle ) * rot.y\n );\n vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;\n float t = dot( pt, dt ) / dot( dt, dt );\n if ( gradientType == 1 ) {\n t = distance (\n ( vUv + morph ) * 3.0,\n ( vUv + offset ) + 1.0\n ) + angle;\n } else if ( gradientType == 2 ) {\n float polar = atan(\n vUv.x + morph.x - 0.5 + offset.x,\n vUv.y + morph.y - 0.5 + offset.y\n ) * -1.0;\n t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );\n }\n\n float p;\n if (smoothed) {\n for ( int i = 1; i < GRAD_MAX; i++ ) {\n p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n color = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n }\n\n } else {\n for ( int i = 1; i < GRAD_MAX; i++ ) {\n p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n color = mix(color, colors[i], p);\n }\n }\n\n float lalpha = alpha * color.a * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n \n return color.xyz;\n }")};var tY=function(e){function n(e,t,a,r,i){var o;return x(this,n),(o=_(this,n,["v3"])).nodeType="Matcap",o.texture=e,o.isMask=r,o.alpha=t,o.mode=a,o.calpha="g".concat(o.uuid.toString().replace(/-/g,""),"_calpha"),o.rotation=i,o}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");var t=e.include(tY.Nodes.matcap);e.require("normal"),e.requires.normal=!0;var a=[];return a.push(this.texture.generate(e,"t")),a.push("normal"),a.push(this.isMask.build(e,"b")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),a.push(this.rotation.build(e,"f")),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);tY.Nodes={matcap:new Z("vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) );\n uv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;\n uv = uv * 0.495 + 0.5;\n vec4 matcapColor = texture2D( matcapTex, uv );\n\n float lalpha = alpha * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n \n return matcapColor.rgb;\n }")};var tK=function(e){function n(e,t,a,r,i,o,s,l,c,u,d,f,p,h,v,m,g,S,y){var b;return x(this,n),(b=_(this,n,["v3"])).nodeType="Noise",b.scale=e,b.size=t,b.move=a,b.fA=r,b.fB=i,b.distortion=o,b.colorA=s,b.colorB=l,b.colorC=c,b.colorD=u,b.noiseType=f,b.voronoiStyle=h,b.highCut=v,b.lowCut=m,b.smoothness=g,b.seed=S,b.quality=y,b.isMask=p,b.alpha=d,b.calpha="g".concat(b.uuid.toString().replace(/-/g,""),"_calpha"),b}return M(n,e),b(n,[{key:"generate",value:function(e,n,t,a,r){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");var i=["simplexFast","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseType.value],o=new Z("vec3 ".concat(i,"customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) \n {\n \n scale = max(abs(scale), 0.001);\n\n vec3 st = position / size;\n st /= scale;\n\n ").concat("voronoi"==i?"\n float v = ".concat(i,"(st + move, voronoiStyle, smoothness, seed, quality);\n\n \n v = remap(v, lowCut, highCut, 0.0, 1.0);\n v = smax(v, 0.0, smoothness * 0.25);\n v = smin(v, 1.0, smoothness * 0.25);\n\n \n vec4 color = mix(colorA, colorC, v); \n "):"\n vec3 q = vec3(".concat(i,"(st),\n ").concat(i,"(st + vec3(1.0)),\n ").concat(i,"(st + vec3(1.0)));\n vec3 r = vec3(").concat(i,"(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),\n ").concat(i,"(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), \n ").concat(i,"(st * q));\n float f = ").concat(i,"(st + r);\n vec4 color;\n color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));\n color = mix(color, colorC, clamp(length(q), 0.0, 1.0));\n color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));\n "),"\n\n float lalpha = alpha * color.a * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return clamp(color, 0.0, 1.0).rgb;\n }"),[tW.simplexFast,tW.simplexFractal,tW.simplexAshima,tW.fbm,tW.perlin,tW.voronoi]),s=e.include(o),l=[];return l.push(this.scale.build(e,"f")),l.push(this.size.build(e,"v3")),l.push(this.move.build(e,"f")),l.push(this.fA.build(e,"v2")),l.push(this.fB.build(e,"v2")),l.push(this.distortion.build(e,"v2")),l.push(this.colorA.build(e,"v4")),l.push(this.colorB.build(e,"v4")),l.push(this.colorC.build(e,"v4")),l.push(this.colorD.build(e,"v4")),l.push(this.voronoiStyle.build(e,"i")),l.push(this.highCut.build(e,"f")),l.push(this.lowCut.build(e,"f")),l.push(this.smoothness.build(e,"f")),l.push(this.seed.build(e,"f")),l.push(this.quality.build(e,"i")),l.push(this.isMask.build(e,"b")),l.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),n)}}]),n}(G);tK.numOctaves=5;var tZ=function(e){function n(e,t,a,r,i,o,s,l,c,u,d,f,p,h,v,m){var g;return x(this,n),(g=_(this,n,["v3"])).nodeType="Outline",g.firstTime=!0,g.outlineColor=e,g.contourColor=t,g.outlineWidth=a,g.contourWidth=r,g.contourThreshold=i,g.outlineThreshold=o,g.contourFrequency=s,g.outlineSmoothing=l,g.contourDirection=c,g.positionalLines=u,g.compensation=d,g.resolution=f,g.normalMap=p,g.depthMap=h,g.pixelRatio=v,g.alpha=m,g.calpha="g".concat(g.uuid.toString().replace(/-/g,""),"_calpha"),g}return M(n,e),b(n,[{key:"generate",value:function(e,n){var t="g".concat(this.uuid.toString().replace(/-/g,""));if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION","".concat(t,"_offset")),this.firstTime){var a=this.outlineWidth.build(e,"f"),r=this.resolution.build(e,"v2"),i=this.compensation.build(e,"b"),o=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(a,"uniform float"),e.addVertexParsVariable(r,"uniform vec2"),e.addVertexParsVariable(i,"uniform bool"),e.addVertexParsVariable(o,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode("\n vID = randomColor.r;\n vec2 ".concat(t,"_offset = vec2(0.0);\n if (").concat(i,") {\n // Instanced draws (cloner instancing): 'transformed' is still\n // instance-local here — three's chunks only apply instanceMatrix\n // inside project_vertex — so apply it by hand like they do.\n vec4 ").concat(t,"_localPosition = vec4(transformed, 1.0);\n vec3 ").concat(t,"_extrudeNormal = extrudeNormal;\n #ifdef USE_INSTANCING\n ").concat(t,"_localPosition = instanceMatrix * ").concat(t,"_localPosition;\n ").concat(t,"_extrudeNormal = mat3(instanceMatrix) * ").concat(t,"_extrudeNormal;\n #endif\n vec4 ").concat(t,"_clipPosition = projectionMatrix * (modelViewMatrix * ").concat(t,"_localPosition);\n \n \n \n vec3 ").concat(t,"_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * ").concat(t,"_extrudeNormal) + 0.0000001;\n ").concat(t,"_offset = normalize(").concat(t,"_clipNormal.xy) / ").concat(r," * (").concat(a," / 2.0) * ").concat(t,"_clipPosition.w * 2.0 * ").concat(o,";\n ").concat(t,"_clipPosition.xy += ").concat(t,"_offset;\n \n \n gl_Position = ").concat(t,"_clipPosition;\n }\n "))}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");var s=e.include(tZ.Nodes.outline),l=[];return l.push(this.outlineColor.build(e,"c")),l.push(this.contourColor.build(e,"c")),l.push(this.outlineWidth.build(e,"f")),l.push(this.contourWidth.build(e,"f")),l.push(this.contourThreshold.build(e,"f")),l.push(this.outlineThreshold.build(e,"f")),l.push(this.contourFrequency.build(e,"f")),l.push(this.outlineSmoothing.build(e,"f")),l.push(this.contourDirection.build(e,"v3")),l.push(this.positionalLines.build(e,"b")),l.push(this.resolution.build(e,"v2")),l.push(this.normalMap.getTexture(e,"t")),l.push(this.depthMap.getTexture(e,"t")),l.push(this.pixelRatio.build(e,"f")),l.push(this.compensation.build(e,"b")),l.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),this.firstTime=!this.firstTime,e.format(s+"("+l.join(",")+")",this.getType(e),n)}return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}}]),n}(G);aw=new Z("\nfloat sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)\n{\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n vec2 texelSize = (vec2(1.0) / resolution);\n vec2 offsetSize = texelSize * outlineWidth * pixelRatio;\n\n vec2 uvSamples[9];\n vec4 normalSamples[9];\n\n uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);\n uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);\n uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);\n uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);\n uvSamples[4] = uv;\n uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);\n uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);\n uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);\n uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);\n\n\n normalSamples[0] = texture2D(t, uvSamples[0]);\n normalSamples[1] = texture2D(t, uvSamples[1]);\n normalSamples[2] = texture2D(t, uvSamples[2]);\n normalSamples[3] = texture2D(t, uvSamples[3]);\n normalSamples[4] = texture2D(t, uvSamples[4]);\n normalSamples[5] = texture2D(t, uvSamples[5]);\n normalSamples[6] = texture2D(t, uvSamples[6]);\n normalSamples[7] = texture2D(t, uvSamples[7]);\n normalSamples[8] = texture2D(t, uvSamples[8]);\n\n float depthBias = 0.0001;\n \n if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n\n if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);\n vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);\n\n float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));\n return edgeNormal;\n}\n"),tZ.Nodes={outline:new Z("vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {\n vec3 result = outlineColor;\n float resultAlpha = 0.0;\n\n vec3 N = normalize(vWNormal);\n vec2 nuv = (gl_FragCoord.xy / resolution);\n float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);\n resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);\n\n \n \n\n float t = 1.0 - contourThreshold;\n if(positionalLines) {\n vec3 NDir = position * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float f = fract(NT * contourFrequency * 0.01);\n float df = fwidth(NT * contourFrequency);\n\n float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);\n if (g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0;\n }\n }\n else {\n vec3 NDir = N * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float df = fwidth(NT * contourThreshold);\n float f = sin(NT * 1.0 * contourFrequency);\n float g = smoothstep(0.0, df * contourWidth, 1.0 - f);\n\n if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0 - g;\n }\n }\n\n float lalpha = alpha * resultAlpha * mask;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n \n return result;\n }",[aw])};var tJ=function(e){function n(e,t,a,r,i,o,s,l,c,u,d,f,p,h,v,m,g,S){var y;return x(this,n),(y=_(this,n,["v3"])).nodeType="Pattern",y.style=e,y.projection=t,y.axis=a,y.blending=r,y.offset=i,y.colorA=o,y.colorB=s,y.frequency=l,y.size=c,y.variation=u,y.smoothness=d,y.zigzag=f,y.rotation=p,y.vertical=h,y.horizontal=v,y.sides=m,y.isMask=S,y.alpha=g,y.calpha="g".concat(y.uuid.toString().replace(/-/g,""),"_calpha"),y}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){switch(e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float"),this.style.value){case 0:default:t="circle";break;case 1:t="ring";break;case 2:t="polygon";break;case 3:t="xcross";break;case 4:t="diamond";break;case 5:t="checkerboard";break;case 6:t="line";break;case 7:t="wave"}var t,a="g".concat(this.uuid.toString().replace(/-/g,"")),r=new Z("float hashwithoutsine12(vec2 p)\n {\n vec3 p3 = fract(vec3(p.xyx) * .1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n }"),i=new Z("vec2 rotate_uv(in vec2 uv, float a, bool repeat) \n {\n const float mid = 0.5;\n float radians = a * (PI / 180.0);\n vec2 rotated = vec2(\n cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,\n cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid\n );\n return repeat ? fract(rotated): rotated;\n }"),o="";if(4===this.projection.value)o="\n vec3 p = position;\n float factor = 0.0125;\n vec2 uv0 = fract(p.xy * factor);\n vec2 uv1 = fract(p.zy * factor);\n vec2 uv2 = fract(p.xz * factor);\n \n uv0 = rotate_uv(uv0 + offset, rotation, true);\n uv1 = rotate_uv(uv1 + offset, rotation, true);\n uv2 = rotate_uv(uv2 + offset, rotation, true);\n \n float d0 = ".concat(2===this.style.value?"".concat(t,"(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)"):"".concat(t,"(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)"),";\n float d1 = ").concat(2===this.style.value?"".concat(t,"(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)"):"".concat(t,"(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)"),";\n float d2 = ").concat(2===this.style.value?"".concat(t,"(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)"):"".concat(t,"(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)"),";\n \n \n float exponent = (1.0 - blending) * 125.0 + 3.0;\n\n vec3 n = vObjectNormal;\n vec3 weights = abs(normalize(n));\n weights = pow(weights, vec3(exponent));\n weights /= dot(weights, vec3(1.0));\n d0 *= weights.z;\n d1 *= weights.x;\n d2 *= weights.y;\n float draw = d0 + d1 + d2;\n \n vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;\n ");else{var s=2===this.style.value?"".concat(t,"(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)"):"".concat(t,"(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)"),l="";0===this.axis.value?l="float radius = length(p);\n float theta = atan(p.y, p.z);\n float phi = acos(p.x / radius);":1===this.axis.value?l="float radius = length(p);\n float theta = atan(p.x, p.z);\n float phi = acos(p.y / radius);":(this.axis.value,l="float radius = length(p);\n float theta = atan(p.y, p.x);\n float phi = acos(p.z / radius);");var c="";switch(this.projection.value){case 0:c="custom_uv = vUv.st;";break;case 1:case 3:default:break;case 2:c="\n vec3 p = position;\n ".concat(l,"\n custom_uv = vec2(theta, phi);\n custom_uv /= PI;\n ")}o="\n vec2 custom_uv;\n ".concat(c,"\n \n custom_uv += offset;\n custom_uv = fract(custom_uv);\n custom_uv = rotate_uv(custom_uv, rotation, true);\n \n float draw = ").concat(s,";\n ")}var u=new Z("vec3 ".concat(a,"_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {\n const float TWO_PI = PI * 2.0;\n float smoothness_remapped = pow(smoothness, 5.0); \n\n ").concat(o,"\n\n \n vec4 color = mix(colorA, colorB, draw);\n color.a = clamp(color.a, 0.0, 1.0);\n\n \n color.a *= \n step(vertical.x, custom_uv.y) * \n step(custom_uv.y, vertical.y);\n color.a *= \n step(horizontal.x, abs(custom_uv.x)) * \n step(abs(custom_uv.x), horizontal.y);\n\n \n float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return clamp(color, 0.0, 1.0).rgb;\n }"),[i,r,tJ.DrawFunctions.circle,tJ.DrawFunctions.ring,tJ.DrawFunctions.polygon,tJ.DrawFunctions.cross,tJ.DrawFunctions.diamond,tJ.DrawFunctions.checkerboard,tJ.DrawFunctions.line,tJ.DrawFunctions.wave]),d=e.include(u),f=[];return f.push("normal"),f.push(this.blending.build(e,"f")),f.push(this.style.build(e,"i")),f.push(this.offset.build(e,"v2")),f.push(this.colorA.build(e,"v4")),f.push(this.colorB.build(e,"v4")),f.push(this.frequency.build(e,"v2")),f.push(this.size.build(e,"f")),f.push(this.variation.build(e,"f")),f.push(this.smoothness.build(e,"f")),f.push(this.zigzag.build(e,"f")),f.push(this.rotation.build(e,"f")),f.push(this.vertical.build(e,"v2")),f.push(this.horizontal.build(e,"v2")),f.push(this.sides.build(e,"i")),f.push(this.isMask.build(e,"b")),f.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),f.push(this.alpha.build(e,"f")),f.push(this.calpha),e.format(d+"("+f.join(",")+")",this.getType(e),n)}return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),n)}}]),n}(G);aT=new Z("float hashwithoutsine12(vec2 p) {\n vec3 p3 = fract(vec3(p.xyx) * 0.1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n }"),tJ.DrawFunctions={tileAndCenter:aE=new Z("vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {\n \n uv *= frequency;\n\n \n vec2 i = floor(uv);\n\n \n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = fract(uv);\n\n \n \n \n \n \n \n \n\n f = f * 2.0 - 1.0;\n\n \n i = floor(uv);\n float rand = (hashwithoutsine12(i) * 5.0 + 1.0);\n float jitter = mix(1.0, rand, variation);\n f *= jitter;\n\n return f;\n }",[aT]),circle:new Z("float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(\n -smoothness, \n smoothness, \n length(f) - size\n );\n }",[aE]),ring:new Z("float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n\n float d = length(f);\n const float inner_width = 0.5;\n\n float outer = smoothstep(-smoothness, smoothness, d - size);\n float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);\n return outer + (1.0 - inner); \n }",[aE]),polygon:new Z("float sdf_ngon(in vec2 p, in float r, in int n) {\n float an = (PI * 2.0) / float(n);\n float he = r * tan(0.5 * an);\n \n \n p = -p.yx; \n float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);\n vec2 cs = vec2(cos(bn), sin(bn));\n p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;\n \n \n return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);\n }\n \n float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));\n }",[aE]),cross:new Z("float sdf_cross(in vec2 p, in vec2 b, float r ) {\n p = abs(p); \n p = (p.y > p.x) ? p.yx : p.xy;\n vec2 q = p - b;\n float k = max(q.y, q.x);\n vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);\n return sign(k) * length(max(w, 0.0)) + r;\n }\n \n \n float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));\n }",[aE]),diamond:new Z("float ndot(vec2 a, vec2 b) { \n return a.x*b.x - a.y*b.y; \n }\n \n float sdf_diamond(in vec2 p, in vec2 b) {\n p = abs(p);\n float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);\n float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));\n return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);\n }\n\n float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));\n }",[aE]),checkerboard:new Z("float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n uv *= frequency;\n vec2 i = floor(uv);\n\n float offset = mod(i.y, 2.0);\n\n uv.x += offset + zigzag * offset;\n float x = floor(uv.x);\n \n return mod(x, 2.0);\n }"),line:new Z("float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);\n \n \n float row = floor(uv * frequency).y;\n float rand = hashwithoutsine12(vec2(row));\n float s = mix(size, size * rand, variation);\n\n return smoothstep(\n s - smoothness, \n s + smoothness, \n abs(f.y)\n );\n }",[aE]),wave:new Z("\n float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {\n \n p = c * (p - vec2(d, a));\n \n const float TWO_PI = PI * 2.0;\n\n \n p.x = mod(p.x, TWO_PI); \n if (p.x > PI) {\n p.x = TWO_PI - p.x;\n }\n \n \n float xa = 0.0;\n float xb = TWO_PI;\n\n \n for (int i = 0; i < 24; i++) {\n float x = 0.5 * (xa + xb);\n float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));\n if (y < 0.0) xa = x; \n else xb = x;\n }\n float x = 0.5 * (xa + xb);\n \n \n vec2 q = vec2(x, b * c * cos(x));\n return length(p - q) / c;\n }\n\n float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n float repeat = frequency.x;\n uv *= repeat;\n vec2 i = floor(uv);\n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = vec2(uv.x, fract(uv.y));\n\n \n const float amplitude = 0.125;\n float wave_frequency = frequency.y * 0.1;\n float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);\n\n \n float rand = hashwithoutsine12(vec2(i.y));\n float s = mix(size, size * rand, variation);\n\n return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);\n }")};var tQ=function(e){function n(e,t,a,r,i,o,s,l){var c,u=!(arguments.length>8)||void 0===arguments[8]||arguments[8];return x(this,n),(c=_(this,n,["v3"])).nodeType="Rainbow",c.filmThickness=e,c.movement=t,c.wavelengths=a,c.noiseStrength=r,c.noiseScale=i,c.offset=o,c.isMask=l,c.alpha=s,c.noiseEnabled=u,c.calpha="g".concat(c.uuid.toString().replace(/-/g,""),"_calpha"),c}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");var t=e.include(this.noiseEnabled?tQ.Nodes.rainbow:tQ.Nodes.rainbowNN),a=[];return a.push(this.filmThickness.build(e,"f")),a.push(this.movement.build(e,"f")),a.push(this.wavelengths.build(e,"v3")),a.push(this.noiseStrength.build(e,"f")),a.push(this.noiseScale.build(e,"f")),a.push(this.offset.build(e,"v3")),a.push(this.isMask.build(e,"b")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);aM=new Z("vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n float f = 0.0;\n\n if (noiseStrength != 0.0) {\n vec3 st = position / noiseScale;\n float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));\n f = noise * noiseStrength;\n }\n\n vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);\n return .5 + .5 * color;\n }",[tW.simplexFast]),aC=new Z("vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n float lalpha = alpha * rainbowContribution * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return res;\n }",[aM]),aR=new Z("vec3 attenuationNN(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n mediump vec3 color = cos(((filmThickness / waves) * angle) + movement);\n return .5 + .5 * color;\n }"),tQ.Nodes={rainbow:aC,rainbowNN:new Z("vec3 rainbowNN(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n mediump vec3 res = clamp(attenuationNN(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n float lalpha = alpha * rainbowContribution * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n return res;\n }",[aR])};var t$=function(e){function n(e,t,a,r,i,o,s,l,c,u){var d;return x(this,n),(d=_(this,n,["v3"])).nodeType="Toon",d.positioning=e,d.colors=t,d.steps=a,d.source=r,d.isWorldSpace=i,d.noiseStrength=o,d.noiseScale=s,d.shadowColor=l,d.offset=c,d.alpha=u,d.calpha="g".concat(d.uuid.toString().replace(/-/g,""),"_calpha"),d}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");var t=e.include(t$.Nodes.toon),a=[];return a.push(this.positioning.build(e,"i")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.source.build(e,"v3")),a.push(this.isWorldSpace.build(e,"b")),a.push(this.noiseStrength.build(e,"f")),a.push(this.noiseScale.build(e,"f")),a.push(this.shadowColor.build(e,"v4")),a.push(this.offset.build(e,"v3")),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);aA=new Z("float rand(float n) {\n return fract(sin(n) * 43758.5453123);\n }"),aP=new Z("float hash1(float p) { \n p = fract(p * 0.011); \n p *= p + 7.5; \n p *= p + p; \n return fract(p); \n }"),aD=new Z("float valueNoise(vec3 x) {\n const vec3 step = vec3(110, 241, 171);\n \n vec3 i = floor(x);\n vec3 f = fract(x);\n \n \n \n float n = dot(i, step);\n \n vec3 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),\n mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),\n mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n }",[aP]),aL=new Z("vec3 hash3(vec3 x) {\n x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),\n dot(x,vec3(269.5, 183.3, 246.1)),\n dot(x,vec3(113.5, 271.9, 124.6)));\n \n return fract(sin(x)*43758.5453123);\n }"),aU=new Z("vec3 voronoiNoise(in vec3 x)\n {\n vec3 p = floor(x);\n vec3 f = fract(x);\n\n float id = 0.0;\n vec2 res = vec2(100.0);\n\n for(int k=-1; k<=1; k++)\n for(int j=-1; j<=1; j++)\n for(int i=-1; i<=1; i++)\n {\n vec3 b = vec3(float(i), float(j), float(k));\n\n \n vec3 r = vec3(b) - f + hash3(p + b);\n float d = dot(r, r);\n\n if (d < res.x)\n {\n id = dot(p + b, vec3(1.0, 57.0, 113.0));\n res = vec2(d, res.x); \n }\n else if (d < res.y)\n {\n res.y = d;\n }\n }\n\n return vec3(sqrt(res), abs(id));\n }\n ",[aL]),t$.Nodes={toon:new Z("vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {\n float t = 0.0;\n float shadow = 1.0;\n\n if (positioning == 0) {\n\n \n #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))\n\n \n const vec3 weights = vec3(0.2125, 0.7154, 0.0721);\n vec3 lpos;\n vec3 l;\n float dproduct;\n\n #if (NUM_POINT_LIGHTS > 0)\n\n #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)\n PointLightShadow pointLightShadow;\n #endif \n\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n \n lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n l = normalize(lpos - worldPosition);\n \n dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n \n \n \n\n t = max(t, dproduct);\n\n \n #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)\n pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];\n shadow *= getPointShadow( \n pointShadowMap[UNROLLED_LOOP_INDEX], \n pointLightShadow.shadowMapSize,\n pointLightShadow.shadowIntensity,\n pointLightShadow.shadowBias, \n pointLightShadow.shadowRadius,\n vPointShadowCoord[UNROLLED_LOOP_INDEX], \n pointLightShadow.shadowCameraNear, \n pointLightShadow.shadowCameraFar);\n #endif\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if NUM_DIR_LIGHTS > 0 \n \n #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)\n DirectionalLightShadow directionalLightShadow;\n #endif \n\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n \n l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;\n \n dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n t = max(t, dproduct);\n\n \n #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)\n directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];\n shadow *= getShadow( \n UNROLLED_LOOP_INDEX,\n directionalShadowMap[UNROLLED_LOOP_INDEX], \n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias, \n directionalLightShadow.shadowRadius, \n vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);\n #endif\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if NUM_SPOT_LIGHTS > 0 \n \n #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)\n SpotLightShadow spotLightShadow;\n #endif \n\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n l = normalize(lpos - worldPosition);\n \n dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n t = max(t, dproduct);\n\n \n #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)\n spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];\n shadow *= getShadow(\n UNROLLED_LOOP_INDEX,\n spotShadowMap[UNROLLED_LOOP_INDEX], \n spotLightShadow.shadowMapSize,\n spotLightShadow.shadowIntensity,\n spotLightShadow.shadowBias, \n spotLightShadow.shadowRadius, \n vSpotLightCoord[UNROLLED_LOOP_INDEX]);\n #endif\n }\n #pragma unroll_loop_end\n\n #endif\n\n t = clamp(t, 0.0, 1.0);\n \n #endif\n\n } else if (positioning == 1) {\n \n vec3 origin = mix(position, worldPosition, float(isWorldSpace));\n vec3 direction = normalize(source - origin);\n t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; \n\n } else {\n\n vec3 origin = worldPosition;\n vec3 source = cameraPosition - offset;\n vec3 direction = normalize(source - origin);\n t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; \n \n }\n\n if (noiseStrength > 0.0) {\n \n vec3 st = position / noiseScale;\n \n \n float noise = 1.0 - voronoiNoise(st).x;\n\n \n \n\n \n \n \n \n \n \n \n \n\n t += noise * noiseStrength;\n }\n\n t = clamp(t, 0.0, 1.0);\n\n \n float p;\n vec4 color = colors[0];\n for (int i = 1; i < COLORS_MAX; i++) {\n p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);\n color = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n }\n\n \n if (positioning == 0) {\n\n vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);\n color.rgb = mix(blendedShadow, color.rgb, shadow);\n \n }\n\n \n float lalpha = alpha * color.a * mask;\n calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n accumAlpha += (1.0 - accumAlpha) * lalpha;\n\n return color.xyz;\n\n }",[tW.simplexFast,aA,aD,aU])};var t0={textureBicubic:new Z("float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n \n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n \n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n \n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n \n \n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n \n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n \n \n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n \n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n \n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n \n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n \n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n \n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n \n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + \n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }")},t1=function(e){function n(e,t,a,r,i,o,s,l){var c;return x(this,n),(c=_(this,n,["v3"])).nodeType="Transmission",c.thickness=e,c.ior=t,c.roughness=a,c.transmissionSamplerSize=r,c.transmissionSamplerMap=i,c.transmissionDepthMap=o,c.aspectRatio=s,c.alpha=l,c.calpha="g".concat(c.uuid.toString().replace(/-/g,""),"_calpha"),c}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,aZ.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");var t=e.include(t1.Nodes.transmission),a=[];return a.push(this.thickness.build(e,"f")),a.push(this.ior.build(e,"f")),a.push(this.roughness.build(e,"f")),a.push(this.transmissionSamplerSize.build(e,"v2")),a.push(this.transmissionSamplerMap.getTexture(e,"t")),a.push(this.transmissionDepthMap.getTexture(e,"t")),a.push(this.aspectRatio.build(e,"v2")),a.push("normal"),a.push(this.mask?"luminance(".concat(this.mask.flow(e,"v3").result,")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);aN=new Z("vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {\n \n \n\n \n if (lod == 0.0) {\n #ifdef TEXTURE_LOD_EXT\n return texture2DLodEXT( sp, U, 0.0).rgb;\n #else\n return textureLod( sp, U, 0.0).rgb;\n #endif\n }\n \n vec2 texelSize = vec2(1.0) / resolution;\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n vec3 res = vec3(0.0);\n vec2 uv = vec2(0.0);\n vec2 offset = vec2(0.0);\n vec2 vogelSample = vec2(0.0);\n for (int i = 0; i < NUM_SAMPLES; i++) {\n vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;\n offset = vogelSample * scale * (lod * 10.0); \n uv = U + offset;\n float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));\n if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {\n uv = unrefractedU;\n lod = lod > 4.0 ? lod : lod / 2.0;\n }\n res += textureLod(sp, uv, lod).rgb;\n }\n return res / float(NUM_SAMPLES);\n }"),aI=new Z("vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n \n vec3 refractionVector = refract( -v, n, 1.0 / ior );\n \n \n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\n \n return normalize( refractionVector ) * thickness * modelScale;\n }"),aO=new Z("float applyIorToRoughness( float roughness, float ior ) {\n // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n // an IOR of 1.5 results in the default amount of microfacet refraction.\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }"),aF=new Z("vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {\n \n \n #ifdef IS_THREEJS_EXPORT\n float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);\n return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;\n #else\n float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n float lod = applyIorToRoughness(roughness, ior);\n return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);\n #endif\n }",[t0.textureBicubic,aO,aN]),az=new Z("vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n\n \n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n\n vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );\n vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;\n unrefractedCoords += 1.0;\n unrefractedCoords /= 2.0;\n\n \n return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );\n }",[aF,aI]),t1.Nodes={transmission:new Z("vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {\n vec3 v = vec3(0.);\n if (isOrthographic) {\n v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n v = normalize(vWPosition - cameraPosition);\n }\n vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );\n \n float lalpha = alpha * mask;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * alpha;\n\n return transmission;\n }",[az])};var t3=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["v3"])).nodeType="VertexColor",t.alpha=e,t.calpha="g".concat(t.uuid.toString().replace(/-/g,""),"_calpha"),t}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("fragment")){e.requires.color[0]=!0;var t=e.include(t3.Nodes.vertexColorLayer);e.addFragmentVariable(this.calpha,"float");var a=[];return a.push("vColor"),a.push(this.mask?"luminance(".concat(this.mask.build(e,"v3"),")"):"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("VertexColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);t3.Nodes={vertexColorLayer:new Z("vec3 vertexColorLayer(vec4 vcolor, float mask, float alpha, out float calpha) {\n float lalpha = alpha * mask * vcolor.a;\n calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n accumAlpha += (1.0 - accumAlpha) * lalpha;\n\n return vcolor.rgb;\n }")};var t2,t4,t5,t6,t8,t9,t7,ae,an,at,aa,ar,ai,ao,as,al,ac,au,ad,af,ap,ah,av,am,ag,a_,ax,aS,ay,ab,aw,aT,aE,aM,aC,aR,aA,aP,aD,aL,aU,aN,aI,aO,aF,az,ak,aB,aV,aG,aH,aW,aX,aj,aq,aY=((aq=aY||{}).NOISE="noise",aq.MAP="map",aq),aK=function(e){function n(e,t,a,r,i,o,s,l,c,u,d){var f;return x(this,n),(f=_(this,n,["v3"])).displacementTypeIndex=new ey(0),f.nodeType="VertexDisplacement",f.intensity=e,f.movementOrTexture=t,"map"===Object.values(aY)[f.displacementTypeIndex.value]&&(f.mat=new tL(f.movementOrTexture.value.matrix)),f.cropOrOffset=a,f.scale=u,f.noiseFunctionIndex=d,f.voronoiStyle=r,f.smoothness=i,f.seed=o,f.highCut=s,f.lowCut=l,f.quality=c,f}return M(n,e),b(n,[{key:"generate",value:function(e,n){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");var t,a=[];switch(a.push("displaced_position"),a.push("displaced_normal"),Object.values(aY)[this.displacementTypeIndex.value]){case"map":t=e.include(aK.Nodes.map),a.push(this.movementOrTexture.getTexture(e,"t")),a.push("uv"),a.push(this.cropOrOffset.build(e,"f")),this.mat&&a.push(this.mat.build(e,"mat3"));break;case"noise":var r=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],i=new Z("vec3 orthogonal(vec3 v) {\n return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n }"),o=new Z("vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {\n ".concat("voronoi"==r?"\n float v = ".concat(r,"((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);\n v = remap(v, lowCut, highCut, 0.0, 1.0);\n v = smax(v, 0.0, smoothness * 0.25);\n v = smin(v, 1.0, smoothness * 0.25);\n\n return p + n * v * intensity;\n "):"\n return p + n * ".concat(r,"((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;\n "),"\n }"),[tW.simplexPrecise,tW.simplexFractal,tW.simplexAshima,tW.fbm,tW.perlin,tW.voronoi]),s=new Z("vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {\n vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n vec3 tangent1 = orthogonal(normal);\n vec3 tangent2 = normalize(cross(normal, tangent1));\n\n \n \n \n \n \n vec3 nearby1 = position + tangent1;\n vec3 nearby2 = position + tangent2;\n vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n return displaced_position;\n }",[o,i]);t=e.include(s),a.push(this.scale.build(e,"f")),a.push(this.cropOrOffset.build(e,"v3")),a.push(this.movementOrTexture.build(e,"f")),a.push(this.voronoiStyle.build(e,"i")),a.push(this.smoothness.build(e,"f")),a.push(this.seed.build(e,"f")),a.push(this.highCut.build(e,"f")),a.push(this.lowCut.build(e,"f")),a.push(this.quality.build(e,"i"))}return a.push(this.intensity.build(e,"f")),a.push("displaced_normal"),e.format(t+"("+a.join(",")+")",this.getType(e),n)}return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}}]),n}(G);a0=new Z("vec3 orthogonal(vec3 v) {\n return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n }"),a1=new Z("float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {\n vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;\n vec4 tmp = texture2D(tex, uvs);\n vec3 col = tmp.rgb;\n if (crop > 0.5) {\n if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n return 0.0;\n }\n }\n return col.r;\n }"),aK.Nodes={map:new Z("vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {\n vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;\n vec3 tangent1 = normalize(orthogonal(normal));\n vec3 tangent2 = normalize(cross(normal, tangent1));\n vec3 nearby1 = position + tangent1 * 0.1;\n vec3 nearby2 = position + tangent2 * 0.1;\n vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n return displaced_position;\n }",[a0,a1])};var aZ={normalRenderTarget:new ei,normalRenderTargetDepth:new ei,normalViewRenderTarget:new ei,transmissionRenderTarget:new ei,aspectRatio:new W,transmissionSize:new W(2048,2048),transmissionRenderTargetDepth:new ei,aoRenderTarget:new ei,aoEnabled:new tC,pixelRatioNode:new q(1),resolution:new W,penumbraSize:new tR(c.d,.5),frameIndex:new ey(0),transmissionLod:new ey(2),taaEnabled:new tC(!0)},aJ=!0,aQ=!1,a$=void 0;try{for(var a0,a1,a3,a2=Object.values(aZ)[Symbol.iterator]();!(aJ=(a3=a2.next()).done);aJ=!0)a3.value.isRenderGlobal=!0}catch(e){aQ=!0,a$=e}finally{try{aJ||null==a2.return||a2.return()}finally{if(aQ)throw a$}}var a4={spe_fogMode:new h.Le(0),spe_fogHeightParams:new h.Le(new h.Fc(.005,.01,0))},a5="\n#include <fog_pars_fragment>\n#ifdef USE_FOG\n uniform float spe_fogMode;\n uniform vec3 spe_fogHeightParams;\n\n // Analytic optical depth of an exponential height-fog layer along the\n // camera->fragment ray (see FogChunk.ts). fogWorldDelta = fragment -\n // camera in WORLD space, fogDist = its length. With x = falloff *\n // fogWorldDelta.y the integral collapses to camDensity * fogDist * F(x),\n // F(x) = (1 - e^-x)/x. F is evaluated on a sign-preserving |x| >= 1e-4:\n // that keeps F's x->0 limit of 1 (horizontal rays / falloff 0 degrade to\n // classic exponential fog) without a branch — deliberate, because the\n // WGSL twins' select() evaluates BOTH sides, so a guarded division, not\n // a branch, is what actually prevents inf/NaN there, and all four\n // implementations stay line-for-line identical.\n float speHeightFogFactor(const in vec3 fogWorldDelta, const in float fogDist) {\n float density = spe_fogHeightParams.x;\n float falloff = spe_fogHeightParams.y;\n float relY = cameraPosition.y - spe_fogHeightParams.z;\n // Density at the camera's own height, overflow-clamped: far below\n // the fog base the exponent explodes; the fog factor saturates to 1\n // long before, so the clamp is invisible.\n float camDensity = density * exp(clamp(-falloff * relY, -60.0, 60.0));\n float x = clamp(falloff * fogWorldDelta.y, -60.0, 60.0);\n float xSafe = (x >= 0.0 ? 1.0 : -1.0) * max(abs(x), 1e-4);\n float opticalDepth =\n camDensity * fogDist * (1.0 - exp(-xSafe)) / xSafe;\n return 1.0 - exp(-max(opticalDepth, 0.0));\n }\n#endif\n",a6="\n#ifdef USE_FOG\n float speFogLinear = smoothstep(fogNear, fogFar, vFogDepth);\n vec3 speFogViewPos = -vViewPosition;\n float speFogDist = length(speFogViewPos);\n vec3 speFogWorldDelta = speFogViewPos * mat3(viewMatrix);\n float speFogHeight = speHeightFogFactor(speFogWorldDelta, speFogDist);\n float speFogWLinear = 1.0 - step(0.5, spe_fogMode) + step(1.5, spe_fogMode);\n float speFogWHeight = step(0.5, spe_fogMode);\n float speFogFactor = 1.0 -\n (1.0 - speFogLinear * speFogWLinear) *\n (1.0 - speFogHeight * speFogWHeight);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, speFogFactor);\n#endif\n",a8=function(e){function n(){var e;return x(this,n),(e=_(this,n,["basic"])).nodeType="Basic",e.color=new eS(d.x),e.shadingAlpha=new q(1),e.shadingBlend=new ey(0),e.previousModelViewMatrix=new tU,e.previouseProjectionMatrix=new tU,e}return M(n,e),b(n,[{key:"category",get:function(){return"phong"}},{key:"generate",value:function(e){var n;if(e.isShader("vertex")){var t=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({resolution:aZ.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h.be.merge([eE.fog])),e.mergeUniform(a4),e.addParsCode("varying vec3 vViewPosition;\nvarying vec3 vWPosition;\n#include <fog_pars_vertex>\n#include <skinning_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>");var a=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #if !defined( USE_LAYER_DISPLACE )\n #include <defaultnormal_vertex>\n #endif\n\n vec3 displaced_position = position;\n vec3 displaced_normal = normal;\n\n #if defined( USE_LAYER_DISPLACE )\n vec3 transformed;\n vec3 transformedNormal;\n #endif\n ","#include <normal_vertex>","\n #if !defined( USE_LAYER_DISPLACE )\n #include <begin_vertex>\n #endif /* !USE_LAYER_DISPLACE */\n "];t&&a.push(t.code,t.result?"displaced_position = "+t.result+";":""),a.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),a.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),a.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),n=a.join("\n")}else{void 0===this.color&&(this.color=new eS(d.x)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});var r=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,o=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=void 0!==i,e.addParsCode(["varying vec3 vWPosition;",a5,"#include <dithering_pars_fragment>\nvarying vec3 vViewPosition;\n#include <normal_pars_fragment>"].join("\n"));var l=["#include <normal_fragment_begin>",r.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,"vec3 outgoingLight = ".concat(r.result,";"),"vec3 finalColor = spe_blend(outgoingLight, ".concat(s.result,", 1.0, SPE_BLENDING_NORMAL);")):l.push("vec3 finalColor = ".concat(r.result,";"));var c="1.0";this.mask&&(this.mask.analyze(e),c="luminance(".concat(this.mask.flow(e,"v3").result,")")),i?l.push("gl_FragColor = vec4( finalColor, accumAlpha * ".concat(i.result," * ").concat(c," );")):l.push("gl_FragColor = vec4("+r.result+", 1.0 );"),o&&l.push("gl_FragColor.a *= ".concat(o.result,";")),l.push(a6,"#include <dithering_fragment>"),n=l.join("\n")}return n}}]),n}(k),a9=function(e){function n(){var e;return x(this,n),(e=_(this,n,["lambert"])).nodeType="Lambert",e.color=new eS(d.x),e.emissive=new eS(0),e.emissiveIntensity=new q(1),e.previousModelViewMatrix=new tU,e.previouseProjectionMatrix=new tU,e.shadingAlpha=new q(1),e.shadingBlend=new ey(0),e.occlusion=new tC(!0),e}return M(n,e),b(n,[{key:"category",get:function(){return"lambert"}},{key:"build",value:function(e){var n;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){var t=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({resolution:aZ.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h.be.merge([eE.fog,eE.lights])),e.mergeUniform(a4),e.addParsCode("varying vec3 vViewPosition;\nvarying vec3 vWPosition;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifndef DOUBLE_SIDED\n #define DOUBLE_SIDED\n#endif\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <skinning_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <clipping_planes_pars_vertex>");var a=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #ifndef USE_LAYER_DISPLACE\n #include <defaultnormal_vertex>\n #endif\n\n vec3 displaced_position = position;\n vec3 displaced_normal = objectNormal;\n\n #ifdef USE_LAYER_DISPLACE\n vec3 transformed;\n vec3 transformedNormal;\n #endif\n ","#include <normal_vertex>","\n #ifndef USE_LAYER_DISPLACE\n #include <begin_vertex>\n #endif\n "];t&&a.push(t.code,t.result?"displaced_position = "+t.result+";":""),a.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),a.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>","\n vec3 diffuse = vec3( 1.0 );\n \n \n struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; };\n GeometricContext geometry;\n geometry.position = mvPosition.xyz;\n geometry.normal = normalize( transformedNormal );\n geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n "),a.push("\n GeometricContext backGeometry;\n backGeometry.position = geometry.position;\n backGeometry.normal = -geometry.normal;\n backGeometry.viewDir = geometry.viewDir;\n vLightFront = vec3( 0.0 );\n vIndirectFront = vec3( 0.0 );\n #ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n vIndirectBack = vec3( 0.0 );\n #endif\n IncidentLight directLight;\n float dotNL;\n vec3 directLightColor_Diffuse;\n vIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n #endif\n #ifdef DOUBLE_SIDED\n vIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n #endif\n #endif\n #if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n getPointLightInfo( pointLights[ i ], geometry.position, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotLightInfo( spotLights[ i ], geometry.position, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalLightInfo( directionalLights[ i ], directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_HEMI_LIGHTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n #ifdef DOUBLE_SIDED\n vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n #endif\n }\n #pragma unroll_loop_end\n #endif\n "," #include <shadowmap_vertex>"," #include <fog_vertex>"),a.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),n=a.join("\n")}else{e.mergeUniform({penumbraSize:aZ.penumbraSize}),e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({aoMap:aZ.aoRenderTarget}),e.mergeUniform({aoEnabled:aZ.aoEnabled}),void 0===this.color&&(this.color=new eS(d.x)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);var r=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),o=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),f=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,v=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==p,e.addParsCode(["uniform float penumbraSize[".concat(c.d,"];"),"uniform sampler2D aoMap;\nuniform bool aoEnabled;\nvarying vec3 vViewPosition;\nvarying vec3 vWPosition;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifndef DOUBLE_SIDED\n #define DOUBLE_SIDED\n#endif\n#include <normal_pars_fragment>\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include <bsdfs>\n#include <lights_pars_begin>",a5,"#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#include <dithering_pars_fragment>"].join("\n"));var m=["#include <normal_fragment_begin>","\n \n vec3 viewdx = dFdx(vViewPosition);\n vec3 viewdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(viewdx, viewdy));\n bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);\n ","#include <clipping_planes_fragment>"];m.push(r.code,"vec3 diffuseColor = "+r.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),p&&m.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),m.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#ifdef USE_LIGHTMAP"," vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );"," reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;","#endif","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&m.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+o.result+";"),m.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");var g="1.0";this.mask&&(this.mask.analyze(e),g="luminance(".concat(this.mask.flow(e,"v3").result,")")),m.push("\n if (outgoingLight != diffuseColor) {\n float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * ".concat(l.result," * ").concat(g," * lightAccu;\n outgoingLight = spe_blend( diffuseColor, outgoingLight, ").concat(l.result," * ").concat(g,", ").concat(u.result," );\n\n outgoingLight *= ao;\n }\n ")),f&&m.push(f.code,"outgoingLight = spe_blend(outgoingLight, ".concat(f.result,", 1.0, SPE_BLENDING_NORMAL);")),p?m.push("gl_FragColor = vec4( outgoingLight, accumAlpha * ".concat(p.result," );")):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),v&&m.push("gl_FragColor.a *= ".concat(v.result,";")),m.push("#include <colorspace_fragment>",a6,"#include <dithering_fragment>"),n=m.join("\n")}return n}}]),n}(k),a7={dHdxy:new Z("vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {\n\n \n vec2 dSTdx = dFdx(bumpMapUv);\n\n \n vec2 dSTdy = dFdy(bumpMapUv);\n \n \n float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);\n float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;\n float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;\n \n return vec2( dBx, dBy );\n }"),perturbNormalArb:new Z("vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = dFdx( surf_pos.xyz );\n vec3 vSigmaY = dFdy( surf_pos.xyz );\n vec3 vN = surf_norm; \n \n vN = normalize(vN);\n\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n\n R1 = normalize(R1);\n R2 = normalize(R2);\n \n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n \n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * vN - vGrad );\n }")},re=function(e){function n(){var e;return x(this,n),(e=_(this,n,["standard"])).nodeType="Standard",e.color=new eS(d.x),e.roughness=new q(.3),e.metalness=new q(0),e.reflectivity=new q(.5),e.previousModelViewMatrix=new tU,e.previouseProjectionMatrix=new tU,e.shadingAlpha=new q(1),e.shadingBlend=new ey(0),e.occlusion=new tC(!0),e}return M(n,e),b(n,[{key:"category",get:function(){return"physical"}},{key:"build",value:function(e){var n;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){var t=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({resolution:aZ.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h.be.merge([eE.fog,eE.lights])),e.mergeUniform(a4),eE.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode("varying vec3 vViewPosition;\nvarying vec3 vWPosition;\n#include <fog_pars_vertex>\n#include <skinning_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <clipping_planes_pars_vertex>");var a=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #if !defined( USE_LAYER_DISPLACE )\n #include <defaultnormal_vertex>\n #endif\n\n vec3 displaced_position = position;\n vec3 displaced_normal = objectNormal;\n\n #if defined( USE_LAYER_DISPLACE )\n vec3 transformed;\n vec3 transformedNormal;\n #endif\n ","#include <normal_vertex>","\n #if !defined( USE_LAYER_DISPLACE )\n #include <begin_vertex>\n #endif /* !USE_LAYER_DISPLACE */\n "];t&&a.push(t.code,t.result?"displaced_position = "+t.result+";":""),a.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),a.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),a.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),n=a.join("\n")}else{e.mergeUniform({penumbraSize:aZ.penumbraSize}),e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({aoMap:aZ.aoRenderTarget}),e.mergeUniform({aoEnabled:aZ.aoEnabled}),e.mergeUniform({dfgLUT:{value:null}});var r={gamma:!0};void 0===this.color&&(this.color=new eS(d.x)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e);var i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);var o=this.color.flow(e,"c",{slot:"color",context:r}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),f=this.shadingBlend.flow(e,"i"),p=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,v=this.alpha?this.alpha.flow(e,"f"):void 0,m=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,g=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=void 0!==v,e.addParsCode(["varying vec3 vViewPosition;\nvarying vec3 vWPosition;","uniform float penumbraSize[".concat(c.d,"];"),"uniform sampler2D aoMap;\nuniform bool aoEnabled;\n#include <normal_pars_fragment>\n#include <dithering_pars_fragment>",a5,"#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>"].join("\n"));var _=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>","\n \n vec3 viewdx = dFdx(vViewPosition);\n vec3 viewdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(viewdx,viewdy));\n if (dot(normal, faceNormal) < 0.0) {\n normal *= -1.0;\n }\n "," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(a7.dHdxy),e.include(a7.perturbNormalArb);var x=this.bumpMap.texture.flow(e,"t"),S=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",b="";b=4===this.bumpMap.projection.value?"\n vec3 bumpNormal = vec3(0.0);\n {\n vec2 uv0 = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs0;\n vec2 uv1 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs1;\n vec2 uv2 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs2;\n vec3 weights = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_triplanarWeights;\n\n vec2 grad0 = dHdxy(").concat(x.result,", uv0, ").concat(y,");\n vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n vec2 grad1 = dHdxy(").concat(x.result,", uv1, ").concat(y,");\n vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n vec2 grad2 = dHdxy(").concat(x.result,", uv2, ").concat(y,");\n vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n \n bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n bumpNormal = normalize(bumpNormal);\n }\n\n normal = bumpNormal;\n "):"\n vec2 bumpMapCachedUv = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs;\n vec2 grad = dHdxy(").concat(x.result,", bumpMapCachedUv, ").concat(y,");\n normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n "),_.push("// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n ".concat(S.result,";\n ").concat(b,"\n "))}if(_.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){var w=this.roughnessMap.texture.flow(e,"t"),T=this.roughnessMap.flow(e,"v3"),E="";E=4===this.roughnessMap.projection.value?"\n float roughnessChange = 1.0;\n {\n vec2 uv0 = g".concat(this.roughnessMap.uuid.toString().replace(/-/g,""),"_writeUvs0;\n vec2 uv1 = g").concat(this.roughnessMap.uuid.toString().replace(/-/g,""),"_writeUvs1;\n vec2 uv2 = g").concat(this.roughnessMap.uuid.toString().replace(/-/g,""),"_writeUvs2;\n vec3 weights = g").concat(this.roughnessMap.uuid.toString().replace(/-/g,""),"_triplanarWeights;\n\n float r0 = luminance(texture(").concat(w.result,", uv0).rgb) * roughnessScale;\n float r1 = luminance(texture(").concat(w.result,", uv1).rgb) * roughnessScale;\n float r2 = luminance(texture(").concat(w.result,", uv2).rgb) * roughnessScale;\n\n roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);\n }\n float roughnessFactor = roughnessChange * ").concat(s.result,";\n "):"\n vec2 roughnessMapCachedUv = g".concat(this.roughnessMap.uuid.toString().replace(/-/g,""),"_writeUvs;\n\n vec4 vals = texture(").concat(w.result,", roughnessMapCachedUv);\n float roughnessFactor = luminance(vals.rgb) * ").concat(s.result,";\n "),_.push("// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n ".concat(T.result,";\n\n const float roughnessScale = 1.0;\n\n ").concat(E,"\n "))}else _.push(s.code," float roughnessFactor = "+s.result+";");v&&_.push(v.code,"#ifdef ALPHATEST"," if ( "+v.result+" <= ALPHATEST ) discard;","#endif"),_.push("vec3 dxy = max( abs( dFdx( normal ) ), abs( dFdy( normal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),_.push("material.diffuseColor = diffuseColor;","material.diffuseContribution = diffuseColor * ( 1.0 - metalnessFactor );","material.metalness = metalnessFactor;","material.specularF90 = 1.0;","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),g?_.push(g.code,"material.specularColor = vec3( 0.16 * pow2( "+g.result+" ) );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"):_.push("material.specularColor = vec3( 0.04 );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"),_.push("#include <lights_fragment_begin>"),_.push("#include <lights_fragment_end>"),_.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");var M="1.0";this.mask&&(this.mask.analyze(e),M="luminance(".concat(this.mask.flow(e,"v3").result,")")),_.push("\n if (outgoingLight != diffuseColor) {\n float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * ".concat(u.result," * ").concat(M," * lightAccu;\n outgoingLight = spe_blend( diffuseColor, outgoingLight, ").concat(u.result," * ").concat(M,", ").concat(f.result," );\n \n outgoingLight *= ao;\n }\n ")),p&&_.push(p.code,"outgoingLight = spe_blend(outgoingLight, ".concat(p.result,", 1.0, SPE_BLENDING_NORMAL);")),v?_.push("gl_FragColor = vec4( outgoingLight, accumAlpha * ".concat(v.result," );")):_.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m&&_.push("gl_FragColor.a *= ".concat(m.result,";")),_.push("#include <colorspace_fragment>",a6,"#include <dithering_fragment>"),n=_.join("\n")}return n}}]),n}(k),rn=function(e){function n(){var e;return x(this,n),(e=_(this,n,["toon"])).nodeType="Toon",e.color=new eS(d.x),e.specular=new eS(1118481),e.shininess=new q(30),e.previousModelViewMatrix=new tU,e.previouseProjectionMatrix=new tU,e.shadingAlpha=new q(1),e.shadingBlend=new ey(0),e}return M(n,e),b(n,[{key:"category",get:function(){return"toon"}},{key:"build",value:function(e){var n;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){var t=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({resolution:aZ.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h.be.merge([eE.fog,eE.lights])),e.mergeUniform(a4),e.addParsCode("varying vec3 vViewPosition;\nvarying vec3 vWPosition;\n#include <fog_pars_vertex>\n#include <skinning_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <clipping_planes_pars_vertex>");var a=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #ifndef USE_LAYER_DISPLACE\n #include <defaultnormal_vertex>\n #endif\n\n vec3 displaced_position = position;\n vec3 displaced_normal = objectNormal;\n\n #ifdef USE_LAYER_DISPLACE\n vec3 transformed;\n vec3 transformedNormal;\n #endif\n ","#include <normal_vertex>","\n #ifndef USE_LAYER_DISPLACE\n #include <begin_vertex>\n #endif\n "];t&&a.push(t.code,t.result?"displaced_position = "+t.result+";":""),a.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),a.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),a.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),n=a.join("\n")}else{e.mergeUniform({penumbraSize:aZ.penumbraSize}),e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({aoMap:aZ.aoRenderTarget}),e.mergeUniform({aoEnabled:aZ.aoEnabled}),void 0===this.color&&(this.color=new eS(d.x)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);var r=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),o=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,f=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==f,e.addParsCode(["uniform float penumbraSize[".concat(c.d,"];"),"uniform sampler2D aoMap;\nuniform bool aoEnabled;\nvarying vec3 vWPosition;\n#include <normal_pars_fragment>\n#include <gradientmap_pars_fragment>",a5,"#include <bsdfs>\n#include <lights_pars_begin>\n#include <dithering_pars_fragment>\n\n varying vec3 vViewPosition;\n struct ToonMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n };\n \n \n \n void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n }\n void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n }\n #define RE_Direct RE_Direct_Toon\n #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n #define Material_LightProbeLOD( material ) (0)\n \n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>"].join("\n"));var v=["#include <normal_fragment_begin>","\n \n vec3 viewdx = dFdx(vViewPosition);\n vec3 viewdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(viewdx,viewdy));\n if (dot(normal, faceNormal) < 0.0) {\n normal *= -1.0;\n }\n "," ToonMaterial material;"];if(this.bumpMap){e.include(a7.dHdxy),e.include(a7.perturbNormalArb);var m=this.bumpMap.texture.flow(e,"t"),g=this.bumpMap.flow(e,"v3"),_=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",x="";x=4===this.bumpMap.projection.value?"\n vec3 bumpNormal = vec3(0.0);\n {\n vec2 uv0 = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs0;\n vec2 uv1 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs1;\n vec2 uv2 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs2;\n vec3 weights = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_triplanarWeights;\n\n vec2 grad0 = dHdxy(").concat(m.result,", uv0, ").concat(_,");\n vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n vec2 grad1 = dHdxy(").concat(m.result,", uv1, ").concat(_,");\n vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n vec2 grad2 = dHdxy(").concat(m.result,", uv2, ").concat(_,");\n vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n \n bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n bumpNormal = normalize(bumpNormal);\n }\n\n normal = bumpNormal;\n "):"\n vec2 bumpMapCachedUv = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs;\n vec2 grad = dHdxy(").concat(m.result,", bumpMapCachedUv, ").concat(_,");\n normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n "),v.push("// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n ".concat(g.result,";\n ").concat(x,"\n "))}v.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",o.code," float shininess = max( 0.0001, "+o.result+" );"," float specularStrength = 1.0;"),f&&v.push(f.code,"#ifdef ALPHATEST","if ( "+f.result+" <= ALPHATEST ) discard;","#endif"),v.push("material.diffuseColor = diffuseColor;"),v.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),v.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");var S="1.0";this.mask&&(this.mask.analyze(e),S="luminance(".concat(this.mask.flow(e,"v3").result,")")),v.push("\n if (outgoingLight != diffuseColor) {\n float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * ".concat(s.result," * ").concat(S," * lightAccu;\n outgoingLight = spe_blend( diffuseColor, outgoingLight, ").concat(s.result," * ").concat(S,", ").concat(l.result," );\n }\n ")),u&&v.push(u.code,"outgoingLight = spe_blend(outgoingLight, ".concat(u.result,", 1.0, SPE_BLENDING_NORMAL);")),f?v.push("gl_FragColor = vec4( outgoingLight, accumAlpha * ".concat(f.result," );")):v.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&v.push("gl_FragColor.a *= ".concat(p.result,";")),v.push("#include <colorspace_fragment>",a6,"#include <dithering_fragment>"),n=v.join("\n")}return n}}]),n}(k),rt=function(e){function n(){var e;return x(this,n),(e=_(this,n,["phong"])).nodeType="Phong",e.color=new eS(d.x),e.specular=new eS(1118481),e.shininess=new q(30),e.previousModelViewMatrix=new tU,e.previouseProjectionMatrix=new tU,e.shadingAlpha=new q(1),e.shadingBlend=new ey(0),e.occlusion=new tC(!0),e}return M(n,e),b(n,[{key:"category",get:function(){return"phong"}},{key:"build",value:function(e){var n;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){var t=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({resolution:aZ.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h.be.merge([eE.fog,eE.lights])),e.mergeUniform(a4),e.addParsCode("varying vec3 vViewPosition;\nvarying vec3 vWPosition;\n#include <fog_pars_vertex>\n#include <skinning_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <clipping_planes_pars_vertex>");var a=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #ifndef USE_LAYER_DISPLACE\n #include <defaultnormal_vertex>\n #endif\n\n vec3 displaced_position = position;\n vec3 displaced_normal = objectNormal;\n\n #ifdef USE_LAYER_DISPLACE\n vec3 transformed;\n vec3 transformedNormal;\n #endif\n ","#include <normal_vertex>","\n #ifndef USE_LAYER_DISPLACE\n #include <begin_vertex>\n #endif\n "];t&&a.push(t.code,t.result?"displaced_position = "+t.result+";":""),a.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),a.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),a.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),n=a.join("\n")}else{e.mergeUniform({penumbraSize:aZ.penumbraSize}),e.mergeUniform({frameIndex:aZ.frameIndex}),e.mergeUniform({aoMap:aZ.aoRenderTarget}),e.mergeUniform({aoEnabled:aZ.aoEnabled}),void 0===this.color&&(this.color=new eS(d.x)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);var r=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);var i=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),f=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,v=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==p,e.addParsCode(["varying vec3 vWPosition;\nuniform vec3 emissive;","uniform float penumbraSize[".concat(c.d,"];"),"uniform sampler2D aoMap;\nuniform bool aoEnabled;\n#include <normal_pars_fragment>",a5,"#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <dithering_pars_fragment>"].join("\n"));var m=["#include <normal_fragment_begin>","\n \n vec3 viewdx = dFdx(vViewPosition);\n vec3 viewdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(viewdx,viewdy));\n if (dot(normal, faceNormal) < 0.0) {\n normal *= -1.0;\n }\n "," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(a7.dHdxy),e.include(a7.perturbNormalArb);var g=this.bumpMap.texture.flow(e,"t"),_=this.bumpMap.flow(e,"v3"),x=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",S="";S=4===this.bumpMap.projection.value?"\n vec3 bumpNormal = vec3(0.0);\n {\n vec2 uv0 = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs0;\n vec2 uv1 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs1;\n vec2 uv2 = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs2;\n vec3 weights = g").concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_triplanarWeights;\n\n vec2 grad0 = dHdxy(").concat(g.result,", uv0, ").concat(x,");\n vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n vec2 grad1 = dHdxy(").concat(g.result,", uv1, ").concat(x,");\n vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n vec2 grad2 = dHdxy(").concat(g.result,", uv2, ").concat(x,");\n vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n \n bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n bumpNormal = normalize(bumpNormal);\n }\n\n normal = bumpNormal;\n "):"\n vec2 bumpMapCachedUv = g".concat(this.bumpMap.uuid.toString().replace(/-/g,""),"_writeUvs;\n vec2 grad = dHdxy(").concat(g.result,", bumpMapCachedUv, ").concat(x,");\n normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n "),m.push("// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n ".concat(_.result,";\n ").concat(S,"\n "))}m.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),p&&m.push(p.code,"#ifdef ALPHATEST","if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),m.push("material.diffuseColor = diffuseColor;"),m.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+r.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");var y="1.0";this.mask&&(this.mask.analyze(e),y="luminance(".concat(this.mask.flow(e,"v3").result,")")),m.push("\n if (outgoingLight != diffuseColor) {\n float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * ".concat(l.result," * ").concat(y," * lightAccu;\n outgoingLight = spe_blend( diffuseColor, outgoingLight, ").concat(l.result," * ").concat(y,", ").concat(u.result," );\n \n outgoingLight *= ao;\n }\n ")),f&&m.push(f.code,"outgoingLight = spe_blend(outgoingLight, ".concat(f.result,", 1.0, SPE_BLENDING_NORMAL);")),p?m.push("gl_FragColor = vec4( outgoingLight, accumAlpha * ".concat(p.result,");")):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),v&&m.push("gl_FragColor.a *= ".concat(v.result,";")),m.push("#include <colorspace_fragment>",a6,"#include <dithering_fragment>"),n=m.join("\n")}return n}}]),n}(k),ra=new Map;function rr(e,n){ra.set(e,n)}var ri=new Set;function ro(e,n){if(Array.isArray(n)){if(!Array.isArray(e)||e.length!==n.length)return!1;var t=!0,a=!1,r=void 0;try{for(var i,o=n.entries()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=L(i.value,2),l=s[0],c=s[1],u=e[l];if("string"==typeof c||"number"==typeof c&&"string"==typeof u)return!0}}catch(e){a=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(a)throw r}}return!1}var d="string"==typeof e,f="string"==typeof n;return d!==f||d&&f}function rs(e,n,t){var a=t.uniforms["f".concat(t.id,"_texture")];if(!a)return!1;var r=!1;if("image"in e){var i=e.image,o=n.image(i);C(a.image,c.n)||a.image.deref(),a.image=o}if("video"in e){var s=e.video,l=n.video(s);C(a.image,c.n)||a.image.deref(),a.image=l}if("wrapping"in e&&(a.wrap=e.wrapping),"minFilter"in e&&(a.minFilter=e.minFilter),"magFilter"in e&&(a.magFilter=e.magFilter),"rotation"in e&&t.uniforms["f".concat(t.id,"_rotation")])return t.uniforms["f".concat(t.id,"_rotation")].value=(null!=(p=(0,c._)(null!=(v=e.rotation)?v:0,n))?p:0)*h.Cc.DEG2RAD,r;if("repeat"in e||"offset"in e||"rotation"in e){var u=t.uniforms["f".concat(t.id,"_").concat("mat")];if(!u)return r;if("repeat"in e){var d=e.repeat;ro(t.data.texture.repeat,d)&&(r=!0),u.repeat=ru(d,n).map(function(e,n){return"string"==typeof d[n]?1/e:e})}if("offset"in e){var f=e.offset;ro(t.data.texture.offset,f)&&(r=!0),u.offset=ru(f,n).map(function(e,n){return"string"==typeof f[n]?-e:e})}if("rotation"in e){var p,v,m,g,_=t.data.texture.rotation,x=null!=(m=e.rotation)?m:0;(void 0===_||ro(_,x))&&(r=!0),u.rotation=null!=(g=(0,c._)(x,n))?g:0}u.updateMatrix()}return r}var rl=function(e,n){var t,a,r;return e||(e=new h.Fc),e.x=null!=(t=(0,c._)(e.x,n))?t:0,e.y=null!=(a=(0,c._)(e.y,n))?a:0,e.z=null!=(r=(0,c._)(e.z,n))?r:0,e},rc=function(e,n){var t,a;return e||(e=new h.Dc),e.x=null!=(t=(0,c._)(e.x,n))?t:0,e.y=null!=(a=(0,c._)(e.y,n))?a:0,e},ru=function(e,n){var t=e.map(function(e){var t;return null!=(t=(0,c._)(e,n))?t:0});return[t[0],t[1]]},rd=function(){function e(n,t,a,r,i){for(var o in x(this,e),this.id=n,this.uuid=t,this.data=a,this.uniforms={},r)this.uniforms["f".concat(this.id,"_").concat(o)]=r[o];for(var s in a)rm(s,this,a,i)}return b(e,[{key:"type",get:function(){return this.data.type}},{key:"updateByOp",value:function(e,n,t){var a=!1;if(void 0===e.path[0]){var r=!0,i=!1,o=void 0;try{for(var s,l=Object.keys(e.props)[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var u=s.value;try{var d=this.data[u],f=n[u];if(Array.isArray(d)&&Array.isArray(f)){var p=!0,v=!1,m=void 0;try{for(var g,_=f.entries()[Symbol.iterator]();!(p=(g=_.next()).done);p=!0){var x=L(g.value,2),y=x[0],b=x[1],w=d[y];if("string"==typeof b||"number"==typeof b&&"string"==typeof w){a=!0;break}}}catch(e){v=!0,m=e}finally{try{p||null==_.return||_.return()}finally{if(v)throw m}}if(a)break}else if("string"==typeof f&&"number"==typeof d||"number"==typeof f&&"string"==typeof d||"string"==typeof f&&"string"==typeof d&&f!==d){a=!0;break}}catch(e){console.error(e)}}}catch(e){i=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}if(0===e.type)return"type"in e.props||"category"in e.props||"visible"in e.props||"noiseType"in e.props?(t.scene.markNeedsUpdateRendererDirty(),!0):function(e,n,t,a){var r=!1,i=!0,o=!1,s=void 0;try{for(var l,u=Object.entries(e)[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var d=L(l.value,2),f=d[0],p=d[1];if("bumpMap"===f||"roughnessMap"===f){r=!0;continue}if(f&&void 0!==p){if(rm(f,t,a,n)){"visible"===f&&"light"===t.type&&(r=!0);continue}t.visible=a.visible;var v=t.uniforms["f".concat(t.id,"_").concat(f)];if(v&&!C(v,tA))switch(r=r||function(e,n,t){if("isMask"===n||"rainbow"===e.type&&"noiseStrength"===n&&void 0!==e.noiseCompiledIn&&(!0===e.noiseForced||(0,c.aa)(t))!==e.noiseCompiledIn)return!0;var a=c.ba[e.type],r=c.ca[e.type];if(void 0!==r){var i=e.color;if(r.includes(n)){var o,s,l=null==(s=i[n])||null==(o=s.value)?void 0:o.length;if(void 0!==l&&l!==t.length)return!0}}return void 0!==a&&a.includes(n)}(t,f,p),v.constructor){case eS:if("string"==typeof p){var m=n.getColor(p);m&&(v.value=m);break}C(v.value,c.j)?v.value=new c.i(p.r,p.g,p.b,p.a):v.setRGBA(p);break;case j:if("string"==typeof p){var g=n.getColor(p);g&&(v.value=g);break}C(v.value,c.j)?v.value=new c.i(p.r,p.g,p.b,p.a):v.value.setRGBA(p.r,p.g,p.b,p.a);break;case W:v.value.setX(p[0]),v.value.setY(p[1]);break;case X:v.value.setX(p[0]),v.value.setY(p[1]),v.value.setZ(p[2]);break;case ei:rs(p,n,t);break;case tO:v.value=p.map(function(e){return S(h.Jc,N(e))});break;default:v.value=p}}}}catch(e){o=!0,s=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw s}}return r}(e.props,t.shared,this,n)||a}else if("texture"===e.path[0])return!("texture"in n)&&!("video"in n)||rs(e.props,t.shared,this)||a;return a}},{key:"dispose",value:function(){if((0,c.$)(this)){var e=this.uniforms["f".concat(this.id,"_texture")];if(!e)return!1;C(e.image,c.n)||e.image.deref()}}},{key:"hasValueByKey",value:function(e){return void 0!==this.uniforms[e]}},{key:"hasValue",value:function(e){return this.hasValueByKey("f".concat(this.id,"_").concat(e))}},{key:"setValue",value:function(e,n){var t="f".concat(this.id,"_").concat(e);if(this.hasValueByKey(t)&&void 0!==n&&(this.uniforms[t].value=n,"noiseStrength"===e&&!1===this.noiseCompiledIn&&"number"==typeof n&&0!==n&&void 0!==this.onNoiseMismatch)){var a=this.onNoiseMismatch;this.onNoiseMismatch=void 0,a(n)&&(this.noiseCompiledIn=!0)}}},{key:"getNode",value:function(e){var n="f".concat(this.id,"_").concat(e);if(this.hasValueByKey(n))return this.uniforms[n]}},{key:"getValue",value:function(e){var n="f".concat(this.id,"_").concat(e);if(this.hasValueByKey(n))return this.uniforms[n].value}},{key:"getName",value:function(e){var n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log("Layer.getName: error ".concat(e))}},{key:"getNames",value:function(){var e=[];for(var n in this.uniforms){var t=this.getName(n);t&&e.push(t)}return e}}],[{key:"create",value:function(e,n,t,r,i){if("light"===t.type)return rh.createLightLayer(e,n,t,r);if("color"===t.type)return _=new er((g=new tz(v=new eS(null!=(p=(h=(0,a.f)(t,r)).color)?p:d.x),(m=rv(h)).alpha)).calpha,"f"),new rf(e,n,t,R({color:v},m),g,m.mode,_,m.isMask,r);var o,s,l,c,u,f,p,h,v,m,g,_,x,S=(x=t.type,ra.get(x));return S?S(e,n,t,r,i):(o=t.type,ri.has(o)||(ri.add(o),console.warn('[spe] Material layer type "'.concat(o,'" is not available in this runtime build (compiled out) — rendering flat red. Re-export the scene with its full layer set or load the full runtime build.'))),l=rv({alpha:"string"==typeof t.alpha?Number(null!=(s=r.getVariable(t.alpha))?s:100)/100:t.alpha,mode:t.mode,isMask:t.isMask}),f=new er((u=new tz(c=new eS(1,0,0,1),l.alpha)).calpha,"f"),new rf(e,n,t,R({color:c},l),u,l.mode,f,l.isMask,r))}}]),e}(),rf=function(e){function n(e,t,a,r,i,o,s,l,c){var u;return x(this,n),(u=_(this,n,[e,t,a,r,c])).params=r,u.color=i,u.mode=o,u.alpha=s,u.isMask=l,u}return M(n,e),n}(rd),rp=function(e){function n(e,t,a,r,i,o){var s;return x(this,n),(s=_(this,n,[e,t,a,r,o])).position=i,s}return M(n,e),n}(rd),rh=function(e){function n(e,t,a,r,i,o){var s;return x(this,n),(s=_(this,n,[e,t,a,i,o])).node=r,s}return M(n,e),b(n,[{key:"category",get:function(){return this.node.category}}],[{key:"createLightLayer",value:function(e,n,t,a){var r,i,o=new q((0,c.Z)(t.alpha,a)),s=new ey(t.mode),l=new q(t.bumpMapIntensity),u=new q((0,c.Z)(t.alphaOverride,a));if(t.visible)if("lambert"===t.category){r=new a9;var d,f,p=new eS(null!=(d=a.color(t.emissive))?d:0),h=new tC(null==(f=t.occlusion)||f);i={emissive:p,occlusion:h},r.emissive=p,r.occlusion=h}else if("toon"===t.category){r=new rn;var v,m,g=new q(null!=(v=t.shininess)?v:30),_=new eS(null!=(m=a.color(t.specular))?m:1118481);i={shininess:g,specular:_},r.shininess=g,r.specular=_}else if("physical"===t.category){r=new re;var x,S,y,b,w=new q(null!=(x=t.roughness)?x:.3),T=new q(null!=(S=t.metalness)?S:0),E=new q(null!=(y=t.reflectivity)?y:.5),M=new tC(null==(b=t.occlusion)||b);i={roughness:w,metalness:T,reflectivity:E,occlusion:M},r.roughness=w,r.metalness=T,r.reflectivity=E,r.occlusion=M}else{r=new rt;var C,R,A,P=new q(null!=(C=t.shininess)?C:30),D=new eS(void 0!==t.specular&&null!=(R=a.color(t.specular))?R:1118481),L=new tC(null==(A=t.occlusion)||A);i={shininess:P,specular:D,occlusion:L},r.shininess=P,r.specular=D,r.occlusion=L}else r=new a8,i={};return r.alpha=new q(1),r.shadingAlpha=o,r.shadingBlend=s,r.bumpMapIntensity=l,r.alphaOverride=u,i.alpha=r.shadingAlpha,i.mode=r.shadingBlend,i.bumpMapIntensity=r.bumpMapIntensity,i.alphaOverride=r.alphaOverride,new rh(e,n,t,r,i,a)}}]),n}(rd);function rv(e){var n,t,a;return{alpha:new q(null!=(n=e.alpha)?n:1),mode:new ey(null!=(t=e.mode)?t:0),isMask:new tC(null!=(a=e.isMask)&&a)}}function rm(e,n,t,a){if("displace"===t.type&&("intensity"===e||"visible"===e)){var r,i=n.uniforms["f".concat(n.id,"_intensity")];return i?(i.value=(null!=(r=(0,c._)(t.intensity,a))?r:1)*!!t.visible,i):void 0}if("displace"!==t.type&&("alpha"===e||"visible"===e)){var o=n.uniforms["f".concat(n.id,"_alpha")];if(!o)return;if(o.value=(0,c.Z)(t.alpha,a)*!!t.visible,"outline"===t.type&&"visible"===e){var s=n.uniforms["f".concat(n.id,"_compensation")];s&&(s.value=t.compensation&&t.visible)}return o}}function rg(e,n,t,a,r,i){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[],s=t,l=!0,c=!1,u=void 0;try{for(var d,f=o[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var p=d.value;p in s&&(s=s[p])}}catch(e){c=!0,u=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw u}}var h=!0,v=!1,m=void 0;try{for(var g,_=e[Symbol.iterator]();!(h=(g=_.next()).done);h=!0){var x=g.value;x in s&&r.getVariable(s[x],["material",i,"layer",a].concat(N(o),[String(x)]))}}catch(e){v=!0,m=e}finally{try{h||null==_.return||_.return()}finally{if(v)throw m}}var S=!0,y=!1,b=void 0;try{for(var w,T=n[Symbol.iterator]();!(S=(w=T.next()).done);S=!0)!function(){var e=w.value;e in s&&s[e].forEach(function(n,t){r.getVariable(n,["material",i,"layer",a].concat(N(o),[String(e),0===t?"x":1===t?"y":"z"]))})}()}catch(e){y=!0,b=e}finally{try{S||null==T.return||T.return()}finally{if(y)throw b}}}var r_=function(e){function n(){var e;return x(this,n),(e=_(this,n,[void 0])).isClassicNodeMaterial=!0,e.flatShading=!1,e.needsJitter=!0,e.shadersPatchedForShapeBlend=!1,e.depthPrepass=!1,e.depthPrepassTwins=[],e.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},e.nodeContextUuid=0,e.fog=!0,e.dithering=!0,e.vertexColors=!0,e.transparent=!0,e}return M(n,e),b(n,[{key:"applyDepthPrepassPolicy",value:function(){var e,n=(0,a.b)({transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:void 0!==(null==(e=this.defines)?void 0:e.SHAPEBLEND),data:this.data});this.depthPrepass=n,this.depthWrite=!n}},{key:"customProgramCacheKey",value:function(){return""}}]),n}(h.ce),rx=!1,rS=function(e){function n(e,t,a,r){var i;return x(this,n),(i=_(this,n)).flatShading=e,i.side=t,i.wireframe=a,i.root=r,i}return M(n,e),b(n,[{key:"updateAfterBuild",value:function(){var e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.nodeExtensions=e.nodeExtensions,this.transparent=e.transparent,this.applyDepthPrepassPolicy(),this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}},{key:"getDepthPrepassTwin",value:function(e){return rb(this,this.root,e)}},{key:"onBeforeCompile",value:function(e,n){this.root.onBeforeCompile(e)}},{key:"data",get:function(){return this.root.data}},{key:"category",get:function(){return this.root.category}},{key:"hasAO",get:function(){return this.root.hasAO}},{key:"getFlavor",value:function(e,n,t,a){return this.root.getFlavor(e,n,t,a)}},{key:"layers",get:function(){return this.root.layers}},{key:"fragment",get:function(){return this.root.fragment}},{key:"getLayersOfType",value:function(e){return this.root.getLayersOfType(e)}},{key:"getLayerByUuid",value:function(e){return this.root.getLayerByUuid(e)}},{key:"setTransparent",value:function(e,n){this.root.setTransparent(e,n)}},{key:"ensureRainbowNoiseCompiled",value:function(e,n){return this.root.ensureRainbowNoiseCompiled(e,n)}},{key:"updateByOp",value:function(e,n,t){this.root.updateByOp(e,n,t)}},{key:"nodeMaterialDispose",value:function(){this.root.nodeMaterialDispose()}}]),n}(r_),ry=function(e){function n(e,t,a){var r;return x(this,n),(r=_(this,n,[e,t,!1,a])).isDepthPrepassMaterial=!0,r.cutoffUniform={value:c.g},r.colorWrite=!1,r.depthWrite=!0,r}return M(n,e),b(n,[{key:"updateAfterBuild",value:function(){T(E(n.prototype),"updateAfterBuild",this).call(this),this.uniforms.alphaDiscardCutoff=this.cutoffUniform,this.colorWrite=!1,this.depthWrite=!0}},{key:"onBeforeCompile",value:function(e,t){T(E(n.prototype),"onBeforeCompile",this).call(this,e,t),e.uniforms=this.uniforms}},{key:"applyDepthPrepassPolicy",value:function(){this.depthPrepass=!1}},{key:"getDepthPrepassTwin",value:function(){return this}}]),n}(rS);function rb(e,n,t){var a=e.depthPrepassTwins[t];return void 0===a&&((a=new ry(e.flatShading,t,n)).needsJitter=n.needsJitter,a.updateAfterBuild(),e.depthPrepassTwins[t]=a,n.depthTwins.push(a)),a}var rw=function(e){function n(e,t){var a,r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return x(this,n),(a=_(this,n)).data=e,a.allowVariableSaves=r,a.layerIdGen=0,a.flavors=[],a.depthTwins=[],a.masks={},a.type="NodeMaterial",a.forceRainbowNoise=new Set,a.syntheticMapLayers=new Map,a.updaters=[],a.needsJitter=t.shared.needsJitter,k.startContext(a),a.reset0(e,t),k.endContext(a),a}return M(n,e),b(n,[{key:"setTransparent",value:function(e,n){var t=this.transparent!==e;if(t){this.transparent=e,this.needsUpdate=!0;var a=!0,r=!1,i=void 0;try{for(var o,s=this.flavors[Symbol.iterator]();!(a=(o=s.next()).done);a=!0){var l=o.value;void 0!==l&&(l.transparent=e,l.needsUpdate=!0)}}catch(e){r=!0,i=e}finally{try{a||null==s.return||s.return()}finally{if(r)throw i}}var c=!0,u=!1,d=void 0;try{for(var f,p=this.depthTwins[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var h=f.value;h.transparent=e,h.needsUpdate=!0}}catch(e){u=!0,d=e}finally{try{c||null==p.return||p.return()}finally{if(u)throw d}}}this.applyDepthPrepassPolicy();var v=!0,m=!1,g=void 0;try{for(var _,x=this.flavors[Symbol.iterator]();!(v=(_=x.next()).done);v=!0){var S=_.value;null==S||S.applyDepthPrepassPolicy()}}catch(e){m=!0,g=e}finally{try{v||null==x.return||x.return()}finally{if(m)throw g}}t&&(null==n||n.markNeedsUpdateRendererDirty())}},{key:"getDepthPrepassTwin",value:function(e){return rb(this,this,e)}},{key:"nodeMaterial",get:function(){return this}},{key:"getFlavor",value:function(e,n,t,a){var r,i=t?6:3*!!e+n;if(0===(i+=7*((null!=(r=null==a?void 0:a.resolutionLevel)?r:0)-4*(null!=a&&!!a.useChildrenColors))))return this;void 0===this.flavors&&(this.flavors=[]),i-=1;var o=this.flavors[i];return void 0===o&&((o=new rS(e,n,t,this)).needsJitter=this.needsJitter,this.flavors[i]=o,o.flatShading=e,o.side=n,o.updateAfterBuild(),a&&(o.defines.SHAPEBLEND=a.resolutionLevel,o.defines.SHAPEBLEND_C=+!!a.useChildrenColors,o.applyDepthPrepassPolicy())),o}},{key:"fragment",get:function(){return this.lightLayer.node}},{key:"category",get:function(){return this.lightLayer.category}},{key:"hasAO",get:function(){var e,n;return null!=(e=null==(n=this.lightLayer.getNode("occlusion"))?void 0:n.value)&&e}},{key:"ensureRainbowNoiseCompiled",value:function(e,n){var t,a,r,i=null==(t=this.data.layers)?void 0:t.data(e);return void 0!==i&&"rainbow"===i.type&&(!this.forceRainbowNoise.has(e)&&!(0,c.aa)(i.noiseStrength)||!1===(null==(a=this.getLayerByUuid(e))?void 0:a.noiseCompiledIn))&&(this.forceRainbowNoise.add(e),k.startContext(this),this.reset0(this.data,this.lastContext),k.endContext(this),void 0!==n&&(null==(r=this.getLayerByUuid(e))||r.setValue("noiseStrength",n)),!0)}},{key:"reset",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];k.startContext(this),(this.data!==e||t)&&this.reset0(e,n),k.endContext(this)}},{key:"reset0",value:function(e,n){var t=this;this.lastContext=n,this.data=e;var a=null!=(l=e.layers)?l:d.ea.defaultTwoLayerData("phong").layers,r=[],i=!0,o=!1,s=void 0;try{for(var l,u,f,p,h=a[Symbol.iterator]();!(i=(p=h.next()).done);i=!0)f=this,function(){var e=p.value;try{var a=rd.create(f.layerIdGen++,e.id,e.data,n.shared,f.forceRainbowNoise.has(e.id)?{forceRainbowNoise:!0}:void 0);if("rainbow"===a.type&&!1===a.noiseCompiledIn){var i=e.id;a.onNoiseMismatch=function(e){return t.ensureRainbowNoiseCompiled(i,e)}}r.push(a)}catch(n){console.warn("[spe] material layer '".concat(e.data.type,"' (").concat(e.id,") failed to build — skipping this layer"),n)}}()}catch(e){o=!0,s=e}finally{try{i||null==h.return||h.return()}finally{if(o)throw s}}this.layers=r,this.layers.reverse(),this.name=null!=(u=e.name)?u:"Untitled Material",this.onUpdate(n.shared),this.setTransparent((0,c.Y)(e,n.shared),n.scene),this.saveVariableLocations(n)}},{key:"onVariableUpdate",value:function(e,n,t){if("alphaOverride"===e[0])this.setTransparent((0,c.Y)(this.data,t.shared),t.scene),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(n)/100,1)));else if("layer"===e[0]){var a=e[1],r=e[2];if(a&&r){var i=this.layers.find(function(e){return e.uuid===a});if(null==i?void 0:i.hasValue(r))if("alpha"===r)this.setTransparent((0,c.Y)(this.data,t.shared),t.scene),i.setValue(r,Math.max(0,Math.min(Number(n)/100,1)));else{var o=i.getValue(r),s=e[3],l=e[4];if(C(o,h.Ic)){var u,d=o[s];return"number"==typeof d?u=Number(n):d.isVector2&&(u=d.toArray(),"x"===l?u[0]=Number(n):"y"===l&&(u[1]=Number(n))),void rs(w({},s,u),t.shared,i)}("x"===s||"y"===s||"z"===s)&&o.isVector3||("x"===s||"y"===s)&&o.isVector2?o[s]=Number(n):i.setValue(r,n)}}}}},{key:"saveVariableLocations",value:function(e){var n,t,a=this;if(this.allowVariableSaves){var r=null==(n=this.data.layers)?void 0:n.find(function(e){return"light"===e.data.type});r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),null==(t=this.data.layers)||t.forEach(function(n){"alpha"in n.data&&"string"==typeof n.data.alpha&&e.shared.getVariable(n.data.alpha,["material",a.uuid,"layer",n.id,"alpha"]),"displace"===n.data.type?"noise"===n.data.displacementType?rg(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],n.data,n.id,e.shared,a.uuid):rg(["intensity"],[],n.data,n.id,e.shared,a.uuid):"depth"===n.data.type?rg(["near","far"],["origin","direction"],n.data,n.id,e.shared,a.uuid):"cavity"===n.data.type?rg(["ridge","valley"],[],n.data,n.id,e.shared,a.uuid):"fresnel"===n.data.type?rg(["bias","scale","intensity","factor"],[],n.data,n.id,e.shared,a.uuid):"dust"===n.data.type?rg(["coverage","softness","noiseStrength","noiseScale"],[],n.data,n.id,e.shared,a.uuid):"rainbow"===n.data.type?rg(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],n.data,n.id,e.shared,a.uuid):"noise"===n.data.type?rg(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],n.data,n.id,e.shared,a.uuid):"pattern"===n.data.type?rg(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],n.data,n.id,e.shared,a.uuid):"outline"===n.data.type?rg(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],n.data,n.id,e.shared,a.uuid):"toon"===n.data.type?rg(["noiseStrength","noiseScale"],["offset","source"],n.data,n.id,e.shared,a.uuid):"transmission"===n.data.type?rg(["roughness","thickness","ior"],[],n.data,n.id,e.shared,a.uuid):"texture"===n.data.type||"video"===n.data.type?(rg([],["size"],n.data,n.id,e.shared,a.uuid),rg(["rotation"],["repeat","offset"],n.data,n.id,e.shared,a.uuid,["texture"])):"gradient"===n.data.type?rg(["angle"],["offset","morph"],n.data,n.id,e.shared,a.uuid):"matcap"===n.data.type&&rg(["rotation"],[],n.data,n.id,e.shared,a.uuid,["texture"])})}}},{key:"getLayersOfType",value:function(e){return this.layers.filter(function(n){return n.type===e})}},{key:"getLayerByUuid",value:function(e){return this.layers.find(function(n){return n.uuid===e})}},{key:"onUpdate",value:function(e){this.lightLayer=this.layers.find(function(e){return C(e,rh)}),void 0===this.lightLayer&&(this.lightLayer=new rh(0,"",A(R({},d.da.defaultData("light","phong")),{visible:!1}),new a8,{},e)),this.dispose();var n=!0,t=!1,a=void 0;try{for(var r,i=this.flavors[Symbol.iterator]();!(n=(r=i.next()).done);n=!0){var o=r.value;o&&o.dispose()}}catch(e){t=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(t)throw a}}var s=!0,l=!1,c=void 0;try{for(var u,f=this.depthTwins[Symbol.iterator]();!(s=(u=f.next()).done);s=!0)u.value.dispose()}catch(e){l=!0,c=e}finally{try{s||null==f.return||f.return()}finally{if(l)throw c}}this.applyTextureMaps(e),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}},{key:"syntheticMapNode",value:function(e,n){var t=this.syntheticMapLayers.get(e);if(void 0===t)try{var a,r,i,o,s,l=d.da.defaultData("texture"),c=A(R({},l),{visible:!1,texture:A(R({},l.texture),{image:e.image,wrapping:null!=(a=e.wrapping)?a:1e3,offset:null!=(r=e.offset)?r:[0,0],repeat:null!=(i=e.repeat)?i:[1,1],minFilter:null!=(o=e.minFilter)?o:1008,magFilter:null!=(s=e.magFilter)?s:1006})});t=rd.create(this.layerIdGen++,"mapImage".concat(this.layerIdGen),c,n),this.syntheticMapLayers.set(e,t)}catch(e){return void console.warn("[spe] light-layer map image failed to build — skipped",e)}var u=t.color;return C(u,tV)?u:void 0}},{key:"applyTextureMaps",value:function(e){var n=this.layers.find(function(e){return C(e,rh)});if(n){var t=n.data,a=t.bumpMap,r=t.roughnessMap;n.node.bumpMap=void 0,n.node.roughnessMap=void 0;var i=!0,o=!1,s=void 0;try{for(var l,c=this.syntheticMapLayers.values()[Symbol.iterator]();!(i=(l=c.next()).done);i=!0)l.value.dispose()}catch(e){o=!0,s=e}finally{try{i||null==c.return||c.return()}finally{if(o)throw s}}this.syntheticMapLayers.clear(),d.V.is(a)&&(n.node.bumpMap=this.syntheticMapNode(a,e)),d.V.is(r)&&(n.node.roughnessMap=this.syntheticMapNode(r,e)),!rx&&(void 0!==t.metalnessMap||void 0!==t.normalMap||void 0!==t.aoMap||void 0!==t.emissiveMap||void 0!==t.roughnessMapChannel&&"luminance"!==t.roughnessMapChannel||void 0!==t.clearcoat||void 0!==t.sheen||void 0!==t.ior||void 0!==t.iridescence||void 0!==t.emissive&&"object"==I(t.emissive)&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0))&&(rx=!0,console.warn("[spline] this document uses PBR material maps (metalness/normal/AO/emissive), which the classic WebGL pipeline does not render — the WebGPU renderer shows them"));for(var u=0;u<this.layers.length;++u){var f=this.layers[u];C(f,rf)&&C(f.color,tV)&&(f.uuid===a&&(n.node.bumpMap=f.color),f.uuid===r&&(n.node.roughnessMap=f.color))}}}},{key:"updateByOp",value:function(e,n,t){if(k.startContext(this),void 0!==n?this.data=n:n=this.data,this.setTransparent((0,c.Y)(n,t.shared),t.scene),"layers"===e.path[0]){var a=t.shared,r=e.path[1];if(void 0===r)t.scene.markNeedsUpdateRendererDirty(),this.reset0(n,t);else{0===e.type&&void 0!==e.props.occlusion&&t.scene.markNeedsUpdateRendererDirty();var i=this.layers.find(function(e){return e.uuid===r});if(i){var o,s=n.layers.data(r);0===e.type&&("alpha"in e.props||"alphaOverride"in e.props)&&(o="alpha"in e.props?A(R({},e.props),{alpha:(0,c.Z)(e.props.alpha,a,["material",this.uuid,"layer",r,"alpha"])}):A(R({},e.props),{alphaOverride:(0,c.Z)(e.props.alphaOverride,a,["material",this.uuid,"alphaOverride"])})),i.updateByOp(A(R({},e,o?{props:o}:{}),{path:e.path.slice(2)}),s,t)&&this.reset0(n,t)}}}else this.reset0(n,t);k.endContext(this)}},{key:"applyMasks",value:function(){for(var e=0;e<this.layers.length;++e){var n=this.layers[e];C(n,rf)?n.color.mask=void 0:C(n,rh)&&(n.node.mask=void 0)}for(var t=0;t<this.layers.length;++t){var a=this.layers[t];if(C(a,rf)&&a.isMask.value&&a.data.visible&&t>0){var r=t-1,i=this.layers[r];C(i,rh)?i.node.mask=new es(a.color,a.alpha,es.MUL):C(i,rf)&&(i.isMask.value||(i.color.mask=new es(a.color,a.alpha,es.MUL)))}}}},{key:"blendColors",value:function(){var e=this.layers.findIndex(function(e){return C(e,rf)}),n=this.layers.findIndex(function(e){return C(e,rh)});if(-1!==e&&e<n){for(var t=this.layers[e].color,a=e+1;a<n;++a){var r=this.layers[a];if(C(r,rf)){if(r.isMask.value)continue;t=new tF(t,r.color,r.alpha,r.mode)}}this.fragment.color=t}else this.fragment.color=void 0}},{key:"blendAfterColors",value:function(){var e=new er("outgoingLight","f"),n=this.layers.findIndex(function(e){return C(e,rh)});if(this.layers.length>n+1){for(var t=n+1;t<this.layers.length;++t){var a=this.layers[t];if(C(a,rf)){if(a.isMask.value)continue;e=new tF(e,a.color,a.alpha,a.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}},{key:"blendPositions",value:function(){var e=this.layers.filter(function(e){return C(e,rp)});if(e.length>0){for(var n=e[0].position,t=1;t<e.length;++t)e[t]&&(n=new es(n,e[t].position,es.ADD),n=new es(n,new q(.5).setReadonly(!0),es.MUL));this.fragment.position=n}else this.fragment.position=void 0}},{key:"getDefines",value:function(){return this.defines}},{key:"getUniforms",value:function(){return this.uniforms}},{key:"getVertexShader",value:function(){return this.vertexShader}},{key:"getFragmentShader",value:function(){return this.fragmentShader}},{key:"onBeforeCompile",value:function(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=!0===this.nodeExtensions.derivatives,e.extensionFragDepth=!0===this.nodeExtensions.fragDepth,e.extensionDrawBuffers=!0===this.nodeExtensions.drawBuffers,e.extensionShaderTextureLOD=!0===this.nodeExtensions.shaderTextureLOD}},{key:"clampUniformsForPreview",value:function(e,n){var t=!0,a=!1,r=void 0;try{for(var i,o=this.layers[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;if("displace"===s.type){var l,c=(l=s.uniforms["f".concat(s.id,"_intensity")].value,Math.min(Math.max(l,e),n));s.uniforms["f".concat(s.id,"_intensity")].value=c}}}catch(e){a=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(a)throw r}}}},{key:"updateFrame",value:function(e){for(var n=0;n<this.updaters.length;++n)e.updateNode(this.updaters[n])}},{key:"build",value:function(){var e=new ex;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.nodeExtensions=e.extensions,this.updaters=e.updaters;var n=!0,t=!1,a=void 0;try{for(var r,i=this.flavors[Symbol.iterator]();!(n=(r=i.next()).done);n=!0){var o=r.value;o&&o.updateAfterBuild()}}catch(e){t=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(t)throw a}}var s=!0,l=!1,c=void 0;try{for(var u,d=this.depthTwins[Symbol.iterator]();!(s=(u=d.next()).done);s=!0)u.value.updateAfterBuild()}catch(e){l=!0,c=e}finally{try{s||null==d.return||d.return()}finally{if(l)throw c}}return this.shadersPatchedForShapeBlend=!1,this}},{key:"nodeMaterialDispose",value:function(){this.layers.forEach(function(e){return e.dispose()});var e=!0,t=!1,a=void 0;try{for(var r,i=this.syntheticMapLayers.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)r.value.dispose()}catch(e){t=!0,a=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw a}}this.syntheticMapLayers.clear(),T(E(n.prototype),"dispose",this).call(this);var o=!0,s=!1,l=void 0;try{for(var c,u=this.depthTwins[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)c.value.dispose()}catch(e){s=!0,l=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}var d=!0,f=!1,p=void 0;try{for(var h,v=this.flavors[Symbol.iterator]();!(d=(h=v.next()).done);d=!0){var m=h.value;m&&m.dispose()}}catch(e){f=!0,p=e}finally{try{d||null==v.return||v.return()}finally{if(f)throw p}}}},{key:"assetsLoaded",value:function(){var e=!0,n=!1,t=void 0;try{for(var a,r=this.layers[Symbol.iterator]();!(e=(a=r.next()).done);e=!0){var i=a.value;if(C(i,rf)){var o=i.params.texture;if(C(o,tD)&&!o.image.loaded)return!1}}}catch(e){n=!0,t=e}finally{try{e||null==r.return||r.return()}finally{if(n)throw t}}var s=!0,l=!1,c=void 0;try{for(var u,d=this.syntheticMapLayers.values()[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){var f,p=null==(f=u.value.params)?void 0:f.texture;if(C(p,tD)&&!p.image.loaded)return!1}}catch(e){l=!0,c=e}finally{try{s||null==d.return||d.return()}finally{if(l)throw c}}return!0}}]),n}(r_);Object.defineProperties(r_.prototype,{properties:{get:function(){return this.fragment.properties}}});var rT=function(e){function n(e,t,a){var r;return x(this,n),(r=_(this,n,[e,t,!1])).isClassicSharedMaterial=!0,r.uuid=a,r.allowVariableSaves=!0,r.saveVariableLocations(t),r}return M(n,e),n}(rw),rE="\nvec2 receiverPlaneDepthBias(vec3 dcdx, vec3 dcdy)\n{\n float det = dcdx.x * dcdy.y - dcdx.y * dcdy.x;\n \n \n float invDet = 1.0 / (abs(det) < 1e-10 ? (det < 0.0 ? -1e-10 : 1e-10) : det);\n return vec2(\n (dcdy.y * dcdx.z - dcdx.y * dcdy.z) * invDet,\n (dcdx.x * dcdy.z - dcdy.x * dcdx.z) * invDet\n );\n}\n\n\n\n\nfloat receiverPlaneAdjust(vec2 dzduv, vec2 offset)\n{\n return clamp(dot(dzduv, offset), -0.05, 0.05);\n}\n",rM=globalThis,rC=null!=(ak=rM.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__)?ak:rM.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__=eT.lights_fragment_begin,rR=null!=(aB=rM.__SPE_ORIGINAL_SHADOWMASK_PARS__)?aB:rM.__SPE_ORIGINAL_SHADOWMASK_PARS__=eT.shadowmask_pars_fragment,rA=null!=(aV=rM.__SPE_ORIGINAL_SHADOWMAP_PARS__)?aV:rM.__SPE_ORIGINAL_SHADOWMAP_PARS__=eT.shadowmap_pars_fragment,rP=null,rD=function(){var e=rA.replaceAll("vogelDiskSample","spStockVogelDiskSample").replaceAll("interleavedGradientNoise","spStockInterleavedGradientNoise"),n=e.indexOf("#if defined( SHADOWMAP_TYPE_PCF )"),t=e.indexOf("#elif defined( SHADOWMAP_TYPE_VSM )");if(n<0||t<=n)return e;var a=e.slice(n,t),r=a.replace(/texture\( shadowMap, vec3\( shadowCoord\.xy \+ spStockVogelDiskSample\( ([0-4]), 5, phi \) \* radius, shadowCoord\.z \) \)/g,"texture( shadowMap, vec3( shadowCoord.xy + spStockOffset$1, shadowCoord.z + receiverPlaneAdjust( spStockDzduv, spStockOffset$1 ) ) )"),i="float phi = spStockInterleavedGradientNoise( gl_FragCoord.xy ) * PI2;";return r!==a&&r.includes(i)?(a=(a=r.replace(i,i+"\n vec2 spStockDzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n vec2 spStockOffset0 = spStockVogelDiskSample( 0, 5, phi ) * radius;\n vec2 spStockOffset1 = spStockVogelDiskSample( 1, 5, phi ) * radius;\n vec2 spStockOffset2 = spStockVogelDiskSample( 2, 5, phi ) * radius;\n vec2 spStockOffset3 = spStockVogelDiskSample( 3, 5, phi ) * radius;\n vec2 spStockOffset4 = spStockVogelDiskSample( 4, 5, phi ) * radius;")).replace("#if defined( SHADOWMAP_TYPE_PCF )",rE+"\n#if defined( SHADOWMAP_TYPE_PCF )"),e.slice(0,n)+a+e.slice(t)):e},rL="\n\n // Linear Fade In\n float linearFadeIn(float t) {\n return t;\n }\n\n\n // linear fade out\n float linearFadeOut(float t) {\n return 1.0 - t;\n }\n \n float linearInOut(float t) {\n return t < 0.5 ? t : (1.0 - t); \n }\n\n // lerp\n float lerp(float a, float b, float t) {\n return a + (b - a) * t;\n }\n\n // Ease In Out Quart\n float exponentialInOut(float t) {\n return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) :\n t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) :\n 1.0;\n }\n\n // constant\n float constant(float t) {\n return 1.0;\n } \n",rU="\n uniform sampler2D uPosition;\n uniform float uSize;\n uniform float uSizeEnd;\n uniform vec3 uWorldOffset;\n uniform vec4 uWorldQuaternion;\n \n uniform float uRotation;\n uniform float uRotationEnd;\n uniform vec2 center;\n\n \n uniform float uRandScaleFactor;\n uniform float uRandRotationFactor;\n\n attribute vec2 ref;\n\n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n \n\nfloat rand(vec3 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n}\n\nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n}\n\n ".concat(rL,"\n"),rN="\n uniform vec4 uColor; \n uniform vec4 uColor2; \n uniform sampler2D uTexture; \n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n float random(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n }\n "+rL+" \n \nvec3 rgb2xyz (in vec3 rgb) {\n float r = rgb.r;\n float g = rgb.g;\n float b = rgb.b;\n\n r = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n g = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n b = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n float x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n float y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n float z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n \n vec3 xyz = vec3(\n (r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0,\n (r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0,\n (r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0\n );\n return(xyz);\n}\n\nvec3 xyz2lab (in vec3 xyz) {\n float x = xyz.x / 95.047;\n float y = xyz.y / 100.0;\n float z = xyz.z / 108.883;\n\n x = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0);\n y = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0);\n z = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0);\n\n vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z));\n return(lab);\n}\n\nvec3 rgb2lab(in vec3 rgb) {\n vec3 xyz = rgb2xyz(rgb);\n vec3 lab = xyz2lab(xyz);\n return(lab);\n}\n\nvec3 xyz2rgb (in vec3 xyz) {\n float x = xyz.x / 100.0;\n float y = xyz.y / 100.0;\n float z = xyz.z / 100.0;\n \n \n float r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n float g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n float b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n r = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92;\n g = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92;\n b = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92;\n\n r = min(max(0.0, r), 1.0);\n g = min(max(0.0, g), 1.0);\n b = min(max(0.0, b), 1.0);\n\n return(vec3(r, g, b));\n}\n\nvec3 lab2xyz (in vec3 lab) {\n float l = lab.x;\n float a = lab.y;\n float b = lab.z;\n\n float y = (l + 16.0) / 116.0;\n float x = a / 500.0 + y;\n float z = y - b / 200.0;\n\n float y2 = pow(y, 3.0);\n float x2 = pow(x, 3.0);\n float z2 = pow(z, 3.0);\n\n y = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787;\n x = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787;\n z = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787;\n\n x *= 95.047;\n y *= 100.0;\n z *= 108.883;\n\n return(vec3(x, y, z));\n}\nvec3 lab2rgb (in vec3 lab) {\n vec3 xyz = lab2xyz(lab);\n vec3 rgb = xyz2rgb(xyz);\n return(rgb);\n}\n\n\n\n",rI=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n)).needsJitter=!0,a.type="ParticleMaterial",a.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},a.easeOpacity="linearFadeIn",a.easeSize="linearFadeIn",a.useSizeEnd=!1,a.isColoringRandom=!1,a.init(e,t),a.context=t,a}return M(n,e),b(n,[{key:"reset",value:function(){}},{key:"init",value:function(e,n){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],k.startContext(k.globalContext),this.lightLayer=new rh(0,"",A(R({},d.da.defaultData("light","phong")),{visible:!1}),new a8,{},n.shared),k.endContext(k.globalContext),this.build()}},{key:"updateState",value:function(e){void 0!==e.coloring&&(this.isColoringRandom="random"===e.coloring),void 0!==e.color&&(C(e.color,Array)?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),void 0!==e.color2&&(C(e.color2,Array)?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),void 0!==e.size&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),void 0!==e.ease&&(this.easeOpacity=e.ease,this.build()),void 0!==e.easeSize&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}},{key:"onBeforeCompile",value:function(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}},{key:"build",value:function(){var e,n,t=new ex;return t.needsJitter=this.needsJitter,t.addFragmentParsCode("\nlayout(location = 1) out vec4 gVelocity;\n"),t.buildShader("vertex",this.fragment),t.buildShader("fragment",this.fragment),t.addFragmentFinalCode("\n \n if (gl_FragColor.a <= 0.0) discard;\n\n gVelocity = vec4(0.0, 0.0, 0.0, 1.0);\n"),this.isColoringRandom&&t.define("USE_RANDOM_COLORING"),this.useSizeEnd&&t.define("USE_SIZE_END"),t.addVertexParsCode(rU),t.addFragmentParsCode(rN),t.addVertexFinalCode((e=({easeSize:this.easeSize}).easeSize,"\n vUv = uv; \n vRef = ref;\n \n float lifeLeft = texture2D(uPosition, ref).w;\n v_LifeLeft = lifeLeft;\n \n vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset;\n \n pos = applyQuaternionToVector(uWorldQuaternion, pos); \n \n #ifdef USE_SIZE_END\n \n float t = 1. - lifeLeft;\n float currentSize = mix(uSize, uSizeEnd, t); \n vec3 scaledPosition = position * vec3(currentSize);\n #else\n \n float easeSize = ".concat(void 0===e?"linearFadeOut":e,"(1. - lifeLeft);\n \n vec3 scaledPosition = position * vec3(uSize * easeSize);\n #endif\n\n \n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); \n \n float randRef = rand(ref);\n scale *= (1.0 - (uRandScaleFactor * randRef));\n \n float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef);\n float originalRotation = (1.0 - uRotation) * 2.0 * PI;\n float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI;\n \n float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft);\n\n vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y;\n rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y;\n \n mat4 instanceMatrix = mat4(\n vec4(1.0, 0.0, 0.0, 0.0),\n vec4(0.0, 1.0, 0.0, 0.0),\n vec4(0.0, 0.0, 1.0, 0.0),\n vec4(pos.x, pos.y, pos.z, 1.0)\n ); \n\n mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition; \n"))),t.addFragmentFinalCode((n=({easeOpacity:this.easeOpacity}).easeOpacity," \n \n if (v_LifeLeft <= 0.005 ) {\n discard;\n }\n\n #ifdef USE_RANDOM_COLORING\n float randVal = random(vRef); \n vec4 color = mix(uColor, uColor2, randVal); \n #else\n vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft);\n #endif\n\n \n float finalAlpha = ".concat(void 0===n?"linearFadeOut":n,"(1. - v_LifeLeft); \n vec4 textureColor = texture2D(uTexture, vUv).rgba; \n finalColor = textureColor.rgb * color.rgb;\n finalAlpha = color.a * textureColor.a * finalAlpha;\n \n gl_FragColor = vec4(finalColor, finalAlpha); \n\n"))),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=R({},t.uniforms,this.uniforms),this.nodeExtensions=t.extensions,this}},{key:"nodeMaterial",get:function(){return this}},{key:"fragment",get:function(){return this.lightLayer.node}},{key:"getDefines",value:function(){return this.defines}},{key:"nodeMaterialDispose",value:function(){this.layers.forEach(function(e){return e.dispose()}),T(E(n.prototype),"dispose",this).call(this)}}]),n}(h.ce),rO=new h.Ae(-1,1,1,-1,0,1),rF=new(function(e){function n(){var e;return x(this,n),(e=_(this,n)).setAttribute("position",new h.bd([-1,3,0,-1,-1,0,3,-1,0],3)),e.setAttribute("uv",new h.bd([0,2,0,0,2,0],2)),e}return M(n,e),n}(h.dd)),rz=function(){function e(n){x(this,e),this._mesh=new h.ld(rF,n)}return b(e,[{key:"dispose",value:function(){this._mesh.geometry.dispose()}},{key:"render",value:function(e){e.render(this._mesh,rO)}},{key:"material",get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}]),e}(),rk=function e(n,t,a){x(this,e);var r=function(e){e.defines.resolution="vec2( "+n.toFixed(1)+", "+t.toFixed(1)+" )"},i=function(e,n){var t=new h.ce({name:"GPUComputationShader",uniforms:n=n||{},vertexShader:"void main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}\n",fragmentShader:e});return r(t),t};this.variables=[],this.currentTextureIndex=0;var o=h.Aa,s={passThruTexture:{value:null}},l=i("uniform sampler2D passThruTexture;\n\nvoid main() {\n\n vec2 uv = gl_FragCoord.xy / resolution.xy;\n\n gl_FragColor = texture2D( passThruTexture, uv );\n\n}\n",s),c=new rz(l);this.setDataType=function(e){return o=e,this},this.addVariable=function(e,n,t){var a={name:e,initialValueTexture:t,material:this.createShaderMaterial(n),dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:h.na,magFilter:h.na};return this.variables.push(a),a},this.setVariableDependencies=function(e,n){e.dependencies=n},this.init=function(){if(0===a.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(var e=0;e<this.variables.length;e++){var r=this.variables[e];r.renderTargets[0]=this.createRenderTarget(n,t,r.wrapS,r.wrapT,r.minFilter,r.magFilter),r.renderTargets[1]=this.createRenderTarget(n,t,r.wrapS,r.wrapT,r.minFilter,r.magFilter),this.renderTexture(r.initialValueTexture,r.renderTargets[0]),this.renderTexture(r.initialValueTexture,r.renderTargets[1]);var i=r.material,o=i.uniforms;if(null!==r.dependencies)for(var s=0;s<r.dependencies.length;s++){var l=r.dependencies[s];if(l.name!==r.name){for(var c=!1,u=0;u<this.variables.length;u++)if(l.name===this.variables[u].name){c=!0;break}if(!c)return"Variable dependency not found. Variable="+r.name+", dependency="+l.name}o[l.name]={value:null},i.fragmentShader="\nuniform sampler2D "+l.name+";\n"+i.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){for(var e=this.currentTextureIndex,n=+(0===this.currentTextureIndex),t=0,a=this.variables.length;t<a;t++){var r=this.variables[t];if(null!==r.dependencies)for(var i=r.material.uniforms,o=0,s=r.dependencies.length;o<s;o++){var l=r.dependencies[o];i[l.name].value=l.renderTargets[e].texture}this.doRenderTarget(r.material,r.renderTargets[n])}this.currentTextureIndex=n},this.getCurrentRenderTarget=function(e){return e.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(e){return e.renderTargets[+(0===this.currentTextureIndex)]},this.dispose=function(){c.dispose();for(var e=this.variables,n=0;n<e.length;n++){var t=e[n];t.initialValueTexture&&t.initialValueTexture.dispose();for(var a=t.renderTargets,r=0;r<a.length;r++)a[r].dispose();t.material.dispose()}},this.addResolutionDefine=r,this.createShaderMaterial=i,this.createRenderTarget=function(e,a,r,i,s,l){return new h.Lc(e=e||n,a=a||t,{wrapS:r=r||h.la,wrapT:i=i||h.la,minFilter:s=s||h.na,magFilter:l=l||h.na,format:h.Ja,type:o,depthBuffer:!1})},this.createTexture=function(){var e=new Float32Array(n*t*4),a=new h.nd(e,n,t,h.Ja,h.Aa);return a.needsUpdate=!0,a},this.renderTexture=function(e,n){s.passThruTexture.value=e,this.doRenderTarget(l,n),s.passThruTexture.value=null},this.doRenderTarget=function(e,n){var t=a.getRenderTarget(),r=a.xr.enabled,i=a.shadowMap.autoUpdate;a.xr.enabled=!1,a.shadowMap.autoUpdate=!1,c.material=e,a.setRenderTarget(n),c.render(a),c.material=l,a.xr.enabled=r,a.shadowMap.autoUpdate=i,a.setRenderTarget(t)}};function rB(e,n,t,a){var r,i,o,s,l,u,d,f,p,v,m,g,_,x="texture"===t.type?null!=t.texture.image?null!=(r=a.uiBuffer(t.texture.image))?r:a.image(t.texture.image):a.getImage(""):a.video(t.texture.video),y=new tD(x,null!=(i=t.texture.wrapping)?i:"texture"===t.type?1e3:1001,null!=(o=t.texture.minFilter)?o:1008,null!=(s=t.texture.magFilter)?s:1006),b=new tP(x),w=new tI(ru(null!=(l=t.texture.repeat)?l:[1,1],a),ru(null!=(u=t.texture.offset)?u:[0,0],a),(0,c._)(null!=(d=t.texture.rotation)?d:0,a)),T=new q(+!!t.crop),E=new ey(null!=(f=t.projection)?f:0),M=new ey(null!=(p=["x","y","z"].indexOf(t.axis))?p:0),C=t.projectionAxis?["x","y","z"].indexOf(t.projectionAxis):-1,R=new ey(null!=(v=t.side)?v:0),A=new W(t.size?S(h.Dc,N(ru(t.size,a))):new h.Dc(100,100)),P=new q(null!=(m=t.blending)?m:0),D=new q((0,c.Z)(t.alpha,a)),L=new ey(null!=(g=t.mode)?g:0),U=new tC(null!=(_=t.isMask)&&_),I=new tV(y,b,T,E,M,R,A,P,w,D,L,U,C),O=new er(I.calpha,"f");return new rf(e,n,t,{texture:y,textureSize:b,crop:T,projection:E,axis:M,side:R,size:A,blending:P,mat:w,alpha:D,mode:L,isMask:U},I,L,O,U,a)}(0,i.c)({createMaterial:function(e,n){return new rI(e,n)},createComputation:function(e,n,t){return new rk(e,n,t)}}),rr("texture",rB),rr("video",rB),rr("matcap",function(e,n,t,a){var r,i,o,s,l,u,d,f=new tD(null!=t.texture.image?a.image(t.texture.image):a.getImage(""),null!=(r=t.texture.wrapping)?r:1001,null!=(i=t.texture.minFilter)?i:1008,null!=(o=t.texture.magFilter)?o:1006),p=new q((0,c.Z)(t.alpha,a)),v=new ey(null!=(s=t.mode)?s:0),m=new tC(null!=(l=t.isMask)&&l),g=new q((null!=(u=(0,c._)(null!=(d=t.texture.rotation)?d:0,a))?u:0)*h.Cc.DEG2RAD),_=new tY(f,p,v,m,g),x=new er(_.calpha,"f");return new rf(e,n,t,{texture:f,alpha:p,mode:v,isMask:m,rotation:g},_,v,x,m,a)}),rr("displace",function(e,n,t,a){if("noise"===t.displacementType){var r,i,o,s,l,u,d,f,p,v,m=new X(S(h.Fc,N(t.offset.map(function(e){var n;return null!=(n=(0,c._)(e,a))?n:0})))),g=new q(null!=(r=(0,c._)(t.scale,a))?r:10),_=new q(null!=(i=(0,c._)(t.intensity,a))?i:8),x=new q(null!=(o=(0,c._)(t.movement,a))?o:1),y=new ey(null!=(s=t.noiseType)?s:0),b=new ey(null!=(l=t.voronoiStyle)?l:0),w=new q(null!=(u=(0,c._)(t.smoothness,a))?u:.5),T=new q(null!=(d=(0,c._)(t.seed,a))?d:0),E=new q(null!=(f=(0,c._)(t.highCut,a))?f:1),M=new q(null!=(p=(0,c._)(t.lowCut,a))?p:0),C=new ey(null!=(v=(0,c._)(t.quality,a))?v:1),R=new aK(_,x,m,b,w,T,E,M,C,g,y);return new rp(e,n,t,{offset:m,scale:g,intensity:_,movement:x,noiseType:y,voronoiStyle:b,smoothness:w,seed:T,highCut:E,lowCut:M,quality:C},R,a)}throw Error()}),rr("cavity",function(e,n,t,r){var i,o,s=(0,a.f)(t,r),l=new q(null!=(i=(0,c._)(s.ridge,r))?i:1),u=new q(null!=(o=(0,c._)(s.valley,r))?o:1),d=rv(s),f=new tH(l,u,aZ.normalViewRenderTarget,aZ.resolution,d.alpha,d.mode,d.isMask),p=new er(f.calpha,"f");return new rf(e,n,t,R({ridge:l,valley:u},d),f,d.mode,p,d.isMask,r)}),rr("dust",function(e,n,t,r){var i,o,s,l,c,u=(0,a.f)(t,r),d=new eS(null!=(i=u.color)?i:0x9d8765),f=new q(null!=(o=u.coverage)?o:.2),p=new q(null!=(s=u.softness)?s:.2),h=new q(null!=(l=u.noiseStrength)?l:.2),v=new q(null!=(c=u.noiseScale)?c:1),m=rv(u),g=new tX(d,f,p,h,v,m.alpha,m.isMask),_=new er(g.calpha,"f");return new rf(e,n,t,R({color:d,coverage:f,softness:p,noiseStrength:h,noiseScale:v},m),g,m.mode,_,m.isMask,r)}),rr("fresnel",function(e,n,t,r){var i,o,s,l,u,d=(0,a.f)(t,r),f=new eS(null!=(i=d.color)?i:0xffffff),p=new q(null!=(o=(0,c._)(d.bias,r))?o:.1),h=new q(null!=(s=(0,c._)(d.scale,r))?s:1),v=new q(null!=(l=(0,c._)(d.intensity,r))?l:2),m=new q(null!=(u=(0,c._)(d.factor,r))?u:1),g=rv(d),_=new tj(f,p,h,v,m,g.alpha,g.mode,g.isMask),x=new er(_.calpha,"f");return new rf(e,n,t,R({color:f,bias:p,scale:h,intensity:v,factor:m},g),_,g.mode,x,g.isMask,r)}),rr("gradient",function(e,n,t,r){var i,o,s,l,u,d,f,p=(0,a.f)(t,r),v=new ey(null!=(i=p.gradientType)?i:0),m=new tC(null!=(o=p.smooth)&&o);p.colors?d=new tO(p.colors.length,p.colors):(d=new tO(10,new h.Jc(0,0,0,1))).value[1]=new h.Jc(1,1,1,1),p.steps?f=new tR(p.steps.length,p.steps):(f=new tR(10,1)).value[0]=0;var g=new W(rc(null!=(s=p.offset)?s:new h.Dc(0,0),r)),_=new W(rc(null!=(l=p.morph)?l:new h.Dc(0,0),r)),x=new q((0,c._)(null!=(u=p.angle)?u:0,r)),S=rv(p),y=new tq(v,m,d,f,g,_,x,S.alpha,S.isMask),b=new er(y.calpha,"f");return new rf(e,n,t,R({gradientType:v,smooth:m,colors:d,steps:f,offset:g,morph:_,angle:x},S),y,S.mode,b,S.isMask,r)}),rr("depth",function(e,n,t,r){var i,o,s,l,u,d,f,p,v=(0,a.f)(t,r),m=new ey(null!=(i=v.gradientType)?i:0),g=new tC(null!=(o=v.smooth)&&o),_=new q(null!=(s=(0,c._)(v.near,r))?s:50),x=new q(null!=(l=(0,c._)(v.far,r))?l:200),S=new q(null!=(u=v.isVector)?u:1),y=new q(null!=(d=v.isWorldSpace)?d:0),b=new X(rl(v.origin,r)),w=new X(rl(v.direction,r));v.colors?f=new tO(v.colors.length,v.colors):(f=new tO(2,new h.Jc(0,0,0,1))).value[1]=new h.Jc(1,1,1,1),v.steps?p=new tR(v.steps.length,v.steps):(p=new tR(2,1)).value[0]=0;var T=rv(v),E=new tG(m,g,_,x,S,y,b,w,f,p,T.alpha,T.isMask),M=new er(E.calpha,"f");return new rf(e,n,t,R({gradientType:m,smooth:g,near:_,far:x,isVector:S,isWorldSpace:y,origin:b,direction:w,colors:f,steps:p},T),E,T.mode,M,T.isMask,r)}),rr("normal",function(e,n,t,r){var i,o=(0,a.f)(t,r),s=new X(null!=(i=o.cnormal)?i:new h.Fc(1,1,1)),l=rv(o),c=new tk(s,l.alpha),u=new er(c.calpha,"f");return new rf(e,n,t,R({cnormal:s},l),c,l.mode,u,l.isMask,r)}),rr("noise",function(e,n,t,r){var i,o,s,l,u,d,f,p,v,m,g,_,x,S=(0,a.f)(t,r),y=new q(null!=(i=(0,c._)(S.scale,r))?i:1),b=new X(rl(null!=(o=S.size)?o:new h.Fc(100,100,100),r)),w=new q(null!=(s=(0,c._)(S.move,r))?s:1),T=new W(rc(null!=(l=S.fA)?l:new h.Dc(1.7,9.2),r)),E=new W(rc(null!=(u=S.fB)?u:new h.Dc(8.3,2.8),r)),M=new W(rc(null!=(d=S.distortion)?d:new h.Dc(1,1),r)),C=new j(S.colorA),P=new j(S.colorB),D=new j(S.colorC),L=new j(S.colorD),U=new ey(null!=(f=S.noiseType)?f:0),N=new ey(null!=(p=S.voronoiStyle)?p:0),I=new q(null!=(v=(0,c._)(S.highCut,r))?v:1),O=new q(null!=(m=(0,c._)(S.lowCut,r))?m:0),F=new q(null!=(g=(0,c._)(S.smoothness,r))?g:.5),z=new q(null!=(_=(0,c._)(S.seed,r))?_:.5),k=new ey(null!=(x=S.quality)?x:1),B=rv(S),V=new tK(y,b,w,T,E,M,C,P,D,L,B.alpha,U,B.isMask,N,I,O,F,z,k),G=new er(V.calpha,"f");return new rf(e,n,t,A(R({scale:y,size:b,move:w,fA:T,fB:E,distortion:M,colorA:C,colorB:P,colorC:D,colorD:L,noiseType:U},B),{voronoiStyle:N,highCut:I,lowCut:O,smoothness:F,seed:z,quality:k}),V,B.mode,G,B.isMask,r)}),rr("rainbow",function(e,n,t,r,i){var o,s,l,u,d=(0,a.f)(t,r),f=new q(null!=(o=(0,c._)(d.filmThickness,r))?o:30),p=new q(null!=(s=(0,c._)(d.movement,r))?s:0),h=new X(rl(d.wavelengths,r)),v=new q(null!=(l=(0,c._)(d.noiseStrength,r))?l:0),m=new q(null!=(u=(0,c._)(d.noiseScale,r))?u:1),g=new X(rl(d.offset,r)),_=rv(d),x=!0===(null==i?void 0:i.forceRainbowNoise),S=x||(0,c.aa)(d.noiseStrength),y=new tQ(f,p,h,v,m,g,_.alpha,_.isMask,S),b=new er(y.calpha,"f"),w=new rf(e,n,t,R({filmThickness:f,movement:p,wavelengths:h,noiseStrength:v,noiseScale:m,offset:g},_),y,_.mode,b,_.isMask,r);return w.noiseCompiledIn=S,w.noiseForced=x,w}),rr("toon",function(e,n,t,r){var i,o,s,l,u,d,f,p,v=(0,a.f)(t,r),m=new ey(null!=(i=v.positioning)?i:0);v.colors?f=new tO(v.colors.length,v.colors):(f=new tO(10,new h.Jc(0,0,0,1))).value[1]=new h.Jc(1,1,1,1),v.steps?p=new tR(v.steps.length,v.steps):(p=new tR(10,1)).value[0]=0;var g=new X(rl(null!=(o=v.source)?o:new h.Fc(0,0,0),r)),_=new tC(null==(s=v.isWorldSpace)||s),x=new q((0,c._)(null!=(l=v.noiseStrength)?l:0,r)),S=new q((0,c._)(null!=(u=v.noiseScale)?u:1,r)),y=new j(v.shadowColor),b=new X(rl(null!=(d=v.offset)?d:new h.Fc(0,0,0),r)),w=rv(v),T=new t$(m,f,p,g,_,x,S,y,b,w.alpha),E=new er(T.calpha,"f");return new rf(e,n,t,R({positioning:m,colors:f,steps:p,source:g,isWorldSpace:_,noiseStrength:x,noiseScale:S,shadowColor:y,offset:b},w),T,w.mode,E,w.isMask,r)}),rr("outline",function(e,n,t,r){var i,o,s,l,u,d,f,p,v,m,g,_=(0,a.f)(t,r),x=new eS(null!=(i=_.outlineColor)?i:0xffffff),S=new eS(null!=(o=_.contourColor)?o:0xffffff),y=new q((0,c._)(null!=(s=_.outlineWidth)?s:.1,r)),b=new q((0,c._)(null!=(l=_.contourWidth)?l:.1,r)),w=new q((0,c._)(null!=(u=_.outlineThreshold)?u:.1,r)),T=new q((0,c._)(null!=(d=_.contourThreshold)?d:.1,r)),E=new q((0,c._)(null!=(f=_.outlineSmoothing)?f:.1,r)),M=new q((0,c._)(null!=(p=_.contourFrequency)?p:.1,r)),C=new X(rl(null!=(v=_.contourDirection)?v:new h.Fc(0,1,0),r)),A=new tC(null!=(m=_.positionalLines)&&m),P=new tC(null==(g=_.compensation)||g),D=aZ.normalRenderTarget,L=aZ.normalRenderTargetDepth,U=aZ.pixelRatioNode,N=aZ.resolution,I=rv(_),O=new tZ(x,S,y,b,w,T,E,M,C,A,P,N,D,L,U,I.alpha),F=new er(O.calpha,"f");return new rf(e,n,t,R({outlineColor:x,contourColor:S,outlineWidth:y,contourWidth:b,outlineThreshold:w,contourThreshold:T,outlineSmoothing:E,contourFrequency:M,contourDirection:C,positionalLines:A,compensation:P},I),O,I.mode,F,I.isMask,r)}),rr("transmission",function(e,n,t,r){var i,o,s,l=(0,a.f)(t,r),u=new q((0,c._)(null!=(i=l.thickness)?i:10,r)),d=new q((0,c._)(null!=(o=l.ior)?o:1.5,r)),f=new q((0,c._)(null!=(s=l.roughness)?s:.5,r)),p=aZ.transmissionSize,h=aZ.transmissionRenderTarget,v=aZ.transmissionRenderTargetDepth,m=window.innerWidth,g=window.innerHeight,_=m>=g?new W(g/m,1):new W(1,m/g),x=rv(l),S=new t1(u,d,f,p,h,v,_,x.alpha),y=new er(S.calpha,"f");return new rf(e,n,t,R({thickness:u,ior:d,roughness:f,aspectRatio:_},x),S,x.mode,y,x.isMask,r)});var rV=!1;rr("reflection",function(e,n,t,r){rV||(rV=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer — it renders as invisible on the classic WebGL pipeline."));var i,o,s,l,c,u=(0,a.f)(t,r),d=new q(null!=(i=u.blur)?i:0),f=new q(null!=(o=u.thickness)?o:.001),p=new ey(null!=(s=u.steps)?s:60),h=new q(null!=(l=u.stepSize)?l:.005),v=new ey(null!=(c=u.tracingMode)?c:1),m=rv(u),g=new tz(new eS(0,0,0,1),new q(0)),_=new er(g.calpha,"f");return new rf(e,n,t,R({blur:d,thickness:f,steps:p,stepSize:h,tracingMode:v},m),g,m.mode,_,m.isMask,r)}),rr("pattern",function(e,n,t,r){var i,o,s,l,u,d,f,p,v,m,g,_,x,S=(0,a.f)(t,r),y=new ey(null!=(i=S.style)?i:0),b=new ey(null!=(o=S.projection)?o:0),w=new ey(null!=(s=["x","y","z"].indexOf(S.axis))?s:0),T=new q((0,c._)(null!=(l=S.blending)?l:0,r)),E=new W(rc(S.offset,r)),M=new j(S.colorA),C=new j(S.colorB),A=new W(rc(null!=(u=S.frequency)?u:new h.Dc(10,10),r)),P=new q((0,c._)(null!=(d=S.size)?d:.5,r)),D=new q((0,c._)(null!=(f=S.variation)?f:0,r)),L=new q((0,c._)(null!=(p=S.smoothness)?p:.5,r)),U=new q((0,c._)(null!=(v=S.zigzag)?v:0,r)),N=new q((0,c._)(null!=(m=S.rotation)?m:0,r)),I=new W(rc(null!=(g=S.vertical)?g:new h.Dc(0,1),r)),O=new W(rc(null!=(_=S.horizontal)?_:new h.Dc(0,1),r)),F=new ey(null!=(x=S.sides)?x:6),z=rv(S),k=new tJ(y,b,w,T,E,M,C,A,P,D,L,U,N,I,O,F,z.alpha,z.isMask),B=new er(k.calpha,"f");return new rf(e,n,t,R({style:y,projection:b,axis:w,blending:T,offset:E,colorA:M,colorB:C,frequency:A,size:P,variation:D,smoothness:L,zigzag:U,rotation:N,vertical:I,horizontal:O,sides:F},z),k,z.mode,B,z.isMask,r)}),rr("vertexColor",function(e,n,t,r){var i=rv((0,a.f)(t,r)),o=new t3(i.alpha),s=new er(o.calpha,"f");return new rf(e,n,t,R({},i),o,i.mode,s,i.isMask,r)}),(0,c.Q)({createRootMaterial:function(e,n){return new rw(e,n)},createSharedMaterial:function(e,n,t){return new rT(e,n,t)}}),(0,c.W)(function(e,n){return e?function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"medium";if(rP===n)return!1;rP=n,e=function(e){switch(e){case"low":return 8;case"medium":default:return 16;case"high":return 32}}(n),eT.shadowmap_pars_fragment="\n\n// PCSS implementation based on:\n// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/\n// NOTE: This number affects how big the shadow blur can\n// possibly get. Bigger number == bigger blur, but less precise results\n\nconst float gPenumbraFilterSize = 80.0;\n// Blocker search at half the PCF budget (min 4): the average-blocker-depth\n// estimate feeds the squared/clamped penumbra term, which tolerates far\n// more estimator variance than the visible PCF edge — and the per-frame\n// vogel rotation integrates the residual under TAA. The reduced count is\n// ALSO the vogelDiskSample count in computePenumbra so the sparser spiral\n// still spans the full search radius (classic N with i < N/2 would only\n// cover the inner sqrt(1/2) of the disk and miss far blockers). Mirrors\n// the WebGPU filter's split (splinePCSS.ts blockerSampleCount).\nconst int gPenumbraSamples = ".concat(Math.max(4,e>>1),";\nconst int gShadowSamples = ").concat(e,";\nconst float gShadowSamplesRpc = 1.0f / float(gShadowSamples);\n\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n struct DirectionalLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n struct SpotLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_POINT_LIGHT_SHADOWS > 0\n\n // r185 renders point-light shadows into a cube render target with a\n // CubeDepthTexture (WebGLShadowMap always uses WebGLCubeRenderTarget\n // for point lights), so the map binds as a cube sampler — the old\n // 2D cube-atlas (cubeToUV) layout no longer exists. BasicShadowMap\n // leaves compareFunction null, so raw depth reads work.\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n struct PointLightShadow {\n // Field order must match three r185's stock struct.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n #endif\n\n /*\n #if NUM_RECT_AREA_LIGHTS > 0\n\n // TODO (abelnation): create uniforms for area light shadows\n\n #endif\n */\n\n").concat(rE,"\n\nfloat computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius, vec2 dzduv)\n{\n float penumbra = 1.0;\n float blockerDepthAvg = 0.0;\n float blockerCount = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 0; i < gPenumbraSamples; i ++)\n {\n vec2 offset = (vogelDiskSample(i, gPenumbraSamples, temporalAngle) * texelSize) * texelScalar;\n float depth = texture2D( shadowMap, uv + offset ).r;\n\n if(depth < compare + receiverPlaneAdjust(dzduv, offset) + 0.0001)\n {\n blockerDepthAvg += depth;\n blockerCount++;\n }\n }\n #pragma unroll_loop_end\n\n if (blockerCount > 0.0)\n {\n blockerDepthAvg /= blockerCount;\n\n \n penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);\n penumbra *= penumbra;\n penumbra *= 200.0 * penumbraSize[min(index, ").concat(c.d," - 1)]; // Magic number that affects how quickly the penumbra grows\n\n return clamp(penumbra, 0.00, 1.0);\n }\n return 0.0;\n}\n\nfloat vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius, vec2 dzduv)\n{\n float shadow = 0.0f;\n\n // NOTE: When using TAA, we should use screen space interleaved gradient noise\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);\n float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius, dzduv);\n if (penumbra == -1.0) {\n return 1.0;\n }\n\n #pragma unroll_loop_start\n for (int i = 0; i < gShadowSamples; i++)\n {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n // Overall blurring offset\n vec2 offset = vogelSample * (shadowRadius * 2.);\n\n // Penumbra offset\n offset += vogelSample * (penumbra * texelScalar);\n\n shadow += step( compare + receiverPlaneAdjust(dzduv, offset), texture2D( shadowMap, uv + offset ).r );\n }\n #pragma unroll_loop_end\n\n return shadow * gShadowSamplesRpc;\n}\n\n\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n // r185: shadow maps are DepthTextures bound without compare mode\n // (BasicShadowMap), so depth is read directly from .r rather than from\n // an RGBA-packed encoding.\n return step( compare, texture2D( depths, uv ).r );\n\n }\n\n float textureCubeCompare( samplerCube depths, vec3 dir, float compare ) {\n\n float depth = textureCube( depths, dir ).r;\n\n #ifdef USE_REVERSED_DEPTH_BUFFER\n\n depth = 1.0 - depth;\n\n #endif\n\n return step( compare, depth );\n\n }\n\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n }\n\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n float occlusion = 1.0;\n\n vec2 distribution = texture2DDistribution( shadow, uv );\n\n float hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n if (hard_shadow != 1.0 ) {\n\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n }\n return occlusion;\n\n }\n\n float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n float shadow = 1.0;\n\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n\n // Receiver-plane depth gradient — derivatives taken BEFORE the\n // frustum branch (well-defined across the quad) of the projected\n // coord, so the vogel taps can slope-correct their compares.\n vec2 dzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n\n // if ( something && something ) breaks ATI OpenGL shader compiler\n // if ( all( something, something ) ) using this instead\n\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n bool frustumTest = all( frustumTestVec );\n\n if ( frustumTest ) {\n\n // SHADOWMAP_TYPE_BASIC included: on r185 the renderer must use\n // BasicShadowMap (PCFShadowMap binds the depth texture as a\n // sampler2DShadow with hardware compare, which this custom PCSS\n // sampling can't read from), so BASIC is the define our PCSS path\n // now runs under.\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius, dzduv );\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n\n #elif defined( SHADOWMAP_TYPE_VSM )\n\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #else // no percentage-closer filtering:\n\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #endif\n\n }\n\n return shadow;\n\n }\n\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n float shadow = 1.0;\n // Offset magnitude matches the pre-r185 2D cube-atlas texel size so the\n // blur radius is visually unchanged.\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n // for point lights, the uniform @vShadowCoord is re-purposed to hold\n // the vector from the light to the world-space position of the fragment.\n vec3 lightToPosition = shadowCoord.xyz;\n\n // r185 cube shadow maps store perspective depth along the sampled\n // face's view axis (not radial distance): view-space depth is the\n // largest component of the light-to-fragment vector.\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\n if ( viewSpaceZ - shadowCameraFar > 0.0 || viewSpaceZ - shadowCameraNear < 0.0 ) {\n\n return shadow;\n\n }\n\n // viewZ to perspective depth\n float compare = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n compare += shadowBias;\n\n // bd3D = base direction 3D\n vec3 bd3D = normalize( lightToPosition );\n\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) || defined( SHADOWMAP_TYPE_BASIC )\n for (int i = 0; i < gShadowSamples; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n // NOTE: Removed for now\n // Penumbra offset\n //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * gShadowSamplesRpc;\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n for (int i = 0; i < 16; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * (1.0 / 16.0);\n #else // no percentage-closer filtering\n\n return textureCubeCompare( shadowMap, bd3D, compare );\n\n #endif\n\n }\n\n#endif\n");var t=rC.slice();eT.lights_fragment_begin=t=(t=t.replace("getShadow( spotShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX + ".concat(c.e,", spotShadowMap[ i ]"))).replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]");var a=rR.slice();return eT.shadowmask_pars_fragment=a=a.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),!0}(n):function(){if(null===rP||"off"===rP){var e=null===rP;return rP="off",e&&(eT.shadowmap_pars_fragment=rD()),!1}return rP="off",eT.shadowmap_pars_fragment=rD(),eT.lights_fragment_begin=rC,eT.shadowmask_pars_fragment=rR,!0}()}),(0,c.T)(function(){var e=new h.Zd;return e.depthWrite=!1,e.opacity=.5,e.onBeforeCompile=function(e){e.fragmentShader="layout(location = 1) out vec4 gVelocity;\n"+e.fragmentShader.replace("void main() {","void main() {\n gVelocity = vec4(0.0);")},e});var rG="\nvec3 normal = (normalize(vNormal)).rgb;\n\nfloat contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;\n\nvec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);\n",rH="\nvec3 nv = normalize(vNormalView);\nif (!gl_FrontFacing) nv = -nv;\n",rW="\nlayout(location = 1) out vec4 gViewNormal;\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n".concat(rG,"\ngl_FragColor = vec4(resultColor, vColor.r);\n\n").concat(rH,"\ngViewNormal = vec4(nv, vColor.r);\n}\n"),rX={value:1},rj=function(e){return new h.ce({vertexShader:"\nattribute vec3 randomColor;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat out vec3 vColor;\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\n\nvoid main()\n{\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\nvec3 transformed = vec3(position);\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n\n\n\n\n\nvec4 localPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nlocalPosition = instanceMatrix * localPosition;\nobjectNormal = mat3(instanceMatrix) * objectNormal;\n#endif\n\nvNormal = normal;\nvNormalView = normalMatrix * objectNormal;\nvColor = randomColor;\ngl_Position = projectionMatrix * (modelViewMatrix * localPosition);\n}\n",fragmentShader:e,uniforms:{depthContrast:rX}})},rq=rj("\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n".concat(rG,"\ngl_FragColor = vec4(resultColor, vColor.r);\n}\n")),rY=rj("\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n".concat(rH,"\ngl_FragColor = vec4(nv, vColor.r);\n}\n")),rK=rj(rW),rZ="float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n }\n\n return 1.0;\n\n}",rJ=/float getDistanceAttenuation\([^)]*\)\s*\{[\s\S]*?\n\}/,rQ=function(e){function n(){return x(this,n),_(this,n,[{name:"PassthroughMaterial",uniforms:{inputBuffer:new h.Le(null)},blending:h.m,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nlayout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}"}])}return M(n,e),b(n,[{key:"inputBuffer",set:function(e){this.uniforms.inputBuffer.value=e}}]),n}(h.ce),r$=function(e){function n(){var e;return x(this,n),(e=_(this,n,["TAAResolvePass"])).MRTCompatible=!0,e.needsSwap=!1,e.passThroughMaterial=new rQ,e.resolutionVector=new h.Dc,e.resolveMaterial=new h.ce({name:"TAAResolveMaterial",uniforms:{inputBuffer:new h.Le(null),historyBuffer:new h.Le(null),velocityBuffer:new h.Le(null),depthBuffer:new h.Le(null),resolution:new h.Le(new h.Dc)},blending:h.m,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;\n#define USE_YCOCG\n#define USE_CATMULL_ROM\nconst float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){\n#ifdef USE_YCOCG\nvec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);\n#else\nreturn texture(tex,uv);\n#endif\n}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){\n#ifdef CHOOSE_LONGEST_MOTION_VECTOR\nfloat longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;\n#else\nfloat closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;\n#endif\n}vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);\n#ifdef USE_CATMULL_ROM\nvec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);\n#else\nvec4 previousColor=sample_color(historyBuffer,previousPixelPos);\n#endif\n#ifdef USE_YCOCG\npreviousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);\n#endif\nvec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);\n#ifdef USE_YCOCG\nvec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;\n#endif\nvec4 previousColorClipped=clamp(previousColor,cmin,cmax);\n#ifdef LUMINANCE_DIFFERENCES\n#ifdef USE_YCOCG\nfloat lum0=currentColor.r;float lum1=previousColorClipped.r;\n#else\nfloat lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);\n#endif\nfloat unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));\n#else\nconst float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);\n#endif\n#ifdef USE_YCOCG\ngl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);\n#else\ngl_FragColor=result;\n#endif\n}"}),e.historyRenderTarget=new h.Lc(1024,1024,{minFilter:h.qa,stencilBuffer:!1,depthBuffer:!1}),e.historyRenderTarget.texture.name="TAA.History",e.resultRenderTarget=new h.Lc(1024,1024,{minFilter:h.qa,stencilBuffer:!1,depthBuffer:!1}),e.resultRenderTarget.texture.name="TAA.Output",e}return M(n,e),b(n,[{key:"setSize",value:function(e,n){this.historyRenderTarget.setSize(e,n),this.resultRenderTarget.setSize(e,n)}},{key:"render",value:function(e,n){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=n.textures[0],this.resolveMaterial.uniforms.velocityBuffer.value=n.textures[1],this.resolveMaterial.uniforms.depthBuffer.value=n.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(n.width,n.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);var t=this.renderToScreen?null:n;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(t),e.render(this.scene,this.camera)}},{key:"dispose",value:function(){T(E(n.prototype),"dispose",this).call(this),this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}}]),n}(f.b),r0=function(e){function n(e,t,a){var r;return x(this,n),(r=_(this,n,["TransmissionPass",void 0,t])).MRTCompatible=!0,r.depthPass=new f.e(e,t,{renderTarget:a.transmissionDepthTarget}),r.passThroughMaterial=new rQ,r.splineScene=e,r.needsSwap=!1,r}return M(n,e),b(n,[{key:"updatePasses",value:function(e){this.passThroughMaterial.dispose(),this.passThroughMaterial=new rQ,this.depthPass.dispose(),this.depthPass=new f.e(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}},{key:"setCamera",value:function(e){this.camera=e}},{key:"setScene",value:function(e){this.splineScene=e}},{key:"render",value:function(e,n,t){var a=this.camera.layers.mask;e.setRenderTarget(e.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=n.textures[0],e.clear(),e.render(this.scene,this.camera),e.shadowMap.needsUpdate=!1,e.shadowMap.autoUpdate=!1,this.camera.layers.disable(3),this.depthPass.render(e,n,t);var r=this.renderToScreen?null:n;this.camera.layers.set(3),e.setRenderTarget(r),e.render(this.splineScene,this.camera),this.camera.layers.mask=a}},{key:"dispose",value:function(){var e;T(E(n.prototype),"dispose",this).call(this),null==(e=this.depthPass)||e.renderPass.dispose(),this.depthPass.dispose(),this.passThroughMaterial.dispose(),this.depthPass=void 0,this.passThroughMaterial=void 0,this.splineScene=void 0,this.scene=void 0,this.camera=void 0}}]),n}(f.b),r1=new h.Vc,r3=new h.ce({transparent:!0,vertexShader:"\n void main() {\n gl_Position = vec4(0.0);\n }\n ",fragmentShader:"\n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n gl_FragColor = vec4(0.0);\n gVelocity = vec4(0.0);\n }\n "}),r2=function(e){function n(e,t,a){var r;return x(this,n),(r=_(this,n,["OpaquePass",null!=t?t:r1,a])).MRTCompatible=!0,r.originalMaterials=[],r.hasTransmissionPass=!1,r.clear=!0,r.clearColorOnly=!1,r.clearDepth=!1,r.needsSwap=!1,r.MRTCompatible=e,r}return M(n,e),b(n,[{key:"setCamera",value:function(e){this.camera=e}},{key:"setScene",value:function(e){this.scene=null!=e?e:r1}},{key:"getScene",value:function(){return this.scene}},{key:"render",value:function(e,n){var t=this;this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.length=0,this.scene.traverse(function(e){e.layers.isEnabled(3)&&C(e,u.v)&&(t.originalMaterials.push([e,e.material]),e.material=r3)}),!0!==e.manageShadowUpdates&&(e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0)),this.camera.layers.enable(8),this.camera.layers.enable(4);var a=this.renderToScreen?null:n;e.setRenderTarget(a),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach(function(e){e[0].material=e[1]})}},{key:"dispose",value:function(){T(E(n.prototype),"dispose",this).call(this),this.originalMaterials.length=0,this.scene=void 0,this.camera=void 0}}]),n}(f.b),r4=function(){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.depthBuffer,r=void 0===a||a,i=t.stencilBuffer,o=void 0!==i&&i,s=t.multisampling,l=void 0===s?0:s,c=t.frameBufferType,u=void 0===c?0:c;x(this,e),this.renderer=n,this.helperStartIndex=0,this.copyPass=new f.c,this.depthTexture=null,this.timer=new f.k,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(r,o,u,l,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(r,o,u,l,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.textures[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(r,o,u,l,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.textures[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(n)}return b(e,[{key:"multisampling",get:function(){return this.inputBuffer.samples||0},set:function(e){var n=this.inputBuffer,t=this.multisampling;t>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(n.depthBuffer,n.stencilBuffer,n.texture.type,e,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}},{key:"getTimer",value:function(){return this.timer}},{key:"getRenderer",value:function(){return this.renderer}},{key:"setRenderer",value:function(e){if(this.renderer=e,null!==e){var n=e.getSize(new h.Dc),t=null!=(s=null==(l=e.getContext().getContextAttributes())?void 0:l.alpha)&&s,a=this.inputBuffer.textures[0].type;a===h.ua&&e.outputColorSpace===h.Ib&&(this.inputBuffer.textures[0].colorSpace=h.Ib,this.outputBuffer.textures[0].colorSpace=h.Ib,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(n.width,n.height,!1);var r=!0,i=!1,o=void 0;try{for(var s,l,c,u=this.passes[Symbol.iterator]();!(r=(c=u.next()).done);r=!0)c.value.initialize(e,t,a)}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}}}},{key:"replaceRenderer",value:function(e){var n=!(arguments.length>1)||void 0===arguments[1]||arguments[1],t=this.renderer,a=t.domElement.parentNode;return this.setRenderer(e),n&&null!==a&&(a.removeChild(t.domElement),a.appendChild(e.domElement)),t}},{key:"createDepthTexture",value:function(){var e=this.depthTexture=new h.Cd(this._width,this._height);return this.inputBuffer.depthTexture=e,this.inputBuffer.stencilBuffer?(e.format=h.La,e.type=h.Ea):e.type=h.za,e}},{key:"deleteDepthTexture",value:function(){if(null!==this.depthTexture){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();var e=!0,n=!1,t=void 0;try{for(var a,r=this.passes[Symbol.iterator]();!(e=(a=r.next()).done);e=!0)a.value.setDepthTexture(null)}catch(e){n=!0,t=e}finally{try{e||null==r.return||r.return()}finally{if(n)throw t}}}}},{key:"createBuffer",value:function(e,n,t,a,r,i){var o,s=this.renderer,l=null===s?new h.Dc:s.getDrawingBufferSize(new h.Dc),c={minFilter:h.qa,magFilter:h.qa,wrapS:h.la,wrapT:h.la,stencilBuffer:n,depthBuffer:e};a>0?(o=new h.Lc(l.width,l.height,c)).samples=a:(r?(o=new h.Lc(l.width,l.height,A(R({},c),{count:2}))).textures[1].type=h.Ba:o=new h.Lc(l.width,l.height,c),o.depthTexture=new h.Cd(2048,2048),o.depthTexture.type=h.Aa);var u=o.textures.length>1;return t===h.ua&&null!==s&&s.outputColorSpace===h.Ib&&(u?o.textures.forEach(function(e){return e.colorSpace=h.Ib}):o.texture.colorSpace=h.Ib),u?o.textures.forEach(function(e,n){e.name="EffectComposer.Buffer ".concat(r," ").concat(n),e.generateMipmaps=!1}):(o.texture.name="EffectComposer.Buffer ".concat(r),o.texture.generateMipmaps=!1),o.name=i,o}},{key:"addPass",value:function(e,n){var t,a,r,i=this.passes,o=this.renderer,s=o.getDrawingBufferSize(new h.Dc),l=null!=(t=null==(a=o.getContext().getContextAttributes())?void 0:a.alpha)&&t;if(e.MRTCompatible&&(r=this.inputBuffer.textures[0].type),e.MRTCompatible||(r=this.inputBuffer.texture.type),e.setRenderer(o),e.setSize(s.width,s.height),e.initialize(o,l,r),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),void 0!==n?i.splice(n,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||null!==this.depthTexture)if(null===this.depthTexture){var c=this.createDepthTexture(),u=!0,d=!1,f=void 0;try{for(var p,v=i[Symbol.iterator]();!(u=(p=v.next()).done);u=!0)(e=p.value).setDepthTexture(c)}catch(e){d=!0,f=e}finally{try{u||null==v.return||v.return()}finally{if(d)throw f}}}else e.setDepthTexture(this.depthTexture)}},{key:"setHelperStartIndex",value:function(e){this.helperStartIndex=e}},{key:"removePass",value:function(e){var n=this.passes,t=n.indexOf(e);-1!==t&&n.splice(t,1).length>0&&(null!==this.depthTexture&&(n.reduce(function(e,n){return e||n.needsDepthTexture},!1)||e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null)),this.autoRenderToScreen&&t===n.length&&(e.renderToScreen=!1,n.length>0&&(n[n.length-1].renderToScreen=!0)))}},{key:"removeAllPasses",value:function(){var e=this.passes;e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}},{key:"render",value:function(e){var n,t,a,r,i=this.renderer,o=this.copyPass,s=this.inputBuffer,l=this.outputBuffer,c=this.inputBufferSingle,u=this.outputBufferSingle,d=!1;void 0===e&&(e=this.timer.update().getDelta());var p=!0,h=!1,v=void 0;try{for(var m,g=this.passes[Symbol.iterator]();!(p=(m=g.next()).done);p=!0){var _=m.value;_.enabled&&(_.MRTCompatible?_.render(i,s,l,e,d):_.render(i,c,u,e,d),_.needsSwap&&(d&&(o.renderToScreen=_.renderToScreen,n=i.getContext(),(t=i.state.buffers.stencil).setFunc(n.NOTEQUAL,1,0xffffffff),o.render(i,s,l,e,d),t.setFunc(n.EQUAL,1,0xffffffff)),a=s,r=c,s=l,c=u,l=a,u=r),C(_,f.i)?d=!0:C(_,f.d)&&(d=!1))}}catch(e){h=!0,v=e}finally{try{p||null==g.return||g.return()}finally{if(h)throw v}}}},{key:"setSize",value:function(e,n,t){var a=this.renderer;if(this._width=e,this._height=n,void 0===e||void 0===n){var r=a.getSize(new h.Dc);e=r.width,n=r.height}a.setSize(e,n,t);var i=a.getDrawingBufferSize(new h.Dc);this.inputBuffer.setSize(i.width,i.height),this.outputBuffer.setSize(i.width,i.height),this.inputBufferSingle.setSize(i.width,i.height),this.outputBufferSingle.setSize(i.width,i.height);var o=!0,s=!1,l=void 0;try{for(var c,u=this.passes[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)c.value.setSize(i.width,i.height)}catch(e){s=!0,l=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw l}}}},{key:"reset",value:function(){var e=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(e)}},{key:"dispose",value:function(){var e=!0,n=!1,t=void 0;try{for(var a,r=this.passes[Symbol.iterator]();!(e=(a=r.next()).done);e=!0)a.value.dispose()}catch(e){n=!0,t=e}finally{try{e||null==r.return||r.return()}finally{if(n)throw t}}this.passes=[],null!==this.inputBuffer&&this.inputBuffer.dispose(),null!==this.outputBuffer&&this.outputBuffer.dispose(),null!==this.inputBufferSingle&&this.inputBufferSingle.dispose(),null!==this.outputBufferSingle&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}}]),e}(),r5=new h.ce({name:"CombineMaterial",uniforms:{inputBufferA:new h.Le(null),inputBufferB:new h.Le(null)},blending:h.m,depthWrite:!1,depthTest:!1,vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n gl_Position = vec4(position.xy, 1.0, 1.0);\n vUv = position.xy * 0.5 + 0.5;\n}\n",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D inputBufferA;\n uniform sampler2D inputBufferB;\n\n \n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n vec4 resA = texture2D(inputBufferA, vUv);\n vec4 resB = texture2D(inputBufferB, vUv);\n float a = resA.a + resB.a * ( 1.0 - resA.a );\n\n vec4 res;\n res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));\n res.a = resA.a + resB.a * (1.0 - resA.a);\n gl_FragColor = res;\n gVelocity = vec4(0.0);\n }\n"}),r6=function(e){function n(e){var t;return x(this,n),(t=_(this,n,["HelperPass",void 0,e])).MRTCompatible=!1,t._width=10,t._height=10,t.fullscreenMaterial=r5,t.helperPass=new r2(!1,void 0,t.camera),t.helperPass.hasTransmissionPass=!1,t.helperPass.clear=!1,t.helperPass.renderToScreen=!1,t.helperPassOnTop=new r2(!1,void 0,t.camera),t.helperPassOnTop.hasTransmissionPass=!1,t.helperPassOnTop.clear=!1,t.helperPassOnTop.renderToScreen=!1,t.rt=new h.Lc(10,10,{minFilter:h.qa,magFilter:h.qa,wrapS:h.la,wrapT:h.la,depthBuffer:!0}),t}return M(n,e),b(n,[{key:"_ensureEffectPass",value:function(){var e,n=this;if(this.effectPass)return this.effectPass;var t=new f.n({preset:f.m.LOW,edgeDetectionMode:f.a.COLOR});return t.addEventListener("load",function(){var e;return null==(e=n.onSmaaTexturesLoaded)?void 0:e.call(n)}),this.effectPass=new f.g(this.camera,t),this._initializeArgs&&(e=this.effectPass).initialize.apply(e,N(this._initializeArgs)),this.effectPass.setSize(this._width,this._height),this.effectPass}},{key:"setSize",value:function(e,n){var t;this._width=e,this._height=n,this.rt.setSize(e,n),null==(t=this.effectPass)||t.setSize(e,n)}},{key:"sceneHelpers",get:function(){return this.helperPass.getScene()},set:function(e){this.helperPass.setScene(e)}},{key:"sceneHelpersOnTop",get:function(){return this.helperPassOnTop.getScene()},set:function(e){this.helperPassOnTop.setScene(e)}},{key:"setCamera",value:function(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}},{key:"initialize",value:function(e,t,a){var r;T(E(n.prototype),"initialize",this).call(this,e,t,a),this._initializeArgs=[e,t,a],null==(r=this.effectPass)||r.initialize(e,t,a)}},{key:"dispose",value:function(){var e;T(E(n.prototype),"dispose",this).call(this),this.rt.dispose(),null==(e=this.effectPass)||e.dispose(),this.helperPass.dispose(),this.helperPassOnTop.dispose()}},{key:"render",value:function(e,n,t){this.rt.depthTexture=n.depthTexture;var a=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt);var r=this._ensureEffectPass();r.renderToScreen=!1,r.render(e,this.rt,t),this.fullscreenMaterial.uniforms.inputBufferA.value=t.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=n.texture,e.setClearAlpha(a),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}}]),n}(f.b),r8=new h.ce({vertexShader:"#define GLSLIFY 1\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\nout vec3 n;void main(){\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\nvec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}",fragmentShader:"#define GLSLIFY 1\nin vec3 n;void main(){gl_FragColor=vec4(gl_FrontFacing ? n :-n,1.0);}",side:h.l}),r9=new h.ce({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}",fragmentShader:"#define GLSLIFY 1\nin vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){\n#ifdef DEBUG\nfloat d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0);\n#else\nvec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao;\n#endif\n}",uniforms:{texture_ao_lrez:new h.Le(null),texture_depth_lrez:new h.Le(null),texture_depth_hrez:new h.Le(null),near:new h.Le(null),far:new h.Le(null)}}),r7=function(e){function n(e,t){var a;return x(this,n),(a=_(this,n,["AmbientOcclusionPass",void 0,t])).fogEnabled=!1,a.fogNear=1,a.fogFar=1e3,a.fogMode=0,a.fogHeightParams=new h.Fc(.005,.01,0),a.frameIndex=0,a.sanitizeViewport=!1,a._runHalfRes=!0,a._width=1,a._height=1,a.gBuffer=new h.Lc(1024,1024,{type:s.c?h.Ba:h.Aa,depthTexture:new h.Cd(1024,1024),minFilter:h.qa,magFilter:h.qa}),a.depthBufferHighRes=new h.Lc(1024,1024,{depthTexture:new h.Cd(1024,1024)}),a.aoBuffer=new h.Lc(1024,1024,{minFilter:h.qa,magFilter:h.qa}),a.splineScene=e,a.splineCamera=t,a.hbaoMaterial=new h.ce({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"precision highp float;precision highp int;precision highp sampler2D;\n#define GLSLIFY 1\nin vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_color_pass;const vec2 blue_noise_in_disk[16]=vec2[16](vec2(0.4787119925022125,0.875764012336731),vec2(-0.3379560112953186,-0.7939590215682983),vec2(-0.9552590250968933,-0.028163999319076538),vec2(0.8645269870758057,0.3256889879703522),vec2(0.20934200286865234,-0.3956570029258728),vec2(-0.10677900165319443,0.6725850105285645),vec2(0.15621300041675568,0.2351129949092865),vec2(-0.4136439859867096,-0.08285599946975708),vec2(-0.41566699743270874,0.3239090144634247),vec2(0.14189599454402924,-0.9399799704551697),vec2(0.9549319744110107,-0.18251599371433258),vec2(-0.7661839723587036,0.4107989966869354),vec2(-0.4349119961261749,-0.45884498953819275),vec2(0.4152419865131378,-0.07872399687767029),vec2(0.7283350229263306,-0.4917770028114319),vec2(-0.05808600038290024,-0.06640099734067917));uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;uniform float fog_mode;uniform vec3 fog_height_params;uniform mat4 camera_world_matrix;float height_fog_factor(vec3 fog_world_delta,float fog_dist,vec3 camera_world_pos){float density=fog_height_params.x;float falloff=fog_height_params.y;float rel_y=camera_world_pos.y-fog_height_params.z;float cam_density=density*exp(clamp(-falloff*rel_y,-60.0,60.0));float x=clamp(falloff*fog_world_delta.y,-60.0,60.0);float x_safe=(x>=0.0 ? 1.0 :-1.0)*max(abs(x),1e-4);float optical_depth=cam_density*fog_dist*(1.0-exp(-x_safe))/x_safe;return 1.0-exp(-max(optical_depth,0.0));}vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/max(norm,1e-4);return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(gl_FragCoord.xy)&ivec2(127);float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=blue_noise_in_disk[index];vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}\n#define USE_GBUFFER_NORMALS\nvoid main(){vec3 view_space_p=get_view_position(v_uv);\n#ifdef USE_GBUFFER_NORMALS\nvec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;\n#else\nvec3 view_space_n=-rebuild_normal(v_uv,view_space_p);\n#endif\nfloat radius_ss=max(radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z),num_steps+1.0);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_linear=smoothstep(fog_near,fog_far,view_space_p.z);vec3 world_p=(camera_world_matrix*vec4(view_space_p.xy,-view_space_p.z,1.0)).xyz;vec3 cam_pos=camera_world_matrix[3].xyz;float fog_height=height_fog_factor(world_p-cam_pos,max(length(world_p-cam_pos),1e-6),cam_pos);float w_linear=1.0-step(0.5,fog_mode)+step(1.5,fog_mode);float w_height=step(0.5,fog_mode);float fog_factor=1.0-(1.0-fog_linear*w_linear)*(1.0-fog_height*w_height);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}",uniforms:{near:new h.Le(null),far:new h.Le(null),fov:new h.Le(null),proj_info:new h.Le(new h.Jc),is_ortho:new h.Le(!1),resolution:new h.Le(new h.Dc),radius_of_influence:new h.Le(8),radius_in_screen_space:new h.Le(1),exponent:new h.Le(1),ao_color:new h.Le(new h.Fc),bias:new h.Le(.5),texture_depth:new h.Le(null),texture_normals:new h.Le(null),texture_blue_noise:new h.Le(null),frame_index:new h.Le(0),fog_enabled:new h.Le(!1),fog_near:new h.Le(1),fog_far:new h.Le(1e3),fog_mode:new h.Le(0),fog_height_params:new h.Le(new h.Fc(.005,.01,0)),camera_world_matrix:new h.Le(new h.Oc)}}),a.radius=128,a.aoColor={r:0,g:0,b:0},a.bias=.5,a.hbaoMaterial.uniforms.texture_depth.value=a.gBuffer.depthTexture,a.hbaoMaterial.uniforms.texture_normals.value=a.gBuffer.texture,a.needsSwap=!0,a.aaBuffer=new h.Lc(1024,1024,{minFilter:h.qa,magFilter:h.qa,wrapS:h.la,wrapT:h.la,depthBuffer:!1,type:h.Aa}),a}return M(n,e),b(n,[{key:"_ensureEffectPass",value:function(){var e,n=this;if(this.effectPass)return this.effectPass;var t=new f.n({preset:f.m.ULTRA,edgeDetectionMode:f.a.COLOR});t.addEventListener("load",function(){var e;return null==(e=n.onSmaaTexturesLoaded)?void 0:e.call(n)}),this.effectPass=new f.g(this.camera,t),this._initializeArgs&&(e=this.effectPass).initialize.apply(e,N(this._initializeArgs));var a=this._runHalfRes?.5:1;return this.effectPass.setSize(this._width*a,this._height*a),this.effectPass}},{key:"initialize",value:function(e,t,a){var r;T(E(n.prototype),"initialize",this).call(this,e,t,a),this._initializeArgs=[e,t,a],null==(r=this.effectPass)||r.initialize(e,t,a)}},{key:"setBlueNoiseTexture",value:function(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}},{key:"setSize",value:function(e,n){this._width=e,this._height=n,this.depthBufferHighRes.setSize(e,n);var t,a=this._runHalfRes?.5:1,r=e*a,i=n*a;this.gBuffer.setSize(r,i),this.aoBuffer.setSize(r,i),this.hbaoMaterial.uniforms.resolution.value.set(r,i),this.aaBuffer.setSize(r,i),null==(t=this.effectPass)||t.setSize(r,i)}},{key:"runHalfRes",get:function(){return this._runHalfRes},set:function(e){this._runHalfRes=e,this.setSize(this._width,this._height)}},{key:"setCamera",value:function(e){this.splineCamera=e}},{key:"setScene",value:function(e){this.splineScene=e}},{key:"setDepthTexture",value:function(e){this.depthBufferHighRes.depthTexture=e,r9.uniforms.texture_depth_hrez.value=e,r9.needsUpdate=!0}},{key:"render",value:function(e,n,t){var a=null,r=null,i=null,o=null,s=function(n){e.setViewport(0,0,n.width,n.height)};this.sanitizeViewport&&(a=new h.Jc,r=new h.Jc,e.getViewport(a),e.getScissor(r),i=e.getScissorTest(),o=e.getRenderTarget(),e.setScissorTest(!1)),this.splineScene.overrideMaterial=r8;var l=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),this.sanitizeViewport&&s(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),this.runHalfRes&&(r8.colorWrite=!1,e.setRenderTarget(this.depthBufferHighRes),this.sanitizeViewport&&s(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),r8.colorWrite=!0,e.state.buffers.color.setMask(!0)),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=l,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.fog_mode.value=this.fogMode,this.hbaoMaterial.uniforms.fog_height_params.value.copy(this.fogHeightParams),this.hbaoMaterial.uniforms.camera_world_matrix.value.copy(this.splineCamera.matrixWorld),this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;var c=this.splineCamera.perspCamera.projectionMatrix.elements,u=2/c[0],d=2/c[5],f=-(1-c[8])/c[0],p=-(1+c[9])/c[5];this.hbaoMaterial.uniforms.proj_info.value.set(u,d,f,p);var v=this.splineCamera.perspCamera.fov*(Math.PI/180),m=this.hbaoMaterial.uniforms.resolution.value.y/(2*Math.tan(.5*v)),g=.5*this.hbaoMaterial.uniforms.radius_of_influence.value*m;this.hbaoMaterial.uniforms.radius_in_screen_space.value=g,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;var _=this.splineCamera.orthoCamera.projectionMatrix.elements,x=2/_[0],S=2/_[5],y=-(1+_[12])/_[0],b=-(1-_[13])/_[5];this.hbaoMaterial.uniforms.proj_info.value.set(x,S,y,b);var w=this.hbaoMaterial.uniforms.resolution.value.y/S*.5,T=this.hbaoMaterial.uniforms.radius_of_influence.value*w;this.hbaoMaterial.uniforms.radius_in_screen_space.value=T,this.hbaoMaterial.uniforms.is_ortho.value=!0}var E=e.aoRenderTarget;if(this.runHalfRes)this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),this.sanitizeViewport&&s(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=r9,r9.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,r9.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,r9.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(E),this.sanitizeViewport&&s(E),e.clear(),e.render(this.scene,this.camera);else{this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),this.sanitizeViewport&&s(this.aaBuffer),e.clear(),e.render(this.scene,this.camera);var M=this._ensureEffectPass();M.renderToScreen=!1,M.render(e,this.aaBuffer,E)}this.sanitizeViewport&&a&&r&&null!==i&&(e.setRenderTarget(o),e.setViewport(a.x,a.y,a.z,a.w),e.setScissor(r.x,r.y,r.z,r.w),e.setScissorTest(i))}},{key:"dispose",value:function(){var e;T(E(n.prototype),"dispose",this).call(this),this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose(),this.aaBuffer.dispose(),null==(e=this.effectPass)||e.dispose(),this.hbaoMaterial.dispose(),this.splineScene=null,this.splineCamera=null}}]),n}(f.b),ie=function(e){function n(){var e;return x(this,n),(e=_(this,n,[new h.ce({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tMap;\nuniform vec2 resolution;\nvarying vec2 vUv;\n\nuniform vec2 uResolution;\nuniform vec2 uCoords;\n\n\nfloat rectangle(vec2 st, vec2 size) {\n size = vec2(0.5) - size * 0.5;\n vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));\n uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));\n\n return uv.x * uv.y;\n}\n\nuniform vec2 uSize;\nuniform float uScale;\nuniform float uDPR;\nuniform float uCurrent;\nuniform vec3 uSceneColor;\n\nvoid main() {\n vec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n screenUv *= 1.0 / uDPR;\n\n vec2 center = vec2(0.5, -0.5);\n vec2 outsideUv = screenUv;\n outsideUv += center;\n outsideUv -= uCoords.xy / uResolution.xy;\n outsideUv = (outsideUv - 0.5) + 0.5;\n outsideUv -= center;\n vec2 s = (uSize / uResolution) * uScale;\n float isOutside = 1.0 - rectangle(outsideUv, s);\n \n vec2 mid = vec2(0.5);\n vec2 insideUv = (screenUv - mid + s * mid) / s;\n vec4 background = texture2D(tInput, screenUv);\n vec4 image = texture2D(tMap, insideUv);\n gl_FragColor = mix(image, background, isOutside);\n}\n",uniforms:{tInput:new h.Le(null),tMap:new h.Le(null),uResolution:new h.Le(new h.Dc),uSize:new h.Le(new h.Dc),uCoords:new h.Le(new h.Dc),uScale:new h.Le(1),uSceneColor:new h.Le(new h.Tc(0xff0000)),uDPR:new h.Le(1),uCurrent:new h.Le(0)}}),"tInput"])).needsSwap=!0,e}return M(n,e),b(n,[{key:"uniforms",get:function(){return this.fullscreenMaterial.uniforms}},{key:"texture",get:function(){return this.uniforms.tMap.value},set:function(e){this.uniforms.tMap.value=e}}]),n}(f.j),it=function(e){function n(){var e;return x(this,n),(e=_(this,n,[new h.ce({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D toScene;\nuniform sampler2D fromScene;\nuniform vec2 resolution;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nuniform float mixRatio;\nuniform sampler2D tMixTexture;\nuniform int useTexture;\nuniform float threshold;\n\nvoid main() {\n vec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n screenUv *= 1.0 / uDPR;\n\n vec4 texel1 = texture2D( fromScene, screenUv );\n vec4 texel2 = texture2D( toScene, screenUv );\n\n if (useTexture==1) {\n \n vec4 transitionTexel = texture2D( tMixTexture, screenUv );\n float r = mixRatio * (1.0 + threshold * 2.0) - threshold;\n float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);\n \n gl_FragColor = mix( texel1, texel2, mixf );\n } else {\n \n gl_FragColor = mix( texel1, texel2, mixRatio );\n \n }\n}\n",uniforms:{toScene:new h.Le(null),fromScene:new h.Le(null),uResolution:new h.Le(new h.Dc),uDPR:new h.Le(1),mixRatio:new h.Le(0),threshold:new h.Le(.1),useTexture:new h.Le(0),tMixTexture:{value:[][0]}}}),"toScene"])).needsSwap=!0,e}return M(n,e),b(n,[{key:"uniforms",get:function(){return this.fullscreenMaterial.uniforms}},{key:"texture",get:function(){return this.uniforms.fromScene.value},set:function(e){this.uniforms.fromScene.value=e}}]),n}(f.j),ia=function(e){function n(){var e;return x(this,n),(e=_(this,n,[new h.ce({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nuniform sampler2D blurredInputBuffer;\nuniform sampler2D overlay;\nuniform float blurIntensity;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nvoid main() {\n vec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n screenUv *= 1.0 / uDPR;\n\n vec4 texel1 = texture2D( overlay, screenUv );\n vec4 texel2 = texture2D( inputBuffer, screenUv );\n vec4 texel3 = texture2D( blurredInputBuffer, screenUv );\n\n float blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity;\n gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a );\n}\n",uniforms:{inputBuffer:new h.Le(null),blurredInputBuffer:new h.Le(null),overlay:new h.Le(null),uResolution:new h.Le(new h.Dc),uDPR:new h.Le(1),blurIntensity:new h.Le(0)}})]))._blurEnabled=!1,e.blurTarget=new h.Lc(1,1,{minFilter:h.qa,magFilter:h.qa,wrapS:h.la,wrapT:h.la}),e.blurPass=new f.h({width:window.innerWidth,height:window.innerHeight,kernelSize:f.l.HUGE,resolutionScale:.25}),e.blurPass.renderToScreen=!1,e.uniforms.blurredInputBuffer.value=e.blurTarget.texture,e}return M(n,e),b(n,[{key:"uniforms",get:function(){return this.fullscreenMaterial.uniforms}},{key:"texture",get:function(){return this.uniforms.overlay.value},set:function(e){this.uniforms.overlay.value=e}},{key:"setResolution",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.uniforms.uResolution.value.set(e,n),this.uniforms.uDPR.value=t,this.blurPass.setSize(e,n),this.blurTarget.setSize(e,n),this.blurPass.setSize(e,n)}},{key:"uiCanvas",get:function(){return this._uiCanvas},set:function(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);var n=e.frame;if(n){var t=n.data.backgroundBlur,a=t.radius;this._blurEnabled=t.enabled,this.uniforms.blurIntensity.value=+!!this._blurEnabled,this.blurPass.scale=a/3}}},{key:"render",value:function(e,t,a,r,i){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,t,this.blurTarget,r,i)),T(E(n.prototype),"render",this).call(this,e,t,a,r,i)}},{key:"dispose",value:function(){T(E(n.prototype),"dispose",this).call(this),this.blurTarget.dispose(),this.blurPass.dispose(),this.fullscreenMaterial.dispose(),this._uiCanvas=void 0}}]),n}(f.j),ir=function(e){function n(){return x(this,n),_(this,n,[new h.ce({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tOverlayImage;\nvarying vec2 vUv;\nuniform vec2 uResolution;\nuniform vec2 uRightBottom;\nuniform vec2 uImageSize;\nuniform float uScale;\nuniform float uDPR;\n\nvec3 blendNormal(vec3 base, vec3 blend) {\n return blend;\n}\n\nvec3 blendNormal(vec3 base, vec3 blend, float opacity) {\n return (blendNormal(base, blend) * opacity + base * (1.0 - opacity));\n}\n\nvec4 drawFixedSizeImage(sampler2D image, vec2 screenUV, vec2 imageSize, vec2 imageCoords, vec2 screenSize, float dpr) {\n vec2 uv = (screenUV * screenSize * dpr - imageCoords) / (imageSize * dpr);\n if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {\n return vec4(0.0);\n }\n return texture2D(image, uv);\n}\n\nvoid main() {\n vec2 screenUV = gl_FragCoord.xy / (uResolution.xy * uDPR);\n vec2 imageCoords = vec2(uResolution.x * uDPR - uImageSize.x * uScale * uDPR - uRightBottom.x * uDPR, uRightBottom.y * uDPR);\n vec4 background = texture2D(tInput, screenUV);\n vec4 image = drawFixedSizeImage(tOverlayImage, screenUV, uImageSize * uScale, imageCoords, uResolution, uDPR);\n gl_FragColor = vec4(blendNormal(background.rgb, image.rgb, image.a), max(background.a, image.a));\n}\n",uniforms:{tInput:new h.Le(null),tOverlayImage:new h.Le(null),uResolution:new h.Le(new h.Dc),uImageSize:new h.Le(new h.Dc),uRightBottom:new h.Le(new h.Dc(20,20)),uScale:new h.Le(.25),uDPR:new h.Le(1)}}),"tInput"])}return M(n,e),b(n,[{key:"uniforms",get:function(){return this.fullscreenMaterial.uniforms}},{key:"texture",get:function(){return this.uniforms.tOverlayImage.value},set:function(e){this.uniforms.tOverlayImage.value=e;var n=e.image;this.uniforms.uImageSize.value.set(n.width,n.height)}}]),n}(f.j),ii=function(e){function n(){var e;return x(this,n),(e=_(this,n,[new h.ce({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nvarying vec2 vUv;\n\nvec3 SrgbToLinear(vec3 color) {\n \n vec3 sRGB = color.rgb;\n color.rgb = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);\n return color;\n}\n\nvoid main() {\n vec4 texel = texture2D(inputBuffer, vUv);\n texel.rgb = SrgbToLinear(texel.rgb);\n gl_FragColor = texel;\n}\n",uniforms:{inputBuffer:new h.Le(null),uResolution:new h.Le(new h.Dc),uDPR:new h.Le(1)}}),"inputBuffer"])).needsSwap=!0,e}return M(n,e),b(n,[{key:"uniforms",get:function(){return this.fullscreenMaterial.uniforms}}]),n}(f.j);function io(e,n){return n&&n.enabled&&e.push(n.effect),e}var is=function(e){function n(e,t){x(this,n),(o=_(this,n))._needsDOFResize=t,o.postprocessingState=d.ra.defaultData,o._scene=new h.Vc,o._camera=new l.a,o.effects=new Map,o.blueNoiseTexture=new h.nd,o._renderToScreen=!0,o._isUIOverlayEnabled=!1,o.timer=new h.Je,o.renderer=e,o.debug=!1;var a=!0,r=!1,i=void 0;try{for(var o,s,c=(0,p.c)()[Symbol.iterator]();!(a=(s=c.next()).done);a=!0){var u=L(s.value,2),f=u[0],v=u[1];o.effects.set(f,v())}}catch(e){r=!0,i=e}finally{try{a||null==c.return||c.return()}finally{if(r)throw i}}o.effectComposer=new r4(o.renderer),o.effectComposer.autoRenderToScreen=!1,o.opaquePass=new r2(!0,o.scene,o.camera),o.opaquePass.clear=!0,o.transmissionPass=new r0(o.scene,o.camera,o.renderer),o.aoPass=new r7(o.scene,o.camera),o.taaPass=new r$,o.taaPass.renderToScreen=!1,o.helperPass=new r6(o.camera),o.helperPass.renderToScreen=!1;var m=function(){o.dispatchEvent({type:"smaaloaded"})};return o.aoPass.onSmaaTexturesLoaded=m,o.helperPass.onSmaaTexturesLoaded=m,o.stylesOverlayPass=new ie,o.stylesOverlayPass.enabled=!1,o.uiOverlayPass=new ia,o.uiOverlayPass.enabled=!1,o.logoOverlayPass=new ir,o.logoOverlayPass.enabled=!1,o.sceneTransitionPass=new it,o.sceneTransitionPass.enabled=!1,o.srgbToLinear=new ii,o.srgbToLinear.enabled=!1,o._initCopyPass(),o._initPasses(),o}return M(n,e),b(n,[{key:"overlayTexture",get:function(){return this.stylesOverlayPass.texture},set:function(e){void 0!==e?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}},{key:"sceneHelpers",get:function(){return this.helperPass.sceneHelpers},set:function(e){this.helperPass.sceneHelpers=e}},{key:"sceneHelpersOnTop",get:function(){return this.helperPass.sceneHelpersOnTop},set:function(e){this.helperPass.sceneHelpersOnTop=e}},{key:"scene",get:function(){return this._scene},set:function(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}},{key:"camera",get:function(){return this._camera},set:function(e){var n,t=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),t&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),null==(n=this.effects.get("depthOfField"))||n.setCamera(e)}},{key:"updateRenderToScreen",value:function(){for(var e=!1,n=this.effectComposer.passes.length-1;n>=0;n--){var t=this.effectComposer.passes[n];!0!==t.enabled||e||!this._renderToScreen?t.renderToScreen=!1:(t.renderToScreen=!0,e=!0)}}},{key:"isUIOverlayEnabled",get:function(){return this._isUIOverlayEnabled}},{key:"disableUIOverlay",value:function(){this._isUIOverlayEnabled=!1}},{key:"enableUIOverlay",value:function(){this._isUIOverlayEnabled=!0}},{key:"disableHelpers",value:function(){this.helperPass.enabled=!1,this.updateRenderToScreen()}},{key:"enableHelpers",value:function(){this.helperPass.enabled=!0,this.updateRenderToScreen()}},{key:"updateBlueNoiseTexture",value:function(e){this.blueNoiseTexture=new h.nd(e,128,128),this.blueNoiseTexture.wrapS=h.ka,this.blueNoiseTexture.wrapT=h.ka,this.blueNoiseTexture.minFilter=h.na,this.blueNoiseTexture.magFilter=h.na,this.blueNoiseTexture.needsUpdate=!0}},{key:"setAmbientOcclusionParams",value:function(e,n,t,a,r,i,o,s,l){this.aoPass.enabled=e,this.aoPass.radius=n,this.aoPass.bias=t,this.aoPass.aoColor=a,this.aoPass.fogEnabled=r,this.aoPass.fogNear=i,this.aoPass.fogFar=o,this.aoPass.fogMode=d.pa.getModeIndex({mode:s.mode}),this.aoPass.fogHeightParams.set(s.density,s.heightFalloff,s.heightBase),!l!==this.aoPass.runHalfRes&&(this.aoPass.runHalfRes=!l)}},{key:"setTransmissionPassEnabled",value:function(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}},{key:"_initPasses",value:function(){var e,n;if(null==(e=this.uvEffectPass)||e.dispose(),null==(n=this.effectPass)||n.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){var t,a=[this.effects.get("pixelation")].reduce(io,[]);a.length>0&&(this.uvEffectPass=S(f.g,[this.camera].concat(N(a))),this.uvEffectPass.renderToScreen=!1,this.uvEffectPass.encodeOutput=!1,this.effectComposer.addPass(this.uvEffectPass));var r=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(io,[]);if(r.length>0&&(this.effectPass=S(f.g,[this.camera].concat(N(r))),this.effectPass.renderToScreen=!1,this.effectPass.encodeOutput=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&(null==(t=this.effects.get("depthOfField"))?void 0:t.enabled)&&void 0!==window)){var i=this.renderer.viewportWidth,o=this.renderer.viewportHeight;this.renderer.setSize(i-1,o-1),this.renderer.setSize(i,o)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.srgbToLinear),this.effectComposer.addPass(this.logoOverlayPass)}},{key:"_initCopyPass",value:function(){if(!this._savePass){var e=new h.Dc;this.renderer.getDrawingBufferSize(e),this._rt=new h.Lc(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:h.ka,wrapT:h.ka}),this._rt.samples=0,this.renderer.outputColorSpace===h.Ib&&(this._rt.texture.colorSpace=h.Ib),this._savePass=new f.c(this._rt,!1),this._savePass.renderToScreen=!1}}},{key:"setCopyPass",value:function(e){this._rt=e,this._savePass=new f.c(this._rt,!1),this.renderToScreen=!1}},{key:"renderToScreen",get:function(){return this._renderToScreen},set:function(e){if(this._renderToScreen!==e){var n=this.effectComposer;n&&(!0===e?n.removePass(this._savePass):n.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}}},{key:"sceneTransitionFromTexture",get:function(){return this.sceneTransitionPass.texture},set:function(e){e!==this.sceneTransitionPass.texture&&(null!==e?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}},{key:"setWatermark",value:function(e){this.logoOverlayPass.enabled=null!==e,e&&(this.logoOverlayPass.texture=e)}},{key:"texture",get:function(){return this._rt&&this._rt.texture}},{key:"renderTarget",get:function(){return this._rt}},{key:"updatePostprocessing",value:function(e){var n=e.enabled,t=function(e,n){if(null==e)return{};var t,a,r,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,t=Reflect.ownKeys(Object(e));r<t.length;r++)a=t[r],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(i[a]=e[a]);return i}if(i=function(e,n){if(null==e)return{};var t,a,r={},i=Object.getOwnPropertyNames(e);for(a=0;a<i.length;a++)t=i[a],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t]);return r}(e,n),Object.getOwnPropertySymbols)for(r=0,t=Object.getOwnPropertySymbols(e);r<t.length;r++)a=t[r],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(i[a]=e[a]);return i}(e,["enabled"]),a=!1;n!==this.postprocessingState.enabled&&(a=!0);var r=!0,i=!1,o=void 0;try{for(var s,l=Object.entries(t)[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var c=s.value,u=c[1],d=this.effects.get(c[0]);if(!d){var h=(0,p.b)(c[0]);h?(d=h(),this.effects.set(c[0],d),"depthOfField"===c[0]&&d.setCamera(this._camera)):(null==u?void 0:u.enabled)&&(0,p.f)(c[0],"webgl")}if(d){d.enabled!==u.enabled&&(a=!0),d.enabled=u.enabled;var v=!0,m=!1,g=void 0;try{for(var _,x=Object.entries(u)[Symbol.iterator]();!(v=(_=x.next()).done);v=!0){var S=L(_.value,2),y=S[0],b=S[1];"blendFunction"===y?d.blendFunction=Object.values(f.f).includes(b)?b:f.f.NORMAL:d[y]=b}}catch(e){m=!0,g=e}finally{try{v||null==x.return||x.return()}finally{if(m)throw g}}}}}catch(e){i=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}this.postprocessingState=e,a&&this._initPasses()}},{key:"render",value:function(){this.renderer.shadowMap.type===h.f&&this._normalizeShadowDepthTextures(),this.timer.update(),this.effectComposer.render(this.timer.getDelta())}},{key:"_normalizeShadowDepthTextures",value:function(){this._scene.traverse(function(e){var n,t;if(e.isLight){var a=null==(t=e.shadow)||null==(n=t.map)?void 0:n.depthTexture;a&&null!==a.compareFunction&&(a.compareFunction=null,a.minFilter=h.na,a.magFilter=h.na,a.needsUpdate=!0)}})}},{key:"setScissor",value:function(e,n,t,a){C(e,h.Jc)?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,t,a),this.effectComposer.outputBuffer.scissor.set(e,n,t,a));var r=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(r),this.effectComposer.outputBuffer.scissor.multiplyScalar(r),this.renderer.setScissor(e,n,t,a)}},{key:"setScissorTest",value:function(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}},{key:"setViewport",value:function(e,n,t,a){C(e,h.Jc)?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,t,a),this.effectComposer.outputBuffer.viewport.set(e,n,t,a))}},{key:"resize",value:function(e,n,t){if(this.effectComposer.setSize(e,n,t),this._rt){var a=this.renderer.getPixelRatio();this._rt.setSize(e*a,n*a)}}},{key:"dispose",value:function(){var e,n,t;null==(e=this.uvEffectPass)||e.dispose(),null==(n=this.effectPass)||n.dispose(),this.effectComposer.dispose(),this.blueNoiseTexture.dispose(),null==(t=this._rt)||t.dispose(),this.effects.forEach(function(e){return e.dispose()}),this.effects.clear(),this._scene=void 0,this._camera=void 0,this.renderer=void 0}}]),n}(h.Bc),il=new h.Ic,ic=new h.Dc,iu=function(e){function n(e){x(this,n),(t=_(this,n,[e]))._pixelRatio=t.getPixelRatio(),t.viewportWidth=1,t.viewportHeight=1,t.resolution=new h.Dc,t.dummyCamera=new l.a,t.sceneTransitionDuration=0,t.sceneTransitionTimeRemaining=-1,t.manageShadowUpdates=!1,t.forceShadowUpdates=!1,t.clear=function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],n=!(arguments.length>1)||void 0===arguments[1]||arguments[1],a=!(arguments.length>2)||void 0===arguments[2]||arguments[2],r=t.getContext(),i=0;e&&(i|=r.COLOR_BUFFER_BIT),n&&(i|=r.DEPTH_BUFFER_BIT),a&&(i|=r.STENCIL_BUFFER_BIT),r.clear(i),r.clearBufferfv(r.COLOR,1,[0,0,0,1])},function(){if(!rJ.test(eT.lights_pars_begin)){if(eT.lights_pars_begin.includes(rZ))return;throw Error("spe: could not find getDistanceAttenuation in lights_pars_begin — three shader chunk layout changed")}eT.lights_pars_begin=eT.lights_pars_begin.replace(rJ,rZ)}(),t.pipeline=new is(t,null!=(r=null==e?void 0:e.needsDOFResize)&&r),t.autoClear=!1;var t,r,i=t.renderBufferDirect;t.renderBufferDirect=function(e,n,r,o,s,l){(0,a.a)(o)&&i.call(t,e,n,r,o.getDepthPrepassTwin(o.side),s,l),i.call(t,e,n,r,o,s,l)};var o=t.setPixelRatio.bind(t),s=t.setSize.bind(t);return t.shadowMap.enabled=!0,t.shadowMap.type=h.f,t.dummyCamera.matrixAutoUpdate=!1,t.domElement.removeAttribute("data-engine"),t._applyPreferredDrawingBufferColorSpace(),t.setPixelRatio=function(e){t._pixelRatio!==e&&(t._pixelRatio=e,o(e))},t.setSize=function(e,n){var a,r,i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];(t.viewportWidth!==e||t.viewportHeight!==n)&&(t.viewportWidth=e,t.viewportHeight=n,s(e,n,i),null==(a=t.normalRenderTarget)||a.setSize(e*t._pixelRatio,n*t._pixelRatio),t._resizeTransmission(e,n),null==(r=t.transmissionDepthTarget)||r.setSize(e*t._pixelRatio/2,n*t._pixelRatio/2),t.pipeline.resize(e,n,i))},t._superDispose=t.dispose,t.dispose=t._currentDispose,t}return M(n,e),b(n,[{key:"_applyPreferredDrawingBufferColorSpace",value:function(){var e=this.getContext();if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}}},{key:"outputColorSpace",get:function(){return T(E(n.prototype),"outputColorSpace",this)},set:function(e){(function(e,n,t,a,r){if(!P(e,n,t,a||e)&&r)throw Error("failed to set property")})(E(n.prototype),"outputColorSpace",e,this,!0),this._applyPreferredDrawingBufferColorSpace()}},{key:"createAORenderTarget",value:function(){void 0===this.aoRenderTarget&&(this.aoRenderTarget=new h.Lc(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:h.qa,magFilter:h.qa,wrapS:h.la,wrapT:h.la,depthBuffer:!1}))}},{key:"_resizeTransmission",value:function(e,n){var t,a;null==(t=this.transmissionRenderTarget)||t.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),null==(a=this.aoRenderTarget)||a.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}},{key:"hdTransmission",get:function(){return 1===aZ.transmissionLod.value},set:function(e){aZ.transmissionLod.value=!0===e?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}},{key:"createTransmissionRenderTarget",value:function(){void 0===this.transmissionRenderTarget&&(this.transmissionRenderTarget=new h.Lc(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:h.sa,magFilter:h.qa,wrapS:h.la,wrapT:h.la,depthBuffer:!1}),this.transmissionDepthTarget=new h.Lc(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:h.na,magFilter:h.na,depthBuffer:!1}))}},{key:"createNormalRenderTarget",value:function(e){var n,t=e.outline&&e.cavity?"both":e.cavity?"normals":"hash";void 0!==this.normalRenderTarget&&this.normalRenderTargetFlavor!==t&&(null==(n=this.normalRenderTarget.depthTexture)||n.dispose(),this.normalRenderTarget.dispose(),this.normalRenderTarget=void 0),void 0===this.normalRenderTarget&&(this.normalRenderTarget=new h.Lc(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{count:"both"===t?2:1,generateMipmaps:!1,minFilter:h.na,magFilter:h.na,type:"normals"===t?h.Ba:h.Aa,depthTexture:new h.Cd(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}),"both"===t&&(this.normalRenderTarget.textures[1].type=h.Ba),this.normalRenderTargetFlavor=t)}},{key:"renderNormal",value:function(e,n,t){if(this.normalRenderTarget){this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),n.traverseEntity(function(e){e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),rX.value=C(t,l.a)?(t.far-t.near)/1e4:1;var a,r=null!=(a=this.normalRenderTargetFlavor)?a:"hash";n.overrideMaterial="both"===r?rK:"normals"===r?rY:rq,this.render(n,t),this.setClearColor(n.bgColor,n.bgColor.a),this.setRenderTarget(null),n.overrideMaterial=e.wireframeState?o.e:null,t.layers.enable(0),t.layers.enable(3),n.traverseEntity(function(e){e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!0)})}}},{key:"renderSplineSceneWithDummyCamera",value:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.dummyCamera.updateCameraState(n.dataPatched),this.dummyCamera.matrix.copy(n.matrixWorld);var a=n.height,r=n.width,i=this.viewportWidth/this.viewportHeight;r<a?r=a*i:a=r/i,this.dummyCamera.setViewplaneSize(r,a);for(var o=0;o<t;o++)this.renderSplineScene(e,this.dummyCamera)}},{key:"renderSplineScene",value:function(e,n){var t,i,c,u,f,p,v,m,g,_,x=this,S=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},y=S.sceneHelpers,b=void 0===y?this.sceneHelpers:y,w=S.sceneHelpersOnTop,T=void 0===w?this.sceneHelpersOnTop:w,E=S.overrideTransmission,M=S.overrideNormal;(0,r.b)(this);var R=C(e,o.f)?e.activePage:e,A=R.visible;R.visible=!0;var P=R.scene,D=d.sa.isSoft(R.data.shadow)?h.f:h.g;if(this.shadowMap.type!==D&&(this.shadowMap.type=D,R.traverseEntity(function(e){var n;e.isLight&&(null==(n=e.shadow)?void 0:n.map)&&(e.shadow.map.dispose(),e.shadow.map=null,e.shadow.needsUpdate=!0)}),P.markShadowsDirty()),this.setClearColor(R.bgColor,R.bgColor.a),R.penumbraSizeArray.forEach(function(e,n){aZ.penumbraSize.value[n]=e}),aZ.pixelRatioNode.value=this.getPixelRatio(),0!==this.resolution.x&&0!==this.resolution.y?aZ.resolution.value.set(this.resolution.x,this.resolution.y):aZ.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),void 0!==M)aZ.normalRenderTarget.value=M,aZ.normalRenderTargetDepth.value=il,aZ.normalViewRenderTarget.value=il;else if(P.needsNormal()){var L=P.normalPassNeeds();this.createNormalRenderTarget(L);var U=this.normalRenderTargetFlavor,N=this.normalRenderTarget.textures;aZ.normalRenderTarget.value="normals"===U?il:N[0],aZ.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,aZ.normalViewRenderTarget.value="both"===U?N[1]:"normals"===U?N[0]:il,this.renderNormal(P,R,n)}a4.spe_fogMode.value=d.pa.getModeIndex({mode:R.fogMode}),a4.spe_fogHeightParams.value.set(null!=(t=R.fogDensity)?t:d.pa.getDensity({}),null!=(i=R.fogHeightFalloff)?i:d.pa.getHeightFalloff({}),null!=(c=R.fogHeightBase)?c:d.pa.getHeightBase({}));var I=R.data.ao,O=I.occlusion&&!a.c.enabled;if(O&&(this.createAORenderTarget(),aZ.aoRenderTarget.value=this.aoRenderTarget.texture),aZ.aoEnabled.value=O,this.pipeline.setAmbientOcclusionParams(O,I.radius,I.bias,R.aoColor,null!==R.fog,R.backupFog.near,R.backupFog.far,{mode:null!=(u=R.fogMode)?u:"linear",density:null!=(f=R.fogDensity)?f:d.pa.getDensity({}),heightFalloff:null!=(p=R.fogHeightFalloff)?p:d.pa.getHeightFalloff({}),heightBase:null!=(v=R.fogHeightBase)?v:d.pa.getHeightBase({})},I.aoFullRes&&!s.c),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&(null==(m=R.uiCanvas)?void 0:m.enabled)&&R.uiCanvas.texture&&R.uiCanvas.texture.image.width>0){var F=this.getSize(ic),z=this.getPixelRatio();(R.uiCanvas.width!==this.viewportWidth||R.uiCanvas.height!==this.viewportHeight||R.uiCanvas.dpr!==z)&&R.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},z),R.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=R.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(F.x,F.y,z),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();if(this.pipeline.logoOverlayPass.enabled){var k=this.getSize(ic),B=this.getPixelRatio();this.pipeline.logoOverlayPass.uniforms.uResolution.value.set(k.x,k.y),this.pipeline.logoOverlayPass.uniforms.uDPR.value=B}var V=!1;if(void 0!==E)aZ.transmissionRenderTarget.value=E,aZ.transmissionRenderTargetDepth.value=il,this.pipeline.setTransmissionPassEnabled(!1);else{var G=P.needsTransmission();G&&(void 0===this.transmissionRenderTarget&&(V=!0),this.createTransmissionRenderTarget(),aZ.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,aZ.aspectRatio.value=(g=this.viewportWidth)>=(_=this.viewportHeight)?new h.Dc(_/g,1):new h.Dc(1,g/_),aZ.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(G)}n.layers.enable(3),n.layers.enable(8),n.layers.enable(4),this.pipeline.sceneHelpers=b,this.pipeline.sceneHelpersOnTop=T,this.pipeline.taaPass.enabled=aZ.taaEnabled.value,this.pipeline.scene=R,this.pipeline.camera=n,V&&this.pipeline.transmissionPass.updatePasses(this);var H=(0,a.d)(R.postprocessing);this.pipeline.postprocessingState!==H&&(this.pipeline.updatePostprocessing(H),b||T||this.pipeline.disableHelpers()),void 0!==this.clearAlphaOverride&&this.setClearAlpha(this.clearAlphaOverride),P.shapeBlendIntances.forEach(function(e){e.onBeforeShadowPass(x)}),this.manageShadowUpdates&&(this.shadowMap.autoUpdate=!1,(P.shadowsDirty||this.forceShadowUpdates)&&(this.shadowMap.needsUpdate=!0)),R.overrideMaterial=P.wireframeState?o.e:null,this.pipeline.render(),this.manageShadowUpdates&&(P.shadowsDirty=!1),aZ.taaEnabled.value&&(aZ.frameIndex.value=(aZ.frameIndex.value+1)%16),C(n,l.a)&&n.copyHistory(),R.visible=A}},{key:"renderFromSceneForSceneTransitionPass",value:function(e,n,t){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,n),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=t,this.sceneTransitionTimeRemaining=t,this.pipeline.renderToScreen=!0;var a=this.pipeline.sceneTransitionPass.uniforms;a.uDPR.value=window.devicePixelRatio,a.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}},{key:"_currentDispose",value:function(){var e,n,t,a,r,i;this._superDispose(),this.pipeline.dispose(),null==(e=this.aoRenderTarget)||e.dispose(),this.aoRenderTarget=void 0,null==(n=this.transmissionRenderTarget)||n.dispose(),this.transmissionRenderTarget=void 0,null==(t=this.transmissionDepthTarget)||t.dispose(),this.transmissionDepthTarget=void 0,null==(r=this.normalRenderTarget)||null==(a=r.depthTexture)||a.dispose(),null==(i=this.normalRenderTarget)||i.dispose(),this.normalRenderTarget=void 0,this.normalRenderTargetFlavor=void 0,this.dummyCamera.dispose(),this.dummyCamera=void 0,aZ.normalRenderTarget.value=il,aZ.normalRenderTargetDepth.value=il,aZ.normalViewRenderTarget.value=il,aZ.transmissionRenderTarget.value=il,aZ.transmissionRenderTargetDepth.value=il,aZ.aoRenderTarget.value=il}}]),n}(tM)}}]);
|