Files
GDevelop/Resource3DPreview.worker.bf51c3b4bf3046ded6d1.worker.js
Florian Rival 61341b7e44 Updates
2025-10-14 14:31:02 +02:00

3 lines
593 KiB
JavaScript

/*! For license information please see Resource3DPreview.worker.bf51c3b4bf3046ded6d1.worker.js.LICENSE.txt */
!function(){"use strict";function e(t){return e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e(t)}function t(e,n){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,n)}function n(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function i(e,r,a){return i=n()?Reflect.construct.bind():function(e,n,i){var r=[null];r.push.apply(r,n);var a=new(Function.bind.apply(e,r));return i&&t(a,i.prototype),a},i.apply(null,arguments)}function r(n){var a="function"===typeof Map?new Map:void 0;return r=function(n){if(null===n||(r=n,-1===Function.toString.call(r).indexOf("[native code]")))return n;var r;if("function"!==typeof n)throw new TypeError("Super expression must either be null or a function");if("undefined"!==typeof a){if(a.has(n))return a.get(n);a.set(n,o)}function o(){return i(n,arguments,e(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),t(o,n)},r(n)}function a(e,t,n,i,r,a,o){try{var s=e[a](o),l=s.value}catch(u){return void n(u)}s.done?t(l):Promise.resolve(l).then(i,r)}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function s(e,t){if(e){if("string"===typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function l(e,t){var n="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=s(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){l=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw a}}}}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,a,o,s=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=a.call(n)).done)&&(s.push(i.value),s.length!==t);l=!0);}catch(c){u=!0,r=c}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw r}}return s}}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(){return c="undefined"!==typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,i){var r=function(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=e(t)););return t}(t,n);if(r){var a=Object.getOwnPropertyDescriptor(r,n);return a.get?a.get.call(arguments.length<3?t:i):a.value}},c.apply(this,arguments)}function h(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&t(e,n)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function m(t){var i=n();return function(){var n,r=e(t);if(i){var a=e(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===p(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}(this,n)}}function v(e){var t=function(e,t){if("object"!==p(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==p(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===p(t)?t:String(t)}function g(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(){_=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(L){l=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),s=new w(r||[]);return i(o,"_invoke",{value:E(e,n,s)}),o}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(L){return{type:"throw",arg:L}}}e.wrap=u;var h={};function d(){}function f(){}function m(){}var v={};l(v,a,(function(){return this}));var g=Object.getPrototypeOf,y=g&&g(g(R([])));y&&y!==t&&n.call(y,a)&&(v=y);var x=m.prototype=d.prototype=Object.create(v);function M(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,a,o,s){var l=c(e[i],e,a);if("throw"!==l.type){var u=l.arg,h=u.value;return h&&"object"==p(h)&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(h).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(l.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function E(e,t,n){var i="suspendedStart";return function(r,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw a;return C()}for(n.method=r,n.arg=a;;){var o=n.delegate;if(o){var s=T(o,n);if(s){if(s===h)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var l=c(e,t,n);if("normal"===l.type){if(i=n.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i="completed",n.method="throw",n.arg=l.arg)}}}function T(e,t){var n=t.method,i=e.iterator[n];if(void 0===i)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var r=c(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,h;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function t(){for(;++i<e.length;)if(n.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=m,i(x,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:f,configurable:!0}),f.displayName=l(m,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,s,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},M(S.prototype),l(S.prototype,o,(function(){return this})),e.AsyncIterator=S,e.async=function(t,n,i,r,a){void 0===a&&(a=Promise);var o=new S(u(t,n,i,r),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},M(x),l(x,s,"Generator"),l(x,a,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=R,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(n,i){return o.type="throw",o.arg=e,t.next=n,i&&(t.method="next",t.arg=void 0),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],o=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,v(i.key),i)}}function M(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var S,E="160",T=1,b=2,A=3,w=0,R=1,C=100,L=0,P=1,U=2,k=0,I=1,N=2,D=3,O=4,F=5,B=6,z="attached",H=301,G=302,V=303,W=304,X=306,j=1e3,q=1001,Y=1002,K=1003,Z=1004,J=1005,Q=1006,$=1007,ee=1008,te=1009,ne=1012,ie=1013,re=1014,ae=1015,oe=1016,se=1020,le=1023,ue=1026,ce=1027,he=33776,de=33777,fe=33778,pe=33779,me=36492,ve=2300,ge=2301,_e=2302,ye=2400,xe=2401,Me=2402,Se=2500,Ee=3001,Te="",be="srgb",Ae="srgb-linear",we="display-p3",Re="display-p3-linear",Ce="linear",Le="srgb",Pe="rec709",Ue="p3",ke=7680,Ie=35044,Ne="300 es",De=1035,Oe=2e3,Fe=2001,Be=function(){function e(){y(this,e)}return M(e,[{key:"addEventListener",value:function(e,t){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}},{key:"hasEventListener",value:function(e,t){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}},{key:"removeEventListener",value:function(e,t){if(void 0!==this._listeners){var n=this._listeners[e];if(void 0!==n){var i=n.indexOf(t);-1!==i&&n.splice(i,1)}}}},{key:"dispatchEvent",value:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var n=t.slice(0),i=0,r=n.length;i<r;i++)n[i].call(this,e);e.target=null}}}}]),e}(),ze=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],He=1234567,Ge=Math.PI/180,Ve=180/Math.PI;function We(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(ze[255&e]+ze[e>>8&255]+ze[e>>16&255]+ze[e>>24&255]+"-"+ze[255&t]+ze[t>>8&255]+"-"+ze[t>>16&15|64]+ze[t>>24&255]+"-"+ze[63&n|128]+ze[n>>8&255]+"-"+ze[n>>16&255]+ze[n>>24&255]+ze[255&i]+ze[i>>8&255]+ze[i>>16&255]+ze[i>>24&255]).toLowerCase()}function Xe(e,t,n){return Math.max(t,Math.min(n,e))}function je(e,t){return(e%t+t)%t}function qe(e,t,n){return(1-n)*e+n*t}function Ye(e){return 0===(e&e-1)&&0!==e}function Ke(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ze(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Je(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var Qe={DEG2RAD:Ge,RAD2DEG:Ve,generateUUID:We,clamp:Xe,euclideanModulo:je,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:qe,damp:function(e,t,n,i){return qe(e,t,1-Math.exp(-n*i))},pingpong:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t-Math.abs(je(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(He=e);var t=He+=1831565813;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Ge},radToDeg:function(e){return e*Ve},isPowerOfTwo:Ye,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:Ke,setQuaternionFromProperEuler:function(e,t,n,i,r){var a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),u=a((t+i)/2),c=o((t+i)/2),h=a((t-i)/2),d=o((t-i)/2),f=a((i-t)/2),p=o((i-t)/2);switch(r){case"XYX":e.set(s*c,l*h,l*d,s*u);break;case"YZY":e.set(l*d,s*c,l*h,s*u);break;case"ZXZ":e.set(l*h,l*d,s*c,s*u);break;case"XZX":e.set(s*c,l*p,l*f,s*u);break;case"YXY":e.set(l*f,s*c,l*p,s*u);break;case"ZYZ":e.set(l*p,l*f,s*c,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Je,denormalize:Ze},$e=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;y(this,t),t.prototype.isVector2=!0,this.x=e,this.y=n}return M(t,[{key:"width",get:function(){return this.x},set:function(e){this.x=e}},{key:"height",get:function(){return this.y},set:function(e){this.y=e}},{key:"set",value:function(e,t){return this.x=e,this.y=t,this}},{key:"setScalar",value:function(e){return this.x=e,this.y=e,this}},{key:"setX",value:function(e){return this.x=e,this}},{key:"setY",value:function(e){return this.y=e,this}},{key:"setComponent",value:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function(){return new this.constructor(this.x,this.y)}},{key:"copy",value:function(e){return this.x=e.x,this.y=e.y,this}},{key:"add",value:function(e){return this.x+=e.x,this.y+=e.y,this}},{key:"addScalar",value:function(e){return this.x+=e,this.y+=e,this}},{key:"addVectors",value:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}},{key:"addScaledVector",value:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}},{key:"sub",value:function(e){return this.x-=e.x,this.y-=e.y,this}},{key:"subScalar",value:function(e){return this.x-=e,this.y-=e,this}},{key:"subVectors",value:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}},{key:"multiply",value:function(e){return this.x*=e.x,this.y*=e.y,this}},{key:"multiplyScalar",value:function(e){return this.x*=e,this.y*=e,this}},{key:"divide",value:function(e){return this.x/=e.x,this.y/=e.y,this}},{key:"divideScalar",value:function(e){return this.multiplyScalar(1/e)}},{key:"applyMatrix3",value:function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}},{key:"min",value:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}},{key:"max",value:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}},{key:"clamp",value:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}},{key:"clampScalar",value:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}},{key:"ceil",value:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}},{key:"round",value:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},{key:"roundToZero",value:function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}},{key:"negate",value:function(){return this.x=-this.x,this.y=-this.y,this}},{key:"dot",value:function(e){return this.x*e.x+this.y*e.y}},{key:"cross",value:function(e){return this.x*e.y-this.y*e.x}},{key:"lengthSq",value:function(){return this.x*this.x+this.y*this.y}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"manhattanLength",value:function(){return Math.abs(this.x)+Math.abs(this.y)}},{key:"normalize",value:function(){return this.divideScalar(this.length()||1)}},{key:"angle",value:function(){var e=Math.atan2(-this.y,-this.x)+Math.PI;return e}},{key:"angleTo",value:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Xe(n,-1,1))}},{key:"distanceTo",value:function(e){return Math.sqrt(this.distanceToSquared(e))}},{key:"distanceToSquared",value:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n}},{key:"manhattanDistanceTo",value:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}},{key:"setLength",value:function(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}},{key:"lerpVectors",value:function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}},{key:"equals",value:function(e){return e.x===this.x&&e.y===this.y}},{key:"fromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e}},{key:"fromBufferAttribute",value:function(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}},{key:"rotateAround",value:function(e,t){var n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}},{key:"random",value:function(){return this.x=Math.random(),this.y=Math.random(),this}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:case"end":return e.stop()}}),e,this)}))}]),t}(),et=function(){function e(t,n,i,r,a,o,s,l,u){y(this,e),e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,n,i,r,a,o,s,l,u)}return M(e,[{key:"set",value:function(e,t,n,i,r,a,o,s,l){var u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=r,u[5]=s,u[6]=n,u[7]=a,u[8]=l,this}},{key:"identity",value:function(){return this.set(1,0,0,0,1,0,0,0,1),this}},{key:"copy",value:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}},{key:"extractBasis",value:function(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}},{key:"setFromMatrix4",value:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}},{key:"multiply",value:function(e){return this.multiplyMatrices(this,e)}},{key:"premultiply",value:function(e){return this.multiplyMatrices(e,this)}},{key:"multiplyMatrices",value:function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],u=n[4],c=n[7],h=n[2],d=n[5],f=n[8],p=i[0],m=i[3],v=i[6],g=i[1],_=i[4],y=i[7],x=i[2],M=i[5],S=i[8];return r[0]=a*p+o*g+s*x,r[3]=a*m+o*_+s*M,r[6]=a*v+o*y+s*S,r[1]=l*p+u*g+c*x,r[4]=l*m+u*_+c*M,r[7]=l*v+u*y+c*S,r[2]=h*p+d*g+f*x,r[5]=h*m+d*_+f*M,r[8]=h*v+d*y+f*S,this}},{key:"multiplyScalar",value:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}},{key:"determinant",value:function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*r*u+n*o*s+i*r*l-i*a*s}},{key:"invert",value:function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=u*a-o*l,h=o*s-u*r,d=l*r-a*s,f=t*c+n*h+i*d;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);var p=1/f;return e[0]=c*p,e[1]=(i*l-u*n)*p,e[2]=(o*n-i*a)*p,e[3]=h*p,e[4]=(u*t-i*s)*p,e[5]=(i*r-o*t)*p,e[6]=d*p,e[7]=(n*s-l*t)*p,e[8]=(a*t-n*r)*p,this}},{key:"transpose",value:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}},{key:"getNormalMatrix",value:function(e){return this.setFromMatrix4(e).invert().transpose()}},{key:"transposeIntoArray",value:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}},{key:"setUvTransform",value:function(e,t,n,i,r,a,o){var s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*a+l*o)+a+e,-i*l,i*s,-i*(-l*a+s*o)+o+t,0,0,1),this}},{key:"scale",value:function(e,t){return this.premultiply(tt.makeScale(e,t)),this}},{key:"rotate",value:function(e){return this.premultiply(tt.makeRotation(-e)),this}},{key:"translate",value:function(e,t){return this.premultiply(tt.makeTranslation(e,t)),this}},{key:"makeTranslation",value:function(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}},{key:"makeRotation",value:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}},{key:"makeScale",value:function(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}},{key:"equals",value:function(e){for(var t=this.elements,n=e.elements,i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<9;n++)this.elements[n]=e[n+t];return this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}},{key:"clone",value:function(){return(new this.constructor).fromArray(this.elements)}}]),e}(),tt=new et;function nt(e){for(var t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;function it(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var rt={};function at(e){e in rt||(rt[e]=!0,console.warn(e))}var ot,st=(new et).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),lt=(new et).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ut=(g(S={},Ae,{transfer:Ce,primaries:Pe,toReference:function(e){return e},fromReference:function(e){return e}}),g(S,be,{transfer:Le,primaries:Pe,toReference:function(e){return e.convertSRGBToLinear()},fromReference:function(e){return e.convertLinearToSRGB()}}),g(S,Re,{transfer:Ce,primaries:Ue,toReference:function(e){return e.applyMatrix3(lt)},fromReference:function(e){return e.applyMatrix3(st)}}),g(S,we,{transfer:Le,primaries:Ue,toReference:function(e){return e.convertSRGBToLinear().applyMatrix3(lt)},fromReference:function(e){return e.applyMatrix3(st).convertLinearToSRGB()}}),S),ct=new Set([Ae,Re]),ht={enabled:!0,_workingColorSpace:Ae,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!ct.has(e))throw new Error('Unsupported working color space, "'.concat(e,'".'));this._workingColorSpace=e},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;var i=ut[t].toReference;return(0,ut[n].fromReference)(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return ut[e].primaries},getTransfer:function(e){return e===Te?Ce:ut[e].transfer}};function dt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ft(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var pt=function(){function e(){y(this,e)}return M(e,null,[{key:"getDataURL",value:function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"===typeof HTMLCanvasElement)return e.src;var t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ot&&(ot=it("canvas")),ot.width=e.width,ot.height=e.height;var n=ot.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ot}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}},{key:"sRGBToLinear",value:function(e){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap){var t=it("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);for(var i=n.getImageData(0,0,e.width,e.height),r=i.data,a=0;a<r.length;a++)r[a]=255*dt(r[a]/255);return n.putImageData(i,0,0),t}if(e.data){for(var o=e.data.slice(0),s=0;s<o.length;s++)o instanceof Uint8Array||o instanceof Uint8ClampedArray?o[s]=Math.floor(255*dt(o[s]/255)):o[s]=dt(o[s]);return{data:o,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}]),e}(),mt=0,vt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;y(this,e),this.isSource=!0,Object.defineProperty(this,"id",{value:mt++}),this.uuid=We(),this.data=t,this.version=0}return M(e,[{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{key:"toJSON",value:function(e){var t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];var n={uuid:this.uuid,url:""},i=this.data;if(null!==i){var r;if(Array.isArray(i)){r=[];for(var a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(gt(i[a].image)):r.push(gt(i[a]))}else r=gt(i);n.url=r}return t||(e.images[this.uuid]=n),n}}]),e}();function gt(e){return"undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap?pt.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var _t=0,yt=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.DEFAULT_IMAGE,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.DEFAULT_MAPPING,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:q,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:q,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Q,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:ee,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:le,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:te,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:n.DEFAULT_ANISOTROPY,f=arguments.length>9&&void 0!==arguments[9]?arguments[9]:Te;return y(this,n),(e=t.call(this)).isTexture=!0,Object.defineProperty(d(e),"id",{value:_t++}),e.uuid=We(),e.name="",e.source=new vt(i),e.mipmaps=[],e.mapping=r,e.channel=0,e.wrapS=a,e.wrapT=o,e.magFilter=s,e.minFilter=l,e.anisotropy=h,e.format=u,e.internalFormat=null,e.type=c,e.offset=new $e(0,0),e.repeat=new $e(1,1),e.center=new $e(0,0),e.rotation=0,e.matrixAutoUpdate=!0,e.matrix=new et,e.generateMipmaps=!0,e.premultiplyAlpha=!1,e.flipY=!0,e.unpackAlignment=4,"string"===typeof f?e.colorSpace=f:(at("THREE.Texture: Property .encoding has been replaced by .colorSpace."),e.colorSpace=f===Ee?be:Te),e.userData={},e.version=0,e.onUpdate=null,e.isRenderTargetTexture=!1,e.needsPMREMUpdate=!1,e}return M(n,[{key:"image",get:function(){return this.source.data},set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.source.data=e}},{key:"updateMatrix",value:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}},{key:"toJSON",value:function(e){var t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}},{key:"transformUv",value:function(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case j:e.x=e.x-Math.floor(e.x);break;case q:e.x=e.x<0?0:1;break;case Y:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case j:e.y=e.y-Math.floor(e.y);break;case q:e.y=e.y<0?0:1;break;case Y:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}},{key:"needsUpdate",set:function(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}},{key:"encoding",get:function(){return at("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===be?Ee:3e3},set:function(e){at("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ee?be:Te}}]),n}(Be);yt.DEFAULT_IMAGE=null,yt.DEFAULT_MAPPING=300,yt.DEFAULT_ANISOTROPY=1;var xt=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;y(this,t),t.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}return M(t,[{key:"width",get:function(){return this.z},set:function(e){this.z=e}},{key:"height",get:function(){return this.w},set:function(e){this.w=e}},{key:"set",value:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}},{key:"setScalar",value:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}},{key:"setX",value:function(e){return this.x=e,this}},{key:"setY",value:function(e){return this.y=e,this}},{key:"setZ",value:function(e){return this.z=e,this}},{key:"setW",value:function(e){return this.w=e,this}},{key:"setComponent",value:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function(){return new this.constructor(this.x,this.y,this.z,this.w)}},{key:"copy",value:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}},{key:"add",value:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}},{key:"addScalar",value:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}},{key:"addVectors",value:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}},{key:"addScaledVector",value:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}},{key:"sub",value:function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}},{key:"subScalar",value:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}},{key:"subVectors",value:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}},{key:"multiply",value:function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}},{key:"multiplyScalar",value:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}},{key:"applyMatrix4",value:function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}},{key:"divideScalar",value:function(e){return this.multiplyScalar(1/e)}},{key:"setAxisAngleFromQuaternion",value:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}},{key:"setAxisAngleFromRotationMatrix",value:function(e){var t,n,i,r,a=.01,o=.1,s=e.elements,l=s[0],u=s[4],c=s[8],h=s[1],d=s[5],f=s[9],p=s[2],m=s[6],v=s[10];if(Math.abs(u-h)<a&&Math.abs(c-p)<a&&Math.abs(f-m)<a){if(Math.abs(u+h)<o&&Math.abs(c+p)<o&&Math.abs(f+m)<o&&Math.abs(l+d+v-3)<o)return this.set(1,0,0,0),this;t=Math.PI;var g=(l+1)/2,_=(d+1)/2,y=(v+1)/2,x=(u+h)/4,M=(c+p)/4,S=(f+m)/4;return g>_&&g>y?g<a?(n=0,i=.707106781,r=.707106781):(i=x/(n=Math.sqrt(g)),r=M/n):_>y?_<a?(n=.707106781,i=0,r=.707106781):(n=x/(i=Math.sqrt(_)),r=S/i):y<a?(n=.707106781,i=.707106781,r=0):(n=M/(r=Math.sqrt(y)),i=S/r),this.set(n,i,r,t),this}var E=Math.sqrt((m-f)*(m-f)+(c-p)*(c-p)+(h-u)*(h-u));return Math.abs(E)<.001&&(E=1),this.x=(m-f)/E,this.y=(c-p)/E,this.z=(h-u)/E,this.w=Math.acos((l+d+v-1)/2),this}},{key:"min",value:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}},{key:"max",value:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}},{key:"clamp",value:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}},{key:"clampScalar",value:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}},{key:"ceil",value:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}},{key:"round",value:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}},{key:"roundToZero",value:function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}},{key:"negate",value:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}},{key:"dot",value:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}},{key:"lengthSq",value:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"manhattanLength",value:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}},{key:"normalize",value:function(){return this.divideScalar(this.length()||1)}},{key:"setLength",value:function(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}},{key:"lerpVectors",value:function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}},{key:"equals",value:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}},{key:"fromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}},{key:"fromBufferAttribute",value:function(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}},{key:"random",value:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:return e.next=6,this.z;case 6:return e.next=8,this.w;case 8:case"end":return e.stop()}}),e,this)}))}]),t}(),Mt=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};y(this,n),(e=t.call(this)).isRenderTarget=!0,e.width=i,e.height=r,e.depth=1,e.scissor=new xt(0,0,i,r),e.scissorTest=!1,e.viewport=new xt(0,0,i,r);var o={width:i,height:r,depth:1};return void 0!==a.encoding&&(at("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),a.colorSpace=a.encoding===Ee?be:Te),a=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Q,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},a),e.texture=new yt(o,a.mapping,a.wrapS,a.wrapT,a.magFilter,a.minFilter,a.format,a.type,a.anisotropy,a.colorSpace),e.texture.isRenderTargetTexture=!0,e.texture.flipY=!1,e.texture.generateMipmaps=a.generateMipmaps,e.texture.internalFormat=a.internalFormat,e.depthBuffer=a.depthBuffer,e.stencilBuffer=a.stencilBuffer,e.depthTexture=a.depthTexture,e.samples=a.samples,e}return M(n,[{key:"setSize",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;var t=Object.assign({},e.texture.image);return this.texture.source=new vt(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}}]),n}(Be),St=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return y(this,n),(e=t.call(this,i,r,a)).isWebGLRenderTarget=!0,e}return M(n)}(Mt),Et=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return y(this,n),(e=t.call(this,null)).isDataArrayTexture=!0,e.image={data:i,width:r,height:a,depth:o},e.magFilter=K,e.minFilter=K,e.wrapR=q,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return M(n)}(yt),Tt=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return y(this,n),(e=t.call(this,null)).isData3DTexture=!0,e.image={data:i,width:r,height:a,depth:o},e.magFilter=K,e.minFilter=K,e.wrapR=q,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return M(n)}(yt),bt=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;y(this,t),this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}return M(t,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}},{key:"set",value:function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}},{key:"clone",value:function(){return new this.constructor(this._x,this._y,this._z,this._w)}},{key:"copy",value:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}},{key:"setFromEuler",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,s=Math.sin,l=o(n/2),u=o(i/2),c=o(r/2),h=s(n/2),d=s(i/2),f=s(r/2);switch(a){case"XYZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"YXZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"ZXY":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"ZYX":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"YZX":this._x=h*u*c+l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c-h*d*f;break;case"XZY":this._x=h*u*c-l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c+h*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}},{key:"setFromAxisAngle",value:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}},{key:"setFromRotationMatrix",value:function(e){var t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],s=t[9],l=t[2],u=t[6],c=t[10],h=n+o+c;if(h>0){var d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-s)*d,this._y=(r-l)*d,this._z=(a-i)*d}else if(n>o&&n>c){var f=2*Math.sqrt(1+n-o-c);this._w=(u-s)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>c){var p=2*Math.sqrt(1+o-n-c);this._w=(r-l)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(s+u)/p}else{var m=2*Math.sqrt(1+c-n-o);this._w=(a-i)/m,this._x=(r+l)/m,this._y=(s+u)/m,this._z=.25*m}return this._onChangeCallback(),this}},{key:"setFromUnitVectors",value:function(e,t){var n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}},{key:"angleTo",value:function(e){return 2*Math.acos(Math.abs(Xe(this.dot(e),-1,1)))}},{key:"rotateTowards",value:function(e,t){var n=this.angleTo(e);if(0===n)return this;var i=Math.min(1,t/n);return this.slerp(e,i),this}},{key:"identity",value:function(){return this.set(0,0,0,1)}},{key:"invert",value:function(){return this.conjugate()}},{key:"conjugate",value:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}},{key:"dot",value:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}},{key:"lengthSq",value:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}},{key:"length",value:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}},{key:"normalize",value:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}},{key:"multiply",value:function(e){return this.multiplyQuaternions(this,e)}},{key:"premultiply",value:function(e){return this.multiplyQuaternions(e,this)}},{key:"multiplyQuaternions",value:function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-r*s,this._y=i*u+a*s+r*o-n*l,this._z=r*u+a*l+n*s-i*o,this._w=a*u-n*o-i*s-r*l,this._onChangeCallback(),this}},{key:"slerp",value:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,a=this._w,o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;var s=1-o*o;if(s<=Number.EPSILON){var l=1-t;return this._w=l*a+t*this._w,this._x=l*n+t*this._x,this._y=l*i+t*this._y,this._z=l*r+t*this._z,this.normalize(),this}var u=Math.sqrt(s),c=Math.atan2(u,o),h=Math.sin((1-t)*c)/u,d=Math.sin(t*c)/u;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}},{key:"slerpQuaternions",value:function(e,t,n){return this.copy(e).slerp(t,n)}},{key:"random",value:function(){var e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}},{key:"equals",value:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}},{key:"fromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}},{key:"fromBufferAttribute",value:function(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}},{key:"toJSON",value:function(){return this.toArray()}},{key:"_onChange",value:function(e){return this._onChangeCallback=e,this}},{key:"_onChangeCallback",value:function(){}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._x;case 2:return e.next=4,this._y;case 4:return e.next=6,this._z;case 6:return e.next=8,this._w;case 8:case"end":return e.stop()}}),e,this)}))}],[{key:"slerpFlat",value:function(e,t,n,i,r,a,o){var s=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],h=r[a+0],d=r[a+1],f=r[a+2],p=r[a+3];if(0===o)return e[t+0]=s,e[t+1]=l,e[t+2]=u,void(e[t+3]=c);if(1===o)return e[t+0]=h,e[t+1]=d,e[t+2]=f,void(e[t+3]=p);if(c!==p||s!==h||l!==d||u!==f){var m=1-o,v=s*h+l*d+u*f+c*p,g=v>=0?1:-1,_=1-v*v;if(_>Number.EPSILON){var y=Math.sqrt(_),x=Math.atan2(y,v*g);m=Math.sin(m*x)/y,o=Math.sin(o*x)/y}var M=o*g;if(s=s*m+h*M,l=l*m+d*M,u=u*m+f*M,c=c*m+p*M,m===1-o){var S=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=S,l*=S,u*=S,c*=S}}e[t]=s,e[t+1]=l,e[t+2]=u,e[t+3]=c}},{key:"multiplyQuaternionsFlat",value:function(e,t,n,i,r,a){var o=n[i],s=n[i+1],l=n[i+2],u=n[i+3],c=r[a],h=r[a+1],d=r[a+2],f=r[a+3];return e[t]=o*f+u*c+s*d-l*h,e[t+1]=s*f+u*h+l*c-o*d,e[t+2]=l*f+u*d+o*h-s*c,e[t+3]=u*f-o*c-s*h-l*d,e}}]),t}(),At=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;y(this,t),t.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}return M(t,[{key:"set",value:function(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}},{key:"setScalar",value:function(e){return this.x=e,this.y=e,this.z=e,this}},{key:"setX",value:function(e){return this.x=e,this}},{key:"setY",value:function(e){return this.y=e,this}},{key:"setZ",value:function(e){return this.z=e,this}},{key:"setComponent",value:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function(){return new this.constructor(this.x,this.y,this.z)}},{key:"copy",value:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}},{key:"add",value:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}},{key:"addScalar",value:function(e){return this.x+=e,this.y+=e,this.z+=e,this}},{key:"addVectors",value:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}},{key:"addScaledVector",value:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}},{key:"sub",value:function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}},{key:"subScalar",value:function(e){return this.x-=e,this.y-=e,this.z-=e,this}},{key:"subVectors",value:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}},{key:"multiply",value:function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}},{key:"multiplyScalar",value:function(e){return this.x*=e,this.y*=e,this.z*=e,this}},{key:"multiplyVectors",value:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}},{key:"applyEuler",value:function(e){return this.applyQuaternion(Rt.setFromEuler(e))}},{key:"applyAxisAngle",value:function(e,t){return this.applyQuaternion(Rt.setFromAxisAngle(e,t))}},{key:"applyMatrix3",value:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}},{key:"applyNormalMatrix",value:function(e){return this.applyMatrix3(e).normalize()}},{key:"applyMatrix4",value:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}},{key:"applyQuaternion",value:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,l=2*(a*i-o*n),u=2*(o*t-r*i),c=2*(r*n-a*t);return this.x=t+s*l+a*c-o*u,this.y=n+s*u+o*l-r*c,this.z=i+s*c+r*u-a*l,this}},{key:"project",value:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}},{key:"unproject",value:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}},{key:"transformDirection",value:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}},{key:"divide",value:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}},{key:"divideScalar",value:function(e){return this.multiplyScalar(1/e)}},{key:"min",value:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}},{key:"max",value:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}},{key:"clamp",value:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}},{key:"clampScalar",value:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}},{key:"ceil",value:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}},{key:"round",value:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}},{key:"roundToZero",value:function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}},{key:"negate",value:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}},{key:"dot",value:function(e){return this.x*e.x+this.y*e.y+this.z*e.z}},{key:"lengthSq",value:function(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"manhattanLength",value:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}},{key:"normalize",value:function(){return this.divideScalar(this.length()||1)}},{key:"setLength",value:function(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}},{key:"lerpVectors",value:function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}},{key:"cross",value:function(e){return this.crossVectors(this,e)}},{key:"crossVectors",value:function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}},{key:"projectOnVector",value:function(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}},{key:"projectOnPlane",value:function(e){return wt.copy(this).projectOnVector(e),this.sub(wt)}},{key:"reflect",value:function(e){return this.sub(wt.copy(e).multiplyScalar(2*this.dot(e)))}},{key:"angleTo",value:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Xe(n,-1,1))}},{key:"distanceTo",value:function(e){return Math.sqrt(this.distanceToSquared(e))}},{key:"distanceToSquared",value:function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}},{key:"manhattanDistanceTo",value:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}},{key:"setFromSpherical",value:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}},{key:"setFromSphericalCoords",value:function(e,t,n){var i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}},{key:"setFromCylindrical",value:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}},{key:"setFromCylindricalCoords",value:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}},{key:"setFromMatrixPosition",value:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}},{key:"setFromMatrixScale",value:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}},{key:"setFromMatrixColumn",value:function(e,t){return this.fromArray(e.elements,4*t)}},{key:"setFromMatrix3Column",value:function(e,t){return this.fromArray(e.elements,3*t)}},{key:"setFromEuler",value:function(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}},{key:"setFromColor",value:function(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}},{key:"equals",value:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}},{key:"fromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}},{key:"fromBufferAttribute",value:function(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}},{key:"random",value:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}},{key:"randomDirection",value:function(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-Math.pow(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:return e.next=6,this.z;case 6:case"end":return e.stop()}}),e,this)}))}]),t}(),wt=new At,Rt=new bt,Ct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new At(1/0,1/0,1/0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new At(-1/0,-1/0,-1/0);y(this,e),this.isBox3=!0,this.min=t,this.max=n}return M(e,[{key:"set",value:function(e,t){return this.min.copy(e),this.max.copy(t),this}},{key:"setFromArray",value:function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t+=3)this.expandByPoint(Pt.fromArray(e,t));return this}},{key:"setFromBufferAttribute",value:function(e){this.makeEmpty();for(var t=0,n=e.count;t<n;t++)this.expandByPoint(Pt.fromBufferAttribute(e,t));return this}},{key:"setFromPoints",value:function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}},{key:"setFromCenterAndSize",value:function(e,t){var n=Pt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}},{key:"setFromObject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.makeEmpty(),this.expandByObject(e,t)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){return this.min.copy(e.min),this.max.copy(e.max),this}},{key:"makeEmpty",value:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}},{key:"isEmpty",value:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}},{key:"getCenter",value:function(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}},{key:"getSize",value:function(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}},{key:"expandByPoint",value:function(e){return this.min.min(e),this.max.max(e),this}},{key:"expandByVector",value:function(e){return this.min.sub(e),this.max.add(e),this}},{key:"expandByScalar",value:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this}},{key:"expandByObject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.updateWorldMatrix(!1,!1);var n=e.geometry;if(void 0!==n){var i=n.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(var r=0,a=i.count;r<a;r++)!0===e.isMesh?e.getVertexPosition(r,Pt):Pt.fromBufferAttribute(i,r),Pt.applyMatrix4(e.matrixWorld),this.expandByPoint(Pt);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Ut.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Ut.copy(n.boundingBox)),Ut.applyMatrix4(e.matrixWorld),this.union(Ut)}for(var o=e.children,s=0,l=o.length;s<l;s++)this.expandByObject(o[s],t);return this}},{key:"containsPoint",value:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}},{key:"containsBox",value:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}},{key:"getParameter",value:function(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}},{key:"intersectsBox",value:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}},{key:"intersectsSphere",value:function(e){return this.clampPoint(e.center,Pt),Pt.distanceToSquared(e.center)<=e.radius*e.radius}},{key:"intersectsPlane",value:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}},{key:"intersectsTriangle",value:function(e){if(this.isEmpty())return!1;this.getCenter(Bt),zt.subVectors(this.max,Bt),kt.subVectors(e.a,Bt),It.subVectors(e.b,Bt),Nt.subVectors(e.c,Bt),Dt.subVectors(It,kt),Ot.subVectors(Nt,It),Ft.subVectors(kt,Nt);var t=[0,-Dt.z,Dt.y,0,-Ot.z,Ot.y,0,-Ft.z,Ft.y,Dt.z,0,-Dt.x,Ot.z,0,-Ot.x,Ft.z,0,-Ft.x,-Dt.y,Dt.x,0,-Ot.y,Ot.x,0,-Ft.y,Ft.x,0];return!!Vt(t,kt,It,Nt,zt)&&(!!Vt(t=[1,0,0,0,1,0,0,0,1],kt,It,Nt,zt)&&(Ht.crossVectors(Dt,Ot),Vt(t=[Ht.x,Ht.y,Ht.z],kt,It,Nt,zt)))}},{key:"clampPoint",value:function(e,t){return t.copy(e).clamp(this.min,this.max)}},{key:"distanceToPoint",value:function(e){return this.clampPoint(e,Pt).distanceTo(e)}},{key:"getBoundingSphere",value:function(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Pt).length()),e}},{key:"intersect",value:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}},{key:"union",value:function(e){return this.min.min(e.min),this.max.max(e.max),this}},{key:"applyMatrix4",value:function(e){return this.isEmpty()||(Lt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lt)),this}},{key:"translate",value:function(e){return this.min.add(e),this.max.add(e),this}},{key:"equals",value:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}]),e}(),Lt=[new At,new At,new At,new At,new At,new At,new At,new At],Pt=new At,Ut=new Ct,kt=new At,It=new At,Nt=new At,Dt=new At,Ot=new At,Ft=new At,Bt=new At,zt=new At,Ht=new At,Gt=new At;function Vt(e,t,n,i,r){for(var a=0,o=e.length-3;a<=o;a+=3){Gt.fromArray(e,a);var s=r.x*Math.abs(Gt.x)+r.y*Math.abs(Gt.y)+r.z*Math.abs(Gt.z),l=t.dot(Gt),u=n.dot(Gt),c=i.dot(Gt);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>s)return!1}return!0}var Wt=new Ct,Xt=new At,jt=new At,qt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new At,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;y(this,e),this.isSphere=!0,this.center=t,this.radius=n}return M(e,[{key:"set",value:function(e,t){return this.center.copy(e),this.radius=t,this}},{key:"setFromPoints",value:function(e,t){var n=this.center;void 0!==t?n.copy(t):Wt.setFromPoints(e).getCenter(n);for(var i=0,r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}},{key:"copy",value:function(e){return this.center.copy(e.center),this.radius=e.radius,this}},{key:"isEmpty",value:function(){return this.radius<0}},{key:"makeEmpty",value:function(){return this.center.set(0,0,0),this.radius=-1,this}},{key:"containsPoint",value:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}},{key:"distanceToPoint",value:function(e){return e.distanceTo(this.center)-this.radius}},{key:"intersectsSphere",value:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}},{key:"intersectsBox",value:function(e){return e.intersectsSphere(this)}},{key:"intersectsPlane",value:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}},{key:"clampPoint",value:function(e,t){var n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}},{key:"getBoundingBox",value:function(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}},{key:"applyMatrix4",value:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}},{key:"translate",value:function(e){return this.center.add(e),this}},{key:"expandByPoint",value:function(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Xt.subVectors(e,this.center);var t=Xt.lengthSq();if(t>this.radius*this.radius){var n=Math.sqrt(t),i=.5*(n-this.radius);this.center.addScaledVector(Xt,i/n),this.radius+=i}return this}},{key:"union",value:function(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(jt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xt.copy(e.center).add(jt)),this.expandByPoint(Xt.copy(e.center).sub(jt))),this)}},{key:"equals",value:function(e){return e.center.equals(this.center)&&e.radius===this.radius}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),e}(),Yt=new At,Kt=new At,Zt=new At,Jt=new At,Qt=new At,$t=new At,en=new At,tn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new At,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new At(0,0,-1);y(this,e),this.origin=t,this.direction=n}return M(e,[{key:"set",value:function(e,t){return this.origin.copy(e),this.direction.copy(t),this}},{key:"copy",value:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}},{key:"at",value:function(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}},{key:"lookAt",value:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this}},{key:"recast",value:function(e){return this.origin.copy(this.at(e,Yt)),this}},{key:"closestPointToPoint",value:function(e,t){t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}},{key:"distanceToPoint",value:function(e){return Math.sqrt(this.distanceSqToPoint(e))}},{key:"distanceSqToPoint",value:function(e){var t=Yt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yt.copy(this.origin).addScaledVector(this.direction,t),Yt.distanceToSquared(e))}},{key:"distanceSqToSegment",value:function(e,t,n,i){Kt.copy(e).add(t).multiplyScalar(.5),Zt.copy(t).sub(e).normalize(),Jt.copy(this.origin).sub(Kt);var r,a,o,s,l=.5*e.distanceTo(t),u=-this.direction.dot(Zt),c=Jt.dot(this.direction),h=-Jt.dot(Zt),d=Jt.lengthSq(),f=Math.abs(1-u*u);if(f>0)if(a=u*c-h,s=l*f,(r=u*h-c)>=0)if(a>=-s)if(a<=s){var p=1/f;o=(r*=p)*(r+u*(a*=p)+2*c)+a*(u*r+a+2*h)+d}else a=l,o=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;else a=-l,o=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;else a<=-s?o=-(r=Math.max(0,-(-u*l+c)))*r+(a=r>0?-l:Math.min(Math.max(-l,-h),l))*(a+2*h)+d:a<=s?(r=0,o=(a=Math.min(Math.max(-l,-h),l))*(a+2*h)+d):o=-(r=Math.max(0,-(u*l+c)))*r+(a=r>0?l:Math.min(Math.max(-l,-h),l))*(a+2*h)+d;else a=u>0?-l:l,o=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(Kt).addScaledVector(Zt,a),o}},{key:"intersectSphere",value:function(e,t){Yt.subVectors(e.center,this.origin);var n=Yt.dot(this.direction),i=Yt.dot(Yt)-n*n,r=e.radius*e.radius;if(i>r)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}},{key:"intersectsSphere",value:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}},{key:"distanceToPlane",value:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}},{key:"intersectPlane",value:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}},{key:"intersectsPlane",value:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}},{key:"intersectBox",value:function(e,t){var n,i,r,a,o,s,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),c>=0?(o=(e.min.z-h.z)*c,s=(e.max.z-h.z)*c):(o=(e.max.z-h.z)*c,s=(e.min.z-h.z)*c),n>s||o>i?null:((o>n||n!==n)&&(n=o),(s<i||i!==i)&&(i=s),i<0?null:this.at(n>=0?n:i,t)))}},{key:"intersectsBox",value:function(e){return null!==this.intersectBox(e,Yt)}},{key:"intersectTriangle",value:function(e,t,n,i,r){Qt.subVectors(t,e),$t.subVectors(n,e),en.crossVectors(Qt,$t);var a,o=this.direction.dot(en);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Jt.subVectors(this.origin,e);var s=a*this.direction.dot($t.crossVectors(Jt,$t));if(s<0)return null;var l=a*this.direction.dot(Qt.cross(Jt));if(l<0)return null;if(s+l>o)return null;var u=-a*Jt.dot(en);return u<0?null:this.at(u/o,r)}},{key:"applyMatrix4",value:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}},{key:"equals",value:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),e}(),nn=function(){function e(t,n,i,r,a,o,s,l,u,c,h,d,f,p,m,v){y(this,e),e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,n,i,r,a,o,s,l,u,c,h,d,f,p,m,v)}return M(e,[{key:"set",value:function(e,t,n,i,r,a,o,s,l,u,c,h,d,f,p,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=r,v[5]=a,v[9]=o,v[13]=s,v[2]=l,v[6]=u,v[10]=c,v[14]=h,v[3]=d,v[7]=f,v[11]=p,v[15]=m,this}},{key:"identity",value:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}},{key:"clone",value:function(){return(new e).fromArray(this.elements)}},{key:"copy",value:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}},{key:"copyPosition",value:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}},{key:"setFromMatrix3",value:function(e){var t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}},{key:"extractBasis",value:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}},{key:"makeBasis",value:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}},{key:"extractRotation",value:function(e){var t=this.elements,n=e.elements,i=1/rn.setFromMatrixColumn(e,0).length(),r=1/rn.setFromMatrixColumn(e,1).length(),a=1/rn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}},{key:"makeRotationFromEuler",value:function(e){var t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){var h=a*u,d=a*c,f=o*u,p=o*c;t[0]=s*u,t[4]=-s*c,t[8]=l,t[1]=d+f*l,t[5]=h-p*l,t[9]=-o*s,t[2]=p-h*l,t[6]=f+d*l,t[10]=a*s}else if("YXZ"===e.order){var m=s*u,v=s*c,g=l*u,_=l*c;t[0]=m+_*o,t[4]=g*o-v,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-o,t[2]=v*o-g,t[6]=_+m*o,t[10]=a*s}else if("ZXY"===e.order){var y=s*u,x=s*c,M=l*u,S=l*c;t[0]=y-S*o,t[4]=-a*c,t[8]=M+x*o,t[1]=x+M*o,t[5]=a*u,t[9]=S-y*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var E=a*u,T=a*c,b=o*u,A=o*c;t[0]=s*u,t[4]=b*l-T,t[8]=E*l+A,t[1]=s*c,t[5]=A*l+E,t[9]=T*l-b,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var w=a*s,R=a*l,C=o*s,L=o*l;t[0]=s*u,t[4]=L-w*c,t[8]=C*c+R,t[1]=c,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=R*c+C,t[10]=w-L*c}else if("XZY"===e.order){var P=a*s,U=a*l,k=o*s,I=o*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=P*c+I,t[5]=a*u,t[9]=U*c-k,t[2]=k*c-U,t[6]=o*u,t[10]=I*c+P}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}},{key:"makeRotationFromQuaternion",value:function(e){return this.compose(on,e,sn)}},{key:"lookAt",value:function(e,t,n){var i=this.elements;return cn.subVectors(e,t),0===cn.lengthSq()&&(cn.z=1),cn.normalize(),ln.crossVectors(n,cn),0===ln.lengthSq()&&(1===Math.abs(n.z)?cn.x+=1e-4:cn.z+=1e-4,cn.normalize(),ln.crossVectors(n,cn)),ln.normalize(),un.crossVectors(cn,ln),i[0]=ln.x,i[4]=un.x,i[8]=cn.x,i[1]=ln.y,i[5]=un.y,i[9]=cn.y,i[2]=ln.z,i[6]=un.z,i[10]=cn.z,this}},{key:"multiply",value:function(e){return this.multiplyMatrices(this,e)}},{key:"premultiply",value:function(e){return this.multiplyMatrices(e,this)}},{key:"multiplyMatrices",value:function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],f=n[2],p=n[6],m=n[10],v=n[14],g=n[3],_=n[7],y=n[11],x=n[15],M=i[0],S=i[4],E=i[8],T=i[12],b=i[1],A=i[5],w=i[9],R=i[13],C=i[2],L=i[6],P=i[10],U=i[14],k=i[3],I=i[7],N=i[11],D=i[15];return r[0]=a*M+o*b+s*C+l*k,r[4]=a*S+o*A+s*L+l*I,r[8]=a*E+o*w+s*P+l*N,r[12]=a*T+o*R+s*U+l*D,r[1]=u*M+c*b+h*C+d*k,r[5]=u*S+c*A+h*L+d*I,r[9]=u*E+c*w+h*P+d*N,r[13]=u*T+c*R+h*U+d*D,r[2]=f*M+p*b+m*C+v*k,r[6]=f*S+p*A+m*L+v*I,r[10]=f*E+p*w+m*P+v*N,r[14]=f*T+p*R+m*U+v*D,r[3]=g*M+_*b+y*C+x*k,r[7]=g*S+_*A+y*L+x*I,r[11]=g*E+_*w+y*P+x*N,r[15]=g*T+_*R+y*U+x*D,this}},{key:"multiplyScalar",value:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}},{key:"determinant",value:function(){var e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],l=e[13],u=e[2],c=e[6],h=e[10],d=e[14];return e[3]*(+r*s*c-i*l*c-r*o*h+n*l*h+i*o*d-n*s*d)+e[7]*(+t*s*d-t*l*h+r*a*h-i*a*d+i*l*u-r*s*u)+e[11]*(+t*l*c-t*o*d-r*a*c+n*a*d+r*o*u-n*l*u)+e[15]*(-i*o*u-t*s*c+t*o*h+i*a*c-n*a*h+n*s*u)}},{key:"transpose",value:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}},{key:"setPosition",value:function(e,t,n){var i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}},{key:"invert",value:function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],v=e[15],g=c*m*l-p*h*l+p*s*d-o*m*d-c*s*v+o*h*v,_=f*h*l-u*m*l-f*s*d+a*m*d+u*s*v-a*h*v,y=u*p*l-f*c*l+f*o*d-a*p*d-u*o*v+a*c*v,x=f*c*s-u*p*s-f*o*h+a*p*h+u*o*m-a*c*m,M=t*g+n*_+i*y+r*x;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var S=1/M;return e[0]=g*S,e[1]=(p*h*r-c*m*r-p*i*d+n*m*d+c*i*v-n*h*v)*S,e[2]=(o*m*r-p*s*r+p*i*l-n*m*l-o*i*v+n*s*v)*S,e[3]=(c*s*r-o*h*r-c*i*l+n*h*l+o*i*d-n*s*d)*S,e[4]=_*S,e[5]=(u*m*r-f*h*r+f*i*d-t*m*d-u*i*v+t*h*v)*S,e[6]=(f*s*r-a*m*r-f*i*l+t*m*l+a*i*v-t*s*v)*S,e[7]=(a*h*r-u*s*r+u*i*l-t*h*l-a*i*d+t*s*d)*S,e[8]=y*S,e[9]=(f*c*r-u*p*r-f*n*d+t*p*d+u*n*v-t*c*v)*S,e[10]=(a*p*r-f*o*r+f*n*l-t*p*l-a*n*v+t*o*v)*S,e[11]=(u*o*r-a*c*r-u*n*l+t*c*l+a*n*d-t*o*d)*S,e[12]=x*S,e[13]=(u*p*i-f*c*i+f*n*h-t*p*h-u*n*m+t*c*m)*S,e[14]=(f*o*i-a*p*i-f*n*s+t*p*s+a*n*m-t*o*m)*S,e[15]=(a*c*i-u*o*i+u*n*s-t*c*s-a*n*h+t*o*h)*S,this}},{key:"scale",value:function(e){var t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}},{key:"getMaxScaleOnAxis",value:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}},{key:"makeTranslation",value:function(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}},{key:"makeRotationX",value:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}},{key:"makeRotationY",value:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}},{key:"makeRotationZ",value:function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}},{key:"makeRotationAxis",value:function(e,t){var n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,s=e.z,l=r*a,u=r*o;return this.set(l*a+n,l*o-i*s,l*s+i*o,0,l*o+i*s,u*o+n,u*s-i*a,0,l*s-i*o,u*s+i*a,r*s*s+n,0,0,0,0,1),this}},{key:"makeScale",value:function(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}},{key:"makeShear",value:function(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}},{key:"compose",value:function(e,t,n){var i=this.elements,r=t._x,a=t._y,o=t._z,s=t._w,l=r+r,u=a+a,c=o+o,h=r*l,d=r*u,f=r*c,p=a*u,m=a*c,v=o*c,g=s*l,_=s*u,y=s*c,x=n.x,M=n.y,S=n.z;return i[0]=(1-(p+v))*x,i[1]=(d+y)*x,i[2]=(f-_)*x,i[3]=0,i[4]=(d-y)*M,i[5]=(1-(h+v))*M,i[6]=(m+g)*M,i[7]=0,i[8]=(f+_)*S,i[9]=(m-g)*S,i[10]=(1-(h+p))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}},{key:"decompose",value:function(e,t,n){var i=this.elements,r=rn.set(i[0],i[1],i[2]).length(),a=rn.set(i[4],i[5],i[6]).length(),o=rn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],an.copy(this);var s=1/r,l=1/a,u=1/o;return an.elements[0]*=s,an.elements[1]*=s,an.elements[2]*=s,an.elements[4]*=l,an.elements[5]*=l,an.elements[6]*=l,an.elements[8]*=u,an.elements[9]*=u,an.elements[10]*=u,t.setFromRotationMatrix(an),n.x=r,n.y=a,n.z=o,this}},{key:"makePerspective",value:function(e,t,n,i,r,a){var o,s,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Oe,u=this.elements,c=2*r/(t-e),h=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i);if(l===Oe)o=-(a+r)/(a-r),s=-2*a*r/(a-r);else{if(l!==Fe)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);o=-a/(a-r),s=-a*r/(a-r)}return u[0]=c,u[4]=0,u[8]=d,u[12]=0,u[1]=0,u[5]=h,u[9]=f,u[13]=0,u[2]=0,u[6]=0,u[10]=o,u[14]=s,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}},{key:"makeOrthographic",value:function(e,t,n,i,r,a){var o,s,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Oe,u=this.elements,c=1/(t-e),h=1/(n-i),d=1/(a-r),f=(t+e)*c,p=(n+i)*h;if(l===Oe)o=(a+r)*d,s=-2*d;else{if(l!==Fe)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);o=r*d,s=-1*d}return u[0]=2*c,u[4]=0,u[8]=0,u[12]=-f,u[1]=0,u[5]=2*h,u[9]=0,u[13]=-p,u[2]=0,u[6]=0,u[10]=s,u[14]=-o,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}},{key:"equals",value:function(e){for(var t=this.elements,n=e.elements,i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<16;n++)this.elements[n]=e[n+t];return this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}]),e}(),rn=new At,an=new nn,on=new At(0,0,0),sn=new At(1,1,1),ln=new At,un=new At,cn=new At,hn=new nn,dn=new bt,fn=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.DEFAULT_ORDER;y(this,t),this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}return M(t,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},{key:"order",get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}},{key:"set",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this._order;return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}},{key:"clone",value:function(){return new this.constructor(this._x,this._y,this._z,this._order)}},{key:"copy",value:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}},{key:"setFromRotationMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=e.elements,r=i[0],a=i[4],o=i[8],s=i[1],l=i[5],u=i[9],c=i[2],h=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(s,r));break;case"ZYX":this._y=Math.asin(-Xe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Xe(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}},{key:"setFromQuaternion",value:function(e,t,n){return hn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hn,t,n)}},{key:"setFromVector3",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order;return this.set(e.x,e.y,e.z,t)}},{key:"reorder",value:function(e){return dn.setFromEuler(this),this.setFromQuaternion(dn,e)}},{key:"equals",value:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}},{key:"fromArray",value:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}},{key:"_onChange",value:function(e){return this._onChangeCallback=e,this}},{key:"_onChangeCallback",value:function(){}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._x;case 2:return e.next=4,this._y;case 4:return e.next=6,this._z;case 6:return e.next=8,this._order;case 8:case"end":return e.stop()}}),e,this)}))}]),t}();fn.DEFAULT_ORDER="XYZ";var pn=function(){function e(){y(this,e),this.mask=1}return M(e,[{key:"set",value:function(e){this.mask=(1<<e|0)>>>0}},{key:"enable",value:function(e){this.mask|=1<<e|0}},{key:"enableAll",value:function(){this.mask=-1}},{key:"toggle",value:function(e){this.mask^=1<<e|0}},{key:"disable",value:function(e){this.mask&=~(1<<e|0)}},{key:"disableAll",value:function(){this.mask=0}},{key:"test",value:function(e){return 0!==(this.mask&e.mask)}},{key:"isEnabled",value:function(e){return 0!==(this.mask&(1<<e|0))}}]),e}(),mn=0,vn=new At,gn=new bt,_n=new nn,yn=new At,xn=new At,Mn=new At,Sn=new bt,En=new At(1,0,0),Tn=new At(0,1,0),bn=new At(0,0,1),An={type:"added"},wn={type:"removed"},Rn=function(e){f(n,e);var t=m(n);function n(){var e;y(this,n),(e=t.call(this)).isObject3D=!0,Object.defineProperty(d(e),"id",{value:mn++}),e.uuid=We(),e.name="",e.type="Object3D",e.parent=null,e.children=[],e.up=n.DEFAULT_UP.clone();var i=new At,r=new fn,a=new bt,o=new At(1,1,1);return r._onChange((function(){a.setFromEuler(r,!1)})),a._onChange((function(){r.setFromQuaternion(a,void 0,!1)})),Object.defineProperties(d(e),{position:{configurable:!0,enumerable:!0,value:i},rotation:{configurable:!0,enumerable:!0,value:r},quaternion:{configurable:!0,enumerable:!0,value:a},scale:{configurable:!0,enumerable:!0,value:o},modelViewMatrix:{value:new nn},normalMatrix:{value:new et}}),e.matrix=new nn,e.matrixWorld=new nn,e.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,e.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,e.matrixWorldNeedsUpdate=!1,e.layers=new pn,e.visible=!0,e.castShadow=!1,e.receiveShadow=!1,e.frustumCulled=!0,e.renderOrder=0,e.animations=[],e.userData={},e}return M(n,[{key:"onBeforeShadow",value:function(){}},{key:"onAfterShadow",value:function(){}},{key:"onBeforeRender",value:function(){}},{key:"onAfterRender",value:function(){}},{key:"applyMatrix4",value:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}},{key:"applyQuaternion",value:function(e){return this.quaternion.premultiply(e),this}},{key:"setRotationFromAxisAngle",value:function(e,t){this.quaternion.setFromAxisAngle(e,t)}},{key:"setRotationFromEuler",value:function(e){this.quaternion.setFromEuler(e,!0)}},{key:"setRotationFromMatrix",value:function(e){this.quaternion.setFromRotationMatrix(e)}},{key:"setRotationFromQuaternion",value:function(e){this.quaternion.copy(e)}},{key:"rotateOnAxis",value:function(e,t){return gn.setFromAxisAngle(e,t),this.quaternion.multiply(gn),this}},{key:"rotateOnWorldAxis",value:function(e,t){return gn.setFromAxisAngle(e,t),this.quaternion.premultiply(gn),this}},{key:"rotateX",value:function(e){return this.rotateOnAxis(En,e)}},{key:"rotateY",value:function(e){return this.rotateOnAxis(Tn,e)}},{key:"rotateZ",value:function(e){return this.rotateOnAxis(bn,e)}},{key:"translateOnAxis",value:function(e,t){return vn.copy(e).applyQuaternion(this.quaternion),this.position.add(vn.multiplyScalar(t)),this}},{key:"translateX",value:function(e){return this.translateOnAxis(En,e)}},{key:"translateY",value:function(e){return this.translateOnAxis(Tn,e)}},{key:"translateZ",value:function(e){return this.translateOnAxis(bn,e)}},{key:"localToWorld",value:function(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}},{key:"worldToLocal",value:function(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_n.copy(this.matrixWorld).invert())}},{key:"lookAt",value:function(e,t,n){e.isVector3?yn.copy(e):yn.set(e,t,n);var i=this.parent;this.updateWorldMatrix(!0,!1),xn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_n.lookAt(xn,yn,this.up):_n.lookAt(yn,xn,this.up),this.quaternion.setFromRotationMatrix(_n),i&&(_n.extractRotation(i.matrixWorld),gn.setFromRotationMatrix(_n),this.quaternion.premultiply(gn.invert()))}},{key:"add",value:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(An)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}},{key:"remove",value:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}var n=this.children.indexOf(e);return-1!==n&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(wn)),this}},{key:"removeFromParent",value:function(){var e=this.parent;return null!==e&&e.remove(this),this}},{key:"clear",value:function(){return this.remove.apply(this,h(this.children))}},{key:"attach",value:function(e){return this.updateWorldMatrix(!0,!1),_n.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),_n.multiply(e.parent.matrixWorld)),e.applyMatrix4(_n),this.add(e),e.updateWorldMatrix(!1,!0),this}},{key:"getObjectById",value:function(e){return this.getObjectByProperty("id",e)}},{key:"getObjectByName",value:function(e){return this.getObjectByProperty("name",e)}},{key:"getObjectByProperty",value:function(e,t){if(this[e]===t)return this;for(var n=0,i=this.children.length;n<i;n++){var r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}},{key:"getObjectsByProperty",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];this[e]===t&&n.push(this);for(var i=this.children,r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}},{key:"getWorldPosition",value:function(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}},{key:"getWorldQuaternion",value:function(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xn,e,Mn),e}},{key:"getWorldScale",value:function(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xn,Sn,e),e}},{key:"getWorldDirection",value:function(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}},{key:"raycast",value:function(){}},{key:"traverse",value:function(e){e(this);for(var t=this.children,n=0,i=t.length;n<i;n++)t[n].traverse(e)}},{key:"traverseVisible",value:function(e){if(!1!==this.visible){e(this);for(var t=this.children,n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}}},{key:"traverseAncestors",value:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}},{key:"updateMatrix",value:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}},{key:"updateMatrixWorld",value:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=this.children,n=0,i=t.length;n<i;n++){var r=t[n];!0!==r.matrixWorldAutoUpdate&&!0!==e||r.updateMatrixWorld(e)}}},{key:"updateWorldMatrix",value:function(e,t){var n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t)for(var i=this.children,r=0,a=i.length;r<a;r++){var o=i[r];!0===o.matrixWorldAutoUpdate&&o.updateWorldMatrix(!1,!0)}}},{key:"toJSON",value:function(e){var t=void 0===e||"string"===typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});var i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((function(e){return{boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);var a=this.geometry.parameters;if(void 0!==a&&void 0!==a.shapes){var o=a.shapes;if(Array.isArray(o))for(var s=0,l=o.length;s<l;s++){var u=o[s];r(e.shapes,u)}else r(e.shapes,o)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){for(var c=[],h=0,d=this.material.length;h<d;h++)c.push(r(e.materials,this.material[h]));i.material=c}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(var f=0;f<this.children.length;f++)i.children.push(this.children[f].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(var p=0;p<this.animations.length;p++){var m=this.animations[p];i.animations.push(r(e.animations,m))}}if(t){var v=T(e.geometries),g=T(e.materials),_=T(e.textures),y=T(e.images),x=T(e.shapes),M=T(e.skeletons),S=T(e.animations),E=T(e.nodes);v.length>0&&(n.geometries=v),g.length>0&&(n.materials=g),_.length>0&&(n.textures=_),y.length>0&&(n.images=y),x.length>0&&(n.shapes=x),M.length>0&&(n.skeletons=M),S.length>0&&(n.animations=S),E.length>0&&(n.nodes=E)}return n.object=i,n;function T(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}}},{key:"clone",value:function(e){return(new this.constructor).copy(this,e)}},{key:"copy",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n<e.children.length;n++){var i=e.children[n];this.add(i.clone())}return this}}]),n}(Be);Rn.DEFAULT_UP=new At(0,1,0),Rn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Rn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Cn=new At,Ln=new At,Pn=new At,Un=new At,kn=new At,In=new At,Nn=new At,Dn=new At,On=new At,Fn=new At,Bn=!1,zn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new At,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new At,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new At;y(this,e),this.a=t,this.b=n,this.c=i}return M(e,[{key:"set",value:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}},{key:"setFromPointsAndIndices",value:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}},{key:"setFromAttributeAndIndices",value:function(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}},{key:"getArea",value:function(){return Cn.subVectors(this.c,this.b),Ln.subVectors(this.a,this.b),.5*Cn.cross(Ln).length()}},{key:"getMidpoint",value:function(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}},{key:"getNormal",value:function(t){return e.getNormal(this.a,this.b,this.c,t)}},{key:"getPlane",value:function(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}},{key:"getBarycoord",value:function(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}},{key:"getUV",value:function(t,n,i,r,a){return!1===Bn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Bn=!0),e.getInterpolation(t,this.a,this.b,this.c,n,i,r,a)}},{key:"getInterpolation",value:function(t,n,i,r,a){return e.getInterpolation(t,this.a,this.b,this.c,n,i,r,a)}},{key:"containsPoint",value:function(t){return e.containsPoint(t,this.a,this.b,this.c)}},{key:"isFrontFacing",value:function(t){return e.isFrontFacing(this.a,this.b,this.c,t)}},{key:"intersectsBox",value:function(e){return e.intersectsTriangle(this)}},{key:"closestPointToPoint",value:function(e,t){var n,i,r=this.a,a=this.b,o=this.c;kn.subVectors(a,r),In.subVectors(o,r),Dn.subVectors(e,r);var s=kn.dot(Dn),l=In.dot(Dn);if(s<=0&&l<=0)return t.copy(r);On.subVectors(e,a);var u=kn.dot(On),c=In.dot(On);if(u>=0&&c<=u)return t.copy(a);var h=s*c-u*l;if(h<=0&&s>=0&&u<=0)return n=s/(s-u),t.copy(r).addScaledVector(kn,n);Fn.subVectors(e,o);var d=kn.dot(Fn),f=In.dot(Fn);if(f>=0&&d<=f)return t.copy(o);var p=d*l-s*f;if(p<=0&&l>=0&&f<=0)return i=l/(l-f),t.copy(r).addScaledVector(In,i);var m=u*f-d*c;if(m<=0&&c-u>=0&&d-f>=0)return Nn.subVectors(o,a),i=(c-u)/(c-u+(d-f)),t.copy(a).addScaledVector(Nn,i);var v=1/(m+p+h);return n=p*v,i=h*v,t.copy(r).addScaledVector(kn,n).addScaledVector(In,i)}},{key:"equals",value:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}],[{key:"getNormal",value:function(e,t,n,i){i.subVectors(n,t),Cn.subVectors(e,t),i.cross(Cn);var r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}},{key:"getBarycoord",value:function(e,t,n,i,r){Cn.subVectors(i,t),Ln.subVectors(n,t),Pn.subVectors(e,t);var a=Cn.dot(Cn),o=Cn.dot(Ln),s=Cn.dot(Pn),l=Ln.dot(Ln),u=Ln.dot(Pn),c=a*l-o*o;if(0===c)return r.set(0,0,0),null;var h=1/c,d=(l*s-o*u)*h,f=(a*u-o*s)*h;return r.set(1-d-f,f,d)}},{key:"containsPoint",value:function(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,Un)&&(Un.x>=0&&Un.y>=0&&Un.x+Un.y<=1)}},{key:"getUV",value:function(e,t,n,i,r,a,o,s){return!1===Bn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Bn=!0),this.getInterpolation(e,t,n,i,r,a,o,s)}},{key:"getInterpolation",value:function(e,t,n,i,r,a,o,s){return null===this.getBarycoord(e,t,n,i,Un)?(s.x=0,s.y=0,"z"in s&&(s.z=0),"w"in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(r,Un.x),s.addScaledVector(a,Un.y),s.addScaledVector(o,Un.z),s)}},{key:"isFrontFacing",value:function(e,t,n,i){return Cn.subVectors(n,t),Ln.subVectors(e,t),Cn.cross(Ln).dot(i)<0}}]),e}(),Hn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Gn={h:0,s:0,l:0},Vn={h:0,s:0,l:0};function Wn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}var Xn=function(e){function t(e,n,i){return y(this,t),this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}return M(t,[{key:"set",value:function(e,t,n){if(void 0===t&&void 0===n){var i=e;i&&i.isColor?this.copy(i):"number"===typeof i?this.setHex(i):"string"===typeof i&&this.setStyle(i)}else this.setRGB(e,t,n);return this}},{key:"setScalar",value:function(e){return this.r=e,this.g=e,this.b=e,this}},{key:"setHex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be;return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ht.toWorkingColorSpace(this,t),this}},{key:"setRGB",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ht.workingColorSpace;return this.r=e,this.g=t,this.b=n,ht.toWorkingColorSpace(this,i),this}},{key:"setHSL",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ht.workingColorSpace;if(e=je(e,1),t=Xe(t,0,1),n=Xe(n,0,1),0===t)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=Wn(a,r,e+1/3),this.g=Wn(a,r,e),this.b=Wn(a,r,e-1/3)}return ht.toWorkingColorSpace(this,i),this}},{key:"setStyle",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be;function i(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(t=/^(\w+)\(([^\)]*)\)/.exec(e)){var r,a=t[1],o=t[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,n);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,n);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^\#([A-Fa-f\d]+)$/.exec(e)){var s=t[1],l=s.length;if(3===l)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(6===l)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}},{key:"setColorName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be,n=Hn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}},{key:"clone",value:function(){return new this.constructor(this.r,this.g,this.b)}},{key:"copy",value:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}},{key:"copySRGBToLinear",value:function(e){return this.r=dt(e.r),this.g=dt(e.g),this.b=dt(e.b),this}},{key:"copyLinearToSRGB",value:function(e){return this.r=ft(e.r),this.g=ft(e.g),this.b=ft(e.b),this}},{key:"convertSRGBToLinear",value:function(){return this.copySRGBToLinear(this),this}},{key:"convertLinearToSRGB",value:function(){return this.copyLinearToSRGB(this),this}},{key:"getHex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:be;return ht.fromWorkingColorSpace(jn.copy(this),e),65536*Math.round(Xe(255*jn.r,0,255))+256*Math.round(Xe(255*jn.g,0,255))+Math.round(Xe(255*jn.b,0,255))}},{key:"getHexString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:be;return("000000"+this.getHex(e).toString(16)).slice(-6)}},{key:"getHSL",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht.workingColorSpace;ht.fromWorkingColorSpace(jn.copy(this),t);var n,i,r=jn.r,a=jn.g,o=jn.b,s=Math.max(r,a,o),l=Math.min(r,a,o),u=(l+s)/2;if(l===s)n=0,i=0;else{var c=s-l;switch(i=u<=.5?c/(s+l):c/(2-s-l),s){case r:n=(a-o)/c+(a<o?6:0);break;case a:n=(o-r)/c+2;break;case o:n=(r-a)/c+4}n/=6}return e.h=n,e.s=i,e.l=u,e}},{key:"getRGB",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht.workingColorSpace;return ht.fromWorkingColorSpace(jn.copy(this),t),e.r=jn.r,e.g=jn.g,e.b=jn.b,e}},{key:"getStyle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:be;ht.fromWorkingColorSpace(jn.copy(this),e);var t=jn.r,n=jn.g,i=jn.b;return e!==be?"color(".concat(e," ").concat(t.toFixed(3)," ").concat(n.toFixed(3)," ").concat(i.toFixed(3),")"):"rgb(".concat(Math.round(255*t),",").concat(Math.round(255*n),",").concat(Math.round(255*i),")")}},{key:"offsetHSL",value:function(e,t,n){return this.getHSL(Gn),this.setHSL(Gn.h+e,Gn.s+t,Gn.l+n)}},{key:"add",value:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}},{key:"addColors",value:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}},{key:"addScalar",value:function(e){return this.r+=e,this.g+=e,this.b+=e,this}},{key:"sub",value:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}},{key:"multiply",value:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}},{key:"multiplyScalar",value:function(e){return this.r*=e,this.g*=e,this.b*=e,this}},{key:"lerp",value:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}},{key:"lerpColors",value:function(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}},{key:"lerpHSL",value:function(e,t){this.getHSL(Gn),e.getHSL(Vn);var n=qe(Gn.h,Vn.h,t),i=qe(Gn.s,Vn.s,t),r=qe(Gn.l,Vn.l,t);return this.setHSL(n,i,r),this}},{key:"setFromVector3",value:function(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}},{key:"applyMatrix3",value:function(e){var t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}},{key:"equals",value:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}},{key:"fromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}},{key:"toArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}},{key:"fromBufferAttribute",value:function(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}},{key:"toJSON",value:function(){return this.getHex()}},{key:Symbol.iterator,value:_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.r;case 2:return e.next=4,this.g;case 4:return e.next=6,this.b;case 6:case"end":return e.stop()}}),e,this)}))}]),t}(),jn=new Xn;Xn.NAMES=Hn;var qn=0,Yn=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this)).isMaterial=!0,Object.defineProperty(d(e),"id",{value:qn++}),e.uuid=We(),e.name="",e.type="Material",e.blending=1,e.side=w,e.vertexColors=!1,e.opacity=1,e.transparent=!1,e.alphaHash=!1,e.blendSrc=204,e.blendDst=205,e.blendEquation=C,e.blendSrcAlpha=null,e.blendDstAlpha=null,e.blendEquationAlpha=null,e.blendColor=new Xn(0,0,0),e.blendAlpha=0,e.depthFunc=3,e.depthTest=!0,e.depthWrite=!0,e.stencilWriteMask=255,e.stencilFunc=519,e.stencilRef=0,e.stencilFuncMask=255,e.stencilFail=ke,e.stencilZFail=ke,e.stencilZPass=ke,e.stencilWrite=!1,e.clippingPlanes=null,e.clipIntersection=!1,e.clipShadows=!1,e.shadowSide=null,e.colorWrite=!0,e.precision=null,e.polygonOffset=!1,e.polygonOffsetFactor=0,e.polygonOffsetUnits=0,e.dithering=!1,e.alphaToCoverage=!1,e.premultipliedAlpha=!1,e.forceSinglePass=!1,e.visible=!0,e.toneMapped=!0,e.userData={},e.version=0,e._alphaTest=0,e}return M(n,[{key:"alphaTest",get:function(){return this._alphaTest},set:function(e){this._alphaTest>0!==e>0&&this.version++,this._alphaTest=e}},{key:"onBuild",value:function(){}},{key:"onBeforeRender",value:function(){}},{key:"onBeforeCompile",value:function(){}},{key:"customProgramCacheKey",value:function(){return this.onBeforeCompile.toString()}},{key:"setValues",value:function(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n){var i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE.Material: '".concat(t,"' is not a property of THREE.").concat(this.type,"."))}else console.warn("THREE.Material: parameter '".concat(t,"' has value of undefined."))}}},{key:"toJSON",value:function(e){var t=void 0===e||"string"===typeof e;t&&(e={textures:{},images:{}});var n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==w&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==C&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ke&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ke&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ke&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){var r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,n=null;if(null!==t){var i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}},{key:"needsUpdate",set:function(e){!0===e&&this.version++}}]),n}(Be),Kn=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isMeshBasicMaterial=!0,t.type="MeshBasicMaterial",t.color=new Xn(16777215),t.map=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.specularMap=null,t.alphaMap=null,t.envMap=null,t.combine=L,t.reflectivity=1,t.refractionRatio=.98,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.fog=!0,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}]),i}(Yn);var Zn=new At,Jn=new $e,Qn=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(y(this,e),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=n,this.count=void 0!==t?t.length/n:0,this.normalized=i,this.usage=Ie,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ae,this.version=0}return M(e,[{key:"onUploadCallback",value:function(){}},{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{key:"updateRange",get:function(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}},{key:"setUsage",value:function(e){return this.usage=e,this}},{key:"addUpdateRange",value:function(e,t){this.updateRanges.push({start:e,count:t})}},{key:"clearUpdateRanges",value:function(){this.updateRanges.length=0}},{key:"copy",value:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}},{key:"copyAt",value:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(var i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}},{key:"copyArray",value:function(e){return this.array.set(e),this}},{key:"applyMatrix3",value:function(e){if(2===this.itemSize)for(var t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyMatrix3(e),this.setXY(t,Jn.x,Jn.y);else if(3===this.itemSize)for(var i=0,r=this.count;i<r;i++)Zn.fromBufferAttribute(this,i),Zn.applyMatrix3(e),this.setXYZ(i,Zn.x,Zn.y,Zn.z);return this}},{key:"applyMatrix4",value:function(e){for(var t=0,n=this.count;t<n;t++)Zn.fromBufferAttribute(this,t),Zn.applyMatrix4(e),this.setXYZ(t,Zn.x,Zn.y,Zn.z);return this}},{key:"applyNormalMatrix",value:function(e){for(var t=0,n=this.count;t<n;t++)Zn.fromBufferAttribute(this,t),Zn.applyNormalMatrix(e),this.setXYZ(t,Zn.x,Zn.y,Zn.z);return this}},{key:"transformDirection",value:function(e){for(var t=0,n=this.count;t<n;t++)Zn.fromBufferAttribute(this,t),Zn.transformDirection(e),this.setXYZ(t,Zn.x,Zn.y,Zn.z);return this}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}},{key:"getComponent",value:function(e,t){var n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ze(n,this.array)),n}},{key:"setComponent",value:function(e,t,n){return this.normalized&&(n=Je(n,this.array)),this.array[e*this.itemSize+t]=n,this}},{key:"getX",value:function(e){var t=this.array[e*this.itemSize];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"setX",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize]=t,this}},{key:"getY",value:function(e){var t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"setY",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+1]=t,this}},{key:"getZ",value:function(e){var t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"setZ",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+2]=t,this}},{key:"getW",value:function(e){var t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"setW",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+3]=t,this}},{key:"setXY",value:function(e,t,n){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}},{key:"setXYZ",value:function(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array),i=Je(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}},{key:"setXYZW",value:function(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}},{key:"onUpload",value:function(e){return this.onUploadCallback=e,this}},{key:"clone",value:function(){return new this.constructor(this.array,this.itemSize).copy(this)}},{key:"toJSON",value:function(){var e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Ie&&(e.usage=this.usage),e}}]),e}(),$n=function(e){f(n,e);var t=m(n);function n(e,i,r){return y(this,n),t.call(this,new Uint16Array(e),i,r)}return M(n)}(Qn),ei=function(e){f(n,e);var t=m(n);function n(e,i,r){return y(this,n),t.call(this,new Uint32Array(e),i,r)}return M(n)}(Qn),ti=function(e){f(n,e);var t=m(n);function n(e,i,r){return y(this,n),t.call(this,new Float32Array(e),i,r)}return M(n)}(Qn),ni=0,ii=new nn,ri=new Rn,ai=new At,oi=new Ct,si=new Ct,li=new At,ui=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this)).isBufferGeometry=!0,Object.defineProperty(d(e),"id",{value:ni++}),e.uuid=We(),e.name="",e.type="BufferGeometry",e.index=null,e.attributes={},e.morphAttributes={},e.morphTargetsRelative=!1,e.groups=[],e.boundingBox=null,e.boundingSphere=null,e.drawRange={start:0,count:1/0},e.userData={},e}return M(n,[{key:"getIndex",value:function(){return this.index}},{key:"setIndex",value:function(e){return Array.isArray(e)?this.index=new(nt(e)?ei:$n)(e,1):this.index=e,this}},{key:"getAttribute",value:function(e){return this.attributes[e]}},{key:"setAttribute",value:function(e,t){return this.attributes[e]=t,this}},{key:"deleteAttribute",value:function(e){return delete this.attributes[e],this}},{key:"hasAttribute",value:function(e){return void 0!==this.attributes[e]}},{key:"addGroup",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.groups.push({start:e,count:t,materialIndex:n})}},{key:"clearGroups",value:function(){this.groups=[]}},{key:"setDrawRange",value:function(e,t){this.drawRange.start=e,this.drawRange.count=t}},{key:"applyMatrix4",value:function(e){var t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var n=this.attributes.normal;if(void 0!==n){var i=(new et).getNormalMatrix(e);n.applyNormalMatrix(i),n.needsUpdate=!0}var r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}},{key:"applyQuaternion",value:function(e){return ii.makeRotationFromQuaternion(e),this.applyMatrix4(ii),this}},{key:"rotateX",value:function(e){return ii.makeRotationX(e),this.applyMatrix4(ii),this}},{key:"rotateY",value:function(e){return ii.makeRotationY(e),this.applyMatrix4(ii),this}},{key:"rotateZ",value:function(e){return ii.makeRotationZ(e),this.applyMatrix4(ii),this}},{key:"translate",value:function(e,t,n){return ii.makeTranslation(e,t,n),this.applyMatrix4(ii),this}},{key:"scale",value:function(e,t,n){return ii.makeScale(e,t,n),this.applyMatrix4(ii),this}},{key:"lookAt",value:function(e){return ri.lookAt(e),ri.updateMatrix(),this.applyMatrix4(ri.matrix),this}},{key:"center",value:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(ai).negate(),this.translate(ai.x,ai.y,ai.z),this}},{key:"setFromPoints",value:function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new ti(t,3)),this}},{key:"computeBoundingBox",value:function(){null===this.boundingBox&&(this.boundingBox=new Ct);var e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new At(-1/0,-1/0,-1/0),new At(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var n=0,i=t.length;n<i;n++){var r=t[n];oi.setFromBufferAttribute(r),this.morphTargetsRelative?(li.addVectors(this.boundingBox.min,oi.min),this.boundingBox.expandByPoint(li),li.addVectors(this.boundingBox.max,oi.max),this.boundingBox.expandByPoint(li)):(this.boundingBox.expandByPoint(oi.min),this.boundingBox.expandByPoint(oi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}},{key:"computeBoundingSphere",value:function(){null===this.boundingSphere&&(this.boundingSphere=new qt);var e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new At,1/0);if(e){var n=this.boundingSphere.center;if(oi.setFromBufferAttribute(e),t)for(var i=0,r=t.length;i<r;i++){var a=t[i];si.setFromBufferAttribute(a),this.morphTargetsRelative?(li.addVectors(oi.min,si.min),oi.expandByPoint(li),li.addVectors(oi.max,si.max),oi.expandByPoint(li)):(oi.expandByPoint(si.min),oi.expandByPoint(si.max))}oi.getCenter(n);for(var o=0,s=0,l=e.count;s<l;s++)li.fromBufferAttribute(e,s),o=Math.max(o,n.distanceToSquared(li));if(t)for(var u=0,c=t.length;u<c;u++)for(var h=t[u],d=this.morphTargetsRelative,f=0,p=h.count;f<p;f++)li.fromBufferAttribute(h,f),d&&(ai.fromBufferAttribute(e,f),li.add(ai)),o=Math.max(o,n.distanceToSquared(li));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}},{key:"computeTangents",value:function(){var e=this.index,t=this.attributes;if(null!==e&&void 0!==t.position&&void 0!==t.normal&&void 0!==t.uv){var n=e.array,i=t.position.array,r=t.normal.array,a=t.uv.array,o=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Qn(new Float32Array(4*o),4));for(var s=this.getAttribute("tangent").array,l=[],u=[],c=0;c<o;c++)l[c]=new At,u[c]=new At;var h=new At,d=new At,f=new At,p=new $e,m=new $e,v=new $e,g=new At,_=new At,y=this.groups;0===y.length&&(y=[{start:0,count:n.length}]);for(var x=0,M=y.length;x<M;++x)for(var S=y[x],E=S.start,T=E,b=E+S.count;T<b;T+=3)D(n[T+0],n[T+1],n[T+2]);for(var A=new At,w=new At,R=new At,C=new At,L=0,P=y.length;L<P;++L)for(var U=y[L],k=U.start,I=k,N=k+U.count;I<N;I+=3)O(n[I+0]),O(n[I+1]),O(n[I+2])}else console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");function D(e,t,n){h.fromArray(i,3*e),d.fromArray(i,3*t),f.fromArray(i,3*n),p.fromArray(a,2*e),m.fromArray(a,2*t),v.fromArray(a,2*n),d.sub(h),f.sub(h),m.sub(p),v.sub(p);var r=1/(m.x*v.y-v.x*m.y);isFinite(r)&&(g.copy(d).multiplyScalar(v.y).addScaledVector(f,-m.y).multiplyScalar(r),_.copy(f).multiplyScalar(m.x).addScaledVector(d,-v.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[n].add(g),u[e].add(_),u[t].add(_),u[n].add(_))}function O(e){R.fromArray(r,3*e),C.copy(R);var t=l[e];A.copy(t),A.sub(R.multiplyScalar(R.dot(t))).normalize(),w.crossVectors(C,t);var n=w.dot(u[e])<0?-1:1;s[4*e]=A.x,s[4*e+1]=A.y,s[4*e+2]=A.z,s[4*e+3]=n}}},{key:"computeVertexNormals",value:function(){var e=this.index,t=this.getAttribute("position");if(void 0!==t){var n=this.getAttribute("normal");if(void 0===n)n=new Qn(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(var i=0,r=n.count;i<r;i++)n.setXYZ(i,0,0,0);var a=new At,o=new At,s=new At,l=new At,u=new At,c=new At,h=new At,d=new At;if(e)for(var f=0,p=e.count;f<p;f+=3){var m=e.getX(f+0),v=e.getX(f+1),g=e.getX(f+2);a.fromBufferAttribute(t,m),o.fromBufferAttribute(t,v),s.fromBufferAttribute(t,g),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),l.fromBufferAttribute(n,m),u.fromBufferAttribute(n,v),c.fromBufferAttribute(n,g),l.add(h),u.add(h),c.add(h),n.setXYZ(m,l.x,l.y,l.z),n.setXYZ(v,u.x,u.y,u.z),n.setXYZ(g,c.x,c.y,c.z)}else for(var _=0,y=t.count;_<y;_+=3)a.fromBufferAttribute(t,_+0),o.fromBufferAttribute(t,_+1),s.fromBufferAttribute(t,_+2),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),n.setXYZ(_+0,h.x,h.y,h.z),n.setXYZ(_+1,h.x,h.y,h.z),n.setXYZ(_+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}},{key:"normalizeNormals",value:function(){for(var e=this.attributes.normal,t=0,n=e.count;t<n;t++)li.fromBufferAttribute(e,t),li.normalize(),e.setXYZ(t,li.x,li.y,li.z)}},{key:"toNonIndexed",value:function(){function e(e,t){for(var n=e.array,i=e.itemSize,r=e.normalized,a=new n.constructor(t.length*i),o=0,s=0,l=0,u=t.length;l<u;l++){o=e.isInterleavedBufferAttribute?t[l]*e.data.stride+e.offset:t[l]*i;for(var c=0;c<i;c++)a[s++]=n[o++]}return new Qn(a,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;var t=new n,i=this.index.array,r=this.attributes;for(var a in r){var o=e(r[a],i);t.setAttribute(a,o)}var s=this.morphAttributes;for(var l in s){for(var u=[],c=s[l],h=0,d=c.length;h<d;h++){var f=e(c[h],i);u.push(f)}t.morphAttributes[l]=u}t.morphTargetsRelative=this.morphTargetsRelative;for(var p=this.groups,m=0,v=p.length;m<v;m++){var g=p[m];t.addGroup(g.start,g.count,g.materialIndex)}return t}},{key:"toJSON",value:function(){var e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var i=this.index;null!==i&&(e.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});var r=this.attributes;for(var a in r){var o=r[a];e.data.attributes[a]=o.toJSON(e.data)}var s={},l=!1;for(var u in this.morphAttributes){for(var c=this.morphAttributes[u],h=[],d=0,f=c.length;d<f;d++){var p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(s[u]=h,l=!0)}l&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);var m=this.groups;m.length>0&&(e.data.groups=JSON.parse(JSON.stringify(m)));var v=this.boundingSphere;return null!==v&&(e.data.boundingSphere={center:v.center.toArray(),radius:v.radius}),e}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var t={};this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone(t));var i=e.attributes;for(var r in i){var a=i[r];this.setAttribute(r,a.clone(t))}var o=e.morphAttributes;for(var s in o){for(var l=[],u=o[s],c=0,h=u.length;c<h;c++)l.push(u[c].clone(t));this.morphAttributes[s]=l}this.morphTargetsRelative=e.morphTargetsRelative;for(var d=e.groups,f=0,p=d.length;f<p;f++){var m=d[f];this.addGroup(m.start,m.count,m.materialIndex)}var v=e.boundingBox;null!==v&&(this.boundingBox=v.clone());var g=e.boundingSphere;return null!==g&&(this.boundingSphere=g.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}}]),n}(Be),ci=new nn,hi=new tn,di=new qt,fi=new At,pi=new At,mi=new At,vi=new At,gi=new At,_i=new At,yi=new $e,xi=new $e,Mi=new $e,Si=new At,Ei=new At,Ti=new At,bi=new At,Ai=new At,wi=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ui,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Kn;return y(this,i),(e=n.call(this)).isMesh=!0,e.type="Mesh",e.geometry=t,e.material=r,e.updateMorphTargets(),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}},{key:"updateMorphTargets",value:function(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,r=n.length;i<r;i++){var a=n[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=i}}}}},{key:"getVertexPosition",value:function(e,t){var n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);var o=this.morphTargetInfluences;if(r&&o){_i.set(0,0,0);for(var s=0,l=r.length;s<l;s++){var u=o[s],c=r[s];0!==u&&(gi.fromBufferAttribute(c,e),a?_i.addScaledVector(gi,u):_i.addScaledVector(gi.sub(t),u))}t.add(_i)}return t}},{key:"raycast",value:function(e,t){var n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),di.copy(n.boundingSphere),di.applyMatrix4(r),hi.copy(e.ray).recast(e.near),!1===di.containsPoint(hi.origin)){if(null===hi.intersectSphere(di,fi))return;if(hi.origin.distanceToSquared(fi)>Math.pow(e.far-e.near,2))return}ci.copy(r).invert(),hi.copy(e.ray).applyMatrix4(ci),null!==n.boundingBox&&!1===hi.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,hi)}}},{key:"_computeIntersections",value:function(e,t,n){var i,r=this.geometry,a=this.material,o=r.index,s=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,c=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(a))for(var f=0,p=h.length;f<p;f++)for(var m=h[f],v=a[m.materialIndex],g=Math.max(m.start,d.start),_=Math.min(o.count,Math.min(m.start+m.count,d.start+d.count));g<_;g+=3){(i=Ri(this,v,e,n,l,u,c,o.getX(g),o.getX(g+1),o.getX(g+2)))&&(i.faceIndex=Math.floor(g/3),i.face.materialIndex=m.materialIndex,t.push(i))}else for(var y=Math.max(0,d.start),x=Math.min(o.count,d.start+d.count);y<x;y+=3){(i=Ri(this,a,e,n,l,u,c,o.getX(y),o.getX(y+1),o.getX(y+2)))&&(i.faceIndex=Math.floor(y/3),t.push(i))}else if(void 0!==s)if(Array.isArray(a))for(var M=0,S=h.length;M<S;M++)for(var E=h[M],T=a[E.materialIndex],b=Math.max(E.start,d.start),A=Math.min(s.count,Math.min(E.start+E.count,d.start+d.count));b<A;b+=3){(i=Ri(this,T,e,n,l,u,c,b,b+1,b+2))&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=E.materialIndex,t.push(i))}else for(var w=Math.max(0,d.start),R=Math.min(s.count,d.start+d.count);w<R;w+=3){(i=Ri(this,a,e,n,l,u,c,w,w+1,w+2))&&(i.faceIndex=Math.floor(w/3),t.push(i))}}}]),i}(Rn);function Ri(e,t,n,i,r,a,o,s,l,u){e.getVertexPosition(s,pi),e.getVertexPosition(l,mi),e.getVertexPosition(u,vi);var c=function(e,t,n,i,r,a,o,s){if(null===(t.side===R?i.intersectTriangle(o,a,r,!0,s):i.intersectTriangle(r,a,o,t.side===w,s)))return null;Ai.copy(s),Ai.applyMatrix4(e.matrixWorld);var l=n.ray.origin.distanceTo(Ai);return l<n.near||l>n.far?null:{distance:l,point:Ai.clone(),object:e}}(e,t,n,i,pi,mi,vi,bi);if(c){r&&(yi.fromBufferAttribute(r,s),xi.fromBufferAttribute(r,l),Mi.fromBufferAttribute(r,u),c.uv=zn.getInterpolation(bi,pi,mi,vi,yi,xi,Mi,new $e)),a&&(yi.fromBufferAttribute(a,s),xi.fromBufferAttribute(a,l),Mi.fromBufferAttribute(a,u),c.uv1=zn.getInterpolation(bi,pi,mi,vi,yi,xi,Mi,new $e),c.uv2=c.uv1),o&&(Si.fromBufferAttribute(o,s),Ei.fromBufferAttribute(o,l),Ti.fromBufferAttribute(o,u),c.normal=zn.getInterpolation(bi,pi,mi,vi,Si,Ei,Ti,new At),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));var h={a:s,b:l,c:u,normal:new At,materialIndex:0};zn.getNormal(pi,mi,vi,h.normal),c.face=h}return c}var Ci=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;y(this,i),(e=n.call(this)).type="BoxGeometry",e.parameters={width:t,height:r,depth:a,widthSegments:o,heightSegments:s,depthSegments:l};var u=d(e);o=Math.floor(o),s=Math.floor(s),l=Math.floor(l);var c=[],h=[],f=[],p=[],m=0,v=0;function g(e,t,n,i,r,a,o,s,l,d,g){for(var _=a/l,y=o/d,x=a/2,M=o/2,S=s/2,E=l+1,T=d+1,b=0,A=0,w=new At,R=0;R<T;R++)for(var C=R*y-M,L=0;L<E;L++){var P=L*_-x;w[e]=P*i,w[t]=C*r,w[n]=S,h.push(w.x,w.y,w.z),w[e]=0,w[t]=0,w[n]=s>0?1:-1,f.push(w.x,w.y,w.z),p.push(L/l),p.push(1-R/d),b+=1}for(var U=0;U<d;U++)for(var k=0;k<l;k++){var I=m+k+E*U,N=m+k+E*(U+1),D=m+(k+1)+E*(U+1),O=m+(k+1)+E*U;c.push(I,N,O),c.push(N,D,O),A+=6}u.addGroup(v,A,g),v+=A,m+=b}return g("z","y","x",-1,-1,a,r,t,l,s,0),g("z","y","x",1,-1,a,r,-t,l,s,1),g("x","z","y",1,1,t,a,r,o,l,2),g("x","z","y",1,-1,t,a,-r,o,l,3),g("x","y","z",1,-1,t,r,a,o,s,4),g("x","y","z",-1,-1,t,r,-a,o,s,5),e.setIndex(c),e.setAttribute("position",new ti(h,3)),e.setAttribute("normal",new ti(f,3)),e.setAttribute("uv",new ti(p,2)),e}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.parameters=Object.assign({},t.parameters),this}}],[{key:"fromJSON",value:function(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}]),i}(ui);function Li(e){var t={};for(var n in e)for(var i in t[n]={},e[n]){var r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}return t}function Pi(e){for(var t={},n=0;n<e.length;n++){var i=Li(e[n]);for(var r in i)t[r]=i[r]}return t}function Ui(e){return null===e.getRenderTarget()?e.outputColorSpace:ht.workingColorSpace}var ki={clone:Li,merge:Pi},Ii=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isShaderMaterial=!0,t.type="ShaderMaterial",t.defines={},t.uniforms={},t.uniformsGroups=[],t.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",t.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",t.linewidth=1,t.wireframe=!1,t.wireframeLinewidth=1,t.fog=!1,t.lights=!1,t.clipping=!1,t.forceSinglePass=!0,t.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},t.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},t.index0AttributeName=void 0,t.uniformsNeedUpdate=!1,t.glslVersion=null,void 0!==e&&t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Li(t.uniforms),this.uniformsGroups=function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n].clone());return t}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);for(var r in n.glslVersion=this.glslVersion,n.uniforms={},this.uniforms){var a=this.uniforms[r].value;a&&a.isTexture?n.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?n.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[r]={type:"m4",value:a.toArray()}:n.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;var o={};for(var s in this.extensions)!0===this.extensions[s]&&(o[s]=!0);return Object.keys(o).length>0&&(n.extensions=o),n}}]),i}(Yn),Ni=function(t){f(i,t);var n=m(i);function i(){var e;return y(this,i),(e=n.call(this)).isCamera=!0,e.type="Camera",e.matrixWorldInverse=new nn,e.projectionMatrix=new nn,e.projectionMatrixInverse=new nn,e.coordinateSystem=Oe,e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}},{key:"getWorldDirection",value:function(t){return c(e(i.prototype),"getWorldDirection",this).call(this,t).negate()}},{key:"updateMatrixWorld",value:function(t){c(e(i.prototype),"updateMatrixWorld",this).call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"updateWorldMatrix",value:function(t,n){c(e(i.prototype),"updateWorldMatrix",this).call(this,t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),i}(Rn),Di=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2e3;return y(this,i),(e=n.call(this)).isPerspectiveCamera=!0,e.type="PerspectiveCamera",e.fov=t,e.zoom=1,e.near=a,e.far=o,e.focus=10,e.aspect=r,e.view=null,e.filmGauge=35,e.filmOffset=0,e.updateProjectionMatrix(),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}},{key:"setFocalLength",value:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*Ve*Math.atan(t),this.updateProjectionMatrix()}},{key:"getFocalLength",value:function(){var e=Math.tan(.5*Ge*this.fov);return.5*this.getFilmHeight()/e}},{key:"getEffectiveFOV",value:function(){return 2*Ve*Math.atan(Math.tan(.5*Ge*this.fov)/this.zoom)}},{key:"getFilmWidth",value:function(){return this.filmGauge*Math.min(this.aspect,1)}},{key:"getFilmHeight",value:function(){return this.filmGauge/Math.max(this.aspect,1)}},{key:"setViewOffset",value:function(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}},{key:"clearViewOffset",value:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}},{key:"updateProjectionMatrix",value:function(){var e=this.near,t=e*Math.tan(.5*Ge*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/o,t-=a.offsetY*n/s,i*=a.width/o,n*=a.height/s}var l=this.filmOffset;0!==l&&(r+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,null!==this.view&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}]),i}(Ni),Oi=-90,Fi=function(e){f(n,e);var t=m(n);function n(e,i,r){var a;y(this,n),(a=t.call(this)).type="CubeCamera",a.renderTarget=r,a.coordinateSystem=null,a.activeMipmapLevel=0;var o=new Di(Oi,1,e,i);o.layers=a.layers,a.add(o);var s=new Di(Oi,1,e,i);s.layers=a.layers,a.add(s);var l=new Di(Oi,1,e,i);l.layers=a.layers,a.add(l);var u=new Di(Oi,1,e,i);u.layers=a.layers,a.add(u);var c=new Di(Oi,1,e,i);c.layers=a.layers,a.add(c);var h=new Di(Oi,1,e,i);return h.layers=a.layers,a.add(h),a}return M(n,[{key:"updateCoordinateSystem",value:function(){var e,t=this.coordinateSystem,n=this.children.concat(),i=u(n,6),r=i[0],a=i[1],o=i[2],s=i[3],c=i[4],h=i[5],d=l(n);try{for(d.s();!(e=d.n()).done;){var f=e.value;this.remove(f)}}catch(g){d.e(g)}finally{d.f()}if(t===Oe)r.up.set(0,1,0),r.lookAt(1,0,0),a.up.set(0,1,0),a.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else{if(t!==Fe)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);r.up.set(0,-1,0),r.lookAt(-1,0,0),a.up.set(0,-1,0),a.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1)}var p,m=l(n);try{for(m.s();!(p=m.n()).done;){var v=p.value;this.add(v),v.updateMatrixWorld()}}catch(g){m.e(g)}finally{m.f()}}},{key:"update",value:function(e,t){null===this.parent&&this.updateMatrixWorld();var n=this.renderTarget,i=this.activeMipmapLevel;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());var r=u(this.children,6),a=r[0],o=r[1],s=r[2],l=r[3],c=r[4],h=r[5],d=e.getRenderTarget(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;var v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,a),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(d,f,p),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}]),n}(Rn),Bi=function(e){f(n,e);var t=m(n);function n(e,i,r,a,o,s,l,u,c,h){var d;return y(this,n),e=void 0!==e?e:[],i=void 0!==i?i:H,(d=t.call(this,e,i,r,a,o,s,l,u,c,h)).isCubeTexture=!0,d.flipY=!1,d}return M(n,[{key:"images",get:function(){return this.image},set:function(e){this.image=e}}]),n}(yt),zi=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y(this,n),(e=t.call(this,i,i,r)).isWebGLCubeRenderTarget=!0;var a={width:i,height:i,depth:1},o=[a,a,a,a,a,a];return void 0!==r.encoding&&(at("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ee?be:Te),e.texture=new Bi(o,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),e.texture.isRenderTargetTexture=!0,e.texture.generateMipmaps=void 0!==r.generateMipmaps&&r.generateMipmaps,e.texture.minFilter=void 0!==r.minFilter?r.minFilter:Q,e}return M(n,[{key:"fromEquirectangularTexture",value:function(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;var n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new Ci(5,5,5),o=new Ii({name:"CubemapFromEquirect",uniforms:Li(n),vertexShader:i,fragmentShader:r,side:R,blending:0});o.uniforms.tEquirect.value=t;var s=new wi(a,o),l=t.minFilter;return t.minFilter===ee&&(t.minFilter=Q),new Fi(1,10,this).update(e,s),t.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}},{key:"clear",value:function(e,t,n,i){for(var r=e.getRenderTarget(),a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}]),n}(St),Hi=new At,Gi=new At,Vi=new et,Wi=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new At(1,0,0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;y(this,e),this.isPlane=!0,this.normal=t,this.constant=n}return M(e,[{key:"set",value:function(e,t){return this.normal.copy(e),this.constant=t,this}},{key:"setComponents",value:function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}},{key:"setFromNormalAndCoplanarPoint",value:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}},{key:"setFromCoplanarPoints",value:function(e,t,n){var i=Hi.subVectors(n,t).cross(Gi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}},{key:"copy",value:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this}},{key:"normalize",value:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}},{key:"negate",value:function(){return this.constant*=-1,this.normal.negate(),this}},{key:"distanceToPoint",value:function(e){return this.normal.dot(e)+this.constant}},{key:"distanceToSphere",value:function(e){return this.distanceToPoint(e.center)-e.radius}},{key:"projectPoint",value:function(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}},{key:"intersectLine",value:function(e,t){var n=e.delta(Hi),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;var r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}},{key:"intersectsLine",value:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}},{key:"intersectsBox",value:function(e){return e.intersectsPlane(this)}},{key:"intersectsSphere",value:function(e){return e.intersectsPlane(this)}},{key:"coplanarPoint",value:function(e){return e.copy(this.normal).multiplyScalar(-this.constant)}},{key:"applyMatrix4",value:function(e,t){var n=t||Vi.getNormalMatrix(e),i=this.coplanarPoint(Hi).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}},{key:"translate",value:function(e){return this.constant-=e.dot(this.normal),this}},{key:"equals",value:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),e}(),Xi=new qt,ji=new At,qi=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Wi,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Wi,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Wi,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Wi,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new Wi,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new Wi;y(this,e),this.planes=[t,n,i,r,a,o]}return M(e,[{key:"set",value:function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}},{key:"copy",value:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this}},{key:"setFromProjectionMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe,n=this.planes,i=e.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=i[4],u=i[5],c=i[6],h=i[7],d=i[8],f=i[9],p=i[10],m=i[11],v=i[12],g=i[13],_=i[14],y=i[15];if(n[0].setComponents(s-r,h-l,m-d,y-v).normalize(),n[1].setComponents(s+r,h+l,m+d,y+v).normalize(),n[2].setComponents(s+a,h+u,m+f,y+g).normalize(),n[3].setComponents(s-a,h-u,m-f,y-g).normalize(),n[4].setComponents(s-o,h-c,m-p,y-_).normalize(),t===Oe)n[5].setComponents(s+o,h+c,m+p,y+_).normalize();else{if(t!==Fe)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(o,c,p,_).normalize()}return this}},{key:"intersectsObject",value:function(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Xi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{var t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Xi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Xi)}},{key:"intersectsSprite",value:function(e){return Xi.center.set(0,0,0),Xi.radius=.7071067811865476,Xi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xi)}},{key:"intersectsSphere",value:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)<i)return!1}return!0}},{key:"intersectsBox",value:function(e){for(var t=this.planes,n=0;n<6;n++){var i=t[n];if(ji.x=i.normal.x>0?e.max.x:e.min.x,ji.y=i.normal.y>0?e.max.y:e.min.y,ji.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ji)<0)return!1}return!0}},{key:"containsPoint",value:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}]),e}();function Yi(){var e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Ki(e,t){var n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){var a=i.get(t);(!a||a.version<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version})}else{t.isInterleavedBufferAttribute&&(t=t.data);var o=i.get(t);if(void 0===o)i.set(t,function(t,i){var r,a=t.array,o=t.usage,s=a.byteLength,l=e.createBuffer();if(e.bindBuffer(i,l),e.bufferData(i,a,o),t.onUploadCallback(),a instanceof Float32Array)r=e.FLOAT;else if(a instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");r=e.HALF_FLOAT}else r=e.UNSIGNED_SHORT;else if(a instanceof Int16Array)r=e.SHORT;else if(a instanceof Uint32Array)r=e.UNSIGNED_INT;else if(a instanceof Int32Array)r=e.INT;else if(a instanceof Int8Array)r=e.BYTE;else if(a instanceof Uint8Array)r=e.UNSIGNED_BYTE;else{if(!(a instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);r=e.UNSIGNED_BYTE}return{buffer:l,type:r,bytesPerElement:a.BYTES_PER_ELEMENT,version:t.version,size:s}}(t,r));else if(o.version<t.version){if(o.size!==t.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,i,r){var a=i.array,o=i._updateRange,s=i.updateRanges;if(e.bindBuffer(r,t),-1===o.count&&0===s.length&&e.bufferSubData(r,0,a),0!==s.length){for(var l=0,u=s.length;l<u;l++){var c=s[l];n?e.bufferSubData(r,c.start*a.BYTES_PER_ELEMENT,a,c.start,c.count):e.bufferSubData(r,c.start*a.BYTES_PER_ELEMENT,a.subarray(c.start,c.start+c.count))}i.clearUpdateRanges()}-1!==o.count&&(n?e.bufferSubData(r,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):e.bufferSubData(r,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1),i.onUploadCallback()}(o.buffer,t,r),o.version=t.version}}}}}var Zi=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;y(this,i),(e=n.call(this)).type="PlaneGeometry",e.parameters={width:t,height:r,widthSegments:a,heightSegments:o};for(var s=t/2,l=r/2,u=Math.floor(a),c=Math.floor(o),h=u+1,d=c+1,f=t/u,p=r/c,m=[],v=[],g=[],_=[],x=0;x<d;x++)for(var M=x*p-l,S=0;S<h;S++){var E=S*f-s;v.push(E,-M,0),g.push(0,0,1),_.push(S/u),_.push(1-x/c)}for(var T=0;T<c;T++)for(var b=0;b<u;b++){var A=b+h*T,w=b+h*(T+1),R=b+1+h*(T+1),C=b+1+h*T;m.push(A,w,C),m.push(w,R,C)}return e.setIndex(m),e.setAttribute("position",new ti(v,3)),e.setAttribute("normal",new ti(g,3)),e.setAttribute("uv",new ti(_,2)),e}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.parameters=Object.assign({},t.parameters),this}}],[{key:"fromJSON",value:function(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}}]),i}(ui),Ji={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn 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\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.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\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\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\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform 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\tvec3 diffuseColor;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 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\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_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\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - 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\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#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\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn 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\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn 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\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn 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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn 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\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform 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\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn 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\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#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\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_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\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( 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\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#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\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform 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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_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\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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 <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#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\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#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\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying 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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\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 <envmap_common_pars_fragment>\n#include <envmap_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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - 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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying 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\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - 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\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\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\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#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 <packing>\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 <envmap_common_pars_fragment>\n#include <envmap_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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying 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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#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\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#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\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#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\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\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\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_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\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#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\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Qi={common:{diffuse:{value:new Xn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new et},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new et}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new et}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new et}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new et},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new et},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new et},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new et}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new et}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new et}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Xn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0},uvTransform:{value:new et}},sprite:{diffuse:{value:new Xn(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new et},alphaMap:{value:null},alphaMapTransform:{value:new et},alphaTest:{value:0}}},$i={basic:{uniforms:Pi([Qi.common,Qi.specularmap,Qi.envmap,Qi.aomap,Qi.lightmap,Qi.fog]),vertexShader:Ji.meshbasic_vert,fragmentShader:Ji.meshbasic_frag},lambert:{uniforms:Pi([Qi.common,Qi.specularmap,Qi.envmap,Qi.aomap,Qi.lightmap,Qi.emissivemap,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,Qi.fog,Qi.lights,{emissive:{value:new Xn(0)}}]),vertexShader:Ji.meshlambert_vert,fragmentShader:Ji.meshlambert_frag},phong:{uniforms:Pi([Qi.common,Qi.specularmap,Qi.envmap,Qi.aomap,Qi.lightmap,Qi.emissivemap,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,Qi.fog,Qi.lights,{emissive:{value:new Xn(0)},specular:{value:new Xn(1118481)},shininess:{value:30}}]),vertexShader:Ji.meshphong_vert,fragmentShader:Ji.meshphong_frag},standard:{uniforms:Pi([Qi.common,Qi.envmap,Qi.aomap,Qi.lightmap,Qi.emissivemap,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,Qi.roughnessmap,Qi.metalnessmap,Qi.fog,Qi.lights,{emissive:{value:new Xn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ji.meshphysical_vert,fragmentShader:Ji.meshphysical_frag},toon:{uniforms:Pi([Qi.common,Qi.aomap,Qi.lightmap,Qi.emissivemap,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,Qi.gradientmap,Qi.fog,Qi.lights,{emissive:{value:new Xn(0)}}]),vertexShader:Ji.meshtoon_vert,fragmentShader:Ji.meshtoon_frag},matcap:{uniforms:Pi([Qi.common,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,Qi.fog,{matcap:{value:null}}]),vertexShader:Ji.meshmatcap_vert,fragmentShader:Ji.meshmatcap_frag},points:{uniforms:Pi([Qi.points,Qi.fog]),vertexShader:Ji.points_vert,fragmentShader:Ji.points_frag},dashed:{uniforms:Pi([Qi.common,Qi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ji.linedashed_vert,fragmentShader:Ji.linedashed_frag},depth:{uniforms:Pi([Qi.common,Qi.displacementmap]),vertexShader:Ji.depth_vert,fragmentShader:Ji.depth_frag},normal:{uniforms:Pi([Qi.common,Qi.bumpmap,Qi.normalmap,Qi.displacementmap,{opacity:{value:1}}]),vertexShader:Ji.meshnormal_vert,fragmentShader:Ji.meshnormal_frag},sprite:{uniforms:Pi([Qi.sprite,Qi.fog]),vertexShader:Ji.sprite_vert,fragmentShader:Ji.sprite_frag},background:{uniforms:{uvTransform:{value:new et},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ji.background_vert,fragmentShader:Ji.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ji.backgroundCube_vert,fragmentShader:Ji.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ji.cube_vert,fragmentShader:Ji.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ji.equirect_vert,fragmentShader:Ji.equirect_frag},distanceRGBA:{uniforms:Pi([Qi.common,Qi.displacementmap,{referencePosition:{value:new At},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ji.distanceRGBA_vert,fragmentShader:Ji.distanceRGBA_frag},shadow:{uniforms:Pi([Qi.lights,Qi.fog,{color:{value:new Xn(0)},opacity:{value:1}}]),vertexShader:Ji.shadow_vert,fragmentShader:Ji.shadow_frag}};$i.physical={uniforms:Pi([$i.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new et},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new et},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new et},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new et},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new et},sheen:{value:0},sheenColor:{value:new Xn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new et},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new et},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new et},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new et},attenuationDistance:{value:0},attenuationColor:{value:new Xn(0)},specularColor:{value:new Xn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new et},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new et},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new et}}]),vertexShader:Ji.meshphysical_vert,fragmentShader:Ji.meshphysical_frag};var er={r:0,b:0,g:0};function tr(e,t,n,i,r,a,o){var s,l,u=new Xn(0),c=!0===a?0:1,h=null,d=0,f=null;function p(t,n){t.getRGB(er,Ui(e)),i.buffers.color.setClear(er.r,er.g,er.b,n,o)}return{getClearColor:function(){return u},setClearColor:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;u.set(e),p(u,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){p(u,c=e)},render:function(a,m){var v=!1,g=!0===m.isScene?m.background:null;g&&g.isTexture&&(g=(m.backgroundBlurriness>0?n:t).get(g)),null===g?p(u,c):g&&g.isColor&&(p(g,1),v=!0);var _=e.xr.getEnvironmentBlendMode();"additive"===_?i.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===_&&i.buffers.color.setClear(0,0,0,0,o),(e.autoClear||v)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),g&&(g.isCubeTexture||g.mapping===X)?(void 0===l&&((l=new wi(new Ci(1,1,1),new Ii({name:"BackgroundCubeMaterial",uniforms:Li($i.backgroundCube.uniforms),vertexShader:$i.backgroundCube.vertexShader,fragmentShader:$i.backgroundCube.fragmentShader,side:R,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=g,l.material.uniforms.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=ht.getTransfer(g.colorSpace)!==Le,h===g&&d===g.version&&f===e.toneMapping||(l.material.needsUpdate=!0,h=g,d=g.version,f=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):g&&g.isTexture&&(void 0===s&&((s=new wi(new Zi(2,2),new Ii({name:"BackgroundMaterial",uniforms:Li($i.background.uniforms),vertexShader:$i.background.vertexShader,fragmentShader:$i.background.fragmentShader,side:w,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=g,s.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,s.material.toneMapped=ht.getTransfer(g.colorSpace)!==Le,!0===g.matrixAutoUpdate&&g.updateMatrix(),s.material.uniforms.uvTransform.value.copy(g.matrix),h===g&&d===g.version&&f===e.toneMapping||(s.material.needsUpdate=!0,h=g,d=g.version,f=e.toneMapping),s.layers.enableAll(),a.unshift(s,s.geometry,s.material,0,0,null))}}}function nr(e,t,n,i){var r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||null!==a,s={},l=f(null),u=l,c=!1;function h(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function f(e){for(var t=[],n=[],i=[],a=0;a<r;a++)t[a]=0,n[a]=0,i[a]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,object:e,attributes:{},index:null}}function p(){for(var e=u.newAttributes,t=0,n=e.length;t<n;t++)e[t]=0}function m(e){v(e,0)}function v(n,r){var a=u.newAttributes,o=u.enabledAttributes,s=u.attributeDivisors;(a[n]=1,0===o[n]&&(e.enableVertexAttribArray(n),o[n]=1),s[n]!==r)&&((i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),s[n]=r)}function g(){for(var t=u.newAttributes,n=u.enabledAttributes,i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function _(t,n,i,r,a,o,s){!0===s?e.vertexAttribIPointer(t,n,i,a,o):e.vertexAttribPointer(t,n,i,r,a,o)}function y(){x(),c=!0,u!==l&&h((u=l).object)}function x(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,y,x){var M=!1;if(o){var S=function(t,n,r){var o=!0===r.wireframe,l=s[t.id];void 0===l&&(l={},s[t.id]=l);var u=l[n.id];void 0===u&&(u={},l[n.id]=u);var c=u[o];void 0===c&&(c=f(i.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),u[o]=c);return c}(y,d,l);u!==S&&h((u=S).object),M=function(e,t,n,i){var r=u.attributes,a=t.attributes,o=0,s=n.getAttributes();for(var l in s){if(s[l].location>=0){var c=r[l],h=a[l];if(void 0===h&&("instanceMatrix"===l&&e.instanceMatrix&&(h=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(h=e.instanceColor)),void 0===c)return!0;if(c.attribute!==h)return!0;if(h&&c.data!==h.data)return!0;o++}}return u.attributesNum!==o||u.index!==i}(r,y,d,x),M&&function(e,t,n,i){var r={},a=t.attributes,o=0,s=n.getAttributes();for(var l in s){if(s[l].location>=0){var c=a[l];void 0===c&&("instanceMatrix"===l&&e.instanceMatrix&&(c=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(c=e.instanceColor));var h={};h.attribute=c,c&&c.data&&(h.data=c.data),r[l]=h,o++}}u.attributes=r,u.attributesNum=o,u.index=i}(r,y,d,x)}else{var E=!0===l.wireframe;u.geometry===y.id&&u.program===d.id&&u.wireframe===E||(u.geometry=y.id,u.program=d.id,u.wireframe=E,M=!0)}null!==x&&n.update(x,e.ELEMENT_ARRAY_BUFFER),(M||c)&&(c=!1,function(r,a,o,s){if(!1===i.isWebGL2&&(r.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();var l=s.attributes,u=o.getAttributes(),c=a.defaultAttributeValues;for(var h in u){var d=u[h];if(d.location>=0){var f=l[h];if(void 0===f&&("instanceMatrix"===h&&r.instanceMatrix&&(f=r.instanceMatrix),"instanceColor"===h&&r.instanceColor&&(f=r.instanceColor)),void 0!==f){var y=f.normalized,x=f.itemSize,M=n.get(f);if(void 0===M)continue;var S=M.buffer,E=M.type,T=M.bytesPerElement,b=!0===i.isWebGL2&&(E===e.INT||E===e.UNSIGNED_INT||f.gpuType===ie);if(f.isInterleavedBufferAttribute){var A=f.data,w=A.stride,R=f.offset;if(A.isInstancedInterleavedBuffer){for(var C=0;C<d.locationSize;C++)v(d.location+C,A.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=A.meshPerAttribute*A.count)}else for(var L=0;L<d.locationSize;L++)m(d.location+L);e.bindBuffer(e.ARRAY_BUFFER,S);for(var P=0;P<d.locationSize;P++)_(d.location+P,x/d.locationSize,E,y,w*T,(R+x/d.locationSize*P)*T,b)}else{if(f.isInstancedBufferAttribute){for(var U=0;U<d.locationSize;U++)v(d.location+U,f.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=f.meshPerAttribute*f.count)}else for(var k=0;k<d.locationSize;k++)m(d.location+k);e.bindBuffer(e.ARRAY_BUFFER,S);for(var I=0;I<d.locationSize;I++)_(d.location+I,x/d.locationSize,E,y,x*T,x/d.locationSize*I*T,b)}}else if(void 0!==c){var N=c[h];if(void 0!==N)switch(N.length){case 2:e.vertexAttrib2fv(d.location,N);break;case 3:e.vertexAttrib3fv(d.location,N);break;case 4:e.vertexAttrib4fv(d.location,N);break;default:e.vertexAttrib1fv(d.location,N)}}}}g()}(r,l,d,y),null!==x&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){for(var e in y(),s){var t=s[e];for(var n in t){var i=t[n];for(var r in i)d(i[r].object),delete i[r];delete t[n]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0!==s[e.id]){var t=s[e.id];for(var n in t){var i=t[n];for(var r in i)d(i[r].object),delete i[r];delete t[n]}delete s[e.id]}},releaseStatesOfProgram:function(e){for(var t in s){var n=s[t];if(void 0!==n[e.id]){var i=n[e.id];for(var r in i)d(i[r].object),delete i[r];delete n[e.id]}}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:g}}function ir(e,t,n,i){var r,a=i.isWebGL2;this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r,1)},this.renderInstances=function(i,o,s){if(0!==s){var l,u;if(a)l=e,u="drawArraysInstanced";else if(u="drawArraysInstancedANGLE",null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](r,i,o,s),n.update(o,r,s)}},this.renderMultiDraw=function(e,i,a){if(0!==a){var o=t.get("WEBGL_multi_draw");if(null===o)for(var s=0;s<a;s++)this.render(e[s],i[s]);else{o.multiDrawArraysWEBGL(r,e,0,i,0,a);for(var l=0,u=0;u<a;u++)l+=i[u];n.update(l,r,1)}}}}function rr(e,t,n){var i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a="undefined"!==typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=a||t.has("WEBGL_draw_buffers"),u=!0===n.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),f=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=h>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){var n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:_,floatFragmentTextures:y,floatVertexTextures:_&&y,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function ar(e){var t=this,n=null,i=0,r=!1,a=!1,o=new Wi,s=new et,l={value:null,needsUpdate:!1};function u(e,n,i,r){var a=null!==e?e.length:0,u=null;if(0!==a){if(u=l.value,!0!==r||null===u){var c=i+4*a,h=n.matrixWorldInverse;s.getNormalMatrix(h),(null===u||u.length<c)&&(u=new Float32Array(c));for(var d=0,f=i;d!==a;++d,f+=4)o.copy(e[d]).applyMatrix4(h,s),o.normal.toArray(u,f),u[f+3]=o.constant}l.value=u,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,u}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){var n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(o,s,c){var h=o.clippingPlanes,d=o.clipIntersection,f=o.clipShadows,p=e.get(o);if(!r||null===h||0===h.length||a&&!f)a?u(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{var m=a?0:i,v=4*m,g=p.clippingState||null;l.value=g,g=u(h,s,v,c);for(var _=0;_!==v;++_)g[_]=n[_];p.clippingState=g,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=m}}}function or(e){var t=new WeakMap;function n(e,t){return t===V?e.mapping=H:t===W&&(e.mapping=G),e}function i(e){var n=e.target;n.removeEventListener("dispose",i);var r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){var a=r.mapping;if(a===V||a===W){if(t.has(r))return n(t.get(r).texture,r.mapping);var o=r.image;if(o&&o.height>0){var s=new zi(o.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}return r},dispose:function(){t=new WeakMap}}}var sr=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.1,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2e3;return y(this,i),(e=n.call(this)).isOrthographicCamera=!0,e.type="OrthographicCamera",e.zoom=1,e.view=null,e.left=t,e.right=r,e.top=a,e.bottom=o,e.near=s,e.far=l,e.updateProjectionMatrix(),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}},{key:"setViewOffset",value:function(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}},{key:"clearViewOffset",value:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}},{key:"updateProjectionMatrix",value:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,a=n+e,o=i+t,s=i-t;if(null!==this.view&&this.view.enabled){var l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a=(r+=l*this.view.offsetX)+l*this.view.width,s=(o-=u*this.view.offsetY)-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,null!==this.view&&(n.object.view=Object.assign({},this.view)),n}}]),i}(Ni),lr=[.125,.215,.35,.446,.526,.582],ur=20,cr=new sr,hr=new Xn,dr=null,fr=0,pr=0,mr=(1+Math.sqrt(5))/2,vr=1/mr,gr=[new At(1,1,1),new At(-1,1,1),new At(1,1,-1),new At(-1,1,-1),new At(0,mr,vr),new At(0,mr,-vr),new At(vr,0,mr),new At(-vr,0,mr),new At(mr,vr,0),new At(-mr,vr,0)],_r=function(){function e(t){y(this,e),this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}return M(e,[{key:"fromScene",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;dr=this._renderer.getRenderTarget(),fr=this._renderer.getActiveCubeFace(),pr=this._renderer.getActiveMipmapLevel(),this._setSize(256);var r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}},{key:"fromEquirectangular",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}},{key:"fromCubemap",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}},{key:"compileCubemapShader",value:function(){null===this._cubemapMaterial&&(this._cubemapMaterial=Sr(),this._compileMaterial(this._cubemapMaterial))}},{key:"compileEquirectangularShader",value:function(){null===this._equirectMaterial&&(this._equirectMaterial=Mr(),this._compileMaterial(this._equirectMaterial))}},{key:"dispose",value:function(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}},{key:"_setSize",value:function(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}},{key:"_dispose",value:function(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(var e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}},{key:"_cleanup",value:function(e){this._renderer.setRenderTarget(dr,fr,pr),e.scissorTest=!1,xr(e,0,0,e.width,e.height)}},{key:"_fromTexture",value:function(e,t){e.mapping===H||e.mapping===G?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),dr=this._renderer.getRenderTarget(),fr=this._renderer.getActiveCubeFace(),pr=this._renderer.getActiveMipmapLevel();var n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}},{key:"_allocateTargets",value:function(){var e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Q,minFilter:Q,generateMipmaps:!1,type:oe,format:le,colorSpace:Ae,depthBuffer:!1},i=yr(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=yr(e,t,n);var r=this._lodMax,a=function(e){for(var t=[],n=[],i=[],r=e,a=e-4+1+lr.length,o=0;o<a;o++){var s=Math.pow(2,r);n.push(s);var l=1/s;o>e-4?l=lr[o-e+4-1]:0===o&&(l=0),i.push(l);for(var u=1/(s-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=6,p=6,m=3,v=2,g=1,_=new Float32Array(m*p*f),y=new Float32Array(v*p*f),x=new Float32Array(g*p*f),M=0;M<f;M++){var S=M%3*2/3-1,E=M>2?0:-1,T=[S,E,0,S+2/3,E,0,S+2/3,E+1,0,S,E,0,S+2/3,E+1,0,S,E+1,0];_.set(T,m*p*M),y.set(d,v*p*M);var b=[M,M,M,M,M,M];x.set(b,g*p*M)}var A=new ui;A.setAttribute("position",new Qn(_,m)),A.setAttribute("uv",new Qn(y,v)),A.setAttribute("faceIndex",new Qn(x,g)),t.push(A),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(r);this._sizeLods=a.sizeLods,this._lodPlanes=a.lodPlanes,this._sigmas=a.sigmas,this._blurMaterial=function(e,t,n){var i=new Float32Array(ur),r=new At(0,1,0),a=new Ii({name:"SphericalGaussianBlur",defines:{n:ur,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:"".concat(e,".0")},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(r,e,t)}return i}},{key:"_compileMaterial",value:function(e){var t=new wi(this._lodPlanes[0],e);this._renderer.compile(t,cr)}},{key:"_sceneToCubeUV",value:function(e,t,n,i){var r=new Di(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,u=s.toneMapping;s.getClearColor(hr),s.toneMapping=k,s.autoClear=!1;var c=new Kn({name:"PMREM.Background",side:R,depthWrite:!1,depthTest:!1}),h=new wi(new Ci,c),d=!1,f=e.background;f?f.isColor&&(c.color.copy(f),e.background=null,d=!0):(c.color.copy(hr),d=!0);for(var p=0;p<6;p++){var m=p%3;0===m?(r.up.set(0,a[p],0),r.lookAt(o[p],0,0)):1===m?(r.up.set(0,0,a[p]),r.lookAt(0,o[p],0)):(r.up.set(0,a[p],0),r.lookAt(0,0,o[p]));var v=this._cubeSize;xr(i,m*v,p>2?v:0,v,v),s.setRenderTarget(i),d&&s.render(h,r),s.render(e,r)}h.geometry.dispose(),h.material.dispose(),s.toneMapping=u,s.autoClear=l,e.background=f}},{key:"_textureToCubeUV",value:function(e,t){var n=this._renderer,i=e.mapping===H||e.mapping===G;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Sr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Mr());var r=i?this._cubemapMaterial:this._equirectMaterial,a=new wi(this._lodPlanes[0],r);r.uniforms.envMap.value=e;var o=this._cubeSize;xr(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,cr)}},{key:"_applyPMREM",value:function(e){var t=this._renderer,n=t.autoClear;t.autoClear=!1;for(var i=1;i<this._lodPlanes.length;i++){var r=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=gr[(i-1)%gr.length];this._blur(e,i-1,i,r,a)}t.autoClear=n}},{key:"_blur",value:function(e,t,n,i,r){var a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}},{key:"_halfBlur",value:function(e,t,n,i,r,a,o){var s=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");var u=new wi(this._lodPlanes[i],l),c=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,f=r/d,p=isFinite(r)?1+Math.floor(3*f):ur;p>ur&&console.warn("sigmaRadians, ".concat(r,", is too large and will clip, as it requested ").concat(p," samples when the maximum is set to ").concat(ur));for(var m=[],v=0,g=0;g<ur;++g){var _=g/f,y=Math.exp(-_*_/2);m.push(y),0===g?v+=y:g<p&&(v+=2*y)}for(var x=0;x<m.length;x++)m[x]=m[x]/v;c.envMap.value=e.texture,c.samples.value=p,c.weights.value=m,c.latitudinal.value="latitudinal"===a,o&&(c.poleAxis.value=o);var M=this._lodMax;c.dTheta.value=d,c.mipInt.value=M-n;var S=this._sizeLods[i];xr(t,3*S*(i>M-4?i-M+4:0),4*(this._cubeSize-S),3*S,2*S),s.setRenderTarget(t),s.render(u,cr)}}]),e}();function yr(e,t,n){var i=new St(e,t,n);return i.texture.mapping=X,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xr(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Mr(){return new Ii({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Sr(){return new Ii({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Er(e){var t=new WeakMap,n=null;function i(e){var n=e.target;n.removeEventListener("dispose",i);var r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){var a=r.mapping,o=a===V||a===W,s=a===H||a===G;if(o||s){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;var l=t.get(r);return null===n&&(n=new _r(e)),l=o?n.fromEquirectangular(r,l):n.fromCubemap(r,l),t.set(r,l),l.texture}if(t.has(r))return t.get(r).texture;var u=r.image;if(o&&u&&u.height>0||s&&u&&function(e){for(var t=0,n=6,i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(u)){null===n&&(n=new _r(e));var c=o?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,c),r.addEventListener("dispose",i),c.texture}return null}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Tr(e){var t={};function n(n){if(void 0!==t[n])return t[n];var i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?(n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance")):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){var t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function br(e,t,n,i){var r={},a=new WeakMap;function o(e){var s=e.target;for(var l in null!==s.index&&t.remove(s.index),s.attributes)t.remove(s.attributes[l]);for(var u in s.morphAttributes)for(var c=s.morphAttributes[u],h=0,d=c.length;h<d;h++)t.remove(c[h]);s.removeEventListener("dispose",o),delete r[s.id];var f=a.get(s);f&&(t.remove(f),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){var n=[],i=e.index,r=e.attributes.position,o=0;if(null!==i){var s=i.array;o=i.version;for(var l=0,u=s.length;l<u;l+=3){var c=s[l+0],h=s[l+1],d=s[l+2];n.push(c,h,h,d,d,c)}}else{if(void 0===r)return;var f=r.array;o=r.version;for(var p=0,m=f.length/3-1;p<m;p+=3){var v=p+0,g=p+1,_=p+2;n.push(v,g,g,_,_,v)}}var y=new(nt(n)?ei:$n)(n,1);y.version=o;var x=a.get(e);x&&t.remove(x),a.set(e,y)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",o),r[t.id]=!0,n.memory.geometries++),t},update:function(n){var i=n.attributes;for(var r in i)t.update(i[r],e.ARRAY_BUFFER);var a=n.morphAttributes;for(var o in a)for(var s=a[o],l=0,u=s.length;l<u;l++)t.update(s[l],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){var t=a.get(e);if(t){var n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return a.get(e)}}}function Ar(e,t,n,i){var r,a,o,s=i.isWebGL2;this.setMode=function(e){r=e},this.setIndex=function(e){a=e.type,o=e.bytesPerElement},this.render=function(t,i){e.drawElements(r,i,a,t*o),n.update(i,r,1)},this.renderInstances=function(i,l,u){if(0!==u){var c,h;if(s)c=e,h="drawElementsInstanced";else if(h="drawElementsInstancedANGLE",null===(c=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[h](r,l,a,i*o,u),n.update(l,r,u)}},this.renderMultiDraw=function(e,i,s){if(0!==s){var l=t.get("WEBGL_multi_draw");if(null===l)for(var u=0;u<s;u++)this.render(e[u]/o,i[u]);else{l.multiDrawElementsWEBGL(r,i,0,a,e,0,s);for(var c=0,h=0;h<s;h++)c+=i[h];n.update(c,r,1)}}}}function wr(e){var t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Rr(e,t){return e[0]-t[0]}function Cr(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Lr(e,t,n){for(var i={},r=new Float32Array(8),a=new WeakMap,o=new xt,s=[],l=0;l<8;l++)s[l]=[l,0];return{update:function(l,u,c){var h=l.morphTargetInfluences;if(!0===t.isWebGL2){var d=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,f=void 0!==d?d.length:0,p=a.get(u);if(void 0===p||p.count!==f){void 0!==p&&p.texture.dispose();var m=void 0!==u.morphAttributes.position,v=void 0!==u.morphAttributes.normal,g=void 0!==u.morphAttributes.color,_=u.morphAttributes.position||[],y=u.morphAttributes.normal||[],x=u.morphAttributes.color||[],M=0;!0===m&&(M=1),!0===v&&(M=2),!0===g&&(M=3);var S=u.attributes.position.count*M,E=1;S>t.maxTextureSize&&(E=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);var T=new Float32Array(S*E*4*f),b=new Et(T,S,E,f);b.type=ae,b.needsUpdate=!0;for(var A=4*M,w=0;w<f;w++)for(var R=_[w],C=y[w],L=x[w],P=S*E*4*w,U=0;U<R.count;U++){var k=U*A;!0===m&&(o.fromBufferAttribute(R,U),T[P+k+0]=o.x,T[P+k+1]=o.y,T[P+k+2]=o.z,T[P+k+3]=0),!0===v&&(o.fromBufferAttribute(C,U),T[P+k+4]=o.x,T[P+k+5]=o.y,T[P+k+6]=o.z,T[P+k+7]=0),!0===g&&(o.fromBufferAttribute(L,U),T[P+k+8]=o.x,T[P+k+9]=o.y,T[P+k+10]=o.z,T[P+k+11]=4===L.itemSize?o.w:1)}p={count:f,texture:b,size:new $e(S,E)},a.set(u,p),u.addEventListener("dispose",(function e(){b.dispose(),a.delete(u),u.removeEventListener("dispose",e)}))}for(var I=0,N=0;N<h.length;N++)I+=h[N];var D=u.morphTargetsRelative?1:1-I;c.getUniforms().setValue(e,"morphTargetBaseInfluence",D),c.getUniforms().setValue(e,"morphTargetInfluences",h),c.getUniforms().setValue(e,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",p.size)}else{var O=void 0===h?0:h.length,F=i[u.id];if(void 0===F||F.length!==O){F=[];for(var B=0;B<O;B++)F[B]=[B,0];i[u.id]=F}for(var z=0;z<O;z++){var H=F[z];H[0]=z,H[1]=h[z]}F.sort(Cr);for(var G=0;G<8;G++)G<O&&F[G][1]?(s[G][0]=F[G][0],s[G][1]=F[G][1]):(s[G][0]=Number.MAX_SAFE_INTEGER,s[G][1]=0);s.sort(Rr);for(var V=u.morphAttributes.position,W=u.morphAttributes.normal,X=0,j=0;j<8;j++){var q=s[j],Y=q[0],K=q[1];Y!==Number.MAX_SAFE_INTEGER&&K?(V&&u.getAttribute("morphTarget"+j)!==V[Y]&&u.setAttribute("morphTarget"+j,V[Y]),W&&u.getAttribute("morphNormal"+j)!==W[Y]&&u.setAttribute("morphNormal"+j,W[Y]),r[j]=K,X+=K):(V&&!0===u.hasAttribute("morphTarget"+j)&&u.deleteAttribute("morphTarget"+j),W&&!0===u.hasAttribute("morphNormal"+j)&&u.deleteAttribute("morphNormal"+j),r[j]=0)}var Z=u.morphTargetsRelative?1:1-X;c.getUniforms().setValue(e,"morphTargetBaseInfluence",Z),c.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function Pr(e,t,n,i){var r=new WeakMap;function a(e){var t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(o){var s=i.render.frame,l=o.geometry,u=t.get(o,l);if(r.get(u)!==s&&(t.update(u),r.set(u,s)),o.isInstancedMesh&&(!1===o.hasEventListener("dispose",a)&&o.addEventListener("dispose",a),r.get(o)!==s&&(n.update(o.instanceMatrix,e.ARRAY_BUFFER),null!==o.instanceColor&&n.update(o.instanceColor,e.ARRAY_BUFFER),r.set(o,s))),o.isSkinnedMesh){var c=o.skeleton;r.get(c)!==s&&(c.update(),r.set(c,s))}return u},dispose:function(){r=new WeakMap}}}var Ur=function(t){f(i,t);var n=m(i);function i(e,t,r,a,o,s,l,u,c,h){var d;if(y(this,i),(h=void 0!==h?h:ue)!==ue&&h!==ce)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");return void 0===r&&h===ue&&(r=re),void 0===r&&h===ce&&(r=se),(d=n.call(this,null,a,o,s,l,u,h,r,c)).isDepthTexture=!0,d.image={width:e,height:t},d.magFilter=void 0!==l?l:K,d.minFilter=void 0!==u?u:K,d.flipY=!1,d.generateMipmaps=!1,d.compareFunction=null,d}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.compareFunction=t.compareFunction,this}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);return null!==this.compareFunction&&(n.compareFunction=this.compareFunction),n}}]),i}(yt),kr=new yt,Ir=new Ur(1,1);Ir.compareFunction=515;var Nr=new Et,Dr=new Tt,Or=new Bi,Fr=[],Br=[],zr=new Float32Array(16),Hr=new Float32Array(9),Gr=new Float32Array(4);function Vr(e,t,n){var i=e[0];if(i<=0||i>0)return e;var r=t*n,a=Fr[r];if(void 0===a&&(a=new Float32Array(r),Fr[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function Wr(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Xr(e,t){for(var n=0,i=t.length;n<i;n++)e[n]=t[n]}function jr(e,t){var n=Br[t];void 0===n&&(n=new Int32Array(t),Br[t]=n);for(var i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function qr(e,t){var n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Yr(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Wr(n,t))return;e.uniform2fv(this.addr,t),Xr(n,t)}}function Kr(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Wr(n,t))return;e.uniform3fv(this.addr,t),Xr(n,t)}}function Zr(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Wr(n,t))return;e.uniform4fv(this.addr,t),Xr(n,t)}}function Jr(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Wr(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Xr(n,t)}else{if(Wr(n,i))return;Gr.set(i),e.uniformMatrix2fv(this.addr,!1,Gr),Xr(n,i)}}function Qr(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Wr(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Xr(n,t)}else{if(Wr(n,i))return;Hr.set(i),e.uniformMatrix3fv(this.addr,!1,Hr),Xr(n,i)}}function $r(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Wr(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Xr(n,t)}else{if(Wr(n,i))return;zr.set(i),e.uniformMatrix4fv(this.addr,!1,zr),Xr(n,i)}}function ea(e,t){var n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function ta(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Wr(n,t))return;e.uniform2iv(this.addr,t),Xr(n,t)}}function na(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Wr(n,t))return;e.uniform3iv(this.addr,t),Xr(n,t)}}function ia(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Wr(n,t))return;e.uniform4iv(this.addr,t),Xr(n,t)}}function ra(e,t){var n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function aa(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Wr(n,t))return;e.uniform2uiv(this.addr,t),Xr(n,t)}}function oa(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Wr(n,t))return;e.uniform3uiv(this.addr,t),Xr(n,t)}}function sa(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Wr(n,t))return;e.uniform4uiv(this.addr,t),Xr(n,t)}}function la(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r);var a=this.type===e.SAMPLER_2D_SHADOW?Ir:kr;n.setTexture2D(t||a,r)}function ua(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Dr,r)}function ca(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||Or,r)}function ha(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||Nr,r)}function da(e,t){e.uniform1fv(this.addr,t)}function fa(e,t){var n=Vr(t,this.size,2);e.uniform2fv(this.addr,n)}function pa(e,t){var n=Vr(t,this.size,3);e.uniform3fv(this.addr,n)}function ma(e,t){var n=Vr(t,this.size,4);e.uniform4fv(this.addr,n)}function va(e,t){var n=Vr(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function ga(e,t){var n=Vr(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function _a(e,t){var n=Vr(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function ya(e,t){e.uniform1iv(this.addr,t)}function xa(e,t){e.uniform2iv(this.addr,t)}function Ma(e,t){e.uniform3iv(this.addr,t)}function Sa(e,t){e.uniform4iv(this.addr,t)}function Ea(e,t){e.uniform1uiv(this.addr,t)}function Ta(e,t){e.uniform2uiv(this.addr,t)}function ba(e,t){e.uniform3uiv(this.addr,t)}function Aa(e,t){e.uniform4uiv(this.addr,t)}function wa(e,t,n){var i=this.cache,r=t.length,a=jr(n,r);Wr(i,a)||(e.uniform1iv(this.addr,a),Xr(i,a));for(var o=0;o!==r;++o)n.setTexture2D(t[o]||kr,a[o])}function Ra(e,t,n){var i=this.cache,r=t.length,a=jr(n,r);Wr(i,a)||(e.uniform1iv(this.addr,a),Xr(i,a));for(var o=0;o!==r;++o)n.setTexture3D(t[o]||Dr,a[o])}function Ca(e,t,n){var i=this.cache,r=t.length,a=jr(n,r);Wr(i,a)||(e.uniform1iv(this.addr,a),Xr(i,a));for(var o=0;o!==r;++o)n.setTextureCube(t[o]||Or,a[o])}function La(e,t,n){var i=this.cache,r=t.length,a=jr(n,r);Wr(i,a)||(e.uniform1iv(this.addr,a),Xr(i,a));for(var o=0;o!==r;++o)n.setTexture2DArray(t[o]||Nr,a[o])}var Pa=M((function e(t,n,i){y(this,e),this.id=t,this.addr=i,this.cache=[],this.type=n.type,this.setValue=function(e){switch(e){case 5126:return qr;case 35664:return Yr;case 35665:return Kr;case 35666:return Zr;case 35674:return Jr;case 35675:return Qr;case 35676:return $r;case 5124:case 35670:return ea;case 35667:case 35671:return ta;case 35668:case 35672:return na;case 35669:case 35673:return ia;case 5125:return ra;case 36294:return aa;case 36295:return oa;case 36296:return sa;case 35678:case 36198:case 36298:case 36306:case 35682:return la;case 35679:case 36299:case 36307:return ua;case 35680:case 36300:case 36308:case 36293:return ca;case 36289:case 36303:case 36311:case 36292:return ha}}(n.type)})),Ua=M((function e(t,n,i){y(this,e),this.id=t,this.addr=i,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=function(e){switch(e){case 5126:return da;case 35664:return fa;case 35665:return pa;case 35666:return ma;case 35674:return va;case 35675:return ga;case 35676:return _a;case 5124:case 35670:return ya;case 35667:case 35671:return xa;case 35668:case 35672:return Ma;case 35669:case 35673:return Sa;case 5125:return Ea;case 36294:return Ta;case 36295:return ba;case 36296:return Aa;case 35678:case 36198:case 36298:case 36306:case 35682:return wa;case 35679:case 36299:case 36307:return Ra;case 35680:case 36300:case 36308:case 36293:return Ca;case 36289:case 36303:case 36311:case 36292:return La}}(n.type)})),ka=function(){function e(t){y(this,e),this.id=t,this.seq=[],this.map={}}return M(e,[{key:"setValue",value:function(e,t,n){for(var i=this.seq,r=0,a=i.length;r!==a;++r){var o=i[r];o.setValue(e,t[o.id],n)}}}]),e}(),Ia=/(\w+)(\])?(\[|\.)?/g;function Na(e,t){e.seq.push(t),e.map[t.id]=t}function Da(e,t,n){var i=e.name,r=i.length;for(Ia.lastIndex=0;;){var a=Ia.exec(i),o=Ia.lastIndex,s=a[1],l="]"===a[2],u=a[3];if(l&&(s|=0),void 0===u||"["===u&&o+2===r){Na(n,void 0===u?new Pa(s,e,t):new Ua(s,e,t));break}var c=n.map[s];void 0===c&&Na(n,c=new ka(s)),n=c}}var Oa=function(){function e(t,n){y(this,e),this.seq=[],this.map={};for(var i=t.getProgramParameter(n,t.ACTIVE_UNIFORMS),r=0;r<i;++r){var a=t.getActiveUniform(n,r);Da(a,t.getUniformLocation(n,a.name),this)}}return M(e,[{key:"setValue",value:function(e,t,n,i){var r=this.map[t];void 0!==r&&r.setValue(e,n,i)}},{key:"setOptional",value:function(e,t,n){var i=t[n];void 0!==i&&this.setValue(e,n,i)}}],[{key:"upload",value:function(e,t,n,i){for(var r=0,a=t.length;r!==a;++r){var o=t[r],s=n[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,i)}}},{key:"seqWithValue",value:function(e,t){for(var n=[],i=0,r=e.length;i!==r;++i){var a=e[i];a.id in t&&n.push(a)}return n}}]),e}();function Fa(e,t,n){var i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var Ba=37297,za=0;function Ha(e,t,n){var i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";var a=/ERROR: 0:(\d+)/.exec(r);if(a){var o=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){for(var n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length),o=r;o<a;o++){var s=o+1;i.push("".concat(s===t?">":" "," ").concat(s,": ").concat(n[o]))}return i.join("\n")}(e.getShaderSource(t),o)}return r}function Ga(e,t){var n=function(e){var t,n=ht.getPrimaries(ht.workingColorSpace),i=ht.getPrimaries(e);switch(n===i?t="":n===Ue&&i===Pe?t="LinearDisplayP3ToLinearSRGB":n===Pe&&i===Ue&&(t="LinearSRGBToLinearDisplayP3"),e){case Ae:case Re:return[t,"LinearTransferOETF"];case be:case we:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[t,"LinearTransferOETF"]}}(t);return"vec4 ".concat(e,"( vec4 value ) { return ").concat(n[0],"( ").concat(n[1],"( value ) ); }")}function Va(e,t){var n;switch(t){case I:n="Linear";break;case N:n="Reinhard";break;case D:n="OptimizedCineon";break;case O:n="ACESFilmic";break;case B:n="AgX";break;case F:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Wa(e){return""!==e}function Xa(e,t){var n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function ja(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var qa=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ya(e){return e.replace(qa,Za)}var Ka=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Za(e,t){var n=Ji[t];if(void 0===n){var i=Ka.get(t);if(void 0===i)throw new Error("Can not resolve #include <"+t+">");n=Ji[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i)}return Ya(n)}var Ja=/#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 Qa(e){return e.replace(Ja,$a)}function $a(e,t,n,i){for(var r="",a=parseInt(t);a<parseInt(n);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function eo(e){var t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function to(e,t,n,i){var r,a,o=e.getContext(),s=n.defines,l=n.vertexShader,u=n.fragmentShader,c=function(e){var t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===T?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===b?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===A&&(t="SHADOWMAP_TYPE_VSM"),t}(n),h=function(e){var t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case H:case G:t="ENVMAP_TYPE_CUBE";break;case X:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),d=function(e){var t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===G&&(t="ENVMAP_MODE_REFRACTION");return t}(n),f=function(e){var t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case L:t="ENVMAP_BLENDING_MULTIPLY";break;case P:t="ENVMAP_BLENDING_MIX";break;case U:t="ENVMAP_BLENDING_ADD"}return t}(n),p=function(e){var t=e.envMapCubeUVHeight;if(null===t)return null;var n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),m=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Wa).join("\n")}(n),v=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(Wa).join("\n")}(n),g=function(e){var t=[];for(var n in e){var i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),_=o.createProgram(),y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((r=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(Wa).join("\n")).length>0&&(r+="\n"),(a=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(Wa).join("\n")).length>0&&(a+="\n")):(r=[eo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Wa).join("\n"),a=[m,eo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==k?"#define TONE_MAPPING":"",n.toneMapping!==k?Ji.tonemapping_pars_fragment:"",n.toneMapping!==k?Va("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ji.colorspace_pars_fragment,Ga("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Wa).join("\n")),l=ja(l=Xa(l=Ya(l),n),n),u=ja(u=Xa(u=Ya(u),n),n),l=Qa(l),u=Qa(u),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",r=[v,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,a=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===Ne?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Ne?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+a);var x,M,S=y+r+l,E=y+a+u,w=Fa(o,o.VERTEX_SHADER,S),R=Fa(o,o.FRAGMENT_SHADER,E);function C(t){if(e.debug.checkShaderErrors){var n=o.getProgramInfoLog(_).trim(),i=o.getShaderInfoLog(w).trim(),s=o.getShaderInfoLog(R).trim(),l=!0,u=!0;if(!1===o.getProgramParameter(_,o.LINK_STATUS))if(l=!1,"function"===typeof e.debug.onShaderError)e.debug.onShaderError(o,_,w,R);else{var c=Ha(o,w,"vertex"),h=Ha(o,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(_,o.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+c+"\n"+h)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(u=!1);u&&(t.diagnostics={runnable:l,programLog:n,vertexShader:{log:i,prefix:r},fragmentShader:{log:s,prefix:a}})}o.deleteShader(w),o.deleteShader(R),x=new Oa(o,_),M=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var a=e.getActiveAttrib(t,r),o=a.name,s=1;a.type===e.FLOAT_MAT2&&(s=2),a.type===e.FLOAT_MAT3&&(s=3),a.type===e.FLOAT_MAT4&&(s=4),n[o]={type:a.type,location:e.getAttribLocation(t,o),locationSize:s}}return n}(o,_)}o.attachShader(_,w),o.attachShader(_,R),void 0!==n.index0AttributeName?o.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(_,0,"position"),o.linkProgram(_),this.getUniforms=function(){return void 0===x&&C(this),x},this.getAttributes=function(){return void 0===M&&C(this),M};var I=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===I&&(I=o.getProgramParameter(_,Ba)),I},this.destroy=function(){i.releaseStatesOfProgram(this),o.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=za++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=R,this}var no=0,io=function(){function e(){y(this,e),this.shaderCache=new Map,this.materialCache=new Map}return M(e,[{key:"update",value:function(e){var t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}},{key:"remove",value:function(e){var t,n=l(this.materialCache.get(e));try{for(n.s();!(t=n.n()).done;){var i=t.value;i.usedTimes--,0===i.usedTimes&&this.shaderCache.delete(i.code)}}catch(r){n.e(r)}finally{n.f()}return this.materialCache.delete(e),this}},{key:"getVertexShaderID",value:function(e){return this._getShaderStage(e.vertexShader).id}},{key:"getFragmentShaderID",value:function(e){return this._getShaderStage(e.fragmentShader).id}},{key:"dispose",value:function(){this.shaderCache.clear(),this.materialCache.clear()}},{key:"_getShaderCacheForMaterial",value:function(e){var t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}},{key:"_getShaderStage",value:function(e){var t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new ro(e),t.set(e,n)),n}}]),e}(),ro=M((function e(t){y(this,e),this.id=no++,this.code=t,this.usedTimes=0}));function ao(e,t,n,i,r,a,o){var s=new pn,l=new io,u=[],c=r.isWebGL2,h=r.logarithmicDepthBuffer,d=r.vertexTextures,f=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return 0===e?"uv":"uv".concat(e)}return{getParameters:function(a,s,u,v,g){var _=v.fog,y=g.geometry,x=a.isMeshStandardMaterial?v.environment:null,M=(a.isMeshStandardMaterial?n:t).get(a.envMap||x),S=M&&M.mapping===X?M.image.height:null,E=p[a.type];null!==a.precision&&(f=r.getMaxPrecision(a.precision))!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead.");var T,b,A,w,C=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,L=void 0!==C?C.length:0,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),E){var U=$i[E];T=U.vertexShader,b=U.fragmentShader}else T=a.vertexShader,b=a.fragmentShader,l.update(a),A=l.getVertexShaderID(a),w=l.getFragmentShaderID(a);var I=e.getRenderTarget(),N=!0===g.isInstancedMesh,D=!0===g.isBatchedMesh,O=!!a.map,F=!!a.matcap,B=!!M,z=!!a.aoMap,H=!!a.lightMap,G=!!a.bumpMap,V=!!a.normalMap,W=!!a.displacementMap,j=!!a.emissiveMap,q=!!a.metalnessMap,Y=!!a.roughnessMap,K=a.anisotropy>0,Z=a.clearcoat>0,J=a.iridescence>0,Q=a.sheen>0,$=a.transmission>0,ee=K&&!!a.anisotropyMap,te=Z&&!!a.clearcoatMap,ne=Z&&!!a.clearcoatNormalMap,ie=Z&&!!a.clearcoatRoughnessMap,re=J&&!!a.iridescenceMap,ae=J&&!!a.iridescenceThicknessMap,oe=Q&&!!a.sheenColorMap,se=Q&&!!a.sheenRoughnessMap,le=!!a.specularMap,ue=!!a.specularColorMap,ce=!!a.specularIntensityMap,he=$&&!!a.transmissionMap,de=$&&!!a.thicknessMap,fe=!!a.gradientMap,pe=!!a.alphaMap,me=a.alphaTest>0,ve=!!a.alphaHash,ge=!!a.extensions,_e=!!y.attributes.uv1,ye=!!y.attributes.uv2,xe=!!y.attributes.uv3,Me=k;return a.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(Me=e.toneMapping)),{isWebGL2:c,shaderID:E,shaderType:a.type,shaderName:a.name,vertexShader:T,fragmentShader:b,defines:a.defines,customVertexShaderID:A,customFragmentShaderID:w,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:D,instancing:N,instancingColor:N&&null!==g.instanceColor,supportsVertexTextures:d,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Ae,map:O,matcap:F,envMap:B,envMapMode:B&&M.mapping,envMapCubeUVHeight:S,aoMap:z,lightMap:H,bumpMap:G,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&1===a.normalMapType,normalMapTangentSpace:V&&0===a.normalMapType,metalnessMap:q,roughnessMap:Y,anisotropy:K,anisotropyMap:ee,clearcoat:Z,clearcoatMap:te,clearcoatNormalMap:ne,clearcoatRoughnessMap:ie,iridescence:J,iridescenceMap:re,iridescenceThicknessMap:ae,sheen:Q,sheenColorMap:oe,sheenRoughnessMap:se,specularMap:le,specularColorMap:ue,specularIntensityMap:ce,transmission:$,transmissionMap:he,thicknessMap:de,gradientMap:fe,opaque:!1===a.transparent&&1===a.blending,alphaMap:pe,alphaTest:me,alphaHash:ve,combine:a.combine,mapUv:O&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:H&&m(a.lightMap.channel),bumpMapUv:G&&m(a.bumpMap.channel),normalMapUv:V&&m(a.normalMap.channel),displacementMapUv:W&&m(a.displacementMap.channel),emissiveMapUv:j&&m(a.emissiveMap.channel),metalnessMapUv:q&&m(a.metalnessMap.channel),roughnessMapUv:Y&&m(a.roughnessMap.channel),anisotropyMapUv:ee&&m(a.anisotropyMap.channel),clearcoatMapUv:te&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:ne&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:le&&m(a.specularMap.channel),specularColorMapUv:ue&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:he&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:pe&&m(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(V||K),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUv1s:_e,vertexUv2s:ye,vertexUv3s:xe,pointsUvs:!0===g.isPoints&&!!y.attributes.uv&&(O||pe),fog:!!_,useFog:!0===a.fog,fogExp2:_&&_.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:L,morphTextureStride:P,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:Me,useLegacyLights:e._useLegacyLights,decodeVideoTexture:O&&!0===a.map.isVideoTexture&&ht.getTransfer(a.map.colorSpace)===Le,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:a.side===R,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ge&&!0===a.extensions.derivatives,extensionFragDepth:ge&&!0===a.extensions.fragDepth,extensionDrawBuffers:ge&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ge&&!0===a.extensions.shaderTextureLOD,extensionClipCullDistance:ge&&a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:c||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){var n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(var i in t.defines)n.push(i),n.push(t.defines[i]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.matcap&&s.enable(4);t.envMap&&s.enable(5);t.normalMapObjectSpace&&s.enable(6);t.normalMapTangentSpace&&s.enable(7);t.clearcoat&&s.enable(8);t.iridescence&&s.enable(9);t.alphaTest&&s.enable(10);t.vertexColors&&s.enable(11);t.vertexAlphas&&s.enable(12);t.vertexUv1s&&s.enable(13);t.vertexUv2s&&s.enable(14);t.vertexUv3s&&s.enable(15);t.vertexTangents&&s.enable(16);t.anisotropy&&s.enable(17);t.alphaHash&&s.enable(18);t.batching&&s.enable(19);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.useLegacyLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.transmission&&s.enable(15);t.sheen&&s.enable(16);t.opaque&&s.enable(17);t.pointsUvs&&s.enable(18);t.decodeVideoTexture&&s.enable(19);e.push(s.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){var t,n=p[e.type];if(n){var i=$i[n];t=ki.clone(i.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){for(var i,r=0,o=u.length;r<o;r++){var s=u[r];if(s.cacheKey===n){++(i=s).usedTimes;break}}return void 0===i&&(i=new to(e,n,t,a),u.push(i)),i},releaseProgram:function(e){if(0===--e.usedTimes){var t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:u,dispose:function(){l.dispose()}}}function oo(){var e=new WeakMap;return{get:function(t){var n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function so(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function lo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function uo(){var e=[],t=0,n=[],i=[],r=[];function a(n,i,r,a,o,s){var l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=o,l.group=s),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,o,s,l,u){var c=a(e,t,o,s,l,u);o.transmission>0?i.push(c):!0===o.transparent?r.push(c):n.push(c)},unshift:function(e,t,o,s,l,u){var c=a(e,t,o,s,l,u);o.transmission>0?i.unshift(c):!0===o.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(var n=t,i=e.length;n<i;n++){var r=e[n];if(null===r.id)break;r.id=null,r.object=null,r.geometry=null,r.material=null,r.group=null}},sort:function(e,t){n.length>1&&n.sort(e||so),i.length>1&&i.sort(t||lo),r.length>1&&r.sort(t||lo)}}}function co(){var e=new WeakMap;return{get:function(t,n){var i,r=e.get(t);return void 0===r?(i=new uo,e.set(t,[i])):n>=r.length?(i=new uo,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function ho(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new At,color:new Xn};break;case"SpotLight":n={position:new At,direction:new At,color:new Xn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new At,color:new Xn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new At,skyColor:new Xn,groundColor:new Xn};break;case"RectAreaLight":n={color:new Xn,position:new At,halfWidth:new At,halfHeight:new At}}return e[t.id]=n,n}}}var fo=0;function po(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function mo(e,t){for(var n=new ho,i=function(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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},a=0;a<9;a++)r.probe.push(new At);var o=new At,s=new nn,l=new nn;return{setup:function(a,o){for(var s=0,l=0,u=0,c=0;c<9;c++)r.probe[c].set(0,0,0);var h=0,d=0,f=0,p=0,m=0,v=0,g=0,_=0,y=0,x=0,M=0;a.sort(po);for(var S=!0===o?Math.PI:1,E=0,T=a.length;E<T;E++){var b=a[E],A=b.color,w=b.intensity,R=b.distance,C=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)s+=A.r*w*S,l+=A.g*w*S,u+=A.b*w*S;else if(b.isLightProbe){for(var L=0;L<9;L++)r.probe[L].addScaledVector(b.sh.coefficients[L],w);M++}else if(b.isDirectionalLight){var P=n.get(b);if(P.color.copy(b.color).multiplyScalar(b.intensity*S),b.castShadow){var U=b.shadow,k=i.get(b);k.shadowBias=U.bias,k.shadowNormalBias=U.normalBias,k.shadowRadius=U.radius,k.shadowMapSize=U.mapSize,r.directionalShadow[h]=k,r.directionalShadowMap[h]=C,r.directionalShadowMatrix[h]=b.shadow.matrix,v++}r.directional[h]=P,h++}else if(b.isSpotLight){var I=n.get(b);I.position.setFromMatrixPosition(b.matrixWorld),I.color.copy(A).multiplyScalar(w*S),I.distance=R,I.coneCos=Math.cos(b.angle),I.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),I.decay=b.decay,r.spot[f]=I;var N=b.shadow;if(b.map&&(r.spotLightMap[y]=b.map,y++,N.updateMatrices(b),b.castShadow&&x++),r.spotLightMatrix[f]=N.matrix,b.castShadow){var D=i.get(b);D.shadowBias=N.bias,D.shadowNormalBias=N.normalBias,D.shadowRadius=N.radius,D.shadowMapSize=N.mapSize,r.spotShadow[f]=D,r.spotShadowMap[f]=C,_++}f++}else if(b.isRectAreaLight){var O=n.get(b);O.color.copy(A).multiplyScalar(w),O.halfWidth.set(.5*b.width,0,0),O.halfHeight.set(0,.5*b.height,0),r.rectArea[p]=O,p++}else if(b.isPointLight){var F=n.get(b);if(F.color.copy(b.color).multiplyScalar(b.intensity*S),F.distance=b.distance,F.decay=b.decay,b.castShadow){var B=b.shadow,z=i.get(b);z.shadowBias=B.bias,z.shadowNormalBias=B.normalBias,z.shadowRadius=B.radius,z.shadowMapSize=B.mapSize,z.shadowCameraNear=B.camera.near,z.shadowCameraFar=B.camera.far,r.pointShadow[d]=z,r.pointShadowMap[d]=C,r.pointShadowMatrix[d]=b.shadow.matrix,g++}r.point[d]=F,d++}else if(b.isHemisphereLight){var H=n.get(b);H.skyColor.copy(b.color).multiplyScalar(w*S),H.groundColor.copy(b.groundColor).multiplyScalar(w*S),r.hemi[m]=H,m++}}p>0&&(t.isWebGL2?!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Qi.LTC_FLOAT_1,r.rectAreaLTC2=Qi.LTC_FLOAT_2):(r.rectAreaLTC1=Qi.LTC_HALF_1,r.rectAreaLTC2=Qi.LTC_HALF_2):!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Qi.LTC_FLOAT_1,r.rectAreaLTC2=Qi.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Qi.LTC_HALF_1,r.rectAreaLTC2=Qi.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=s,r.ambient[1]=l,r.ambient[2]=u;var G=r.hash;G.directionalLength===h&&G.pointLength===d&&G.spotLength===f&&G.rectAreaLength===p&&G.hemiLength===m&&G.numDirectionalShadows===v&&G.numPointShadows===g&&G.numSpotShadows===_&&G.numSpotMaps===y&&G.numLightProbes===M||(r.directional.length=h,r.spot.length=f,r.rectArea.length=p,r.point.length=d,r.hemi.length=m,r.directionalShadow.length=v,r.directionalShadowMap.length=v,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=v,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=_+y-x,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=x,r.numLightProbes=M,G.directionalLength=h,G.pointLength=d,G.spotLength=f,G.rectAreaLength=p,G.hemiLength=m,G.numDirectionalShadows=v,G.numPointShadows=g,G.numSpotShadows=_,G.numSpotMaps=y,G.numLightProbes=M,r.version=fo++)},setupView:function(e,t){for(var n=0,i=0,a=0,u=0,c=0,h=t.matrixWorldInverse,d=0,f=e.length;d<f;d++){var p=e[d];if(p.isDirectionalLight){var m=r.directional[n];m.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),m.direction.sub(o),m.direction.transformDirection(h),n++}else if(p.isSpotLight){var v=r.spot[a];v.position.setFromMatrixPosition(p.matrixWorld),v.position.applyMatrix4(h),v.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),v.direction.sub(o),v.direction.transformDirection(h),a++}else if(p.isRectAreaLight){var g=r.rectArea[u];g.position.setFromMatrixPosition(p.matrixWorld),g.position.applyMatrix4(h),l.identity(),s.copy(p.matrixWorld),s.premultiply(h),l.extractRotation(s),g.halfWidth.set(.5*p.width,0,0),g.halfHeight.set(0,.5*p.height,0),g.halfWidth.applyMatrix4(l),g.halfHeight.applyMatrix4(l),u++}else if(p.isPointLight){var _=r.point[i];_.position.setFromMatrixPosition(p.matrixWorld),_.position.applyMatrix4(h),i++}else if(p.isHemisphereLight){var y=r.hemi[c];y.direction.setFromMatrixPosition(p.matrixWorld),y.direction.transformDirection(h),c++}}},state:r}}function vo(e,t){var n=new mo(e,t),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(e){n.setup(i,e)},setupLightsView:function(e){n.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){r.push(e)}}}function go(e,t){var n=new WeakMap;return{get:function(i){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=n.get(i);return void 0===o?(r=new vo(e,t),n.set(i,[r])):a>=o.length?(r=new vo(e,t),o.push(r)):r=o[a],r},dispose:function(){n=new WeakMap}}}var _o=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isMeshDepthMaterial=!0,t.type="MeshDepthMaterial",t.depthPacking=3200,t.map=null,t.alphaMap=null,t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.wireframe=!1,t.wireframeLinewidth=1,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}]),i}(Yn),yo=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isMeshDistanceMaterial=!0,t.type="MeshDistanceMaterial",t.map=null,t.alphaMap=null,t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}]),i}(Yn);function xo(e,t,n){var i,r=new qi,a=new $e,o=new $e,s=new xt,l=new _o({depthPacking:3201}),u=new yo,c={},h=n.maxTextureSize,d=(g(i={},w,R),g(i,R,w),g(i,2,2),i),f=new Ii({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=f.clone();p.defines.HORIZONTAL_PASS=1;var m=new ui;m.setAttribute("position",new Qn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var v=new wi(m,f),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=T;var y=this.type;function x(n,i){var r=t.update(v);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new St(a.x,a.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,f,v,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,p,v,null)}function M(t,n,i,r){var a=null,o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===i.isPointLight?u:l,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){var s=a.uuid,h=n.uuid,f=c[s];void 0===f&&(f={},c[s]=f);var p=f[h];void 0===p&&(p=a.clone(),f[h]=p,n.addEventListener("dispose",E)),a=p}(a.visible=n.visible,a.wireframe=n.wireframe,a.side=r===A?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial)&&(e.properties.get(a).light=i);return a}function S(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===A)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var l=t.update(n),u=n.material;if(Array.isArray(u))for(var c=l.groups,h=0,d=c.length;h<d;h++){var f=c[h],p=u[f.materialIndex];if(p&&p.visible){var m=M(n,p,o,s);n.onBeforeShadow(e,n,i,a,l,m,f),e.renderBufferDirect(a,null,l,m,n,f),n.onAfterShadow(e,n,i,a,l,m,f)}}else if(u.visible){var v=M(n,u,o,s);n.onBeforeShadow(e,n,i,a,l,v,null),e.renderBufferDirect(a,null,l,v,n,null),n.onAfterShadow(e,n,i,a,l,v,null)}}for(var g=n.children,_=0,y=g.length;_<y;_++)S(g[_],i,a,o,s)}}function E(e){var t=e.target;for(var n in t.removeEventListener("dispose",E),c){var i=c[n],r=e.target.uuid;if(r in i)i[r].dispose(),delete i[r]}}this.render=function(t,n,i){if(!1!==_.enabled&&(!1!==_.autoUpdate||!1!==_.needsUpdate)&&0!==t.length){var l=e.getRenderTarget(),u=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(var f=y!==A&&this.type===A,p=y===A&&this.type!==A,m=0,v=t.length;m<v;m++){var g=t[m],M=g.shadow;if(void 0!==M){if(!1!==M.autoUpdate||!1!==M.needsUpdate){a.copy(M.mapSize);var E=M.getFrameExtents();if(a.multiply(E),o.copy(M.mapSize),(a.x>h||a.y>h)&&(a.x>h&&(o.x=Math.floor(h/E.x),a.x=o.x*E.x,M.mapSize.x=o.x),a.y>h&&(o.y=Math.floor(h/E.y),a.y=o.y*E.y,M.mapSize.y=o.y)),null===M.map||!0===f||!0===p){var T=this.type!==A?{minFilter:K,magFilter:K}:{};null!==M.map&&M.map.dispose(),M.map=new St(a.x,a.y,T),M.map.texture.name=g.name+".shadowMap",M.camera.updateProjectionMatrix()}e.setRenderTarget(M.map),e.clear();for(var b=M.getViewportCount(),w=0;w<b;w++){var R=M.getViewport(w);s.set(o.x*R.x,o.y*R.y,o.x*R.z,o.y*R.w),d.viewport(s),M.updateMatrices(g,w),r=M.getFrustum(),S(n,i,M.camera,g,this.type)}!0!==M.isPointLightShadow&&this.type===A&&x(M,i),M.needsUpdate=!1}}else console.warn("THREE.WebGLShadowMap:",g,"has no shadow.")}y=this.type,_.needsUpdate=!1,e.setRenderTarget(l,u,c)}}}function Mo(e,t,n){var i,r,a=n.isWebGL2;var o=new function(){var t=!1,n=new xt,i=null,r=new xt(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,o,s){!0===s&&(t*=o,i*=o,a*=o),n.set(t,i,a,o),!1===r.equals(n)&&(e.clearColor(t,i,a,o),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){var t=!1,n=null,i=null,r=null;return{setTest:function(t){t?q(e.DEPTH_TEST):Y(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},l=new function(){var t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,u=null;return{setTest:function(n){t||(n?q(e.STENCIL_TEST):Y(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,o){i===t&&r===n&&a===o||(e.stencilFunc(t,n,o),i=t,r=n,a=o)},setOp:function(t,n,i){o===t&&s===n&&l===i||(e.stencilOp(t,n,i),o=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,u=null}}},u=new WeakMap,c=new WeakMap,h={},d={},f=new WeakMap,p=[],m=null,v=!1,_=null,y=null,x=null,M=null,S=null,E=null,T=null,b=new Xn(0,0,0),A=0,w=!1,L=null,P=null,U=null,k=null,I=null,N=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),D=!1,O=0,F=e.getParameter(e.VERSION);-1!==F.indexOf("WebGL")?(O=parseFloat(/^WebGL (\d)/.exec(F)[1]),D=O>=1):-1!==F.indexOf("OpenGL ES")&&(O=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),D=O>=2);var B=null,z={},H=e.getParameter(e.SCISSOR_BOX),G=e.getParameter(e.VIEWPORT),V=(new xt).fromArray(H),W=(new xt).fromArray(G);function X(t,n,i,r){var o=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var l=0;l<i;l++)!a||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(n+l,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,o);return s}var j={};function q(t){!0!==h[t]&&(e.enable(t),h[t]=!0)}function Y(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}j[e.TEXTURE_2D]=X(e.TEXTURE_2D,e.TEXTURE_2D,1),j[e.TEXTURE_CUBE_MAP]=X(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),a&&(j[e.TEXTURE_2D_ARRAY]=X(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),j[e.TEXTURE_3D]=X(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),s.setClear(1),l.setClear(0),q(e.DEPTH_TEST),s.setFunc(3),$(!1),ee(1),q(e.CULL_FACE),Q(0);var K=(g(i={},C,e.FUNC_ADD),g(i,101,e.FUNC_SUBTRACT),g(i,102,e.FUNC_REVERSE_SUBTRACT),i);if(a)K[103]=e.MIN,K[104]=e.MAX;else{var Z=t.get("EXT_blend_minmax");null!==Z&&(K[103]=Z.MIN_EXT,K[104]=Z.MAX_EXT)}var J=(g(r={},200,e.ZERO),g(r,201,e.ONE),g(r,202,e.SRC_COLOR),g(r,204,e.SRC_ALPHA),g(r,210,e.SRC_ALPHA_SATURATE),g(r,208,e.DST_COLOR),g(r,206,e.DST_ALPHA),g(r,203,e.ONE_MINUS_SRC_COLOR),g(r,205,e.ONE_MINUS_SRC_ALPHA),g(r,209,e.ONE_MINUS_DST_COLOR),g(r,207,e.ONE_MINUS_DST_ALPHA),g(r,211,e.CONSTANT_COLOR),g(r,212,e.ONE_MINUS_CONSTANT_COLOR),g(r,213,e.CONSTANT_ALPHA),g(r,214,e.ONE_MINUS_CONSTANT_ALPHA),r);function Q(t,n,i,r,a,o,s,l,u,c){if(0!==t){if(!1===v&&(q(e.BLEND),v=!0),5===t)a=a||n,o=o||i,s=s||r,n===y&&a===S||(e.blendEquationSeparate(K[n],K[a]),y=n,S=a),i===x&&r===M&&o===E&&s===T||(e.blendFuncSeparate(J[i],J[r],J[o],J[s]),x=i,M=r,E=o,T=s),!1!==l.equals(b)&&u===A||(e.blendColor(l.r,l.g,l.b,u),b.copy(l),A=u),_=t,w=!1;else if(t!==_||c!==w){if(y===C&&S===C||(e.blendEquation(e.FUNC_ADD),y=C,S=C),c)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}x=null,M=null,E=null,T=null,b.set(0,0,0),A=0,_=t,w=c}}else!0===v&&(Y(e.BLEND),v=!1)}function $(t){L!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),L=t)}function ee(t){0!==t?(q(e.CULL_FACE),t!==P&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):Y(e.CULL_FACE),P=t}function te(t,n,i){t?(q(e.POLYGON_OFFSET_FILL),k===n&&I===i||(e.polygonOffset(n,i),k=n,I=i)):Y(e.POLYGON_OFFSET_FILL)}return{buffers:{color:o,depth:s,stencil:l},enable:q,disable:Y,bindFramebuffer:function(t,n){return d[t]!==n&&(e.bindFramebuffer(t,n),d[t]=n,a&&(t===e.DRAW_FRAMEBUFFER&&(d[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(d[e.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(i,r){var a=p,o=!1;if(i)if(void 0===(a=f.get(r))&&(a=[],f.set(r,a)),i.isWebGLMultipleRenderTargets){var s=i.texture;if(a.length!==s.length||a[0]!==e.COLOR_ATTACHMENT0){for(var l=0,u=s.length;l<u;l++)a[l]=e.COLOR_ATTACHMENT0+l;a.length=s.length,o=!0}}else a[0]!==e.COLOR_ATTACHMENT0&&(a[0]=e.COLOR_ATTACHMENT0,o=!0);else a[0]!==e.BACK&&(a[0]=e.BACK,o=!0);o&&(n.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(t){return m!==t&&(e.useProgram(t),m=t,!0)},setBlending:Q,setMaterial:function(t,n){2===t.side?Y(e.CULL_FACE):q(e.CULL_FACE);var i=t.side===R;n&&(i=!i),$(i),1===t.blending&&!1===t.transparent?Q(0):Q(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),o.setMask(t.colorWrite);var r=t.stencilWrite;l.setTest(r),r&&(l.setMask(t.stencilWriteMask),l.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),l.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),te(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?q(e.SAMPLE_ALPHA_TO_COVERAGE):Y(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:$,setCullFace:ee,setLineWidth:function(t){t!==U&&(D&&e.lineWidth(t),U=t)},setPolygonOffset:te,setScissorTest:function(t){t?q(e.SCISSOR_TEST):Y(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+N-1),B!==t&&(e.activeTexture(t),B=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===B?e.TEXTURE0+N-1:B);var r=z[i];void 0===r&&(r={type:void 0,texture:void 0},z[i]=r),r.type===t&&r.texture===n||(B!==i&&(e.activeTexture(i),B=i),e.bindTexture(t,n||j[t]),r.type=t,r.texture=n)},unbindTexture:function(){var t=z[B];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(t,n){var i=c.get(n);void 0===i&&(i=new WeakMap,c.set(n,i));var r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){var i=c.get(n).get(t);u.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),u.set(n,i))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(t){!1===V.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),V.copy(t))},viewport:function(t){!1===W.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),W.copy(t))},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),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===a&&(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),h={},B=null,z={},d={},f=new WeakMap,p=[],m=null,v=!1,_=null,y=null,x=null,M=null,S=null,E=null,T=null,b=new Xn(0,0,0),A=0,w=!1,L=null,P=null,U=null,k=null,I=null,V.set(0,0,e.canvas.width,e.canvas.height),W.set(0,0,e.canvas.width,e.canvas.height),o.reset(),s.reset(),l.reset()}}}function So(e,t,n,i,r,a,o){var s,l,u,c,h=r.isWebGL2,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f="undefined"!==typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m=new WeakMap,v=!1;try{v="undefined"!==typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(V){}function _(e,t){return v?new OffscreenCanvas(e,t):it("canvas")}function y(e,t,n,i){var r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?Ke:Math.floor,o=a(r*e.width),s=a(r*e.height);void 0===c&&(c=_(o,s));var l=n?_(o,s):c;return l.width=o,l.height=s,l.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function x(e){return Ye(e.width)&&Ye(e.height)}function M(e,t){return e.generateMipmaps&&t&&e.minFilter!==K&&e.minFilter!==Q}function S(t){e.generateMipmap(t)}function E(n,i,r,a){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!1===h)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}var s=i;if(i===e.RED&&(r===e.FLOAT&&(s=e.R32F),r===e.HALF_FLOAT&&(s=e.R16F),r===e.UNSIGNED_BYTE&&(s=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.R8UI),r===e.UNSIGNED_SHORT&&(s=e.R16UI),r===e.UNSIGNED_INT&&(s=e.R32UI),r===e.BYTE&&(s=e.R8I),r===e.SHORT&&(s=e.R16I),r===e.INT&&(s=e.R32I)),i===e.RG&&(r===e.FLOAT&&(s=e.RG32F),r===e.HALF_FLOAT&&(s=e.RG16F),r===e.UNSIGNED_BYTE&&(s=e.RG8)),i===e.RGBA){var l=o?Ce:ht.getTransfer(a);r===e.FLOAT&&(s=e.RGBA32F),r===e.HALF_FLOAT&&(s=e.RGBA16F),r===e.UNSIGNED_BYTE&&(s=l===Le?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}return s!==e.R16F&&s!==e.R32F&&s!==e.RG16F&&s!==e.RG32F&&s!==e.RGBA16F&&s!==e.RGBA32F||t.get("EXT_color_buffer_float"),s}function T(e,t,n){return!0===M(e,n)||e.isFramebufferTexture&&e.minFilter!==K&&e.minFilter!==Q?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(t){return t===K||t===Z||t===J?e.NEAREST:e.LINEAR}function A(e){var t=e.target;t.removeEventListener("dispose",A),function(e){var t=i.get(e);if(void 0===t.__webglInit)return;var n=e.source,r=m.get(n);if(r){var a=r[t.__cacheKey];a.usedTimes--,0===a.usedTimes&&R(e),0===Object.keys(r).length&&m.delete(n)}i.remove(e)}(t),t.isVideoTexture&&p.delete(t)}function w(t){var n=t.target;n.removeEventListener("dispose",w),function(t){var n=t.texture,r=i.get(t),a=i.get(n);void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(var s=0;s<6;s++){if(Array.isArray(r.__webglFramebuffer[s]))for(var l=0;l<r.__webglFramebuffer[s].length;l++)e.deleteFramebuffer(r.__webglFramebuffer[s][l]);else e.deleteFramebuffer(r.__webglFramebuffer[s]);r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[s])}else{if(Array.isArray(r.__webglFramebuffer))for(var u=0;u<r.__webglFramebuffer.length;u++)e.deleteFramebuffer(r.__webglFramebuffer[u]);else e.deleteFramebuffer(r.__webglFramebuffer);if(r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(var c=0;c<r.__webglColorRenderbuffer.length;c++)r.__webglColorRenderbuffer[c]&&e.deleteRenderbuffer(r.__webglColorRenderbuffer[c]);r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(var h=0,d=n.length;h<d;h++){var f=i.get(n[h]);f.__webglTexture&&(e.deleteTexture(f.__webglTexture),o.memory.textures--),i.remove(n[h])}i.remove(n),i.remove(t)}(n)}function R(t){var n=i.get(t);e.deleteTexture(n.__webglTexture);var r=t.source;delete m.get(r)[n.__cacheKey],o.memory.textures--}var C=0;function L(t,r){var a=i.get(t);if(t.isVideoTexture&&function(e){var t=o.render.frame;p.get(e)!==t&&(p.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version){var s=t.image;if(null===s)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==s.complete)return void D(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}var P=(g(s={},j,e.REPEAT),g(s,q,e.CLAMP_TO_EDGE),g(s,Y,e.MIRRORED_REPEAT),s),U=(g(l={},K,e.NEAREST),g(l,Z,e.NEAREST_MIPMAP_NEAREST),g(l,J,e.NEAREST_MIPMAP_LINEAR),g(l,Q,e.LINEAR),g(l,$,e.LINEAR_MIPMAP_NEAREST),g(l,ee,e.LINEAR_MIPMAP_LINEAR),l),k=(g(u={},512,e.NEVER),g(u,519,e.ALWAYS),g(u,513,e.LESS),g(u,515,e.LEQUAL),g(u,514,e.EQUAL),g(u,518,e.GEQUAL),g(u,516,e.GREATER),g(u,517,e.NOTEQUAL),u);function I(n,a,o){if(o?(e.texParameteri(n,e.TEXTURE_WRAP_S,P[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,P[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,P[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,U[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,U[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),a.wrapS===q&&a.wrapT===q||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,b(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,b(a.minFilter)),a.minFilter!==K&&a.minFilter!==Q&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,k[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){var s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===K)return;if(a.minFilter!==J&&a.minFilter!==ee)return;if(a.type===ae&&!1===t.has("OES_texture_float_linear"))return;if(!1===h&&a.type===oe&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function N(t,n){var i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",A));var r=n.source,a=m.get(r);void 0===a&&(a={},m.set(r,a));var s=function(e){var t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(s!==t.__cacheKey){void 0===a[s]&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,i=!0),a[s].usedTimes++;var l=a[t.__cacheKey];void 0!==l&&(a[t.__cacheKey].usedTimes--,0===l.usedTimes&&R(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return i}function D(t,o,s){var l=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(l=e.TEXTURE_3D);var u=N(t,o),c=o.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);var d=i.get(c);if(c.version!==d.__version||!0===u){n.activeTexture(e.TEXTURE0+s);var f=ht.getPrimaries(ht.workingColorSpace),p=o.colorSpace===Te?null:ht.getPrimaries(o.colorSpace),m=o.colorSpace===Te||f===p?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,m);var v,g=function(e){return!h&&(e.wrapS!==q||e.wrapT!==q||e.minFilter!==K&&e.minFilter!==Q)}(o)&&!1===x(o.image),_=y(o.image,g,!1,r.maxTextureSize),b=x(_=G(o,_))||h,A=a.convert(o.format,o.colorSpace),w=a.convert(o.type),R=E(o.internalFormat,A,w,o.colorSpace,o.isVideoTexture);I(l,o,b);var C=o.mipmaps,L=h&&!0!==o.isVideoTexture&&36196!==R,P=void 0===d.__version||!0===u,U=T(o,_,b);if(o.isDepthTexture)R=e.DEPTH_COMPONENT,h?R=o.type===ae?e.DEPTH_COMPONENT32F:o.type===re?e.DEPTH_COMPONENT24:o.type===se?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:o.type===ae&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),o.format===ue&&R===e.DEPTH_COMPONENT&&o.type!==ne&&o.type!==re&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),o.type=re,w=a.convert(o.type)),o.format===ce&&R===e.DEPTH_COMPONENT&&(R=e.DEPTH_STENCIL,o.type!==se&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),o.type=se,w=a.convert(o.type))),P&&(L?n.texStorage2D(e.TEXTURE_2D,1,R,_.width,_.height):n.texImage2D(e.TEXTURE_2D,0,R,_.width,_.height,0,A,w,null));else if(o.isDataTexture)if(C.length>0&&b){L&&P&&n.texStorage2D(e.TEXTURE_2D,U,R,C[0].width,C[0].height);for(var k=0,D=C.length;k<D;k++)v=C[k],L?n.texSubImage2D(e.TEXTURE_2D,k,0,0,v.width,v.height,A,w,v.data):n.texImage2D(e.TEXTURE_2D,k,R,v.width,v.height,0,A,w,v.data);o.generateMipmaps=!1}else L?(P&&n.texStorage2D(e.TEXTURE_2D,U,R,_.width,_.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,_.width,_.height,A,w,_.data)):n.texImage2D(e.TEXTURE_2D,0,R,_.width,_.height,0,A,w,_.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){L&&P&&n.texStorage3D(e.TEXTURE_2D_ARRAY,U,R,C[0].width,C[0].height,_.depth);for(var O=0,F=C.length;O<F;O++)v=C[O],o.format!==le?null!==A?L?n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,O,0,0,0,v.width,v.height,_.depth,A,v.data,0,0):n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,O,R,v.width,v.height,_.depth,0,v.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?n.texSubImage3D(e.TEXTURE_2D_ARRAY,O,0,0,0,v.width,v.height,_.depth,A,w,v.data):n.texImage3D(e.TEXTURE_2D_ARRAY,O,R,v.width,v.height,_.depth,0,A,w,v.data)}else{L&&P&&n.texStorage2D(e.TEXTURE_2D,U,R,C[0].width,C[0].height);for(var B=0,z=C.length;B<z;B++)v=C[B],o.format!==le?null!==A?L?n.compressedTexSubImage2D(e.TEXTURE_2D,B,0,0,v.width,v.height,A,v.data):n.compressedTexImage2D(e.TEXTURE_2D,B,R,v.width,v.height,0,v.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?n.texSubImage2D(e.TEXTURE_2D,B,0,0,v.width,v.height,A,w,v.data):n.texImage2D(e.TEXTURE_2D,B,R,v.width,v.height,0,A,w,v.data)}else if(o.isDataArrayTexture)L?(P&&n.texStorage3D(e.TEXTURE_2D_ARRAY,U,R,_.width,_.height,_.depth),n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,_.width,_.height,_.depth,A,w,_.data)):n.texImage3D(e.TEXTURE_2D_ARRAY,0,R,_.width,_.height,_.depth,0,A,w,_.data);else if(o.isData3DTexture)L?(P&&n.texStorage3D(e.TEXTURE_3D,U,R,_.width,_.height,_.depth),n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,_.width,_.height,_.depth,A,w,_.data)):n.texImage3D(e.TEXTURE_3D,0,R,_.width,_.height,_.depth,0,A,w,_.data);else if(o.isFramebufferTexture){if(P)if(L)n.texStorage2D(e.TEXTURE_2D,U,R,_.width,_.height);else for(var H=_.width,V=_.height,W=0;W<U;W++)n.texImage2D(e.TEXTURE_2D,W,R,H,V,0,A,w,null),H>>=1,V>>=1}else if(C.length>0&&b){L&&P&&n.texStorage2D(e.TEXTURE_2D,U,R,C[0].width,C[0].height);for(var X=0,j=C.length;X<j;X++)v=C[X],L?n.texSubImage2D(e.TEXTURE_2D,X,0,0,A,w,v):n.texImage2D(e.TEXTURE_2D,X,R,A,w,v);o.generateMipmaps=!1}else L?(P&&n.texStorage2D(e.TEXTURE_2D,U,R,_.width,_.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,A,w,_)):n.texImage2D(e.TEXTURE_2D,0,R,A,w,_);M(o,b)&&S(l),d.__version=c.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function O(t,r,o,s,l,u){var c=a.convert(o.format,o.colorSpace),h=a.convert(o.type),f=E(o.internalFormat,c,h,o.colorSpace);if(!i.get(r).__hasExternalTextures){var p=Math.max(1,r.width>>u),m=Math.max(1,r.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,f,p,m,r.depth,0,c,h,null):n.texImage2D(l,u,f,p,m,0,c,h,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),H(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,l,i.get(o).__webglTexture,0,z(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,i.get(o).__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){var r=!0===h?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(i||H(n)){var o=n.depthTexture;o&&o.isDepthTexture&&(o.type===ae?r=e.DEPTH_COMPONENT32F:o.type===re&&(r=e.DEPTH_COMPONENT24));var s=z(n);H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,s,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,s,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){var l=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,l,e.DEPTH24_STENCIL8,n.width,n.height):H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,l,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else for(var u=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture],c=0;c<u.length;c++){var f=u[c],p=a.convert(f.format,f.colorSpace),m=a.convert(f.type),v=E(f.internalFormat,p,m,f.colorSpace),g=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,g,v,n.width,n.height):H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,g,v,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,v,n.width,n.height)}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t){var r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__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),L(r.depthTexture,0);var a=i.get(r.depthTexture).__webglTexture,o=z(r);if(r.depthTexture.format===ue)H(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ce)throw new Error("Unknown depthTexture format");H(r)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=e.createRenderbuffer(),F(r.__webglDepthbuffer[o],t,!1)}else n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),F(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(e){return Math.min(r.maxSamples,e.samples)}function H(e){var n=i.get(e);return h&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){var i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===De||i!==Ae&&i!==Te&&(ht.getTransfer(i)===Le?!1===h?!0===t.has("EXT_sRGB")&&r===le?(e.format=De,e.minFilter=Q,e.generateMipmaps=!1):n=pt.sRGBToLinear(n):r===le&&a===te||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){var e=C;return e>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=L,this.setTexture2DArray=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?D(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?D(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,o){var s=i.get(t);t.version>0&&s.__version!==t.version?function(t,o,s){if(6!==o.image.length)return;var l=N(t,o),u=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);var c=i.get(u);if(u.version!==c.__version||!0===l){n.activeTexture(e.TEXTURE0+s);var d=ht.getPrimaries(ht.workingColorSpace),f=o.colorSpace===Te?null:ht.getPrimaries(o.colorSpace),p=o.colorSpace===Te||d===f?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);for(var m=o.isCompressedTexture||o.image[0].isCompressedTexture,v=o.image[0]&&o.image[0].isDataTexture,g=[],_=0;_<6;_++)g[_]=m||v?v?o.image[_].image:o.image[_]:y(o.image[_],!1,!0,r.maxCubemapSize),g[_]=G(o,g[_]);var b,A=g[0],w=x(A)||h,R=a.convert(o.format,o.colorSpace),C=a.convert(o.type),L=E(o.internalFormat,R,C,o.colorSpace),P=h&&!0!==o.isVideoTexture,U=void 0===c.__version||!0===l,k=T(o,A,w);if(I(e.TEXTURE_CUBE_MAP,o,w),m){P&&U&&n.texStorage2D(e.TEXTURE_CUBE_MAP,k,L,A.width,A.height);for(var D=0;D<6;D++){b=g[D].mipmaps;for(var O=0;O<b.length;O++){var F=b[O];o.format!==le?null!==R?P?n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+D,O,0,0,F.width,F.height,R,F.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+D,O,L,F.width,F.height,0,F.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+D,O,0,0,F.width,F.height,R,C,F.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+D,O,L,F.width,F.height,0,R,C,F.data)}}}else{b=o.mipmaps,P&&U&&(b.length>0&&k++,n.texStorage2D(e.TEXTURE_CUBE_MAP,k,L,g[0].width,g[0].height));for(var B=0;B<6;B++)if(v){P?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,0,0,g[B].width,g[B].height,R,C,g[B].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,L,g[B].width,g[B].height,0,R,C,g[B].data);for(var z=0;z<b.length;z++){var H=b[z].image[B].image;P?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,z+1,0,0,H.width,H.height,R,C,H.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,z+1,L,H.width,H.height,0,R,C,H.data)}}else{P?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,0,0,R,C,g[B]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,L,R,C,g[B]);for(var V=0;V<b.length;V++){var W=b[V];P?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,V+1,0,0,R,C,W.image[B]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,V+1,L,R,C,W.image[B])}}}M(o,w)&&S(e.TEXTURE_CUBE_MAP),c.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}(s,t,o):n.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+o)},this.rebindTextures=function(t,n,r){var a=i.get(t);void 0!==n&&O(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&B(t)},this.setupRenderTarget=function(t){var s=t.texture,l=i.get(t),u=i.get(s);t.addEventListener("dispose",w),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=s.version,o.memory.textures++);var c=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,f=x(t)||h;if(c){l.__webglFramebuffer=[];for(var p=0;p<6;p++)if(h&&s.mipmaps&&s.mipmaps.length>0){l.__webglFramebuffer[p]=[];for(var m=0;m<s.mipmaps.length;m++)l.__webglFramebuffer[p][m]=e.createFramebuffer()}else l.__webglFramebuffer[p]=e.createFramebuffer()}else{if(h&&s.mipmaps&&s.mipmaps.length>0){l.__webglFramebuffer=[];for(var v=0;v<s.mipmaps.length;v++)l.__webglFramebuffer[v]=e.createFramebuffer()}else l.__webglFramebuffer=e.createFramebuffer();if(d)if(r.drawBuffers)for(var g=t.texture,_=0,y=g.length;_<y;_++){var T=i.get(g[_]);void 0===T.__webglTexture&&(T.__webglTexture=e.createTexture(),o.memory.textures++)}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(h&&t.samples>0&&!1===H(t)){var b=d?s:[s];l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(var A=0;A<b.length;A++){var R=b[A];l.__webglColorRenderbuffer[A]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,l.__webglColorRenderbuffer[A]);var C=a.convert(R.format,R.colorSpace),L=a.convert(R.type),P=E(R.internalFormat,C,L,R.colorSpace,!0===t.isXRRenderTarget),U=z(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,U,P,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+A,e.RENDERBUFFER,l.__webglColorRenderbuffer[A])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(l.__webglDepthRenderbuffer=e.createRenderbuffer(),F(l.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(c){n.bindTexture(e.TEXTURE_CUBE_MAP,u.__webglTexture),I(e.TEXTURE_CUBE_MAP,s,f);for(var k=0;k<6;k++)if(h&&s.mipmaps&&s.mipmaps.length>0)for(var N=0;N<s.mipmaps.length;N++)O(l.__webglFramebuffer[k][N],t,s,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+k,N);else O(l.__webglFramebuffer[k],t,s,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0);M(s,f)&&S(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(var D=t.texture,G=0,V=D.length;G<V;G++){var W=D[G],X=i.get(W);n.bindTexture(e.TEXTURE_2D,X.__webglTexture),I(e.TEXTURE_2D,W,f),O(l.__webglFramebuffer,t,W,e.COLOR_ATTACHMENT0+G,e.TEXTURE_2D,0),M(W,f)&&S(e.TEXTURE_2D)}n.unbindTexture()}else{var j=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(h?j=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(j,u.__webglTexture),I(j,s,f),h&&s.mipmaps&&s.mipmaps.length>0)for(var q=0;q<s.mipmaps.length;q++)O(l.__webglFramebuffer[q],t,s,e.COLOR_ATTACHMENT0,j,q);else O(l.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0,j,0);M(s,f)&&S(j),n.unbindTexture()}t.depthBuffer&&B(t)},this.updateRenderTargetMipmap=function(t){for(var r=x(t)||h,a=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=0,s=a.length;o<s;o++){var l=a[o];if(M(l,r)){var u=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,c=i.get(l).__webglTexture;n.bindTexture(u,c),S(u),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(h&&t.samples>0&&!1===H(t)){var r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=[],u=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(var p=0;p<r.length;p++)n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+p,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+p,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(var m=0;m<r.length;m++){l.push(e.COLOR_ATTACHMENT0+m),t.depthBuffer&&l.push(u);var v=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;if(!1===v&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),d&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[m]),!0===v&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[u]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[u])),d){var g=i.get(r[m]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,g,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),f&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,l)}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(var _=0;_<r.length;_++){n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_,e.RENDERBUFFER,c.__webglColorRenderbuffer[_]);var y=i.get(r[_]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_,e.TEXTURE_2D,y,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=O,this.useMultisampledRTT=H}function Eo(e,t,n){var i=n.isWebGL2;return{convert:function(n){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Te,o=ht.getTransfer(a);if(n===te)return e.UNSIGNED_BYTE;if(1017===n)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===n)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===n)return e.BYTE;if(1011===n)return e.SHORT;if(n===ne)return e.UNSIGNED_SHORT;if(n===ie)return e.INT;if(n===re)return e.UNSIGNED_INT;if(n===ae)return e.FLOAT;if(n===oe)return i?e.HALF_FLOAT:null!==(r=t.get("OES_texture_half_float"))?r.HALF_FLOAT_OES:null;if(1021===n)return e.ALPHA;if(n===le)return e.RGBA;if(1024===n)return e.LUMINANCE;if(1025===n)return e.LUMINANCE_ALPHA;if(n===ue)return e.DEPTH_COMPONENT;if(n===ce)return e.DEPTH_STENCIL;if(n===De)return null!==(r=t.get("EXT_sRGB"))?r.SRGB_ALPHA_EXT:null;if(1028===n)return e.RED;if(1029===n)return e.RED_INTEGER;if(1030===n)return e.RG;if(1031===n)return e.RG_INTEGER;if(1033===n)return e.RGBA_INTEGER;if(n===he||n===de||n===fe||n===pe)if(o===Le){if(null===(r=t.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(n===he)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===de)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===fe)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===pe)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(r=t.get("WEBGL_compressed_texture_s3tc")))return null;if(n===he)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===de)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===fe)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===pe)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(null===(r=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(35840===n)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===n)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===n)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===n)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===n)return null!==(r=t.get("WEBGL_compressed_texture_etc1"))?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===n||37496===n){if(null===(r=t.get("WEBGL_compressed_texture_etc")))return null;if(37492===n)return o===Le?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(37496===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(37808===n||37809===n||37810===n||37811===n||37812===n||37813===n||37814===n||37815===n||37816===n||37817===n||37818===n||37819===n||37820===n||37821===n){if(null===(r=t.get("WEBGL_compressed_texture_astc")))return null;if(37808===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return o===Le?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===me||36494===n||36495===n){if(null===(r=t.get("EXT_texture_compression_bptc")))return null;if(n===me)return o===Le?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(36494===n)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(36495===n)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===n||36284===n||36285===n||36286===n){if(null===(r=t.get("EXT_texture_compression_rgtc")))return null;if(n===me)return r.COMPRESSED_RED_RGTC1_EXT;if(36284===n)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===n)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===n)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===se?i?e.UNSIGNED_INT_24_8:null!==(r=t.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:null:void 0!==e[n]?e[n]:null}}}var To=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return y(this,n),(e=t.call(this)).isArrayCamera=!0,e.cameras=i,e}return M(n)}(Di),bo=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this)).isGroup=!0,e.type="Group",e}return M(n)}(Rn),Ao={type:"move"},wo=function(){function e(){y(this,e),this._targetRay=null,this._grip=null,this._hand=null}return M(e,[{key:"getHandSpace",value:function(){return null===this._hand&&(this._hand=new bo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}},{key:"getTargetRaySpace",value:function(){return null===this._targetRay&&(this._targetRay=new bo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new At,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new At),this._targetRay}},{key:"getGripSpace",value:function(){return null===this._grip&&(this._grip=new bo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new At,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new At),this._grip}},{key:"dispatchEvent",value:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}},{key:"connect",value:function(e){if(e&&e.hand){var t=this._hand;if(t){var n,i=l(e.hand.values());try{for(i.s();!(n=i.n()).done;){var r=n.value;this._getHandJoint(t,r)}}catch(a){i.e(a)}finally{i.f()}}}return this.dispatchEvent({type:"connected",data:e}),this}},{key:"disconnect",value:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}},{key:"update",value:function(e,t,n){var i=null,r=null,a=null,o=this._targetRay,s=this._grip,u=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(u&&e.hand){a=!0;var c,h=l(e.hand.values());try{for(h.s();!(c=h.n()).done;){var d=c.value,f=t.getJointPose(d,n),p=this._getHandJoint(u,d);null!==f&&(p.matrix.fromArray(f.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=f.radius),p.visible=null!==f}}catch(_){h.e(_)}finally{h.f()}var m=u.joints["index-finger-tip"],v=u.joints["thumb-tip"],g=m.position.distanceTo(v.position);u.inputState.pinching&&g>.025?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=.015&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1);null!==o&&(null===(i=t.getPose(e.targetRaySpace,n))&&null!==r&&(i=r),null!==i&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ao)))}return null!==o&&(o.visible=null!==i),null!==s&&(s.visible=null!==r),null!==u&&(u.visible=null!==a),this}},{key:"_getHandJoint",value:function(e,t){if(void 0===e.joints[t.jointName]){var n=new bo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}]),e}(),Ro=function(e){f(n,e);var t=m(n);function n(e,i){var r;y(this,n);var o=d(r=t.call(this)),s=null,l=1,u=null,c="local-floor",h=1,f=null,p=null,m=null,v=null,g=null,x=null,M=i.getContextAttributes(),S=null,E=null,T=[],b=[],A=new $e,w=null,R=new Di;R.layers.enable(1),R.viewport=new xt;var C=new Di;C.layers.enable(2),C.viewport=new xt;var L=[R,C],P=new To;P.layers.enable(1),P.layers.enable(2);var U=null,k=null;function I(e){var t=b.indexOf(e.inputSource);if(-1!==t){var n=T[t];void 0!==n&&(n.update(e.inputSource,e.frame,f||u),n.dispatchEvent({type:e.type,data:e.inputSource}))}}function N(){s.removeEventListener("select",I),s.removeEventListener("selectstart",I),s.removeEventListener("selectend",I),s.removeEventListener("squeeze",I),s.removeEventListener("squeezestart",I),s.removeEventListener("squeezeend",I),s.removeEventListener("end",N),s.removeEventListener("inputsourceschange",D);for(var t=0;t<T.length;t++){var n=b[t];null!==n&&(b[t]=null,T[t].disconnect(n))}U=null,k=null,e.setRenderTarget(S),g=null,v=null,m=null,s=null,E=null,H.stop(),o.isPresenting=!1,e.setPixelRatio(w),e.setSize(A.width,A.height,!1),o.dispatchEvent({type:"sessionend"})}function D(e){for(var t=0;t<e.removed.length;t++){var n=e.removed[t],i=b.indexOf(n);i>=0&&(b[i]=null,T[i].disconnect(n))}for(var r=0;r<e.added.length;r++){var a=e.added[r],o=b.indexOf(a);if(-1===o){for(var s=0;s<T.length;s++){if(s>=b.length){b.push(a),o=s;break}if(null===b[s]){b[s]=a,o=s;break}}if(-1===o)break}var l=T[o];l&&l.connect(a)}}r.cameraAutoUpdate=!0,r.enabled=!1,r.isPresenting=!1,r.getController=function(e){var t=T[e];return void 0===t&&(t=new wo,T[e]=t),t.getTargetRaySpace()},r.getControllerGrip=function(e){var t=T[e];return void 0===t&&(t=new wo,T[e]=t),t.getGripSpace()},r.getHand=function(e){var t=T[e];return void 0===t&&(t=new wo,T[e]=t),t.getHandSpace()},r.setFramebufferScaleFactor=function(e){l=e,!0===o.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},r.setReferenceSpaceType=function(e){c=e,!0===o.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},r.getReferenceSpace=function(){return f||u},r.setReferenceSpace=function(e){f=e},r.getBaseLayer=function(){return null!==v?v:g},r.getBinding=function(){return m},r.getFrame=function(){return x},r.getSession=function(){return s},r.setSession=function(){var t,n=(t=_().mark((function t(n){var r,a,d,p,y;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(s=n)){t.next=27;break}if(S=e.getRenderTarget(),s.addEventListener("select",I),s.addEventListener("selectstart",I),s.addEventListener("selectend",I),s.addEventListener("squeeze",I),s.addEventListener("squeezestart",I),s.addEventListener("squeezeend",I),s.addEventListener("end",N),s.addEventListener("inputsourceschange",D),!0===M.xrCompatible){t.next=14;break}return t.next=14,i.makeXRCompatible();case 14:return w=e.getPixelRatio(),e.getSize(A),void 0===s.renderState.layers||!1===e.capabilities.isWebGL2?(r={antialias:void 0!==s.renderState.layers||M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:l},g=new XRWebGLLayer(s,i,r),s.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),E=new St(g.framebufferWidth,g.framebufferHeight,{format:le,type:te,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil})):(a=null,d=null,p=null,M.depth&&(p=M.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,a=M.stencil?ce:ue,d=M.stencil?se:re),y={colorFormat:i.RGBA8,depthFormat:p,scaleFactor:l},m=new XRWebGLBinding(s,i),v=m.createProjectionLayer(y),s.updateRenderState({layers:[v]}),e.setPixelRatio(1),e.setSize(v.textureWidth,v.textureHeight,!1),E=new St(v.textureWidth,v.textureHeight,{format:le,type:te,depthTexture:new Ur(v.textureWidth,v.textureHeight,d,void 0,void 0,void 0,void 0,void 0,void 0,a),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0}),e.properties.get(E).__ignoreDepthValues=v.ignoreDepthValues),E.isXRRenderTarget=!0,this.setFoveation(h),f=null,t.next=22,s.requestReferenceSpace(c);case 22:u=t.sent,H.setContext(s),H.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"});case 27:case"end":return t.stop()}}),t,this)})),function(){var e=this,n=arguments;return new Promise((function(i,r){var o=t.apply(e,n);function s(e){a(o,i,r,s,l,"next",e)}function l(e){a(o,i,r,s,l,"throw",e)}s(void 0)}))});return function(e){return n.apply(this,arguments)}}(),r.getEnvironmentBlendMode=function(){if(null!==s)return s.environmentBlendMode};var O=new At,F=new At;function B(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}r.updateCamera=function(e){if(null!==s){P.near=C.near=R.near=e.near,P.far=C.far=R.far=e.far,U===P.near&&k===P.far||(s.updateRenderState({depthNear:P.near,depthFar:P.far}),U=P.near,k=P.far);var t=e.parent,n=P.cameras;B(P,t);for(var i=0;i<n.length;i++)B(n[i],t);2===n.length?function(e,t,n){O.setFromMatrixPosition(t.matrixWorld),F.setFromMatrixPosition(n.matrixWorld);var i=O.distanceTo(F),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=r[14]/(r[10]-1),s=r[14]/(r[10]+1),l=(r[9]+1)/r[5],u=(r[9]-1)/r[5],c=(r[8]-1)/r[0],h=(a[8]+1)/a[0],d=o*c,f=o*h,p=i/(-c+h),m=p*-c;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();var v=o+p,g=s+p,_=d-m,y=f+(i-m),x=l*s/g*v,M=u*s/g*v;e.projectionMatrix.makePerspective(_,y,x,M,v,g),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(P,R,C):P.projectionMatrix.copy(R.projectionMatrix),function(e,t,n){null===n?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*Ve*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,P,t)}},r.getCamera=function(){return P},r.getFoveation=function(){if(null!==v||null!==g)return h},r.setFoveation=function(e){h=e,null!==v&&(v.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)};var z=null;var H=new Yi;return H.setAnimationLoop((function(t,n){if(p=n.getViewerPose(f||u),x=n,null!==p){var i=p.views;null!==g&&(e.setRenderTargetFramebuffer(E,g.framebuffer),e.setRenderTarget(E));var r=!1;i.length!==P.cameras.length&&(P.cameras.length=0,r=!0);for(var a=0;a<i.length;a++){var s=i[a],l=null;if(null!==g)l=g.getViewport(s);else{var c=m.getViewSubImage(v,s);l=c.viewport,0===a&&(e.setRenderTargetTextures(E,c.colorTexture,v.ignoreDepthValues?void 0:c.depthStencilTexture),e.setRenderTarget(E))}var h=L[a];void 0===h&&((h=new Di).layers.enable(a),h.viewport=new xt,L[a]=h),h.matrix.fromArray(s.transform.matrix),h.matrix.decompose(h.position,h.quaternion,h.scale),h.projectionMatrix.fromArray(s.projectionMatrix),h.projectionMatrixInverse.copy(h.projectionMatrix).invert(),h.viewport.set(l.x,l.y,l.width,l.height),0===a&&(P.matrix.copy(h.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),!0===r&&P.cameras.push(h)}}for(var d=0;d<T.length;d++){var _=b[d],y=T[d];null!==_&&void 0!==y&&y.update(_,n,f||u)}z&&z(t,n),n.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:n}),x=null})),r.setAnimationLoop=function(e){z=e},r.dispose=function(){},r}return M(n)}(Be);function Co(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(i,r){i.opacity.value=r.opacity,r.color&&i.diffuse.value.copy(r.color),r.emissive&&i.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(i.map.value=r.map,n(r.map,i.mapTransform)),r.alphaMap&&(i.alphaMap.value=r.alphaMap,n(r.alphaMap,i.alphaMapTransform)),r.bumpMap&&(i.bumpMap.value=r.bumpMap,n(r.bumpMap,i.bumpMapTransform),i.bumpScale.value=r.bumpScale,r.side===R&&(i.bumpScale.value*=-1)),r.normalMap&&(i.normalMap.value=r.normalMap,n(r.normalMap,i.normalMapTransform),i.normalScale.value.copy(r.normalScale),r.side===R&&i.normalScale.value.negate()),r.displacementMap&&(i.displacementMap.value=r.displacementMap,n(r.displacementMap,i.displacementMapTransform),i.displacementScale.value=r.displacementScale,i.displacementBias.value=r.displacementBias),r.emissiveMap&&(i.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,i.emissiveMapTransform)),r.specularMap&&(i.specularMap.value=r.specularMap,n(r.specularMap,i.specularMapTransform)),r.alphaTest>0&&(i.alphaTest.value=r.alphaTest);var a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;var o=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*o,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Ui(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,o,s){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform));e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));var r=t.get(i).envMap;r&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===R&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,s)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){var i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,o):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Lo(e,t,n,i){var r={},a={},o=[],s=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n,i){var r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"===typeof r||"boolean"===typeof r?r:r.clone(),!0;var o=i[a];if("number"===typeof r||"boolean"===typeof r){if(o!==r)return i[a]=r,!0}else if(!1===o.equals(r))return o.copy(r),!0;return!1}function u(e){var t={boundary:0,storage:0};return"number"===typeof e||"boolean"===typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){var n=t.target;n.removeEventListener("dispose",c);var i=o.indexOf(n.__bindingPointIndex);o.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){var n=t.program;i.uniformBlockBinding(e,n)},update:function(n,h){var d=r[n.id];void 0===d&&(!function(e){for(var t=e.uniforms,n=0,i=16,r=0,a=t.length;r<a;r++)for(var o=Array.isArray(t[r])?t[r]:[t[r]],s=0,l=o.length;s<l;s++)for(var c=o[s],h=Array.isArray(c.value)?c.value:[c.value],d=0,f=h.length;d<f;d++){var p=u(h[d]),m=n%i;0!==m&&i-m<p.boundary&&(n+=i-m),c.__data=new Float32Array(p.storage/Float32Array.BYTES_PER_ELEMENT),c.__offset=n,n+=p.storage}var v=n%i;v>0&&(n+=i-v);e.__size=n,e.__cache={}}(n),d=function(t){var n=function(){for(var e=0;e<s;e++)if(-1===o.indexOf(e))return o.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;var i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",c));var f=h.program;i.updateUBOMapping(n,f);var p=t.render.frame;a[n.id]!==p&&(!function(t){var n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(var o=0,s=i.length;o<s;o++)for(var c=Array.isArray(i[o])?i[o]:[i[o]],h=0,d=c.length;h<d;h++){var f=c[h];if(!0===l(f,o,h,a)){for(var p=f.__offset,m=Array.isArray(f.value)?f.value:[f.value],v=0,g=0;g<m.length;g++){var _=m[g],y=u(_);"number"===typeof _||"boolean"===typeof _?(f.__data[0]=_,e.bufferSubData(e.UNIFORM_BUFFER,p+v,f.__data)):_.isMatrix3?(f.__data[0]=_.elements[0],f.__data[1]=_.elements[1],f.__data[2]=_.elements[2],f.__data[3]=0,f.__data[4]=_.elements[3],f.__data[5]=_.elements[4],f.__data[6]=_.elements[5],f.__data[7]=0,f.__data[8]=_.elements[6],f.__data[9]=_.elements[7],f.__data[10]=_.elements[8],f.__data[11]=0):(_.toArray(f.__data,v),v+=y.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,p,f.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=p)},dispose:function(){for(var t in r)e.deleteBuffer(r[t]);o=[],r={},a={}}}}var Po=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y(this,e);var n,i=t.canvas,r=void 0===i?function(){var e=it("canvas");return e.style.display="block",e}():i,a=t.context,o=void 0===a?null:a,s=t.depth,l=void 0===s||s,u=t.stencil,c=void 0===u||u,h=t.alpha,d=void 0!==h&&h,f=t.antialias,p=void 0!==f&&f,m=t.premultipliedAlpha,v=void 0===m||m,g=t.preserveDrawingBuffer,_=void 0!==g&&g,x=t.powerPreference,M=void 0===x?"default":x,S=t.failIfMajorPerformanceCaveat,T=void 0!==S&&S;this.isWebGLRenderer=!0,n=null!==o?o.getContextAttributes().alpha:d;var b=new Uint32Array(4),A=new Int32Array(4),C=null,L=null,P=[],U=[];this.domElement=r,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=be,this._useLegacyLights=!1,this.toneMapping=k,this.toneMappingExposure=1;var I=this,N=!1,D=0,O=0,F=null,B=-1,z=null,H=new xt,G=new xt,V=null,W=new Xn(0),X=0,j=r.width,q=r.height,Y=1,K=null,Z=null,J=new xt(0,0,j,q),Q=new xt(0,0,j,q),$=!1,ie=new qi,ue=!1,ce=!1,he=null,de=new nn,fe=new $e,pe=new At,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ve(){return null===F?Y:1}var ge,_e,ye,xe,Me,Se,Ee,Te,we,Re,Ce,Le,Pe,Ue,ke,Ie,Ne,De,Oe,Fe,Be,ze,He,Ge,Ve=o;function We(e,t){for(var n=0;n<e.length;n++){var i=e[n],a=r.getContext(i,t);if(null!==a)return a}return null}try{var Xe={alpha:!0,depth:l,stencil:c,antialias:p,premultipliedAlpha:v,preserveDrawingBuffer:_,powerPreference:M,failIfMajorPerformanceCaveat:T};if("setAttribute"in r&&r.setAttribute("data-engine","three.js r".concat(E)),r.addEventListener("webglcontextlost",Ze,!1),r.addEventListener("webglcontextrestored",Je,!1),r.addEventListener("webglcontextcreationerror",Qe,!1),null===Ve){var je=["webgl2","webgl","experimental-webgl"];if(!0===I.isWebGL1Renderer&&je.shift(),null===(Ve=We(je,Xe)))throw We(je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!==typeof WebGLRenderingContext&&Ve instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Ve.getShaderPrecisionFormat&&(Ve.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(pt){throw console.error("THREE.WebGLRenderer: "+pt.message),pt}function qe(){ge=new Tr(Ve),_e=new rr(Ve,ge,t),ge.init(_e),ze=new Eo(Ve,ge,_e),ye=new Mo(Ve,ge,_e),xe=new wr(Ve),Me=new oo,Se=new So(Ve,ge,ye,Me,_e,ze,xe),Ee=new or(I),Te=new Er(I),we=new Ki(Ve,_e),He=new nr(Ve,ge,we,_e),Re=new br(Ve,we,xe,He),Ce=new Pr(Ve,Re,we,xe),Oe=new Lr(Ve,_e,Se),Ie=new ar(Me),Le=new ao(I,Ee,Te,ge,_e,He,Ie),Pe=new Co(I,Me),Ue=new co,ke=new go(ge,_e),De=new tr(I,Ee,Te,ye,Ce,n,v),Ne=new xo(I,Ce,_e),Ge=new Lo(Ve,xe,_e,ye),Fe=new ir(Ve,ge,xe,_e),Be=new Ar(Ve,ge,xe,_e),xe.programs=Le.programs,I.capabilities=_e,I.extensions=ge,I.properties=Me,I.renderLists=Ue,I.shadowMap=Ne,I.state=ye,I.info=xe}qe();var Ye=new Ro(I,Ve);function Ze(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;var e=xe.autoReset,t=Ne.enabled,n=Ne.autoUpdate,i=Ne.needsUpdate,r=Ne.type;qe(),xe.autoReset=e,Ne.enabled=t,Ne.autoUpdate=n,Ne.needsUpdate=i,Ne.type=r}function Qe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function et(e){var t=e.target;t.removeEventListener("dispose",et),function(e){(function(e){var t=Me.get(e).programs;void 0!==t&&(t.forEach((function(e){Le.releaseProgram(e)})),e.isShaderMaterial&&Le.releaseShaderCache(e))})(e),Me.remove(e)}(t)}function tt(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=R,e.needsUpdate=!0,ht(e,t,n),e.side=w,e.needsUpdate=!0,ht(e,t,n),e.side=2):ht(e,t,n)}this.xr=Ye,this.getContext=function(){return Ve},this.getContextAttributes=function(){return Ve.getContextAttributes()},this.forceContextLoss=function(){var e=ge.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=ge.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(e){void 0!==e&&(Y=e,this.setSize(j,q,!1))},this.getSize=function(e){return e.set(j,q)},this.setSize=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];Ye.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(j=e,q=t,r.width=Math.floor(e*Y),r.height=Math.floor(t*Y),!0===n&&(r.style.width=e+"px",r.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(j*Y,q*Y).floor()},this.setDrawingBufferSize=function(e,t,n){j=e,q=t,Y=n,r.width=Math.floor(e*n),r.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(H)},this.getViewport=function(e){return e.copy(J)},this.setViewport=function(e,t,n,i){e.isVector4?J.set(e.x,e.y,e.z,e.w):J.set(e,t,n,i),ye.viewport(H.copy(J).multiplyScalar(Y).floor())},this.getScissor=function(e){return e.copy(Q)},this.setScissor=function(e,t,n,i){e.isVector4?Q.set(e.x,e.y,e.z,e.w):Q.set(e,t,n,i),ye.scissor(G.copy(Q).multiplyScalar(Y).floor())},this.getScissorTest=function(){return $},this.setScissorTest=function(e){ye.setScissorTest($=e)},this.setOpaqueSort=function(e){K=e},this.setTransparentSort=function(e){Z=e},this.getClearColor=function(e){return e.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor.apply(De,arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha.apply(De,arguments)},this.clear=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=0;if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){var i=!1;if(null!==F){var r=F.texture.format;i=1033===r||1031===r||1029===r}if(i){var a=F.texture.type,o=a===te||a===re||a===ne||a===se||1017===a||1018===a,s=De.getClearColor(),l=De.getClearAlpha(),u=s.r,c=s.g,h=s.b;o?(b[0]=u,b[1]=c,b[2]=h,b[3]=l,Ve.clearBufferuiv(Ve.COLOR,0,b)):(A[0]=u,A[1]=c,A[2]=h,A[3]=l,Ve.clearBufferiv(Ve.COLOR,0,A))}else n|=Ve.COLOR_BUFFER_BIT}e&&(n|=Ve.DEPTH_BUFFER_BIT),t&&(n|=Ve.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ve.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){r.removeEventListener("webglcontextlost",Ze,!1),r.removeEventListener("webglcontextrestored",Je,!1),r.removeEventListener("webglcontextcreationerror",Qe,!1),Ue.dispose(),ke.dispose(),Me.dispose(),Ee.dispose(),Te.dispose(),Ce.dispose(),He.dispose(),Ge.dispose(),Le.dispose(),Ye.dispose(),Ye.removeEventListener("sessionstart",rt),Ye.removeEventListener("sessionend",at),he&&(he.dispose(),he=null),ot.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=me);var o=r.isMesh&&r.matrixWorld.determinant()<0,s=function(e,t,n,i,r){!0!==t.isScene&&(t=me);Se.resetTextureUnits();var a=t.fog,o=i.isMeshStandardMaterial?t.environment:null,s=null===F?I.outputColorSpace:!0===F.isXRRenderTarget?F.texture.colorSpace:Ae,l=(i.isMeshStandardMaterial?Te:Ee).get(i.envMap||o),u=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),h=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,f=!!n.morphAttributes.color,p=k;i.toneMapped&&(null!==F&&!0!==F.isXRRenderTarget||(p=I.toneMapping));var m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==m?m.length:0,g=Me.get(i),_=L.state.lights;if(!0===ue&&(!0===ce||e!==z)){var y=e===z&&i.id===B;Ie.setState(i,e,y)}var x=!1;i.version===g.__version?g.needsLights&&g.lightsStateVersion!==_.state.version||g.outputColorSpace!==s||r.isBatchedMesh&&!1===g.batching?x=!0:r.isBatchedMesh||!0!==g.batching?r.isInstancedMesh&&!1===g.instancing?x=!0:r.isInstancedMesh||!0!==g.instancing?r.isSkinnedMesh&&!1===g.skinning?x=!0:r.isSkinnedMesh||!0!==g.skinning?r.isInstancedMesh&&!0===g.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===g.instancingColor&&null!==r.instanceColor||g.envMap!==l||!0===i.fog&&g.fog!==a?x=!0:void 0===g.numClippingPlanes||g.numClippingPlanes===Ie.numPlanes&&g.numIntersection===Ie.numIntersection?(g.vertexAlphas!==u||g.vertexTangents!==c||g.morphTargets!==h||g.morphNormals!==d||g.morphColors!==f||g.toneMapping!==p||!0===_e.isWebGL2&&g.morphTargetsCount!==v)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,g.__version=i.version);var M=g.currentProgram;!0===x&&(M=ht(i,t,r));var S=!1,E=!1,T=!1,b=M.getUniforms(),A=g.uniforms;ye.useProgram(M.program)&&(S=!0,E=!0,T=!0);i.id!==B&&(B=i.id,E=!0);if(S||z!==e){b.setValue(Ve,"projectionMatrix",e.projectionMatrix),b.setValue(Ve,"viewMatrix",e.matrixWorldInverse);var w=b.map.cameraPosition;void 0!==w&&w.setValue(Ve,pe.setFromMatrixPosition(e.matrixWorld)),_e.logarithmicDepthBuffer&&b.setValue(Ve,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&b.setValue(Ve,"isOrthographic",!0===e.isOrthographicCamera),z!==e&&(z=e,E=!0,T=!0)}if(r.isSkinnedMesh){b.setOptional(Ve,r,"bindMatrix"),b.setOptional(Ve,r,"bindMatrixInverse");var R=r.skeleton;R&&(_e.floatVertexTextures?(null===R.boneTexture&&R.computeBoneTexture(),b.setValue(Ve,"boneTexture",R.boneTexture,Se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}r.isBatchedMesh&&(b.setOptional(Ve,r,"batchingTexture"),b.setValue(Ve,"batchingTexture",r._matricesTexture,Se));var C=n.morphAttributes;(void 0!==C.position||void 0!==C.normal||void 0!==C.color&&!0===_e.isWebGL2)&&Oe.update(r,n,M);(E||g.receiveShadow!==r.receiveShadow)&&(g.receiveShadow=r.receiveShadow,b.setValue(Ve,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(A.envMap.value=l,A.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);E&&(b.setValue(Ve,"toneMappingExposure",I.toneMappingExposure),g.needsLights&&(U=T,(P=A).ambientLightColor.needsUpdate=U,P.lightProbe.needsUpdate=U,P.directionalLights.needsUpdate=U,P.directionalLightShadows.needsUpdate=U,P.pointLights.needsUpdate=U,P.pointLightShadows.needsUpdate=U,P.spotLights.needsUpdate=U,P.spotLightShadows.needsUpdate=U,P.rectAreaLights.needsUpdate=U,P.hemisphereLights.needsUpdate=U),a&&!0===i.fog&&Pe.refreshFogUniforms(A,a),Pe.refreshMaterialUniforms(A,i,Y,q,he),Oa.upload(Ve,dt(g),A,Se));var P,U;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Oa.upload(Ve,dt(g),A,Se),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&b.setValue(Ve,"center",r.center);if(b.setValue(Ve,"modelViewMatrix",r.modelViewMatrix),b.setValue(Ve,"normalMatrix",r.normalMatrix),b.setValue(Ve,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial)for(var N=i.uniformsGroups,D=0,O=N.length;D<O;D++)if(_e.isWebGL2){var H=N[D];Ge.update(H,M),Ge.bind(H,M)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.");return M}(e,t,n,i,r);ye.setMaterial(i,o);var l=n.index,u=1;if(!0===i.wireframe){if(void 0===(l=Re.getWireframeAttribute(n)))return;u=2}var c=n.drawRange,h=n.attributes.position,d=c.start*u,f=(c.start+c.count)*u;null!==a&&(d=Math.max(d,a.start*u),f=Math.min(f,(a.start+a.count)*u)),null!==l?(d=Math.max(d,0),f=Math.min(f,l.count)):void 0!==h&&null!==h&&(d=Math.max(d,0),f=Math.min(f,h.count));var p=f-d;if(!(p<0||p===1/0)){var m;He.setup(r,i,s,n,l);var v=Fe;if(null!==l&&(m=we.get(l),(v=Be).setIndex(m)),r.isMesh)!0===i.wireframe?(ye.setLineWidth(i.wireframeLinewidth*ve()),v.setMode(Ve.LINES)):v.setMode(Ve.TRIANGLES);else if(r.isLine){var g=i.linewidth;void 0===g&&(g=1),ye.setLineWidth(g*ve()),r.isLineSegments?v.setMode(Ve.LINES):r.isLineLoop?v.setMode(Ve.LINE_LOOP):v.setMode(Ve.LINE_STRIP)}else r.isPoints?v.setMode(Ve.POINTS):r.isSprite&&v.setMode(Ve.TRIANGLES);if(r.isBatchedMesh)v.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else if(r.isInstancedMesh)v.renderInstances(d,p,r.count);else if(n.isInstancedBufferGeometry){var _=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,y=Math.min(n.instanceCount,_);v.renderInstances(d,p,y)}else v.render(d,p)}},this.compile=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null===n&&(n=e),(L=ke.get(n)).init(),U.push(L),n.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(L.pushLight(e),e.castShadow&&L.pushShadow(e))})),e!==n&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(L.pushLight(e),e.castShadow&&L.pushShadow(e))})),L.setupLights(I._useLegacyLights);var i=new Set;return e.traverse((function(e){var t=e.material;if(t)if(Array.isArray(t))for(var r=0;r<t.length;r++){var a=t[r];tt(a,n,e),i.add(a)}else tt(t,n,e),i.add(t)})),U.pop(),L=null,i},this.compileAsync=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=this.compile(e,t,n);return new Promise((function(t){function n(){i.forEach((function(e){Me.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==ge.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};var nt=null;function rt(){ot.stop()}function at(){ot.start()}var ot=new Yi;function st(e,t,n,i){if(!1!==e.visible){if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)L.pushLight(e),e.castShadow&&L.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ie.intersectsSprite(e)){i&&pe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);var r=Ce.update(e),a=e.material;a.visible&&C.push(e,r,a,n,pe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ie.intersectsObject(e))){var o=Ce.update(e),s=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),pe.copy(e.boundingSphere.center)):(null===o.boundingSphere&&o.computeBoundingSphere(),pe.copy(o.boundingSphere.center)),pe.applyMatrix4(e.matrixWorld).applyMatrix4(de)),Array.isArray(s))for(var l=o.groups,u=0,c=l.length;u<c;u++){var h=l[u],d=s[h.materialIndex];d&&d.visible&&C.push(e,o,d,n,pe.z,h)}else s.visible&&C.push(e,o,s,n,pe.z,null)}for(var f=e.children,p=0,m=f.length;p<m;p++)st(f[p],t,n,i)}}function lt(e,t,n,i){var r=e.opaque,a=e.transmissive,o=e.transparent;L.setupLightsView(n),!0===ue&&Ie.setGlobalState(I.clippingPlanes,n),a.length>0&&function(e,t,n,i){var r=!0===n.isScene?n.overrideMaterial:null;if(null!==r)return;var a=_e.isWebGL2;null===he&&(he=new St(1,1,{generateMipmaps:!0,type:ge.has("EXT_color_buffer_half_float")?oe:te,minFilter:ee,samples:a?4:0}));I.getDrawingBufferSize(fe),a?he.setSize(fe.x,fe.y):he.setSize(Ke(fe.x),Ke(fe.y));var o=I.getRenderTarget();I.setRenderTarget(he),I.getClearColor(W),(X=I.getClearAlpha())<1&&I.setClearColor(16777215,.5);I.clear();var s=I.toneMapping;I.toneMapping=k,ut(e,n,i),Se.updateMultisampleRenderTarget(he),Se.updateRenderTargetMipmap(he);for(var l=!1,u=0,c=t.length;u<c;u++){var h=t[u],d=h.object,f=h.geometry,p=h.material,m=h.group;if(2===p.side&&d.layers.test(i.layers)){var v=p.side;p.side=R,p.needsUpdate=!0,ct(d,n,i,f,p,m),p.side=v,p.needsUpdate=!0,l=!0}}!0===l&&(Se.updateMultisampleRenderTarget(he),Se.updateRenderTargetMipmap(he));I.setRenderTarget(o),I.setClearColor(W,X),I.toneMapping=s}(r,a,t,n),i&&ye.viewport(H.copy(i)),r.length>0&&ut(r,t,n),a.length>0&&ut(a,t,n),o.length>0&&ut(o,t,n),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function ut(e,t,n){for(var i=!0===t.isScene?t.overrideMaterial:null,r=0,a=e.length;r<a;r++){var o=e[r],s=o.object,l=o.geometry,u=null===i?o.material:i,c=o.group;s.layers.test(n.layers)&&ct(s,t,n,l,u,c)}}function ct(e,t,n,i,r,a){e.onBeforeRender(I,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(I,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=R,r.needsUpdate=!0,I.renderBufferDirect(n,t,i,r,e,a),r.side=w,r.needsUpdate=!0,I.renderBufferDirect(n,t,i,r,e,a),r.side=2):I.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(I,t,n,i,r,a)}function ht(e,t,n){!0!==t.isScene&&(t=me);var i=Me.get(e),r=L.state.lights,a=L.state.shadowsArray,o=r.state.version,s=Le.getParameters(e,r.state,a,t,n),l=Le.getProgramCacheKey(s),u=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?Te:Ee).get(e.envMap||i.environment),void 0===u&&(e.addEventListener("dispose",et),u=new Map,i.programs=u);var c=u.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===o)return ft(e,s),c}else s.uniforms=Le.getUniforms(e),e.onBuild(n,s,I),e.onBeforeCompile(s,I),c=Le.acquireProgram(s,l),u.set(l,c),i.uniforms=s.uniforms;var h=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(h.clippingPlanes=Ie.uniform),ft(e,s),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=o,i.needsLights&&(h.ambientLightColor.value=r.state.ambient,h.lightProbe.value=r.state.probe,h.directionalLights.value=r.state.directional,h.directionalLightShadows.value=r.state.directionalShadow,h.spotLights.value=r.state.spot,h.spotLightShadows.value=r.state.spotShadow,h.rectAreaLights.value=r.state.rectArea,h.ltc_1.value=r.state.rectAreaLTC1,h.ltc_2.value=r.state.rectAreaLTC2,h.pointLights.value=r.state.point,h.pointLightShadows.value=r.state.pointShadow,h.hemisphereLights.value=r.state.hemi,h.directionalShadowMap.value=r.state.directionalShadowMap,h.directionalShadowMatrix.value=r.state.directionalShadowMatrix,h.spotShadowMap.value=r.state.spotShadowMap,h.spotLightMatrix.value=r.state.spotLightMatrix,h.spotLightMap.value=r.state.spotLightMap,h.pointShadowMap.value=r.state.pointShadowMap,h.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=c,i.uniformsList=null,c}function dt(e){if(null===e.uniformsList){var t=e.currentProgram.getUniforms();e.uniformsList=Oa.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function ft(e,t){var n=Me.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}ot.setAnimationLoop((function(e){nt&&nt(e)})),"undefined"!==typeof self&&ot.setContext(self),this.setAnimationLoop=function(e){nt=e,Ye.setAnimationLoop(e),null===e?ot.stop():ot.start()},Ye.addEventListener("sessionstart",rt),Ye.addEventListener("sessionend",at),this.render=function(e,t){if(void 0===t||!0===t.isCamera){if(!0!==N){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Ye.enabled&&!0===Ye.isPresenting&&(!0===Ye.cameraAutoUpdate&&Ye.updateCamera(t),t=Ye.getCamera()),!0===e.isScene&&e.onBeforeRender(I,e,t,F),(L=ke.get(e,U.length)).init(),U.push(L),de.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ie.setFromProjectionMatrix(de),ce=this.localClippingEnabled,ue=Ie.init(this.clippingPlanes,ce),(C=Ue.get(e,P.length)).init(),P.push(C),st(e,t,0,I.sortObjects),C.finish(),!0===I.sortObjects&&C.sort(K,Z),this.info.render.frame++,!0===ue&&Ie.beginShadows();var n=L.state.shadowsArray;if(Ne.render(n,e,t),!0===ue&&Ie.endShadows(),!0===this.info.autoReset&&this.info.reset(),De.render(C,e),L.setupLights(I._useLegacyLights),t.isArrayCamera)for(var i=t.cameras,r=0,a=i.length;r<a;r++){var o=i[r];lt(C,e,o,o.viewport)}else lt(C,e,t);null!==F&&(Se.updateMultisampleRenderTarget(F),Se.updateRenderTargetMipmap(F)),!0===e.isScene&&e.onAfterRender(I,e,t),He.resetDefaultState(),B=-1,z=null,U.pop(),L=U.length>0?U[U.length-1]:null,P.pop(),C=P.length>0?P[P.length-1]:null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(e,t,n){Me.get(e.texture).__webglTexture=t,Me.get(e.depthTexture).__webglTexture=n;var i=Me.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ge.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){var n=Me.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;F=e,D=t,O=n;var i=!0,r=null,a=!1,o=!1;if(e){var s=Me.get(e);void 0!==s.__useDefaultFramebuffer?(ye.bindFramebuffer(Ve.FRAMEBUFFER,null),i=!1):void 0===s.__webglFramebuffer?Se.setupRenderTarget(e):s.__hasExternalTextures&&Se.rebindTextures(e,Me.get(e.texture).__webglTexture,Me.get(e.depthTexture).__webglTexture);var l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(o=!0);var u=Me.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(u[t])?u[t][n]:u[t],a=!0):r=_e.isWebGL2&&e.samples>0&&!1===Se.useMultisampledRTT(e)?Me.get(e).__webglMultisampledFramebuffer:Array.isArray(u)?u[n]:u,H.copy(e.viewport),G.copy(e.scissor),V=e.scissorTest}else H.copy(J).multiplyScalar(Y).floor(),G.copy(Q).multiplyScalar(Y).floor(),V=$;if(ye.bindFramebuffer(Ve.FRAMEBUFFER,r)&&_e.drawBuffers&&i&&ye.drawBuffers(e,r),ye.viewport(H),ye.scissor(G),ye.setScissorTest(V),a){var c=Me.get(e.texture);Ve.framebufferTexture2D(Ve.FRAMEBUFFER,Ve.COLOR_ATTACHMENT0,Ve.TEXTURE_CUBE_MAP_POSITIVE_X+t,c.__webglTexture,n)}else if(o){var h=Me.get(e.texture),d=t||0;Ve.framebufferTextureLayer(Ve.FRAMEBUFFER,Ve.COLOR_ATTACHMENT0,h.__webglTexture,n||0,d)}B=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(e&&e.isWebGLRenderTarget){var s=Me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){ye.bindFramebuffer(Ve.FRAMEBUFFER,s);try{var l=e.texture,u=l.format,c=l.type;if(u!==le&&ze.convert(u)!==Ve.getParameter(Ve.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");var h=c===oe&&(ge.has("EXT_color_buffer_half_float")||_e.isWebGL2&&ge.has("EXT_color_buffer_float"));if(c!==te&&ze.convert(c)!==Ve.getParameter(Ve.IMPLEMENTATION_COLOR_READ_TYPE)&&(c!==ae||!(_e.isWebGL2||ge.has("OES_texture_float")||ge.has("WEBGL_color_buffer_float")))&&!h)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Ve.readPixels(t,n,i,r,ze.convert(u),ze.convert(c),a)}finally{var d=null!==F?Me.get(F).__webglFramebuffer:null;ye.bindFramebuffer(Ve.FRAMEBUFFER,d)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);Se.setTexture2D(t,0),Ve.copyTexSubImage2D(Ve.TEXTURE_2D,n,0,0,e.x,e.y,r,a),ye.unbindTexture()},this.copyTextureToTexture=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=t.image.width,a=t.image.height,o=ze.convert(n.format),s=ze.convert(n.type);Se.setTexture2D(n,0),Ve.pixelStorei(Ve.UNPACK_FLIP_Y_WEBGL,n.flipY),Ve.pixelStorei(Ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Ve.pixelStorei(Ve.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Ve.texSubImage2D(Ve.TEXTURE_2D,i,e.x,e.y,r,a,o,s,t.image.data):t.isCompressedTexture?Ve.compressedTexSubImage2D(Ve.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):Ve.texSubImage2D(Ve.TEXTURE_2D,i,e.x,e.y,o,s,t.image),0===i&&n.generateMipmaps&&Ve.generateMipmap(Ve.TEXTURE_2D),ye.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(I.isWebGL1Renderer)console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var a,o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,l=e.max.z-e.min.z+1,u=ze.convert(i.format),c=ze.convert(i.type);if(i.isData3DTexture)Se.setTexture3D(i,0),a=Ve.TEXTURE_3D;else{if(!i.isDataArrayTexture&&!i.isCompressedArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Se.setTexture2DArray(i,0),a=Ve.TEXTURE_2D_ARRAY}Ve.pixelStorei(Ve.UNPACK_FLIP_Y_WEBGL,i.flipY),Ve.pixelStorei(Ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Ve.pixelStorei(Ve.UNPACK_ALIGNMENT,i.unpackAlignment);var h=Ve.getParameter(Ve.UNPACK_ROW_LENGTH),d=Ve.getParameter(Ve.UNPACK_IMAGE_HEIGHT),f=Ve.getParameter(Ve.UNPACK_SKIP_PIXELS),p=Ve.getParameter(Ve.UNPACK_SKIP_ROWS),m=Ve.getParameter(Ve.UNPACK_SKIP_IMAGES),v=n.isCompressedTexture?n.mipmaps[r]:n.image;Ve.pixelStorei(Ve.UNPACK_ROW_LENGTH,v.width),Ve.pixelStorei(Ve.UNPACK_IMAGE_HEIGHT,v.height),Ve.pixelStorei(Ve.UNPACK_SKIP_PIXELS,e.min.x),Ve.pixelStorei(Ve.UNPACK_SKIP_ROWS,e.min.y),Ve.pixelStorei(Ve.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Ve.texSubImage3D(a,r,t.x,t.y,t.z,o,s,l,u,c,v.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Ve.compressedTexSubImage3D(a,r,t.x,t.y,t.z,o,s,l,u,v.data)):Ve.texSubImage3D(a,r,t.x,t.y,t.z,o,s,l,u,c,v),Ve.pixelStorei(Ve.UNPACK_ROW_LENGTH,h),Ve.pixelStorei(Ve.UNPACK_IMAGE_HEIGHT,d),Ve.pixelStorei(Ve.UNPACK_SKIP_PIXELS,f),Ve.pixelStorei(Ve.UNPACK_SKIP_ROWS,p),Ve.pixelStorei(Ve.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&Ve.generateMipmap(a),ye.unbindTexture()}},this.initTexture=function(e){e.isCubeTexture?Se.setTextureCube(e,0):e.isData3DTexture?Se.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Se.setTexture2DArray(e,0):Se.setTexture2D(e,0),ye.unbindTexture()},this.resetState=function(){D=0,O=0,F=null,ye.reset(),He.reset()},"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}return M(e,[{key:"coordinateSystem",get:function(){return Oe}},{key:"outputColorSpace",get:function(){return this._outputColorSpace},set:function(e){this._outputColorSpace=e;var t=this.getContext();t.drawingBufferColorSpace=e===we?"display-p3":"srgb",t.unpackColorSpace=ht.workingColorSpace===Re?"display-p3":"srgb"}},{key:"outputEncoding",get:function(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===be?Ee:3e3},set:function(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ee?be:Ae}},{key:"useLegacyLights",get:function(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights},set:function(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}]),e}(),Uo=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Po);Uo.prototype.isWebGL1Renderer=!0;var ko=function(t){f(i,t);var n=m(i);function i(){var e;return y(this,i),(e=n.call(this)).isScene=!0,e.type="Scene",e.background=null,e.environment=null,e.fog=null,e.backgroundBlurriness=0,e.backgroundIntensity=1,e.overrideMaterial=null,"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:d(e)})),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);return null!==this.fog&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}]),i}(Rn),Io=function(){function e(t,n){y(this,e),this.isInterleavedBuffer=!0,this.array=t,this.stride=n,this.count=void 0!==t?t.length/n:0,this.usage=Ie,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=We()}return M(e,[{key:"onUploadCallback",value:function(){}},{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{key:"updateRange",get:function(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}},{key:"setUsage",value:function(e){return this.usage=e,this}},{key:"addUpdateRange",value:function(e,t){this.updateRanges.push({start:e,count:t})}},{key:"clearUpdateRanges",value:function(){this.updateRanges.length=0}},{key:"copy",value:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}},{key:"copyAt",value:function(e,t,n){e*=this.stride,n*=t.stride;for(var i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}},{key:"clone",value:function(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=We()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);var t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}},{key:"onUpload",value:function(e){return this.onUploadCallback=e,this}},{key:"toJSON",value:function(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=We()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}]),e}(),No=new At,Do=function(){function e(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];y(this,e),this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=n,this.offset=i,this.normalized=r}return M(e,[{key:"count",get:function(){return this.data.count}},{key:"array",get:function(){return this.data.array}},{key:"needsUpdate",set:function(e){this.data.needsUpdate=e}},{key:"applyMatrix4",value:function(e){for(var t=0,n=this.data.count;t<n;t++)No.fromBufferAttribute(this,t),No.applyMatrix4(e),this.setXYZ(t,No.x,No.y,No.z);return this}},{key:"applyNormalMatrix",value:function(e){for(var t=0,n=this.count;t<n;t++)No.fromBufferAttribute(this,t),No.applyNormalMatrix(e),this.setXYZ(t,No.x,No.y,No.z);return this}},{key:"transformDirection",value:function(e){for(var t=0,n=this.count;t<n;t++)No.fromBufferAttribute(this,t),No.transformDirection(e),this.setXYZ(t,No.x,No.y,No.z);return this}},{key:"setX",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}},{key:"setY",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}},{key:"setZ",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}},{key:"setW",value:function(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}},{key:"getX",value:function(e){var t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"getY",value:function(e){var t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"getZ",value:function(e){var t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"getW",value:function(e){var t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ze(t,this.array)),t}},{key:"setXY",value:function(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}},{key:"setXYZ",value:function(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array),i=Je(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}},{key:"setXYZW",value:function(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),n=Je(n,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}},{key:"clone",value:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");for(var n=[],i=0;i<this.count;i++)for(var r=i*this.data.stride+this.offset,a=0;a<this.itemSize;a++)n.push(this.data.array[r+a]);return new Qn(new this.array.constructor(n),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}},{key:"toJSON",value:function(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");for(var t=[],n=0;n<this.count;n++)for(var i=n*this.data.stride+this.offset,r=0;r<this.itemSize;r++)t.push(this.data.array[i+r]);return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}]),e}();var Oo=new At,Fo=new xt,Bo=new xt,zo=new At,Ho=new nn,Go=new At,Vo=new qt,Wo=new nn,Xo=new tn,jo=function(t){f(i,t);var n=m(i);function i(e,t){var r;return y(this,i),(r=n.call(this,e,t)).isSkinnedMesh=!0,r.type="SkinnedMesh",r.bindMode=z,r.bindMatrix=new nn,r.bindMatrixInverse=new nn,r.boundingBox=null,r.boundingSphere=null,r}return M(i,[{key:"computeBoundingBox",value:function(){var e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Ct),this.boundingBox.makeEmpty();for(var t=e.getAttribute("position"),n=0;n<t.count;n++)this.getVertexPosition(n,Go),this.boundingBox.expandByPoint(Go)}},{key:"computeBoundingSphere",value:function(){var e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new qt),this.boundingSphere.makeEmpty();for(var t=e.getAttribute("position"),n=0;n<t.count;n++)this.getVertexPosition(n,Go),this.boundingSphere.expandByPoint(Go)}},{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}},{key:"raycast",value:function(e,t){var n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Vo.copy(this.boundingSphere),Vo.applyMatrix4(i),!1!==e.ray.intersectsSphere(Vo)&&(Wo.copy(i).invert(),Xo.copy(e.ray).applyMatrix4(Wo),null!==this.boundingBox&&!1===Xo.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,Xo)))}},{key:"getVertexPosition",value:function(t,n){return c(e(i.prototype),"getVertexPosition",this).call(this,t,n),this.applyBoneTransform(t,n),n}},{key:"bind",value:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}},{key:"pose",value:function(){this.skeleton.pose()}},{key:"normalizeSkinWeights",value:function(){for(var e=new xt,t=this.geometry.attributes.skinWeight,n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);var r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}},{key:"updateMatrixWorld",value:function(t){c(e(i.prototype),"updateMatrixWorld",this).call(this,t),this.bindMode===z?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}},{key:"applyBoneTransform",value:function(e,t){var n=this.skeleton,i=this.geometry;Fo.fromBufferAttribute(i.attributes.skinIndex,e),Bo.fromBufferAttribute(i.attributes.skinWeight,e),Oo.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(var r=0;r<4;r++){var a=Bo.getComponent(r);if(0!==a){var o=Fo.getComponent(r);Ho.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(zo.copy(Oo).applyMatrix4(Ho),a)}}return t.applyMatrix4(this.bindMatrixInverse)}},{key:"boneTransform",value:function(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}]),i}(wi),qo=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this)).isBone=!0,e.type="Bone",e}return M(n)}(Rn),Yo=function(e){f(n,e);var t=m(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,l=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,c=arguments.length>7?arguments[7]:void 0,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:K,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:K,f=arguments.length>10?arguments[10]:void 0,p=arguments.length>11?arguments[11]:void 0;return y(this,n),(e=t.call(this,null,l,u,c,h,d,o,s,f,p)).isDataTexture=!0,e.image={data:i,width:r,height:a},e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return M(n)}(yt),Ko=new nn,Zo=new nn,Jo=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];y(this,e),this.uuid=We(),this.bones=t.slice(0),this.boneInverses=n,this.boneMatrices=null,this.boneTexture=null,this.init()}return M(e,[{key:"init",value:function(){var e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(var n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new nn)}}},{key:"calculateInverses",value:function(){this.boneInverses.length=0;for(var e=0,t=this.bones.length;e<t;e++){var n=new nn;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}},{key:"pose",value:function(){for(var e=0,t=this.bones.length;e<t;e++){var n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(var i=0,r=this.bones.length;i<r;i++){var a=this.bones[i];a&&(a.parent&&a.parent.isBone?(a.matrix.copy(a.parent.matrixWorld).invert(),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale))}}},{key:"update",value:function(){for(var e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture,r=0,a=e.length;r<a;r++){var o=e[r]?e[r].matrixWorld:Zo;Ko.multiplyMatrices(o,t[r]),Ko.toArray(n,16*r)}null!==i&&(i.needsUpdate=!0)}},{key:"clone",value:function(){return new e(this.bones,this.boneInverses)}},{key:"computeBoneTexture",value:function(){var e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);var t=new Float32Array(e*e*4);t.set(this.boneMatrices);var n=new Yo(t,e,e,le,ae);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}},{key:"getBoneByName",value:function(e){for(var t=0,n=this.bones.length;t<n;t++){var i=this.bones[t];if(i.name===e)return i}}},{key:"dispose",value:function(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}},{key:"fromJSON",value:function(e,t){this.uuid=e.uuid;for(var n=0,i=e.bones.length;n<i;n++){var r=e.bones[n],a=t[r];void 0===a&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new qo),this.bones.push(a),this.boneInverses.push((new nn).fromArray(e.boneInverses[n]))}return this.init(),this}},{key:"toJSON",value:function(){var e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;for(var t=this.bones,n=this.boneInverses,i=0,r=t.length;i<r;i++){var a=t[i];e.bones.push(a.uuid);var o=n[i];e.boneInverses.push(o.toArray())}return e}}]),e}(),Qo=function(t){f(i,t);var n=m(i);function i(e,t,r){var a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return y(this,i),(a=n.call(this,e,t,r)).isInstancedBufferAttribute=!0,a.meshPerAttribute=o,a}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}},{key:"toJSON",value:function(){var t=c(e(i.prototype),"toJSON",this).call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}]),i}(Qn),$o=new nn,es=new nn,ts=[],ns=new Ct,is=new nn,rs=new wi,as=new qt,os=function(t){f(i,t);var n=m(i);function i(e,t,r){var a;y(this,i),(a=n.call(this,e,t)).isInstancedMesh=!0,a.instanceMatrix=new Qo(new Float32Array(16*r),16),a.instanceColor=null,a.count=r,a.boundingBox=null,a.boundingSphere=null;for(var o=0;o<r;o++)a.setMatrixAt(o,is);return a}return M(i,[{key:"computeBoundingBox",value:function(){var e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Ct),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(var n=0;n<t;n++)this.getMatrixAt(n,$o),ns.copy(e.boundingBox).applyMatrix4($o),this.boundingBox.union(ns)}},{key:"computeBoundingSphere",value:function(){var e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new qt),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(var n=0;n<t;n++)this.getMatrixAt(n,$o),as.copy(e.boundingSphere).applyMatrix4($o),this.boundingSphere.union(as)}},{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}},{key:"getColorAt",value:function(e,t){t.fromArray(this.instanceColor.array,3*e)}},{key:"getMatrixAt",value:function(e,t){t.fromArray(this.instanceMatrix.array,16*e)}},{key:"raycast",value:function(e,t){var n=this.matrixWorld,i=this.count;if(rs.geometry=this.geometry,rs.material=this.material,void 0!==rs.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),as.copy(this.boundingSphere),as.applyMatrix4(n),!1!==e.ray.intersectsSphere(as)))for(var r=0;r<i;r++){this.getMatrixAt(r,$o),es.multiplyMatrices(n,$o),rs.matrixWorld=es,rs.raycast(e,ts);for(var a=0,o=ts.length;a<o;a++){var s=ts[a];s.instanceId=r,s.object=this,t.push(s)}ts.length=0}}},{key:"setColorAt",value:function(e,t){null===this.instanceColor&&(this.instanceColor=new Qo(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}},{key:"setMatrixAt",value:function(e,t){t.toArray(this.instanceMatrix.array,16*e)}},{key:"updateMorphTargets",value:function(){}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}}]),i}(wi);var ss=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isLineBasicMaterial=!0,t.type="LineBasicMaterial",t.color=new Xn(16777215),t.map=null,t.linewidth=1,t.linecap="round",t.linejoin="round",t.fog=!0,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}]),i}(Yn),ls=new At,us=new At,cs=new nn,hs=new tn,ds=new qt,fs=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ui,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ss;return y(this,i),(e=n.call(this)).isLine=!0,e.type="Line",e.geometry=t,e.material=r,e.updateMorphTargets(),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}},{key:"computeLineDistances",value:function(){var e=this.geometry;if(null===e.index){for(var t=e.attributes.position,n=[0],i=1,r=t.count;i<r;i++)ls.fromBufferAttribute(t,i-1),us.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ls.distanceTo(us);e.setAttribute("lineDistance",new ti(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},{key:"raycast",value:function(e,t){var n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ds.copy(n.boundingSphere),ds.applyMatrix4(i),ds.radius+=r,!1!==e.ray.intersectsSphere(ds)){cs.copy(i).invert(),hs.copy(e.ray).applyMatrix4(cs);var o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,l=new At,u=new At,c=new At,h=new At,d=this.isLineSegments?2:1,f=n.index,p=n.attributes.position;if(null!==f)for(var m=Math.max(0,a.start),v=Math.min(f.count,a.start+a.count)-1;m<v;m+=d){var g=f.getX(m),_=f.getX(m+1);if(l.fromBufferAttribute(p,g),u.fromBufferAttribute(p,_),!(hs.distanceSqToSegment(l,u,h,c)>s)){h.applyMatrix4(this.matrixWorld);var y=e.ray.origin.distanceTo(h);y<e.near||y>e.far||t.push({distance:y,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else for(var x=Math.max(0,a.start),M=Math.min(p.count,a.start+a.count)-1;x<M;x+=d){if(l.fromBufferAttribute(p,x),u.fromBufferAttribute(p,x+1),!(hs.distanceSqToSegment(l,u,h,c)>s)){h.applyMatrix4(this.matrixWorld);var S=e.ray.origin.distanceTo(h);S<e.near||S>e.far||t.push({distance:S,point:c.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}}},{key:"updateMorphTargets",value:function(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,r=n.length;i<r;i++){var a=n[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=i}}}}}]),i}(Rn),ps=new At,ms=new At,vs=function(e){f(n,e);var t=m(n);function n(e,i){var r;return y(this,n),(r=t.call(this,e,i)).isLineSegments=!0,r.type="LineSegments",r}return M(n,[{key:"computeLineDistances",value:function(){var e=this.geometry;if(null===e.index){for(var t=e.attributes.position,n=[],i=0,r=t.count;i<r;i+=2)ps.fromBufferAttribute(t,i),ms.fromBufferAttribute(t,i+1),n[i]=0===i?0:n[i-1],n[i+1]=n[i]+ps.distanceTo(ms);e.setAttribute("lineDistance",new ti(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}]),n}(fs),gs=function(e){f(n,e);var t=m(n);function n(e,i){var r;return y(this,n),(r=t.call(this,e,i)).isLineLoop=!0,r.type="LineLoop",r}return M(n)}(fs),_s=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isPointsMaterial=!0,t.type="PointsMaterial",t.color=new Xn(16777215),t.map=null,t.alphaMap=null,t.size=1,t.sizeAttenuation=!0,t.fog=!0,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}]),i}(Yn),ys=new nn,xs=new tn,Ms=new qt,Ss=new At,Es=function(t){f(i,t);var n=m(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ui,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new _s;return y(this,i),(e=n.call(this)).isPoints=!0,e.type="Points",e.geometry=t,e.material=r,e.updateMorphTargets(),e}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}},{key:"raycast",value:function(e,t){var n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ms.copy(n.boundingSphere),Ms.applyMatrix4(i),Ms.radius+=r,!1!==e.ray.intersectsSphere(Ms)){ys.copy(i).invert(),xs.copy(e.ray).applyMatrix4(ys);var o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,l=n.index,u=n.attributes.position;if(null!==l)for(var c=Math.max(0,a.start),h=Math.min(l.count,a.start+a.count);c<h;c++){var d=l.getX(c);Ss.fromBufferAttribute(u,d),Ts(Ss,d,s,i,e,t,this)}else for(var f=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);f<p;f++)Ss.fromBufferAttribute(u,f),Ts(Ss,f,s,i,e,t,this)}}},{key:"updateMorphTargets",value:function(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var i=0,r=n.length;i<r;i++){var a=n[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=i}}}}}]),i}(Rn);function Ts(e,t,n,i,r,a,o){var s=xs.distanceSqToPoint(e);if(s<n){var l=new At;xs.closestPointToPoint(e,l),l.applyMatrix4(i);var u=r.ray.origin.distanceTo(l);if(u<r.near||u>r.far)return;a.push({distance:u,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:o})}}var bs=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isMeshStandardMaterial=!0,t.defines={STANDARD:""},t.type="MeshStandardMaterial",t.color=new Xn(16777215),t.roughness=1,t.metalness=0,t.map=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.emissive=new Xn(0),t.emissiveIntensity=1,t.emissiveMap=null,t.bumpMap=null,t.bumpScale=1,t.normalMap=null,t.normalMapType=0,t.normalScale=new $e(1,1),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.roughnessMap=null,t.metalnessMap=null,t.alphaMap=null,t.envMap=null,t.envMapIntensity=1,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.flatShading=!1,t.fog=!0,t.setValues(e),t}return M(i,[{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}]),i}(Yn),As=function(t){f(i,t);var n=m(i);function i(e){var t;return y(this,i),(t=n.call(this)).isMeshPhysicalMaterial=!0,t.defines={STANDARD:"",PHYSICAL:""},t.type="MeshPhysicalMaterial",t.anisotropyRotation=0,t.anisotropyMap=null,t.clearcoatMap=null,t.clearcoatRoughness=0,t.clearcoatRoughnessMap=null,t.clearcoatNormalScale=new $e(1,1),t.clearcoatNormalMap=null,t.ior=1.5,Object.defineProperty(d(t),"reflectivity",{get:function(){return Xe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),t.iridescenceMap=null,t.iridescenceIOR=1.3,t.iridescenceThicknessRange=[100,400],t.iridescenceThicknessMap=null,t.sheenColor=new Xn(0),t.sheenColorMap=null,t.sheenRoughness=1,t.sheenRoughnessMap=null,t.transmissionMap=null,t.thickness=0,t.thicknessMap=null,t.attenuationDistance=1/0,t.attenuationColor=new Xn(1,1,1),t.specularIntensity=1,t.specularIntensityMap=null,t.specularColor=new Xn(1,1,1),t.specularColorMap=null,t._anisotropy=0,t._clearcoat=0,t._iridescence=0,t._sheen=0,t._transmission=0,t.setValues(e),t}return M(i,[{key:"anisotropy",get:function(){return this._anisotropy},set:function(e){this._anisotropy>0!==e>0&&this.version++,this._anisotropy=e}},{key:"clearcoat",get:function(){return this._clearcoat},set:function(e){this._clearcoat>0!==e>0&&this.version++,this._clearcoat=e}},{key:"iridescence",get:function(){return this._iridescence},set:function(e){this._iridescence>0!==e>0&&this.version++,this._iridescence=e}},{key:"sheen",get:function(){return this._sheen},set:function(e){this._sheen>0!==e>0&&this.version++,this._sheen=e}},{key:"transmission",get:function(){return this._transmission},set:function(e){this._transmission>0!==e>0&&this.version++,this._transmission=e}},{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=h(t.iridescenceThicknessRange),this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}]),i}(bs);function ws(e,t,n){return!e||!n&&e.constructor===t?e:"number"===typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Rs(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Cs(e){for(var t=e.length,n=new Array(t),i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n}function Ls(e,t,n){for(var i=e.length,r=new e.constructor(i),a=0,o=0;o!==i;++a)for(var s=n[a]*t,l=0;l!==t;++l)r[o++]=e[s+l];return r}function Ps(e,t,n,i){for(var r=1,a=e[0];void 0!==a&&void 0===a[i];)a=e[r++];if(void 0!==a){var o=a[i];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[i])&&(t.push(a.time),n.push.apply(n,o)),a=e[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[i])&&(t.push(a.time),o.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{void 0!==(o=a[i])&&(t.push(a.time),n.push(o)),a=e[r++]}while(void 0!==a)}}var Us=function(){function e(t,n,i,r){y(this,e),this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}return M(e,[{key:"evaluate",value:function(e){var t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{var a;n:{i:if(!(e<i)){for(var o=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,e<(i=t[++n]))break t}a=t.length;break n}if(e>=r)break e;var s=t[1];e<s&&(n=2,r=s);for(var l=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,e>=(r=t[--n-1]))break t}a=n,n=0}for(;n<a;){var u=n+a>>>1;e<t[u]?a=u:n=u+1}if(i=t[n],void 0===(r=t[n-1]))return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}},{key:"getSettings_",value:function(){return this.settings||this.DefaultSettings_}},{key:"copySampleValue_",value:function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i,a=0;a!==i;++a)t[a]=n[r+a];return t}},{key:"interpolate_",value:function(){throw new Error("call to abstract method")}},{key:"intervalChanged_",value:function(){}}]),e}(),ks=function(e){f(n,e);var t=m(n);function n(e,i,r,a){var o;return y(this,n),(o=t.call(this,e,i,r,a))._weightPrev=-0,o._offsetPrev=-0,o._weightNext=-0,o._offsetNext=-0,o.DefaultSettings_={endingStart:ye,endingEnd:ye},o}return M(n,[{key:"intervalChanged_",value:function(e,t,n){var i=this.parameterPositions,r=e-2,a=e+1,o=i[r],s=i[a];if(void 0===o)switch(this.getSettings_().endingStart){case xe:r=e,o=2*t-n;break;case Me:o=t+i[r=i.length-2]-i[r+1];break;default:r=e,o=n}if(void 0===s)switch(this.getSettings_().endingEnd){case xe:a=e,s=2*n-t;break;case Me:a=1,s=n+i[1]-i[0];break;default:a=e-1,s=t}var l=.5*(n-t),u=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(s-n),this._offsetPrev=r*u,this._offsetNext=a*u}},{key:"interpolate_",value:function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,u=this._offsetPrev,c=this._offsetNext,h=this._weightPrev,d=this._weightNext,f=(n-t)/(i-t),p=f*f,m=p*f,v=-h*m+2*h*p-h*f,g=(1+h)*m+(-1.5-2*h)*p+(-.5+h)*f+1,_=(-1-d)*m+(1.5+d)*p+.5*f,y=d*m-d*p,x=0;x!==o;++x)r[x]=v*a[u+x]+g*a[l+x]+_*a[s+x]+y*a[c+x];return r}}]),n}(Us),Is=function(e){f(n,e);var t=m(n);function n(e,i,r,a){return y(this,n),t.call(this,e,i,r,a)}return M(n,[{key:"interpolate_",value:function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,u=(n-t)/(i-t),c=1-u,h=0;h!==o;++h)r[h]=a[l+h]*c+a[s+h]*u;return r}}]),n}(Us),Ns=function(e){f(n,e);var t=m(n);function n(e,i,r,a){return y(this,n),t.call(this,e,i,r,a)}return M(n,[{key:"interpolate_",value:function(e){return this.copySampleValue_(e-1)}}]),n}(Us),Ds=function(){function e(t,n,i,r){if(y(this,e),void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===n||0===n.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ws(n,this.TimeBufferType),this.values=ws(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}return M(e,[{key:"InterpolantFactoryMethodDiscrete",value:function(e){return new Ns(this.times,this.values,this.getValueSize(),e)}},{key:"InterpolantFactoryMethodLinear",value:function(e){return new Is(this.times,this.values,this.getValueSize(),e)}},{key:"InterpolantFactoryMethodSmooth",value:function(e){return new ks(this.times,this.values,this.getValueSize(),e)}},{key:"setInterpolation",value:function(e){var t;switch(e){case ve:t=this.InterpolantFactoryMethodDiscrete;break;case ge:t=this.InterpolantFactoryMethodLinear;break;case _e:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(n);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}},{key:"getInterpolation",value:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ve;case this.InterpolantFactoryMethodLinear:return ge;case this.InterpolantFactoryMethodSmooth:return _e}}},{key:"getValueSize",value:function(){return this.values.length/this.times.length}},{key:"shift",value:function(e){if(0!==e)for(var t=this.times,n=0,i=t.length;n!==i;++n)t[n]+=e;return this}},{key:"scale",value:function(e){if(1!==e)for(var t=this.times,n=0,i=t.length;n!==i;++n)t[n]*=e;return this}},{key:"trim",value:function(e,t){for(var n=this.times,i=n.length,r=0,a=i-1;r!==i&&n[r]<e;)++r;for(;-1!==a&&n[a]>t;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}},{key:"validate",value:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==r;o++){var s=n[o];if("number"===typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==i&&Rs(i))for(var l=0,u=i.length;l!==u;++l){var c=i[l];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,c),e=!1;break}}return e}},{key:"optimize",value:function(){for(var e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===_e,r=e.length-1,a=1,o=1;o<r;++o){var s=!1,l=e[o];if(l!==e[o+1]&&(1!==o||l!==e[0]))if(i)s=!0;else for(var u=o*n,c=u-n,h=u+n,d=0;d!==n;++d){var f=t[u+d];if(f!==t[c+d]||f!==t[h+d]){s=!0;break}}if(s){if(o!==a){e[a]=e[o];for(var p=o*n,m=a*n,v=0;v!==n;++v)t[m+v]=t[p+v]}++a}}if(r>0){e[a]=e[r];for(var g=r*n,_=a*n,y=0;y!==n;++y)t[_+y]=t[g+y];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}},{key:"clone",value:function(){var e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}],[{key:"toJSON",value:function(e){var t,n=e.constructor;if(n.toJSON!==this.toJSON)t=n.toJSON(e);else{t={name:e.name,times:ws(e.times,Array),values:ws(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t}}]),e}();Ds.prototype.TimeBufferType=Float32Array,Ds.prototype.ValueBufferType=Float32Array,Ds.prototype.DefaultInterpolation=ge;var Os=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Ds);Os.prototype.ValueTypeName="bool",Os.prototype.ValueBufferType=Array,Os.prototype.DefaultInterpolation=ve,Os.prototype.InterpolantFactoryMethodLinear=void 0,Os.prototype.InterpolantFactoryMethodSmooth=void 0;var Fs=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Ds);Fs.prototype.ValueTypeName="color";var Bs=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Ds);Bs.prototype.ValueTypeName="number";var zs=function(e){f(n,e);var t=m(n);function n(e,i,r,a){return y(this,n),t.call(this,e,i,r,a)}return M(n,[{key:"interpolate_",value:function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(i-t),l=e*o,u=l+o;l!==u;l+=4)bt.slerpFlat(r,0,a,l-o,a,l,s);return r}}]),n}(Us),Hs=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n,[{key:"InterpolantFactoryMethodLinear",value:function(e){return new zs(this.times,this.values,this.getValueSize(),e)}}]),n}(Ds);Hs.prototype.ValueTypeName="quaternion",Hs.prototype.DefaultInterpolation=ge,Hs.prototype.InterpolantFactoryMethodSmooth=void 0;var Gs=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Ds);Gs.prototype.ValueTypeName="string",Gs.prototype.ValueBufferType=Array,Gs.prototype.DefaultInterpolation=ve,Gs.prototype.InterpolantFactoryMethodLinear=void 0,Gs.prototype.InterpolantFactoryMethodSmooth=void 0;var Vs=function(e){f(n,e);var t=m(n);function n(){return y(this,n),t.apply(this,arguments)}return M(n)}(Ds);Vs.prototype.ValueTypeName="vector";var Ws=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Se;y(this,e),this.name=t,this.tracks=i,this.duration=n,this.blendMode=r,this.uuid=We(),this.duration<0&&this.resetDuration()}return M(e,[{key:"resetDuration",value:function(){for(var e=0,t=0,n=this.tracks.length;t!==n;++t){var i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}},{key:"trim",value:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}},{key:"validate",value:function(){for(var e=!0,t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}},{key:"optimize",value:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}},{key:"clone",value:function(){for(var e=[],t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}},{key:"toJSON",value:function(){return this.constructor.toJSON(this)}}],[{key:"parse",value:function(e){for(var t=[],n=e.tracks,i=1/(e.fps||1),r=0,a=n.length;r!==a;++r)t.push(Xs(n[r]).scale(i));var o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}},{key:"toJSON",value:function(e){for(var t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode},r=0,a=n.length;r!==a;++r)t.push(Ds.toJSON(n[r]));return i}},{key:"CreateFromMorphTargetSequence",value:function(e,t,n,i){for(var r=t.length,a=[],o=0;o<r;o++){var s=[],l=[];s.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);var u=Cs(s);s=Ls(s,1,u),l=Ls(l,1,u),i||0!==s[0]||(s.push(r),l.push(l[0])),a.push(new Bs(".morphTargetInfluences["+t[o].name+"]",s,l).scale(1/n))}return new this(e,-1,a)}},{key:"findByName",value:function(e,t){var n=e;if(!Array.isArray(e)){var i=e;n=i.geometry&&i.geometry.animations||i.animations}for(var r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}},{key:"CreateClipsFromMorphTargetSequences",value:function(e,t,n){for(var i={},r=/^([\w-]*?)([\d]+)$/,a=0,o=e.length;a<o;a++){var s=e[a],l=s.name.match(r);if(l&&l.length>1){var u=l[1],c=i[u];c||(i[u]=c=[]),c.push(s)}}var h=[];for(var d in i)h.push(this.CreateFromMorphTargetSequence(d,i[d],t,n));return h}},{key:"parseAnimation",value:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var a=[],o=[];Ps(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode,s=e.length||-1,l=e.hierarchy||[],u=0;u<l.length;u++){var c=l[u].keys;if(c&&0!==c.length)if(c[0].morphTargets){var h={},d=void 0;for(d=0;d<c.length;d++)if(c[d].morphTargets)for(var f=0;f<c[d].morphTargets.length;f++)h[c[d].morphTargets[f]]=-1;for(var p in h){for(var m=[],v=[],g=0;g!==c[d].morphTargets.length;++g){var _=c[d];m.push(_.time),v.push(_.morphTarget===p?1:0)}i.push(new Bs(".morphTargetInfluence["+p+"]",m,v))}s=h.length*a}else{var y=".bones["+t[u].name+"]";n(Vs,y+".position",c,"pos",i),n(Hs,y+".quaternion",c,"rot",i),n(Vs,y+".scale",c,"scl",i)}}return 0===i.length?null:new this(r,s,i,o)}}]),e}();function Xs(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bs;case"vector":case"vector2":case"vector3":case"vector4":return Vs;case"color":return Fs;case"quaternion":return Hs;case"bool":case"boolean":return Os;case"string":return Gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){var n=[],i=[];Ps(e.keys,n,i,"value"),e.times=n,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var js={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},qs=M((function e(t,n,i){y(this,e);var r=this,a=!1,o=0,s=0,l=void 0,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=n,this.onError=i,this.itemStart=function(e){s++,!1===a&&void 0!==r.onStart&&r.onStart(e,o,s),a=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,s),o===s&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return l?l(e):e},this.setURLModifier=function(e){return l=e,this},this.addHandler=function(e,t){return u.push(e,t),this},this.removeHandler=function(e){var t=u.indexOf(e);return-1!==t&&u.splice(t,2),this},this.getHandler=function(e){for(var t=0,n=u.length;t<n;t+=2){var i=u[t],r=u[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return r}return null}})),Ys=new qs,Ks=function(){function e(t){y(this,e),this.manager=void 0!==t?t:Ys,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}return M(e,[{key:"load",value:function(){}},{key:"loadAsync",value:function(e,t){var n=this;return new Promise((function(i,r){n.load(e,i,t,r)}))}},{key:"parse",value:function(){}},{key:"setCrossOrigin",value:function(e){return this.crossOrigin=e,this}},{key:"setWithCredentials",value:function(e){return this.withCredentials=e,this}},{key:"setPath",value:function(e){return this.path=e,this}},{key:"setResourcePath",value:function(e){return this.resourcePath=e,this}},{key:"setRequestHeader",value:function(e){return this.requestHeader=e,this}}]),e}();Ks.DEFAULT_MATERIAL_NAME="__DEFAULT";var Zs={},Js=function(e){f(n,e);var t=m(n);function n(e,i){var r;return y(this,n),(r=t.call(this,e)).response=i,r}return M(n)}(r(Error)),Qs=function(e){f(n,e);var t=m(n);function n(e){return y(this,n),t.call(this,e)}return M(n,[{key:"load",value:function(e,t,n,i){var r=this;void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var a=js.get(e);if(void 0!==a)return this.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;if(void 0===Zs[e]){Zs[e]=[],Zs[e].push({onLoad:t,onProgress:n,onError:i});var o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,l=this.responseType;fetch(o).then((function(t){if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"===typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;var n=Zs[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,o=0!==a,s=0,l=new ReadableStream({start:function(e){!function t(){i.read().then((function(i){var r=i.done,l=i.value;if(r)e.close();else{s+=l.byteLength;for(var u=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a}),c=0,h=n.length;c<h;c++){var d=n[c];d.onProgress&&d.onProgress(u)}e.enqueue(l),t()}}))}()}});return new Response(l)}throw new Js('fetch for "'.concat(t.url,'" responded with ').concat(t.status,": ").concat(t.statusText),t)})).then((function(e){switch(l){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((function(e){return(new DOMParser).parseFromString(e,s)}));case"json":return e.json();default:if(void 0===s)return e.text();var t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((function(e){return i.decode(e)}))}})).then((function(t){js.add(e,t);var n=Zs[e];delete Zs[e];for(var i=0,r=n.length;i<r;i++){var a=n[i];a.onLoad&&a.onLoad(t)}})).catch((function(t){var n=Zs[e];if(void 0===n)throw r.manager.itemError(e),t;delete Zs[e];for(var i=0,a=n.length;i<a;i++){var o=n[i];o.onError&&o.onError(t)}r.manager.itemError(e)})).finally((function(){r.manager.itemEnd(e)})),this.manager.itemStart(e)}else Zs[e].push({onLoad:t,onProgress:n,onError:i})}},{key:"setResponseType",value:function(e){return this.responseType=e,this}},{key:"setMimeType",value:function(e){return this.mimeType=e,this}}]),n}(Ks),$s=function(e){f(n,e);var t=m(n);function n(e){return y(this,n),t.call(this,e)}return M(n,[{key:"load",value:function(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var r=this,a=js.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;var o=it("img");function s(){u(),js.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){u(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}]),n}(Ks),el=function(e){f(n,e);var t=m(n);function n(e){return y(this,n),t.call(this,e)}return M(n,[{key:"load",value:function(e,t,n,i){var r=new yt,a=new $s(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}]),n}(Ks),tl=function(t){f(i,t);var n=m(i);function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return y(this,i),(t=n.call(this)).isLight=!0,t.type="Light",t.color=new Xn(e),t.intensity=r,t}return M(i,[{key:"dispose",value:function(){}},{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.color.copy(t.color),this.intensity=t.intensity,this}},{key:"toJSON",value:function(t){var n=c(e(i.prototype),"toJSON",this).call(this,t);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,void 0!==this.groundColor&&(n.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(n.object.distance=this.distance),void 0!==this.angle&&(n.object.angle=this.angle),void 0!==this.decay&&(n.object.decay=this.decay),void 0!==this.penumbra&&(n.object.penumbra=this.penumbra),void 0!==this.shadow&&(n.object.shadow=this.shadow.toJSON()),n}}]),i}(Rn),nl=function(t){f(i,t);var n=m(i);function i(e,t,r){var a;return y(this,i),(a=n.call(this,e,r)).isHemisphereLight=!0,a.type="HemisphereLight",a.position.copy(Rn.DEFAULT_UP),a.updateMatrix(),a.groundColor=new Xn(t),a}return M(i,[{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.groundColor.copy(t.groundColor),this}}]),i}(tl),il=new nn,rl=new At,al=new At,ol=function(){function e(t){y(this,e),this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new $e(512,512),this.map=null,this.mapPass=null,this.matrix=new nn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qi,this._frameExtents=new $e(1,1),this._viewportCount=1,this._viewports=[new xt(0,0,1,1)]}return M(e,[{key:"getViewportCount",value:function(){return this._viewportCount}},{key:"getFrustum",value:function(){return this._frustum}},{key:"updateMatrices",value:function(e){var t=this.camera,n=this.matrix;rl.setFromMatrixPosition(e.matrixWorld),t.position.copy(rl),al.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(al),t.updateMatrixWorld(),il.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(il),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(il)}},{key:"getViewport",value:function(e){return this._viewports[e]}},{key:"getFrameExtents",value:function(){return this._frameExtents}},{key:"dispose",value:function(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}},{key:"copy",value:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"toJSON",value:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}]),e}(),sl=function(t){f(i,t);var n=m(i);function i(){var e;return y(this,i),(e=n.call(this,new Di(50,1,.5,500))).isSpotLightShadow=!0,e.focus=1,e}return M(i,[{key:"updateMatrices",value:function(t){var n=this.camera,r=2*Ve*t.angle*this.focus,a=this.mapSize.width/this.mapSize.height,o=t.distance||n.far;r===n.fov&&a===n.aspect&&o===n.far||(n.fov=r,n.aspect=a,n.far=o,n.updateProjectionMatrix()),c(e(i.prototype),"updateMatrices",this).call(this,t)}},{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.focus=t.focus,this}}]),i}(ol),ll=function(t){f(i,t);var n=m(i);function i(e,t){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Math.PI/3,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2;return y(this,i),(r=n.call(this,e,t)).isSpotLight=!0,r.type="SpotLight",r.position.copy(Rn.DEFAULT_UP),r.updateMatrix(),r.target=new Rn,r.distance=a,r.angle=o,r.penumbra=s,r.decay=l,r.map=null,r.shadow=new sl,r}return M(i,[{key:"power",get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}},{key:"dispose",value:function(){this.shadow.dispose()}},{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}]),i}(tl),ul=new nn,cl=new At,hl=new At,dl=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this,new Di(90,1,.5,500))).isPointLightShadow=!0,e._frameExtents=new $e(4,2),e._viewportCount=6,e._viewports=[new xt(2,1,1,1),new xt(0,1,1,1),new xt(3,1,1,1),new xt(1,1,1,1),new xt(3,0,1,1),new xt(1,0,1,1)],e._cubeDirections=[new At(1,0,0),new At(-1,0,0),new At(0,0,1),new At(0,0,-1),new At(0,1,0),new At(0,-1,0)],e._cubeUps=[new At(0,1,0),new At(0,1,0),new At(0,1,0),new At(0,1,0),new At(0,0,1),new At(0,0,-1)],e}return M(n,[{key:"updateMatrices",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),cl.setFromMatrixPosition(e.matrixWorld),n.position.copy(cl),hl.copy(n.position),hl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(hl),n.updateMatrixWorld(),i.makeTranslation(-cl.x,-cl.y,-cl.z),ul.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ul)}}]),n}(ol),fl=function(t){f(i,t);var n=m(i);function i(e,t){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;return y(this,i),(r=n.call(this,e,t)).isPointLight=!0,r.type="PointLight",r.distance=a,r.decay=o,r.shadow=new dl,r}return M(i,[{key:"power",get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}},{key:"dispose",value:function(){this.shadow.dispose()}},{key:"copy",value:function(t,n){return c(e(i.prototype),"copy",this).call(this,t,n),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}]),i}(tl),pl=function(e){f(n,e);var t=m(n);function n(){var e;return y(this,n),(e=t.call(this,new sr(-5,5,5,-5,.5,500))).isDirectionalLightShadow=!0,e}return M(n)}(ol),ml=function(t){f(i,t);var n=m(i);function i(e,t){var r;return y(this,i),(r=n.call(this,e,t)).isDirectionalLight=!0,r.type="DirectionalLight",r.position.copy(Rn.DEFAULT_UP),r.updateMatrix(),r.target=new Rn,r.shadow=new pl,r}return M(i,[{key:"dispose",value:function(){this.shadow.dispose()}},{key:"copy",value:function(t){return c(e(i.prototype),"copy",this).call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}]),i}(tl),vl=function(){function e(){y(this,e)}return M(e,null,[{key:"decodeText",value:function(e){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(r){return t}}},{key:"extractUrlBase",value:function(e){var t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}},{key:"resolveURL",value:function(e,t){return"string"!==typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}]),e}(),gl=function(e){f(n,e);var t=m(n);function n(e){var i;return y(this,n),(i=t.call(this,e)).isImageBitmapLoader=!0,"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),i.options={premultiplyAlpha:"none"},i}return M(n,[{key:"setOptions",value:function(e){return this.options=e,this}},{key:"load",value:function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var r=this,a=js.get(e);if(void 0!==a)return r.manager.itemStart(e),a.then?void a.then((function(n){t&&t(n),r.manager.itemEnd(e)})).catch((function(e){i&&i(e)})):(setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a);var o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader;var s=fetch(e,o).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return js.add(e,n),t&&t(n),r.manager.itemEnd(e),n})).catch((function(t){i&&i(t),js.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));js.add(e,s),r.manager.itemStart(e)}}]),n}(Ks);var _l="\\[\\]\\.:\\/",yl=new RegExp("["+_l+"]","g"),xl="[^"+_l+"]",Ml="[^"+_l.replace("\\.","")+"]",Sl=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",xl)+/(WCOD+)?/.source.replace("WCOD",Ml)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xl)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xl)+"$"),El=["material","materials","bones","map"],Tl=function(){function e(t,n,i){y(this,e);var r=i||bl.parseTrackName(n);this._targetGroup=t,this._bindings=t.subscribe_(n,r)}return M(e,[{key:"getValue",value:function(e,t){this.bind();var n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}},{key:"setValue",value:function(e,t){for(var n=this._bindings,i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}},{key:"bind",value:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}},{key:"unbind",value:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}]),e}(),bl=function(){function e(t,n,i){y(this,e),this.path=n,this.parsedPath=i||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}return M(e,[{key:"_getValue_unavailable",value:function(){}},{key:"_setValue_unavailable",value:function(){}},{key:"_getValue_direct",value:function(e,t){e[t]=this.targetObject[this.propertyName]}},{key:"_getValue_array",value:function(e,t){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)e[t++]=n[i]}},{key:"_getValue_arrayElement",value:function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}},{key:"_getValue_toArray",value:function(e,t){this.resolvedProperty.toArray(e,t)}},{key:"_setValue_direct",value:function(e,t){this.targetObject[this.propertyName]=e[t]}},{key:"_setValue_direct_setNeedsUpdate",value:function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}},{key:"_setValue_direct_setMatrixWorldNeedsUpdate",value:function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_array",value:function(e,t){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=e[t++]}},{key:"_setValue_array_setNeedsUpdate",value:function(e,t){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}},{key:"_setValue_array_setMatrixWorldNeedsUpdate",value:function(e,t){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_arrayElement",value:function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}},{key:"_setValue_arrayElement_setNeedsUpdate",value:function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}},{key:"_setValue_arrayElement_setMatrixWorldNeedsUpdate",value:function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_fromArray",value:function(e,t){this.resolvedProperty.fromArray(e,t)}},{key:"_setValue_fromArray_setNeedsUpdate",value:function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}},{key:"_setValue_fromArray_setMatrixWorldNeedsUpdate",value:function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_getValue_unbound",value:function(e,t){this.bind(),this.getValue(e,t)}},{key:"_setValue_unbound",value:function(e,t){this.bind(),this.setValue(e,t)}},{key:"bind",value:function(){var t=this.node,n=this.parsedPath,i=n.objectName,r=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(i){var o=n.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var s=0;s<t.length;s++)if(t[s].name===o){o=s;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==o){if(void 0===t[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[o]}}var l=t[r];if(void 0!==l){var u=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?u=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(u=this.Versioning.MatrixWorldNeedsUpdate);var c=this.BindingType.Direct;if(void 0!==a){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[a]&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=l,this.propertyIndex=a}else void 0!==l.fromArray&&void 0!==l.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=l):Array.isArray(l)?(c=this.BindingType.EntireArray,this.resolvedProperty=l):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][u]}else{var h=n.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",t)}}else console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".")}},{key:"unbind",value:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}],[{key:"create",value:function(t,n,i){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,i):new e(t,n,i)}},{key:"sanitizeNodeName",value:function(e){return e.replace(/\s/g,"_").replace(yl,"")}},{key:"parseTrackName",value:function(e){var t=Sl.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var r=n.nodeName.substring(i+1);-1!==El.indexOf(r)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}},{key:"findNode",value:function(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){var i=function e(n){for(var i=0;i<n.length;i++){var r=n[i];if(r.name===t||r.uuid===t)return r;var a=e(r.children);if(a)return a}return null}(e.children);if(i)return i}return null}}]),e}();bl.Composite=Tl,bl.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},bl.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},bl.prototype.GetterByBindingType=[bl.prototype._getValue_direct,bl.prototype._getValue_array,bl.prototype._getValue_arrayElement,bl.prototype._getValue_toArray],bl.prototype.SetterByBindingTypeAndVersioning=[[bl.prototype._setValue_direct,bl.prototype._setValue_direct_setNeedsUpdate,bl.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bl.prototype._setValue_array,bl.prototype._setValue_array_setNeedsUpdate,bl.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bl.prototype._setValue_arrayElement,bl.prototype._setValue_arrayElement_setNeedsUpdate,bl.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bl.prototype._setValue_fromArray,bl.prototype._setValue_fromArray_setNeedsUpdate,bl.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];new Float32Array(1);function Al(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){var n=e.getIndex();if(null===n){var i=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var a=0;a<r.count;a++)i.push(a);e.setIndex(i),n=e.getIndex()}var o=n.count-2,s=[];if(2===t)for(var l=1;l<=o;l++)s.push(n.getX(0)),s.push(n.getX(l)),s.push(n.getX(l+1));else for(var u=0;u<o;u++)u%2===0?(s.push(n.getX(u)),s.push(n.getX(u+1)),s.push(n.getX(u+2))):(s.push(n.getX(u+2)),s.push(n.getX(u+1)),s.push(n.getX(u)));s.length/3!==o&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var c=e.clone();return c.setIndex(s),c.clearGroups(),c}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:E}})),"undefined"!==typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=E);var wl=function(e){f(n,e);var t=m(n);function n(e){var i;return y(this,n),(i=t.call(this,e)).dracoLoader=null,i.ktx2Loader=null,i.meshoptDecoder=null,i.pluginCallbacks=[],i.register((function(e){return new kl(e)})),i.register((function(e){return new Gl(e)})),i.register((function(e){return new Vl(e)})),i.register((function(e){return new Wl(e)})),i.register((function(e){return new Nl(e)})),i.register((function(e){return new Dl(e)})),i.register((function(e){return new Ol(e)})),i.register((function(e){return new Fl(e)})),i.register((function(e){return new Ul(e)})),i.register((function(e){return new Bl(e)})),i.register((function(e){return new Il(e)})),i.register((function(e){return new Hl(e)})),i.register((function(e){return new zl(e)})),i.register((function(e){return new Ll(e)})),i.register((function(e){return new Xl(e)})),i.register((function(e){return new jl(e)})),i}return M(n,[{key:"load",value:function(e,t,n,i){var r,a=this;if(""!==this.resourcePath)r=this.resourcePath;else if(""!==this.path){var o=vl.extractUrlBase(e);r=vl.resolveURL(o,this.path)}else r=vl.extractUrlBase(e);this.manager.itemStart(e);var s=function(t){i?i(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)},l=new Qs(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(n){try{a.parse(n,r,(function(n){t(n),a.manager.itemEnd(e)}),s)}catch(i){s(i)}}),n,s)}},{key:"setDRACOLoader",value:function(e){return this.dracoLoader=e,this}},{key:"setDDSLoader",value:function(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}},{key:"setKTX2Loader",value:function(e){return this.ktx2Loader=e,this}},{key:"setMeshoptDecoder",value:function(e){return this.meshoptDecoder=e,this}},{key:"register",value:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}},{key:"unregister",value:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}},{key:"parse",value:function(e,t,n,i){var r,a={},o={},s=new TextDecoder;if("string"===typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===ql){try{a[Cl.KHR_BINARY_GLTF]=new Zl(e)}catch(p){return void(i&&i(p))}r=JSON.parse(a[Cl.KHR_BINARY_GLTF].content)}else r=JSON.parse(s.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{var l=new Mu(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(var u=0;u<this.pluginCallbacks.length;u++){var c=this.pluginCallbacks[u](l);c.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[c.name]=c,a[c.name]=!0}if(r.extensionsUsed)for(var h=0;h<r.extensionsUsed.length;++h){var d=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(d){case Cl.KHR_MATERIALS_UNLIT:a[d]=new Pl;break;case Cl.KHR_DRACO_MESH_COMPRESSION:a[d]=new Jl(r,this.dracoLoader);break;case Cl.KHR_TEXTURE_TRANSFORM:a[d]=new Ql;break;case Cl.KHR_MESH_QUANTIZATION:a[d]=new $l;break;default:f.indexOf(d)>=0&&void 0===o[d]&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,i)}}},{key:"parseAsync",value:function(e,t){var n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}]),n}(Ks);function Rl(){var e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var Cl={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Ll=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}return M(e,[{key:"_markDefs",value:function(){for(var e=this.parser,t=this.parser.json.nodes||[],n=0,i=t.length;n<i;n++){var r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}},{key:"_loadLight",value:function(e){var t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;var r,a=t.json,o=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],s=new Xn(16777215);void 0!==o.color&&s.setRGB(o.color[0],o.color[1],o.color[2],Ae);var l=void 0!==o.range?o.range:0;switch(o.type){case"directional":(r=new ml(s)).target.position.set(0,0,-1),r.add(r.target);break;case"point":(r=new fl(s)).distance=l;break;case"spot":(r=new ll(s)).distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,r.angle=o.spot.outerConeAngle,r.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,r.target.position.set(0,0,-1),r.add(r.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return r.position.set(0,0,0),r.decay=2,mu(r,o),void 0!==o.intensity&&(r.intensity=o.intensity),r.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(r),t.cache.add(n,i),i}},{key:"getDependency",value:function(e,t){if("light"===e)return this._loadLight(t)}},{key:"createNodeAttachment",value:function(e){var t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}]),e}(),Pl=function(){function e(){y(this,e),this.name=Cl.KHR_MATERIALS_UNLIT}return M(e,[{key:"getMaterialType",value:function(){return Kn}},{key:"extendParams",value:function(e,t,n){var i=[];e.color=new Xn(1,1,1),e.opacity=1;var r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){var a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Ae),e.opacity=a[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,be))}return Promise.all(i)}}]),e}(),Ul=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_EMISSIVE_STRENGTH}return M(e,[{key:"extendMaterialParams",value:function(e,t){var n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();var i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}]),e}(),kl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_CLEARCOAT}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){var o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new $e(o,o)}return Promise.all(r)}}]),e}(),Il=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_IRIDESCENCE}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(t.iridescenceIOR=a.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}]),e}(),Nl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_SHEEN}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[];t.sheenColor=new Xn(0,0,0),t.sheenRoughness=0,t.sheen=1;var a=i.extensions[this.name];if(void 0!==a.sheenColorFactor){var o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Ae)}return void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,be)),void 0!==a.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}]),e}(),Dl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_TRANSMISSION}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}]),e}(),Ol=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_VOLUME}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;var o=a.attenuationColor||[1,1,1];return t.attenuationColor=(new Xn).setRGB(o[0],o[1],o[2],Ae),Promise.all(r)}}]),e}(),Fl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_IOR}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();var i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}]),e}(),Bl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_SPECULAR}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));var o=a.specularColorFactor||[1,1,1];return t.specularColor=(new Xn).setRGB(o[0],o[1],o[2],Ae),void 0!==a.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,be)),Promise.all(r)}}]),e}(),zl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.EXT_MATERIALS_BUMP}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];return t.bumpScale=void 0!==a.bumpFactor?a.bumpFactor:1,void 0!==a.bumpTexture&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}]),e}(),Hl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_MATERIALS_ANISOTROPY}return M(e,[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?As:null}},{key:"extendMaterialParams",value:function(e,t){var n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();var r=[],a=i.extensions[this.name];return void 0!==a.anisotropyStrength&&(t.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(t.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}]),e}(),Gl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.KHR_TEXTURE_BASISU}return M(e,[{key:"loadTexture",value:function(e){var t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;var r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}]),e}(),Vl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.EXT_TEXTURE_WEBP,this.isSupported=null}return M(e,[{key:"loadTexture",value:function(e){var t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;var a=r.extensions[t],o=i.images[a.source],s=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(s=l)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}},{key:"detectSupport",value:function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}]),e}(),Wl=function(){function e(t){y(this,e),this.parser=t,this.name=Cl.EXT_TEXTURE_AVIF,this.isSupported=null}return M(e,[{key:"loadTexture",value:function(e){var t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;var a=r.extensions[t],o=i.images[a.source],s=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(s=l)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}},{key:"detectSupport",value:function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}]),e}(),Xl=function(){function e(t){y(this,e),this.name=Cl.EXT_MESHOPT_COMPRESSION,this.parser=t}return M(e,[{key:"loadBufferView",value:function(e){var t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){var i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(e){var t=i.byteOffset||0,n=i.byteLength||0,r=i.count,o=i.byteStride,s=new Uint8Array(e,t,n);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(r,o,s,i.mode,i.filter).then((function(e){return e.buffer})):a.ready.then((function(){var e=new ArrayBuffer(r*o);return a.decodeGltfBuffer(new Uint8Array(e),r,o,s,i.mode,i.filter),e}))}))}return null}}]),e}(),jl=function(){function e(t){y(this,e),this.name=Cl.EXT_MESH_GPU_INSTANCING,this.parser=t}return M(e,[{key:"createNodeMesh",value:function(e){var t=this,n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;var r,a=l(n.meshes[i.mesh].primitives);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(o.mode!==iu.TRIANGLES&&o.mode!==iu.TRIANGLE_STRIP&&o.mode!==iu.TRIANGLE_FAN&&void 0!==o.mode)return null}}catch(f){a.e(f)}finally{a.f()}var s=i.extensions[this.name].attributes,u=[],c={},h=function(e){u.push(t.parser.getDependency("accessor",s[e]).then((function(t){return c[e]=t,c[e]})))};for(var d in s)h(d);return u.length<1?null:(u.push(this.parser.createNodeMesh(e)),Promise.all(u).then((function(e){var n,i=e.pop(),r=i.isGroup?i.children:[i],a=e[0].count,o=[],s=l(r);try{for(s.s();!(n=s.n()).done;){for(var u=n.value,h=new nn,d=new At,p=new bt,m=new At(1,1,1),v=new os(u.geometry,u.material,a),g=0;g<a;g++)c.TRANSLATION&&d.fromBufferAttribute(c.TRANSLATION,g),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,g),c.SCALE&&m.fromBufferAttribute(c.SCALE,g),v.setMatrixAt(g,h.compose(d,p,m));for(var _ in c)if("_COLOR_0"===_){var y=c[_];v.instanceColor=new Qo(y.array,y.itemSize,y.normalized)}else"TRANSLATION"!==_&&"ROTATION"!==_&&"SCALE"!==_&&u.geometry.setAttribute(_,c[_]);Rn.prototype.copy.call(v,u),t.parser.assignFinalMaterial(v),o.push(v)}}catch(f){s.e(f)}finally{s.f()}return i.isGroup?(i.clear(),i.add.apply(i,o),i):o[0]})))}}]),e}(),ql="glTF",Yl=1313821514,Kl=5130562,Zl=M((function e(t){y(this,e),this.name=Cl.KHR_BINARY_GLTF,this.content=null,this.body=null;var n=new DataView(t,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==ql)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var r=this.header.length-12,a=new DataView(t,12),o=0;o<r;){var s=a.getUint32(o,!0);o+=4;var l=a.getUint32(o,!0);if(o+=4,l===Yl){var u=new Uint8Array(t,12+o,s);this.content=i.decode(u)}else if(l===Kl){var c=12+o;this.body=t.slice(c,c+s)}o+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),Jl=function(){function e(t,n){if(y(this,e),!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Cl.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=n,this.dracoLoader.preload()}return M(e,[{key:"decodePrimitive",value:function(e,t){var n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var u in a){var c=lu[u]||u.toLowerCase();o[c]=a[u]}for(var h in e.attributes){var d=lu[h]||h.toLowerCase();if(void 0!==a[h]){var f=n.accessors[e.attributes[h]],p=ru[f.componentType];l[d]=p.name,s[d]=!0===f.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t,n){i.decodeDracoFile(e,(function(e){for(var n in e.attributes){var i=e.attributes[n],r=s[n];void 0!==r&&(i.normalized=r)}t(e)}),o,l,Ae,n)}))}))}}]),e}(),Ql=function(){function e(){y(this,e),this.name=Cl.KHR_TEXTURE_TRANSFORM}return M(e,[{key:"extendTexture",value:function(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}]),e}(),$l=M((function e(){y(this,e),this.name=Cl.KHR_MESH_QUANTIZATION})),eu=function(e){f(n,e);var t=m(n);function n(e,i,r,a){return y(this,n),t.call(this,e,i,r,a)}return M(n,[{key:"copySampleValue_",value:function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i,a=0;a!==i;a++)t[a]=n[r+a];return t}},{key:"interpolate_",value:function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,u=i-t,c=(n-t)/u,h=c*c,d=h*c,f=e*l,p=f-l,m=-2*d+3*h,v=d-h,g=1-m,_=v-h+c,y=0;y!==o;y++){var x=a[p+y+o],M=a[p+y+s]*u,S=a[f+y+o],E=a[f+y]*u;r[y]=g*x+_*M+m*S+v*E}return r}}]),n}(Us),tu=new bt,nu=function(t){f(i,t);var n=m(i);function i(){return y(this,i),n.apply(this,arguments)}return M(i,[{key:"interpolate_",value:function(t,n,r,a){var o=c(e(i.prototype),"interpolate_",this).call(this,t,n,r,a);return tu.fromArray(o).normalize().toArray(o),o}}]),i}(eu),iu={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ru={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},au={9728:K,9729:Q,9984:Z,9985:$,9986:J,9987:ee},ou={33071:q,33648:Y,10497:j},su={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},lu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},uu={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},cu={CUBICSPLINE:void 0,LINEAR:ge,STEP:ve},hu="OPAQUE",du="MASK",fu="BLEND";function pu(e,t,n){for(var i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function mu(e,t){void 0!==t.extras&&("object"===typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function vu(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){var r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(var a=0,o=r.length;a<o;a++)e.morphTargetDictionary[r[a]]=a}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function gu(e){var t,n=e.extensions&&e.extensions[Cl.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+_u(n.attributes):e.indices+":"+_u(e.attributes)+":"+e.mode,void 0!==e.targets)for(var i=0,r=e.targets.length;i<r;i++)t+=":"+_u(e.targets[i]);return t}function _u(e){for(var t="",n=Object.keys(e).sort(),i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function yu(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}var xu=new nn,Mu=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y(this,e),this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new Rl,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};var i=!1,r=!1,a=-1;"undefined"!==typeof navigator&&(i=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),a=(r=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"===typeof createImageBitmap||i||r&&a<98?this.textureLoader=new el(this.options.manager):this.textureLoader=new gl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Qs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}return M(e,[{key:"setExtensions",value:function(e){this.extensions=e}},{key:"setPlugins",value:function(e){this.plugins=e}},{key:"parse",value:function(e,t){var n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){var a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return pu(r,a,i),mu(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}},{key:"_markDefs",value:function(){for(var e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[],i=0,r=t.length;i<r;i++)for(var a=t[i].joints,o=0,s=a.length;o<s;o++)e[a[o]].isBone=!0;for(var l=0,u=e.length;l<u;l++){var c=e[l];void 0!==c.mesh&&(this._addNodeRef(this.meshCache,c.mesh),void 0!==c.skin&&(n[c.mesh].isSkinnedMesh=!0)),void 0!==c.camera&&this._addNodeRef(this.cameraCache,c.camera)}}},{key:"_addNodeRef",value:function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}},{key:"_getNodeRef",value:function(e,t,n){var i=this;if(e.refs[t]<=1)return n;var r=n.clone();return function e(t,n){var r=i.associations.get(t);null!=r&&i.associations.set(n,r);var a,o=l(t.children.entries());try{for(o.s();!(a=o.n()).done;){var s=u(a.value,2),c=s[0];e(s[1],n.children[c])}}catch(h){o.e(h)}finally{o.f()}}(n,r),r.name+="_instance_"+e.uses[t]++,r}},{key:"_invokeOne",value:function(e){var t=Object.values(this.plugins);t.push(this);for(var n=0;n<t.length;n++){var i=e(t[n]);if(i)return i}return null}},{key:"_invokeAll",value:function(e){var t=Object.values(this.plugins);t.unshift(this);for(var n=[],i=0;i<t.length;i++){var r=e(t[i]);r&&n.push(r)}return n}},{key:"getDependency",value:function(e,t){var n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(!(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}))))throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}},{key:"getDependencies",value:function(e){var t=this.cache.get(e);if(!t){var n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}},{key:"loadBuffer",value:function(e){var t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Cl.KHR_BINARY_GLTF].body);var i=this.options;return new Promise((function(e,r){n.load(vl.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}},{key:"loadBufferView",value:function(e){var t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}},{key:"loadAccessor",value:function(e){var t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){var r=su[i.type],a=ru[i.componentType],o=!0===i.normalized,s=new a(i.count*r);return Promise.resolve(new Qn(s,r,o))}var l=[];return void 0!==i.bufferView?l.push(this.getDependency("bufferView",i.bufferView)):l.push(null),void 0!==i.sparse&&(l.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),l.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(l).then((function(e){var r,a,o=e[0],s=su[i.type],l=ru[i.componentType],u=l.BYTES_PER_ELEMENT,c=u*s,h=i.byteOffset||0,d=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,f=!0===i.normalized;if(d&&d!==c){var p=Math.floor(h/d),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,v=t.cache.get(m);v||(r=new l(o,p*d,i.count*d/u),v=new Io(r,d/u),t.cache.add(m,v)),a=new Do(v,s,h%d/u,f)}else r=null===o?new l(i.count*s):new l(o,h,i.count*s),a=new Qn(r,s,f);if(void 0!==i.sparse){var g=su.SCALAR,_=ru[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,M=new _(e[1],y,i.sparse.count*g),S=new l(e[2],x,i.sparse.count*s);null!==o&&(a=new Qn(a.array.slice(),a.itemSize,a.normalized));for(var E=0,T=M.length;E<T;E++){var b=M[E];if(a.setX(b,S[E*s]),s>=2&&a.setY(b,S[E*s+1]),s>=3&&a.setZ(b,S[E*s+2]),s>=4&&a.setW(b,S[E*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))}},{key:"loadTexture",value:function(e){var t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i],a=this.textureLoader;if(r.uri){var o=n.manager.getHandler(r.uri);null!==o&&(a=o)}return this.loadTextureImage(e,i,a)}},{key:"loadTextureImage",value:function(e,t,n){var i=this,r=this.json,a=r.textures[e],o=r.images[t],s=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[s])return this.textureCache[s];var l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||o.name||"",""===t.name&&"string"===typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);var n=(r.samplers||{})[a.sampler]||{};return t.magFilter=au[n.magFilter]||Q,t.minFilter=au[n.minFilter]||ee,t.wrapS=ou[n.wrapS]||j,t.wrapT=ou[n.wrapT]||j,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}},{key:"loadImageSource",value:function(e,t){var n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((function(e){return e.clone()}));var r=n.images[e],a=self.URL||self.webkitURL,o=r.uri||"",s=!1;if(void 0!==r.bufferView)o=this.getDependency("bufferView",r.bufferView).then((function(e){s=!0;var t=new Blob([e],{type:r.mimeType});return o=a.createObjectURL(t)}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");var l=Promise.resolve(o).then((function(e){return new Promise((function(n,r){var a=n;!0===t.isImageBitmapLoader&&(a=function(e){var t=new yt(e);t.needsUpdate=!0,n(t)}),t.load(vl.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===s&&a.revokeObjectURL(o),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=l,l}},{key:"assignTexture",value:function(e,t,n,i){var r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Cl.KHR_TEXTURE_TRANSFORM]){var o=void 0!==n.extensions?n.extensions[Cl.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var s=r.associations.get(a);a=r.extensions[Cl.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,s)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}},{key:"assignFinalMaterial",value:function(e){var t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){var o="PointsMaterial:"+n.uuid,s=this.cache.get(o);s||(s=new _s,Yn.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,s.sizeAttenuation=!1,this.cache.add(o,s)),n=s}else if(e.isLine){var l="LineBasicMaterial:"+n.uuid,u=this.cache.get(l);u||(u=new ss,Yn.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(l,u)),n=u}if(i||r||a){var c="ClonedMaterial:"+n.uuid+":";i&&(c+="derivative-tangents:"),r&&(c+="vertex-colors:"),a&&(c+="flat-shading:");var h=this.cache.get(c);h||(h=n.clone(),r&&(h.vertexColors=!0),a&&(h.flatShading=!0),i&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(c,h),this.associations.set(h,this.associations.get(n))),n=h}e.material=n}},{key:"getMaterialType",value:function(){return bs}},{key:"loadMaterial",value:function(e){var t,n=this,i=this.json,r=this.extensions,a=i.materials[e],o={},s=[];if((a.extensions||{})[Cl.KHR_MATERIALS_UNLIT]){var l=r[Cl.KHR_MATERIALS_UNLIT];t=l.getMaterialType(),s.push(l.extendParams(o,a,n))}else{var u=a.pbrMetallicRoughness||{};if(o.color=new Xn(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){var c=u.baseColorFactor;o.color.setRGB(c[0],c[1],c[2],Ae),o.opacity=c[3]}void 0!==u.baseColorTexture&&s.push(n.assignTexture(o,"map",u.baseColorTexture,be)),o.metalness=void 0!==u.metallicFactor?u.metallicFactor:1,o.roughness=void 0!==u.roughnessFactor?u.roughnessFactor:1,void 0!==u.metallicRoughnessTexture&&(s.push(n.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),s.push(n.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),s.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===a.doubleSided&&(o.side=2);var h=a.alphaMode||hu;if(h===fu?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===du&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==Kn&&(s.push(n.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new $e(1,1),void 0!==a.normalTexture.scale)){var d=a.normalTexture.scale;o.normalScale.set(d,d)}if(void 0!==a.occlusionTexture&&t!==Kn&&(s.push(n.assignTexture(o,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==Kn){var f=a.emissiveFactor;o.emissive=(new Xn).setRGB(f[0],f[1],f[2],Ae)}return void 0!==a.emissiveTexture&&t!==Kn&&s.push(n.assignTexture(o,"emissiveMap",a.emissiveTexture,be)),Promise.all(s).then((function(){var i=new t(o);return a.name&&(i.name=a.name),mu(i,a),n.associations.set(i,{materials:e}),a.extensions&&pu(r,i,a),i}))}},{key:"createUniqueName",value:function(e){var t=bl.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}},{key:"loadGeometries",value:function(e){var t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Cl.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Su(n,e,t)}))}for(var a=[],o=0,s=e.length;o<s;o++){var l=e[o],u=gu(l),c=i[u];if(c)a.push(c.promise);else{var h=void 0;h=l.extensions&&l.extensions[Cl.KHR_DRACO_MESH_COMPRESSION]?r(l):Su(new ui,l,t),i[u]={primitive:l,promise:h},a.push(h)}}return Promise.all(a)}},{key:"loadMesh",value:function(e){for(var t,n=this,i=this.json,r=this.extensions,a=i.meshes[e],o=a.primitives,s=[],l=0,u=o.length;l<u;l++){var c=void 0===o[l].material?(void 0===(t=this.cache).DefaultMaterial&&(t.DefaultMaterial=new bs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:w})),t.DefaultMaterial):this.getDependency("material",o[l].material);s.push(c)}return s.push(n.loadGeometries(o)),Promise.all(s).then((function(t){for(var i=t.slice(0,t.length-1),s=t[t.length-1],l=[],u=0,c=s.length;u<c;u++){var h=s[u],d=o[u],f=void 0,p=i[u];if(d.mode===iu.TRIANGLES||d.mode===iu.TRIANGLE_STRIP||d.mode===iu.TRIANGLE_FAN||void 0===d.mode)!0===(f=!0===a.isSkinnedMesh?new jo(h,p):new wi(h,p)).isSkinnedMesh&&f.normalizeSkinWeights(),d.mode===iu.TRIANGLE_STRIP?f.geometry=Al(f.geometry,1):d.mode===iu.TRIANGLE_FAN&&(f.geometry=Al(f.geometry,2));else if(d.mode===iu.LINES)f=new vs(h,p);else if(d.mode===iu.LINE_STRIP)f=new fs(h,p);else if(d.mode===iu.LINE_LOOP)f=new gs(h,p);else{if(d.mode!==iu.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);f=new Es(h,p)}Object.keys(f.geometry.morphAttributes).length>0&&vu(f,a),f.name=n.createUniqueName(a.name||"mesh_"+e),mu(f,a),d.extensions&&pu(r,f,d),n.assignFinalMaterial(f),l.push(f)}for(var m=0,v=l.length;m<v;m++)n.associations.set(l[m],{meshes:e,primitives:m});if(1===l.length)return a.extensions&&pu(r,l[0],a),l[0];var g=new bo;a.extensions&&pu(r,g,a),n.associations.set(g,{meshes:e});for(var _=0,y=l.length;_<y;_++)g.add(l[_]);return g}))}},{key:"loadCamera",value:function(e){var t,n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new Di(Qe.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new sr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),mu(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}},{key:"loadSkin",value:function(e){for(var t=this.json.skins[e],n=[],i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){for(var n=e.pop(),i=e,r=[],a=[],o=0,s=i.length;o<s;o++){var l=i[o];if(l){r.push(l);var u=new nn;null!==n&&u.fromArray(n.array,16*o),a.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[o])}return new Jo(r,a)}))}},{key:"loadAnimation",value:function(e){for(var t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],s=[],l=[],u=[],c=0,h=i.channels.length;c<h;c++){var d=i.channels[c],f=i.samplers[d.sampler],p=d.target,m=p.node,v=void 0!==i.parameters?i.parameters[f.input]:f.input,g=void 0!==i.parameters?i.parameters[f.output]:f.output;void 0!==p.node&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",v)),s.push(this.getDependency("accessor",g)),l.push(f),u.push(p))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(l),Promise.all(u)]).then((function(e){for(var t=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=[],u=0,c=t.length;u<c;u++){var h=t[u],d=i[u],f=a[u],p=o[u],m=s[u];if(void 0!==h){h.updateMatrix&&h.updateMatrix();var v=n._createAnimationTracks(h,d,f,p,m);if(v)for(var g=0;g<v.length;g++)l.push(v[g])}}return new Ws(r,void 0,l)}))}},{key:"createNodeMesh",value:function(e){var t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){var t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(var t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}},{key:"loadNode",value:function(e){for(var t=this,n=this.json.nodes[e],i=t._loadNodeShallow(e),r=[],a=n.children||[],o=0,s=a.length;o<s;o++)r.push(t.getDependency("node",a[o]));var l=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),l]).then((function(e){var t=e[0],n=e[1],i=e[2];null!==i&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(i,xu)}));for(var r=0,a=n.length;r<a;r++)t.add(n[r]);return t}))}},{key:"_loadNodeShallow",value:function(e){var t=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];var r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],s=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return s&&o.push(s),void 0!==r.camera&&o.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){o.push(e)})),this.nodeCache[e]=Promise.all(o).then((function(t){var o;if((o=!0===r.isBone?new qo:t.length>1?new bo:1===t.length?t[0]:new Rn)!==t[0])for(var s=0,l=t.length;s<l;s++)o.add(t[s]);if(r.name&&(o.userData.name=r.name,o.name=a),mu(o,r),r.extensions&&pu(n,o,r),void 0!==r.matrix){var u=new nn;u.fromArray(r.matrix),o.applyMatrix4(u)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);return i.associations.has(o)||i.associations.set(o,{}),i.associations.get(o).nodes=e,o})),this.nodeCache[e]}},{key:"loadScene",value:function(e){var t=this.extensions,n=this.json.scenes[e],i=this,r=new bo;n.name&&(r.name=i.createUniqueName(n.name)),mu(r,n),n.extensions&&pu(t,r,n);for(var a=n.nodes||[],o=[],s=0,c=a.length;s<c;s++)o.push(i.getDependency("node",a[s]));return Promise.all(o).then((function(e){for(var t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=function(e){var t,n=new Map,r=l(i.associations);try{for(r.s();!(t=r.n()).done;){var a=u(t.value,2),o=a[0],s=a[1];(o instanceof Yn||o instanceof yt)&&n.set(o,s)}}catch(c){r.e(c)}finally{r.f()}return e.traverse((function(e){var t=i.associations.get(e);null!=t&&n.set(e,t)})),n}(r),r}))}},{key:"_createAnimationTracks",value:function(e,t,n,i,r){var a,o=[],s=e.name?e.name:e.uuid,l=[];switch(uu[r.path]===uu.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(s),uu[r.path]){case uu.weights:a=Bs;break;case uu.rotation:a=Hs;break;case uu.position:case uu.scale:a=Vs;break;default:if(1===n.itemSize)a=Bs;else a=Vs}for(var u=void 0!==i.interpolation?cu[i.interpolation]:ge,c=this._getArrayFromAccessor(n),h=0,d=l.length;h<d;h++){var f=new a(l[h]+"."+uu[r.path],t.array,c,u);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(f),o.push(f)}return o}},{key:"_getArrayFromAccessor",value:function(e){var t=e.array;if(e.normalized){for(var n=yu(t.constructor),i=new Float32Array(t.length),r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}},{key:"_createCubicSplineTrackInterpolant",value:function(e){e.createInterpolant=function(e){return new(this instanceof Hs?nu:eu)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}]),e}();function Su(e,t,n){var i=t.attributes,r=[];function a(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(var o in i){var s=lu[o]||o.toLowerCase();s in e.attributes||r.push(a(i[o],s))}if(void 0!==t.indices&&!e.index){var l=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(l)}return ht.workingColorSpace!==Ae&&"COLOR_0"in i&&console.warn('THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "'.concat(ht.workingColorSpace,'" not supported.')),mu(e,t),function(e,t,n){var i=t.attributes,r=new Ct;if(void 0!==i.POSITION){var a=n.json.accessors[i.POSITION],o=a.min,s=a.max;if(void 0!==o&&void 0!==s){if(r.set(new At(o[0],o[1],o[2]),new At(s[0],s[1],s[2])),a.normalized){var l=yu(ru[a.componentType]);r.min.multiplyScalar(l),r.max.multiplyScalar(l)}var u=t.targets;if(void 0!==u){for(var c=new At,h=new At,d=0,f=u.length;d<f;d++){var p=u[d];if(void 0!==p.POSITION){var m=n.json.accessors[p.POSITION],v=m.min,g=m.max;if(void 0!==v&&void 0!==g){if(h.setX(Math.max(Math.abs(v[0]),Math.abs(g[0]))),h.setY(Math.max(Math.abs(v[1]),Math.abs(g[1]))),h.setZ(Math.max(Math.abs(v[2]),Math.abs(g[2]))),m.normalized){var _=yu(ru[m.componentType]);h.multiplyScalar(_)}c.max(h)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(c)}e.boundingBox=r;var y=new qt;r.getCenter(y.center),y.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=y}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){for(var i=!1,r=!1,a=!1,o=0,s=t.length;o<s;o++){var l=t[o];if(void 0!==l.POSITION&&(i=!0),void 0!==l.NORMAL&&(r=!0),void 0!==l.COLOR_0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(e);for(var u=[],c=[],h=[],d=0,f=t.length;d<f;d++){var p=t[d];if(i){var m=void 0!==p.POSITION?n.getDependency("accessor",p.POSITION):e.attributes.position;u.push(m)}if(r){var v=void 0!==p.NORMAL?n.getDependency("accessor",p.NORMAL):e.attributes.normal;c.push(v)}if(a){var g=void 0!==p.COLOR_0?n.getDependency("accessor",p.COLOR_0):e.attributes.color;h.push(g)}}return Promise.all([Promise.all(u),Promise.all(c),Promise.all(h)]).then((function(t){var n=t[0],o=t[1],s=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const Eu=e=>{e.metalness&&(e.metalness=0)},Tu=e=>{if(e.material)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Eu(e.material[t]);else Eu(e.material)},bu="RENDER_MODEL",Au="RENDER_COMPLETE",wu="RENDER_ERROR",Ru="INIT";let Cu=null,Lu=null;self.onmessage=async e=>{const{type:t,resourceUrl:n}=e.data;try{switch(t){case Ru:const e=(Lu=new OffscreenCanvas(256,256),Cu=new Po({canvas:Lu,antialias:!0,alpha:!0}),Cu.useLegacyLights=!0,Cu.setSize(256,256,!1),!0);self.postMessage({type:Ru,success:e});break;case bu:if(!Cu)throw new Error("Renderer not initialized");const i=await(async e=>{if(!Cu)throw new Error("Renderer not initialized");const t=new ko,n=new nl;n.color=new Xn(1,1,1),n.groundColor=new Xn(.25,.25,.25),n.position.set(0,0,1);const i=new bo;return i.rotation.order="ZYX",i.rotation.x=Math.PI/4,i.add(n),t.add(i),new Promise(((n,i)=>{const r=new wl;var a;r.withCredentials=!(!(a=e).startsWith("https://project-resources.gdevelop.io/")&&!a.startsWith("https://project-resources-dev.gdevelop.io/")),r.load(e,(e=>{if(!Cu)throw new Error("Renderer not initialized");if(!Lu)throw new Error("Offscreen canvas not initialized");const i=e.scene;i.traverse(Tu);const r=new Ct,a=[];i.traverse((e=>{e.isMesh&&a.push(e)})),a.forEach((e=>{e.geometry.computeBoundingBox();const t=e.geometry.boundingBox.clone();t.applyMatrix4(e.matrixWorld),r.union(t)}));const o=new At,s=new At;r.getSize(o),r.getCenter(s);const l=1/Math.max(o.x,o.y,o.z);i.scale.set(l,l,l),i.position.x-=s.x*l,i.position.z-=s.z*l,i.position.y-=(s.y-o.y/2)*l,t.add(i);const u=new Di(45,1,.1,1e3);u.position.set(1*(.5+o.x*l),1*(.5+o.y*l),2*(.5+o.z*l)),u.lookAt(0,.5*o.y*l,0),Cu.render(t,u);const c=Lu.convertToBlob?Lu.convertToBlob().then((e=>URL.createObjectURL(e))):Promise.resolve(Cu.domElement.toDataURL());n(c)}),void 0,(e=>{i(e)}))}))})(n);self.postMessage({type:Au,resourceUrl:n,screenshot:i});break;default:console.warn("Unknown message type:",t)}}catch(i){self.postMessage({type:wu,resourceUrl:n,error:i.message||"Unknown error",originalEvent:JSON.stringify(e.data)})}}}();
//# sourceMappingURL=Resource3DPreview.worker.bf51c3b4bf3046ded6d1.worker.js.map