/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/three-umd-172@1.0.5/three.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).THREE=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n,i,r,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}function n(e){return function(){var n=this,i=arguments;return new Promise((function(r,a){var o=e.apply(n,i);function s(e){t(o,r,a,s,l,"next",e)}function l(e){t(o,r,a,s,l,"throw",e)}s(void 0)}))}}function i(e,t,n){return t=c(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,n||[],c(e).constructor):t.apply(e,n))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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,x(i.key),i)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=S(e))||t){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,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function l(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},u.apply(null,arguments)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(d=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(){v=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof y?t:y,o=Object.create(a.prototype),s=new I(i||[]);return r(o,"_invoke",{value:A(e,n,s)}),o}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var d="suspendedStart",f="suspendedYield",p="executing",m="completed",g={};function y(){}function _(){}function x(){}var M={};u(M,o,(function(){return this}));var S=Object.getPrototypeOf,b=S&&S(S(P([])));b&&b!==n&&i.call(b,o)&&(M=b);var T=x.prototype=y.prototype=Object.create(M);function E(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(r,a,o,s){var l=h(e[r],e,a);if("throw"!==l.type){var u=l.arg,c=u.value;return c&&"object"==typeof c&&i.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,o,s)}),(function(e){n("throw",e,o,s)})):t.resolve(c).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,s)}))}s(l.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function A(t,n,i){var r=d;return function(a,o){if(r===p)throw Error("Generator is already running");if(r===m){if("throw"===a)throw o;return{value:e,done:!0}}for(i.method=a,i.arg=o;;){var s=i.delegate;if(s){var l=R(s,i);if(l){if(l===g)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===d)throw r=m,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=p;var u=h(t,n,i);if("normal"===u.type){if(r=i.done?m:f,u.arg===g)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(r=m,i.method="throw",i.arg=u.arg)}}}function R(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var a=h(r,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var o=a.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function C(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return _.prototype=x,r(T,"constructor",{value:x,configurable:!0}),r(x,"constructor",{value:_,configurable:!0}),_.displayName=u(x,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,u(e,l,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},E(w.prototype),u(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,i,r,a){void 0===a&&(a=Promise);var o=new w(c(e,n,i,r),a);return t.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},E(T),u(T,l,"Generator"),u(T,o,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),t.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}},t.values=P,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return s.type="throw",s.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(l&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.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,g):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),g},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),k(n),g}},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;k(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:P(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),g}},t}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function g(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(e){u=!0,r=e}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 y(e,t,n,i){var r=u(c(e.prototype),t,n);return"function"==typeof r?function(e){return r.apply(n,e)}:r}function _(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||S(t)||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 x(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function M(e){return M="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},M(e)}function S(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(d())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var r=new(e.bind.apply(e,i));return n&&m(r,n.prototype),r}(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)},b(e)
/**
   * @license
   * Copyright 2010-2024 Three.js Authors
   * SPDX-License-Identifier: MIT
   */}var T="172",E=100,w=204,A=205,R="attached",C="detached",k=300,I=301,P=302,L=303,N=304,U=306,D=1e3,O=1001,F=1002,B=1003,z=1004,H=1005,V=1006,G=1007,W=1008,j=1009,X=1010,q=1011,Y=1012,Z=1013,K=1014,J=1015,Q=1016,$=1017,ee=1018,te=1020,ne=35902,ie=1021,re=1022,ae=1023,oe=1024,se=1025,le=1026,ue=1027,ce=1028,he=1029,de=1030,fe=1031,pe=1033,ve=33776,me=33777,ge=33778,ye=33779,_e=35840,xe=35841,Me=35842,Se=35843,be=36196,Te=37492,Ee=37496,we=37808,Ae=37809,Re=37810,Ce=37811,ke=37812,Ie=37813,Pe=37814,Le=37815,Ne=37816,Ue=37817,De=37818,Oe=37819,Fe=37820,Be=37821,ze=36492,He=36494,Ve=36495,Ge=36283,We=36284,je=36285,Xe=36286,qe=2300,Ye=2301,Ze=2302,Ke=2400,Je=2401,Qe=2402,$e=2500,et=2501,tt="",nt="srgb",it="srgb-linear",rt="linear",at="srgb",ot=7680,st=35044,lt="300 es",ut=2e3,ct=2001,ht=function(){return o((function e(){r(this,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}}}}])}(),dt=["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"],ft=1234567,pt=Math.PI/180,vt=180/Math.PI;function mt(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(dt[255&e]+dt[e>>8&255]+dt[e>>16&255]+dt[e>>24&255]+"-"+dt[255&t]+dt[t>>8&255]+"-"+dt[t>>16&15|64]+dt[t>>24&255]+"-"+dt[63&n|128]+dt[n>>8&255]+"-"+dt[n>>16&255]+dt[n>>24&255]+dt[255&i]+dt[i>>8&255]+dt[i>>16&255]+dt[i>>24&255]).toLowerCase()}function gt(e,t,n){return Math.max(t,Math.min(n,e))}function yt(e,t){return(e%t+t)%t}function _t(e,t,n){return(1-n)*e+n*t}function xt(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 Mt(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 St={DEG2RAD:pt,RAD2DEG:vt,generateUUID:mt,clamp:gt,euclideanModulo:yt,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:_t,damp:function(e,t,n,i){return _t(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(yt(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&&(ft=e);var t=ft+=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*pt},radToDeg:function(e){return e*vt},isPowerOfTwo:function(e){return!(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},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:Mt,denormalize:xt},bt=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,e),e.prototype.isVector2=!0,this.x=t,this.y=n}),[{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=gt(this.x,e.x,t.x),this.y=gt(this.y,e.y,t.y),this}},{key:"clampScalar",value:function(e,t){return this.x=gt(this.x,e,t),this.y=gt(this.y,e,t),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(gt(n,e,t))}},{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(gt(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:v().mark((function e(){return v().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)}))}])}(),Tt=function(){return o((function e(t,n,i,a,o,s,l,u,c){r(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,a,o,s,l,u,c)}),[{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],v=i[3],m=i[6],g=i[1],y=i[4],_=i[7],x=i[2],M=i[5],S=i[8];return r[0]=a*p+o*g+s*x,r[3]=a*v+o*y+s*M,r[6]=a*m+o*_+s*S,r[1]=l*p+u*g+c*x,r[4]=l*v+u*y+c*M,r[7]=l*m+u*_+c*S,r[2]=h*p+d*g+f*x,r[5]=h*v+d*y+f*M,r[8]=h*m+d*_+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(Et.makeScale(e,t)),this}},{key:"rotate",value:function(e){return this.premultiply(Et.makeRotation(-e)),this}},{key:"translate",value:function(e,t){return this.premultiply(Et.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)}}])}(),Et=new Tt;function wt(e){for(var t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var At={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Rt(e,t){return new At[e](t)}function Ct(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function kt(){var e=Ct("canvas");return e.style.display="block",e}var It={};function Pt(e){e in It||(It[e]=!0,console.warn(e))}function Lt(e,t,n){return new Promise((function(i,r){setTimeout((function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}}),n)}))}var Nt=(new Tt).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ut=(new Tt).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dt(){var e={enabled:!0,workingColorSpace:it,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===at&&(e.r=Bt(e.r),e.g=Bt(e.g),e.b=Bt(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===at&&(e.r=zt(e.r),e.g=zt(e.g),e.b=zt(e.b)),e):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 this.spaces[e].primaries},getTransfer:function(e){return e===tt?rt:this.spaces[e].transfer},getLuminanceCoefficients:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.workingColorSpace;return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.workingColorSpace;return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define(l(l({},it,{primaries:t,whitePoint:i,transfer:rt,toXYZ:Nt,fromXYZ:Ut,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:nt},outputColorSpaceConfig:{drawingBufferColorSpace:nt}}),nt,{primaries:t,whitePoint:i,transfer:at,toXYZ:Nt,fromXYZ:Ut,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:nt}})),e}var Ot,Ft=Dt();function Bt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function zt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var Ht=function(){return o((function e(){r(this,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=Ct("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=Ct("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*Bt(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*Bt(o[s]/255)):o[s]=Bt(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}}])}(),Vt=0,Gt=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;r(this,e),this.isSource=!0,Object.defineProperty(this,"id",{value:Vt++}),this.uuid=mt(),this.data=t,this.dataReady=!0,this.version=0}),[{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(Wt(i[a].image)):r.push(Wt(i[a]))}else r=Wt(i);n.url=r}return t||(e.images[this.uuid]=n),n}}])}();function Wt(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Ht.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 jt=0,Xt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.DEFAULT_IMAGE,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DEFAULT_MAPPING,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:O,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:O,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:V,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:W,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:ae,h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:j,d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:t.DEFAULT_ANISOTROPY,f=arguments.length>9&&void 0!==arguments[9]?arguments[9]:tt;return r(this,t),(e=i(this,t)).isTexture=!0,Object.defineProperty(e,"id",{value:jt++}),e.uuid=mt(),e.name="",e.source=new Gt(n),e.mipmaps=[],e.mapping=a,e.channel=0,e.wrapS=o,e.wrapT=s,e.magFilter=l,e.minFilter=u,e.anisotropy=d,e.format=c,e.internalFormat=null,e.type=h,e.offset=new bt(0,0),e.repeat=new bt(1,1),e.center=new bt(0,0),e.rotation=0,e.matrixAutoUpdate=!0,e.matrix=new Tt,e.generateMipmaps=!0,e.premultiplyAlpha=!1,e.flipY=!0,e.unpackAlignment=4,e.colorSpace=f,e.userData={},e.version=0,e.onUpdate=null,e.renderTarget=null,e.isRenderTargetTexture=!1,e.pmremVersion=0,e}return h(t,e),o(t,[{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.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,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(this.mapping!==k)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case D:e.x=e.x-Math.floor(e.x);break;case O:e.x=e.x<0?0:1;break;case F: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 D:e.y=e.y-Math.floor(e.y);break;case O:e.y=e.y<0?0:1;break;case F: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:"needsPMREMUpdate",set:function(e){!0===e&&this.pmremVersion++}}])}(ht);Xt.DEFAULT_IMAGE=null,Xt.DEFAULT_MAPPING=k,Xt.DEFAULT_ANISOTROPY=1;var qt=function(){return o((function e(){var t=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,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;r(this,e),e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=i,this.w=a}),[{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:"divide",value:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,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],v=s[6],m=s[10];if(Math.abs(u-h)<a&&Math.abs(c-p)<a&&Math.abs(f-v)<a){if(Math.abs(u+h)<o&&Math.abs(c+p)<o&&Math.abs(f+v)<o&&Math.abs(l+d+m-3)<o)return this.set(1,0,0,0),this;t=Math.PI;var g=(l+1)/2,y=(d+1)/2,_=(m+1)/2,x=(u+h)/4,M=(c+p)/4,S=(f+v)/4;return g>y&&g>_?g<a?(n=0,i=.707106781,r=.707106781):(i=x/(n=Math.sqrt(g)),r=M/n):y>_?y<a?(n=.707106781,i=0,r=.707106781):(n=x/(i=Math.sqrt(y)),r=S/i):_<a?(n=.707106781,i=.707106781,r=0):(n=M/(r=Math.sqrt(_)),i=S/r),this.set(n,i,r,t),this}var b=Math.sqrt((v-f)*(v-f)+(c-p)*(c-p)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(v-f)/b,this.y=(c-p)/b,this.z=(h-u)/b,this.w=Math.acos((l+d+m-1)/2),this}},{key:"setFromMatrixPosition",value:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=gt(this.x,e.x,t.x),this.y=gt(this.y,e.y,t.y),this.z=gt(this.z,e.z,t.z),this.w=gt(this.w,e.w,t.w),this}},{key:"clampScalar",value:function(e,t){return this.x=gt(this.x,e,t),this.y=gt(this.y,e,t),this.z=gt(this.z,e,t),this.w=gt(this.w,e,t),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(gt(n,e,t))}},{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:v().mark((function e(){return v().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)}))}])}(),Yt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r(this,t),(e=i(this,t)).isRenderTarget=!0,e.width=n,e.height=a,e.depth=1,e.scissor=new qt(0,0,n,a),e.scissorTest=!1,e.viewport=new qt(0,0,n,a);var s={width:n,height:a,depth:1};o=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:V,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},o);var l=new Xt(s,o.mapping,o.wrapS,o.wrapT,o.magFilter,o.minFilter,o.format,o.type,o.anisotropy,o.colorSpace);l.flipY=!1,l.generateMipmaps=o.generateMipmaps,l.internalFormat=o.internalFormat,e.textures=[];for(var u=o.count,c=0;c<u;c++)e.textures[c]=l.clone(),e.textures[c].isRenderTargetTexture=!0,e.textures[c].renderTarget=e;return e.depthBuffer=o.depthBuffer,e.stencilBuffer=o.stencilBuffer,e.resolveDepthBuffer=o.resolveDepthBuffer,e.resolveStencilBuffer=o.resolveStencilBuffer,e._depthTexture=null,e.depthTexture=o.depthTexture,e.samples=o.samples,e}return h(t,e),o(t,[{key:"texture",get:function(){return this.textures[0]},set:function(e){this.textures[0]=e}},{key:"depthTexture",get:function(){return this._depthTexture},set:function(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}},{key:"setSize",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(var i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].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.textures.length=0;for(var t=0,n=e.textures.length;t<n;t++)this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;var i=Object.assign({},e.texture.image);return this.texture.source=new Gt(i),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"})}}])}(ht),Zt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r(this,t),(e=i(this,t,[n,a,o])).isWebGLRenderTarget=!0,e}return h(t,e),o(t)}(Yt),Kt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return r(this,t),(e=i(this,t,[null])).isDataArrayTexture=!0,e.image={data:n,width:a,height:o,depth:s},e.magFilter=B,e.minFilter=B,e.wrapR=O,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e.layerUpdates=new Set,e}return h(t,e),o(t,[{key:"addLayerUpdate",value:function(e){this.layerUpdates.add(e)}},{key:"clearLayerUpdates",value:function(){this.layerUpdates.clear()}}])}(Xt),Jt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r(this,t),(e=i(this,t,[n,a,s])).isWebGLArrayRenderTarget=!0,e.depth=o,e.texture=new Kt(null,n,a,o),e.texture.isRenderTargetTexture=!0,e}return h(t,e),o(t)}(Zt),Qt=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return r(this,t),(e=i(this,t,[null])).isData3DTexture=!0,e.image={data:n,width:a,height:o,depth:s},e.magFilter=B,e.minFilter=B,e.wrapR=O,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return h(t,e),o(t)}(Xt),$t=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r(this,t),(e=i(this,t,[n,a,s])).isWebGL3DRenderTarget=!0,e.depth=o,e.texture=new Qt(null,n,a,o),e.texture.isRenderTargetTexture=!0,e}return h(t,e),o(t)}(Zt),en=function(){return o((function e(){var t=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,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;r(this,e),this.isQuaternion=!0,this._x=t,this._y=n,this._z=i,this._w=a}),[{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 v=2*Math.sqrt(1+c-n-o);this._w=(a-i)/v,this._x=(r+l)/v,this._y=(s+u)/v,this._z=.25*v}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(gt(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=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}},{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:v().mark((function e(){return v().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 v=1-o,m=s*h+l*d+u*f+c*p,g=m>=0?1:-1,y=1-m*m;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,m*g);v=Math.sin(v*x)/_,o=Math.sin(o*x)/_}var M=o*g;if(s=s*v+h*M,l=l*v+d*M,u=u*v+f*M,c=c*v+p*M,v===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}}])}(),tn=function(){return o((function e(){var t=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(this,e),e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=i}),[{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(rn.setFromEuler(e))}},{key:"applyAxisAngle",value:function(e,t){return this.applyQuaternion(rn.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=gt(this.x,e.x,t.x),this.y=gt(this.y,e.y,t.y),this.z=gt(this.z,e.z,t.z),this}},{key:"clampScalar",value:function(e,t){return this.x=gt(this.x,e,t),this.y=gt(this.y,e,t),this.z=gt(this.z,e,t),this}},{key:"clampLength",value:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(gt(n,e,t))}},{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 nn.copy(this).projectOnVector(e),this.sub(nn)}},{key:"reflect",value:function(e){return this.sub(nn.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(gt(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=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}},{key:Symbol.iterator,value:v().mark((function e(){return v().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)}))}])}(),nn=new tn,rn=new en,an=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn(1/0,1/0,1/0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn(-1/0,-1/0,-1/0);r(this,e),this.isBox3=!0,this.min=t,this.max=n}),[{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(sn.fromArray(e,t));return this}},{key:"setFromBufferAttribute",value:function(e){this.makeEmpty();for(var t=0,n=e.count;t<n;t++)this.expandByPoint(sn.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=sn.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,sn):sn.fromBufferAttribute(i,r),sn.applyMatrix4(e.matrixWorld),this.expandByPoint(sn);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),ln.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),ln.copy(n.boundingBox)),ln.applyMatrix4(e.matrixWorld),this.union(ln)}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,sn),sn.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(vn),mn.subVectors(this.max,vn),un.subVectors(e.a,vn),cn.subVectors(e.b,vn),hn.subVectors(e.c,vn),dn.subVectors(cn,un),fn.subVectors(hn,cn),pn.subVectors(un,hn);var t=[0,-dn.z,dn.y,0,-fn.z,fn.y,0,-pn.z,pn.y,dn.z,0,-dn.x,fn.z,0,-fn.x,pn.z,0,-pn.x,-dn.y,dn.x,0,-fn.y,fn.x,0,-pn.y,pn.x,0];return!!_n(t,un,cn,hn,mn)&&(!!_n(t=[1,0,0,0,1,0,0,0,1],un,cn,hn,mn)&&(gn.crossVectors(dn,fn),_n(t=[gn.x,gn.y,gn.z],un,cn,hn,mn)))}},{key:"clampPoint",value:function(e,t){return t.copy(e).clamp(this.min,this.max)}},{key:"distanceToPoint",value:function(e){return this.clampPoint(e,sn).distanceTo(e)}},{key:"getBoundingSphere",value:function(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(sn).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()||(on[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),on[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),on[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),on[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),on[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),on[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),on[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),on[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(on)),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)}}])}(),on=[new tn,new tn,new tn,new tn,new tn,new tn,new tn,new tn],sn=new tn,ln=new an,un=new tn,cn=new tn,hn=new tn,dn=new tn,fn=new tn,pn=new tn,vn=new tn,mn=new tn,gn=new tn,yn=new tn;function _n(e,t,n,i,r){for(var a=0,o=e.length-3;a<=o;a+=3){yn.fromArray(e,a);var s=r.x*Math.abs(yn.x)+r.y*Math.abs(yn.y)+r.z*Math.abs(yn.z),l=t.dot(yn),u=n.dot(yn),c=i.dot(yn);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>s)return!1}return!0}var xn=new an,Mn=new tn,Sn=new tn,bn=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;r(this,e),this.isSphere=!0,this.center=t,this.radius=n}),[{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):xn.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;Mn.subVectors(e,this.center);var t=Mn.lengthSq();if(t>this.radius*this.radius){var n=Math.sqrt(t),i=.5*(n-this.radius);this.center.addScaledVector(Mn,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):(Sn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mn.copy(e.center).add(Sn)),this.expandByPoint(Mn.copy(e.center).sub(Sn))),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)}}])}(),Tn=new tn,En=new tn,wn=new tn,An=new tn,Rn=new tn,Cn=new tn,kn=new tn,In=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn(0,0,-1);r(this,e),this.origin=t,this.direction=n}),[{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,Tn)),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=Tn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Tn.copy(this.origin).addScaledVector(this.direction,t),Tn.distanceToSquared(e))}},{key:"distanceSqToSegment",value:function(e,t,n,i){En.copy(e).add(t).multiplyScalar(.5),wn.copy(t).sub(e).normalize(),An.copy(this.origin).sub(En);var r,a,o,s,l=.5*e.distanceTo(t),u=-this.direction.dot(wn),c=An.dot(this.direction),h=-An.dot(wn),d=An.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(En).addScaledVector(wn,a),o}},{key:"intersectSphere",value:function(e,t){Tn.subVectors(e.center,this.origin);var n=Tn.dot(this.direction),i=Tn.dot(Tn)-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,Tn)}},{key:"intersectTriangle",value:function(e,t,n,i,r){Rn.subVectors(t,e),Cn.subVectors(n,e),kn.crossVectors(Rn,Cn);var a,o=this.direction.dot(kn);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}An.subVectors(this.origin,e);var s=a*this.direction.dot(Cn.crossVectors(An,Cn));if(s<0)return null;var l=a*this.direction.dot(Rn.cross(An));if(l<0)return null;if(s+l>o)return null;var u=-a*An.dot(kn);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)}}])}(),Pn=function(){function e(t,n,i,a,o,s,l,u,c,h,d,f,p,v,m,g){r(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,a,o,s,l,u,c,h,d,f,p,v,m,g)}return o(e,[{key:"set",value:function(e,t,n,i,r,a,o,s,l,u,c,h,d,f,p,v){var m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=s,m[2]=l,m[6]=u,m[10]=c,m[14]=h,m[3]=d,m[7]=f,m[11]=p,m[15]=v,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/Ln.setFromMatrixColumn(e,0).length(),r=1/Ln.setFromMatrixColumn(e,1).length(),a=1/Ln.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 v=s*u,m=s*c,g=l*u,y=l*c;t[0]=v+y*o,t[4]=g*o-m,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-o,t[2]=m*o-g,t[6]=y+v*o,t[10]=a*s}else if("ZXY"===e.order){var _=s*u,x=s*c,M=l*u,S=l*c;t[0]=_-S*o,t[4]=-a*c,t[8]=M+x*o,t[1]=x+M*o,t[5]=a*u,t[9]=S-_*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var b=a*u,T=a*c,E=o*u,w=o*c;t[0]=s*u,t[4]=E*l-T,t[8]=b*l+w,t[1]=s*c,t[5]=w*l+b,t[9]=T*l-E,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var A=a*s,R=a*l,C=o*s,k=o*l;t[0]=s*u,t[4]=k-A*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]=A-k*c}else if("XZY"===e.order){var I=a*s,P=a*l,L=o*s,N=o*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=I*c+N,t[5]=a*u,t[9]=P*c-L,t[2]=L*c-P,t[6]=o*u,t[10]=N*c+I}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(Un,e,Dn)}},{key:"lookAt",value:function(e,t,n){var i=this.elements;return Bn.subVectors(e,t),0===Bn.lengthSq()&&(Bn.z=1),Bn.normalize(),On.crossVectors(n,Bn),0===On.lengthSq()&&(1===Math.abs(n.z)?Bn.x+=1e-4:Bn.z+=1e-4,Bn.normalize(),On.crossVectors(n,Bn)),On.normalize(),Fn.crossVectors(Bn,On),i[0]=On.x,i[4]=Fn.x,i[8]=Bn.x,i[1]=On.y,i[5]=Fn.y,i[9]=Bn.y,i[2]=On.z,i[6]=Fn.z,i[10]=Bn.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],v=n[10],m=n[14],g=n[3],y=n[7],_=n[11],x=n[15],M=i[0],S=i[4],b=i[8],T=i[12],E=i[1],w=i[5],A=i[9],R=i[13],C=i[2],k=i[6],I=i[10],P=i[14],L=i[3],N=i[7],U=i[11],D=i[15];return r[0]=a*M+o*E+s*C+l*L,r[4]=a*S+o*w+s*k+l*N,r[8]=a*b+o*A+s*I+l*U,r[12]=a*T+o*R+s*P+l*D,r[1]=u*M+c*E+h*C+d*L,r[5]=u*S+c*w+h*k+d*N,r[9]=u*b+c*A+h*I+d*U,r[13]=u*T+c*R+h*P+d*D,r[2]=f*M+p*E+v*C+m*L,r[6]=f*S+p*w+v*k+m*N,r[10]=f*b+p*A+v*I+m*U,r[14]=f*T+p*R+v*P+m*D,r[3]=g*M+y*E+_*C+x*L,r[7]=g*S+y*w+_*k+x*N,r[11]=g*b+y*A+_*I+x*U,r[15]=g*T+y*R+_*P+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],v=e[14],m=e[15],g=c*v*l-p*h*l+p*s*d-o*v*d-c*s*m+o*h*m,y=f*h*l-u*v*l-f*s*d+a*v*d+u*s*m-a*h*m,_=u*p*l-f*c*l+f*o*d-a*p*d-u*o*m+a*c*m,x=f*c*s-u*p*s-f*o*h+a*p*h+u*o*v-a*c*v,M=t*g+n*y+i*_+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*v*r-p*i*d+n*v*d+c*i*m-n*h*m)*S,e[2]=(o*v*r-p*s*r+p*i*l-n*v*l-o*i*m+n*s*m)*S,e[3]=(c*s*r-o*h*r-c*i*l+n*h*l+o*i*d-n*s*d)*S,e[4]=y*S,e[5]=(u*v*r-f*h*r+f*i*d-t*v*d-u*i*m+t*h*m)*S,e[6]=(f*s*r-a*v*r-f*i*l+t*v*l+a*i*m-t*s*m)*S,e[7]=(a*h*r-u*s*r+u*i*l-t*h*l-a*i*d+t*s*d)*S,e[8]=_*S,e[9]=(f*c*r-u*p*r-f*n*d+t*p*d+u*n*m-t*c*m)*S,e[10]=(a*p*r-f*o*r+f*n*l-t*p*l-a*n*m+t*o*m)*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*v+t*c*v)*S,e[14]=(f*o*i-a*p*i-f*n*s+t*p*s+a*n*v-t*o*v)*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,v=a*c,m=o*c,g=s*l,y=s*u,_=s*c,x=n.x,M=n.y,S=n.z;return i[0]=(1-(p+m))*x,i[1]=(d+_)*x,i[2]=(f-y)*x,i[3]=0,i[4]=(d-_)*M,i[5]=(1-(h+m))*M,i[6]=(v+g)*M,i[7]=0,i[8]=(f+y)*S,i[9]=(v-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=Ln.set(i[0],i[1],i[2]).length(),a=Ln.set(i[4],i[5],i[6]).length(),o=Ln.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],Nn.copy(this);var s=1/r,l=1/a,u=1/o;return Nn.elements[0]*=s,Nn.elements[1]*=s,Nn.elements[2]*=s,Nn.elements[4]*=l,Nn.elements[5]*=l,Nn.elements[6]*=l,Nn.elements[8]*=u,Nn.elements[9]*=u,Nn.elements[10]*=u,t.setFromRotationMatrix(Nn),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]:ut,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===ut)o=-(a+r)/(a-r),s=-2*a*r/(a-r);else{if(l!==ct)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]:ut,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===ut)o=(a+r)*d,s=-2*d;else{if(l!==ct)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}}])}(),Ln=new tn,Nn=new Pn,Un=new tn(0,0,0),Dn=new tn(1,1,1),On=new tn,Fn=new tn,Bn=new tn,zn=new Pn,Hn=new en,Vn=function(){return o((function e(){var t=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,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.DEFAULT_ORDER;r(this,e),this.isEuler=!0,this._x=t,this._y=n,this._z=i,this._order=a}),[{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(gt(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(-gt(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(gt(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(-gt(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(gt(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(-gt(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 zn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zn,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 Hn.setFromEuler(this),this.setFromQuaternion(Hn,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:v().mark((function e(){return v().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)}))}])}();Vn.DEFAULT_ORDER="XYZ";var Gn=function(){return o((function e(){r(this,e),this.mask=1}),[{key:"set",value:function(e){this.mask=1<<e>>>0}},{key:"enable",value:function(e){this.mask|=1<<e}},{key:"enableAll",value:function(){this.mask=-1}},{key:"toggle",value:function(e){this.mask^=1<<e}},{key:"disable",value:function(e){this.mask&=~(1<<e)}},{key:"disableAll",value:function(){this.mask=0}},{key:"test",value:function(e){return!!(this.mask&e.mask)}},{key:"isEnabled",value:function(e){return!!(this.mask&1<<e)}}])}(),Wn=0,jn=new tn,Xn=new en,qn=new Pn,Yn=new tn,Zn=new tn,Kn=new tn,Jn=new en,Qn=new tn(1,0,0),$n=new tn(0,1,0),ei=new tn(0,0,1),ti={type:"added"},ni={type:"removed"},ii={type:"childadded",child:null},ri={type:"childremoved",child:null},ai=function(e){function t(){var e;r(this,t),(e=i(this,t)).isObject3D=!0,Object.defineProperty(e,"id",{value:Wn++}),e.uuid=mt(),e.name="",e.type="Object3D",e.parent=null,e.children=[],e.up=t.DEFAULT_UP.clone();var n=new tn,a=new Vn,o=new en,s=new tn(1,1,1);return a._onChange((function(){o.setFromEuler(a,!1)})),o._onChange((function(){a.setFromQuaternion(o,void 0,!1)})),Object.defineProperties(e,{position:{configurable:!0,enumerable:!0,value:n},rotation:{configurable:!0,enumerable:!0,value:a},quaternion:{configurable:!0,enumerable:!0,value:o},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Pn},normalMatrix:{value:new Tt}}),e.matrix=new Pn,e.matrixWorld=new Pn,e.matrixAutoUpdate=t.DEFAULT_MATRIX_AUTO_UPDATE,e.matrixWorldAutoUpdate=t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,e.matrixWorldNeedsUpdate=!1,e.layers=new Gn,e.visible=!0,e.castShadow=!1,e.receiveShadow=!1,e.frustumCulled=!0,e.renderOrder=0,e.animations=[],e.userData={},e}return h(t,e),o(t,[{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 Xn.setFromAxisAngle(e,t),this.quaternion.multiply(Xn),this}},{key:"rotateOnWorldAxis",value:function(e,t){return Xn.setFromAxisAngle(e,t),this.quaternion.premultiply(Xn),this}},{key:"rotateX",value:function(e){return this.rotateOnAxis(Qn,e)}},{key:"rotateY",value:function(e){return this.rotateOnAxis($n,e)}},{key:"rotateZ",value:function(e){return this.rotateOnAxis(ei,e)}},{key:"translateOnAxis",value:function(e,t){return jn.copy(e).applyQuaternion(this.quaternion),this.position.add(jn.multiplyScalar(t)),this}},{key:"translateX",value:function(e){return this.translateOnAxis(Qn,e)}},{key:"translateY",value:function(e){return this.translateOnAxis($n,e)}},{key:"translateZ",value:function(e){return this.translateOnAxis(ei,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(qn.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),Zn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qn.lookAt(Zn,Yn,this.up):qn.lookAt(Yn,Zn,this.up),this.quaternion.setFromRotationMatrix(qn),i&&(qn.extractRotation(i.matrixWorld),Xn.setFromRotationMatrix(qn),this.quaternion.premultiply(Xn.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?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ti),ii.child=e,this.dispatchEvent(ii),ii.child=null):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(ni),ri.child=e,this.dispatchEvent(ri),ri.child=null),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,_(this.children))}},{key:"attach",value:function(e){return this.updateWorldMatrix(!0,!1),qn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(qn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ti),ii.child=e,this.dispatchEvent(ii),ii.child=null,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(Zn,e,Kn),e}},{key:"getWorldScale",value:function(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zn,Jn,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)&&(!0===this.matrixWorldAutoUpdate&&(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++){t[n].updateMatrixWorld(e)}}},{key:"updateWorldMatrix",value:function(e,t){var n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(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++){i[r].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.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.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 v=this.animations[p];i.animations.push(r(e.animations,v))}}if(t){var m=T(e.geometries),g=T(e.materials),y=T(e.textures),_=T(e.images),x=T(e.shapes),M=T(e.skeletons),S=T(e.animations),b=T(e.nodes);m.length>0&&(n.geometries=m),g.length>0&&(n.materials=g),y.length>0&&(n.textures=y),_.length>0&&(n.images=_),x.length>0&&(n.shapes=x),M.length>0&&(n.skeletons=M),S.length>0&&(n.animations=S),b.length>0&&(n.nodes=b)}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}}])}(ht);ai.DEFAULT_UP=new tn(0,1,0),ai.DEFAULT_MATRIX_AUTO_UPDATE=!0,ai.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var oi=new tn,si=new tn,li=new tn,ui=new tn,ci=new tn,hi=new tn,di=new tn,fi=new tn,pi=new tn,vi=new tn,mi=new qt,gi=new qt,yi=new qt,_i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new tn;r(this,e),this.a=t,this.b=n,this.c=i}return o(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 oi.subVectors(this.c,this.b),si.subVectors(this.a,this.b),.5*oi.cross(si).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:"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;ci.subVectors(a,r),hi.subVectors(o,r),fi.subVectors(e,r);var s=ci.dot(fi),l=hi.dot(fi);if(s<=0&&l<=0)return t.copy(r);pi.subVectors(e,a);var u=ci.dot(pi),c=hi.dot(pi);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(ci,n);vi.subVectors(e,o);var d=ci.dot(vi),f=hi.dot(vi);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(hi,i);var v=u*f-d*c;if(v<=0&&c-u>=0&&d-f>=0)return di.subVectors(o,a),i=(c-u)/(c-u+(d-f)),t.copy(a).addScaledVector(di,i);var m=1/(v+p+h);return n=p*m,i=h*m,t.copy(r).addScaledVector(ci,n).addScaledVector(hi,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),oi.subVectors(e,t),i.cross(oi);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){oi.subVectors(i,t),si.subVectors(n,t),li.subVectors(e,t);var a=oi.dot(oi),o=oi.dot(si),s=oi.dot(li),l=si.dot(si),u=si.dot(li),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,ui)&&(ui.x>=0&&ui.y>=0&&ui.x+ui.y<=1)}},{key:"getInterpolation",value:function(e,t,n,i,r,a,o,s){return null===this.getBarycoord(e,t,n,i,ui)?(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,ui.x),s.addScaledVector(a,ui.y),s.addScaledVector(o,ui.z),s)}},{key:"getInterpolatedAttribute",value:function(e,t,n,i,r,a){return mi.setScalar(0),gi.setScalar(0),yi.setScalar(0),mi.fromBufferAttribute(e,t),gi.fromBufferAttribute(e,n),yi.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(mi,r.x),a.addScaledVector(gi,r.y),a.addScaledVector(yi,r.z),a}},{key:"isFrontFacing",value:function(e,t,n,i){return oi.subVectors(n,t),si.subVectors(e,t),oi.cross(si).dot(i)<0}}])}(),xi={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},Mi={h:0,s:0,l:0},Si={h:0,s:0,l:0};function bi(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 Ti=function(){return o((function e(t,n,i){return r(this,e),this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,n,i)}),[{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]:nt;return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ft.toWorkingColorSpace(this,t),this}},{key:"setRGB",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ft.workingColorSpace;return this.r=e,this.g=t,this.b=n,Ft.toWorkingColorSpace(this,i),this}},{key:"setHSL",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ft.workingColorSpace;if(e=yt(e,1),t=gt(t,0,1),n=gt(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=bi(a,r,e+1/3),this.g=bi(a,r,e),this.b=bi(a,r,e-1/3)}return Ft.toWorkingColorSpace(this,i),this}},{key:"setStyle",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nt;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]:nt,n=xi[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=Bt(e.r),this.g=Bt(e.g),this.b=Bt(e.b),this}},{key:"copyLinearToSRGB",value:function(e){return this.r=zt(e.r),this.g=zt(e.g),this.b=zt(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]:nt;return Ft.fromWorkingColorSpace(Ei.copy(this),e),65536*Math.round(gt(255*Ei.r,0,255))+256*Math.round(gt(255*Ei.g,0,255))+Math.round(gt(255*Ei.b,0,255))}},{key:"getHexString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nt;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]:Ft.workingColorSpace;Ft.fromWorkingColorSpace(Ei.copy(this),t);var n,i,r=Ei.r,a=Ei.g,o=Ei.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]:Ft.workingColorSpace;return Ft.fromWorkingColorSpace(Ei.copy(this),t),e.r=Ei.r,e.g=Ei.g,e.b=Ei.b,e}},{key:"getStyle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nt;Ft.fromWorkingColorSpace(Ei.copy(this),e);var t=Ei.r,n=Ei.g,i=Ei.b;return e!==nt?"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(Mi),this.setHSL(Mi.h+e,Mi.s+t,Mi.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(Mi),e.getHSL(Si);var n=_t(Mi.h,Si.h,t),i=_t(Mi.s,Si.s,t),r=_t(Mi.l,Si.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:v().mark((function e(){return v().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)}))}])}(),Ei=new Ti;Ti.NAMES=xi;var wi=0,Ai=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isMaterial=!0,Object.defineProperty(e,"id",{value:wi++}),e.uuid=mt(),e.name="",e.type="Material",e.blending=1,e.side=0,e.vertexColors=!1,e.opacity=1,e.transparent=!1,e.alphaHash=!1,e.blendSrc=w,e.blendDst=A,e.blendEquation=E,e.blendSrcAlpha=null,e.blendDstAlpha=null,e.blendEquationAlpha=null,e.blendColor=new Ti(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=ot,e.stencilZFail=ot,e.stencilZPass=ot,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 h(t,e),o(t,[{key:"alphaTest",get:function(){return this._alphaTest},set:function(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}},{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()),void 0!==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.dispersion&&(n.dispersion=this.dispersion),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.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),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),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==w&&(n.blendSrc=this.blendSrc),this.blendDst!==A&&(n.blendDst=this.blendDst),this.blendEquation!==E&&(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!==ot&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ot&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ot&&(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++}},{key:"onBuild",value:function(){console.warn("Material: onBuild() has been removed.")}}])}(ht),Ri=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshBasicMaterial=!0,n.type="MeshBasicMaterial",n.color=new Ti(16777215),n.map=null,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=null,n.aoMapIntensity=1,n.specularMap=null,n.alphaMap=null,n.envMap=null,n.envMapRotation=new Vn,n.combine=0,n.reflectivity=1,n.refractionRatio=.98,n.wireframe=!1,n.wireframeLinewidth=1,n.wireframeLinecap="round",n.wireframeLinejoin="round",n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}])}(Ai),Ci=ki();function ki(){for(var e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512),a=0;a<256;++a){var o=a-127;o<-27?(i[a]=0,i[256|a]=32768,r[a]=24,r[256|a]=24):o<-14?(i[a]=1024>>-o-14,i[256|a]=1024>>-o-14|32768,r[a]=-o-1,r[256|a]=-o-1):o<=15?(i[a]=o+15<<10,i[256|a]=o+15<<10|32768,r[a]=13,r[256|a]=13):o<128?(i[a]=31744,i[256|a]=64512,r[a]=24,r[256|a]=24):(i[a]=31744,i[256|a]=64512,r[a]=13,r[256|a]=13)}for(var s=new Uint32Array(2048),l=new Uint32Array(64),u=new Uint32Array(64),c=1;c<1024;++c){for(var h=c<<13,d=0;!(8388608&h);)h<<=1,d-=8388608;h&=-8388609,d+=947912704,s[c]=h|d}for(var f=1024;f<2048;++f)s[f]=939524096+(f-1024<<13);for(var p=1;p<31;++p)l[p]=p<<23;l[31]=1199570944,l[32]=2147483648;for(var v=33;v<63;++v)l[v]=2147483648+(v-32<<23);l[63]=3347054592;for(var m=1;m<64;++m)32!==m&&(u[m]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:l,offsetTable:u}}function Ii(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=gt(e,-65504,65504),Ci.floatView[0]=e;var t=Ci.uint32View[0],n=t>>23&511;return Ci.baseTable[n]+((8388607&t)>>Ci.shiftTable[n])}function Pi(e){var t=e>>10;return Ci.uint32View[0]=Ci.mantissaTable[Ci.offsetTable[t]+(1023&e)]+Ci.exponentTable[t],Ci.floatView[0]}var Li={toHalfFloat:Ii,fromHalfFloat:Pi},Ni=new tn,Ui=new bt,Di=function(){return o((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(r(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=st,this.updateRanges=[],this.gpuType=J,this.version=0}),[{key:"onUploadCallback",value:function(){}},{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{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++)Ui.fromBufferAttribute(this,t),Ui.applyMatrix3(e),this.setXY(t,Ui.x,Ui.y);else if(3===this.itemSize)for(var i=0,r=this.count;i<r;i++)Ni.fromBufferAttribute(this,i),Ni.applyMatrix3(e),this.setXYZ(i,Ni.x,Ni.y,Ni.z);return this}},{key:"applyMatrix4",value:function(e){for(var t=0,n=this.count;t<n;t++)Ni.fromBufferAttribute(this,t),Ni.applyMatrix4(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}},{key:"applyNormalMatrix",value:function(e){for(var t=0,n=this.count;t<n;t++)Ni.fromBufferAttribute(this,t),Ni.applyNormalMatrix(e),this.setXYZ(t,Ni.x,Ni.y,Ni.z);return this}},{key:"transformDirection",value:function(e){for(var t=0,n=this.count;t<n;t++)Ni.fromBufferAttribute(this,t),Ni.transformDirection(e),this.setXYZ(t,Ni.x,Ni.y,Ni.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=xt(n,this.array)),n}},{key:"setComponent",value:function(e,t,n){return this.normalized&&(n=Mt(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=xt(t,this.array)),t}},{key:"setX",value:function(e,t){return this.normalized&&(t=Mt(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=xt(t,this.array)),t}},{key:"setY",value:function(e,t){return this.normalized&&(t=Mt(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=xt(t,this.array)),t}},{key:"setZ",value:function(e,t){return this.normalized&&(t=Mt(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=xt(t,this.array)),t}},{key:"setW",value:function(e,t){return this.normalized&&(t=Mt(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=Mt(t,this.array),n=Mt(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=Mt(t,this.array),n=Mt(n,this.array),i=Mt(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=Mt(t,this.array),n=Mt(n,this.array),i=Mt(i,this.array),r=Mt(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!==st&&(e.usage=this.usage),e}}])}(),Oi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Int8Array(e),n,a])}return h(t,e),o(t)}(Di),Fi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Uint8Array(e),n,a])}return h(t,e),o(t)}(Di),Bi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Uint8ClampedArray(e),n,a])}return h(t,e),o(t)}(Di),zi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Int16Array(e),n,a])}return h(t,e),o(t)}(Di),Hi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Uint16Array(e),n,a])}return h(t,e),o(t)}(Di),Vi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Int32Array(e),n,a])}return h(t,e),o(t)}(Di),Gi=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Uint32Array(e),n,a])}return h(t,e),o(t)}(Di),Wi=function(e){function t(e,n,a){var o;return r(this,t),(o=i(this,t,[new Uint16Array(e),n,a])).isFloat16BufferAttribute=!0,o}return h(t,e),o(t,[{key:"getX",value:function(e){var t=Pi(this.array[e*this.itemSize]);return this.normalized&&(t=xt(t,this.array)),t}},{key:"setX",value:function(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize]=Ii(t),this}},{key:"getY",value:function(e){var t=Pi(this.array[e*this.itemSize+1]);return this.normalized&&(t=xt(t,this.array)),t}},{key:"setY",value:function(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+1]=Ii(t),this}},{key:"getZ",value:function(e){var t=Pi(this.array[e*this.itemSize+2]);return this.normalized&&(t=xt(t,this.array)),t}},{key:"setZ",value:function(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+2]=Ii(t),this}},{key:"getW",value:function(e){var t=Pi(this.array[e*this.itemSize+3]);return this.normalized&&(t=xt(t,this.array)),t}},{key:"setW",value:function(e,t){return this.normalized&&(t=Mt(t,this.array)),this.array[e*this.itemSize+3]=Ii(t),this}},{key:"setXY",value:function(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array)),this.array[e+0]=Ii(t),this.array[e+1]=Ii(n),this}},{key:"setXYZ",value:function(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),i=Mt(i,this.array)),this.array[e+0]=Ii(t),this.array[e+1]=Ii(n),this.array[e+2]=Ii(i),this}},{key:"setXYZW",value:function(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Mt(t,this.array),n=Mt(n,this.array),i=Mt(i,this.array),r=Mt(r,this.array)),this.array[e+0]=Ii(t),this.array[e+1]=Ii(n),this.array[e+2]=Ii(i),this.array[e+3]=Ii(r),this}}])}(Di),ji=function(e){function t(e,n,a){return r(this,t),i(this,t,[new Float32Array(e),n,a])}return h(t,e),o(t)}(Di),Xi=0,qi=new Pn,Yi=new ai,Zi=new tn,Ki=new an,Ji=new an,Qi=new tn,$i=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isBufferGeometry=!0,Object.defineProperty(e,"id",{value:Xi++}),e.uuid=mt(),e.name="",e.type="BufferGeometry",e.index=null,e.indirect=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 h(t,e),o(t,[{key:"getIndex",value:function(){return this.index}},{key:"setIndex",value:function(e){return Array.isArray(e)?this.index=new(wt(e)?Gi:Hi)(e,1):this.index=e,this}},{key:"setIndirect",value:function(e){return this.indirect=e,this}},{key:"getIndirect",value:function(){return this.indirect}},{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 Tt).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 qi.makeRotationFromQuaternion(e),this.applyMatrix4(qi),this}},{key:"rotateX",value:function(e){return qi.makeRotationX(e),this.applyMatrix4(qi),this}},{key:"rotateY",value:function(e){return qi.makeRotationY(e),this.applyMatrix4(qi),this}},{key:"rotateZ",value:function(e){return qi.makeRotationZ(e),this.applyMatrix4(qi),this}},{key:"translate",value:function(e,t,n){return qi.makeTranslation(e,t,n),this.applyMatrix4(qi),this}},{key:"scale",value:function(e,t,n){return qi.makeScale(e,t,n),this.applyMatrix4(qi),this}},{key:"lookAt",value:function(e){return Yi.lookAt(e),Yi.updateMatrix(),this.applyMatrix4(Yi.matrix),this}},{key:"center",value:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Zi).negate(),this.translate(Zi.x,Zi.y,Zi.z),this}},{key:"setFromPoints",value:function(e){var t=this.getAttribute("position");if(void 0===t){for(var n=[],i=0,r=e.length;i<r;i++){var a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ji(n,3))}else{for(var o=Math.min(e.length,t.count),s=0;s<o;s++){var l=e[s];t.setXYZ(s,l.x,l.y,l.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}},{key:"computeBoundingBox",value:function(){null===this.boundingBox&&(this.boundingBox=new an);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.",this),void this.boundingBox.set(new tn(-1/0,-1/0,-1/0),new tn(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];Ki.setFromBufferAttribute(r),this.morphTargetsRelative?(Qi.addVectors(this.boundingBox.min,Ki.min),this.boundingBox.expandByPoint(Qi),Qi.addVectors(this.boundingBox.max,Ki.max),this.boundingBox.expandByPoint(Qi)):(this.boundingBox.expandByPoint(Ki.min),this.boundingBox.expandByPoint(Ki.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 bn);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.",this),void this.boundingSphere.set(new tn,1/0);if(e){var n=this.boundingSphere.center;if(Ki.setFromBufferAttribute(e),t)for(var i=0,r=t.length;i<r;i++){var a=t[i];Ji.setFromBufferAttribute(a),this.morphTargetsRelative?(Qi.addVectors(Ki.min,Ji.min),Ki.expandByPoint(Qi),Qi.addVectors(Ki.max,Ji.max),Ki.expandByPoint(Qi)):(Ki.expandByPoint(Ji.min),Ki.expandByPoint(Ji.max))}Ki.getCenter(n);for(var o=0,s=0,l=e.count;s<l;s++)Qi.fromBufferAttribute(e,s),o=Math.max(o,n.distanceToSquared(Qi));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++)Qi.fromBufferAttribute(h,f),d&&(Zi.fromBufferAttribute(e,f),Qi.add(Zi)),o=Math.max(o,n.distanceToSquared(Qi));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=t.position,i=t.normal,r=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Di(new Float32Array(4*n.count),4));for(var a=this.getAttribute("tangent"),o=[],s=[],l=0;l<n.count;l++)o[l]=new tn,s[l]=new tn;var u=new tn,c=new tn,h=new tn,d=new bt,f=new bt,p=new bt,v=new tn,m=new tn,g=this.groups;0===g.length&&(g=[{start:0,count:e.count}]);for(var y=0,_=g.length;y<_;++y)for(var x=g[y],M=x.start,S=M,b=M+x.count;S<b;S+=3)N(e.getX(S+0),e.getX(S+1),e.getX(S+2));for(var T=new tn,E=new tn,w=new tn,A=new tn,R=0,C=g.length;R<C;++R)for(var k=g[R],I=k.start,P=I,L=I+k.count;P<L;P+=3)U(e.getX(P+0)),U(e.getX(P+1)),U(e.getX(P+2))}else console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");function N(e,t,i){u.fromBufferAttribute(n,e),c.fromBufferAttribute(n,t),h.fromBufferAttribute(n,i),d.fromBufferAttribute(r,e),f.fromBufferAttribute(r,t),p.fromBufferAttribute(r,i),c.sub(u),h.sub(u),f.sub(d),p.sub(d);var a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(v.copy(c).multiplyScalar(p.y).addScaledVector(h,-f.y).multiplyScalar(a),m.copy(h).multiplyScalar(f.x).addScaledVector(c,-p.x).multiplyScalar(a),o[e].add(v),o[t].add(v),o[i].add(v),s[e].add(m),s[t].add(m),s[i].add(m))}function U(e){w.fromBufferAttribute(i,e),A.copy(w);var t=o[e];T.copy(t),T.sub(w.multiplyScalar(w.dot(t))).normalize(),E.crossVectors(A,t);var n=E.dot(s[e])<0?-1:1;a.setXYZW(e,T.x,T.y,T.z,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 Di(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 tn,o=new tn,s=new tn,l=new tn,u=new tn,c=new tn,h=new tn,d=new tn;if(e)for(var f=0,p=e.count;f<p;f+=3){var v=e.getX(f+0),m=e.getX(f+1),g=e.getX(f+2);a.fromBufferAttribute(t,v),o.fromBufferAttribute(t,m),s.fromBufferAttribute(t,g),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),l.fromBufferAttribute(n,v),u.fromBufferAttribute(n,m),c.fromBufferAttribute(n,g),l.add(h),u.add(h),c.add(h),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(m,u.x,u.y,u.z),n.setXYZ(g,c.x,c.y,c.z)}else for(var y=0,_=t.count;y<_;y+=3)a.fromBufferAttribute(t,y+0),o.fromBufferAttribute(t,y+1),s.fromBufferAttribute(t,y+2),h.subVectors(s,o),d.subVectors(a,o),h.cross(d),n.setXYZ(y+0,h.x,h.y,h.z),n.setXYZ(y+1,h.x,h.y,h.z),n.setXYZ(y+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++)Qi.fromBufferAttribute(e,t),Qi.normalize(),e.setXYZ(t,Qi.x,Qi.y,Qi.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 Di(a,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;var n=new t,i=this.index.array,r=this.attributes;for(var a in r){var o=e(r[a],i);n.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)}n.morphAttributes[l]=u}n.morphTargetsRelative=this.morphTargetsRelative;for(var p=this.groups,v=0,m=p.length;v<m;v++){var g=p[v];n.addGroup(g.start,g.count,g.materialIndex)}return n}},{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 v=this.groups;v.length>0&&(e.data.groups=JSON.parse(JSON.stringify(v)));var m=this.boundingSphere;return null!==m&&(e.data.boundingSphere={center:m.center.toArray(),radius:m.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 v=d[f];this.addGroup(v.start,v.count,v.materialIndex)}var m=e.boundingBox;null!==m&&(this.boundingBox=m.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"})}}])}(ht),er=new Pn,tr=new In,nr=new bn,ir=new tn,rr=new tn,ar=new tn,or=new tn,sr=new tn,lr=new tn,ur=new tn,cr=new tn,hr=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new $i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ri;return r(this,t),(e=i(this,t)).isMesh=!0,e.type="Mesh",e.geometry=n,e.material=a,e.updateMorphTargets(),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.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){lr.set(0,0,0);for(var s=0,l=r.length;s<l;s++){var u=o[s],c=r[s];0!==u&&(sr.fromBufferAttribute(c,e),a?lr.addScaledVector(sr,u):lr.addScaledVector(sr.sub(t),u))}t.add(lr)}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(),nr.copy(n.boundingSphere),nr.applyMatrix4(r),tr.copy(e.ray).recast(e.near),!1===nr.containsPoint(tr.origin)){if(null===tr.intersectSphere(nr,ir))return;if(tr.origin.distanceToSquared(ir)>Math.pow(e.far-e.near,2))return}er.copy(r).invert(),tr.copy(e.ray).applyMatrix4(er),null!==n.boundingBox&&!1===tr.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,tr)}}},{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 v=h[f],m=a[v.materialIndex],g=Math.max(v.start,d.start),y=Math.min(o.count,Math.min(v.start+v.count,d.start+d.count));g<y;g+=3){(i=dr(this,m,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=v.materialIndex,t.push(i))}else for(var _=Math.max(0,d.start),x=Math.min(o.count,d.start+d.count);_<x;_+=3){(i=dr(this,a,e,n,l,u,c,o.getX(_),o.getX(_+1),o.getX(_+2)))&&(i.faceIndex=Math.floor(_/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 b=h[M],T=a[b.materialIndex],E=Math.max(b.start,d.start),w=Math.min(s.count,Math.min(b.start+b.count,d.start+d.count));E<w;E+=3){(i=dr(this,T,e,n,l,u,c,E,E+1,E+2))&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=b.materialIndex,t.push(i))}else for(var A=Math.max(0,d.start),R=Math.min(s.count,d.start+d.count);A<R;A+=3){(i=dr(this,a,e,n,l,u,c,A,A+1,A+2))&&(i.faceIndex=Math.floor(A/3),t.push(i))}}}])}(ai);function dr(e,t,n,i,r,a,o,s,l,u){e.getVertexPosition(s,rr),e.getVertexPosition(l,ar),e.getVertexPosition(u,or);var c=function(e,t,n,i,r,a,o,s){if(null===(1===t.side?i.intersectTriangle(o,a,r,!0,s):i.intersectTriangle(r,a,o,0===t.side,s)))return null;cr.copy(s),cr.applyMatrix4(e.matrixWorld);var l=n.ray.origin.distanceTo(cr);return l<n.near||l>n.far?null:{distance:l,point:cr.clone(),object:e}}(e,t,n,i,rr,ar,or,ur);if(c){var h=new tn;_i.getBarycoord(ur,rr,ar,or,h),r&&(c.uv=_i.getInterpolatedAttribute(r,s,l,u,h,new bt)),a&&(c.uv1=_i.getInterpolatedAttribute(a,s,l,u,h,new bt)),o&&(c.normal=_i.getInterpolatedAttribute(o,s,l,u,h,new tn),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));var d={a:s,b:l,c:u,normal:new tn,materialIndex:0};_i.getNormal(rr,ar,or,d.normal),c.face=d,c.barycoord=h}return c}var fr=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;r(this,t),(e=i(this,t)).type="BoxGeometry",e.parameters={width:n,height:a,depth:o,widthSegments:s,heightSegments:l,depthSegments:u};var c=e;s=Math.floor(s),l=Math.floor(l),u=Math.floor(u);var h=[],d=[],f=[],p=[],v=0,m=0;function g(e,t,n,i,r,a,o,s,l,u,g){for(var y=a/l,_=o/u,x=a/2,M=o/2,S=s/2,b=l+1,T=u+1,E=0,w=0,A=new tn,R=0;R<T;R++)for(var C=R*_-M,k=0;k<b;k++){var I=k*y-x;A[e]=I*i,A[t]=C*r,A[n]=S,d.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=s>0?1:-1,f.push(A.x,A.y,A.z),p.push(k/l),p.push(1-R/u),E+=1}for(var P=0;P<u;P++)for(var L=0;L<l;L++){var N=v+L+b*P,U=v+L+b*(P+1),D=v+(L+1)+b*(P+1),O=v+(L+1)+b*P;h.push(N,U,O),h.push(U,D,O),w+=6}c.addGroup(m,w,g),m+=w,v+=E}return g("z","y","x",-1,-1,o,a,n,u,l,0),g("z","y","x",1,-1,o,a,-n,u,l,1),g("x","z","y",1,1,n,o,a,s,u,2),g("x","z","y",1,-1,n,o,-a,s,u,3),g("x","y","z",1,-1,n,a,o,s,l,4),g("x","y","z",-1,-1,n,a,-o,s,l,5),e.setIndex(h),e.setAttribute("position",new ji(d,3)),e.setAttribute("normal",new ji(f,3)),e.setAttribute("uv",new ji(p,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}])}($i);function pr(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 vr(e){for(var t={},n=0;n<e.length;n++){var i=pr(e[n]);for(var r in i)t[r]=i[r]}return t}function mr(e){var t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:Ft.workingColorSpace}var gr,yr={clone:pr,merge:vr},_r=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isShaderMaterial=!0,n.type="ShaderMaterial",n.defines={},n.uniforms={},n.uniformsGroups=[],n.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",n.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",n.linewidth=1,n.wireframe=!1,n.wireframeLinewidth=1,n.fog=!1,n.lights=!1,n.clipping=!1,n.forceSinglePass=!0,n.extensions={clipCullDistance:!1,multiDraw:!1},n.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},n.index0AttributeName=void 0,n.uniformsNeedUpdate=!1,n.glslVersion=null,void 0!==e&&n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=pr(e.uniforms),this.uniformsGroups=function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);for(var i in n.glslVersion=this.glslVersion,n.uniforms={},this.uniforms){var r=this.uniforms[i].value;r&&r.isTexture?n.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?n.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?n.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?n.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?n.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?n.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?n.uniforms[i]={type:"m4",value:r.toArray()}:n.uniforms[i]={value:r}}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 a={};for(var o in this.extensions)!0===this.extensions[o]&&(a[o]=!0);return Object.keys(a).length>0&&(n.extensions=a),n}}])}(Ai),xr=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isCamera=!0,e.type="Camera",e.matrixWorldInverse=new Pn,e.projectionMatrix=new Pn,e.projectionMatrixInverse=new Pn,e.coordinateSystem=ut,e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}},{key:"getWorldDirection",value:function(e){return y(t,"getWorldDirection",this)([e]).negate()}},{key:"updateMatrixWorld",value:function(e){y(t,"updateMatrixWorld",this)([e]),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"updateWorldMatrix",value:function(e,n){y(t,"updateWorldMatrix",this)([e,n]),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}])}(ai),Mr=new tn,Sr=new bt,br=new bt,Tr=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2e3;return r(this,t),(e=i(this,t)).isPerspectiveCamera=!0,e.type="PerspectiveCamera",e.fov=n,e.zoom=1,e.near=o,e.far=s,e.focus=10,e.aspect=a,e.view=null,e.filmGauge=35,e.filmOffset=0,e.updateProjectionMatrix(),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}},{key:"setFocalLength",value:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*vt*Math.atan(t),this.updateProjectionMatrix()}},{key:"getFocalLength",value:function(){var e=Math.tan(.5*pt*this.fov);return.5*this.getFilmHeight()/e}},{key:"getEffectiveFOV",value:function(){return 2*vt*Math.atan(Math.tan(.5*pt*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:"getViewBounds",value:function(e,t,n){Mr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mr.x,Mr.y).multiplyScalar(-e/Mr.z),Mr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mr.x,Mr.y).multiplyScalar(-e/Mr.z)}},{key:"getViewSize",value:function(e,t){return this.getViewBounds(e,Sr,br),t.subVectors(br,Sr)}},{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*pt*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(e){var n=y(t,"toJSON",this)([e]);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}}])}(xr),Er=-90,wr=function(e){function t(e,n,a){var o;r(this,t),(o=i(this,t)).type="CubeCamera",o.renderTarget=a,o.coordinateSystem=null,o.activeMipmapLevel=0;var s=new Tr(Er,1,e,n);s.layers=o.layers,o.add(s);var l=new Tr(Er,1,e,n);l.layers=o.layers,o.add(l);var u=new Tr(Er,1,e,n);u.layers=o.layers,o.add(u);var c=new Tr(Er,1,e,n);c.layers=o.layers,o.add(c);var h=new Tr(Er,1,e,n);h.layers=o.layers,o.add(h);var d=new Tr(Er,1,e,n);return d.layers=o.layers,o.add(d),o}return h(t,e),o(t,[{key:"updateCoordinateSystem",value:function(){var e,t=this.coordinateSystem,n=this.children.concat(),i=g(n,6),r=i[0],a=i[1],o=i[2],l=i[3],u=i[4],c=i[5],h=s(n);try{for(h.s();!(e=h.n()).done;){var d=e.value;this.remove(d)}}catch(e){h.e(e)}finally{h.f()}if(t===ut)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),l.up.set(0,0,1),l.lookAt(0,-1,0),u.up.set(0,1,0),u.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else{if(t!==ct)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),l.up.set(0,0,-1),l.lookAt(0,-1,0),u.up.set(0,-1,0),u.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1)}var f,p=s(n);try{for(p.s();!(f=p.n()).done;){var v=f.value;this.add(v),v.updateMatrixWorld()}}catch(e){p.e(e)}finally{p.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=g(this.children,6),a=r[0],o=r[1],s=r[2],l=r[3],u=r[4],c=r[5],h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=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,u),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(h,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}])}(ai),Ar=function(e){function t(e,n,a,o,s,l,u,c,h,d){var f;return r(this,t),(f=i(this,t,[e=void 0!==e?e:[],n=void 0!==n?n:I,a,o,s,l,u,c,h,d])).isCubeTexture=!0,f.flipY=!1,f}return h(t,e),o(t,[{key:"images",get:function(){return this.image},set:function(e){this.image=e}}])}(Xt),Rr=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,t),(e=i(this,t,[n,n,a])).isWebGLCubeRenderTarget=!0;var o={width:n,height:n,depth:1},s=[o,o,o,o,o,o];return e.texture=new Ar(s,a.mapping,a.wrapS,a.wrapT,a.magFilter,a.minFilter,a.format,a.type,a.anisotropy,a.colorSpace),e.texture.isRenderTargetTexture=!0,e.texture.generateMipmaps=void 0!==a.generateMipmaps&&a.generateMipmaps,e.texture.minFilter=void 0!==a.minFilter?a.minFilter:V,e}return h(t,e),o(t,[{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 fr(5,5,5),o=new _r({name:"CubemapFromEquirect",uniforms:pr(n),vertexShader:i,fragmentShader:r,side:1,blending:0});o.uniforms.tEquirect.value=t;var s=new hr(a,o),l=t.minFilter;return t.minFilter===W&&(t.minFilter=V),new wr(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)}}])}(Zt),Cr=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:25e-5;r(this,e),this.isFogExp2=!0,this.name="",this.color=new Ti(t),this.density=n}return o(e,[{key:"clone",value:function(){return new e(this.color,this.density)}},{key:"toJSON",value:function(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}])}(),kr=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;r(this,e),this.isFog=!0,this.name="",this.color=new Ti(t),this.near=n,this.far=i}return o(e,[{key:"clone",value:function(){return new e(this.color,this.near,this.far)}},{key:"toJSON",value:function(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}])}(),Ir=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isScene=!0,e.type="Scene",e.background=null,e.environment=null,e.fog=null,e.backgroundBlurriness=0,e.backgroundIntensity=1,e.backgroundRotation=new Vn,e.environmentIntensity=1,e.environmentRotation=new Vn,e.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:e})),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);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.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}])}(ai),Pr=function(){return o((function e(t,n){r(this,e),this.isInterleavedBuffer=!0,this.array=t,this.stride=n,this.count=void 0!==t?t.length/n:0,this.usage=st,this.updateRanges=[],this.version=0,this.uuid=mt()}),[{key:"onUploadCallback",value:function(){}},{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{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=mt()),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=mt()),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}}}])}(),Lr=new tn,Nr=function(){function e(t,n,i){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];r(this,e),this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=n,this.offset=i,this.normalized=a}return o(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++)Lr.fromBufferAttribute(this,t),Lr.applyMatrix4(e),this.setXYZ(t,Lr.x,Lr.y,Lr.z);return this}},{key:"applyNormalMatrix",value:function(e){for(var t=0,n=this.count;t<n;t++)Lr.fromBufferAttribute(this,t),Lr.applyNormalMatrix(e),this.setXYZ(t,Lr.x,Lr.y,Lr.z);return this}},{key:"transformDirection",value:function(e){for(var t=0,n=this.count;t<n;t++)Lr.fromBufferAttribute(this,t),Lr.transformDirection(e),this.setXYZ(t,Lr.x,Lr.y,Lr.z);return this}},{key:"getComponent",value:function(e,t){var n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=xt(n,this.array)),n}},{key:"setComponent",value:function(e,t,n){return this.normalized&&(n=Mt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}},{key:"setX",value:function(e,t){return this.normalized&&(t=Mt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}},{key:"setY",value:function(e,t){return this.normalized&&(t=Mt(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=Mt(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=Mt(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=xt(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=xt(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=xt(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=xt(t,this.array)),t}},{key:"setXY",value:function(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mt(t,this.array),n=Mt(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=Mt(t,this.array),n=Mt(n,this.array),i=Mt(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=Mt(t,this.array),n=Mt(n,this.array),i=Mt(i,this.array),r=Mt(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 Di(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}}}])}(),Ur=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isSpriteMaterial=!0,n.type="SpriteMaterial",n.color=new Ti(16777215),n.map=null,n.alphaMap=null,n.rotation=0,n.sizeAttenuation=!0,n.transparent=!0,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}])}(Ai),Dr=new tn,Or=new tn,Fr=new tn,Br=new bt,zr=new bt,Hr=new Pn,Vr=new tn,Gr=new tn,Wr=new tn,jr=new bt,Xr=new bt,qr=new bt,Yr=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ur;if(r(this,t),(e=i(this,t)).isSprite=!0,e.type="Sprite",void 0===gr){gr=new $i;var a=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),o=new Pr(a,5);gr.setIndex([0,1,2,0,2,3]),gr.setAttribute("position",new Nr(o,3,0,!1)),gr.setAttribute("uv",new Nr(o,2,3,!1))}return e.geometry=gr,e.material=n,e.center=new bt(.5,.5),e}return h(t,e),o(t,[{key:"raycast",value:function(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Or.setFromMatrixScale(this.matrixWorld),Hr.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Fr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Or.multiplyScalar(-Fr.z);var n,i,r=this.material.rotation;0!==r&&(i=Math.cos(r),n=Math.sin(r));var a=this.center;Zr(Vr.set(-.5,-.5,0),Fr,a,Or,n,i),Zr(Gr.set(.5,-.5,0),Fr,a,Or,n,i),Zr(Wr.set(.5,.5,0),Fr,a,Or,n,i),jr.set(0,0),Xr.set(1,0),qr.set(1,1);var o=e.ray.intersectTriangle(Vr,Gr,Wr,!1,Dr);if(null!==o||(Zr(Gr.set(-.5,.5,0),Fr,a,Or,n,i),Xr.set(0,1),null!==(o=e.ray.intersectTriangle(Vr,Wr,Gr,!1,Dr)))){var s=e.ray.origin.distanceTo(Dr);s<e.near||s>e.far||t.push({distance:s,point:Dr.clone(),uv:_i.getInterpolation(Dr,Vr,Gr,Wr,jr,Xr,qr,new bt),face:null,object:this})}}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}])}(ai);function Zr(e,t,n,i,r,a){Br.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(zr.x=a*Br.x-r*Br.y,zr.y=r*Br.x+a*Br.y):zr.copy(Br),e.copy(t),e.x+=zr.x,e.y+=zr.y,e.applyMatrix4(Hr)}var Kr=new tn,Jr=new tn,Qr=function(e){function t(){var e;return r(this,t),(e=i(this,t))._currentLevel=0,e.type="LOD",Object.defineProperties(e,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),e.autoUpdate=!0,e}return h(t,e),o(t,[{key:"copy",value:function(e){y(t,"copy",this)([e,!1]);for(var n=e.levels,i=0,r=n.length;i<r;i++){var a=n[i];this.addLevel(a.object.clone(),a.distance,a.hysteresis)}return this.autoUpdate=e.autoUpdate,this}},{key:"addLevel",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]:0;t=Math.abs(t);var i,r=this.levels;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}},{key:"removeLevel",value:function(e){for(var t=this.levels,n=0;n<t.length;n++)if(t[n].distance===e){var i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}},{key:"getCurrentLevel",value:function(){return this._currentLevel}},{key:"getObjectForDistance",value:function(e){var t=this.levels;if(t.length>0){var n,i;for(n=1,i=t.length;n<i;n++){var r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}},{key:"raycast",value:function(e,t){if(this.levels.length>0){Kr.setFromMatrixPosition(this.matrixWorld);var n=e.ray.origin.distanceTo(Kr);this.getObjectForDistance(n).raycast(e,t)}}},{key:"update",value:function(e){var t=this.levels;if(t.length>1){Kr.setFromMatrixPosition(e.matrixWorld),Jr.setFromMatrixPosition(this.matrixWorld);var n,i,r=Kr.distanceTo(Jr)/e.zoom;for(t[0].object.visible=!0,n=1,i=t.length;n<i;n++){var a=t[n].distance;if(t[n].object.visible&&(a-=a*t[n].hysteresis),!(r>=a))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;n<i;n++)t[n].object.visible=!1}}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);!1===this.autoUpdate&&(n.object.autoUpdate=!1),n.object.levels=[];for(var i=this.levels,r=0,a=i.length;r<a;r++){var o=i[r];n.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return n}}])}(ai),$r=new tn,ea=new qt,ta=new qt,na=new tn,ia=new Pn,ra=new tn,aa=new bn,oa=new Pn,sa=new In,la=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e,n])).isSkinnedMesh=!0,a.type="SkinnedMesh",a.bindMode=R,a.bindMatrix=new Pn,a.bindMatrixInverse=new Pn,a.boundingBox=null,a.boundingSphere=null,a}return h(t,e),o(t,[{key:"computeBoundingBox",value:function(){var e=this.geometry;null===this.boundingBox&&(this.boundingBox=new an),this.boundingBox.makeEmpty();for(var t=e.getAttribute("position"),n=0;n<t.count;n++)this.getVertexPosition(n,ra),this.boundingBox.expandByPoint(ra)}},{key:"computeBoundingSphere",value:function(){var e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new bn),this.boundingSphere.makeEmpty();for(var t=e.getAttribute("position"),n=0;n<t.count;n++)this.getVertexPosition(n,ra),this.boundingSphere.expandByPoint(ra)}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}},{key:"raycast",value:function(e,t){var n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),aa.copy(this.boundingSphere),aa.applyMatrix4(i),!1!==e.ray.intersectsSphere(aa)&&(oa.copy(i).invert(),sa.copy(e.ray).applyMatrix4(oa),null!==this.boundingBox&&!1===sa.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,sa)))}},{key:"getVertexPosition",value:function(e,n){return y(t,"getVertexPosition",this)([e,n]),this.applyBoneTransform(e,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 qt,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(e){y(t,"updateMatrixWorld",this)([e]),this.bindMode===R?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===C?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;ea.fromBufferAttribute(i.attributes.skinIndex,e),ta.fromBufferAttribute(i.attributes.skinWeight,e),$r.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(var r=0;r<4;r++){var a=ta.getComponent(r);if(0!==a){var o=ea.getComponent(r);ia.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(na.copy($r).applyMatrix4(ia),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}])}(hr),ua=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isBone=!0,e.type="Bone",e}return h(t,e),o(t)}(ai),ca=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,u=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0,h=arguments.length>7?arguments[7]:void 0,d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:B,f=arguments.length>9&&void 0!==arguments[9]?arguments[9]:B,p=arguments.length>10?arguments[10]:void 0,v=arguments.length>11?arguments[11]:void 0;return r(this,t),(e=i(this,t,[null,u,c,h,d,f,s,l,p,v])).isDataTexture=!0,e.image={data:n,width:a,height:o},e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return h(t,e),o(t)}(Xt),ha=new Pn,da=new Pn,fa=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];r(this,e),this.uuid=mt(),this.bones=t.slice(0),this.boneInverses=n,this.boneMatrices=null,this.boneTexture=null,this.init()}return o(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 Pn)}}},{key:"calculateInverses",value:function(){this.boneInverses.length=0;for(var e=0,t=this.bones.length;e<t;e++){var n=new Pn;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:da;ha.multiplyMatrices(o,t[r]),ha.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 ca(t,e,e,ae,J);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 ua),this.bones.push(a),this.boneInverses.push((new Pn).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}}])}(),pa=function(e){function t(e,n,a){var o,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return r(this,t),(o=i(this,t,[e,n,a])).isInstancedBufferAttribute=!0,o.meshPerAttribute=s,o}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.meshPerAttribute=e.meshPerAttribute,this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}])}(Di),va=new Pn,ma=new Pn,ga=[],ya=new an,_a=new Pn,xa=new hr,Ma=new bn,Sa=function(e){function t(e,n,a){var o;r(this,t),(o=i(this,t,[e,n])).isInstancedMesh=!0,o.instanceMatrix=new pa(new Float32Array(16*a),16),o.instanceColor=null,o.morphTexture=null,o.count=a,o.boundingBox=null,o.boundingSphere=null;for(var s=0;s<a;s++)o.setMatrixAt(s,_a);return o}return h(t,e),o(t,[{key:"computeBoundingBox",value:function(){var e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new an),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(var n=0;n<t;n++)this.getMatrixAt(n,va),ya.copy(e.boundingBox).applyMatrix4(va),this.boundingBox.union(ya)}},{key:"computeBoundingSphere",value:function(){var e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new bn),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(var n=0;n<t;n++)this.getMatrixAt(n,va),Ma.copy(e.boundingSphere).applyMatrix4(va),this.boundingSphere.union(Ma)}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.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:"getMorphAt",value:function(e,t){for(var n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=e*(n.length+1)+1,a=0;a<n.length;a++)n[a]=i[r+a]}},{key:"raycast",value:function(e,t){var n=this.matrixWorld,i=this.count;if(xa.geometry=this.geometry,xa.material=this.material,void 0!==xa.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Ma.copy(this.boundingSphere),Ma.applyMatrix4(n),!1!==e.ray.intersectsSphere(Ma)))for(var r=0;r<i;r++){this.getMatrixAt(r,va),ma.multiplyMatrices(n,va),xa.matrixWorld=ma,xa.raycast(e,ga);for(var a=0,o=ga.length;a<o;a++){var s=ga[a];s.instanceId=r,s.object=this,t.push(s)}ga.length=0}}},{key:"setColorAt",value:function(e,t){null===this.instanceColor&&(this.instanceColor=new pa(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e)}},{key:"setMatrixAt",value:function(e,t){t.toArray(this.instanceMatrix.array,16*e)}},{key:"setMorphAt",value:function(e,t){var n=t.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new ca(new Float32Array(i*this.count),i,this.count,ce,J));for(var r=this.morphTexture.source.data.data,a=0,o=0;o<n.length;o++)a+=n[o];var s=this.geometry.morphTargetsRelative?1:1-a,l=i*e;r[l]=s,r.set(n,l+1)}},{key:"updateMorphTargets",value:function(){}},{key:"dispose",value:function(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}])}(hr),ba=new tn,Ta=new tn,Ea=new Tt,wa=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn(1,0,0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,e),this.isPlane=!0,this.normal=t,this.constant=n}),[{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=ba.subVectors(n,t).cross(Ta.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(ba),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||Ea.getNormalMatrix(e),i=this.coplanarPoint(ba).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)}}])}(),Aa=new bn,Ra=new tn,Ca=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new wa,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new wa,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new wa,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new wa,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new wa,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new wa;r(this,e),this.planes=[t,n,i,a,o,s]}),[{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]:ut,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],v=i[11],m=i[12],g=i[13],y=i[14],_=i[15];if(n[0].setComponents(s-r,h-l,v-d,_-m).normalize(),n[1].setComponents(s+r,h+l,v+d,_+m).normalize(),n[2].setComponents(s+a,h+u,v+f,_+g).normalize(),n[3].setComponents(s-a,h-u,v-f,_-g).normalize(),n[4].setComponents(s-o,h-c,v-p,_-y).normalize(),t===ut)n[5].setComponents(s+o,h+c,v+p,_+y).normalize();else{if(t!==ct)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(o,c,p,y).normalize()}return this}},{key:"intersectsObject",value:function(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Aa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{var t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Aa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Aa)}},{key:"intersectsSprite",value:function(e){return Aa.center.set(0,0,0),Aa.radius=.7071067811865476,Aa.applyMatrix4(e.matrixWorld),this.intersectsSphere(Aa)}},{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(Ra.x=i.normal.x>0?e.max.x:e.min.x,Ra.y=i.normal.y>0?e.max.y:e.min.y,Ra.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ra)<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)}}])}();function ka(e,t){return e-t}function Ia(e,t){return e.z-t.z}function Pa(e,t){return t.z-e.z}var La=function(){return o((function e(){r(this,e),this.index=0,this.pool=[],this.list=[]}),[{key:"push",value:function(e,t,n,i){var r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});var o=r[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=i}},{key:"reset",value:function(){this.list.length=0,this.index=0}}])}(),Na=new Pn,Ua=new Ti(1,1,1),Da=new Ca,Oa=new an,Fa=new bn,Ba=new tn,za=new tn,Ha=new tn,Va=new La,Ga=new hr,Wa=[];function ja(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor)for(var r=e.count,a=0;a<r;a++)for(var o=0;o<i;o++)t.setComponent(a+n,o,e.getComponent(a,o));else t.array.set(e.array,n*i);t.needsUpdate=!0}function Xa(e,t){if(e.constructor!==t.constructor)for(var n=Math.min(e.length,t.length),i=0;i<n;i++)t[i]=e[i];else{var r=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,r))}}var qa=function(e){function t(e,n){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2*n,s=arguments.length>3?arguments[3]:void 0;return r(this,t),(a=i(this,t,[new $i,s])).isBatchedMesh=!0,a.perObjectFrustumCulled=!0,a.sortObjects=!0,a.boundingBox=null,a.boundingSphere=null,a.customSort=null,a._instanceInfo=[],a._geometryInfo=[],a._availableInstanceIds=[],a._availableGeometryIds=[],a._nextIndexStart=0,a._nextVertexStart=0,a._geometryCount=0,a._visibilityChanged=!0,a._geometryInitialized=!1,a._maxInstanceCount=e,a._maxVertexCount=n,a._maxIndexCount=o,a._multiDrawCounts=new Int32Array(e),a._multiDrawStarts=new Int32Array(e),a._multiDrawCount=0,a._multiDrawInstances=null,a._matricesTexture=null,a._indirectTexture=null,a._colorsTexture=null,a._initMatricesTexture(),a._initIndirectTexture(),a}return h(t,e),o(t,[{key:"maxInstanceCount",get:function(){return this._maxInstanceCount}},{key:"instanceCount",get:function(){return this._instanceInfo.length-this._availableInstanceIds.length}},{key:"unusedVertexCount",get:function(){return this._maxVertexCount-this._nextVertexStart}},{key:"unusedIndexCount",get:function(){return this._maxIndexCount-this._nextIndexStart}},{key:"_initMatricesTexture",value:function(){var e=Math.sqrt(4*this._maxInstanceCount);e=4*Math.ceil(e/4),e=Math.max(e,4);var t=new Float32Array(e*e*4),n=new ca(t,e,e,ae,J);this._matricesTexture=n}},{key:"_initIndirectTexture",value:function(){var e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);var t=new Uint32Array(e*e),n=new ca(t,e,e,he,K);this._indirectTexture=n}},{key:"_initColorsTexture",value:function(){var e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);var t=new Float32Array(e*e*4).fill(1),n=new ca(t,e,e,ae,J);n.colorSpace=Ft.workingColorSpace,this._colorsTexture=n}},{key:"_initializeGeometry",value:function(e){var t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(var r in e.attributes){var a=e.getAttribute(r),o=a.array,s=a.itemSize,l=a.normalized,u=new o.constructor(n*s),c=new Di(u,s,l);t.setAttribute(r,c)}if(null!==e.getIndex()){var h=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Di(h,1))}this._geometryInitialized=!0}}},{key:"_validateGeometry",value:function(e){var t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(var n in t.attributes){if(!e.hasAttribute(n))throw new Error('THREE.BatchedMesh: Added geometry missing "'.concat(n,'". All geometries must have consistent attributes.'));var i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}},{key:"validateInstanceId",value:function(e){var t=this._instanceInfo;if(e<0||e>=t.length||!1===t[e].active)throw new Error("THREE.BatchedMesh: Invalid instanceId ".concat(e,". Instance is either out of range or has been deleted."))}},{key:"validateGeometryId",value:function(e){var t=this._geometryInfo;if(e<0||e>=t.length||!1===t[e].active)throw new Error("THREE.BatchedMesh: Invalid geometryId ".concat(e,". Geometry is either out of range or has been deleted."))}},{key:"setCustomSort",value:function(e){return this.customSort=e,this}},{key:"computeBoundingBox",value:function(){null===this.boundingBox&&(this.boundingBox=new an);var e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(var n=0,i=t.length;n<i;n++)if(!1!==t[n].active){var r=t[n].geometryIndex;this.getMatrixAt(n,Na),this.getBoundingBoxAt(r,Oa).applyMatrix4(Na),e.union(Oa)}}},{key:"computeBoundingSphere",value:function(){null===this.boundingSphere&&(this.boundingSphere=new bn);var e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(var n=0,i=t.length;n<i;n++)if(!1!==t[n].active){var r=t[n].geometryIndex;this.getMatrixAt(n,Na),this.getBoundingSphereAt(r,Fa).applyMatrix4(Na),e.union(Fa)}}},{key:"addInstance",value:function(e){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");var t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ka),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));var i=this._matricesTexture;Na.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;var r=this._colorsTexture;return r&&(Ua.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}},{key:"addGeometry",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;this._initializeGeometry(e),this._validateGeometry(e);var i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===t?e.getAttribute("position").count:t;var a,o=e.getIndex();if(null!==o&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?o.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ka),r[a=this._availableGeometryIds.shift()]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}},{key:"setGeometryAt",value:function(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);var n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(i&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");var s=o.vertexStart,l=o.reservedVertexCount;for(var u in o.vertexCount=t.getAttribute("position").count,n.attributes){var c=t.getAttribute(u),h=n.getAttribute(u);ja(c,h,s);for(var d=c.itemSize,f=c.count,p=l;f<p;f++)for(var v=s+f,m=0;m<d;m++)h.setComponent(v,m,0);h.needsUpdate=!0,h.addUpdateRange(s*d,l*d)}if(i){var g=o.indexStart,y=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(var _=0;_<a.count;_++)r.setX(g+_,s+a.getX(_));for(var x=a.count,M=y;x<M;x++)r.setX(g+x,s);r.needsUpdate=!0,r.addUpdateRange(g,o.reservedIndexCount)}return o.start=i?o.indexStart:o.vertexStart,o.count=i?o.indexCount:o.vertexCount,o.boundingBox=null,null!==t.boundingBox&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,null!==t.boundingSphere&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}},{key:"deleteGeometry",value:function(e){var t=this._geometryInfo;if(e>=t.length||!1===t[e].active)return this;for(var n=this._instanceInfo,i=0,r=n.length;i<r;i++)n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}},{key:"deleteInstance",value:function(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}},{key:"optimize",value:function(){for(var e=0,t=0,n=this._geometryInfo,i=n.map((function(e,t){return t})).sort((function(e,t){return n[e].vertexStart-n[t].vertexStart})),r=this.geometry,a=0,o=n.length;a<o;a++){var s=i[a],l=n[s];if(!1!==l.active){if(null!==r.index){if(l.indexStart!==t){for(var u=l.indexStart,c=l.vertexStart,h=l.reservedIndexCount,d=r.index,f=d.array,p=e-c,v=u;v<u+h;v++)f[v]=f[v]+p;d.array.copyWithin(t,u,u+h),d.addUpdateRange(t,h),l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){var m=l.vertexStart,g=l.reservedVertexCount,y=r.attributes;for(var _ in y){var x=y[_],M=x.array,S=x.itemSize;M.copyWithin(e*S,m*S,(m+g)*S),x.addUpdateRange(e*S,g*S)}l.vertexStart=e}e+=l.reservedVertexCount,l.start=r.index?l.indexStart:l.vertexStart,this._nextIndexStart=r.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}},{key:"getBoundingBoxAt",value:function(e,t){if(e>=this._geometryCount)return null;var n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingBox){for(var r=new an,a=n.index,o=n.attributes.position,s=i.start,l=i.start+i.count;s<l;s++){var u=s;a&&(u=a.getX(u)),r.expandByPoint(Ba.fromBufferAttribute(o,u))}i.boundingBox=r}return t.copy(i.boundingBox),t}},{key:"getBoundingSphereAt",value:function(e,t){if(e>=this._geometryCount)return null;var n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingSphere){var r=new bn;this.getBoundingBoxAt(e,Oa),Oa.getCenter(r.center);for(var a=n.index,o=n.attributes.position,s=0,l=i.start,u=i.start+i.count;l<u;l++){var c=l;a&&(c=a.getX(c)),Ba.fromBufferAttribute(o,c),s=Math.max(s,r.center.distanceToSquared(Ba))}r.radius=Math.sqrt(s),i.boundingSphere=r}return t.copy(i.boundingSphere),t}},{key:"setMatrixAt",value:function(e,t){this.validateInstanceId(e);var n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,16*e),n.needsUpdate=!0,this}},{key:"getMatrixAt",value:function(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,16*e)}},{key:"setColorAt",value:function(e,t){return this.validateInstanceId(e),null===this._colorsTexture&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,4*e),this._colorsTexture.needsUpdate=!0,this}},{key:"getColorAt",value:function(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,4*e)}},{key:"setVisibleAt",value:function(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(this._instanceInfo[e].visible=t,this._visibilityChanged=!0),this}},{key:"getVisibleAt",value:function(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}},{key:"setGeometryIdAt",value:function(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}},{key:"getGeometryIdAt",value:function(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}},{key:"getGeometryRangeAt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.validateGeometryId(e);var n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}},{key:"setInstanceCount",value:function(e){var t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(ka);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error("BatchedMesh: Instance ids outside the range ".concat(e," are being used. Cannot shrink instance count."));var i=new Int32Array(e),r=new Int32Array(e);Xa(this._multiDrawCounts,i),Xa(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=e;var a=this._indirectTexture,o=this._matricesTexture,s=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Xa(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),Xa(o.image.data,this._matricesTexture.image.data),s&&(s.dispose(),this._initColorsTexture(),Xa(s.image.data,this._colorsTexture.image.data))}},{key:"setGeometrySize",value:function(e,t){var n=_(this._geometryInfo).filter((function(e){return e.active}));if(Math.max.apply(Math,_(n.map((function(e){return e.vertexStart+e.reservedVertexCount}))))>e)throw new Error("BatchedMesh: Geometry vertex values are being used outside the range ".concat(t,". Cannot shrink further."));if(this.geometry.index&&Math.max.apply(Math,_(n.map((function(e){return e.indexStart+e.reservedIndexCount}))))>t)throw new Error("BatchedMesh: Geometry index values are being used outside the range ".concat(t,". Cannot shrink further."));var i=this.geometry;i.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new $i,this._initializeGeometry(i));var r=this.geometry;for(var a in i.index&&Xa(i.index.array,r.index.array),i.attributes)Xa(i.attributes[a].array,r.attributes[a].array)}},{key:"raycast",value:function(e,t){var n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;Ga.material=this.material,Ga.geometry.index=a.index,Ga.geometry.attributes=a.attributes,null===Ga.geometry.boundingBox&&(Ga.geometry.boundingBox=new an),null===Ga.geometry.boundingSphere&&(Ga.geometry.boundingSphere=new bn);for(var o=0,s=n.length;o<s;o++)if(n[o].visible&&n[o].active){var l=n[o].geometryIndex,u=i[l];Ga.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,Ga.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,Ga.geometry.boundingBox),this.getBoundingSphereAt(l,Ga.geometry.boundingSphere),Ga.raycast(e,Wa);for(var c=0,h=Wa.length;c<h;c++){var d=Wa[c];d.object=this,d.batchId=o,t.push(d)}Wa.length=0}Ga.material=null,Ga.geometry.index=null,Ga.geometry.attributes={},Ga.geometry.setDrawRange(0,1/0)}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=null!==e.boundingBox?e.boundingBox.clone():null,this.boundingSphere=null!==e.boundingSphere?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map((function(e){return p(p({},e),{},{boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})})),this._instanceInfo=e._instanceInfo.map((function(e){return p({},e)})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}},{key:"dispose",value:function(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}},{key:"onBeforeRender",value:function(e,t,n,i,r){if(this._visibilityChanged||this.perObjectFrustumCulled||this.sortObjects){var a=i.getIndex(),o=null===a?1:a.array.BYTES_PER_ELEMENT,s=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,c=this._geometryInfo,h=this.perObjectFrustumCulled,d=this._indirectTexture,f=d.image.data;h&&(Na.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Da.setFromProjectionMatrix(Na,e.coordinateSystem));var p=0;if(this.sortObjects){Na.copy(this.matrixWorld).invert(),Ba.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Na),za.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Na);for(var v=0,m=s.length;v<m;v++)if(s[v].visible&&s[v].active){var g=s[v].geometryIndex;this.getMatrixAt(v,Na),this.getBoundingSphereAt(g,Fa).applyMatrix4(Na);var y=!1;if(h&&(y=!Da.intersectsSphere(Fa)),!y){var _=c[g],x=Ha.subVectors(Fa.center,Ba).dot(za);Va.push(_.start,_.count,x,v)}}var M=Va.list,S=this.customSort;null===S?M.sort(r.transparent?Pa:Ia):S.call(this,M,n);for(var b=0,T=M.length;b<T;b++){var E=M[b];l[p]=E.start*o,u[p]=E.count,f[p]=E.index,p++}Va.reset()}else for(var w=0,A=s.length;w<A;w++)if(s[w].visible&&s[w].active){var R=s[w].geometryIndex,C=!1;if(h&&(this.getMatrixAt(w,Na),this.getBoundingSphereAt(R,Fa).applyMatrix4(Na),C=!Da.intersectsSphere(Fa)),!C){var k=c[R];l[p]=k.start*o,u[p]=k.count,f[p]=w,p++}}d.needsUpdate=!0,this._multiDrawCount=p,this._visibilityChanged=!1}}},{key:"onBeforeShadow",value:function(e,t,n,i,r,a){this.onBeforeRender(e,null,i,r,a)}}])}(hr),Ya=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isLineBasicMaterial=!0,n.type="LineBasicMaterial",n.color=new Ti(16777215),n.map=null,n.linewidth=1,n.linecap="round",n.linejoin="round",n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}])}(Ai),Za=new tn,Ka=new tn,Ja=new Pn,Qa=new In,$a=new bn,eo=new tn,to=new tn,no=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new $i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ya;return r(this,t),(e=i(this,t)).isLine=!0,e.type="Line",e.geometry=n,e.material=a,e.updateMorphTargets(),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.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++)Za.fromBufferAttribute(t,i-1),Ka.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Za.distanceTo(Ka);e.setAttribute("lineDistance",new ji(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(),$a.copy(n.boundingSphere),$a.applyMatrix4(i),$a.radius+=r,!1!==e.ray.intersectsSphere($a)){Ja.copy(i).invert(),Qa.copy(e.ray).applyMatrix4(Ja);var o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,l=this.isLineSegments?2:1,u=n.index,c=n.attributes.position;if(null!==u){for(var h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count),f=h,p=d-1;f<p;f+=l){var v=u.getX(f),m=u.getX(f+1),g=io(this,e,Qa,s,v,m);g&&t.push(g)}if(this.isLineLoop){var y=u.getX(d-1),_=u.getX(h),x=io(this,e,Qa,s,y,_);x&&t.push(x)}}else{for(var M=Math.max(0,a.start),S=Math.min(c.count,a.start+a.count),b=M,T=S-1;b<T;b+=l){var E=io(this,e,Qa,s,b,b+1);E&&t.push(E)}if(this.isLineLoop){var w=io(this,e,Qa,s,S-1,M);w&&t.push(w)}}}}},{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}}}}}])}(ai);function io(e,t,n,i,r,a){var o=e.geometry.attributes.position;if(Za.fromBufferAttribute(o,r),Ka.fromBufferAttribute(o,a),!(n.distanceSqToSegment(Za,Ka,eo,to)>i)){eo.applyMatrix4(e.matrixWorld);var s=t.ray.origin.distanceTo(eo);if(!(s<t.near||s>t.far))return{distance:s,point:to.clone().applyMatrix4(e.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:e}}}var ro=new tn,ao=new tn,oo=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e,n])).isLineSegments=!0,a.type="LineSegments",a}return h(t,e),o(t,[{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)ro.fromBufferAttribute(t,i),ao.fromBufferAttribute(t,i+1),n[i]=0===i?0:n[i-1],n[i+1]=n[i]+ro.distanceTo(ao);e.setAttribute("lineDistance",new ji(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}])}(no),so=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e,n])).isLineLoop=!0,a.type="LineLoop",a}return h(t,e),o(t)}(no),lo=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isPointsMaterial=!0,n.type="PointsMaterial",n.color=new Ti(16777215),n.map=null,n.alphaMap=null,n.size=1,n.sizeAttenuation=!0,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}])}(Ai),uo=new Pn,co=new In,ho=new bn,fo=new tn,po=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new $i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new lo;return r(this,t),(e=i(this,t)).isPoints=!0,e.type="Points",e.geometry=n,e.material=a,e.updateMorphTargets(),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.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(),ho.copy(n.boundingSphere),ho.applyMatrix4(i),ho.radius+=r,!1!==e.ray.intersectsSphere(ho)){uo.copy(i).invert(),co.copy(e.ray).applyMatrix4(uo);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);fo.fromBufferAttribute(u,d),vo(fo,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++)fo.fromBufferAttribute(u,f),vo(fo,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}}}}}])}(ai);function vo(e,t,n,i,r,a,o){var s=co.distanceSqToPoint(e);if(s<n){var l=new tn;co.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,faceIndex:null,barycoord:null,object:o})}}var mo=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isGroup=!0,e.type="Group",e}return h(t,e),o(t)}(ai),go=function(e){function t(e,n,a,o,s,l,u,c,h){var d;r(this,t),(d=i(this,t,[e,n,a,o,s,l,u,c,h])).isVideoTexture=!0,d.minFilter=void 0!==l?l:V,d.magFilter=void 0!==s?s:V,d.generateMipmaps=!1;var f=d;return"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){f.needsUpdate=!0,e.requestVideoFrameCallback(t)})),d}return h(t,e),o(t,[{key:"clone",value:function(){return new this.constructor(this.image).copy(this)}},{key:"update",value:function(){var e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}])}(Xt),yo=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[{width:e,height:n}])).isFramebufferTexture=!0,a.magFilter=B,a.minFilter=B,a.generateMipmaps=!1,a.needsUpdate=!0,a}return h(t,e),o(t)}(Xt),_o=function(e){function t(e,n,a,o,s,l,u,c,h,d,f,p){var v;return r(this,t),(v=i(this,t,[null,l,u,c,h,d,o,s,f,p])).isCompressedTexture=!0,v.image={width:n,height:a},v.mipmaps=e,v.flipY=!1,v.generateMipmaps=!1,v}return h(t,e),o(t)}(Xt),xo=function(e){function t(e,n,a,o,s,l){var u;return r(this,t),(u=i(this,t,[e,n,a,s,l])).isCompressedArrayTexture=!0,u.image.depth=o,u.wrapR=O,u.layerUpdates=new Set,u}return h(t,e),o(t,[{key:"addLayerUpdate",value:function(e){this.layerUpdates.add(e)}},{key:"clearLayerUpdates",value:function(){this.layerUpdates.clear()}}])}(_o),Mo=function(e){function t(e,n,a){var o;return r(this,t),(o=i(this,t,[void 0,e[0].width,e[0].height,n,a,I])).isCompressedCubeTexture=!0,o.isCubeTexture=!0,o.image=e,o}return h(t,e),o(t)}(_o),So=function(e){function t(e,n,a,o,s,l,u,c,h){var d;return r(this,t),(d=i(this,t,[e,n,a,o,s,l,u,c,h])).isCanvasTexture=!0,d.needsUpdate=!0,d}return h(t,e),o(t)}(Xt),bo=function(e){function t(e,n,a,o,s,l,u,c,h){var d,f=arguments.length>9&&void 0!==arguments[9]?arguments[9]:le;if(r(this,t),f!==le&&f!==ue)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");return void 0===a&&f===le&&(a=K),void 0===a&&f===ue&&(a=te),(d=i(this,t,[null,o,s,l,u,c,f,a,h])).isDepthTexture=!0,d.image={width:e,height:n},d.magFilter=void 0!==u?u:B,d.minFilter=void 0!==c?c:B,d.flipY=!1,d.generateMipmaps=!1,d.compareFunction=null,d}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.compareFunction=e.compareFunction,this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);return null!==this.compareFunction&&(n.compareFunction=this.compareFunction),n}}])}(Xt),To=function(){return o((function e(){r(this,e),this.type="Curve",this.arcLengthDivisions=200}),[{key:"getPoint",value:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}},{key:"getPointAt",value:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)}},{key:"getPoints",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}},{key:"getSpacedPoints",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}},{key:"getLength",value:function(){var e=this.getLengths();return e[e.length-1]}},{key:"getLengths",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.arcLengthDivisions;if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n=[],i=this.getPoint(0),r=0;n.push(0);for(var a=1;a<=e;a++)r+=(t=this.getPoint(a/e)).distanceTo(i),n.push(r),i=t;return this.cacheArcLengths=n,n}},{key:"updateArcLengths",value:function(){this.needsUpdate=!0,this.getLengths()}},{key:"getUtoTmapping",value:function(e,t){var n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];for(var o,s=0,l=a-1;s<=l;)if((o=i[r=Math.floor(s+(l-s)/2)]-n)<0)s=r+1;else{if(!(o>0)){l=r;break}l=r-1}if(i[r=l]===n)return r/(a-1);var u=i[r];return(r+(n-u)/(i[r+1]-u))/(a-1)}},{key:"getTangent",value:function(e,t){var n=1e-4,i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);var a=this.getPoint(i),o=this.getPoint(r),s=t||(a.isVector2?new bt:new tn);return s.copy(o).sub(a).normalize(),s}},{key:"getTangentAt",value:function(e,t){var n=this.getUtoTmapping(e);return this.getTangent(n,t)}},{key:"computeFrenetFrames",value:function(e,t){for(var n=new tn,i=[],r=[],a=[],o=new tn,s=new Pn,l=0;l<=e;l++){var u=l/e;i[l]=this.getTangentAt(u,new tn)}r[0]=new tn,a[0]=new tn;var c=Number.MAX_VALUE,h=Math.abs(i[0].x),d=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),f<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(var p=1;p<=e;p++){if(r[p]=r[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(i[p-1],i[p]),o.length()>Number.EPSILON){o.normalize();var v=Math.acos(gt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(s.makeRotationAxis(o,v))}a[p].crossVectors(i[p],r[p])}if(!0===t){var m=Math.acos(gt(r[0].dot(r[e]),-1,1));m/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(m=-m);for(var g=1;g<=e;g++)r[g].applyMatrix4(s.makeRotationAxis(i[g],m*g)),a[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:a}}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"copy",value:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},{key:"toJSON",value:function(){var e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}},{key:"fromJSON",value:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}])}(),Eo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI,c=arguments.length>6&&void 0!==arguments[6]&&arguments[6],h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0;return r(this,t),(e=i(this,t)).isEllipseCurve=!0,e.type="EllipseCurve",e.aX=n,e.aY=a,e.xRadius=o,e.yRadius=s,e.aStartAngle=l,e.aEndAngle=u,e.aClockwise=c,e.aRotation=h,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,n=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)<Number.EPSILON;i<0;)i+=n;for(;i>n;)i-=n;i<Number.EPSILON&&(i=r?0:n),!0!==this.aClockwise||r||(i===n?i=-n:i-=n);var a=this.aStartAngle+e*i,o=this.aX+this.xRadius*Math.cos(a),s=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){var l=Math.cos(this.aRotation),u=Math.sin(this.aRotation),c=o-this.aX,h=s-this.aY;o=c*l-h*u+this.aX,s=c*u+h*l+this.aY}return t.set(o,s)}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}])}(To),wo=function(e){function t(e,n,a,o,s,l){var u;return r(this,t),(u=i(this,t,[e,n,a,a,o,s,l])).isArcCurve=!0,u.type="ArcCurve",u}return h(t,e),o(t)}(Eo);function Ao(){var e=0,t=0,n=0,i=0;function r(r,a,o,s){e=r,t=o,n=-3*r+3*a-2*o-s,i=2*r-2*a+o+s}return{initCatmullRom:function(e,t,n,i,a){r(t,n,a*(n-e),a*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,a,o,s){var l=(t-e)/a-(n-e)/(a+o)+(n-t)/o,u=(n-t)/o-(i-t)/(o+s)+(i-n)/s;r(t,n,l*=o,u*=o)},calc:function(r){var a=r*r;return e+t*r+n*a+i*(a*r)}}}var Ro=new tn,Co=new Ao,ko=new Ao,Io=new Ao,Po=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"centripetal",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;return r(this,t),(e=i(this,t)).isCatmullRomCurve3=!0,e.type="CatmullRomCurve3",e.points=n,e.closed=a,e.curveType=o,e.tension=s,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,r=this.points,a=r.length,o=(a-(this.closed?0:1))*e,s=Math.floor(o),l=o-s;this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===l&&s===a-1&&(s=a-2,l=1),this.closed||s>0?t=r[(s-1)%a]:(Ro.subVectors(r[0],r[1]).add(r[0]),t=Ro);var u=r[s%a],c=r[(s+1)%a];if(this.closed||s+2<a?n=r[(s+2)%a]:(Ro.subVectors(r[a-1],r[a-2]).add(r[a-1]),n=Ro),"centripetal"===this.curveType||"chordal"===this.curveType){var h="chordal"===this.curveType?.5:.25,d=Math.pow(t.distanceToSquared(u),h),f=Math.pow(u.distanceToSquared(c),h),p=Math.pow(c.distanceToSquared(n),h);f<1e-4&&(f=1),d<1e-4&&(d=f),p<1e-4&&(p=f),Co.initNonuniformCatmullRom(t.x,u.x,c.x,n.x,d,f,p),ko.initNonuniformCatmullRom(t.y,u.y,c.y,n.y,d,f,p),Io.initNonuniformCatmullRom(t.z,u.z,c.z,n.z,d,f,p)}else"catmullrom"===this.curveType&&(Co.initCatmullRom(t.x,u.x,c.x,n.x,this.tension),ko.initCatmullRom(t.y,u.y,c.y,n.y,this.tension),Io.initCatmullRom(t.z,u.z,c.z,n.z,this.tension));return i.set(Co.calc(l),ko.calc(l),Io.calc(l)),i}},{key:"copy",value:function(e){y(t,"copy",this)([e]),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var r=e.points[n];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);e.points=[];for(var n=0,i=this.points.length;n<i;n++){var r=this.points[n];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}},{key:"fromJSON",value:function(e){y(t,"fromJSON",this)([e]),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var r=e.points[n];this.points.push((new tn).fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}])}(To);function Lo(e,t,n,i,r){var a=.5*(i-t),o=.5*(r-n),s=e*e;return(2*n-2*i+a+o)*(e*s)+(-3*n+3*i-2*a-o)*s+a*e+n}function No(e,t,n,i){return function(e,t){var n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,i)}function Uo(e,t,n,i,r){return function(e,t){var n=1-e;return n*n*n*t}(e,t)+function(e,t){var n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,i)+function(e,t){return e*e*e*t}(e,r)}var Do=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new bt,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new bt,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new bt;return r(this,t),(e=i(this,t)).isCubicBezierCurve=!0,e.type="CubicBezierCurve",e.v0=n,e.v1=a,e.v2=o,e.v3=s,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,n=this.v0,i=this.v1,r=this.v2,a=this.v3;return t.set(Uo(e,n.x,i.x,r.x,a.x),Uo(e,n.y,i.y,r.y,a.y)),t}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}])}(To),Oo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new tn,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new tn;return r(this,t),(e=i(this,t)).isCubicBezierCurve3=!0,e.type="CubicBezierCurve3",e.v0=n,e.v1=a,e.v2=o,e.v3=s,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,n=this.v0,i=this.v1,r=this.v2,a=this.v3;return t.set(Uo(e,n.x,i.x,r.x,a.x),Uo(e,n.y,i.y,r.y,a.y),Uo(e,n.z,i.z,r.z,a.z)),t}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}])}(To),Fo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new bt,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt;return r(this,t),(e=i(this,t)).isLineCurve=!0,e.type="LineCurve",e.v1=n,e.v2=a,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}},{key:"getPointAt",value:function(e,t){return this.getPoint(e,t)}},{key:"getTangent",value:function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt).subVectors(this.v2,this.v1).normalize()}},{key:"getTangentAt",value:function(e,t){return this.getTangent(e,t)}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}])}(To),Bo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn;return r(this,t),(e=i(this,t)).isLineCurve3=!0,e.type="LineCurve3",e.v1=n,e.v2=a,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}},{key:"getPointAt",value:function(e,t){return this.getPoint(e,t)}},{key:"getTangent",value:function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn).subVectors(this.v2,this.v1).normalize()}},{key:"getTangentAt",value:function(e,t){return this.getTangent(e,t)}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}])}(To),zo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new bt,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new bt;return r(this,t),(e=i(this,t)).isQuadraticBezierCurve=!0,e.type="QuadraticBezierCurve",e.v0=n,e.v1=a,e.v2=o,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,n=this.v0,i=this.v1,r=this.v2;return t.set(No(e,n.x,i.x,r.x),No(e,n.y,i.y,r.y)),t}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}])}(To),Ho=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new tn;return r(this,t),(e=i(this,t)).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=n,e.v1=a,e.v2=o,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn,n=this.v0,i=this.v1,r=this.v2;return t.set(No(e,n.x,i.x,r.x),No(e,n.y,i.y,r.y),No(e,n.z,i.z,r.z)),t}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}])}(To),Vo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return r(this,t),(e=i(this,t)).isSplineCurve=!0,e.type="SplineCurve",e.points=n,e}return h(t,e),o(t,[{key:"getPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt,n=this.points,i=(n.length-1)*e,r=Math.floor(i),a=i-r,o=n[0===r?r:r-1],s=n[r],l=n[r>n.length-2?n.length-1:r+1],u=n[r>n.length-3?n.length-1:r+2];return t.set(Lo(a,o.x,s.x,l.x,u.x),Lo(a,o.y,s.y,l.y,u.y)),t}},{key:"copy",value:function(e){y(t,"copy",this)([e]),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var r=e.points[n];this.points.push(r.clone())}return this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);e.points=[];for(var n=0,i=this.points.length;n<i;n++){var r=this.points[n];e.points.push(r.toArray())}return e}},{key:"fromJSON",value:function(e){y(t,"fromJSON",this)([e]),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var r=e.points[n];this.points.push((new bt).fromArray(r))}return this}}])}(To),Go=Object.freeze({__proto__:null,ArcCurve:wo,CatmullRomCurve3:Po,CubicBezierCurve:Do,CubicBezierCurve3:Oo,EllipseCurve:Eo,LineCurve:Fo,LineCurve3:Bo,QuadraticBezierCurve:zo,QuadraticBezierCurve3:Ho,SplineCurve:Vo}),Wo=function(e){function t(){var e;return r(this,t),(e=i(this,t)).type="CurvePath",e.curves=[],e.autoClose=!1,e}return h(t,e),o(t,[{key:"add",value:function(e){this.curves.push(e)}},{key:"closePath",value:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){var n=!0===e.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Go[n](t,e))}return this}},{key:"getPoint",value:function(e,t){for(var n=e*this.getLength(),i=this.getCurveLengths(),r=0;r<i.length;){if(i[r]>=n){var a=i[r]-n,o=this.curves[r],s=o.getLength(),l=0===s?0:1-a/s;return o.getPointAt(l,t)}r++}return null}},{key:"getLength",value:function(){var e=this.getCurveLengths();return e[e.length-1]}},{key:"updateArcLengths",value:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}},{key:"getCurveLengths",value:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}},{key:"getSpacedPoints",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:40,t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}},{key:"getPoints",value:function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,n=[],i=0,r=this.curves;i<r.length;i++)for(var a=r[i],o=a.isEllipseCurve?2*t:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,s=a.getPoints(o),l=0;l<s.length;l++){var u=s[l];e&&e.equals(u)||(n.push(u),e=u)}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}},{key:"copy",value:function(e){y(t,"copy",this)([e]),this.curves=[];for(var n=0,i=e.curves.length;n<i;n++){var r=e.curves[n];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);e.autoClose=this.autoClose,e.curves=[];for(var n=0,i=this.curves.length;n<i;n++){var r=this.curves[n];e.curves.push(r.toJSON())}return e}},{key:"fromJSON",value:function(e){y(t,"fromJSON",this)([e]),this.autoClose=e.autoClose,this.curves=[];for(var n=0,i=e.curves.length;n<i;n++){var r=e.curves[n];this.curves.push((new Go[r.type]).fromJSON(r))}return this}}])}(To),jo=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).type="Path",n.currentPoint=new bt,e&&n.setFromPoints(e),n}return h(t,e),o(t,[{key:"setFromPoints",value:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}},{key:"moveTo",value:function(e,t){return this.currentPoint.set(e,t),this}},{key:"lineTo",value:function(e,t){var n=new Fo(this.currentPoint.clone(),new bt(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}},{key:"quadraticCurveTo",value:function(e,t,n,i){var r=new zo(this.currentPoint.clone(),new bt(e,t),new bt(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}},{key:"bezierCurveTo",value:function(e,t,n,i,r,a){var o=new Do(this.currentPoint.clone(),new bt(e,t),new bt(n,i),new bt(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}},{key:"splineThru",value:function(e){var t=[this.currentPoint.clone()].concat(e),n=new Vo(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}},{key:"arc",value:function(e,t,n,i,r,a){var o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,i,r,a),this}},{key:"absarc",value:function(e,t,n,i,r,a){return this.absellipse(e,t,n,n,i,r,a),this}},{key:"ellipse",value:function(e,t,n,i,r,a,o,s){var l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,r,a,o,s),this}},{key:"absellipse",value:function(e,t,n,i,r,a,o,s){var l=new Eo(e,t,n,i,r,a,o,s);if(this.curves.length>0){var u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);var c=l.getPoint(1);return this.currentPoint.copy(c),this}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.currentPoint.copy(e.currentPoint),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.currentPoint=this.currentPoint.toArray(),e}},{key:"fromJSON",value:function(e){return y(t,"fromJSON",this)([e]),this.currentPoint.fromArray(e.currentPoint),this}}])}(Wo),Xo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[new bt(0,-.5),new bt(.5,0),new bt(0,.5)],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;r(this,t),(e=i(this,t)).type="LatheGeometry",e.parameters={points:n,segments:a,phiStart:o,phiLength:s},a=Math.floor(a),s=gt(s,0,2*Math.PI);for(var l=[],u=[],c=[],h=[],d=[],f=1/a,p=new tn,v=new bt,m=new tn,g=new tn,y=new tn,_=0,x=0,M=0;M<=n.length-1;M++)switch(M){case 0:_=n[M+1].x-n[M].x,x=n[M+1].y-n[M].y,m.x=1*x,m.y=-_,m.z=0*x,y.copy(m),m.normalize(),h.push(m.x,m.y,m.z);break;case n.length-1:h.push(y.x,y.y,y.z);break;default:_=n[M+1].x-n[M].x,x=n[M+1].y-n[M].y,m.x=1*x,m.y=-_,m.z=0*x,g.copy(m),m.x+=y.x,m.y+=y.y,m.z+=y.z,m.normalize(),h.push(m.x,m.y,m.z),y.copy(g)}for(var S=0;S<=a;S++)for(var b=o+S*f*s,T=Math.sin(b),E=Math.cos(b),w=0;w<=n.length-1;w++){p.x=n[w].x*T,p.y=n[w].y,p.z=n[w].x*E,u.push(p.x,p.y,p.z),v.x=S/a,v.y=w/(n.length-1),c.push(v.x,v.y);var A=h[3*w+0]*T,R=h[3*w+1],C=h[3*w+0]*E;d.push(A,R,C)}for(var k=0;k<a;k++)for(var I=0;I<n.length-1;I++){var P=I+k*n.length,L=P,N=P+n.length,U=P+n.length+1,D=P+1;l.push(L,N,D),l.push(U,D,N)}return e.setIndex(l),e.setAttribute("position",new ji(u,3)),e.setAttribute("uv",new ji(c,2)),e.setAttribute("normal",new ji(d,3)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.points,e.segments,e.phiStart,e.phiLength)}}])}($i),qo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8;r(this,t);var l=new jo;return l.absarc(0,-a/2,n,1.5*Math.PI,0),l.absarc(0,a/2,n,0,.5*Math.PI),(e=i(this,t,[l.getPoints(o),s])).type="CapsuleGeometry",e.parameters={radius:n,length:a,capSegments:o,radialSegments:s},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.length,e.capSegments,e.radialSegments)}}])}(Xo),Yo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;r(this,t),(e=i(this,t)).type="CircleGeometry",e.parameters={radius:n,segments:a,thetaStart:o,thetaLength:s},a=Math.max(3,a);var l=[],u=[],c=[],h=[],d=new tn,f=new bt;u.push(0,0,0),c.push(0,0,1),h.push(.5,.5);for(var p=0,v=3;p<=a;p++,v+=3){var m=o+p/a*s;d.x=n*Math.cos(m),d.y=n*Math.sin(m),u.push(d.x,d.y,d.z),c.push(0,0,1),f.x=(u[v]/n+1)/2,f.y=(u[v+1]/n+1)/2,h.push(f.x,f.y)}for(var g=1;g<=a;g++)l.push(g,g+1,0);return e.setIndex(l),e.setAttribute("position",new ji(u,3)),e.setAttribute("normal",new ji(c,3)),e.setAttribute("uv",new ji(h,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.radius,e.segments,e.thetaStart,e.thetaLength)}}])}($i),Zo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,u=arguments.length>5&&void 0!==arguments[5]&&arguments[5],c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:2*Math.PI;r(this,t),(e=i(this,t)).type="CylinderGeometry",e.parameters={radiusTop:n,radiusBottom:a,height:o,radialSegments:s,heightSegments:l,openEnded:u,thetaStart:c,thetaLength:h};var d=e;s=Math.floor(s),l=Math.floor(l);var f=[],p=[],v=[],m=[],g=0,y=[],_=o/2,x=0;function M(e){for(var t=g,i=new bt,r=new tn,o=0,l=!0===e?n:a,u=!0===e?1:-1,y=1;y<=s;y++)p.push(0,_*u,0),v.push(0,u,0),m.push(.5,.5),g++;for(var M=g,S=0;S<=s;S++){var b=S/s*h+c,T=Math.cos(b),E=Math.sin(b);r.x=l*E,r.y=_*u,r.z=l*T,p.push(r.x,r.y,r.z),v.push(0,u,0),i.x=.5*T+.5,i.y=.5*E*u+.5,m.push(i.x,i.y),g++}for(var w=0;w<s;w++){var A=t+w,R=M+w;!0===e?f.push(R,R+1,A):f.push(R+1,R,A),o+=3}d.addGroup(x,o,!0===e?1:2),x+=o}return function(){for(var e=new tn,t=new tn,i=0,r=(a-n)/o,u=0;u<=l;u++){for(var M=[],S=u/l,b=S*(a-n)+n,T=0;T<=s;T++){var E=T/s,w=E*h+c,A=Math.sin(w),R=Math.cos(w);t.x=b*A,t.y=-S*o+_,t.z=b*R,p.push(t.x,t.y,t.z),e.set(A,r,R).normalize(),v.push(e.x,e.y,e.z),m.push(E,1-S),M.push(g++)}y.push(M)}for(var C=0;C<s;C++)for(var k=0;k<l;k++){var I=y[k][C],P=y[k+1][C],L=y[k+1][C+1],N=y[k][C+1];(n>0||0!==k)&&(f.push(I,P,N),i+=3),(a>0||k!==l-1)&&(f.push(P,L,N),i+=3)}d.addGroup(x,i,0),x+=i}(),!1===u&&(n>0&&M(!0),a>0&&M(!1)),e.setIndex(f),e.setAttribute("position",new ji(p,3)),e.setAttribute("normal",new ji(v,3)),e.setAttribute("uv",new ji(m,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}])}($i),Ko=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:2*Math.PI;return r(this,t),(e=i(this,t,[0,n,a,o,s,l,u,c])).type="ConeGeometry",e.parameters={radius:n,height:a,radialSegments:o,heightSegments:s,openEnded:l,thetaStart:u,thetaLength:c},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}])}(Zo),Jo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;r(this,t),(e=i(this,t)).type="PolyhedronGeometry",e.parameters={vertices:n,indices:a,radius:o,detail:s};var l=[],u=[];function c(e,t,n,i){for(var r=i+1,a=[],o=0;o<=r;o++){a[o]=[];for(var s=e.clone().lerp(n,o/r),l=t.clone().lerp(n,o/r),u=r-o,c=0;c<=u;c++)a[o][c]=0===c&&o===r?s:s.clone().lerp(l,c/u)}for(var d=0;d<r;d++)for(var f=0;f<2*(r-d)-1;f++){var p=Math.floor(f/2);f%2==0?(h(a[d][p+1]),h(a[d+1][p]),h(a[d][p])):(h(a[d][p+1]),h(a[d+1][p+1]),h(a[d+1][p]))}}function h(e){l.push(e.x,e.y,e.z)}function d(e,t){var i=3*e;t.x=n[i+0],t.y=n[i+1],t.z=n[i+2]}function f(e,t,n,i){i<0&&1===e.x&&(u[t]=e.x-1),0===n.x&&0===n.z&&(u[t]=i/2/Math.PI+.5)}function p(e){return Math.atan2(e.z,-e.x)}return function(e){for(var t=new tn,n=new tn,i=new tn,r=0;r<a.length;r+=3)d(a[r+0],t),d(a[r+1],n),d(a[r+2],i),c(t,n,i,e)}(s),function(e){for(var t=new tn,n=0;n<l.length;n+=3)t.x=l[n+0],t.y=l[n+1],t.z=l[n+2],t.normalize().multiplyScalar(e),l[n+0]=t.x,l[n+1]=t.y,l[n+2]=t.z}(o),function(){for(var e=new tn,t=0;t<l.length;t+=3){e.x=l[t+0],e.y=l[t+1],e.z=l[t+2];var n=p(e)/2/Math.PI+.5,i=(r=e,Math.atan2(-r.y,Math.sqrt(r.x*r.x+r.z*r.z))/Math.PI+.5);u.push(n,1-i)}var r;(function(){for(var e=new tn,t=new tn,n=new tn,i=new tn,r=new bt,a=new bt,o=new bt,s=0,c=0;s<l.length;s+=9,c+=6){e.set(l[s+0],l[s+1],l[s+2]),t.set(l[s+3],l[s+4],l[s+5]),n.set(l[s+6],l[s+7],l[s+8]),r.set(u[c+0],u[c+1]),a.set(u[c+2],u[c+3]),o.set(u[c+4],u[c+5]),i.copy(e).add(t).add(n).divideScalar(3);var h=p(i);f(r,c+0,e,h),f(a,c+2,t,h),f(o,c+4,n,h)}})(),function(){for(var e=0;e<u.length;e+=6){var t=u[e+0],n=u[e+2],i=u[e+4],r=Math.max(t,n,i),a=Math.min(t,n,i);r>.9&&a<.1&&(t<.2&&(u[e+0]+=1),n<.2&&(u[e+2]+=1),i<.2&&(u[e+4]+=1))}}()}(),e.setAttribute("position",new ji(l,3)),e.setAttribute("normal",new ji(l.slice(),3)),e.setAttribute("uv",new ji(u,2)),0===s?e.computeVertexNormals():e.normalizeNormals(),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.vertices,e.indices,e.radius,e.details)}}])}($i),Qo=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,t);var o=(1+Math.sqrt(5))/2,s=1/o;return(e=i(this,t,[[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-o,0,-s,o,0,s,-o,0,s,o,-s,-o,0,-s,o,0,s,-o,0,s,o,0,-o,0,-s,o,0,-s,-o,0,s,o,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],n,a])).type="DodecahedronGeometry",e.parameters={radius:n,detail:a},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.detail)}}])}(Jo),$o=new tn,es=new tn,ts=new tn,ns=new _i,is=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r(this,t),(e=i(this,t)).type="EdgesGeometry",e.parameters={geometry:n,thresholdAngle:a},null!==n){for(var o=Math.pow(10,4),s=Math.cos(pt*a),l=n.getIndex(),u=n.getAttribute("position"),c=l?l.count:u.count,h=[0,0,0],d=["a","b","c"],f=new Array(3),p={},v=[],m=0;m<c;m+=3){l?(h[0]=l.getX(m),h[1]=l.getX(m+1),h[2]=l.getX(m+2)):(h[0]=m,h[1]=m+1,h[2]=m+2);var g=ns.a,y=ns.b,_=ns.c;if(g.fromBufferAttribute(u,h[0]),y.fromBufferAttribute(u,h[1]),_.fromBufferAttribute(u,h[2]),ns.getNormal(ts),f[0]="".concat(Math.round(g.x*o),",").concat(Math.round(g.y*o),",").concat(Math.round(g.z*o)),f[1]="".concat(Math.round(y.x*o),",").concat(Math.round(y.y*o),",").concat(Math.round(y.z*o)),f[2]="".concat(Math.round(_.x*o),",").concat(Math.round(_.y*o),",").concat(Math.round(_.z*o)),f[0]!==f[1]&&f[1]!==f[2]&&f[2]!==f[0])for(var x=0;x<3;x++){var M=(x+1)%3,S=f[x],b=f[M],T=ns[d[x]],E=ns[d[M]],w="".concat(S,"_").concat(b),A="".concat(b,"_").concat(S);A in p&&p[A]?(ts.dot(p[A].normal)<=s&&(v.push(T.x,T.y,T.z),v.push(E.x,E.y,E.z)),p[A]=null):w in p||(p[w]={index0:h[x],index1:h[M],normal:ts.clone()})}}for(var R in p)if(p[R]){var C=p[R],k=C.index0,I=C.index1;$o.fromBufferAttribute(u,k),es.fromBufferAttribute(u,I),v.push($o.x,$o.y,$o.z),v.push(es.x,es.y,es.z)}e.setAttribute("position",new ji(v,3))}return e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}])}($i),rs=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).uuid=mt(),n.type="Shape",n.holes=[],n}return h(t,e),o(t,[{key:"getPointsHoles",value:function(e){for(var t=[],n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}},{key:"extractPoints",value:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}},{key:"copy",value:function(e){y(t,"copy",this)([e]),this.holes=[];for(var n=0,i=e.holes.length;n<i;n++){var r=e.holes[n];this.holes.push(r.clone())}return this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);e.uuid=this.uuid,e.holes=[];for(var n=0,i=this.holes.length;n<i;n++){var r=this.holes[n];e.holes.push(r.toJSON())}return e}},{key:"fromJSON",value:function(e){y(t,"fromJSON",this)([e]),this.uuid=e.uuid,this.holes=[];for(var n=0,i=e.holes.length;n<i;n++){var r=e.holes[n];this.holes.push((new jo).fromJSON(r))}return this}}])}(jo),as=function(e,t){var n,i,r,a,o,s,l,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,c=t&&t.length,h=c?t[0]*u:e.length,d=os(e,0,h,u,!0),f=[];if(!d||d.next===d.prev)return f;if(c&&(d=function(e,t,n,i){var r,a,o,s=[];for(r=0,a=t.length;r<a;r++)(o=os(e,t[r]*i,r<a-1?t[r+1]*i:e.length,i,!1))===o.next&&(o.steiner=!0),s.push(gs(o));for(s.sort(fs),r=0;r<s.length;r++)n=ps(s[r],n);return n}(e,t,d,u)),e.length>80*u){n=r=e[0],i=a=e[1];for(var p=u;p<h;p+=u)(o=e[p])<n&&(n=o),(s=e[p+1])<i&&(i=s),o>r&&(r=o),s>a&&(a=s);l=0!==(l=Math.max(r-n,a-i))?32767/l:0}return ls(d,f,u,n,i,l,0),f};function os(e,t,n,i,r){var a,o;if(r===function(e,t,n,i){for(var r=0,a=t,o=n-i;a<n;a+=i)r+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return r}(e,t,n,i)>0)for(a=t;a<n;a+=i)o=As(a,e[a],e[a+1],o);else for(a=n-i;a>=t;a-=i)o=As(a,e[a],e[a+1],o);return o&&Ms(o,o.next)&&(Rs(o),o=o.next),o}function ss(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!Ms(i,i.next)&&0!==xs(i.prev,i,i.next))i=i.next;else{if(Rs(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function ls(e,t,n,i,r,a,o){if(e){!o&&a&&function(e,t,n,i){var r=e;do{0===r.z&&(r.z=ms(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,n,i,r,a,o,s,l,u=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t<u&&(s++,i=i.nextZ);t++);for(l=u;s>0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,u*=2}while(o>1)}(r)}(e,i,r,a);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?cs(e,i,r,a):us(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Rs(e),e=l.next,u=l.next;else if((e=l)===u){o?1===o?ls(e=hs(ss(e),t,n),t,n,i,r,a,2):2===o&&ds(e,t,n,i,r,a):ls(ss(e),t,n,i,r,a,1);break}}}function us(e){var t=e.prev,n=e,i=e.next;if(xs(t,n,i)>=0)return!1;for(var r=t.x,a=n.x,o=i.x,s=t.y,l=n.y,u=i.y,c=r<a?r<o?r:o:a<o?a:o,h=s<l?s<u?s:u:l<u?l:u,d=r>a?r>o?r:o:a>o?a:o,f=s>l?s>u?s:u:l>u?l:u,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&ys(r,s,a,l,o,u,p.x,p.y)&&xs(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function cs(e,t,n,i){var r=e.prev,a=e,o=e.next;if(xs(r,a,o)>=0)return!1;for(var s=r.x,l=a.x,u=o.x,c=r.y,h=a.y,d=o.y,f=s<l?s<u?s:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,v=s>l?s>u?s:u:l>u?l:u,m=c>h?c>d?c:d:h>d?h:d,g=ms(f,p,t,n,i),y=ms(v,m,t,n,i),_=e.prevZ,x=e.nextZ;_&&_.z>=g&&x&&x.z<=y;){if(_.x>=f&&_.x<=v&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ys(s,c,l,h,u,d,_.x,_.y)&&xs(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=f&&x.x<=v&&x.y>=p&&x.y<=m&&x!==r&&x!==o&&ys(s,c,l,h,u,d,x.x,x.y)&&xs(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=g;){if(_.x>=f&&_.x<=v&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ys(s,c,l,h,u,d,_.x,_.y)&&xs(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=v&&x.y>=p&&x.y<=m&&x!==r&&x!==o&&ys(s,c,l,h,u,d,x.x,x.y)&&xs(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function hs(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!Ms(r,a)&&Ss(r,i,i.next,a)&&Es(r,a)&&Es(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Rs(i),Rs(i.next),i=e=a),i=i.next}while(i!==e);return ss(i)}function ds(e,t,n,i,r,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&_s(o,s)){var l=ws(o,s);return o=ss(o,o.next),l=ss(l,l.next),ls(o,t,n,i,r,a,0),void ls(l,t,n,i,r,a,0)}s=s.next}o=o.next}while(o!==e)}function fs(e,t){return e.x-t.x}function ps(e,t){var n=function(e,t){var n,i=t,r=-1/0,a=e.x,o=e.y;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var s=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=a&&s>r&&(r=s,n=i.x<i.next.x?i:i.next,s===a))return n}i=i.next}while(i!==t);if(!n)return null;var l,u=n,c=n.x,h=n.y,d=1/0;i=n;do{a>=i.x&&i.x>=c&&a!==i.x&&ys(o<h?a:r,o,c,h,o<h?r:a,o,i.x,i.y)&&(l=Math.abs(o-i.y)/(a-i.x),Es(i,e)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&vs(n,i)))&&(n=i,d=l)),i=i.next}while(i!==u);return n}(e,t);if(!n)return t;var i=ws(n,e);return ss(i,i.next),ss(n,n.next)}function vs(e,t){return xs(e.prev,e,t.prev)<0&&xs(t.next,e,e.next)<0}function ms(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function gs(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function ys(e,t,n,i,r,a,o,s){return(r-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(i-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(r-o)*(i-s)}function _s(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ss(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Es(e,t)&&Es(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(xs(e.prev,e,t.prev)||xs(e,t.prev,t))||Ms(e,t)&&xs(e.prev,e,e.next)>0&&xs(t.prev,t,t.next)>0)}function xs(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ms(e,t){return e.x===t.x&&e.y===t.y}function Ss(e,t,n,i){var r=Ts(xs(e,t,n)),a=Ts(xs(e,t,i)),o=Ts(xs(n,i,e)),s=Ts(xs(n,i,t));return r!==a&&o!==s||(!(0!==r||!bs(e,n,t))||(!(0!==a||!bs(e,i,t))||(!(0!==o||!bs(n,e,i))||!(0!==s||!bs(n,t,i)))))}function bs(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Ts(e){return e>0?1:e<0?-1:0}function Es(e,t){return xs(e.prev,e,e.next)<0?xs(e,t,e.next)>=0&&xs(e,e.prev,t)>=0:xs(e,t,e.prev)<0||xs(e,e.next,t)<0}function ws(e,t){var n=new Cs(e.i,e.x,e.y),i=new Cs(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function As(e,t,n,i){var r=new Cs(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Rs(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Cs(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}var ks=function(){function e(){r(this,e)}return o(e,null,[{key:"area",value:function(e){for(var t=e.length,n=0,i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return.5*n}},{key:"isClockWise",value:function(t){return e.area(t)<0}},{key:"triangulateShape",value:function(e,t){var n=[],i=[],r=[];Is(e),Ps(n,e);var a=e.length;t.forEach(Is);for(var o=0;o<t.length;o++)i.push(a),a+=t[o].length,Ps(n,t[o]);for(var s=as(n,i),l=0;l<s.length;l+=3)r.push(s.slice(l,l+3));return r}}])}();function Is(e){var t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ps(e,t){for(var n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Ls=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new rs([new bt(.5,.5),new bt(-.5,.5),new bt(-.5,-.5),new bt(.5,-.5)]),a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,t),(e=i(this,t)).type="ExtrudeGeometry",e.parameters={shapes:n,options:a},n=Array.isArray(n)?n:[n];for(var o=e,s=[],l=[],u=0,c=n.length;u<c;u++){h(n[u])}function h(e){var t,n,i,r,u,c=[],h=void 0!==a.curveSegments?a.curveSegments:12,d=void 0!==a.steps?a.steps:1,f=void 0!==a.depth?a.depth:1,p=void 0===a.bevelEnabled||a.bevelEnabled,v=void 0!==a.bevelThickness?a.bevelThickness:.2,m=void 0!==a.bevelSize?a.bevelSize:v-.1,g=void 0!==a.bevelOffset?a.bevelOffset:0,y=void 0!==a.bevelSegments?a.bevelSegments:3,_=a.extrudePath,x=void 0!==a.UVGenerator?a.UVGenerator:Ns,M=!1;_&&(t=_.getSpacedPoints(d),M=!0,p=!1,n=_.computeFrenetFrames(d,!1),i=new tn,r=new tn,u=new tn),p||(y=0,v=0,m=0,g=0);var S=e.extractPoints(h),b=S.shape,T=S.holes;if(!ks.isClockWise(b)){b=b.reverse();for(var E=0,w=T.length;E<w;E++){var A=T[E];ks.isClockWise(A)&&(T[E]=A.reverse())}}for(var R=ks.triangulateShape(b,T),C=b,k=0,I=T.length;k<I;k++){var P=T[k];b=b.concat(P)}function L(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}var N=b.length,U=R.length;function D(e,t,n){var i,r,a,o=e.x-t.x,s=e.y-t.y,l=n.x-e.x,u=n.y-e.y,c=o*o+s*s,h=o*u-s*l;if(Math.abs(h)>Number.EPSILON){var d=Math.sqrt(c),f=Math.sqrt(l*l+u*u),p=t.x-s/d,v=t.y+o/d,m=((n.x-u/f-p)*u-(n.y+l/f-v)*l)/(o*u-s*l),g=(i=p+o*m-e.x)*i+(r=v+s*m-e.y)*r;if(g<=2)return new bt(i,r);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?l>Number.EPSILON&&(y=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(u)&&(y=!0),y?(i=-s,r=o,a=Math.sqrt(c)):(i=o,r=s,a=Math.sqrt(c/2))}return new bt(i/a,r/a)}for(var O=[],F=0,B=C.length,z=B-1,H=F+1;F<B;F++,z++,H++)z===B&&(z=0),H===B&&(H=0),O[F]=D(C[F],C[z],C[H]);for(var V,G=[],W=O.concat(),j=0,X=T.length;j<X;j++){var q=T[j];V=[];for(var Y=0,Z=q.length,K=Z-1,J=Y+1;Y<Z;Y++,K++,J++)K===Z&&(K=0),J===Z&&(J=0),V[Y]=D(q[Y],q[K],q[J]);G.push(V),W=W.concat(V)}for(var Q=0;Q<y;Q++){for(var $=Q/y,ee=v*Math.cos($*Math.PI/2),te=m*Math.sin($*Math.PI/2)+g,ne=0,ie=C.length;ne<ie;ne++){var re=L(C[ne],O[ne],te);Ie(re.x,re.y,-ee)}for(var ae=0,oe=T.length;ae<oe;ae++){var se=T[ae];V=G[ae];for(var le=0,ue=se.length;le<ue;le++){var ce=L(se[le],V[le],te);Ie(ce.x,ce.y,-ee)}}}for(var he=m+g,de=0;de<N;de++){var fe=p?L(b[de],W[de],he):b[de];M?(r.copy(n.normals[0]).multiplyScalar(fe.x),i.copy(n.binormals[0]).multiplyScalar(fe.y),u.copy(t[0]).add(r).add(i),Ie(u.x,u.y,u.z)):Ie(fe.x,fe.y,0)}for(var pe=1;pe<=d;pe++)for(var ve=0;ve<N;ve++){var me=p?L(b[ve],W[ve],he):b[ve];M?(r.copy(n.normals[pe]).multiplyScalar(me.x),i.copy(n.binormals[pe]).multiplyScalar(me.y),u.copy(t[pe]).add(r).add(i),Ie(u.x,u.y,u.z)):Ie(me.x,me.y,f/d*pe)}for(var ge=y-1;ge>=0;ge--){for(var ye=ge/y,_e=v*Math.cos(ye*Math.PI/2),xe=m*Math.sin(ye*Math.PI/2)+g,Me=0,Se=C.length;Me<Se;Me++){var be=L(C[Me],O[Me],xe);Ie(be.x,be.y,f+_e)}for(var Te=0,Ee=T.length;Te<Ee;Te++){var we=T[Te];V=G[Te];for(var Ae=0,Re=we.length;Ae<Re;Ae++){var Ce=L(we[Ae],V[Ae],xe);M?Ie(Ce.x,Ce.y+t[d-1].y,t[d-1].x+_e):Ie(Ce.x,Ce.y,f+_e)}}}function ke(e,t){for(var n=e.length;--n>=0;){var i=n,r=n-1;r<0&&(r=e.length-1);for(var a=0,o=d+2*y;a<o;a++){var s=N*a,l=N*(a+1);Le(t+i+s,t+r+s,t+r+l,t+i+l)}}}function Ie(e,t,n){c.push(e),c.push(t),c.push(n)}function Pe(e,t,n){Ne(e),Ne(t),Ne(n);var i=s.length/3,r=x.generateTopUV(o,s,i-3,i-2,i-1);Ue(r[0]),Ue(r[1]),Ue(r[2])}function Le(e,t,n,i){Ne(e),Ne(t),Ne(i),Ne(t),Ne(n),Ne(i);var r=s.length/3,a=x.generateSideWallUV(o,s,r-6,r-3,r-2,r-1);Ue(a[0]),Ue(a[1]),Ue(a[3]),Ue(a[1]),Ue(a[2]),Ue(a[3])}function Ne(e){s.push(c[3*e+0]),s.push(c[3*e+1]),s.push(c[3*e+2])}function Ue(e){l.push(e.x),l.push(e.y)}!function(){var e=s.length/3;if(p){for(var t=0,n=N*t,i=0;i<U;i++){var r=R[i];Pe(r[2]+n,r[1]+n,r[0]+n)}n=N*(t=d+2*y);for(var a=0;a<U;a++){var l=R[a];Pe(l[0]+n,l[1]+n,l[2]+n)}}else{for(var u=0;u<U;u++){var c=R[u];Pe(c[2],c[1],c[0])}for(var h=0;h<U;h++){var f=R[h];Pe(f[0]+N*d,f[1]+N*d,f[2]+N*d)}}o.addGroup(e,s.length/3-e,0)}(),function(){var e=s.length/3,t=0;ke(C,t),t+=C.length;for(var n=0,i=T.length;n<i;n++){var r=T[n];ke(r,t),t+=r.length}o.addGroup(e,s.length/3-e,1)}()}return e.setAttribute("position",new ji(s,3)),e.setAttribute("uv",new ji(l,2)),e.computeVertexNormals(),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var a=e[i];n.shapes.push(a.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}}],[{key:"fromJSON",value:function(e,n){for(var i=[],r=0,a=e.shapes.length;r<a;r++){var o=n[e.shapes[r]];i.push(o)}var s=e.options.extrudePath;return void 0!==s&&(e.options.extrudePath=(new Go[s.type]).fromJSON(s)),new t(i,e.options)}}])}($i),Ns={generateTopUV:function(e,t,n,i,r){var a=t[3*n],o=t[3*n+1],s=t[3*i],l=t[3*i+1],u=t[3*r],c=t[3*r+1];return[new bt(a,o),new bt(s,l),new bt(u,c)]},generateSideWallUV:function(e,t,n,i,r,a){var o=t[3*n],s=t[3*n+1],l=t[3*n+2],u=t[3*i],c=t[3*i+1],h=t[3*i+2],d=t[3*r],f=t[3*r+1],p=t[3*r+2],v=t[3*a],m=t[3*a+1],g=t[3*a+2];return Math.abs(s-c)<Math.abs(o-u)?[new bt(o,1-l),new bt(u,1-h),new bt(d,1-p),new bt(v,1-g)]:[new bt(s,1-l),new bt(c,1-h),new bt(f,1-p),new bt(m,1-g)]}};var Us=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,t);var o=(1+Math.sqrt(5))/2;return(e=i(this,t,[[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],n,a])).type="IcosahedronGeometry",e.parameters={radius:n,detail:a},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.detail)}}])}(Jo),Ds=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,t);return(e=i(this,t,[[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],n,a])).type="OctahedronGeometry",e.parameters={radius:n,detail:a},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.detail)}}])}(Jo),Os=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;r(this,t),(e=i(this,t)).type="PlaneGeometry",e.parameters={width:n,height:a,widthSegments:o,heightSegments:s};for(var l=n/2,u=a/2,c=Math.floor(o),h=Math.floor(s),d=c+1,f=h+1,p=n/c,v=a/h,m=[],g=[],y=[],_=[],x=0;x<f;x++)for(var M=x*v-u,S=0;S<d;S++){var b=S*p-l;g.push(b,-M,0),y.push(0,0,1),_.push(S/c),_.push(1-x/h)}for(var T=0;T<h;T++)for(var E=0;E<c;E++){var w=E+d*T,A=E+d*(T+1),R=E+1+d*(T+1),C=E+1+d*T;m.push(w,A,C),m.push(A,R,C)}return e.setIndex(m),e.setAttribute("position",new ji(g,3)),e.setAttribute("normal",new ji(y,3)),e.setAttribute("uv",new ji(_,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.width,e.height,e.widthSegments,e.heightSegments)}}])}($i),Fs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI;r(this,t),(e=i(this,t)).type="RingGeometry",e.parameters={innerRadius:n,outerRadius:a,thetaSegments:o,phiSegments:s,thetaStart:l,thetaLength:u},o=Math.max(3,o);for(var c=[],h=[],d=[],f=[],p=n,v=(a-n)/(s=Math.max(1,s)),m=new tn,g=new bt,y=0;y<=s;y++){for(var _=0;_<=o;_++){var x=l+_/o*u;m.x=p*Math.cos(x),m.y=p*Math.sin(x),h.push(m.x,m.y,m.z),d.push(0,0,1),g.x=(m.x/a+1)/2,g.y=(m.y/a+1)/2,f.push(g.x,g.y)}p+=v}for(var M=0;M<s;M++)for(var S=M*(o+1),b=0;b<o;b++){var T=b+S,E=T,w=T+o+1,A=T+o+2,R=T+1;c.push(E,w,R),c.push(w,A,R)}return e.setIndex(c),e.setAttribute("position",new ji(h,3)),e.setAttribute("normal",new ji(d,3)),e.setAttribute("uv",new ji(f,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}])}($i),Bs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new rs([new bt(0,.5),new bt(-.5,-.5),new bt(.5,-.5)]),a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;r(this,t),(e=i(this,t)).type="ShapeGeometry",e.parameters={shapes:n,curveSegments:a};var o=[],s=[],l=[],u=[],c=0,h=0;if(!1===Array.isArray(n))f(n);else for(var d=0;d<n.length;d++)f(n[d]),e.addGroup(c,h,d),c+=h,h=0;function f(e){var t=s.length/3,n=e.extractPoints(a),i=n.shape,r=n.holes;!1===ks.isClockWise(i)&&(i=i.reverse());for(var c=0,d=r.length;c<d;c++){var f=r[c];!0===ks.isClockWise(f)&&(r[c]=f.reverse())}for(var p=ks.triangulateShape(i,r),v=0,m=r.length;v<m;v++){var g=r[v];i=i.concat(g)}for(var y=0,_=i.length;y<_;y++){var x=i[y];s.push(x.x,x.y,0),l.push(0,0,1),u.push(x.x,x.y)}for(var M=0,S=p.length;M<S;M++){var b=p[M],T=b[0]+t,E=b[1]+t,w=b[2]+t;o.push(T,E,w),h+=3}}return e.setIndex(o),e.setAttribute("position",new ji(s,3)),e.setAttribute("normal",new ji(l,3)),e.setAttribute("uv",new ji(u,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return function(e,t){if(t.shapes=[],Array.isArray(e))for(var n=0,i=e.length;n<i;n++){var r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}}],[{key:"fromJSON",value:function(e,n){for(var i=[],r=0,a=e.shapes.length;r<a;r++){var o=n[e.shapes[r]];i.push(o)}return new t(i,e.curveSegments)}}])}($i);var zs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Math.PI;r(this,t),(e=i(this,t)).type="SphereGeometry",e.parameters={radius:n,widthSegments:a,heightSegments:o,phiStart:s,phiLength:l,thetaStart:u,thetaLength:c},a=Math.max(3,Math.floor(a)),o=Math.max(2,Math.floor(o));for(var h=Math.min(u+c,Math.PI),d=0,f=[],p=new tn,v=new tn,m=[],g=[],y=[],_=[],x=0;x<=o;x++){var M=[],S=x/o,b=0;0===x&&0===u?b=.5/a:x===o&&h===Math.PI&&(b=-.5/a);for(var T=0;T<=a;T++){var E=T/a;p.x=-n*Math.cos(s+E*l)*Math.sin(u+S*c),p.y=n*Math.cos(u+S*c),p.z=n*Math.sin(s+E*l)*Math.sin(u+S*c),g.push(p.x,p.y,p.z),v.copy(p).normalize(),y.push(v.x,v.y,v.z),_.push(E+b,1-S),M.push(d++)}f.push(M)}for(var w=0;w<o;w++)for(var A=0;A<a;A++){var R=f[w][A+1],C=f[w][A],k=f[w+1][A],I=f[w+1][A+1];(0!==w||u>0)&&m.push(R,C,I),(w!==o-1||h<Math.PI)&&m.push(C,k,I)}return e.setIndex(m),e.setAttribute("position",new ji(g,3)),e.setAttribute("normal",new ji(y,3)),e.setAttribute("uv",new ji(_,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}])}($i),Hs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,t);return(e=i(this,t,[[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],n,a])).type="TetrahedronGeometry",e.parameters={radius:n,detail:a},e}return h(t,e),o(t,null,[{key:"fromJSON",value:function(e){return new t(e.radius,e.detail)}}])}(Jo),Vs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:48,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI;r(this,t),(e=i(this,t)).type="TorusGeometry",e.parameters={radius:n,tube:a,radialSegments:o,tubularSegments:s,arc:l},o=Math.floor(o),s=Math.floor(s);for(var u=[],c=[],h=[],d=[],f=new tn,p=new tn,v=new tn,m=0;m<=o;m++)for(var g=0;g<=s;g++){var y=g/s*l,_=m/o*Math.PI*2;p.x=(n+a*Math.cos(_))*Math.cos(y),p.y=(n+a*Math.cos(_))*Math.sin(y),p.z=a*Math.sin(_),c.push(p.x,p.y,p.z),f.x=n*Math.cos(y),f.y=n*Math.sin(y),v.subVectors(p,f).normalize(),h.push(v.x,v.y,v.z),d.push(g/s),d.push(m/o)}for(var x=1;x<=o;x++)for(var M=1;M<=s;M++){var S=(s+1)*x+M-1,b=(s+1)*(x-1)+M-1,T=(s+1)*(x-1)+M,E=(s+1)*x+M;u.push(S,b,E),u.push(b,T,E)}return e.setIndex(u),e.setAttribute("position",new ji(c,3)),e.setAttribute("normal",new ji(h,3)),e.setAttribute("uv",new ji(d,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}])}($i),Gs=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:3;r(this,t),(e=i(this,t)).type="TorusKnotGeometry",e.parameters={radius:n,tube:a,tubularSegments:o,radialSegments:s,p:l,q:u},o=Math.floor(o),s=Math.floor(s);for(var c=[],h=[],d=[],f=[],p=new tn,v=new tn,m=new tn,g=new tn,y=new tn,_=new tn,x=new tn,M=0;M<=o;++M){var S=M/o*l*Math.PI*2;L(S,l,u,n,m),L(S+.01,l,u,n,g),_.subVectors(g,m),x.addVectors(g,m),y.crossVectors(_,x),x.crossVectors(y,_),y.normalize(),x.normalize();for(var b=0;b<=s;++b){var T=b/s*Math.PI*2,E=-a*Math.cos(T),w=a*Math.sin(T);p.x=m.x+(E*x.x+w*y.x),p.y=m.y+(E*x.y+w*y.y),p.z=m.z+(E*x.z+w*y.z),h.push(p.x,p.y,p.z),v.subVectors(p,m).normalize(),d.push(v.x,v.y,v.z),f.push(M/o),f.push(b/s)}}for(var A=1;A<=o;A++)for(var R=1;R<=s;R++){var C=(s+1)*(A-1)+(R-1),k=(s+1)*A+(R-1),I=(s+1)*A+R,P=(s+1)*(A-1)+R;c.push(C,k,P),c.push(k,I,P)}function L(e,t,n,i,r){var a=Math.cos(e),o=Math.sin(e),s=n/t*e,l=Math.cos(s);r.x=i*(2+l)*.5*a,r.y=i*(2+l)*o*.5,r.z=i*Math.sin(s)*.5}return e.setIndex(c),e.setAttribute("position",new ji(h,3)),e.setAttribute("normal",new ji(d,3)),e.setAttribute("uv",new ji(f,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}],[{key:"fromJSON",value:function(e){return new t(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}])}($i),Ws=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ho(new tn(-1,-1,0),new tn(-1,1,0),new tn(1,1,0)),a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4];r(this,t),(e=i(this,t)).type="TubeGeometry",e.parameters={path:n,tubularSegments:a,radius:o,radialSegments:s,closed:l};var u=n.computeFrenetFrames(a,l);e.tangents=u.tangents,e.normals=u.normals,e.binormals=u.binormals;var c=new tn,h=new tn,d=new bt,f=new tn,p=[],v=[],m=[],g=[];function y(e){f=n.getPointAt(e/a,f);for(var t=u.normals[e],i=u.binormals[e],r=0;r<=s;r++){var l=r/s*Math.PI*2,d=Math.sin(l),m=-Math.cos(l);h.x=m*t.x+d*i.x,h.y=m*t.y+d*i.y,h.z=m*t.z+d*i.z,h.normalize(),v.push(h.x,h.y,h.z),c.x=f.x+o*h.x,c.y=f.y+o*h.y,c.z=f.z+o*h.z,p.push(c.x,c.y,c.z)}}return function(){for(var e=0;e<a;e++)y(e);y(!1===l?a:0),function(){for(var e=0;e<=a;e++)for(var t=0;t<=s;t++)d.x=e/a,d.y=t/s,m.push(d.x,d.y)}(),function(){for(var e=1;e<=a;e++)for(var t=1;t<=s;t++){var n=(s+1)*(e-1)+(t-1),i=(s+1)*e+(t-1),r=(s+1)*e+t,o=(s+1)*(e-1)+t;g.push(n,i,o),g.push(i,r,o)}}()}(),e.setIndex(g),e.setAttribute("position",new ji(p,3)),e.setAttribute("normal",new ji(v,3)),e.setAttribute("uv",new ji(m,2)),e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.path=this.parameters.path.toJSON(),e}}],[{key:"fromJSON",value:function(e){return new t((new Go[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}])}($i),js=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(r(this,t),(e=i(this,t)).type="WireframeGeometry",e.parameters={geometry:n},null!==n){var a=[],o=new Set,s=new tn,l=new tn;if(null!==n.index){var u=n.attributes.position,c=n.index,h=n.groups;0===h.length&&(h=[{start:0,count:c.count,materialIndex:0}]);for(var d=0,f=h.length;d<f;++d)for(var p=h[d],v=p.start,m=v,g=v+p.count;m<g;m+=3)for(var y=0;y<3;y++){var _=c.getX(m+y),x=c.getX(m+(y+1)%3);s.fromBufferAttribute(u,_),l.fromBufferAttribute(u,x),!0===Xs(s,l,o)&&(a.push(s.x,s.y,s.z),a.push(l.x,l.y,l.z))}}else for(var M=n.attributes.position,S=0,b=M.count/3;S<b;S++)for(var T=0;T<3;T++){var E=3*S+T,w=3*S+(T+1)%3;s.fromBufferAttribute(M,E),l.fromBufferAttribute(M,w),!0===Xs(s,l,o)&&(a.push(s.x,s.y,s.z),a.push(l.x,l.y,l.z))}e.setAttribute("position",new ji(a,3))}return e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.parameters=Object.assign({},e.parameters),this}}])}($i);function Xs(e,t,n){var i="".concat(e.x,",").concat(e.y,",").concat(e.z,"-").concat(t.x,",").concat(t.y,",").concat(t.z),r="".concat(t.x,",").concat(t.y,",").concat(t.z,"-").concat(e.x,",").concat(e.y,",").concat(e.z);return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var qs=Object.freeze({__proto__:null,BoxGeometry:fr,CapsuleGeometry:qo,CircleGeometry:Yo,ConeGeometry:Ko,CylinderGeometry:Zo,DodecahedronGeometry:Qo,EdgesGeometry:is,ExtrudeGeometry:Ls,IcosahedronGeometry:Us,LatheGeometry:Xo,OctahedronGeometry:Ds,PlaneGeometry:Os,PolyhedronGeometry:Jo,RingGeometry:Fs,ShapeGeometry:Bs,SphereGeometry:zs,TetrahedronGeometry:Hs,TorusGeometry:Vs,TorusKnotGeometry:Gs,TubeGeometry:Ws,WireframeGeometry:js}),Ys=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isShadowMaterial=!0,n.type="ShadowMaterial",n.color=new Ti(0),n.transparent=!0,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.fog=e.fog,this}}])}(Ai),Zs=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).isRawShaderMaterial=!0,n.type="RawShaderMaterial",n}return h(t,e),o(t)}(_r),Ks=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshStandardMaterial=!0,n.type="MeshStandardMaterial",n.defines={STANDARD:""},n.color=new Ti(16777215),n.roughness=1,n.metalness=0,n.map=null,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=null,n.aoMapIntensity=1,n.emissive=new Ti(0),n.emissiveIntensity=1,n.emissiveMap=null,n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.roughnessMap=null,n.metalnessMap=null,n.alphaMap=null,n.envMap=null,n.envMapRotation=new Vn,n.envMapIntensity=1,n.wireframe=!1,n.wireframeLinewidth=1,n.wireframeLinecap="round",n.wireframeLinejoin="round",n.flatShading=!1,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}])}(Ai),Js=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshPhysicalMaterial=!0,n.defines={STANDARD:"",PHYSICAL:""},n.type="MeshPhysicalMaterial",n.anisotropyRotation=0,n.anisotropyMap=null,n.clearcoatMap=null,n.clearcoatRoughness=0,n.clearcoatRoughnessMap=null,n.clearcoatNormalScale=new bt(1,1),n.clearcoatNormalMap=null,n.ior=1.5,Object.defineProperty(n,"reflectivity",{get:function(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),n.iridescenceMap=null,n.iridescenceIOR=1.3,n.iridescenceThicknessRange=[100,400],n.iridescenceThicknessMap=null,n.sheenColor=new Ti(0),n.sheenColorMap=null,n.sheenRoughness=1,n.sheenRoughnessMap=null,n.transmissionMap=null,n.thickness=0,n.thicknessMap=null,n.attenuationDistance=1/0,n.attenuationColor=new Ti(1,1,1),n.specularIntensity=1,n.specularIntensityMap=null,n.specularColor=new Ti(1,1,1),n.specularColorMap=null,n._anisotropy=0,n._clearcoat=0,n._dispersion=0,n._iridescence=0,n._sheen=0,n._transmission=0,n.setValues(e),n}return h(t,e),o(t,[{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:"dispersion",get:function(){return this._dispersion},set:function(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=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(e){return y(t,"copy",this)([e]),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=_(e.iridescenceThicknessRange),this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}])}(Ks),Qs=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshPhongMaterial=!0,n.type="MeshPhongMaterial",n.color=new Ti(16777215),n.specular=new Ti(1118481),n.shininess=30,n.map=null,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=null,n.aoMapIntensity=1,n.emissive=new Ti(0),n.emissiveIntensity=1,n.emissiveMap=null,n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.specularMap=null,n.alphaMap=null,n.envMap=null,n.envMapRotation=new Vn,n.combine=0,n.reflectivity=1,n.refractionRatio=.98,n.wireframe=!1,n.wireframeLinewidth=1,n.wireframeLinecap="round",n.wireframeLinejoin="round",n.flatShading=!1,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}])}(Ai),$s=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshToonMaterial=!0,n.defines={TOON:""},n.type="MeshToonMaterial",n.color=new Ti(16777215),n.map=null,n.gradientMap=null,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=null,n.aoMapIntensity=1,n.emissive=new Ti(0),n.emissiveIntensity=1,n.emissiveMap=null,n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.alphaMap=null,n.wireframe=!1,n.wireframeLinewidth=1,n.wireframeLinecap="round",n.wireframeLinejoin="round",n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}])}(Ai),el=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshNormalMaterial=!0,n.type="MeshNormalMaterial",n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.wireframe=!1,n.wireframeLinewidth=1,n.flatShading=!1,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}])}(Ai),tl=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshLambertMaterial=!0,n.type="MeshLambertMaterial",n.color=new Ti(16777215),n.map=null,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=null,n.aoMapIntensity=1,n.emissive=new Ti(0),n.emissiveIntensity=1,n.emissiveMap=null,n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.specularMap=null,n.alphaMap=null,n.envMap=null,n.envMapRotation=new Vn,n.combine=0,n.reflectivity=1,n.refractionRatio=.98,n.wireframe=!1,n.wireframeLinewidth=1,n.wireframeLinecap="round",n.wireframeLinejoin="round",n.flatShading=!1,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}])}(Ai),nl=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshDepthMaterial=!0,n.type="MeshDepthMaterial",n.depthPacking=3200,n.map=null,n.alphaMap=null,n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.wireframe=!1,n.wireframeLinewidth=1,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}])}(Ai),il=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshDistanceMaterial=!0,n.type="MeshDistanceMaterial",n.map=null,n.alphaMap=null,n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}])}(Ai),rl=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isMeshMatcapMaterial=!0,n.defines={MATCAP:""},n.type="MeshMatcapMaterial",n.color=new Ti(16777215),n.matcap=null,n.map=null,n.bumpMap=null,n.bumpScale=1,n.normalMap=null,n.normalMapType=0,n.normalScale=new bt(1,1),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.alphaMap=null,n.flatShading=!1,n.fog=!0,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}])}(Ai),al=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).isLineDashedMaterial=!0,n.type="LineDashedMaterial",n.scale=1,n.dashSize=3,n.gapSize=1,n.setValues(e),n}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}])}(Ya);function ol(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 sl(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ll(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 ul(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 cl(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 hl={convertArray:ol,isTypedArray:sl,getKeyframeOrder:ll,sortedArray:ul,flattenJSON:cl,subclip:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:30,a=e.clone();a.name=t;for(var o=[],s=0;s<a.tracks.length;++s){for(var l=a.tracks[s],u=l.getValueSize(),c=[],h=[],d=0;d<l.times.length;++d){var f=l.times[d]*r;if(!(f<n||f>=i)){c.push(l.times[d]);for(var p=0;p<u;++p)h.push(l.values[d*u+p])}}0!==c.length&&(l.times=ol(c,l.times.constructor),l.values=ol(h,l.values.constructor),o.push(l))}a.tracks=o;for(var v=1/0,m=0;m<a.tracks.length;++m)v>a.tracks[m].times[0]&&(v=a.tracks[m].times[0]);for(var g=0;g<a.tracks.length;++g)a.tracks[g].shift(-1*v);return a.resetDuration(),a},makeClipAdditive:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30;i<=0&&(i=30);for(var r=n.tracks.length,a=t/i,o=function(){var t=n.tracks[s],i=t.ValueTypeName;if("bool"===i||"string"===i)return 0;var r=e.tracks.find((function(e){return e.name===t.name&&e.ValueTypeName===i}));if(void 0===r)return 0;var o=0,l=t.getValueSize();t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);var u=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=c/3);var h,d=t.times.length-1;if(a<=t.times[0]){var f=o,p=l-o;h=t.values.slice(f,p)}else if(a>=t.times[d]){var v=d*l+o,m=v+l-o;h=t.values.slice(v,m)}else{var g=t.createInterpolant(),y=o,_=l-o;g.evaluate(a),h=g.resultBuffer.slice(y,_)}"quaternion"===i&&(new en).fromArray(h).normalize().conjugate().toArray(h);for(var x=r.times.length,M=0;M<x;++M){var S=M*c+u;if("quaternion"===i)en.multiplyQuaternionsFlat(r.values,S,h,0,r.values,S);else for(var b=c-2*u,T=0;T<b;++T)r.values[S+T]-=h[T]}},s=0;s<r;++s)o();return e.blendMode=et,e}},dl=function(){return o((function e(t,n,i,a){r(this,e),this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==a?a:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}),[{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(){}}])}(),fl=function(e){function t(e,n,a,o){var s;return r(this,t),(s=i(this,t,[e,n,a,o]))._weightPrev=-0,s._offsetPrev=-0,s._weightNext=-0,s._offsetNext=-0,s.DefaultSettings_={endingStart:Ke,endingEnd:Ke},s}return h(t,e),o(t,[{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 Je:r=e,o=2*t-n;break;case Qe: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 Je:a=e,s=2*n-t;break;case Qe: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,v=p*f,m=-h*v+2*h*p-h*f,g=(1+h)*v+(-1.5-2*h)*p+(-.5+h)*f+1,y=(-1-d)*v+(1.5+d)*p+.5*f,_=d*v-d*p,x=0;x!==o;++x)r[x]=m*a[u+x]+g*a[l+x]+y*a[s+x]+_*a[c+x];return r}}])}(dl),pl=function(e){function t(e,n,a,o){return r(this,t),i(this,t,[e,n,a,o])}return h(t,e),o(t,[{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}}])}(dl),vl=function(e){function t(e,n,a,o){return r(this,t),i(this,t,[e,n,a,o])}return h(t,e),o(t,[{key:"interpolate_",value:function(e){return this.copySampleValue_(e-1)}}])}(dl),ml=function(){return o((function e(t,n,i,a){if(r(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=ol(n,this.TimeBufferType),this.values=ol(i,this.ValueBufferType),this.setInterpolation(a||this.DefaultInterpolation)}),[{key:"InterpolantFactoryMethodDiscrete",value:function(e){return new vl(this.times,this.values,this.getValueSize(),e)}},{key:"InterpolantFactoryMethodLinear",value:function(e){return new pl(this.times,this.values,this.getValueSize(),e)}},{key:"InterpolantFactoryMethodSmooth",value:function(e){return new fl(this.times,this.values,this.getValueSize(),e)}},{key:"setInterpolation",value:function(e){var t;switch(e){case qe:t=this.InterpolantFactoryMethodDiscrete;break;case Ye:t=this.InterpolantFactoryMethodLinear;break;case Ze: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 qe;case this.InterpolantFactoryMethodLinear:return Ye;case this.InterpolantFactoryMethodSmooth:return Ze}}},{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&&sl(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()===Ze,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,v=a*n,m=0;m!==n;++m)t[v+m]=t[p+m]}++a}}if(r>0){e[a]=e[r];for(var g=r*n,y=a*n,_=0;_!==n;++_)t[y+_]=t[g+_];++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:ol(e.times,Array),values:ol(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t}}])}();ml.prototype.TimeBufferType=Float32Array,ml.prototype.ValueBufferType=Float32Array,ml.prototype.DefaultInterpolation=Ye;var gl=function(e){function t(e,n,a){return r(this,t),i(this,t,[e,n,a])}return h(t,e),o(t)}(ml);gl.prototype.ValueTypeName="bool",gl.prototype.ValueBufferType=Array,gl.prototype.DefaultInterpolation=qe,gl.prototype.InterpolantFactoryMethodLinear=void 0,gl.prototype.InterpolantFactoryMethodSmooth=void 0;var yl=function(e){function t(){return r(this,t),i(this,t,arguments)}return h(t,e),o(t)}(ml);yl.prototype.ValueTypeName="color";var _l=function(e){function t(){return r(this,t),i(this,t,arguments)}return h(t,e),o(t)}(ml);_l.prototype.ValueTypeName="number";var xl=function(e){function t(e,n,a,o){return r(this,t),i(this,t,[e,n,a,o])}return h(t,e),o(t,[{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)en.slerpFlat(r,0,a,l-o,a,l,s);return r}}])}(dl),Ml=function(e){function t(){return r(this,t),i(this,t,arguments)}return h(t,e),o(t,[{key:"InterpolantFactoryMethodLinear",value:function(e){return new xl(this.times,this.values,this.getValueSize(),e)}}])}(ml);Ml.prototype.ValueTypeName="quaternion",Ml.prototype.InterpolantFactoryMethodSmooth=void 0;var Sl=function(e){function t(e,n,a){return r(this,t),i(this,t,[e,n,a])}return h(t,e),o(t)}(ml);Sl.prototype.ValueTypeName="string",Sl.prototype.ValueBufferType=Array,Sl.prototype.DefaultInterpolation=qe,Sl.prototype.InterpolantFactoryMethodLinear=void 0,Sl.prototype.InterpolantFactoryMethodSmooth=void 0;var bl=function(e){function t(){return r(this,t),i(this,t,arguments)}return h(t,e),o(t)}(ml);bl.prototype.ValueTypeName="vector";var Tl=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$e;r(this,e),this.name=t,this.tracks=i,this.duration=n,this.blendMode=a,this.uuid=mt(),this.duration<0&&this.resetDuration()}),[{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(El(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(ml.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=ll(s);s=ul(s,1,u),l=ul(l,1,u),i||0!==s[0]||(s.push(r),l.push(l[0])),a.push(new _l(".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=[];cl(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 v=[],m=[],g=0;g!==c[d].morphTargets.length;++g){var y=c[d];v.push(y.time),m.push(y.morphTarget===p?1:0)}i.push(new _l(".morphTargetInfluence["+p+"]",v,m))}s=h.length*a}else{var _=".bones["+t[u].name+"]";n(bl,_+".position",c,"pos",i),n(Ml,_+".quaternion",c,"rot",i),n(bl,_+".scale",c,"scl",i)}}return 0===i.length?null:new this(r,s,i,o)}}])}();function El(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 _l;case"vector":case"vector2":case"vector3":case"vector4":return bl;case"color":return yl;case"quaternion":return Ml;case"bool":case"boolean":return gl;case"string":return Sl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){var n=[],i=[];cl(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 wl={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={}}},Al=o((function e(t,n,i){r(this,e);var a=this,o=!1,s=0,l=0,u=void 0,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=n,this.onError=i,this.itemStart=function(e){l++,!1===o&&void 0!==a.onStart&&a.onStart(e,s,l),o=!0},this.itemEnd=function(e){s++,void 0!==a.onProgress&&a.onProgress(e,s,l),s===l&&(o=!1,void 0!==a.onLoad&&a.onLoad())},this.itemError=function(e){void 0!==a.onError&&a.onError(e)},this.resolveURL=function(e){return u?u(e):e},this.setURLModifier=function(e){return u=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){var t=c.indexOf(e);return-1!==t&&c.splice(t,2),this},this.getHandler=function(e){for(var t=0,n=c.length;t<n;t+=2){var i=c[t],r=c[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return r}return null}})),Rl=new Al,Cl=function(){return o((function e(t){r(this,e),this.manager=void 0!==t?t:Rl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}),[{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}}])}();Cl.DEFAULT_MATERIAL_NAME="__DEFAULT";var kl,Il={},Pl=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e])).response=n,a}return h(t,e),o(t)}(b(Error)),Ll=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{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=wl.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===Il[e]){Il[e]=[],Il[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=Il[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),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()}}),(function(t){e.error(t)}))}()}});return new Response(l)}throw new Pl('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){wl.add(e,t);var n=Il[e];delete Il[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=Il[e];if(void 0===n)throw r.manager.itemError(e),t;delete Il[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 Il[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}}])}(Cl),Nl=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=new Ll(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}},{key:"parse",value:function(e){for(var t=[],n=0;n<e.length;n++){var i=Tl.parse(e[n]);t.push(i)}return t}}])}(Cl),Ul=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=[],o=new _o,s=new Ll(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials);var l=0;function u(u){s.load(e[u],(function(e){var n=r.parse(e,!0);a[u]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(l+=1)&&(1===n.mipmapCount&&(o.minFilter=V),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))}),n,i)}if(Array.isArray(e))for(var c=0,h=e.length;c<h;++c)u(c);else s.load(e,(function(e){var n=r.parse(e,!0);if(n.isCubemap){for(var i=n.mipmaps.length/n.mipmapCount,s=0;s<i;s++){a[s]={mipmaps:[]};for(var l=0;l<n.mipmapCount;l++)a[s].mipmaps.push(n.mipmaps[s*n.mipmapCount+l]),a[s].format=n.format,a[s].width=n.width,a[s].height=n.height}o.image=a}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;1===n.mipmapCount&&(o.minFilter=V),o.format=n.format,o.needsUpdate=!0,t&&t(o)}),n,i);return o}}])}(Cl),Dl=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{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=wl.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;var o=Ct("img");function s(){u(),wl.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}}])}(Cl),Ol=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=new Ar;r.colorSpace=nt;var a=new Dl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);var o=0;function s(n){a.load(e[n],(function(e){r.images[n]=e,6===++o&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(var l=0;l<e.length;++l)s(l);return r}}])}(Cl),Fl=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=new ca,o=new Ll(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,(function(e){var n;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:O,a.wrapT=void 0!==n.wrapT?n.wrapT:O,a.magFilter=void 0!==n.magFilter?n.magFilter:V,a.minFilter=void 0!==n.minFilter?n.minFilter:V,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(a.colorSpace=n.colorSpace),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=W),1===n.mipmapCount&&(a.minFilter=V),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}}])}(Cl),Bl=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=new Xt,a=new Dl(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}}])}(Cl),zl=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return r(this,t),(n=i(this,t)).isLight=!0,n.type="Light",n.color=new Ti(e),n.intensity=a,n}return h(t,e),o(t,[{key:"dispose",value:function(){}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.color.copy(e.color),this.intensity=e.intensity,this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);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()),void 0!==this.target&&(n.object.target=this.target.uuid),n}}])}(ai),Hl=function(e){function t(e,n,a){var o;return r(this,t),(o=i(this,t,[e,a])).isHemisphereLight=!0,o.type="HemisphereLight",o.position.copy(ai.DEFAULT_UP),o.updateMatrix(),o.groundColor=new Ti(n),o}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.groundColor.copy(e.groundColor),this}}])}(zl),Vl=new Pn,Gl=new tn,Wl=new tn,jl=function(){return o((function e(t){r(this,e),this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new bt(512,512),this.map=null,this.mapPass=null,this.matrix=new Pn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ca,this._frameExtents=new bt(1,1),this._viewportCount=1,this._viewports=[new qt(0,0,1,1)]}),[{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;Gl.setFromMatrixPosition(e.matrixWorld),t.position.copy(Gl),Wl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Wl),t.updateMatrixWorld(),Vl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Vl)}},{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.intensity=e.intensity,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 1!==this.intensity&&(e.intensity=this.intensity),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}}])}(),Xl=function(e){function t(){var e;return r(this,t),(e=i(this,t,[new Tr(50,1,.5,500)])).isSpotLightShadow=!0,e.focus=1,e}return h(t,e),o(t,[{key:"updateMatrices",value:function(e){var n=this.camera,i=2*vt*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||n.far;i===n.fov&&r===n.aspect&&a===n.far||(n.fov=i,n.aspect=r,n.far=a,n.updateProjectionMatrix()),y(t,"updateMatrices",this)([e])}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.focus=e.focus,this}}])}(jl),ql=function(e){function t(e,n){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Math.PI/3,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2;return r(this,t),(a=i(this,t,[e,n])).isSpotLight=!0,a.type="SpotLight",a.position.copy(ai.DEFAULT_UP),a.updateMatrix(),a.target=new ai,a.distance=o,a.angle=s,a.penumbra=l,a.decay=u,a.map=null,a.shadow=new Xl,a}return h(t,e),o(t,[{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(e,n){return y(t,"copy",this)([e,n]),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}])}(zl),Yl=new Pn,Zl=new tn,Kl=new tn,Jl=function(e){function t(){var e;return r(this,t),(e=i(this,t,[new Tr(90,1,.5,500)])).isPointLightShadow=!0,e._frameExtents=new bt(4,2),e._viewportCount=6,e._viewports=[new qt(2,1,1,1),new qt(0,1,1,1),new qt(3,1,1,1),new qt(1,1,1,1),new qt(3,0,1,1),new qt(1,0,1,1)],e._cubeDirections=[new tn(1,0,0),new tn(-1,0,0),new tn(0,0,1),new tn(0,0,-1),new tn(0,1,0),new tn(0,-1,0)],e._cubeUps=[new tn(0,1,0),new tn(0,1,0),new tn(0,1,0),new tn(0,1,0),new tn(0,0,1),new tn(0,0,-1)],e}return h(t,e),o(t,[{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()),Zl.setFromMatrixPosition(e.matrixWorld),n.position.copy(Zl),Kl.copy(n.position),Kl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Kl),n.updateMatrixWorld(),i.makeTranslation(-Zl.x,-Zl.y,-Zl.z),Yl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yl)}}])}(jl),Ql=function(e){function t(e,n){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;return r(this,t),(a=i(this,t,[e,n])).isPointLight=!0,a.type="PointLight",a.distance=o,a.decay=s,a.shadow=new Jl,a}return h(t,e),o(t,[{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(e,n){return y(t,"copy",this)([e,n]),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}])}(zl),$l=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.1,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2e3;return r(this,t),(e=i(this,t)).isOrthographicCamera=!0,e.type="OrthographicCamera",e.zoom=1,e.view=null,e.left=n,e.right=a,e.top=o,e.bottom=s,e.near=l,e.far=u,e.updateProjectionMatrix(),e}return h(t,e),o(t,[{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.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(e){var n=y(t,"toJSON",this)([e]);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}}])}(xr),eu=function(e){function t(){var e;return r(this,t),(e=i(this,t,[new $l(-5,5,5,-5,.5,500)])).isDirectionalLightShadow=!0,e}return h(t,e),o(t)}(jl),tu=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e,n])).isDirectionalLight=!0,a.type="DirectionalLight",a.position.copy(ai.DEFAULT_UP),a.updateMatrix(),a.target=new ai,a.shadow=new eu,a}return h(t,e),o(t,[{key:"dispose",value:function(){this.shadow.dispose()}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}])}(zl),nu=function(e){function t(e,n){var a;return r(this,t),(a=i(this,t,[e,n])).isAmbientLight=!0,a.type="AmbientLight",a}return h(t,e),o(t)}(zl),iu=function(e){function t(e,n){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;return r(this,t),(a=i(this,t,[e,n])).isRectAreaLight=!0,a.type="RectAreaLight",a.width=o,a.height=s,a}return h(t,e),o(t,[{key:"power",get:function(){return this.intensity*this.width*this.height*Math.PI},set:function(e){this.intensity=e/(this.width*this.height*Math.PI)}},{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.width=e.width,this.height=e.height,this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);return n.object.width=this.width,n.object.height=this.height,n}}])}(zl),ru=function(){return o((function e(){r(this,e),this.isSphericalHarmonics3=!0,this.coefficients=[];for(var t=0;t<9;t++)this.coefficients.push(new tn)}),[{key:"set",value:function(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}},{key:"zero",value:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}},{key:"getAt",value:function(e,t){var n=e.x,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*i*1.092548),t.addScaledVector(a[5],i*r*1.092548),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],n*r*1.092548),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}},{key:"getIrradianceAt",value:function(e,t){var n=e.x,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*i),t.addScaledVector(a[2],1.023328*r),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*i),t.addScaledVector(a[5],.858086*i*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],.858086*n*r),t.addScaledVector(a[8],.429043*(n*n-i*i)),t}},{key:"add",value:function(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}},{key:"addScaledSH",value:function(e,t){for(var n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}},{key:"scale",value:function(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}},{key:"lerp",value:function(e,t){for(var n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}},{key:"equals",value:function(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}},{key:"copy",value:function(e){return this.set(e.coefficients)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.coefficients,i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}},{key:"toArray",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.coefficients,i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}}],[{key:"getBasisAt",value:function(e,t){var n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}])}(),au=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ru,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return r(this,t),(e=i(this,t,[void 0,a])).isLightProbe=!0,e.sh=n,e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.sh.copy(e.sh),this}},{key:"fromJSON",value:function(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);return n.object.sh=this.sh.toArray(),n}}])}(zl),ou=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).textures={},n}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=new Ll(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}},{key:"parse",value:function(e){var t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}var i=this.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new Ti).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(i.dispersion=e.dispersion),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(i.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(i.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(i.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(i.depthFunc=e.depthFunc),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(i.blendSrc=e.blendSrc),void 0!==e.blendDst&&(i.blendDst=e.blendDst),void 0!==e.blendEquation&&(i.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(i.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(i.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(i.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(i.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),void 0!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(i.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(var r in e.uniforms){var a=e.uniforms[r];switch(i.uniforms[r]={},a.type){case"t":i.uniforms[r].value=n(a.value);break;case"c":i.uniforms[r].value=(new Ti).setHex(a.value);break;case"v2":i.uniforms[r].value=(new bt).fromArray(a.value);break;case"v3":i.uniforms[r].value=(new tn).fromArray(a.value);break;case"v4":i.uniforms[r].value=(new qt).fromArray(a.value);break;case"m3":i.uniforms[r].value=(new Tt).fromArray(a.value);break;case"m4":i.uniforms[r].value=(new Pn).fromArray(a.value);break;default:i.uniforms[r].value=a.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(var o in e.extensions)i.extensions[o]=e.extensions[o];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){var s=e.normalScale;!1===Array.isArray(s)&&(s=[s,s]),i.normalScale=(new bt).fromArray(s)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new bt).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}},{key:"setTextures",value:function(e){return this.textures=e,this}},{key:"createMaterialFromType",value:function(e){return t.createMaterialFromType(e)}}],[{key:"createMaterialFromType",value:function(e){return new{ShadowMaterial:Ys,SpriteMaterial:Ur,RawShaderMaterial:Zs,ShaderMaterial:_r,PointsMaterial:lo,MeshPhysicalMaterial:Js,MeshStandardMaterial:Ks,MeshPhongMaterial:Qs,MeshToonMaterial:$s,MeshNormalMaterial:el,MeshLambertMaterial:tl,MeshDepthMaterial:nl,MeshDistanceMaterial:il,MeshBasicMaterial:Ri,MeshMatcapMaterial:rl,LineDashedMaterial:al,LineBasicMaterial:Ya,Material:Ai}[e]}}])}(Cl),su=function(){return o((function e(){r(this,e)}),null,[{key:"decodeText",value:function(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"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(e){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)}}])}(),lu=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isInstancedBufferGeometry=!0,e.type="InstancedBufferGeometry",e.instanceCount=1/0,e}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.instanceCount=e.instanceCount,this}},{key:"toJSON",value:function(){var e=y(t,"toJSON",this)([]);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}])}($i),uu=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=new Ll(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}},{key:"parse",value:function(e){var t={},n={};function i(e,i){if(void 0!==t[i])return t[i];var r=e.interleavedBuffers[i],a=function(e,t){if(void 0!==n[t])return n[t];var i=e.arrayBuffers,r=i[t],a=new Uint32Array(r).buffer;return n[t]=a,a}(e,r.buffer),o=Rt(r.type,a),s=new Pr(o,r.stride);return s.uuid=r.uuid,t[i]=s,s}var r=e.isInstancedBufferGeometry?new lu:new $i,a=e.data.index;if(void 0!==a){var o=Rt(a.type,a.array);r.setIndex(new Di(o,1))}var s=e.data.attributes;for(var l in s){var u=s[l],c=void 0;if(u.isInterleavedBufferAttribute){var h=i(e.data,u.data);c=new Nr(h,u.itemSize,u.offset,u.normalized)}else{var d=Rt(u.type,u.array);c=new(u.isInstancedBufferAttribute?pa:Di)(d,u.itemSize,u.normalized)}void 0!==u.name&&(c.name=u.name),void 0!==u.usage&&c.setUsage(u.usage),r.setAttribute(l,c)}var f=e.data.morphAttributes;if(f)for(var p in f){for(var v=f[p],m=[],g=0,y=v.length;g<y;g++){var _=v[g],x=void 0;if(_.isInterleavedBufferAttribute){var M=i(e.data,_.data);x=new Nr(M,_.itemSize,_.offset,_.normalized)}else{var S=Rt(_.type,_.array);x=new Di(S,_.itemSize,_.normalized)}void 0!==_.name&&(x.name=_.name),m.push(x)}r.morphAttributes[p]=m}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);var b=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==b)for(var T=0,E=b.length;T!==E;++T){var w=b[T];r.addGroup(w.start,w.count,w.materialIndex)}var A=e.data.boundingSphere;if(void 0!==A){var R=new tn;void 0!==A.center&&R.fromArray(A.center),r.boundingSphere=new bn(R,A.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}])}(Cl),cu=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=""===this.path?su.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;var o=new Ll(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){var a=null;try{a=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var o=a.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+e)),void console.error("THREE.ObjectLoader: Can't load "+e);r.parse(a,t)}),n,i)}},{key:"loadAsync",value:(l=n(v().mark((function e(t,n){var i,r,a,o,s,l;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this,r=""===this.path?su.extractUrlBase(t):this.path,this.resourcePath=this.resourcePath||r,(a=new Ll(this.manager)).setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),e.next=9,a.loadAsync(t,n);case 9:if(o=e.sent,s=JSON.parse(o),void 0!==(l=s.metadata)&&void 0!==l.type&&"geometry"!==l.type.toLowerCase()){e.next=14;break}throw new Error("THREE.ObjectLoader: Can't load "+t);case 14:return e.next=16,i.parseAsync(s);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"parse",value:function(e,t){var n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),o=this.parseTextures(e.textures,a),s=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,r,s,o,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),void 0!==t){var c=!1;for(var h in a)if(a[h].data instanceof HTMLImageElement){c=!0;break}!1===c&&t(l)}return l}},{key:"parseAsync",value:(s=n(v().mark((function e(t){var n,i,r,a,o,s,l,u;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),e.next=5,this.parseImagesAsync(t.images);case 5:return a=e.sent,o=this.parseTextures(t.textures,a),s=this.parseMaterials(t.materials,o),l=this.parseObject(t.object,r,s,o,n),u=this.parseSkeletons(t.skeletons,l),this.bindSkeletons(l,u),this.bindLightTargets(l),e.abrupt("return",l);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"parseShapes",value:function(e){var t={};if(void 0!==e)for(var n=0,i=e.length;n<i;n++){var r=(new rs).fromJSON(e[n]);t[r.uuid]=r}return t}},{key:"parseSkeletons",value:function(e,t){var n={},i={};if(t.traverse((function(e){e.isBone&&(i[e.uuid]=e)})),void 0!==e)for(var r=0,a=e.length;r<a;r++){var o=(new fa).fromJSON(e[r],i);n[o.uuid]=o}return n}},{key:"parseGeometries",value:function(e,t){var n={};if(void 0!==e)for(var i=new uu,r=0,a=e.length;r<a;r++){var o=void 0,s=e[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(s);break;default:s.type in qs?o=qs[s.type].fromJSON(s,t):console.warn('THREE.ObjectLoader: Unsupported geometry type "'.concat(s.type,'"'))}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),void 0!==s.userData&&(o.userData=s.userData),n[s.uuid]=o}return n}},{key:"parseMaterials",value:function(e,t){var n={},i={};if(void 0!==e){var r=new ou;r.setTextures(t);for(var a=0,o=e.length;a<o;a++){var s=e[a];void 0===n[s.uuid]&&(n[s.uuid]=r.parse(s)),i[s.uuid]=n[s.uuid]}}return i}},{key:"parseAnimations",value:function(e){var t={};if(void 0!==e)for(var n=0;n<e.length;n++){var i=e[n],r=Tl.parse(i);t[r.uuid]=r}return t}},{key:"parseImages",value:function(e,t){var n,i=this,r={};function a(e){if("string"==typeof e){var t=e;return function(e){return i.manager.itemStart(e),n.load(e,(function(){i.manager.itemEnd(e)}),void 0,(function(){i.manager.itemError(e),i.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:i.resourcePath+t)}return e.data?{data:Rt(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){var o=new Al(t);(n=new Dl(o)).setCrossOrigin(this.crossOrigin);for(var s=0,l=e.length;s<l;s++){var u=e[s],c=u.url;if(Array.isArray(c)){for(var h=[],d=0,f=c.length;d<f;d++){var p=a(c[d]);null!==p&&(p instanceof HTMLImageElement?h.push(p):h.push(new ca(p.data,p.width,p.height)))}r[u.uuid]=new Gt(h)}else{var v=a(u.url);r[u.uuid]=new Gt(v)}}}return r}},{key:"parseImagesAsync",value:(a=n(v().mark((function e(t){var i,r,a,o,s,l,u,c,h,d,f,p,m,g,y;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=function(){return s=n(v().mark((function e(t){var n,r;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=8;break}return r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n=t)?n:i.resourcePath+n,e.next=5,a.loadAsync(r);case 5:return e.abrupt("return",e.sent);case 8:if(!t.data){e.next=12;break}return e.abrupt("return",{data:Rt(t.type,t.data),width:t.width,height:t.height});case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)}))),s.apply(this,arguments)},o=function(e){return s.apply(this,arguments)},i=this,r={},!(void 0!==t&&t.length>0)){e.next=33;break}(a=new Dl(this.manager)).setCrossOrigin(this.crossOrigin),l=0,u=t.length;case 8:if(!(l<u)){e.next=33;break}if(c=t[l],h=c.url,!Array.isArray(h)){e.next=26;break}d=[],f=0,p=h.length;case 14:if(!(f<p)){e.next=23;break}return m=h[f],e.next=18,o(m);case 18:null!==(g=e.sent)&&(g instanceof HTMLImageElement?d.push(g):d.push(new ca(g.data,g.width,g.height)));case 20:f++,e.next=14;break;case 23:r[c.uuid]=new Gt(d),e.next=30;break;case 26:return e.next=28,o(c.url);case 28:y=e.sent,r[c.uuid]=new Gt(y);case 30:l++,e.next=8;break;case 33:return e.abrupt("return",r);case 34:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"parseTextures",value:function(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var i={};if(void 0!==e)for(var r=0,a=e.length;r<a;r++){var o=e[r];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);var s=t[o.image],l=s.data,u=void 0;Array.isArray(l)?(u=new Ar,6===l.length&&(u.needsUpdate=!0)):(u=l&&l.data?new ca:new Xt,l&&(u.needsUpdate=!0)),u.source=s,u.uuid=o.uuid,void 0!==o.name&&(u.name=o.name),void 0!==o.mapping&&(u.mapping=n(o.mapping,hu)),void 0!==o.channel&&(u.channel=o.channel),void 0!==o.offset&&u.offset.fromArray(o.offset),void 0!==o.repeat&&u.repeat.fromArray(o.repeat),void 0!==o.center&&u.center.fromArray(o.center),void 0!==o.rotation&&(u.rotation=o.rotation),void 0!==o.wrap&&(u.wrapS=n(o.wrap[0],du),u.wrapT=n(o.wrap[1],du)),void 0!==o.format&&(u.format=o.format),void 0!==o.internalFormat&&(u.internalFormat=o.internalFormat),void 0!==o.type&&(u.type=o.type),void 0!==o.colorSpace&&(u.colorSpace=o.colorSpace),void 0!==o.minFilter&&(u.minFilter=n(o.minFilter,fu)),void 0!==o.magFilter&&(u.magFilter=n(o.magFilter,fu)),void 0!==o.anisotropy&&(u.anisotropy=o.anisotropy),void 0!==o.flipY&&(u.flipY=o.flipY),void 0!==o.generateMipmaps&&(u.generateMipmaps=o.generateMipmaps),void 0!==o.premultiplyAlpha&&(u.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(u.unpackAlignment=o.unpackAlignment),void 0!==o.compareFunction&&(u.compareFunction=o.compareFunction),void 0!==o.userData&&(u.userData=o.userData),i[o.uuid]=u}return i}},{key:"parseObject",value:function(e,t,n,i,r){var a,o,s;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function u(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],i=0,r=e.length;i<r;i++){var a=e[i];void 0===n[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),t.push(n[a])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function c(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":a=new Ir,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new Ti(e.background):a.background=c(e.background)),void 0!==e.environment&&(a.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new kr(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new Cr(e.fog.color,e.fog.density)),""!==e.fog.name&&(a.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(a.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(a.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&a.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(a.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Tr(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new $l(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new nu(e.color,e.intensity);break;case"DirectionalLight":(a=new tu(e.color,e.intensity)).target=e.target||"";break;case"PointLight":a=new Ql(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new iu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":(a=new ql(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay)).target=e.target||"";break;case"HemisphereLight":a=new Hl(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new au).fromJSON(e);break;case"SkinnedMesh":o=l(e.geometry),s=u(e.material),a=new la(o,s),void 0!==e.bindMode&&(a.bindMode=e.bindMode),void 0!==e.bindMatrix&&a.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(a.skeleton=e.skeleton);break;case"Mesh":o=l(e.geometry),s=u(e.material),a=new hr(o,s);break;case"InstancedMesh":o=l(e.geometry),s=u(e.material);var h=e.count,d=e.instanceMatrix,f=e.instanceColor;(a=new Sa(o,s,h)).instanceMatrix=new pa(new Float32Array(d.array),16),void 0!==f&&(a.instanceColor=new pa(new Float32Array(f.array),f.itemSize));break;case"BatchedMesh":o=l(e.geometry),s=u(e.material),(a=new qa(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,s)).geometry=o,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map((function(e){var t=new an;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);var n=new bn;return n.radius=e.sphereRadius,n.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:n}})),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),void 0!==e.colorsTexture&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new Qr;break;case"Line":a=new no(l(e.geometry),u(e.material));break;case"LineLoop":a=new so(l(e.geometry),u(e.material));break;case"LineSegments":a=new oo(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new po(l(e.geometry),u(e.material));break;case"Sprite":a=new Yr(u(e.material));break;case"Group":a=new mo;break;case"Bone":a=new ua;break;default:a=new ai}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(a.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children)for(var p=e.children,v=0;v<p.length;v++)a.add(this.parseObject(p[v],t,n,i,r));if(void 0!==e.animations)for(var m=e.animations,g=0;g<m.length;g++){var y=m[g];a.animations.push(r[y])}if("LOD"===e.type){void 0!==e.autoUpdate&&(a.autoUpdate=e.autoUpdate);for(var _=e.levels,x=0;x<_.length;x++){var M=_[x],S=a.getObjectByProperty("uuid",M.object);void 0!==S&&a.addLevel(S,M.distance,M.hysteresis)}}return a}},{key:"bindSkeletons",value:function(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){var n=t[e.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}},{key:"bindLightTargets",value:function(e){e.traverse((function(t){if(t.isDirectionalLight||t.isSpotLight){var n=t.target,i=e.getObjectByProperty("uuid",n);t.target=void 0!==i?i:new ai}}))}}]);var a,s,l}(Cl),hu={UVMapping:k,CubeReflectionMapping:I,CubeRefractionMapping:P,EquirectangularReflectionMapping:L,EquirectangularRefractionMapping:N,CubeUVReflectionMapping:U},du={RepeatWrapping:D,ClampToEdgeWrapping:O,MirroredRepeatWrapping:F},fu={NearestFilter:B,NearestMipmapNearestFilter:z,NearestMipmapLinearFilter:H,LinearFilter:V,LinearMipmapNearestFilter:G,LinearMipmapLinearFilter:W},pu=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),n.options={premultiplyAlpha:"none"},n}return h(t,e),o(t,[{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=wl.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 wl.add(e,n),t&&t(n),r.manager.itemEnd(e),n})).catch((function(t){i&&i(t),wl.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));wl.add(e,s),r.manager.itemStart(e)}}])}(Cl),vu=function(){return o((function e(){r(this,e)}),null,[{key:"getContext",value:function(){return void 0===kl&&(kl=new(window.AudioContext||window.webkitAudioContext)),kl}},{key:"setContext",value:function(e){kl=e}}])}(),mu=function(e){function t(e){return r(this,t),i(this,t,[e])}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r=this,a=new Ll(this.manager);function o(t){i?i(t):console.error(t),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){try{var n=e.slice(0);vu.getContext().decodeAudioData(n,(function(e){t(e)})).catch(o)}catch(e){o(e)}}),n,i)}}])}(Cl),gu=new Pn,yu=new Pn,_u=new Pn,xu=function(){return o((function e(){r(this,e),this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Tr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Tr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}),[{key:"update",value:function(e){var t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,_u.copy(e.projectionMatrix);var n,i,r=t.eyeSep/2,a=r*t.near/t.focus,o=t.near*Math.tan(pt*t.fov*.5)/t.zoom;yu.elements[12]=-r,gu.elements[12]=r,n=-o*t.aspect+a,i=o*t.aspect+a,_u.elements[0]=2*t.near/(i-n),_u.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy(_u),n=-o*t.aspect-a,i=o*t.aspect-a,_u.elements[0]=2*t.near/(i-n),_u.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy(_u)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(yu),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(gu)}}])}(),Mu=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return r(this,t),(e=i(this,t)).isArrayCamera=!0,e.cameras=n,e}return h(t,e),o(t)}(Tr),Su=function(){return o((function e(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];r(this,e),this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}),[{key:"start",value:function(){this.startTime=bu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}},{key:"stop",value:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}},{key:"getElapsedTime",value:function(){return this.getDelta(),this.elapsedTime}},{key:"getDelta",value:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=bu();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}])}();function bu(){return performance.now()}var Tu=new tn,Eu=new en,wu=new tn,Au=new tn,Ru=function(e){function t(){var e;return r(this,t),(e=i(this,t)).type="AudioListener",e.context=vu.getContext(),e.gain=e.context.createGain(),e.gain.connect(e.context.destination),e.filter=null,e.timeDelta=0,e._clock=new Su,e}return h(t,e),o(t,[{key:"getInput",value:function(){return this.gain}},{key:"removeFilter",value:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}},{key:"getFilter",value:function(){return this.filter}},{key:"setFilter",value:function(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}},{key:"getMasterVolume",value:function(){return this.gain.gain.value}},{key:"setMasterVolume",value:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},{key:"updateMatrixWorld",value:function(e){y(t,"updateMatrixWorld",this)([e]);var n=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Tu,Eu,wu),Au.set(0,0,-1).applyQuaternion(Eu),n.positionX){var r=this.context.currentTime+this.timeDelta;n.positionX.linearRampToValueAtTime(Tu.x,r),n.positionY.linearRampToValueAtTime(Tu.y,r),n.positionZ.linearRampToValueAtTime(Tu.z,r),n.forwardX.linearRampToValueAtTime(Au.x,r),n.forwardY.linearRampToValueAtTime(Au.y,r),n.forwardZ.linearRampToValueAtTime(Au.z,r),n.upX.linearRampToValueAtTime(i.x,r),n.upY.linearRampToValueAtTime(i.y,r),n.upZ.linearRampToValueAtTime(i.z,r)}else n.setPosition(Tu.x,Tu.y,Tu.z),n.setOrientation(Au.x,Au.y,Au.z,i.x,i.y,i.z)}}])}(ai),Cu=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).type="Audio",n.listener=e,n.context=e.context,n.gain=n.context.createGain(),n.gain.connect(e.getInput()),n.autoplay=!1,n.buffer=null,n.detune=0,n.loop=!1,n.loopStart=0,n.loopEnd=0,n.offset=0,n.duration=void 0,n.playbackRate=1,n.isPlaying=!1,n.hasPlaybackControl=!0,n.source=null,n.sourceType="empty",n._startedAt=0,n._progress=0,n._connected=!1,n.filters=[],n}return h(t,e),o(t,[{key:"getOutput",value:function(){return this.gain}},{key:"setNodeSource",value:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}},{key:"setMediaElementSource",value:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}},{key:"setMediaStreamSource",value:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}},{key:"setBuffer",value:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+e;var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")}},{key:"pause",value:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"connect",value:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}},{key:"disconnect",value:function(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}},{key:"getFilters",value:function(){return this.filters}},{key:"setFilters",value:function(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}},{key:"setDetune",value:function(e){return this.detune=e,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}},{key:"getDetune",value:function(){return this.detune}},{key:"getFilter",value:function(){return this.getFilters()[0]}},{key:"setFilter",value:function(e){return this.setFilters(e?[e]:[])}},{key:"setPlaybackRate",value:function(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"getPlaybackRate",value:function(){return this.playbackRate}},{key:"onEnded",value:function(){this.isPlaying=!1,this._progress=0}},{key:"getLoop",value:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}},{key:"setLoop",value:function(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"setLoopStart",value:function(e){return this.loopStart=e,this}},{key:"setLoopEnd",value:function(e){return this.loopEnd=e,this}},{key:"getVolume",value:function(){return this.gain.gain.value}},{key:"setVolume",value:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),"buffer"!==e.sourceType?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}},{key:"clone",value:function(e){return new this.constructor(this.listener).copy(this,e)}}])}(ai),ku=new tn,Iu=new en,Pu=new tn,Lu=new tn,Nu=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).panner=n.context.createPanner(),n.panner.panningModel="HRTF",n.panner.connect(n.gain),n}return h(t,e),o(t,[{key:"connect",value:function(){y(t,"connect",this)([]),this.panner.connect(this.gain)}},{key:"disconnect",value:function(){y(t,"disconnect",this)([]),this.panner.disconnect(this.gain)}},{key:"getOutput",value:function(){return this.panner}},{key:"getRefDistance",value:function(){return this.panner.refDistance}},{key:"setRefDistance",value:function(e){return this.panner.refDistance=e,this}},{key:"getRolloffFactor",value:function(){return this.panner.rolloffFactor}},{key:"setRolloffFactor",value:function(e){return this.panner.rolloffFactor=e,this}},{key:"getDistanceModel",value:function(){return this.panner.distanceModel}},{key:"setDistanceModel",value:function(e){return this.panner.distanceModel=e,this}},{key:"getMaxDistance",value:function(){return this.panner.maxDistance}},{key:"setMaxDistance",value:function(e){return this.panner.maxDistance=e,this}},{key:"setDirectionalCone",value:function(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}},{key:"updateMatrixWorld",value:function(e){if(y(t,"updateMatrixWorld",this)([e]),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(ku,Iu,Pu),Lu.set(0,0,1).applyQuaternion(Iu);var n=this.panner;if(n.positionX){var i=this.context.currentTime+this.listener.timeDelta;n.positionX.linearRampToValueAtTime(ku.x,i),n.positionY.linearRampToValueAtTime(ku.y,i),n.positionZ.linearRampToValueAtTime(ku.z,i),n.orientationX.linearRampToValueAtTime(Lu.x,i),n.orientationY.linearRampToValueAtTime(Lu.y,i),n.orientationZ.linearRampToValueAtTime(Lu.z,i)}else n.setPosition(ku.x,ku.y,ku.z),n.setOrientation(Lu.x,Lu.y,Lu.z)}}}])}(Cu),Uu=function(){return o((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2048;r(this,e),this.analyser=t.context.createAnalyser(),this.analyser.fftSize=n,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}),[{key:"getFrequencyData",value:function(){return this.analyser.getByteFrequencyData(this.data),this.data}},{key:"getAverageFrequency",value:function(){for(var e=0,t=this.getFrequencyData(),n=0;n<t.length;n++)e+=t[n];return e/t.length}}])}(),Du=function(){return o((function e(t,n,i){var a,o,s;switch(r(this,e),this.binding=t,this.valueSize=i,n){case"quaternion":a=this._slerp,o=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":a=this._select,o=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:a=this._lerp,o=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=a,this._mixBufferRegionAdditive=o,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}),[{key:"accumulate",value:function(e,t){var n=this.buffer,i=this.valueSize,r=e*i+i,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==i;++o)n[r+o]=n[o];a=t}else{var s=t/(a+=t);this._mixBufferRegion(n,r,0,s,i)}this.cumulativeWeight=a}},{key:"accumulateAdditive",value:function(e){var t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}},{key:"apply",value:function(e){var t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){var s=t*this._origIndex;this._mixBufferRegion(n,i,s,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(var l=t,u=t+t;l!==u;++l)if(n[l]!==n[l+t]){o.setValue(n,i);break}}},{key:"saveOriginalState",value:function(){var e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(var r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}},{key:"restoreOriginalState",value:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}},{key:"_setAdditiveIdentityNumeric",value:function(){for(var e=this._addIndex*this.valueSize,t=e+this.valueSize,n=e;n<t;n++)this.buffer[n]=0}},{key:"_setAdditiveIdentityQuaternion",value:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}},{key:"_setAdditiveIdentityOther",value:function(){for(var e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize,n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}},{key:"_select",value:function(e,t,n,i,r){if(i>=.5)for(var a=0;a!==r;++a)e[t+a]=e[n+a]}},{key:"_slerp",value:function(e,t,n,i){en.slerpFlat(e,t,e,t,e,n,i)}},{key:"_slerpAdditive",value:function(e,t,n,i,r){var a=this._workIndex*r;en.multiplyQuaternionsFlat(e,a,e,t,e,n),en.slerpFlat(e,t,e,t,e,a,i)}},{key:"_lerp",value:function(e,t,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*i}}},{key:"_lerpAdditive",value:function(e,t,n,i,r){for(var a=0;a!==r;++a){var o=t+a;e[o]=e[o]+e[n+a]*i}}}])}(),Ou="\\[\\]\\.:\\/",Fu=new RegExp("["+Ou+"]","g"),Bu="[^"+Ou+"]",zu="[^"+Ou.replace("\\.","")+"]",Hu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Bu)+/(WCOD+)?/.source.replace("WCOD",zu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Bu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Bu)+"$"),Vu=["material","materials","bones","map"],Gu=function(){return o((function e(t,n,i){r(this,e);var a=i||Wu.parseTrackName(n);this._targetGroup=t,this._bindings=t.subscribe_(n,a)}),[{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()}}])}(),Wu=function(){function e(t,n,i){r(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 o(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,!0===t.isMaterial?u=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(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(Fu,"")}},{key:"parseTrackName",value:function(e){var t=Hu.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!==Vu.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){for(var n=0;n<e.length;n++){var r=e[n];if(r.name===t||r.uuid===t)return r;var a=i(r.children);if(a)return a}return null},r=i(e.children);if(r)return r}return null}}])}();Wu.Composite=Gu,Wu.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Wu.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Wu.prototype.GetterByBindingType=[Wu.prototype._getValue_direct,Wu.prototype._getValue_array,Wu.prototype._getValue_arrayElement,Wu.prototype._getValue_toArray],Wu.prototype.SetterByBindingTypeAndVersioning=[[Wu.prototype._setValue_direct,Wu.prototype._setValue_direct_setNeedsUpdate,Wu.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Wu.prototype._setValue_array,Wu.prototype._setValue_array_setNeedsUpdate,Wu.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Wu.prototype._setValue_arrayElement,Wu.prototype._setValue_arrayElement_setNeedsUpdate,Wu.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Wu.prototype._setValue_fromArray,Wu.prototype._setValue_fromArray_setNeedsUpdate,Wu.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var ju=function(){return o((function e(){r(this,e),this.isAnimationObjectGroup=!0,this.uuid=mt(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var a=this;this.stats={objects:{get total(){return a._objects.length},get inUse(){return this.total-a.nCachedObjects_}},get bindingsPerObject(){return a._bindings.length}}}),[{key:"add",value:function(){for(var e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,a=r.length,o=void 0,s=e.length,l=this.nCachedObjects_,u=0,c=arguments.length;u!==c;++u){var h=arguments[u],d=h.uuid,f=t[d];if(void 0===f){f=s++,t[d]=f,e.push(h);for(var p=0,v=a;p!==v;++p)r[p].push(new Wu(h,n[p],i[p]))}else if(f<l){o=e[f];var m=--l,g=e[m];t[g.uuid]=f,e[f]=g,t[d]=m,e[m]=h;for(var y=0,_=a;y!==_;++y){var x=r[y],M=x[m],S=x[f];x[f]=M,void 0===S&&(S=new Wu(h,n[y],i[y])),x[m]=S}}else e[f]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}},{key:"remove",value:function(){for(var e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=0,o=arguments.length;a!==o;++a){var s=arguments[a],l=s.uuid,u=t[l];if(void 0!==u&&u>=r){var c=r++,h=e[c];t[h.uuid]=u,e[u]=h,t[l]=c,e[c]=s;for(var d=0,f=i;d!==f;++d){var p=n[d],v=p[c],m=p[u];p[u]=v,p[c]=m}}}this.nCachedObjects_=r}},{key:"uncache",value:function(){for(var e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length,o=0,s=arguments.length;o!==s;++o){var l=arguments[o].uuid,u=t[l];if(void 0!==u)if(delete t[l],u<r){var c=--r,h=e[c],d=--a,f=e[d];t[h.uuid]=u,e[u]=h,t[f.uuid]=c,e[c]=f,e.pop();for(var p=0,v=i;p!==v;++p){var m=n[p],g=m[c],y=m[d];m[u]=g,m[c]=y,m.pop()}}else{var _=--a,x=e[_];_>0&&(t[x.uuid]=u),e[u]=x,e.pop();for(var M=0,S=i;M!==S;++M){var b=n[M];b[u]=b[_],b.pop()}}}this.nCachedObjects_=r}},{key:"subscribe_",value:function(e,t){var n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];var a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,u=this.nCachedObjects_,c=new Array(l);i=r.length,n[e]=i,a.push(e),o.push(t),r.push(c);for(var h=u,d=s.length;h!==d;++h){var f=s[h];c[h]=new Wu(f,e,t)}return c}},{key:"unsubscribe_",value:function(e){var t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){var i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];t[e[o]]=n,a[n]=s,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}])}(),Xu=function(){return o((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.blendMode;r(this,e),this._mixer=t,this._clip=n,this._localRoot=i,this.blendMode=a;for(var o=n.tracks,s=o.length,l=new Array(s),u={endingStart:Ke,endingEnd:Ke},c=0;c!==s;++c){var h=o[c].createInterpolant(null);l[c]=h,h.settings=u}this._interpolantSettings=u,this._interpolants=l,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}),[{key:"play",value:function(){return this._mixer._activateAction(this),this}},{key:"stop",value:function(){return this._mixer._deactivateAction(this),this.reset()}},{key:"reset",value:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}},{key:"isRunning",value:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}},{key:"isScheduled",value:function(){return this._mixer._isActiveAction(this)}},{key:"startAt",value:function(e){return this._startTime=e,this}},{key:"setLoop",value:function(e,t){return this.loop=e,this.repetitions=t,this}},{key:"setEffectiveWeight",value:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}},{key:"getEffectiveWeight",value:function(){return this._effectiveWeight}},{key:"fadeIn",value:function(e){return this._scheduleFading(e,0,1)}},{key:"fadeOut",value:function(e){return this._scheduleFading(e,1,0)}},{key:"crossFadeFrom",value:function(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){var i=this._clip.duration,r=e._clip.duration,a=r/i,o=i/r;e.warp(1,a,t),this.warp(o,1,t)}return this}},{key:"crossFadeTo",value:function(e,t,n){return e.crossFadeFrom(this,t,n)}},{key:"stopFading",value:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}},{key:"setEffectiveTimeScale",value:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}},{key:"getEffectiveTimeScale",value:function(){return this._effectiveTimeScale}},{key:"setDuration",value:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}},{key:"syncWith",value:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}},{key:"halt",value:function(e){return this.warp(this._effectiveTimeScale,0,e)}},{key:"warp",value:function(e,t,n){var i=this._mixer,r=i.time,a=this.timeScale,o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,l=o.sampleValues;return s[0]=r,s[1]=r+n,l[0]=e/a,l[1]=t/a,this}},{key:"stopWarping",value:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}},{key:"getMixer",value:function(){return this._mixer}},{key:"getClip",value:function(){return this._clip}},{key:"getRoot",value:function(){return this._localRoot||this._mixer._root}},{key:"_update",value:function(e,t,n,i){if(this.enabled){var r=this._startTime;if(null!==r){var a=(e-r)*n;a<0||0===n?t=0:(this._startTime=null,t=n*a)}t*=this._updateTimeScale(e);var o=this._updateTime(t),s=this._updateWeight(e);if(s>0){var l=this._interpolants,u=this._propertyBindings;if(this.blendMode===et)for(var c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(s);else for(var d=0,f=l.length;d!==f;++d)l[d].evaluate(o),u[d].accumulate(i,s)}}else this._updateWeight(e)}},{key:"_updateWeight",value:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}},{key:"_updateTimeScale",value:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t}},{key:"_updateTime",value:function(e){var t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=2202===n;if(0===e)return-1===r||!a||1&~r?i:t-i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){var o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&!(1&~r))return t-i}return i}},{key:"_setEndings",value:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=Je,i.endingEnd=Je):(i.endingStart=e?this.zeroSlopeAtStart?Je:Ke:Qe,i.endingEnd=t?this.zeroSlopeAtEnd?Je:Ke:Qe)}},{key:"_scheduleFading",value:function(e,t,n){var i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}])}(),qu=new Float32Array(1),Yu=function(e){function t(e){var n;return r(this,t),(n=i(this,t))._root=e,n._initMemoryManager(),n._accuIndex=0,n.time=0,n.timeScale=1,n}return h(t,e),o(t,[{key:"_bindAction",value:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,u=l[s];void 0===u&&(u={},l[s]=u);for(var c=0;c!==r;++c){var h=i[c],d=h.name,f=u[d];if(void 0!==f)++f.referenceCount,a[c]=f;else{if(void 0!==(f=a[c])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,d));continue}var p=t&&t._propertyBindings[c].binding.parsedPath;++(f=new Du(Wu.create(n,d,p),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,d),a[c]=f}o[c].resultBuffer=f.buffer}}},{key:"_activateAction",value:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}},{key:"_deactivateAction",value:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}},{key:"_initMemoryManager",value:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}},{key:"_isActiveAction",value:function(e){var t=e._cacheIndex;return null!==t&&t<this._nActiveActions}},{key:"_addInactiveAction",value:function(e,t,n){var i=this._actions,r=this._actionsByClip,a=r[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{var o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}},{key:"_removeInactiveAction",value:function(e){var t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;var r=e._clip.uuid,a=this._actionsByClip,o=a[r],s=o.knownActions,l=s[s.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,s[u]=l,s.pop(),e._byClipCacheIndex=null,delete o.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete a[r],this._removeInactiveBindingsForAction(e)}},{key:"_removeInactiveBindingsForAction",value:function(e){for(var t=e._propertyBindings,n=0,i=t.length;n!==i;++n){var r=t[n];0==--r.referenceCount&&this._removeInactiveBinding(r)}}},{key:"_lendAction",value:function(e){var t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}},{key:"_takeBackAction",value:function(e){var t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}},{key:"_addInactiveBinding",value:function(e,t,n){var i=this._bindingsByRootAndName,r=this._bindings,a=i[t];void 0===a&&(a={},i[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}},{key:"_removeInactiveBinding",value:function(e){var t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,o=a[i],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete o[r],0===Object.keys(o).length&&delete a[i]}},{key:"_lendBinding",value:function(e){var t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}},{key:"_takeBackBinding",value:function(e){var t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}},{key:"_lendControlInterpolant",value:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return void 0===n&&((n=new pl(new Float32Array(2),new Float32Array(2),1,qu)).__cacheIndex=t,e[t]=n),n}},{key:"_takeBackControlInterpolant",value:function(e){var t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}},{key:"clipAction",value:function(e,t,n){var i=t||this._root,r=i.uuid,a="string"==typeof e?Tl.findByName(i,e):e,o=null!==a?a.uuid:e,s=this._actionsByClip[o],l=null;if(void 0===n&&(n=null!==a?a.blendMode:$e),void 0!==s){var u=s.actionByRoot[r];if(void 0!==u&&u.blendMode===n)return u;l=s.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;var c=new Xu(this,a,t,n);return this._bindAction(c,l),this._addInactiveAction(c,o,r),c}},{key:"existingAction",value:function(e,t){var n=t||this._root,i=n.uuid,r="string"==typeof e?Tl.findByName(n,e):e,a=r?r.uuid:e,o=this._actionsByClip[a];return void 0!==o&&o.actionByRoot[i]||null}},{key:"stopAllAction",value:function(){for(var e=this._actions,t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}},{key:"update",value:function(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1,o=0;o!==n;++o){t[o]._update(i,e,r,a)}for(var s=this._bindings,l=this._nActiveBindings,u=0;u!==l;++u)s[u].apply(a);return this}},{key:"setTime",value:function(e){this.time=0;for(var t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}},{key:"getRoot",value:function(){return this._root}},{key:"uncacheClip",value:function(e){var t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){for(var a=r.knownActions,o=0,s=a.length;o!==s;++o){var l=a[o];this._deactivateAction(l);var u=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=u,t[u]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}},{key:"uncacheRoot",value:function(e){var t=e.uuid,n=this._actionsByClip;for(var i in n){var r=n[i].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var a=this._bindingsByRootAndName[t];if(void 0!==a)for(var o in a){var s=a[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}}},{key:"uncacheAction",value:function(e,t){var n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}])}(ht),Zu=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r(this,t),(e=i(this,t,[n,a,s])).isRenderTarget3D=!0,e.depth=o,e.texture=new Qt(null,n,a,o),e.texture.isRenderTargetTexture=!0,e}return h(t,e),o(t)}(Yt),Ku=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r(this,t),(e=i(this,t,[n,a,s])).isRenderTargetArray=!0,e.depth=o,e.texture=new Kt(null,n,a,o),e.texture.isRenderTargetTexture=!0,e}return h(t,e),o(t)}(Yt),Ju=function(){function e(t){r(this,e),this.value=t}return o(e,[{key:"clone",value:function(){return new e(void 0===this.value.clone?this.value:this.value.clone())}}])}(),Qu=0,$u=function(e){function t(){var e;return r(this,t),(e=i(this,t)).isUniformsGroup=!0,Object.defineProperty(e,"id",{value:Qu++}),e.name="",e.usage=st,e.uniforms=[],e}return h(t,e),o(t,[{key:"add",value:function(e){return this.uniforms.push(e),this}},{key:"remove",value:function(e){var t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}},{key:"setName",value:function(e){return this.name=e,this}},{key:"setUsage",value:function(e){return this.usage=e,this}},{key:"dispose",value:function(){return this.dispatchEvent({type:"dispose"}),this}},{key:"copy",value:function(e){this.name=e.name,this.usage=e.usage;var t=e.uniforms;this.uniforms.length=0;for(var n=0,i=t.length;n<i;n++)for(var r=Array.isArray(t[n])?t[n]:[t[n]],a=0;a<r.length;a++)this.uniforms.push(r[a].clone());return this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}])}(ht),ec=function(e){function t(e,n){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return r(this,t),(a=i(this,t,[e,n])).isInstancedInterleavedBuffer=!0,a.meshPerAttribute=o,a}return h(t,e),o(t,[{key:"copy",value:function(e){return y(t,"copy",this)([e]),this.meshPerAttribute=e.meshPerAttribute,this}},{key:"clone",value:function(e){var n=y(t,"clone",this)([e]);return n.meshPerAttribute=this.meshPerAttribute,n}},{key:"toJSON",value:function(e){var n=y(t,"toJSON",this)([e]);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}])}(Pr),tc=function(){return o((function e(t,n,i,a,o){r(this,e),this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=n,this.itemSize=i,this.elementSize=a,this.count=o,this.version=0}),[{key:"needsUpdate",set:function(e){!0===e&&this.version++}},{key:"setBuffer",value:function(e){return this.buffer=e,this}},{key:"setType",value:function(e,t){return this.type=e,this.elementSize=t,this}},{key:"setItemSize",value:function(e){return this.itemSize=e,this}},{key:"setCount",value:function(e){return this.count=e,this}}])}(),nc=new Pn,ic=function(){return o((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;r(this,e),this.ray=new In(t,n),this.near=i,this.far=a,this.camera=null,this.layers=new Gn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}),[{key:"set",value:function(e,t){this.ray.set(e,t)}},{key:"setFromCamera",value:function(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}},{key:"setFromXRController",value:function(e){return nc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(nc),this}},{key:"intersectObject",value:function(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return ac(e,this,t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1]),t.sort(rc),t}},{key:"intersectObjects",value:function(e){for(var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=0,r=e.length;i<r;i++)ac(e[i],this,n,t);return n.sort(rc),n}}])}();function rc(e,t){return e.distance-t.distance}function ac(e,t,n,i){var r=!0;e.layers.test(t.layers)&&(!1===e.raycast(t,n)&&(r=!1));if(!0===r&&!0===i)for(var a=e.children,o=0,s=a.length;o<s;o++)ac(a[o],t,n,!0)}var oc=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return r(this,e),this.radius=t,this.phi=n,this.theta=i,this}),[{key:"set",value:function(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}},{key:"copy",value:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}},{key:"makeSafe",value:function(){var e=1e-6;return this.phi=gt(this.phi,e,Math.PI-e),this}},{key:"setFromVector3",value:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}},{key:"setFromCartesianCoords",value:function(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(gt(t/this.radius,-1,1))),this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}])}(),sc=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return r(this,e),this.radius=t,this.theta=n,this.y=i,this}),[{key:"set",value:function(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}},{key:"copy",value:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}},{key:"setFromVector3",value:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}},{key:"setFromCartesianCoords",value:function(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}])}(),lc=function(){return o((function e(t,n,i,a){r(this,e),e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,n,i,a)}),[{key:"identity",value:function(){return this.set(1,0,0,1),this}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<4;n++)this.elements[n]=e[n+t];return this}},{key:"set",value:function(e,t,n,i){var r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}])}(),uc=new bt,cc=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new bt(1/0,1/0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bt(-1/0,-1/0);r(this,e),this.isBox2=!0,this.min=t,this.max=n}),[{key:"set",value:function(e,t){return this.min.copy(e),this.max.copy(t),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=uc.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}},{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=1/0,this.max.x=this.max.y=-1/0,this}},{key:"isEmpty",value:function(){return this.max.x<this.min.x||this.max.y<this.min.y}},{key:"getCenter",value:function(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}},{key:"getSize",value:function(e){return this.isEmpty()?e.set(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:"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}},{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}},{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))}},{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}},{key:"clampPoint",value:function(e,t){return t.copy(e).clamp(this.min,this.max)}},{key:"distanceToPoint",value:function(e){return this.clampPoint(e,uc).distanceTo(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:"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)}}])}(),hc=new tn,dc=new tn,fc=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn;r(this,e),this.start=t,this.end=n}),[{key:"set",value:function(e,t){return this.start.copy(e),this.end.copy(t),this}},{key:"copy",value:function(e){return this.start.copy(e.start),this.end.copy(e.end),this}},{key:"getCenter",value:function(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}},{key:"delta",value:function(e){return e.subVectors(this.end,this.start)}},{key:"distanceSq",value:function(){return this.start.distanceToSquared(this.end)}},{key:"distance",value:function(){return this.start.distanceTo(this.end)}},{key:"at",value:function(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}},{key:"closestPointToPointParameter",value:function(e,t){hc.subVectors(e,this.start),dc.subVectors(this.end,this.start);var n=dc.dot(dc),i=dc.dot(hc)/n;return t&&(i=gt(i,0,1)),i}},{key:"closestPointToPoint",value:function(e,t,n){var i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}},{key:"applyMatrix4",value:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}},{key:"equals",value:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}},{key:"clone",value:function(){return(new this.constructor).copy(this)}}])}(),pc=new tn,vc=function(e){function t(e,n){var a;r(this,t),(a=i(this,t)).light=e,a.matrixAutoUpdate=!1,a.color=n,a.type="SpotLightHelper";for(var o=new $i,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],l=0,u=1;l<32;l++,u++){var c=l/32*Math.PI*2,h=u/32*Math.PI*2;s.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}o.setAttribute("position",new ji(s,3));var d=new Ya({fog:!1,toneMapped:!1});return a.cone=new oo(o,d),a.add(a.cone),a.update(),a}return h(t,e),o(t,[{key:"dispose",value:function(){this.cone.geometry.dispose(),this.cone.material.dispose()}},{key:"update",value:function(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),pc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(pc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}])}(ai),mc=new tn,gc=new Pn,yc=new Pn,_c=function(e){function t(e){var n;r(this,t);for(var a=xc(e),o=new $i,s=[],l=[],u=new Ti(0,0,1),c=new Ti(0,1,0),h=0;h<a.length;h++){var d=a[h];d.parent&&d.parent.isBone&&(s.push(0,0,0),s.push(0,0,0),l.push(u.r,u.g,u.b),l.push(c.r,c.g,c.b))}return o.setAttribute("position",new ji(s,3)),o.setAttribute("color",new ji(l,3)),(n=i(this,t,[o,new Ya({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})])).isSkeletonHelper=!0,n.type="SkeletonHelper",n.root=e,n.bones=a,n.matrix=e.matrixWorld,n.matrixAutoUpdate=!1,n}return h(t,e),o(t,[{key:"updateMatrixWorld",value:function(e){var n=this.bones,i=this.geometry,r=i.getAttribute("position");yc.copy(this.root.matrixWorld).invert();for(var a=0,o=0;a<n.length;a++){var s=n[a];s.parent&&s.parent.isBone&&(gc.multiplyMatrices(yc,s.matrixWorld),mc.setFromMatrixPosition(gc),r.setXYZ(o,mc.x,mc.y,mc.z),gc.multiplyMatrices(yc,s.parent.matrixWorld),mc.setFromMatrixPosition(gc),r.setXYZ(o+1,mc.x,mc.y,mc.z),o+=2)}i.getAttribute("position").needsUpdate=!0,y(t,"updateMatrixWorld",this)([e])}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo);function xc(e){var t=[];!0===e.isBone&&t.push(e);for(var n=0;n<e.children.length;n++)t.push.apply(t,xc(e.children[n]));return t}var Mc=function(e){function t(e,n,a){var o;return r(this,t),(o=i(this,t,[new zs(n,4,2),new Ri({wireframe:!0,fog:!1,toneMapped:!1})])).light=e,o.color=a,o.type="PointLightHelper",o.matrix=o.light.matrixWorld,o.matrixAutoUpdate=!1,o.update(),o}return h(t,e),o(t,[{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}},{key:"update",value:function(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}])}(hr),Sc=new tn,bc=new Ti,Tc=new Ti,Ec=function(e){function t(e,n,a){var o;r(this,t),(o=i(this,t)).light=e,o.matrix=e.matrixWorld,o.matrixAutoUpdate=!1,o.color=a,o.type="HemisphereLightHelper";var s=new Ds(n);s.rotateY(.5*Math.PI),o.material=new Ri({wireframe:!0,fog:!1,toneMapped:!1}),void 0===o.color&&(o.material.vertexColors=!0);var l=s.getAttribute("position"),u=new Float32Array(3*l.count);return s.setAttribute("color",new Di(u,3)),o.add(new hr(s,o.material)),o.update(),o}return h(t,e),o(t,[{key:"dispose",value:function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}},{key:"update",value:function(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var t=e.geometry.getAttribute("color");bc.copy(this.light.color),Tc.copy(this.light.groundColor);for(var n=0,i=t.count;n<i;n++){var r=n<i/2?bc:Tc;t.setXYZ(n,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Sc.setFromMatrixPosition(this.light.matrixWorld).negate())}}])}(ai),wc=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4473924,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8947848;r(this,t),o=new Ti(o),s=new Ti(s);for(var l=a/2,u=n/a,c=n/2,h=[],d=[],f=0,p=0,v=-c;f<=a;f++,v+=u){h.push(-c,0,v,c,0,v),h.push(v,0,-c,v,0,c);var m=f===l?o:s;m.toArray(d,p),p+=3,m.toArray(d,p),p+=3,m.toArray(d,p),p+=3,m.toArray(d,p),p+=3}var g=new $i;return g.setAttribute("position",new ji(h,3)),g.setAttribute("color",new ji(d,3)),(e=i(this,t,[g,new Ya({vertexColors:!0,toneMapped:!1})])).type="GridHelper",e}return h(t,e),o(t,[{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo),Ac=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:64,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:4473924,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:8947848;r(this,t),l=new Ti(l),u=new Ti(u);var c=[],h=[];if(a>1)for(var d=0;d<a;d++){var f=d/a*(2*Math.PI),p=Math.sin(f)*n,v=Math.cos(f)*n;c.push(0,0,0),c.push(p,0,v);var m=1&d?l:u;h.push(m.r,m.g,m.b),h.push(m.r,m.g,m.b)}for(var g=0;g<o;g++)for(var y=1&g?l:u,_=n-n/o*g,x=0;x<s;x++){var M=x/s*(2*Math.PI),S=Math.sin(M)*_,b=Math.cos(M)*_;c.push(S,0,b),h.push(y.r,y.g,y.b),M=(x+1)/s*(2*Math.PI),S=Math.sin(M)*_,b=Math.cos(M)*_,c.push(S,0,b),h.push(y.r,y.g,y.b)}var T=new $i;return T.setAttribute("position",new ji(c,3)),T.setAttribute("color",new ji(h,3)),(e=i(this,t,[T,new Ya({vertexColors:!0,toneMapped:!1})])).type="PolarGridHelper",e}return h(t,e),o(t,[{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo),Rc=new tn,Cc=new tn,kc=new tn,Ic=function(e){function t(e,n,a){var o;r(this,t),(o=i(this,t)).light=e,o.matrix=e.matrixWorld,o.matrixAutoUpdate=!1,o.color=a,o.type="DirectionalLightHelper",void 0===n&&(n=1);var s=new $i;s.setAttribute("position",new ji([-n,n,0,n,n,0,n,-n,0,-n,-n,0,-n,n,0],3));var l=new Ya({fog:!1,toneMapped:!1});return o.lightPlane=new no(s,l),o.add(o.lightPlane),(s=new $i).setAttribute("position",new ji([0,0,0,0,0,1],3)),o.targetLine=new no(s,l),o.add(o.targetLine),o.update(),o}return h(t,e),o(t,[{key:"dispose",value:function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}},{key:"update",value:function(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Rc.setFromMatrixPosition(this.light.matrixWorld),Cc.setFromMatrixPosition(this.light.target.matrixWorld),kc.subVectors(Cc,Rc),this.lightPlane.lookAt(Cc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Cc),this.targetLine.scale.z=kc.length()}}])}(ai),Pc=new tn,Lc=new xr,Nc=function(e){function t(e){var n;r(this,t);var a=new $i,o=new Ya({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],l=[],u={};function c(e,t){h(e),h(t)}function h(e){s.push(0,0,0),l.push(0,0,0),void 0===u[e]&&(u[e]=[]),u[e].push(s.length/3-1)}c("n1","n2"),c("n2","n4"),c("n4","n3"),c("n3","n1"),c("f1","f2"),c("f2","f4"),c("f4","f3"),c("f3","f1"),c("n1","f1"),c("n2","f2"),c("n3","f3"),c("n4","f4"),c("p","n1"),c("p","n2"),c("p","n3"),c("p","n4"),c("u1","u2"),c("u2","u3"),c("u3","u1"),c("c","t"),c("p","c"),c("cn1","cn2"),c("cn3","cn4"),c("cf1","cf2"),c("cf3","cf4"),a.setAttribute("position",new ji(s,3)),a.setAttribute("color",new ji(l,3)),(n=i(this,t,[a,o])).type="CameraHelper",n.camera=e,n.camera.updateProjectionMatrix&&n.camera.updateProjectionMatrix(),n.matrix=e.matrixWorld,n.matrixAutoUpdate=!1,n.pointMap=u,n.update();var d=new Ti(16755200),f=new Ti(16711680),p=new Ti(43775),v=new Ti(16777215),m=new Ti(3355443);return n.setColors(d,f,p,v,m),n}return h(t,e),o(t,[{key:"setColors",value:function(e,t,n,i,r){var a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}},{key:"update",value:function(){var e=this.geometry,t=this.pointMap;Lc.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);var n=this.camera.coordinateSystem===ut?-1:0;Uc("c",t,e,Lc,0,0,n),Uc("t",t,e,Lc,0,0,1),Uc("n1",t,e,Lc,-1,-1,n),Uc("n2",t,e,Lc,1,-1,n),Uc("n3",t,e,Lc,-1,1,n),Uc("n4",t,e,Lc,1,1,n),Uc("f1",t,e,Lc,-1,-1,1),Uc("f2",t,e,Lc,1,-1,1),Uc("f3",t,e,Lc,-1,1,1),Uc("f4",t,e,Lc,1,1,1),Uc("u1",t,e,Lc,.7,1.1,n),Uc("u2",t,e,Lc,-.7,1.1,n),Uc("u3",t,e,Lc,0,2,n),Uc("cf1",t,e,Lc,-1,0,1),Uc("cf2",t,e,Lc,1,0,1),Uc("cf3",t,e,Lc,0,-1,1),Uc("cf4",t,e,Lc,0,1,1),Uc("cn1",t,e,Lc,-1,0,n),Uc("cn2",t,e,Lc,1,0,n),Uc("cn3",t,e,Lc,0,-1,n),Uc("cn4",t,e,Lc,0,1,n),e.getAttribute("position").needsUpdate=!0}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo);function Uc(e,t,n,i,r,a,o){Pc.set(r,a,o).unproject(i);var s=t[e];if(void 0!==s)for(var l=n.getAttribute("position"),u=0,c=s.length;u<c;u++)l.setXYZ(s[u],Pc.x,Pc.y,Pc.z)}var Dc,Oc,Fc=new an,Bc=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;r(this,t);var o=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=new Float32Array(24),l=new $i;return l.setIndex(new Di(o,1)),l.setAttribute("position",new Di(s,3)),(n=i(this,t,[l,new Ya({color:a,toneMapped:!1})])).object=e,n.type="BoxHelper",n.matrixAutoUpdate=!1,n.update(),n}return h(t,e),o(t,[{key:"update",value:function(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Fc.setFromObject(this.object),!Fc.isEmpty()){var t=Fc.min,n=Fc.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}}},{key:"setFromObject",value:function(e){return this.object=e,this.update(),this}},{key:"copy",value:function(e,n){return y(t,"copy",this)([e,n]),this.object=e.object,this}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo),zc=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;r(this,t);var o=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=new $i;return s.setIndex(new Di(o,1)),s.setAttribute("position",new ji([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),(n=i(this,t,[s,new Ya({color:a,toneMapped:!1})])).box=e,n.type="Box3Helper",n.geometry.computeBoundingSphere(),n}return h(t,e),o(t,[{key:"updateMatrixWorld",value:function(e){var n=this.box;n.isEmpty()||(n.getCenter(this.position),n.getSize(this.scale),this.scale.multiplyScalar(.5),y(t,"updateMatrixWorld",this)([e]))}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo),Hc=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16776960;r(this,t);var s=o,l=new $i;l.setAttribute("position",new ji([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),l.computeBoundingSphere(),(n=i(this,t,[l,new Ya({color:s,toneMapped:!1})])).type="PlaneHelper",n.plane=e,n.size=a;var u=new $i;return u.setAttribute("position",new ji([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),u.computeBoundingSphere(),n.add(new hr(u,new Ri({color:s,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1}))),n}return h(t,e),o(t,[{key:"updateMatrixWorld",value:function(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),y(t,"updateMatrixWorld",this)([e])}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}])}(no),Vc=new tn,Gc=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tn(0,0,1),a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new tn(0,0,0),o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16776960,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.2*o,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:.2*l;return r(this,t),(e=i(this,t)).type="ArrowHelper",void 0===Dc&&((Dc=new $i).setAttribute("position",new ji([0,0,0,0,1,0],3)),(Oc=new Zo(0,.5,1,5,1)).translate(0,-.5,0)),e.position.copy(a),e.line=new no(Dc,new Ya({color:s,toneMapped:!1})),e.line.matrixAutoUpdate=!1,e.add(e.line),e.cone=new hr(Oc,new Ri({color:s,toneMapped:!1})),e.cone.matrixAutoUpdate=!1,e.add(e.cone),e.setDirection(n),e.setLength(o,l,u),e}return h(t,e),o(t,[{key:"setDirection",value:function(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Vc.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Vc,t)}}},{key:"setLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2*e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.2*t;this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}},{key:"setColor",value:function(e){this.line.material.color.set(e),this.cone.material.color.set(e)}},{key:"copy",value:function(e){return y(t,"copy",this)([e,!1]),this.line.copy(e.line),this.cone.copy(e.cone),this}},{key:"dispose",value:function(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}])}(ai),Wc=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;r(this,t);var a=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],o=new $i;return o.setAttribute("position",new ji(a,3)),o.setAttribute("color",new ji([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),(e=i(this,t,[o,new Ya({vertexColors:!0,toneMapped:!1})])).type="AxesHelper",e}return h(t,e),o(t,[{key:"setColors",value:function(e,t,n){var i=new Ti,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}},{key:"dispose",value:function(){this.geometry.dispose(),this.material.dispose()}}])}(oo),jc=function(){return o((function e(){r(this,e),this.type="ShapePath",this.color=new Ti,this.subPaths=[],this.currentPath=null}),[{key:"moveTo",value:function(e,t){return this.currentPath=new jo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}},{key:"lineTo",value:function(e,t){return this.currentPath.lineTo(e,t),this}},{key:"quadraticCurveTo",value:function(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}},{key:"bezierCurveTo",value:function(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}},{key:"splineThru",value:function(e){return this.currentPath.splineThru(e),this}},{key:"toShapes",value:function(e){function t(e,t){for(var n=t.length,i=!1,r=n-1,a=0;a<n;r=a++){var o=t[r],s=t[a],l=s.x-o.x,u=s.y-o.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(o=t[a],l=-l,s=t[r],u=-u),e.y<o.y||e.y>s.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var c=u*(e.x-o.x)-l*(e.y-o.y);if(0===c)return!0;if(c<0)continue;i=!i}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return i}var n,i,r,a=ks.isClockWise,o=this.subPaths;if(0===o.length)return[];var s=[];if(1===o.length)return i=o[0],(r=new rs).curves=i.curves,s.push(r),s;var l=!a(o[0].getPoints());l=e?!l:l;var u,c,h=[],d=[],f=[],p=0;d[p]=void 0,f[p]=[];for(var v=0,m=o.length;v<m;v++)n=a(u=(i=o[v]).getPoints()),(n=e?!n:n)?(!l&&d[p]&&p++,d[p]={s:new rs,p:u},d[p].s.curves=i.curves,l&&p++,f[p]=[]):f[p].push({h:i,p:u[0]});if(!d[0])return function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e[n],a=new rs;a.curves=r.curves,t.push(a)}return t}(o);if(d.length>1){for(var g=!1,y=0,_=0,x=d.length;_<x;_++)h[_]=[];for(var M=0,S=d.length;M<S;M++)for(var b=f[M],T=0;T<b.length;T++){for(var E=b[T],w=!0,A=0;A<d.length;A++)t(E.p,d[A].p)&&(M!==A&&y++,w?(w=!1,h[A].push(E)):g=!0);w&&h[M].push(E)}y>0&&!1===g&&(f=h)}for(var R=0,C=d.length;R<C;R++){r=d[R].s,s.push(r);for(var k=0,I=(c=f[R]).length;k<I;k++)r.holes.push(c[k].h)}return s}}])}(),Xc=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return r(this,t),(n=i(this,t)).object=e,n.domElement=a,n.enabled=!0,n.state=-1,n.keys={},n.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},n.touches={ONE:null,TWO:null},n}return h(t,e),o(t,[{key:"connect",value:function(){}},{key:"disconnect",value:function(){}},{key:"dispose",value:function(){}},{key:"update",value:function(){}}])}(ht);function qc(e,t,n,i){var r=function(e){switch(e){case j:case X:return{byteLength:1,components:1};case Y:case q:case Q:return{byteLength:2,components:1};case $:case ee:return{byteLength:2,components:4};case K:case Z:case J:return{byteLength:4,components:1};case ne:return{byteLength:4,components:3}}throw new Error("Unknown texture type ".concat(e,"."))}(i);switch(n){case ie:case oe:return e*t;case se:return e*t*2;case ce:case he:return e*t/r.components*r.byteLength;case de:case fe:return e*t*2/r.components*r.byteLength;case re:return e*t*3/r.components*r.byteLength;case ae:case pe:return e*t*4/r.components*r.byteLength;case ve:case me:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case ge:case ye:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case xe:case Se:return Math.max(e,16)*Math.max(t,8)/4;case _e:case Me:return Math.max(e,8)*Math.max(t,8)/2;case be:case Te:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ee:case we:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ae:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case Re:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Ce:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case ke:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Ie:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Pe:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Le:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Ne:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Ue:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case De:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case Oe:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case Fe:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case Be:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case ze:case He:case Ve:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Ge:case We:return Math.ceil(e/4)*Math.ceil(t/4)*8;case je:case Xe:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error("Unable to determine texture byte length for ".concat(n," format."))}var Yc={contain:function(e,t){var n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e},cover:function(e,t){var n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e},fill:function(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e},getByteLength:qc};function Zc(){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 Kc(e){var t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){var r=t.get(n);(!r||r.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version})}else{var a=t.get(n);if(void 0===a)t.set(n,function(t,n){var i,r=t.array,a=t.usage,o=r.byteLength,s=e.createBuffer();if(e.bindBuffer(n,s),e.bufferData(n,r,a),t.onUploadCallback(),r instanceof Float32Array)i=e.FLOAT;else if(r instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)i=e.SHORT;else if(r instanceof Uint32Array)i=e.UNSIGNED_INT;else if(r instanceof Int32Array)i=e.INT;else if(r instanceof Int8Array)i=e.BYTE;else if(r instanceof Uint8Array)i=e.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);i=e.UNSIGNED_BYTE}return{buffer:s,type:i,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:o}}(n,i));else if(a.version<n.version){if(a.size!==n.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,n,i){var r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((function(e,t){return e.start-t.start}));for(var o=0,s=1;s<a.length;s++){var l=a[o],u=a[s];u.start<=l.start+l.count+1?l.count=Math.max(l.count,u.start+u.count-l.start):a[++o]=u}a.length=o+1;for(var c=0,h=a.length;c<h;c++){var d=a[c];e.bufferSubData(i,d.start*r.BYTES_PER_ELEMENT,r,d.start,d.count)}n.clearUpdateRanges()}n.onUploadCallback()}(a.buffer,n,i),a.version=n.version}}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:T}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=T);var Jc={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\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\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\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\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\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\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#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\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 ) || defined( USE_BATCHING_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 ) || defined( USE_BATCHING_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\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.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}\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\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\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:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\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}",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, envMapRotation * 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\tuniform mat3 envMapRotation;\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, envMapRotation * 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, envMapRotation * 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_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\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\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_DISPERSION\n\tmaterial.dispersion = dispersion;\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\tfloat dispersion;\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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, 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 )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\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",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\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\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\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.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in 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( const in 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 shadowIntensity;\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 shadowIntensity;\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 shadowIntensity;\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 shadowIntensity, 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 mix( 1.0, shadow, shadowIntensity );\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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\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 shadowIntensity;\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 shadowIntensity;\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 shadowIntensity;\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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, 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 CineonToneMapping( 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 *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\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\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\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.dispersion, 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 dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\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;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * 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#include <morphinstance_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\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\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#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\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#include <morphinstance_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\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\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 ), diffuseColor.a );\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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_DISPERSION\n\tuniform float dispersion;\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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\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 <morphinstance_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\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 <morphinstance_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[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\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}"},Qc={common:{diffuse:{value:new Ti(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tt},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tt}},envmap:{envMap:{value:null},envMapRotation:{value:new Tt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tt},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ti(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 Ti(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0},uvTransform:{value:new Tt}},sprite:{diffuse:{value:new Ti(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tt},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0}}},$c={basic:{uniforms:vr([Qc.common,Qc.specularmap,Qc.envmap,Qc.aomap,Qc.lightmap,Qc.fog]),vertexShader:Jc.meshbasic_vert,fragmentShader:Jc.meshbasic_frag},lambert:{uniforms:vr([Qc.common,Qc.specularmap,Qc.envmap,Qc.aomap,Qc.lightmap,Qc.emissivemap,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,Qc.fog,Qc.lights,{emissive:{value:new Ti(0)}}]),vertexShader:Jc.meshlambert_vert,fragmentShader:Jc.meshlambert_frag},phong:{uniforms:vr([Qc.common,Qc.specularmap,Qc.envmap,Qc.aomap,Qc.lightmap,Qc.emissivemap,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,Qc.fog,Qc.lights,{emissive:{value:new Ti(0)},specular:{value:new Ti(1118481)},shininess:{value:30}}]),vertexShader:Jc.meshphong_vert,fragmentShader:Jc.meshphong_frag},standard:{uniforms:vr([Qc.common,Qc.envmap,Qc.aomap,Qc.lightmap,Qc.emissivemap,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,Qc.roughnessmap,Qc.metalnessmap,Qc.fog,Qc.lights,{emissive:{value:new Ti(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Jc.meshphysical_vert,fragmentShader:Jc.meshphysical_frag},toon:{uniforms:vr([Qc.common,Qc.aomap,Qc.lightmap,Qc.emissivemap,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,Qc.gradientmap,Qc.fog,Qc.lights,{emissive:{value:new Ti(0)}}]),vertexShader:Jc.meshtoon_vert,fragmentShader:Jc.meshtoon_frag},matcap:{uniforms:vr([Qc.common,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,Qc.fog,{matcap:{value:null}}]),vertexShader:Jc.meshmatcap_vert,fragmentShader:Jc.meshmatcap_frag},points:{uniforms:vr([Qc.points,Qc.fog]),vertexShader:Jc.points_vert,fragmentShader:Jc.points_frag},dashed:{uniforms:vr([Qc.common,Qc.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Jc.linedashed_vert,fragmentShader:Jc.linedashed_frag},depth:{uniforms:vr([Qc.common,Qc.displacementmap]),vertexShader:Jc.depth_vert,fragmentShader:Jc.depth_frag},normal:{uniforms:vr([Qc.common,Qc.bumpmap,Qc.normalmap,Qc.displacementmap,{opacity:{value:1}}]),vertexShader:Jc.meshnormal_vert,fragmentShader:Jc.meshnormal_frag},sprite:{uniforms:vr([Qc.sprite,Qc.fog]),vertexShader:Jc.sprite_vert,fragmentShader:Jc.sprite_frag},background:{uniforms:{uvTransform:{value:new Tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Jc.background_vert,fragmentShader:Jc.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Tt}},vertexShader:Jc.backgroundCube_vert,fragmentShader:Jc.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Jc.cube_vert,fragmentShader:Jc.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Jc.equirect_vert,fragmentShader:Jc.equirect_frag},distanceRGBA:{uniforms:vr([Qc.common,Qc.displacementmap,{referencePosition:{value:new tn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Jc.distanceRGBA_vert,fragmentShader:Jc.distanceRGBA_frag},shadow:{uniforms:vr([Qc.lights,Qc.fog,{color:{value:new Ti(0)},opacity:{value:1}}]),vertexShader:Jc.shadow_vert,fragmentShader:Jc.shadow_frag}};$c.physical={uniforms:vr([$c.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tt},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tt},sheen:{value:0},sheenColor:{value:new Ti(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tt},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tt},attenuationDistance:{value:0},attenuationColor:{value:new Ti(0)},specularColor:{value:new Ti(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tt},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tt}}]),vertexShader:Jc.meshphysical_vert,fragmentShader:Jc.meshphysical_frag};var eh={r:0,b:0,g:0},th=new Vn,nh=new Pn;function ih(e,t,n,i,r,a,o){var s,l,u=new Ti(0),c=!0===a?0:1,h=null,d=0,f=null;function p(e){var i=!0===e.isScene?e.background:null;i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i));return i}function v(t,n){t.getRGB(eh,mr(e)),i.buffers.color.setClear(eh.r,eh.g,eh.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),v(u,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){v(u,c=e)},render:function(t){var n=!1,r=p(t);null===r?v(u,c):r&&r.isColor&&(v(r,1),n=!0);var a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,o),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){var i=p(n);i&&(i.isCubeTexture||i.mapping===U)?(void 0===l&&((l=new hr(new fr(1,1,1),new _r({name:"BackgroundCubeMaterial",uniforms:pr($c.backgroundCube.uniforms),vertexShader:$c.backgroundCube.vertexShader,fragmentShader:$c.backgroundCube.fragmentShader,side:1,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)),th.copy(n.backgroundRotation),th.x*=-1,th.y*=-1,th.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(th.y*=-1,th.z*=-1),l.material.uniforms.envMap.value=i,l.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(nh.makeRotationFromEuler(th)),l.material.toneMapped=Ft.getTransfer(i.colorSpace)!==at,h===i&&d===i.version&&f===e.toneMapping||(l.material.needsUpdate=!0,h=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(void 0===s&&((s=new hr(new Os(2,2),new _r({name:"BackgroundMaterial",uniforms:pr($c.background.uniforms),vertexShader:$c.background.vertexShader,fragmentShader:$c.background.fragmentShader,side:0,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=i,s.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,s.material.toneMapped=Ft.getTransfer(i.colorSpace)!==at,!0===i.matrixAutoUpdate&&i.updateMatrix(),s.material.uniforms.uvTransform.value.copy(i.matrix),h===i&&d===i.version&&f===e.toneMapping||(s.material.needsUpdate=!0,h=i,d=i.version,f=e.toneMapping),s.layers.enableAll(),t.unshift(s,s.geometry,s.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose()),void 0!==s&&(s.geometry.dispose(),s.material.dispose())}}}function rh(e,t){var n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=u(null),a=r,o=!1;function s(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){for(var t=[],i=[],r=[],a=0;a<n;a++)t[a]=0,i[a]=0,r[a]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function c(){for(var e=a.newAttributes,t=0,n=e.length;t<n;t++)e[t]=0}function h(e){d(e,0)}function d(t,n){var i=a.newAttributes,r=a.enabledAttributes,o=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function f(){for(var t=a.newAttributes,n=a.enabledAttributes,i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function p(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 v(){m(),o=!0,a!==r&&s((a=r).object)}function m(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,v,m){var g,y=function(t,n,r){var a=!0===r.wireframe,o=i[t.id];void 0===o&&(o={},i[t.id]=o);var s=o[n.id];void 0===s&&(s={},o[n.id]=s);var l=s[a];void 0===l&&(l=u(e.createVertexArray()),s[a]=l);return l}(v,l,r);a!==y&&s((a=y).object),(g=function(e,t,n,i){var r=a.attributes,o=t.attributes,s=0,l=n.getAttributes();for(var u in l){if(l[u].location>=0){var c=r[u],h=o[u];if(void 0===h&&("instanceMatrix"===u&&e.instanceMatrix&&(h=e.instanceMatrix),"instanceColor"===u&&e.instanceColor&&(h=e.instanceColor)),void 0===c)return!0;if(c.attribute!==h)return!0;if(h&&c.data!==h.data)return!0;s++}}return a.attributesNum!==s||a.index!==i}(n,v,l,m))&&function(e,t,n,i){var r={},o=t.attributes,s=0,l=n.getAttributes();for(var u in l){if(l[u].location>=0){var c=o[u];void 0===c&&("instanceMatrix"===u&&e.instanceMatrix&&(c=e.instanceMatrix),"instanceColor"===u&&e.instanceColor&&(c=e.instanceColor));var h={};h.attribute=c,c&&c.data&&(h.data=c.data),r[u]=h,s++}}a.attributes=r,a.attributesNum=s,a.index=i}(n,v,l,m),null!==m&&t.update(m,e.ELEMENT_ARRAY_BUFFER),(g||o)&&(o=!1,function(n,i,r,a){c();var o=a.attributes,s=r.getAttributes(),l=i.defaultAttributeValues;for(var u in s){var v=s[u];if(v.location>=0){var m=o[u];if(void 0===m&&("instanceMatrix"===u&&n.instanceMatrix&&(m=n.instanceMatrix),"instanceColor"===u&&n.instanceColor&&(m=n.instanceColor)),void 0!==m){var g=m.normalized,y=m.itemSize,_=t.get(m);if(void 0===_)continue;var x=_.buffer,M=_.type,S=_.bytesPerElement,b=M===e.INT||M===e.UNSIGNED_INT||m.gpuType===Z;if(m.isInterleavedBufferAttribute){var T=m.data,E=T.stride,w=m.offset;if(T.isInstancedInterleavedBuffer){for(var A=0;A<v.locationSize;A++)d(v.location+A,T.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=T.meshPerAttribute*T.count)}else for(var R=0;R<v.locationSize;R++)h(v.location+R);e.bindBuffer(e.ARRAY_BUFFER,x);for(var C=0;C<v.locationSize;C++)p(v.location+C,y/v.locationSize,M,g,E*S,(w+y/v.locationSize*C)*S,b)}else{if(m.isInstancedBufferAttribute){for(var k=0;k<v.locationSize;k++)d(v.location+k,m.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=m.meshPerAttribute*m.count)}else for(var I=0;I<v.locationSize;I++)h(v.location+I);e.bindBuffer(e.ARRAY_BUFFER,x);for(var P=0;P<v.locationSize;P++)p(v.location+P,y/v.locationSize,M,g,y*S,y/v.locationSize*P*S,b)}}else if(void 0!==l){var L=l[u];if(void 0!==L)switch(L.length){case 2:e.vertexAttrib2fv(v.location,L);break;case 3:e.vertexAttrib3fv(v.location,L);break;case 4:e.vertexAttrib4fv(v.location,L);break;default:e.vertexAttrib1fv(v.location,L)}}}}f()}(n,r,l,v),null!==m&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(m).buffer))},reset:v,resetDefaultState:m,dispose:function(){for(var e in v(),i){var t=i[e];for(var n in t){var r=t[n];for(var a in r)l(r[a].object),delete r[a];delete t[n]}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0!==i[e.id]){var t=i[e.id];for(var n in t){var r=t[n];for(var a in r)l(r[a].object),delete r[a];delete t[n]}delete i[e.id]}},releaseStatesOfProgram:function(e){for(var t in i){var n=i[t];if(void 0!==n[e.id]){var r=n[e.id];for(var a in r)l(r[a].object),delete r[a];delete n[e.id]}}},initAttributes:c,enableAttribute:h,disableUnusedAttributes:f}}function ah(e,t,n){var i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0!==a){t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);for(var o=0,s=0;s<a;s++)o+=r[s];n.update(o,i,1)}},this.renderMultiDrawInstances=function(e,a,o,s){if(0!==o){var l=t.get("WEBGL_multi_draw");if(null===l)for(var u=0;u<e.length;u++)r(e[u],a[u],s[u]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,s,0,o);for(var c=0,h=0;h<o;h++)c+=a[h]*s[h];n.update(c,i,1)}}}}function oh(e,t,n,i){var r;function a(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 o=void 0!==n.precision?n.precision:"highp",s=a(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===n.logarithmicDepthBuffer,u=!0===n.reverseDepthBuffer&&t.has("EXT_clip_control"),c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){var n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===ae||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){var r=n===Q&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==j&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==J&&!r)},precision:o,logarithmicDepthBuffer:l,reverseDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:h>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function sh(e){var t=this,n=null,i=0,r=!1,a=!1,o=new wa,s=new Tt,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 v=a?0:i,m=4*v,g=p.clippingState||null;l.value=g,g=u(h,s,m,c);for(var y=0;y!==m;++y)g[y]=n[y];p.clippingState=g,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=v}}}function lh(e){var t=new WeakMap;function n(e,t){return t===L?e.mapping=I:t===N&&(e.mapping=P),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===L||a===N){if(t.has(r))return n(t.get(r).texture,r.mapping);var o=r.image;if(o&&o.height>0){var s=new Rr(o.height);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 uh=[.125,.215,.35,.446,.526,.582],ch=20,hh=new $l,dh=new Ti,fh=null,ph=0,vh=0,mh=!1,gh=(1+Math.sqrt(5))/2,yh=1/gh,_h=[new tn(-gh,yh,0),new tn(gh,yh,0),new tn(-yh,0,gh),new tn(yh,0,gh),new tn(0,gh,-yh),new tn(0,gh,yh),new tn(-1,1,-1),new tn(1,1,-1),new tn(-1,1,1),new tn(1,1,1)],xh=function(){return o((function e(t){r(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)}),[{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;fh=this._renderer.getRenderTarget(),ph=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,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=Th(),this._compileMaterial(this._cubemapMaterial))}},{key:"compileEquirectangularShader",value:function(){null===this._equirectMaterial&&(this._equirectMaterial=bh(),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(fh,ph,vh),this._renderer.xr.enabled=mh,e.scissorTest=!1,Sh(e,0,0,e.width,e.height)}},{key:"_fromTexture",value:function(e,t){e.mapping===I||e.mapping===P?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),fh=this._renderer.getRenderTarget(),ph=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;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:V,minFilter:V,generateMipmaps:!1,type:Q,format:ae,colorSpace:it,depthBuffer:!1},i=Mh(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Mh(e,t,n);var r=this._lodMax,a=function(e){for(var t=[],n=[],i=[],r=e,a=e-4+1+uh.length,o=0;o<a;o++){var s=Math.pow(2,r);n.push(s);var l=1/s;o>e-4?l=uh[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,v=3,m=2,g=1,y=new Float32Array(v*p*f),_=new Float32Array(m*p*f),x=new Float32Array(g*p*f),M=0;M<f;M++){var S=M%3*2/3-1,b=M>2?0:-1,T=[S,b,0,S+2/3,b,0,S+2/3,b+1,0,S,b,0,S+2/3,b+1,0,S,b+1,0];y.set(T,v*p*M),_.set(d,m*p*M);var E=[M,M,M,M,M,M];x.set(E,g*p*M)}var w=new $i;w.setAttribute("position",new Di(y,v)),w.setAttribute("uv",new Di(_,m)),w.setAttribute("faceIndex",new Di(x,g)),t.push(w),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(ch),r=new tn(0,1,0),a=new _r({name:"SphericalGaussianBlur",defines:{n:ch,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 hr(this._lodPlanes[0],e);this._renderer.compile(t,hh)}},{key:"_sceneToCubeUV",value:function(e,t,n,i){var r=new Tr(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(dh),s.toneMapping=0,s.autoClear=!1;var c=new Ri({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),h=new hr(new fr,c),d=!1,f=e.background;f?f.isColor&&(c.color.copy(f),e.background=null,d=!0):(c.color.copy(dh),d=!0);for(var p=0;p<6;p++){var v=p%3;0===v?(r.up.set(0,a[p],0),r.lookAt(o[p],0,0)):1===v?(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 m=this._cubeSize;Sh(i,v*m,p>2?m:0,m,m),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===I||e.mapping===P;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Th()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=bh());var r=i?this._cubemapMaterial:this._equirectMaterial,a=new hr(this._lodPlanes[0],r);r.uniforms.envMap.value=e;var o=this._cubeSize;Sh(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,hh)}},{key:"_applyPMREM",value:function(e){var t=this._renderer,n=t.autoClear;t.autoClear=!1;for(var i=this._lodPlanes.length,r=1;r<i;r++){var a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=_h[(i-r-1)%_h.length];this._blur(e,r-1,r,a,o)}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 hr(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):ch;p>ch&&console.warn("sigmaRadians, ".concat(r,", is too large and will clip, as it requested ").concat(p," samples when the maximum is set to ").concat(ch));for(var v=[],m=0,g=0;g<ch;++g){var y=g/f,_=Math.exp(-y*y/2);v.push(_),0===g?m+=_:g<p&&(m+=2*_)}for(var x=0;x<v.length;x++)v[x]=v[x]/m;c.envMap.value=e.texture,c.samples.value=p,c.weights.value=v,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];Sh(t,3*S*(i>M-4?i-M+4:0),4*(this._cubeSize-S),3*S,2*S),s.setRenderTarget(t),s.render(u,hh)}}])}();function Mh(e,t,n){var i=new Zt(e,t,n);return i.texture.mapping=U,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Sh(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function bh(){return new _r({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 Th(){return new _r({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 Eh(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===L||a===N,s=a===I||a===P;if(o||s){var l=t.get(r),u=void 0!==l?l.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==u)return null===n&&(n=new xh(e)),(l=o?n.fromEquirectangular(r,l):n.fromCubemap(r,l)).texture.pmremVersion=r.pmremVersion,t.set(r,l),l.texture;if(void 0!==l)return l.texture;var c=r.image;return o&&c&&c.height>0||s&&c&&function(e){for(var t=0,n=6,i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(c)?(null===n&&(n=new xh(e)),(l=o?n.fromEquirectangular(r):n.fromCubemap(r)).texture.pmremVersion=r.pmremVersion,t.set(r,l),r.addEventListener("dispose",i),l.texture):null}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function wh(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(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){var t=n(e);return null===t&&Pt("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ah(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]);s.removeEventListener("dispose",o),delete r[s.id];var u=a.get(s);u&&(t.remove(u),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,v=f.length/3-1;p<v;p+=3){var m=p+0,g=p+1,y=p+2;n.push(m,g,g,y,y,m)}}var _=new(wt(n)?Gi:Hi)(n,1);_.version=o;var x=a.get(e);x&&t.remove(x),a.set(e,_)}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)},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 Rh(e,t,n){var i,r,a;function o(t,o,s){0!==s&&(e.drawElementsInstanced(i,o,r,t*a,s),n.update(o,i,s))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,o){e.drawElements(i,o,r,t*a),n.update(o,i,1)},this.renderInstances=o,this.renderMultiDraw=function(e,a,o){if(0!==o){t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,o);for(var s=0,l=0;l<o;l++)s+=a[l];n.update(s,i,1)}},this.renderMultiDrawInstances=function(e,s,l,u){if(0!==l){var c=t.get("WEBGL_multi_draw");if(null===c)for(var h=0;h<e.length;h++)o(e[h]/a,s[h],u[h]);else{c.multiDrawElementsInstancedWEBGL(i,s,0,r,e,0,u,0,l);for(var d=0,f=0;f<l;f++)d+=s[f]*u[f];n.update(d,i,1)}}}}function Ch(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 kh(e,t,n){var i=new WeakMap,r=new qt;return{update:function(a,o,s){var l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,c=void 0!==u?u.length:0,h=i.get(o);if(void 0===h||h.count!==c){var d=function(){b.dispose(),i.delete(o),o.removeEventListener("dispose",d)};void 0!==h&&h.texture.dispose();var f=void 0!==o.morphAttributes.position,p=void 0!==o.morphAttributes.normal,v=void 0!==o.morphAttributes.color,m=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],y=o.morphAttributes.color||[],_=0;!0===f&&(_=1),!0===p&&(_=2),!0===v&&(_=3);var x=o.attributes.position.count*_,M=1;x>t.maxTextureSize&&(M=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);var S=new Float32Array(x*M*4*c),b=new Kt(S,x,M,c);b.type=J,b.needsUpdate=!0;for(var T=4*_,E=0;E<c;E++)for(var w=m[E],A=g[E],R=y[E],C=x*M*4*E,k=0;k<w.count;k++){var I=k*T;!0===f&&(r.fromBufferAttribute(w,k),S[C+I+0]=r.x,S[C+I+1]=r.y,S[C+I+2]=r.z,S[C+I+3]=0),!0===p&&(r.fromBufferAttribute(A,k),S[C+I+4]=r.x,S[C+I+5]=r.y,S[C+I+6]=r.z,S[C+I+7]=0),!0===v&&(r.fromBufferAttribute(R,k),S[C+I+8]=r.x,S[C+I+9]=r.y,S[C+I+10]=r.z,S[C+I+11]=4===R.itemSize?r.w:1)}h={count:c,texture:b,size:new bt(x,M)},i.set(o,h),o.addEventListener("dispose",d)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)s.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{for(var P=0,L=0;L<l.length;L++)P+=l[L];var N=o.morphTargetsRelative?1:1-P;s.getUniforms().setValue(e,"morphTargetBaseInfluence",N),s.getUniforms().setValue(e,"morphTargetInfluences",l)}s.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),s.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}}}function Ih(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 Ph=new Xt,Lh=new bo(1,1),Nh=new Kt,Uh=new Qt,Dh=new Ar,Oh=[],Fh=[],Bh=new Float32Array(16),zh=new Float32Array(9),Hh=new Float32Array(4);function Vh(e,t,n){var i=e[0];if(i<=0||i>0)return e;var r=t*n,a=Oh[r];if(void 0===a&&(a=new Float32Array(r),Oh[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 Gh(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 Wh(e,t){for(var n=0,i=t.length;n<i;n++)e[n]=t[n]}function jh(e,t){var n=Fh[t];void 0===n&&(n=new Int32Array(t),Fh[t]=n);for(var i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Xh(e,t){var n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function qh(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(Gh(n,t))return;e.uniform2fv(this.addr,t),Wh(n,t)}}function Yh(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(Gh(n,t))return;e.uniform3fv(this.addr,t),Wh(n,t)}}function Zh(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(Gh(n,t))return;e.uniform4fv(this.addr,t),Wh(n,t)}}function Kh(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Gh(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Wh(n,t)}else{if(Gh(n,i))return;Hh.set(i),e.uniformMatrix2fv(this.addr,!1,Hh),Wh(n,i)}}function Jh(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Gh(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Wh(n,t)}else{if(Gh(n,i))return;zh.set(i),e.uniformMatrix3fv(this.addr,!1,zh),Wh(n,i)}}function Qh(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Gh(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Wh(n,t)}else{if(Gh(n,i))return;Bh.set(i),e.uniformMatrix4fv(this.addr,!1,Bh),Wh(n,i)}}function $h(e,t){var n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function ed(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(Gh(n,t))return;e.uniform2iv(this.addr,t),Wh(n,t)}}function td(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(Gh(n,t))return;e.uniform3iv(this.addr,t),Wh(n,t)}}function nd(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(Gh(n,t))return;e.uniform4iv(this.addr,t),Wh(n,t)}}function id(e,t){var n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function rd(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(Gh(n,t))return;e.uniform2uiv(this.addr,t),Wh(n,t)}}function ad(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(Gh(n,t))return;e.uniform3uiv(this.addr,t),Wh(n,t)}}function od(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(Gh(n,t))return;e.uniform4uiv(this.addr,t),Wh(n,t)}}function sd(e,t,n){var i,r=this.cache,a=n.allocateTextureUnit();r[0]!==a&&(e.uniform1i(this.addr,a),r[0]=a),this.type===e.SAMPLER_2D_SHADOW?(Lh.compareFunction=515,i=Lh):i=Ph,n.setTexture2D(t||i,a)}function ld(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Uh,r)}function ud(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||Dh,r)}function cd(e,t,n){var i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||Nh,r)}function hd(e,t){e.uniform1fv(this.addr,t)}function dd(e,t){var n=Vh(t,this.size,2);e.uniform2fv(this.addr,n)}function fd(e,t){var n=Vh(t,this.size,3);e.uniform3fv(this.addr,n)}function pd(e,t){var n=Vh(t,this.size,4);e.uniform4fv(this.addr,n)}function vd(e,t){var n=Vh(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function md(e,t){var n=Vh(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function gd(e,t){var n=Vh(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function yd(e,t){e.uniform1iv(this.addr,t)}function _d(e,t){e.uniform2iv(this.addr,t)}function xd(e,t){e.uniform3iv(this.addr,t)}function Md(e,t){e.uniform4iv(this.addr,t)}function Sd(e,t){e.uniform1uiv(this.addr,t)}function bd(e,t){e.uniform2uiv(this.addr,t)}function Td(e,t){e.uniform3uiv(this.addr,t)}function Ed(e,t){e.uniform4uiv(this.addr,t)}function wd(e,t,n){var i=this.cache,r=t.length,a=jh(n,r);Gh(i,a)||(e.uniform1iv(this.addr,a),Wh(i,a));for(var o=0;o!==r;++o)n.setTexture2D(t[o]||Ph,a[o])}function Ad(e,t,n){var i=this.cache,r=t.length,a=jh(n,r);Gh(i,a)||(e.uniform1iv(this.addr,a),Wh(i,a));for(var o=0;o!==r;++o)n.setTexture3D(t[o]||Uh,a[o])}function Rd(e,t,n){var i=this.cache,r=t.length,a=jh(n,r);Gh(i,a)||(e.uniform1iv(this.addr,a),Wh(i,a));for(var o=0;o!==r;++o)n.setTextureCube(t[o]||Dh,a[o])}function Cd(e,t,n){var i=this.cache,r=t.length,a=jh(n,r);Gh(i,a)||(e.uniform1iv(this.addr,a),Wh(i,a));for(var o=0;o!==r;++o)n.setTexture2DArray(t[o]||Nh,a[o])}var kd=o((function e(t,n,i){r(this,e),this.id=t,this.addr=i,this.cache=[],this.type=n.type,this.setValue=function(e){switch(e){case 5126:return Xh;case 35664:return qh;case 35665:return Yh;case 35666:return Zh;case 35674:return Kh;case 35675:return Jh;case 35676:return Qh;case 5124:case 35670:return $h;case 35667:case 35671:return ed;case 35668:case 35672:return td;case 35669:case 35673:return nd;case 5125:return id;case 36294:return rd;case 36295:return ad;case 36296:return od;case 35678:case 36198:case 36298:case 36306:case 35682:return sd;case 35679:case 36299:case 36307:return ld;case 35680:case 36300:case 36308:case 36293:return ud;case 36289:case 36303:case 36311:case 36292:return cd}}(n.type)})),Id=o((function e(t,n,i){r(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 hd;case 35664:return dd;case 35665:return fd;case 35666:return pd;case 35674:return vd;case 35675:return md;case 35676:return gd;case 5124:case 35670:return yd;case 35667:case 35671:return _d;case 35668:case 35672:return xd;case 35669:case 35673:return Md;case 5125:return Sd;case 36294:return bd;case 36295:return Td;case 36296:return Ed;case 35678:case 36198:case 36298:case 36306:case 35682:return wd;case 35679:case 36299:case 36307:return Ad;case 35680:case 36300:case 36308:case 36293:return Rd;case 36289:case 36303:case 36311:case 36292:return Cd}}(n.type)})),Pd=function(){return o((function e(t){r(this,e),this.id=t,this.seq=[],this.map={}}),[{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)}}}])}(),Ld=/(\w+)(\])?(\[|\.)?/g;function Nd(e,t){e.seq.push(t),e.map[t.id]=t}function Ud(e,t,n){var i=e.name,r=i.length;for(Ld.lastIndex=0;;){var a=Ld.exec(i),o=Ld.lastIndex,s=a[1],l="]"===a[2],u=a[3];if(l&&(s|=0),void 0===u||"["===u&&o+2===r){Nd(n,void 0===u?new kd(s,e,t):new Id(s,e,t));break}var c=n.map[s];void 0===c&&Nd(n,c=new Pd(s)),n=c}}var Dd=function(){return o((function e(t,n){r(this,e),this.seq=[],this.map={};for(var i=t.getProgramParameter(n,t.ACTIVE_UNIFORMS),a=0;a<i;++a){var o=t.getActiveUniform(n,a);Ud(o,t.getUniformLocation(n,o.name),this)}}),[{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}}])}();function Od(e,t,n){var i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var Fd=0;var Bd=new Tt;function zd(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 Hd(e,t){var n=function(e){Ft._getMatrix(Bd,Ft.workingColorSpace,e);var t="mat3( ".concat(Bd.elements.map((function(e){return e.toFixed(4)}))," )");switch(Ft.getTransfer(e)){case rt:return[t,"LinearTransferOETF"];case at:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return["vec4 ".concat(e,"( vec4 value ) {"),"\treturn ".concat(n[1],"( vec4( value.rgb * ").concat(n[0],", value.a ) );"),"}"].join("\n")}function Vd(e,t){var n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Gd=new tn;function Wd(){Ft.getLuminanceCoefficients(Gd);var e=Gd.x.toFixed(4),t=Gd.y.toFixed(4),n=Gd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {","\tconst vec3 weights = vec3( ".concat(e,", ").concat(t,", ").concat(n," );"),"\treturn dot( weights, rgb );","}"].join("\n")}function jd(e){return""!==e}function Xd(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 qd(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var Yd=/^[ \t]*#include +<([\w\d./]+)>/gm;function Zd(e){return e.replace(Yd,Jd)}var Kd=new Map;function Jd(e,t){var n=Jc[t];if(void 0===n){var i=Kd.get(t);if(void 0===i)throw new Error("Can not resolve #include <"+t+">");n=Jc[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i)}return Zd(n)}var Qd=/#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 $d(e){return e.replace(Qd,ef)}function ef(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 tf(e){var t="precision ".concat(e.precision," float;\n\tprecision ").concat(e.precision," int;\n\tprecision ").concat(e.precision," sampler2D;\n\tprecision ").concat(e.precision," samplerCube;\n\tprecision ").concat(e.precision," sampler3D;\n\tprecision ").concat(e.precision," sampler2DArray;\n\tprecision ").concat(e.precision," sampler2DShadow;\n\tprecision ").concat(e.precision," samplerCubeShadow;\n\tprecision ").concat(e.precision," sampler2DArrayShadow;\n\tprecision ").concat(e.precision," isampler2D;\n\tprecision ").concat(e.precision," isampler3D;\n\tprecision ").concat(e.precision," isamplerCube;\n\tprecision ").concat(e.precision," isampler2DArray;\n\tprecision ").concat(e.precision," usampler2D;\n\tprecision ").concat(e.precision," usampler3D;\n\tprecision ").concat(e.precision," usamplerCube;\n\tprecision ").concat(e.precision," usampler2DArray;\n\t");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 nf(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 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(n),h=function(e){var t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case I:case P:t="ENVMAP_TYPE_CUBE";break;case U:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),d=function(e){var t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===P&&(t="ENVMAP_MODE_REFRACTION");return t}(n),f=function(e){var t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2: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),v=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(jd).join("\n")}(n),m=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),g=o.createProgram(),y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((r=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(jd).join("\n")).length>0&&(r+="\n"),(a=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(jd).join("\n")).length>0&&(a+="\n")):(r=[tf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+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?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(jd).join("\n"),a=[tf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+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.dispersion?"#define USE_DISPERSION":"",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||n.batchingColor?"#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.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Jc.tonemapping_pars_fragment:"",0!==n.toneMapping?Vd("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Jc.colorspace_pars_fragment,Hd("linearToOutputTexel",n.outputColorSpace),Wd(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(jd).join("\n")),l=qd(l=Xd(l=Zd(l),n),n),u=qd(u=Xd(u=Zd(u),n),n),l=$d(l),u=$d(u),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",r=[v,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,a=["#define varying in",n.glslVersion===lt?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===lt?"":"#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=y+r+l,S=y+a+u,b=Od(o,o.VERTEX_SHADER,M),T=Od(o,o.FRAGMENT_SHADER,S);function E(t){if(e.debug.checkShaderErrors){var n=o.getProgramInfoLog(g).trim(),i=o.getShaderInfoLog(b).trim(),s=o.getShaderInfoLog(T).trim(),l=!0,u=!0;if(!1===o.getProgramParameter(g,o.LINK_STATUS))if(l=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(o,g,b,T);else{var c=zd(o,b,"vertex"),h=zd(o,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(g,o.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\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(b),o.deleteShader(T),_=new Dd(o,g),x=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,g)}o.attachShader(g,b),o.attachShader(g,T),void 0!==n.index0AttributeName?o.bindAttribLocation(g,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(g,0,"position"),o.linkProgram(g),this.getUniforms=function(){return void 0===_&&E(this),_},this.getAttributes=function(){return void 0===x&&E(this),x};var w=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===w&&(w=o.getProgramParameter(g,37297)),w},this.destroy=function(){i.releaseStatesOfProgram(this),o.deleteProgram(g),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Fd++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=T,this}var rf=0,af=function(){return o((function e(){r(this,e),this.shaderCache=new Map,this.materialCache=new Map}),[{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=s(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(e){n.e(e)}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 of(e),t.set(e,n)),n}}])}(),of=o((function e(t){r(this,e),this.id=rf++,this.code=t,this.usedTimes=0}));function sf(e,t,n,i,r,a,o){var s=new Gn,l=new af,u=new Set,c=[],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 v(e){return u.add(e),0===e?"uv":"uv".concat(e)}return{getParameters:function(a,s,c,m,g){var y=m.fog,_=g.geometry,x=a.isMeshStandardMaterial?m.environment:null,M=(a.isMeshStandardMaterial?n:t).get(a.envMap||x),S=M&&M.mapping===U?M.image.height:null,b=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,E,w,A,R=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,C=void 0!==R?R.length:0,k=0;if(void 0!==_.morphAttributes.position&&(k=1),void 0!==_.morphAttributes.normal&&(k=2),void 0!==_.morphAttributes.color&&(k=3),b){var I=$c[b];T=I.vertexShader,E=I.fragmentShader}else T=a.vertexShader,E=a.fragmentShader,l.update(a),w=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);var P=e.getRenderTarget(),L=e.state.buffers.depth.getReversed(),N=!0===g.isInstancedMesh,D=!0===g.isBatchedMesh,O=!!a.map,F=!!a.matcap,B=!!M,z=!!a.aoMap,H=!!a.lightMap,V=!!a.bumpMap,G=!!a.normalMap,W=!!a.displacementMap,j=!!a.emissiveMap,X=!!a.metalnessMap,q=!!a.roughnessMap,Y=a.anisotropy>0,Z=a.clearcoat>0,K=a.dispersion>0,J=a.iridescence>0,Q=a.sheen>0,$=a.transmission>0,ee=Y&&!!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,ve=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions,ye=0;a.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(ye=e.toneMapping));var _e={shaderID:b,shaderType:a.type,shaderName:a.name,vertexShader:T,fragmentShader:E,defines:a.defines,customVertexShaderID:w,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:N,instancingColor:N&&null!==g.instanceColor,instancingMorph:N&&null!==g.morphTexture,supportsVertexTextures:d,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:it,alphaToCoverage:!!a.alphaToCoverage,map:O,matcap:F,envMap:B,envMapMode:B&&M.mapping,envMapCubeUVHeight:S,aoMap:z,lightMap:H,bumpMap:V,normalMap:G,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:G&&1===a.normalMapType,normalMapTangentSpace:G&&0===a.normalMapType,metalnessMap:X,roughnessMap:q,anisotropy:Y,anisotropyMap:ee,clearcoat:Z,clearcoatMap:te,clearcoatNormalMap:ne,clearcoatRoughnessMap:ie,dispersion:K,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&&!1===a.alphaToCoverage,alphaMap:pe,alphaTest:ve,alphaHash:me,combine:a.combine,mapUv:O&&v(a.map.channel),aoMapUv:z&&v(a.aoMap.channel),lightMapUv:H&&v(a.lightMap.channel),bumpMapUv:V&&v(a.bumpMap.channel),normalMapUv:G&&v(a.normalMap.channel),displacementMapUv:W&&v(a.displacementMap.channel),emissiveMapUv:j&&v(a.emissiveMap.channel),metalnessMapUv:X&&v(a.metalnessMap.channel),roughnessMapUv:q&&v(a.roughnessMap.channel),anisotropyMapUv:ee&&v(a.anisotropyMap.channel),clearcoatMapUv:te&&v(a.clearcoatMap.channel),clearcoatNormalMapUv:ne&&v(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&v(a.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&v(a.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&v(a.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&v(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&v(a.sheenRoughnessMap.channel),specularMapUv:le&&v(a.specularMap.channel),specularColorMapUv:ue&&v(a.specularColorMap.channel),specularIntensityMapUv:ce&&v(a.specularIntensityMap.channel),transmissionMapUv:he&&v(a.transmissionMap.channel),thicknessMapUv:de&&v(a.thicknessMap.channel),alphaMapUv:pe&&v(a.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(G||Y),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!_.attributes.uv&&(O||pe),fog:!!y,useFog:!0===a.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:h,reverseDepthBuffer:L,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:C,morphTextureStride:k,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&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ye,decodeVideoTexture:O&&!0===a.map.isVideoTexture&&Ft.getTransfer(a.map.colorSpace)===at,decodeVideoTextureEmissive:j&&!0===a.emissiveMap.isVideoTexture&&Ft.getTransfer(a.emissiveMap.colorSpace)===at,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||D)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return _e.vertexUv1s=u.has(1),_e.vertexUv2s=u.has(2),_e.vertexUv3s=u.has(3),u.clear(),_e},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.supportsVertexTextures&&s.enable(0);t.instancing&&s.enable(1);t.instancingColor&&s.enable(2);t.instancingMorph&&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);t.dispersion&&s.enable(20);t.batchingColor&&s.enable(21);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.reverseDepthBuffer&&s.enable(4);t.skinning&&s.enable(5);t.morphTargets&&s.enable(6);t.morphNormals&&s.enable(7);t.morphColors&&s.enable(8);t.premultipliedAlpha&&s.enable(9);t.shadowMapEnabled&&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);t.decodeVideoTextureEmissive&&s.enable(20);t.alphaToCoverage&&s.enable(21);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=$c[n];t=yr.clone(i.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){for(var i,r=0,o=c.length;r<o;r++){var s=c[r];if(s.cacheKey===n){++(i=s).usedTimes;break}}return void 0===i&&(i=new nf(e,n,t,a),c.push(i)),i},releaseProgram:function(e){if(0==--e.usedTimes){var t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function lf(){var e=new WeakMap;return{has:function(t){return e.has(t)},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 uf(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 cf(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 hf(){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||uf),i.length>1&&i.sort(t||cf),r.length>1&&r.sort(t||cf)}}}function df(){var e=new WeakMap;return{get:function(t,n){var i,r=e.get(t);return void 0===r?(i=new hf,e.set(t,[i])):n>=r.length?(i=new hf,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function ff(){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 tn,color:new Ti};break;case"SpotLight":n={position:new tn,direction:new tn,color:new Ti,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new tn,color:new Ti,distance:0,decay:0};break;case"HemisphereLight":n={direction:new tn,skyColor:new Ti,groundColor:new Ti};break;case"RectAreaLight":n={color:new Ti,position:new tn,halfWidth:new tn,halfHeight:new tn}}return e[t.id]=n,n}}}var pf=0;function vf(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function mf(e){for(var t,n=new ff,i=(t={},{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.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 tn);var o=new tn,s=new Pn,l=new Pn;return{setup:function(t){for(var a=0,o=0,s=0,l=0;l<9;l++)r.probe[l].set(0,0,0);var u=0,c=0,h=0,d=0,f=0,p=0,v=0,m=0,g=0,y=0,_=0;t.sort(vf);for(var x=0,M=t.length;x<M;x++){var S=t[x],b=S.color,T=S.intensity,E=S.distance,w=S.shadow&&S.shadow.map?S.shadow.map.texture:null;if(S.isAmbientLight)a+=b.r*T,o+=b.g*T,s+=b.b*T;else if(S.isLightProbe){for(var A=0;A<9;A++)r.probe[A].addScaledVector(S.sh.coefficients[A],T);_++}else if(S.isDirectionalLight){var R=n.get(S);if(R.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){var C=S.shadow,k=i.get(S);k.shadowIntensity=C.intensity,k.shadowBias=C.bias,k.shadowNormalBias=C.normalBias,k.shadowRadius=C.radius,k.shadowMapSize=C.mapSize,r.directionalShadow[u]=k,r.directionalShadowMap[u]=w,r.directionalShadowMatrix[u]=S.shadow.matrix,p++}r.directional[u]=R,u++}else if(S.isSpotLight){var I=n.get(S);I.position.setFromMatrixPosition(S.matrixWorld),I.color.copy(b).multiplyScalar(T),I.distance=E,I.coneCos=Math.cos(S.angle),I.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),I.decay=S.decay,r.spot[h]=I;var P=S.shadow;if(S.map&&(r.spotLightMap[g]=S.map,g++,P.updateMatrices(S),S.castShadow&&y++),r.spotLightMatrix[h]=P.matrix,S.castShadow){var L=i.get(S);L.shadowIntensity=P.intensity,L.shadowBias=P.bias,L.shadowNormalBias=P.normalBias,L.shadowRadius=P.radius,L.shadowMapSize=P.mapSize,r.spotShadow[h]=L,r.spotShadowMap[h]=w,m++}h++}else if(S.isRectAreaLight){var N=n.get(S);N.color.copy(b).multiplyScalar(T),N.halfWidth.set(.5*S.width,0,0),N.halfHeight.set(0,.5*S.height,0),r.rectArea[d]=N,d++}else if(S.isPointLight){var U=n.get(S);if(U.color.copy(S.color).multiplyScalar(S.intensity),U.distance=S.distance,U.decay=S.decay,S.castShadow){var D=S.shadow,O=i.get(S);O.shadowIntensity=D.intensity,O.shadowBias=D.bias,O.shadowNormalBias=D.normalBias,O.shadowRadius=D.radius,O.shadowMapSize=D.mapSize,O.shadowCameraNear=D.camera.near,O.shadowCameraFar=D.camera.far,r.pointShadow[c]=O,r.pointShadowMap[c]=w,r.pointShadowMatrix[c]=S.shadow.matrix,v++}r.point[c]=U,c++}else if(S.isHemisphereLight){var F=n.get(S);F.skyColor.copy(S.color).multiplyScalar(T),F.groundColor.copy(S.groundColor).multiplyScalar(T),r.hemi[f]=F,f++}}d>0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Qc.LTC_FLOAT_1,r.rectAreaLTC2=Qc.LTC_FLOAT_2):(r.rectAreaLTC1=Qc.LTC_HALF_1,r.rectAreaLTC2=Qc.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;var B=r.hash;B.directionalLength===u&&B.pointLength===c&&B.spotLength===h&&B.rectAreaLength===d&&B.hemiLength===f&&B.numDirectionalShadows===p&&B.numPointShadows===v&&B.numSpotShadows===m&&B.numSpotMaps===g&&B.numLightProbes===_||(r.directional.length=u,r.spot.length=h,r.rectArea.length=d,r.point.length=c,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=v,r.pointShadowMap.length=v,r.spotShadow.length=m,r.spotShadowMap.length=m,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=v,r.spotLightMatrix.length=m+g-y,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=y,r.numLightProbes=_,B.directionalLength=u,B.pointLength=c,B.spotLength=h,B.rectAreaLength=d,B.hemiLength=f,B.numDirectionalShadows=p,B.numPointShadows=v,B.numSpotShadows=m,B.numSpotMaps=g,B.numLightProbes=_,r.version=pf++)},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 v=r.directional[n];v.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),v.direction.sub(o),v.direction.transformDirection(h),n++}else if(p.isSpotLight){var m=r.spot[a];m.position.setFromMatrixPosition(p.matrixWorld),m.position.applyMatrix4(h),m.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),m.direction.sub(o),m.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 y=r.point[i];y.position.setFromMatrixPosition(p.matrixWorld),y.position.applyMatrix4(h),i++}else if(p.isHemisphereLight){var _=r.hemi[c];_.direction.setFromMatrixPosition(p.matrixWorld),_.direction.transformDirection(h),c++}}},state:r}}function gf(e){var t=new mf(e),n=[],i=[];var r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function yf(e){var t=new WeakMap;return{get:function(n){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=t.get(n);return void 0===a?(i=new gf(e),t.set(n,[i])):r>=a.length?(i=new gf(e),a.push(i)):i=a[r],i},dispose:function(){t=new WeakMap}}}function _f(e,t,n){var i=new Ca,r=new bt,a=new bt,o=new qt,s=new nl({depthPacking:3201}),u=new il,c={},h=n.maxTextureSize,d=l(l(l({},0,1),1,0),2,2),f=new _r({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},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 v=new $i;v.setAttribute("position",new Di(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var m=new hr(v,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;var y=this.type;function _(n,i){var a=t.update(m);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 Zt(r.x,r.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,a,f,m,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,a,p,m,null)}function x(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:s,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 l=a.uuid,h=n.uuid,f=c[l];void 0===f&&(f={},c[l]=f);var p=f[h];void 0===p&&(p=a.clone(),f[h]=p,n.addEventListener("dispose",S)),a=p}(a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?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 M(n,r,a,o,s){if(!1!==n.visible){if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.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 v=x(n,p,o,s);n.onBeforeShadow(e,n,r,a,l,v,f),e.renderBufferDirect(a,null,l,v,n,f),n.onAfterShadow(e,n,r,a,l,v,f)}}else if(u.visible){var m=x(n,u,o,s);n.onBeforeShadow(e,n,r,a,l,m,null),e.renderBufferDirect(a,null,l,m,n,null),n.onAfterShadow(e,n,r,a,l,m,null)}}for(var g=n.children,y=0,_=g.length;y<_;y++)M(g[y],r,a,o,s)}}function S(e){var t=e.target;for(var n in t.removeEventListener("dispose",S),c){var i=c[n],r=e.target.uuid;if(r in i)i[r].dispose(),delete i[r]}}this.render=function(t,n,s){if(!1!==g.enabled&&(!1!==g.autoUpdate||!1!==g.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=3!==y&&3===this.type,p=3===y&&3!==this.type,v=0,m=t.length;v<m;v++){var x=t[v],S=x.shadow;if(void 0!==S){if(!1!==S.autoUpdate||!1!==S.needsUpdate){r.copy(S.mapSize);var b=S.getFrameExtents();if(r.multiply(b),a.copy(S.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(a.x=Math.floor(h/b.x),r.x=a.x*b.x,S.mapSize.x=a.x),r.y>h&&(a.y=Math.floor(h/b.y),r.y=a.y*b.y,S.mapSize.y=a.y)),null===S.map||!0===f||!0===p){var T=3!==this.type?{minFilter:B,magFilter:B}:{};null!==S.map&&S.map.dispose(),S.map=new Zt(r.x,r.y,T),S.map.texture.name=x.name+".shadowMap",S.camera.updateProjectionMatrix()}e.setRenderTarget(S.map),e.clear();for(var E=S.getViewportCount(),w=0;w<E;w++){var A=S.getViewport(w);o.set(a.x*A.x,a.y*A.y,a.x*A.z,a.y*A.w),d.viewport(o),S.updateMatrices(x,w),i=S.getFrustum(),M(n,s,S.camera,x,this.type)}!0!==S.isPointLightShadow&&3===this.type&&_(S,s),S.needsUpdate=!1}}else console.warn("THREE.WebGLShadowMap:",x,"has no shadow.")}y=this.type,g.needsUpdate=!1,e.setRenderTarget(l,u,c)}}}var xf=l(l(l(l(l(l(l(l({},0,1),2,6),4,7),3,5),1,0),6,2),7,4),5,3);function Mf(e,t){var n;var i=new function(){var t=!1,n=new qt,i=null,r=new qt(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)}}},r=new function(){var n=!1,i=!1,r=null,a=null,o=null;return{setReversed:function(e){if(i!==e){var n=t.get("EXT_clip_control");i?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT);var r=o;o=null,this.setClear(r)}i=e},getReversed:function(){return i},setTest:function(t){t?j(e.DEPTH_TEST):X(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=xf[t]),a!==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)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(i&&(t=1-t),e.clearDepth(t),o=t)},reset:function(){n=!1,r=null,a=null,o=null,i=!1}}},a=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?j(e.STENCIL_TEST):X(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}}},o=new WeakMap,s=new WeakMap,u={},c={},h=new WeakMap,d=[],f=null,p=!1,v=null,m=null,g=null,y=null,_=null,x=null,M=null,S=new Ti(0,0,0),b=0,T=!1,R=null,C=null,k=null,I=null,P=null,L=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,U=0,D=e.getParameter(e.VERSION);-1!==D.indexOf("WebGL")?(U=parseFloat(/^WebGL (\d)/.exec(D)[1]),N=U>=1):-1!==D.indexOf("OpenGL ES")&&(U=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=U>=2);var O=null,F={},B=e.getParameter(e.SCISSOR_BOX),z=e.getParameter(e.VIEWPORT),H=(new qt).fromArray(B),V=(new qt).fromArray(z);function G(t,n,i,r){var a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var s=0;s<i;s++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}var W={};function j(t){!0!==u[t]&&(e.enable(t),u[t]=!0)}function X(t){!1!==u[t]&&(e.disable(t),u[t]=!1)}W[e.TEXTURE_2D]=G(e.TEXTURE_2D,e.TEXTURE_2D,1),W[e.TEXTURE_CUBE_MAP]=G(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),W[e.TEXTURE_2D_ARRAY]=G(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),W[e.TEXTURE_3D]=G(e.TEXTURE_3D,e.TEXTURE_3D,1,1),i.setClear(0,0,0,1),r.setClear(1),a.setClear(0),j(e.DEPTH_TEST),r.setFunc(3),K(!1),J(1),j(e.CULL_FACE),Z(0);var q=l(l(l({},E,e.FUNC_ADD),101,e.FUNC_SUBTRACT),102,e.FUNC_REVERSE_SUBTRACT);q[103]=e.MIN,q[104]=e.MAX;var Y=(l(l(l(l(l(l(l(l(l(l(n={},200,e.ZERO),201,e.ONE),202,e.SRC_COLOR),w,e.SRC_ALPHA),210,e.SRC_ALPHA_SATURATE),208,e.DST_COLOR),206,e.DST_ALPHA),203,e.ONE_MINUS_SRC_COLOR),A,e.ONE_MINUS_SRC_ALPHA),209,e.ONE_MINUS_DST_COLOR),l(l(l(l(l(n,207,e.ONE_MINUS_DST_ALPHA),211,e.CONSTANT_COLOR),212,e.ONE_MINUS_CONSTANT_COLOR),213,e.CONSTANT_ALPHA),214,e.ONE_MINUS_CONSTANT_ALPHA));function Z(t,n,i,r,a,o,s,l,u,c){if(0!==t){if(!1===p&&(j(e.BLEND),p=!0),5===t)a=a||n,o=o||i,s=s||r,n===m&&a===_||(e.blendEquationSeparate(q[n],q[a]),m=n,_=a),i===g&&r===y&&o===x&&s===M||(e.blendFuncSeparate(Y[i],Y[r],Y[o],Y[s]),g=i,y=r,x=o,M=s),!1!==l.equals(S)&&u===b||(e.blendColor(l.r,l.g,l.b,u),S.copy(l),b=u),v=t,T=!1;else if(t!==v||c!==T){if(m===E&&_===E||(e.blendEquation(e.FUNC_ADD),m=E,_=E),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)}g=null,y=null,x=null,M=null,S.set(0,0,0),b=0,v=t,T=c}}else!0===p&&(X(e.BLEND),p=!1)}function K(t){R!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),R=t)}function J(t){0!==t?(j(e.CULL_FACE),t!==C&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):X(e.CULL_FACE),C=t}function Q(t,n,i){t?(j(e.POLYGON_OFFSET_FILL),I===n&&P===i||(e.polygonOffset(n,i),I=n,P=i)):X(e.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:r,stencil:a},enable:j,disable:X,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){var i=d,r=!1;if(t){void 0===(i=h.get(n))&&(i=[],h.set(n,i));var a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(var o=0,s=a.length;o<s;o++)i[o]=e.COLOR_ATTACHMENT0+o;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return f!==t&&(e.useProgram(t),f=t,!0)},setBlending:Z,setMaterial:function(t,n){2===t.side?X(e.CULL_FACE):j(e.CULL_FACE);var o=1===t.side;n&&(o=!o),K(o),1===t.blending&&!1===t.transparent?Z(0):Z(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),r.setFunc(t.depthFunc),r.setTest(t.depthTest),r.setMask(t.depthWrite),i.setMask(t.colorWrite);var s=t.stencilWrite;a.setTest(s),s&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),Q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?j(e.SAMPLE_ALPHA_TO_COVERAGE):X(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:K,setCullFace:J,setLineWidth:function(t){t!==k&&(N&&e.lineWidth(t),k=t)},setPolygonOffset:Q,setScissorTest:function(t){t?j(e.SCISSOR_TEST):X(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+L-1),O!==t&&(e.activeTexture(t),O=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===O?e.TEXTURE0+L-1:O);var r=F[i];void 0===r&&(r={type:void 0,texture:void 0},F[i]=r),r.type===t&&r.texture===n||(O!==i&&(e.activeTexture(i),O=i),e.bindTexture(t,n||W[t]),r.type=t,r.texture=n)},unbindTexture:function(){var t=F[O];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(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){var i=s.get(n);void 0===i&&(i=new WeakMap,s.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=s.get(n).get(t);o.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),o.set(n,i))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===H.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),H.copy(t))},viewport:function(t){!1===V.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),V.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),r.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},O=null,F={},c={},h=new WeakMap,d=[],f=null,p=!1,v=null,m=null,g=null,y=null,_=null,x=null,M=null,S=new Ti(0,0,0),b=0,T=!1,R=null,C=null,k=null,I=null,P=null,H.set(0,0,e.canvas.width,e.canvas.height),V.set(0,0,e.canvas.width,e.canvas.height),i.reset(),r.reset(),a.reset()}}}function Sf(e,t,n,i,r,a,o){var u,c=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),d=new bt,f=new WeakMap,p=new WeakMap,v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function m(e,t){return v?new OffscreenCanvas(e,t):Ct("canvas")}function g(e,t,n){var i=1,r=ie(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){var a=Math.floor(i*r.width),o=Math.floor(i*r.height);void 0===u&&(u=m(a,o));var s=t?m(a,o):u;return s.width=a,s.height=o,s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function y(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function x(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function M(n,i,r,a){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];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.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RG8UI),r===e.UNSIGNED_SHORT&&(s=e.RG16UI),r===e.UNSIGNED_INT&&(s=e.RG32UI),r===e.BYTE&&(s=e.RG8I),r===e.SHORT&&(s=e.RG16I),r===e.INT&&(s=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RGB8UI),r===e.UNSIGNED_SHORT&&(s=e.RGB16UI),r===e.UNSIGNED_INT&&(s=e.RGB32UI),r===e.BYTE&&(s=e.RGB8I),r===e.SHORT&&(s=e.RGB16I),r===e.INT&&(s=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(s=e.RGBA16UI),r===e.UNSIGNED_INT&&(s=e.RGBA32UI),r===e.BYTE&&(s=e.RGBA8I),r===e.SHORT&&(s=e.RGBA16I),r===e.INT&&(s=e.RGBA32I)),i===e.RGB&&r===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5),i===e.RGBA){var l=o?rt:Ft.getTransfer(a);r===e.FLOAT&&(s=e.RGBA32F),r===e.HALF_FLOAT&&(s=e.RGBA16F),r===e.UNSIGNED_BYTE&&(s=l===at?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 S(t,n){var i;return t?null===n||n===K||n===te?i=e.DEPTH24_STENCIL8:n===J?i=e.DEPTH32F_STENCIL8:n===Y&&(i=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===K||n===te?i=e.DEPTH_COMPONENT24:n===J?i=e.DEPTH_COMPONENT32F:n===Y&&(i=e.DEPTH_COMPONENT16),i}function b(e,t){return!0===y(e)||e.isFramebufferTexture&&e.minFilter!==B&&e.minFilter!==V?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 T(e){var t=e.target;t.removeEventListener("dispose",T),function(e){var t=i.get(e);if(void 0===t.__webglInit)return;var n=e.source,r=p.get(n);if(r){var a=r[t.__cacheKey];a.usedTimes--,0===a.usedTimes&&w(e),0===Object.keys(r).length&&p.delete(n)}i.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function E(t){var n=t.target;n.removeEventListener("dispose",E),function(t){var n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(var r=0;r<6;r++){if(Array.isArray(n.__webglFramebuffer[r]))for(var a=0;a<n.__webglFramebuffer[r].length;a++)e.deleteFramebuffer(n.__webglFramebuffer[r][a]);else e.deleteFramebuffer(n.__webglFramebuffer[r]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[r])}else{if(Array.isArray(n.__webglFramebuffer))for(var s=0;s<n.__webglFramebuffer.length;s++)e.deleteFramebuffer(n.__webglFramebuffer[s]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(var l=0;l<n.__webglColorRenderbuffer.length;l++)n.__webglColorRenderbuffer[l]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[l]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}for(var u=t.textures,c=0,h=u.length;c<h;c++){var d=i.get(u[c]);d.__webglTexture&&(e.deleteTexture(d.__webglTexture),o.memory.textures--),i.remove(u[c])}i.remove(t)}(n)}function w(t){var n=i.get(t);e.deleteTexture(n.__webglTexture);var r=t.source;delete p.get(r)[n.__cacheKey],o.memory.textures--}var A=0;function R(t,r){var a=i.get(t);if(t.isVideoTexture&&function(e){var t=o.render.frame;f.get(e)!==t&&(f.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 N(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 C=l(l(l({},D,e.REPEAT),O,e.CLAMP_TO_EDGE),F,e.MIRRORED_REPEAT),k=l(l(l(l(l(l({},B,e.NEAREST),z,e.NEAREST_MIPMAP_NEAREST),H,e.NEAREST_MIPMAP_LINEAR),V,e.LINEAR),G,e.LINEAR_MIPMAP_NEAREST),W,e.LINEAR_MIPMAP_LINEAR),I=l(l(l(l(l(l(l(l({},512,e.NEVER),519,e.ALWAYS),513,e.LESS),515,e.LEQUAL),514,e.EQUAL),518,e.GEQUAL),516,e.GREATER),517,e.NOTEQUAL);function P(n,a){if(a.type!==J||!1!==t.has("OES_texture_float_linear")||a.magFilter!==V&&a.magFilter!==G&&a.magFilter!==H&&a.magFilter!==W&&a.minFilter!==V&&a.minFilter!==G&&a.minFilter!==H&&a.minFilter!==W||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,C[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,C[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,C[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,k[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,k[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===B)return;if(a.minFilter!==H&&a.minFilter!==W)return;if(a.type===J&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){var o=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function L(t,n){var i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));var r=n.source,a=p.get(r);void 0===a&&(a={},p.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&&w(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return i}function N(t,o,l){var u=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(u=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(u=e.TEXTURE_3D);var c=L(t,o),h=o.source;n.bindTexture(u,t.__webglTexture,e.TEXTURE0+l);var d=i.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+l);var f=Ft.getPrimaries(Ft.workingColorSpace),p=o.colorSpace===tt?null:Ft.getPrimaries(o.colorSpace),v=o.colorSpace===tt||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,v);var m=g(o.image,!1,r.maxTextureSize);m=ne(o,m);var x,T=a.convert(o.format,o.colorSpace),E=a.convert(o.type),w=M(o.internalFormat,T,E,o.colorSpace,o.isVideoTexture);P(u,o);var A=o.mipmaps,R=!0!==o.isVideoTexture,C=void 0===d.__version||!0===c,k=h.dataReady,I=b(o,m);if(o.isDepthTexture)w=S(o.format===ue,o.type),C&&(R?n.texStorage2D(e.TEXTURE_2D,1,w,m.width,m.height):n.texImage2D(e.TEXTURE_2D,0,w,m.width,m.height,0,T,E,null));else if(o.isDataTexture)if(A.length>0){R&&C&&n.texStorage2D(e.TEXTURE_2D,I,w,A[0].width,A[0].height);for(var N=0,U=A.length;N<U;N++)x=A[N],R?k&&n.texSubImage2D(e.TEXTURE_2D,N,0,0,x.width,x.height,T,E,x.data):n.texImage2D(e.TEXTURE_2D,N,w,x.width,x.height,0,T,E,x.data);o.generateMipmaps=!1}else R?(C&&n.texStorage2D(e.TEXTURE_2D,I,w,m.width,m.height),k&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,m.width,m.height,T,E,m.data)):n.texImage2D(e.TEXTURE_2D,0,w,m.width,m.height,0,T,E,m.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){R&&C&&n.texStorage3D(e.TEXTURE_2D_ARRAY,I,w,A[0].width,A[0].height,m.depth);for(var D=0,O=A.length;D<O;D++)if(x=A[D],o.format!==ae)if(null!==T)if(R){if(k)if(o.layerUpdates.size>0){var F,B=qc(x.width,x.height,o.format,o.type),z=s(o.layerUpdates);try{for(z.s();!(F=z.n()).done;){var H=F.value,V=x.data.subarray(H*B/x.data.BYTES_PER_ELEMENT,(H+1)*B/x.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,D,0,0,H,x.width,x.height,1,T,V)}}catch(e){z.e(e)}finally{z.f()}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,D,0,0,0,x.width,x.height,m.depth,T,x.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,D,w,x.width,x.height,m.depth,0,x.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?k&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,D,0,0,0,x.width,x.height,m.depth,T,E,x.data):n.texImage3D(e.TEXTURE_2D_ARRAY,D,w,x.width,x.height,m.depth,0,T,E,x.data)}else{R&&C&&n.texStorage2D(e.TEXTURE_2D,I,w,A[0].width,A[0].height);for(var G=0,W=A.length;G<W;G++)x=A[G],o.format!==ae?null!==T?R?k&&n.compressedTexSubImage2D(e.TEXTURE_2D,G,0,0,x.width,x.height,T,x.data):n.compressedTexImage2D(e.TEXTURE_2D,G,w,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?k&&n.texSubImage2D(e.TEXTURE_2D,G,0,0,x.width,x.height,T,E,x.data):n.texImage2D(e.TEXTURE_2D,G,w,x.width,x.height,0,T,E,x.data)}else if(o.isDataArrayTexture)if(R){if(C&&n.texStorage3D(e.TEXTURE_2D_ARRAY,I,w,m.width,m.height,m.depth),k)if(o.layerUpdates.size>0){var j,X=qc(m.width,m.height,o.format,o.type),q=s(o.layerUpdates);try{for(q.s();!(j=q.n()).done;){var Y=j.value,Z=m.data.subarray(Y*X/m.data.BYTES_PER_ELEMENT,(Y+1)*X/m.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,Y,m.width,m.height,1,T,E,Z)}}catch(e){q.e(e)}finally{q.f()}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,T,E,m.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,w,m.width,m.height,m.depth,0,T,E,m.data);else if(o.isData3DTexture)R?(C&&n.texStorage3D(e.TEXTURE_3D,I,w,m.width,m.height,m.depth),k&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,T,E,m.data)):n.texImage3D(e.TEXTURE_3D,0,w,m.width,m.height,m.depth,0,T,E,m.data);else if(o.isFramebufferTexture){if(C)if(R)n.texStorage2D(e.TEXTURE_2D,I,w,m.width,m.height);else for(var K=m.width,J=m.height,Q=0;Q<I;Q++)n.texImage2D(e.TEXTURE_2D,Q,w,K,J,0,T,E,null),K>>=1,J>>=1}else if(A.length>0){if(R&&C){var $=ie(A[0]);n.texStorage2D(e.TEXTURE_2D,I,w,$.width,$.height)}for(var ee=0,te=A.length;ee<te;ee++)x=A[ee],R?k&&n.texSubImage2D(e.TEXTURE_2D,ee,0,0,T,E,x):n.texImage2D(e.TEXTURE_2D,ee,w,T,E,x);o.generateMipmaps=!1}else if(R){if(C){var re=ie(m);n.texStorage2D(e.TEXTURE_2D,I,w,re.width,re.height)}k&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,T,E,m)}else n.texImage2D(e.TEXTURE_2D,0,w,T,E,m);y(o)&&_(u),d.__version=h.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function U(t,r,o,s,l,u){var h=a.convert(o.format,o.colorSpace),d=a.convert(o.type),f=M(o.internalFormat,h,d,o.colorSpace),p=i.get(r),v=i.get(o);if(v.__renderTarget=r,!p.__hasExternalTextures){var m=Math.max(1,r.width>>u),g=Math.max(1,r.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,f,m,g,r.depth,0,h,d,null):n.texImage2D(l,u,f,m,g,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),ee(r)?c.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,l,v.__webglTexture,0,$(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,l,v.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function X(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){var r=n.depthTexture,o=r&&r.isDepthTexture?r.type:null,s=S(n.stencilBuffer,o),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=$(n);ee(n)?c.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else for(var h=n.textures,d=0;d<h.length;d++){var f=h[d],p=a.convert(f.format,f.colorSpace),v=a.convert(f.type),m=M(f.internalFormat,p,v,f.colorSpace),g=$(n);i&&!1===ee(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,g,m,n.width,n.height):ee(n)?c.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,g,m,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,m,n.width,n.height)}e.bindRenderbuffer(e.RENDERBUFFER,null)}function q(t){var r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){var o=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),o){var s=function(){delete r.__boundDepthTexture,delete r.__depthDisposeCallback,o.removeEventListener("dispose",s)};o.addEventListener("dispose",s),r.__depthDisposeCallback=s}r.__boundDepthTexture=o}if(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");var a=i.get(r.depthTexture);a.__renderTarget=r,a.__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),R(r.depthTexture,0);var o=a.__webglTexture,s=$(r);if(r.depthTexture.format===le)ee(r)?c.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0);else{if(r.depthTexture.format!==ue)throw new Error("Unknown depthTexture format");ee(r)?c.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(var l=0;l<6;l++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[l]),void 0===r.__webglDepthbuffer[l])r.__webglDepthbuffer[l]=e.createRenderbuffer(),X(r.__webglDepthbuffer[l],t,!1);else{var u=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=r.__webglDepthbuffer[l];e.bindRenderbuffer(e.RENDERBUFFER,h),e.framebufferRenderbuffer(e.FRAMEBUFFER,u,e.RENDERBUFFER,h)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),X(r.__webglDepthbuffer,t,!1);else{var d=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,f=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,f),e.framebufferRenderbuffer(e.FRAMEBUFFER,d,e.RENDERBUFFER,f)}n.bindFramebuffer(e.FRAMEBUFFER,null)}var Z=[],Q=[];function $(e){return Math.min(r.maxSamples,e.samples)}function ee(e){var n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ne(e,t){var n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==it&&n!==tt&&(Ft.getTransfer(n)===at?i===ae&&r===j||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function ie(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(d.width=e.naturalWidth||e.width,d.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(d.width=e.displayWidth,d.height=e.displayHeight):(d.width=e.width,d.height=e.height),d}this.allocateTextureUnit=function(){var e=A;return e>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),A+=1,e},this.resetTextureUnits=function(){A=0},this.setTexture2D=R,this.setTexture2DArray=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?N(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?N(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=L(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 h=Ft.getPrimaries(Ft.workingColorSpace),d=o.colorSpace===tt?null:Ft.getPrimaries(o.colorSpace),f=o.colorSpace===tt||h===d?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,f);for(var p=o.isCompressedTexture||o.image[0].isCompressedTexture,v=o.image[0]&&o.image[0].isDataTexture,m=[],x=0;x<6;x++)m[x]=p||v?v?o.image[x].image:o.image[x]:g(o.image[x],!0,r.maxCubemapSize),m[x]=ne(o,m[x]);var S,T=m[0],E=a.convert(o.format,o.colorSpace),w=a.convert(o.type),A=M(o.internalFormat,E,w,o.colorSpace),R=!0!==o.isVideoTexture,C=void 0===c.__version||!0===l,k=u.dataReady,I=b(o,T);if(P(e.TEXTURE_CUBE_MAP,o),p){R&&C&&n.texStorage2D(e.TEXTURE_CUBE_MAP,I,A,T.width,T.height);for(var N=0;N<6;N++){S=m[N].mipmaps;for(var U=0;U<S.length;U++){var D=S[U];o.format!==ae?null!==E?R?k&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,U,0,0,D.width,D.height,E,D.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,U,A,D.width,D.height,0,D.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?k&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,U,0,0,D.width,D.height,E,w,D.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,U,A,D.width,D.height,0,E,w,D.data)}}}else{if(S=o.mipmaps,R&&C){S.length>0&&I++;var O=ie(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,I,A,O.width,O.height)}for(var F=0;F<6;F++)if(v){R?k&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,0,0,m[F].width,m[F].height,E,w,m[F].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,A,m[F].width,m[F].height,0,E,w,m[F].data);for(var B=0;B<S.length;B++){var z=S[B].image[F].image;R?k&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,B+1,0,0,z.width,z.height,E,w,z.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,B+1,A,z.width,z.height,0,E,w,z.data)}}else{R?k&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,0,0,E,w,m[F]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,A,E,w,m[F]);for(var H=0;H<S.length;H++){var V=S[H];R?k&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,H+1,0,0,E,w,V.image[F]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+F,H+1,A,E,w,V.image[F])}}}y(o)&&_(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&&U(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&q(t)},this.setupRenderTarget=function(t){var r=t.texture,s=i.get(t),l=i.get(r);t.addEventListener("dispose",E);var u=t.textures,c=!0===t.isWebGLCubeRenderTarget,h=u.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,o.memory.textures++),c){s.__webglFramebuffer=[];for(var d=0;d<6;d++)if(r.mipmaps&&r.mipmaps.length>0){s.__webglFramebuffer[d]=[];for(var f=0;f<r.mipmaps.length;f++)s.__webglFramebuffer[d][f]=e.createFramebuffer()}else s.__webglFramebuffer[d]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){s.__webglFramebuffer=[];for(var p=0;p<r.mipmaps.length;p++)s.__webglFramebuffer[p]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(h)for(var v=0,m=u.length;v<m;v++){var g=i.get(u[v]);void 0===g.__webglTexture&&(g.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&!1===ee(t)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(var x=0;x<u.length;x++){var S=u[x];s.__webglColorRenderbuffer[x]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[x]);var b=a.convert(S.format,S.colorSpace),T=a.convert(S.type),w=M(S.internalFormat,b,T,S.colorSpace,!0===t.isXRRenderTarget),A=$(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,A,w,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+x,e.RENDERBUFFER,s.__webglColorRenderbuffer[x])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),X(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(c){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),P(e.TEXTURE_CUBE_MAP,r);for(var R=0;R<6;R++)if(r.mipmaps&&r.mipmaps.length>0)for(var C=0;C<r.mipmaps.length;C++)U(s.__webglFramebuffer[R][C],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+R,C);else U(s.__webglFramebuffer[R],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+R,0);y(r)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(var k=0,I=u.length;k<I;k++){var L=u[k],N=i.get(L);n.bindTexture(e.TEXTURE_2D,N.__webglTexture),P(e.TEXTURE_2D,L),U(s.__webglFramebuffer,t,L,e.COLOR_ATTACHMENT0+k,e.TEXTURE_2D,0),y(L)&&_(e.TEXTURE_2D)}n.unbindTexture()}else{var D=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(D=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(D,l.__webglTexture),P(D,r),r.mipmaps&&r.mipmaps.length>0)for(var O=0;O<r.mipmaps.length;O++)U(s.__webglFramebuffer[O],t,r,e.COLOR_ATTACHMENT0,D,O);else U(s.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,D,0);y(r)&&_(D),n.unbindTexture()}t.depthBuffer&&q(t)},this.updateRenderTargetMipmap=function(e){for(var t=e.textures,r=0,a=t.length;r<a;r++){var o=t[r];if(y(o)){var s=x(e),l=i.get(o).__webglTexture;n.bindTexture(s,l),_(s),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===ee(t)){var r=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=i.get(t),c=r.length>1;if(c)for(var d=0;d<r.length;d++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+d,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+d,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(var f=0;f<r.length;f++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),c){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[f]);var p=i.get(r[f]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,p,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),!0===h&&(Z.length=0,Q.length=0,Z.push(e.COLOR_ATTACHMENT0+f),t.depthBuffer&&!1===t.resolveDepthBuffer&&(Z.push(l),Q.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Q)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Z))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),c)for(var v=0;v<r.length;v++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+v,e.RENDERBUFFER,u.__webglColorRenderbuffer[v]);var m=i.get(r[v]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+v,e.TEXTURE_2D,m,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&h){var g=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[g])}},this.setupDepthRenderbuffer=q,this.setupFrameBufferTexture=U,this.useMultisampledRTT=ee}function bf(e,t){return{convert:function(n){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tt,a=Ft.getTransfer(r);if(n===j)return e.UNSIGNED_BYTE;if(n===$)return e.UNSIGNED_SHORT_4_4_4_4;if(n===ee)return e.UNSIGNED_SHORT_5_5_5_1;if(n===ne)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===X)return e.BYTE;if(n===q)return e.SHORT;if(n===Y)return e.UNSIGNED_SHORT;if(n===Z)return e.INT;if(n===K)return e.UNSIGNED_INT;if(n===J)return e.FLOAT;if(n===Q)return e.HALF_FLOAT;if(n===ie)return e.ALPHA;if(n===re)return e.RGB;if(n===ae)return e.RGBA;if(n===oe)return e.LUMINANCE;if(n===se)return e.LUMINANCE_ALPHA;if(n===le)return e.DEPTH_COMPONENT;if(n===ue)return e.DEPTH_STENCIL;if(n===ce)return e.RED;if(n===he)return e.RED_INTEGER;if(n===de)return e.RG;if(n===fe)return e.RG_INTEGER;if(n===pe)return e.RGBA_INTEGER;if(n===ve||n===me||n===ge||n===ye)if(a===at){if(null===(i=t.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(n===ve)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===me)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ge)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ye)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(i=t.get("WEBGL_compressed_texture_s3tc")))return null;if(n===ve)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===me)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ge)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ye)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===_e||n===xe||n===Me||n===Se){if(null===(i=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(n===_e)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===xe)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Me)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Se)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===be||n===Te||n===Ee){if(null===(i=t.get("WEBGL_compressed_texture_etc")))return null;if(n===be||n===Te)return a===at?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===Ee)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}if(n===we||n===Ae||n===Re||n===Ce||n===ke||n===Ie||n===Pe||n===Le||n===Ne||n===Ue||n===De||n===Oe||n===Fe||n===Be){if(null===(i=t.get("WEBGL_compressed_texture_astc")))return null;if(n===we)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ae)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Re)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ce)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ke)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ie)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Pe)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Le)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ne)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ue)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===De)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Oe)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Fe)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Be)return a===at?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===ze||n===He||n===Ve){if(null===(i=t.get("EXT_texture_compression_bptc")))return null;if(n===ze)return a===at?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===He)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ve)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Ge||n===We||n===je||n===Xe){if(null===(i=t.get("EXT_texture_compression_rgtc")))return null;if(n===ze)return i.COMPRESSED_RED_RGTC1_EXT;if(n===We)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===je)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Xe)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===te?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}var Tf={type:"move"},Ef=function(){return o((function e(){r(this,e),this._targetRay=null,this._grip=null,this._hand=null}),[{key:"getHandSpace",value:function(){return null===this._hand&&(this._hand=new mo,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 mo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new tn,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new tn),this._targetRay}},{key:"getGripSpace",value:function(){return null===this._grip&&(this._grip=new mo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new tn,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new tn),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=s(e.hand.values());try{for(i.s();!(n=i.n()).done;){var r=n.value;this._getHandJoint(t,r)}}catch(e){i.e(e)}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,l=this._grip,u=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(u&&e.hand){a=!0;var c,h=s(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(e){h.e(e)}finally{h.f()}var v=u.joints["index-finger-tip"],m=u.joints["thumb-tip"],g=v.position.distanceTo(m.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!==l&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.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(Tf)))}return null!==o&&(o.visible=null!==i),null!==l&&(l.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 mo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}])}(),wf=function(){return o((function e(){r(this,e),this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}),[{key:"init",value:function(e,t,n){if(null===this.texture){var i=new Xt;e.properties.get(i).__webglTexture=t.texture,t.depthNear===n.depthNear&&t.depthFar===n.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}},{key:"getMesh",value:function(e){if(null!==this.texture&&null===this.mesh){var t=e.cameras[0].viewport,n=new _r({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new hr(new Os(20,20),n)}return this.mesh}},{key:"reset",value:function(){this.texture=null,this.mesh=null}},{key:"getDepthTexture",value:function(){return this.texture}}])}(),Af=function(e){function t(e,a){var o;r(this,t);var s=o=i(this,t),l=null,u=1,c=null,h="local-floor",d=1,f=null,p=null,m=null,g=null,y=null,_=null,x=new wf,M=a.getContextAttributes(),S=null,b=null,T=[],E=[],w=new bt,A=null,R=new Tr;R.viewport=new qt;var C=new Tr;C.viewport=new qt;var k=[R,C],I=new Mu,P=null,L=null;function N(e){var t=E.indexOf(e.inputSource);if(-1!==t){var n=T[t];void 0!==n&&(n.update(e.inputSource,e.frame,f||c),n.dispatchEvent({type:e.type,data:e.inputSource}))}}function U(){l.removeEventListener("select",N),l.removeEventListener("selectstart",N),l.removeEventListener("selectend",N),l.removeEventListener("squeeze",N),l.removeEventListener("squeezestart",N),l.removeEventListener("squeezeend",N),l.removeEventListener("end",U),l.removeEventListener("inputsourceschange",D);for(var t=0;t<T.length;t++){var n=E[t];null!==n&&(E[t]=null,T[t].disconnect(n))}P=null,L=null,x.reset(),e.setRenderTarget(S),y=null,g=null,m=null,l=null,b=null,H.stop(),s.isPresenting=!1,e.setPixelRatio(A),e.setSize(w.width,w.height,!1),s.dispatchEvent({type:"sessionend"})}function D(e){for(var t=0;t<e.removed.length;t++){var n=e.removed[t],i=E.indexOf(n);i>=0&&(E[i]=null,T[i].disconnect(n))}for(var r=0;r<e.added.length;r++){var a=e.added[r],o=E.indexOf(a);if(-1===o){for(var s=0;s<T.length;s++){if(s>=E.length){E.push(a),o=s;break}if(null===E[s]){E[s]=a,o=s;break}}if(-1===o)break}var l=T[o];l&&l.connect(a)}}o.cameraAutoUpdate=!0,o.enabled=!1,o.isPresenting=!1,o.getController=function(e){var t=T[e];return void 0===t&&(t=new Ef,T[e]=t),t.getTargetRaySpace()},o.getControllerGrip=function(e){var t=T[e];return void 0===t&&(t=new Ef,T[e]=t),t.getGripSpace()},o.getHand=function(e){var t=T[e];return void 0===t&&(t=new Ef,T[e]=t),t.getHandSpace()},o.setFramebufferScaleFactor=function(e){u=e,!0===s.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},o.setReferenceSpaceType=function(e){h=e,!0===s.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},o.getReferenceSpace=function(){return f||c},o.setReferenceSpace=function(e){f=e},o.getBaseLayer=function(){return null!==g?g:y},o.getBinding=function(){return m},o.getFrame=function(){return _},o.getSession=function(){return l},o.setSession=function(){var t=n(v().mark((function t(n){var i,r,o,p,_;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(l=n)){t.next=28;break}if(S=e.getRenderTarget(),l.addEventListener("select",N),l.addEventListener("selectstart",N),l.addEventListener("selectend",N),l.addEventListener("squeeze",N),l.addEventListener("squeezestart",N),l.addEventListener("squeezeend",N),l.addEventListener("end",U),l.addEventListener("inputsourceschange",D),!0===M.xrCompatible){t.next=14;break}return t.next=14,a.makeXRCompatible();case 14:return A=e.getPixelRatio(),e.getSize(w),void 0!==l.enabledFeatures&&l.enabledFeatures.includes("layers")?(r=null,o=null,p=null,M.depth&&(p=M.stencil?a.DEPTH24_STENCIL8:a.DEPTH_COMPONENT24,r=M.stencil?ue:le,o=M.stencil?te:K),_={colorFormat:a.RGBA8,depthFormat:p,scaleFactor:u},m=new XRWebGLBinding(l,a),g=m.createProjectionLayer(_),l.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new Zt(g.textureWidth,g.textureHeight,{format:ae,type:j,depthTexture:new bo(g.textureWidth,g.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,r),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:!1===g.ignoreDepthValues})):(i={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:u},y=new XRWebGLLayer(l,a,i),l.updateRenderState({baseLayer:y}),e.setPixelRatio(1),e.setSize(y.framebufferWidth,y.framebufferHeight,!1),b=new Zt(y.framebufferWidth,y.framebufferHeight,{format:ae,type:j,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil})),b.isXRRenderTarget=!0,this.setFoveation(d),f=null,t.next=23,l.requestReferenceSpace(h);case 23:c=t.sent,H.setContext(l),H.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"});case 28:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.getEnvironmentBlendMode=function(){if(null!==l)return l.environmentBlendMode},o.getDepthTexture=function(){return x.getDepthTexture()};var O=new tn,F=new tn;function B(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}o.updateCamera=function(e){if(null!==l){var t=e.near,n=e.far;null!==x.texture&&(x.depthNear>0&&(t=x.depthNear),x.depthFar>0&&(n=x.depthFar)),I.near=C.near=R.near=t,I.far=C.far=R.far=n,P===I.near&&L===I.far||(l.updateRenderState({depthNear:I.near,depthFar:I.far}),P=I.near,L=I.far),R.layers.mask=2|e.layers.mask,C.layers.mask=4|e.layers.mask,I.layers.mask=R.layers.mask|C.layers.mask;var i=e.parent,r=I.cameras;B(I,i);for(var a=0;a<r.length;a++)B(r[a],i);2===r.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),v=p*-c;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(v),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{var m=o+p,g=s+p,y=d-v,_=f+(i-v),x=l*s/g*m,M=u*s/g*m;e.projectionMatrix.makePerspective(y,_,x,M,m,g),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(I,R,C):I.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*vt*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,I,i)}},o.getCamera=function(){return I},o.getFoveation=function(){if(null!==g||null!==y)return d},o.setFoveation=function(e){d=e,null!==g&&(g.fixedFoveation=e),null!==y&&void 0!==y.fixedFoveation&&(y.fixedFoveation=e)},o.hasDepthSensing=function(){return null!==x.texture},o.getDepthSensingMesh=function(){return x.getMesh(I)};var z=null;var H=new Zc;return H.setAnimationLoop((function(t,n){if(p=n.getViewerPose(f||c),_=n,null!==p){var i=p.views;null!==y&&(e.setRenderTargetFramebuffer(b,y.framebuffer),e.setRenderTarget(b));var r=!1;i.length!==I.cameras.length&&(I.cameras.length=0,r=!0);for(var a=0;a<i.length;a++){var o=i[a],u=null;if(null!==y)u=y.getViewport(o);else{var h=m.getViewSubImage(g,o);u=h.viewport,0===a&&(e.setRenderTargetTextures(b,h.colorTexture,g.ignoreDepthValues?void 0:h.depthStencilTexture),e.setRenderTarget(b))}var d=k[a];void 0===d&&((d=new Tr).layers.enable(a),d.viewport=new qt,k[a]=d),d.matrix.fromArray(o.transform.matrix),d.matrix.decompose(d.position,d.quaternion,d.scale),d.projectionMatrix.fromArray(o.projectionMatrix),d.projectionMatrixInverse.copy(d.projectionMatrix).invert(),d.viewport.set(u.x,u.y,u.width,u.height),0===a&&(I.matrix.copy(d.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),!0===r&&I.cameras.push(d)}var v=l.enabledFeatures;if(v&&v.includes("depth-sensing")){var M=m.getDepthInformation(i[0]);M&&M.isValid&&M.texture&&x.init(e,M,l.renderState)}}for(var S=0;S<T.length;S++){var w=E[S],A=T[S];null!==w&&void 0!==A&&A.update(w,n,f||c)}z&&z(t,n),n.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:n}),_=null})),o.setAnimationLoop=function(e){z=e},o.dispose=function(){},o}return h(t,e),o(t)}(ht),Rf=new Vn,Cf=new Pn;function kf(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);var r=t.get(i),a=r.envMap,o=r.envMapRotation;a&&(e.envMap.value=a,Rf.copy(o),Rf.x*=-1,Rf.y*=-1,Rf.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(Rf.y*=-1,Rf.z*=-1),e.envMapRotation.value.setFromMatrix4(Cf.makeRotationFromEuler(Rf)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,mr(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,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.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),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);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 If(e,t,n,i){var r={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);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]),v=n%i,m=v%p.boundary,g=v+m;n+=m,0!==g&&i-g<p.storage&&(n+=i-g),c.__data=new Float32Array(p.storage/Float32Array.BYTES_PER_ELEMENT),c.__offset=n,n+=p.storage}var y=n%i;y>0&&(n+=i-y);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,v=Array.isArray(f.value)?f.value:[f.value],m=0,g=0;g<v.length;g++){var y=v[g],_=u(y);"number"==typeof y||"boolean"==typeof y?(f.__data[0]=y,e.bufferSubData(e.UNIFORM_BUFFER,p+m,f.__data)):y.isMatrix3?(f.__data[0]=y.elements[0],f.__data[1]=y.elements[1],f.__data[2]=y.elements[2],f.__data[3]=0,f.__data[4]=y.elements[3],f.__data[5]=y.elements[4],f.__data[6]=y.elements[5],f.__data[7]=0,f.__data[8]=y.elements[6],f.__data[9]=y.elements[7],f.__data[10]=y.elements[8],f.__data[11]=0):(y.toArray(f.__data,m),m+=_.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 Pf=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e);var i,a=t.canvas,o=void 0===a?kt():a,s=t.context,l=void 0===s?null:s,u=t.depth,c=void 0===u||u,h=t.stencil,d=void 0!==h&&h,f=t.alpha,p=void 0!==f&&f,m=t.antialias,g=void 0!==m&&m,y=t.premultipliedAlpha,_=void 0===y||y,x=t.preserveDrawingBuffer,M=void 0!==x&&x,S=t.powerPreference,b=void 0===S?"default":S,E=t.failIfMajorPerformanceCaveat,w=void 0!==E&&E,A=t.reverseDepthBuffer,R=void 0!==A&&A;if(this.isWebGLRenderer=!0,null!==l){if("undefined"!=typeof WebGLRenderingContext&&l instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");i=l.getContextAttributes().alpha}else i=p;var C=new Uint32Array(4),k=new Int32Array(4),I=null,P=null,L=[],N=[];this.domElement=o,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=nt,this.toneMapping=0,this.toneMappingExposure=1;var U=this,D=!1,O=0,F=0,B=null,z=-1,H=null,V=new qt,G=new qt,X=null,q=new Ti(0),Z=0,J=o.width,ne=o.height,ie=1,re=null,ae=null,oe=new qt(0,0,J,ne),se=new qt(0,0,J,ne),le=!1,ue=new Ca,ce=!1,de=!1;this.transmissionResolutionScale=1;var ve=new Pn,me=new Pn,ge=new tn,ye=new qt,_e={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},xe=!1;function Me(){return null===B?ie:1}var Se,be,Te,Ee,we,Ae,Re,Ce,ke,Ie,Pe,Le,Ne,Ue,De,Oe,Fe,Be,ze,He,Ve,Ge,We,je,Xe=l;function qe(e,t){return o.getContext(e,t)}try{var Ye={alpha:!0,depth:c,stencil:d,antialias:g,premultipliedAlpha:_,preserveDrawingBuffer:M,powerPreference:b,failIfMajorPerformanceCaveat:w};if("setAttribute"in o&&o.setAttribute("data-engine","three.js r".concat(T)),o.addEventListener("webglcontextlost",Qe,!1),o.addEventListener("webglcontextrestored",$e,!1),o.addEventListener("webglcontextcreationerror",et,!1),null===Xe){var Ze="webgl2";if(null===(Xe=qe(Ze,Ye)))throw qe(Ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ke(){(Se=new wh(Xe)).init(),Ge=new bf(Xe,Se),be=new oh(Xe,Se,t,Ge),Te=new Mf(Xe,Se),be.reverseDepthBuffer&&R&&Te.buffers.depth.setReversed(!0),Ee=new Ch(Xe),we=new lf,Ae=new Sf(Xe,Se,Te,we,be,Ge,Ee),Re=new lh(U),Ce=new Eh(U),ke=new Kc(Xe),We=new rh(Xe,ke),Ie=new Ah(Xe,ke,Ee,We),Pe=new Ih(Xe,Ie,ke,Ee),ze=new kh(Xe,be,Ae),Oe=new sh(we),Le=new sf(U,Re,Ce,Se,be,We,Oe),Ne=new kf(U,we),Ue=new df,De=new yf(Se),Be=new ih(U,Re,Ce,Te,Pe,i,_),Fe=new _f(U,Pe,be),je=new If(Xe,Ee,be,Te),He=new ah(Xe,Se,Ee),Ve=new Rh(Xe,Se,Ee),Ee.programs=Le.programs,U.capabilities=be,U.extensions=Se,U.properties=we,U.renderLists=Ue,U.shadowMap=Fe,U.state=Te,U.info=Ee}Ke();var Je=new Af(U,Xe);function Qe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),D=!0}function $e(){console.log("THREE.WebGLRenderer: Context Restored."),D=!1;var e=Ee.autoReset,t=Fe.enabled,n=Fe.autoUpdate,i=Fe.needsUpdate,r=Fe.type;Ke(),Ee.autoReset=e,Fe.enabled=t,Fe.autoUpdate=n,Fe.needsUpdate=i,Fe.type=r}function et(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function tt(e){var t=e.target;t.removeEventListener("dispose",tt),function(e){(function(e){var t=we.get(e).programs;void 0!==t&&(t.forEach((function(e){Le.releaseProgram(e)})),e.isShaderMaterial&&Le.releaseShaderCache(e))})(e),we.remove(e)}(t)}function rt(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,pt(e,t,n),e.side=0,e.needsUpdate=!0,pt(e,t,n),e.side=2):pt(e,t,n)}this.xr=Je,this.getContext=function(){return Xe},this.getContextAttributes=function(){return Xe.getContextAttributes()},this.forceContextLoss=function(){var e=Se.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=Se.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(e){void 0!==e&&(ie=e,this.setSize(J,ne,!1))},this.getSize=function(e){return e.set(J,ne)},this.setSize=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];Je.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(J=e,ne=t,o.width=Math.floor(e*ie),o.height=Math.floor(t*ie),!0===n&&(o.style.width=e+"px",o.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(J*ie,ne*ie).floor()},this.setDrawingBufferSize=function(e,t,n){J=e,ne=t,ie=n,o.width=Math.floor(e*n),o.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(V)},this.getViewport=function(e){return e.copy(oe)},this.setViewport=function(e,t,n,i){e.isVector4?oe.set(e.x,e.y,e.z,e.w):oe.set(e,t,n,i),Te.viewport(V.copy(oe).multiplyScalar(ie).round())},this.getScissor=function(e){return e.copy(se)},this.setScissor=function(e,t,n,i){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,n,i),Te.scissor(G.copy(se).multiplyScalar(ie).round())},this.getScissorTest=function(){return le},this.setScissorTest=function(e){Te.setScissorTest(le=e)},this.setOpaqueSort=function(e){re=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor.apply(Be,arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha.apply(Be,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!==B){var r=B.texture.format;i=r===pe||r===fe||r===he}if(i){var a=B.texture.type,o=a===j||a===K||a===Y||a===te||a===$||a===ee,s=Be.getClearColor(),l=Be.getClearAlpha(),u=s.r,c=s.g,h=s.b;o?(C[0]=u,C[1]=c,C[2]=h,C[3]=l,Xe.clearBufferuiv(Xe.COLOR,0,C)):(k[0]=u,k[1]=c,k[2]=h,k[3]=l,Xe.clearBufferiv(Xe.COLOR,0,k))}else n|=Xe.COLOR_BUFFER_BIT}e&&(n|=Xe.DEPTH_BUFFER_BIT),t&&(n|=Xe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Xe.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(){o.removeEventListener("webglcontextlost",Qe,!1),o.removeEventListener("webglcontextrestored",$e,!1),o.removeEventListener("webglcontextcreationerror",et,!1),Be.dispose(),Ue.dispose(),De.dispose(),we.dispose(),Re.dispose(),Ce.dispose(),Pe.dispose(),We.dispose(),je.dispose(),Le.dispose(),Je.dispose(),Je.removeEventListener("sessionstart",ot),Je.removeEventListener("sessionend",st),lt.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=_e);var o=r.isMesh&&r.matrixWorld.determinant()<0,s=function(e,t,n,i,r){!0!==t.isScene&&(t=_e);Ae.resetTextureUnits();var a=t.fog,o=i.isMeshStandardMaterial?t.environment:null,s=null===B?U.outputColorSpace:!0===B.isXRRenderTarget?B.texture.colorSpace:it,l=(i.isMeshStandardMaterial?Ce:Re).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=0;i.toneMapped&&(null!==B&&!0!==B.isXRRenderTarget||(p=U.toneMapping));var v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,m=void 0!==v?v.length:0,g=we.get(i),y=P.state.lights;if(!0===ce&&(!0===de||e!==H)){var _=e===H&&i.id===z;Oe.setState(i,e,_)}var x=!1;i.version===g.__version?g.needsLights&&g.lightsStateVersion!==y.state.version||g.outputColorSpace!==s||r.isBatchedMesh&&!1===g.batching?x=!0:r.isBatchedMesh||!0!==g.batching?r.isBatchedMesh&&!0===g.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===g.batchingColor&&null!==r.colorTexture||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||r.isInstancedMesh&&!0===g.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===g.instancingMorph&&null!==r.morphTexture||g.envMap!==l||!0===i.fog&&g.fog!==a?x=!0:void 0===g.numClippingPlanes||g.numClippingPlanes===Oe.numPlanes&&g.numIntersection===Oe.numIntersection?(g.vertexAlphas!==u||g.vertexTangents!==c||g.morphTargets!==h||g.morphNormals!==d||g.morphColors!==f||g.toneMapping!==p||g.morphTargetsCount!==m)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,g.__version=i.version);var M=g.currentProgram;!0===x&&(M=pt(i,t,r));var S=!1,b=!1,T=!1,E=M.getUniforms(),w=g.uniforms;Te.useProgram(M.program)&&(S=!0,b=!0,T=!0);i.id!==z&&(z=i.id,b=!0);if(S||H!==e){Te.buffers.depth.getReversed()?(ve.copy(e.projectionMatrix),(R=ve.elements)[2]=.5*R[2]+.5*R[3],R[6]=.5*R[6]+.5*R[7],R[10]=.5*R[10]+.5*R[11],R[14]=.5*R[14]+.5*R[15],function(e){var t=e.elements;-1===t[11]?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=1-t[14])}(ve),E.setValue(Xe,"projectionMatrix",ve)):E.setValue(Xe,"projectionMatrix",e.projectionMatrix),E.setValue(Xe,"viewMatrix",e.matrixWorldInverse);var A=E.map.cameraPosition;void 0!==A&&A.setValue(Xe,ge.setFromMatrixPosition(e.matrixWorld)),be.logarithmicDepthBuffer&&E.setValue(Xe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&E.setValue(Xe,"isOrthographic",!0===e.isOrthographicCamera),H!==e&&(H=e,b=!0,T=!0)}var R;if(r.isSkinnedMesh){E.setOptional(Xe,r,"bindMatrix"),E.setOptional(Xe,r,"bindMatrixInverse");var C=r.skeleton;C&&(null===C.boneTexture&&C.computeBoneTexture(),E.setValue(Xe,"boneTexture",C.boneTexture,Ae))}r.isBatchedMesh&&(E.setOptional(Xe,r,"batchingTexture"),E.setValue(Xe,"batchingTexture",r._matricesTexture,Ae),E.setOptional(Xe,r,"batchingIdTexture"),E.setValue(Xe,"batchingIdTexture",r._indirectTexture,Ae),E.setOptional(Xe,r,"batchingColorTexture"),null!==r._colorsTexture&&E.setValue(Xe,"batchingColorTexture",r._colorsTexture,Ae));var k=n.morphAttributes;void 0===k.position&&void 0===k.normal&&void 0===k.color||ze.update(r,n,M);(b||g.receiveShadow!==r.receiveShadow)&&(g.receiveShadow=r.receiveShadow,E.setValue(Xe,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(w.envMap.value=l,w.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(w.envMapIntensity.value=t.environmentIntensity);b&&(E.setValue(Xe,"toneMappingExposure",U.toneMappingExposure),g.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(w,T),a&&!0===i.fog&&Ne.refreshFogUniforms(w,a),Ne.refreshMaterialUniforms(w,i,ie,ne,P.state.transmissionRenderTarget[e.id]),Dd.upload(Xe,vt(g),w,Ae));i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Dd.upload(Xe,vt(g),w,Ae),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&E.setValue(Xe,"center",r.center);if(E.setValue(Xe,"modelViewMatrix",r.modelViewMatrix),E.setValue(Xe,"normalMatrix",r.normalMatrix),E.setValue(Xe,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial)for(var I=i.uniformsGroups,L=0,N=I.length;L<N;L++){var D=I[L];je.update(D,M),je.bind(D,M)}return M}(e,t,n,i,r);Te.setMaterial(i,o);var l=n.index,u=1;if(!0===i.wireframe){if(void 0===(l=Ie.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)):null!=h&&(d=Math.max(d,0),f=Math.min(f,h.count));var p=f-d;if(!(p<0||p===1/0)){var v;We.setup(r,i,s,n,l);var m=He;if(null!==l&&(v=ke.get(l),(m=Ve).setIndex(v)),r.isMesh)!0===i.wireframe?(Te.setLineWidth(i.wireframeLinewidth*Me()),m.setMode(Xe.LINES)):m.setMode(Xe.TRIANGLES);else if(r.isLine){var g=i.linewidth;void 0===g&&(g=1),Te.setLineWidth(g*Me()),r.isLineSegments?m.setMode(Xe.LINES):r.isLineLoop?m.setMode(Xe.LINE_LOOP):m.setMode(Xe.LINE_STRIP)}else r.isPoints?m.setMode(Xe.POINTS):r.isSprite&&m.setMode(Xe.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)m.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Se.get("WEBGL_multi_draw"))m.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else for(var y=r._multiDrawStarts,_=r._multiDrawCounts,x=r._multiDrawCount,M=l?ke.get(l).bytesPerElement:1,S=we.get(i).currentProgram.getUniforms(),b=0;b<x;b++)S.setValue(Xe,"_gl_DrawID",b),m.render(y[b]/M,_[b]);else if(r.isInstancedMesh)m.renderInstances(d,p,r.count);else if(n.isInstancedBufferGeometry){var T=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,E=Math.min(n.instanceCount,T);m.renderInstances(d,p,E)}else m.render(d,p)}},this.compile=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null===n&&(n=e),(P=De.get(n)).init(t),N.push(P),n.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(P.pushLight(e),e.castShadow&&P.pushShadow(e))})),e!==n&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(P.pushLight(e),e.castShadow&&P.pushShadow(e))})),P.setupLights();var i=new Set;return e.traverse((function(e){if(e.isMesh||e.isPoints||e.isLine||e.isSprite){var t=e.material;if(t)if(Array.isArray(t))for(var r=0;r<t.length;r++){var a=t[r];rt(a,n,e),i.add(a)}else rt(t,n,e),i.add(t)}})),N.pop(),P=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){we.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==Se.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};var at=null;function ot(){lt.stop()}function st(){lt.start()}var lt=new Zc;function ut(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)P.pushLight(e),e.castShadow&&P.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ue.intersectsSprite(e)){i&&ye.setFromMatrixPosition(e.matrixWorld).applyMatrix4(me);var r=Pe.update(e),a=e.material;a.visible&&I.push(e,r,a,n,ye.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ue.intersectsObject(e))){var o=Pe.update(e),s=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ye.copy(e.boundingSphere.center)):(null===o.boundingSphere&&o.computeBoundingSphere(),ye.copy(o.boundingSphere.center)),ye.applyMatrix4(e.matrixWorld).applyMatrix4(me)),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&&I.push(e,o,d,n,ye.z,h)}else s.visible&&I.push(e,o,s,n,ye.z,null)}for(var f=e.children,p=0,v=f.length;p<v;p++)ut(f[p],t,n,i)}}function ct(e,t,n,i){var r=e.opaque,a=e.transmissive,o=e.transparent;P.setupLightsView(n),!0===ce&&Oe.setGlobalState(U.clippingPlanes,n),i&&Te.viewport(V.copy(i)),r.length>0&&dt(r,t,n),a.length>0&&dt(a,t,n),o.length>0&&dt(o,t,n),Te.buffers.depth.setTest(!0),Te.buffers.depth.setMask(!0),Te.buffers.color.setMask(!0),Te.setPolygonOffset(!1)}function ht(e,t,n,i){if(null===(!0===n.isScene?n.overrideMaterial:null)){void 0===P.state.transmissionRenderTarget[i.id]&&(P.state.transmissionRenderTarget[i.id]=new Zt(1,1,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")||Se.has("EXT_color_buffer_float")?Q:j,minFilter:W,samples:4,stencilBuffer:d,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ft.workingColorSpace}));var r=P.state.transmissionRenderTarget[i.id],a=i.viewport||V;r.setSize(a.z*U.transmissionResolutionScale,a.w*U.transmissionResolutionScale);var o=U.getRenderTarget();U.setRenderTarget(r),U.getClearColor(q),(Z=U.getClearAlpha())<1&&U.setClearColor(16777215,.5),U.clear(),xe&&Be.render(n);var s=U.toneMapping;U.toneMapping=0;var l=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),P.setupLightsView(i),!0===ce&&Oe.setGlobalState(U.clippingPlanes,i),dt(e,n,i),Ae.updateMultisampleRenderTarget(r),Ae.updateRenderTargetMipmap(r),!1===Se.has("WEBGL_multisampled_render_to_texture")){for(var u=!1,c=0,h=t.length;c<h;c++){var f=t[c],p=f.object,v=f.geometry,m=f.material,g=f.group;if(2===m.side&&p.layers.test(i.layers)){var y=m.side;m.side=1,m.needsUpdate=!0,ft(p,n,i,v,m,g),m.side=y,m.needsUpdate=!0,u=!0}}!0===u&&(Ae.updateMultisampleRenderTarget(r),Ae.updateRenderTargetMipmap(r))}U.setRenderTarget(o),U.setClearColor(q,Z),void 0!==l&&(i.viewport=l),U.toneMapping=s}}function dt(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)&&ft(s,t,n,l,u,c)}}function ft(e,t,n,i,r,a){e.onBeforeRender(U,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(U,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,U.renderBufferDirect(n,t,i,r,e,a),r.side=0,r.needsUpdate=!0,U.renderBufferDirect(n,t,i,r,e,a),r.side=2):U.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(U,t,n,i,r,a)}function pt(e,t,n){!0!==t.isScene&&(t=_e);var i=we.get(e),r=P.state.lights,a=P.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?Ce:Re).get(e.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===u&&(e.addEventListener("dispose",tt),u=new Map,i.programs=u);var c=u.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===o)return mt(e,s),c}else s.uniforms=Le.getUniforms(e),e.onBeforeCompile(s,U),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=Oe.uniform),mt(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 vt(e){if(null===e.uniformsList){var t=e.currentProgram.getUniforms();e.uniformsList=Dd.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function mt(e,t){var n=we.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,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}lt.setAnimationLoop((function(e){at&&at(e)})),"undefined"!=typeof self&&lt.setContext(self),this.setAnimationLoop=function(e){at=e,Je.setAnimationLoop(e),null===e?lt.stop():lt.start()},Je.addEventListener("sessionstart",ot),Je.addEventListener("sessionend",st),this.render=function(e,t){if(void 0===t||!0===t.isCamera){if(!0!==D){if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Je.enabled&&!0===Je.isPresenting&&(!0===Je.cameraAutoUpdate&&Je.updateCamera(t),t=Je.getCamera()),!0===e.isScene&&e.onBeforeRender(U,e,t,B),(P=De.get(e,N.length)).init(t),N.push(P),me.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ue.setFromProjectionMatrix(me),de=this.localClippingEnabled,ce=Oe.init(this.clippingPlanes,de),(I=Ue.get(e,L.length)).init(),L.push(I),!0===Je.enabled&&!0===Je.isPresenting){var n=U.xr.getDepthSensingMesh();null!==n&&ut(n,t,-1/0,U.sortObjects)}ut(e,t,0,U.sortObjects),I.finish(),!0===U.sortObjects&&I.sort(re,ae),(xe=!1===Je.enabled||!1===Je.isPresenting||!1===Je.hasDepthSensing())&&Be.addToRenderList(I,e),this.info.render.frame++,!0===ce&&Oe.beginShadows();var i=P.state.shadowsArray;Fe.render(i,e,t),!0===ce&&Oe.endShadows(),!0===this.info.autoReset&&this.info.reset();var r=I.opaque,a=I.transmissive;if(P.setupLights(),t.isArrayCamera){var o=t.cameras;if(a.length>0)for(var s=0,l=o.length;s<l;s++){ht(r,a,e,o[s])}xe&&Be.render(e);for(var u=0,c=o.length;u<c;u++){var h=o[u];ct(I,e,h,h.viewport)}}else a.length>0&&ht(r,a,e,t),xe&&Be.render(e),ct(I,e,t);null!==B&&0===F&&(Ae.updateMultisampleRenderTarget(B),Ae.updateRenderTargetMipmap(B)),!0===e.isScene&&e.onAfterRender(U,e,t),We.resetDefaultState(),z=-1,H=null,N.pop(),N.length>0?(P=N[N.length-1],!0===ce&&Oe.setGlobalState(U.clippingPlanes,P.state.camera)):P=null,L.pop(),I=L.length>0?L[L.length-1]:null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return F},this.getRenderTarget=function(){return B},this.setRenderTargetTextures=function(e,t,n){we.get(e.texture).__webglTexture=t,we.get(e.depthTexture).__webglTexture=n;var i=we.get(e);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===Se.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=we.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};var gt=Xe.createFramebuffer();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;B=e,O=t,F=n;var i=!0,r=null,a=!1,o=!1;if(e){var s=we.get(e);if(void 0!==s.__useDefaultFramebuffer)Te.bindFramebuffer(Xe.FRAMEBUFFER,null),i=!1;else if(void 0===s.__webglFramebuffer)Ae.setupRenderTarget(e);else if(s.__hasExternalTextures)Ae.rebindTextures(e,we.get(e.texture).__webglTexture,we.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){var l=e.depthTexture;if(s.__boundDepthTexture!==l){if(null!==l&&we.has(l)&&(e.width!==l.image.width||e.height!==l.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ae.setupDepthRenderbuffer(e)}}var u=e.texture;(u.isData3DTexture||u.isDataArrayTexture||u.isCompressedArrayTexture)&&(o=!0);var c=we.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===Ae.useMultisampledRTT(e)?we.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,V.copy(e.viewport),G.copy(e.scissor),X=e.scissorTest}else V.copy(oe).multiplyScalar(ie).floor(),G.copy(se).multiplyScalar(ie).floor(),X=le;if(0!==n&&(r=gt),Te.bindFramebuffer(Xe.FRAMEBUFFER,r)&&i&&Te.drawBuffers(e,r),Te.viewport(V),Te.scissor(G),Te.setScissorTest(X),a){var h=we.get(e.texture);Xe.framebufferTexture2D(Xe.FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,Xe.TEXTURE_CUBE_MAP_POSITIVE_X+t,h.__webglTexture,n)}else if(o){var d=we.get(e.texture),f=t;Xe.framebufferTextureLayer(Xe.FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,d.__webglTexture,n,f)}else if(null!==e&&0!==n){var p=we.get(e.texture);Xe.framebufferTexture2D(Xe.FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,Xe.TEXTURE_2D,p.__webglTexture,n)}z=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(e&&e.isWebGLRenderTarget){var s=we.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){Te.bindFramebuffer(Xe.FRAMEBUFFER,s);try{var l=e.texture,u=l.format,c=l.type;if(!be.textureFormatReadable(u))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!be.textureTypeReadable(c))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&&Xe.readPixels(t,n,i,r,Ge.convert(u),Ge.convert(c),a)}finally{var h=null!==B?we.get(B).__webglFramebuffer:null;Te.bindFramebuffer(Xe.FRAMEBUFFER,h)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.readRenderTargetPixelsAsync=function(){var e=n(v().mark((function e(t,n,i,r,a,o,s){var l,u,c,h,d,f,p;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&t.isWebGLRenderTarget){e.next=2;break}throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");case 2:if(l=we.get(t).__webglFramebuffer,t.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),!l){e.next=32;break}if(u=t.texture,c=u.format,h=u.type,be.textureFormatReadable(c)){e.next=10;break}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");case 10:if(be.textureTypeReadable(h)){e.next=12;break}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");case 12:if(!(n>=0&&n<=t.width-r&&i>=0&&i<=t.height-a)){e.next=31;break}return Te.bindFramebuffer(Xe.FRAMEBUFFER,l),d=Xe.createBuffer(),Xe.bindBuffer(Xe.PIXEL_PACK_BUFFER,d),Xe.bufferData(Xe.PIXEL_PACK_BUFFER,o.byteLength,Xe.STREAM_READ),Xe.readPixels(n,i,r,a,Ge.convert(c),Ge.convert(h),0),f=null!==B?we.get(B).__webglFramebuffer:null,Te.bindFramebuffer(Xe.FRAMEBUFFER,f),p=Xe.fenceSync(Xe.SYNC_GPU_COMMANDS_COMPLETE,0),Xe.flush(),e.next=24,Lt(Xe,p,4);case 24:return Xe.bindBuffer(Xe.PIXEL_PACK_BUFFER,d),Xe.getBufferSubData(Xe.PIXEL_PACK_BUFFER,0,o),Xe.deleteBuffer(d),Xe.deleteSync(p),e.abrupt("return",o);case 31:throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");case 32:case"end":return e.stop()}}),e)})));return function(t,n,i,r,a,o,s){return e.apply(this,arguments)}}(),this.copyFramebufferToTexture=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;!0!==e.isTexture&&(Pt("WebGLRenderer: copyFramebufferToTexture function signature has changed."),t=arguments[0]||null,e=arguments[1]);var i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),o=null!==t?t.x:0,s=null!==t?t.y:0;Ae.setTexture2D(e,0),Xe.copyTexSubImage2D(Xe.TEXTURE_2D,n,0,0,o,s,r,a),Te.unbindTexture()};var yt=Xe.createFramebuffer(),_t=Xe.createFramebuffer();this.copyTextureToTexture=function(e,t){var n,i,r,a,o,s,l,u,c,h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,f=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,p=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;!0!==e.isTexture&&(Pt("WebGLRenderer: copyTextureToTexture function signature has changed."),d=arguments[0]||null,e=arguments[1],t=arguments[2],p=arguments[3]||0,h=null),null===p&&(0!==f?(Pt("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),p=f,f=0):p=0);var v=e.isCompressedTexture?e.mipmaps[p]:e.image;if(null!==h)n=h.max.x-h.min.x,i=h.max.y-h.min.y,r=h.isBox3?h.max.z-h.min.z:1,a=h.min.x,o=h.min.y,s=h.isBox3?h.min.z:0;else{var m=Math.pow(2,-f);n=Math.floor(v.width*m),i=Math.floor(v.height*m),r=e.isDataArrayTexture?v.depth:e.isData3DTexture?Math.floor(v.depth*m):1,a=0,o=0,s=0}null!==d?(l=d.x,u=d.y,c=d.z):(l=0,u=0,c=0);var g,y=Ge.convert(t.format),_=Ge.convert(t.type);t.isData3DTexture?(Ae.setTexture3D(t,0),g=Xe.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Ae.setTexture2DArray(t,0),g=Xe.TEXTURE_2D_ARRAY):(Ae.setTexture2D(t,0),g=Xe.TEXTURE_2D),Xe.pixelStorei(Xe.UNPACK_FLIP_Y_WEBGL,t.flipY),Xe.pixelStorei(Xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Xe.pixelStorei(Xe.UNPACK_ALIGNMENT,t.unpackAlignment);var x=Xe.getParameter(Xe.UNPACK_ROW_LENGTH),M=Xe.getParameter(Xe.UNPACK_IMAGE_HEIGHT),S=Xe.getParameter(Xe.UNPACK_SKIP_PIXELS),b=Xe.getParameter(Xe.UNPACK_SKIP_ROWS),T=Xe.getParameter(Xe.UNPACK_SKIP_IMAGES);Xe.pixelStorei(Xe.UNPACK_ROW_LENGTH,v.width),Xe.pixelStorei(Xe.UNPACK_IMAGE_HEIGHT,v.height),Xe.pixelStorei(Xe.UNPACK_SKIP_PIXELS,a),Xe.pixelStorei(Xe.UNPACK_SKIP_ROWS,o),Xe.pixelStorei(Xe.UNPACK_SKIP_IMAGES,s);var E=e.isDataArrayTexture||e.isData3DTexture,w=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){var A=we.get(e),R=we.get(t),C=we.get(A.__renderTarget),k=we.get(R.__renderTarget);Te.bindFramebuffer(Xe.READ_FRAMEBUFFER,C.__webglFramebuffer),Te.bindFramebuffer(Xe.DRAW_FRAMEBUFFER,k.__webglFramebuffer);for(var I=0;I<r;I++)E&&(Xe.framebufferTextureLayer(Xe.READ_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,we.get(e).__webglTexture,f,s+I),Xe.framebufferTextureLayer(Xe.DRAW_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,we.get(t).__webglTexture,p,c+I)),Xe.blitFramebuffer(a,o,n,i,l,u,n,i,Xe.DEPTH_BUFFER_BIT,Xe.NEAREST);Te.bindFramebuffer(Xe.READ_FRAMEBUFFER,null),Te.bindFramebuffer(Xe.DRAW_FRAMEBUFFER,null)}else if(0!==f||e.isRenderTargetTexture||we.has(e)){var P=we.get(e),L=we.get(t);Te.bindFramebuffer(Xe.READ_FRAMEBUFFER,yt),Te.bindFramebuffer(Xe.DRAW_FRAMEBUFFER,_t);for(var N=0;N<r;N++)E?Xe.framebufferTextureLayer(Xe.READ_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,P.__webglTexture,f,s+N):Xe.framebufferTexture2D(Xe.READ_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,Xe.TEXTURE_2D,P.__webglTexture,f),w?Xe.framebufferTextureLayer(Xe.DRAW_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,L.__webglTexture,p,c+N):Xe.framebufferTexture2D(Xe.DRAW_FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,Xe.TEXTURE_2D,L.__webglTexture,p),0!==f?Xe.blitFramebuffer(a,o,n,i,l,u,n,i,Xe.COLOR_BUFFER_BIT,Xe.NEAREST):w?Xe.copyTexSubImage3D(g,p,l,u,c+N,a,o,n,i):Xe.copyTexSubImage2D(g,p,l,u,a,o,n,i);Te.bindFramebuffer(Xe.READ_FRAMEBUFFER,null),Te.bindFramebuffer(Xe.DRAW_FRAMEBUFFER,null)}else w?e.isDataTexture||e.isData3DTexture?Xe.texSubImage3D(g,p,l,u,c,n,i,r,y,_,v.data):t.isCompressedArrayTexture?Xe.compressedTexSubImage3D(g,p,l,u,c,n,i,r,y,v.data):Xe.texSubImage3D(g,p,l,u,c,n,i,r,y,_,v):e.isDataTexture?Xe.texSubImage2D(Xe.TEXTURE_2D,p,l,u,n,i,y,_,v.data):e.isCompressedTexture?Xe.compressedTexSubImage2D(Xe.TEXTURE_2D,p,l,u,v.width,v.height,y,v.data):Xe.texSubImage2D(Xe.TEXTURE_2D,p,l,u,n,i,y,_,v);Xe.pixelStorei(Xe.UNPACK_ROW_LENGTH,x),Xe.pixelStorei(Xe.UNPACK_IMAGE_HEIGHT,M),Xe.pixelStorei(Xe.UNPACK_SKIP_PIXELS,S),Xe.pixelStorei(Xe.UNPACK_SKIP_ROWS,b),Xe.pixelStorei(Xe.UNPACK_SKIP_IMAGES,T),0===p&&t.generateMipmaps&&Xe.generateMipmap(g),Te.unbindTexture()},this.copyTextureToTexture3D=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;return!0!==e.isTexture&&(Pt("WebGLRenderer: copyTextureToTexture3D function signature has changed."),n=arguments[0]||null,i=arguments[1]||null,e=arguments[2],t=arguments[3],r=arguments[4]||0),Pt('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(e,t,n,i,r)},this.initRenderTarget=function(e){void 0===we.get(e).__webglFramebuffer&&Ae.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?Ae.setTextureCube(e,0):e.isData3DTexture?Ae.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Ae.setTexture2DArray(e,0):Ae.setTexture2D(e,0),Te.unbindTexture()},this.resetState=function(){O=0,F=0,B=null,Te.reset(),We.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}),[{key:"coordinateSystem",get:function(){return ut}},{key:"outputColorSpace",get:function(){return this._outputColorSpace},set:function(e){this._outputColorSpace=e;var t=this.getContext();t.drawingBufferColorspace=Ft._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ft._getUnpackColorSpace()}}])}(),Lf={__proto__:null,ACESFilmicToneMapping:4,AddEquation:E,AddOperation:2,AdditiveAnimationBlendMode:et,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:ie,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:nu,AnimationAction:Xu,AnimationClip:Tl,AnimationLoader:Nl,AnimationMixer:Yu,AnimationObjectGroup:ju,AnimationUtils:hl,ArcCurve:wo,ArrayCamera:Mu,ArrowHelper:Gc,AttachedBindMode:R,Audio:Cu,AudioAnalyser:Uu,AudioContext:vu,AudioListener:Ru,AudioLoader:mu,AxesHelper:Wc,BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:qa,Bone:ua,BooleanKeyframeTrack:gl,Box2:cc,Box3:an,Box3Helper:zc,BoxGeometry:fr,BoxHelper:Bc,BufferAttribute:Di,BufferGeometry:$i,BufferGeometryLoader:uu,ByteType:X,Cache:wl,Camera:xr,CameraHelper:Nc,CanvasTexture:So,CapsuleGeometry:qo,CatmullRomCurve3:Po,CineonToneMapping:3,CircleGeometry:Yo,ClampToEdgeWrapping:O,Clock:Su,Color:Ti,ColorKeyframeTrack:yl,ColorManagement:Ft,CompressedArrayTexture:xo,CompressedCubeTexture:Mo,CompressedTexture:_o,CompressedTextureLoader:Ul,ConeGeometry:Ko,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:Xc,CubeCamera:wr,CubeReflectionMapping:I,CubeRefractionMapping:P,CubeTexture:Ar,CubeTextureLoader:Ol,CubeUVReflectionMapping:U,CubicBezierCurve:Do,CubicBezierCurve3:Oo,CubicInterpolant:fl,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:To,CurvePath:Wo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:Zo,Cylindrical:sc,Data3DTexture:Qt,DataArrayTexture:Kt,DataTexture:ca,DataTextureLoader:Fl,DataUtils:Li,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:Rl,DepthFormat:le,DepthStencilFormat:ue,DepthTexture:bo,DetachedBindMode:C,DirectionalLight:tu,DirectionalLightHelper:Ic,DiscreteInterpolant:vl,DodecahedronGeometry:Qo,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:is,EllipseCurve:Eo,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:L,EquirectangularRefractionMapping:N,Euler:Vn,EventDispatcher:ht,ExtrudeGeometry:Ls,FileLoader:Ll,Float16BufferAttribute:Wi,Float32BufferAttribute:ji,FloatType:J,Fog:kr,FogExp2:Cr,FramebufferTexture:yo,FrontSide:0,Frustum:Ca,GLBufferAttribute:tc,GLSL1:"100",GLSL3:lt,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:wc,Group:mo,HalfFloatType:Q,HemisphereLight:Hl,HemisphereLightHelper:Ec,IcosahedronGeometry:Us,ImageBitmapLoader:pu,ImageLoader:Dl,ImageUtils:Ht,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:pa,InstancedBufferGeometry:lu,InstancedInterleavedBuffer:ec,InstancedMesh:Sa,Int16BufferAttribute:zi,Int32BufferAttribute:Vi,Int8BufferAttribute:Oi,IntType:Z,InterleavedBuffer:Pr,InterleavedBufferAttribute:Nr,Interpolant:dl,InterpolateDiscrete:qe,InterpolateLinear:Ye,InterpolateSmooth:Ze,InvertStencilOp:5386,KeepStencilOp:ot,KeyframeTrack:ml,LOD:Qr,LatheGeometry:Xo,Layers:Gn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:zl,LightProbe:au,Line:no,Line3:fc,LineBasicMaterial:Ya,LineCurve:Fo,LineCurve3:Bo,LineDashedMaterial:al,LineLoop:so,LineSegments:oo,LinearFilter:V,LinearInterpolant:pl,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:W,LinearMipmapNearestFilter:G,LinearSRGBColorSpace:it,LinearToneMapping:1,LinearTransfer:rt,Loader:Cl,LoaderUtils:su,LoadingManager:Al,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:se,LuminanceFormat:oe,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:Ai,MaterialLoader:ou,MathUtils:St,Matrix2:lc,Matrix3:Tt,Matrix4:Pn,MaxEquation:104,Mesh:hr,MeshBasicMaterial:Ri,MeshDepthMaterial:nl,MeshDistanceMaterial:il,MeshLambertMaterial:tl,MeshMatcapMaterial:rl,MeshNormalMaterial:el,MeshPhongMaterial:Qs,MeshPhysicalMaterial:Js,MeshStandardMaterial:Ks,MeshToonMaterial:$s,MinEquation:103,MirroredRepeatWrapping:F,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:B,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:H,NearestMipmapNearestFilter:z,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:tt,NoToneMapping:0,NormalAnimationBlendMode:$e,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:_l,Object3D:ai,ObjectLoader:cu,ObjectSpaceNormalMap:1,OctahedronGeometry:Ds,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:A,OneMinusSrcColorFactor:203,OrthographicCamera:$l,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:xh,Path:jo,PerspectiveCamera:Tr,Plane:wa,PlaneGeometry:Os,PlaneHelper:Hc,PointLight:Ql,PointLightHelper:Mc,Points:po,PointsMaterial:lo,PolarGridHelper:Ac,PolyhedronGeometry:Jo,PositionalAudio:Nu,PropertyBinding:Wu,PropertyMixer:Du,QuadraticBezierCurve:zo,QuadraticBezierCurve3:Ho,Quaternion:en,QuaternionKeyframeTrack:Ml,QuaternionLinearInterpolant:xl,RED_GREEN_RGTC2_Format:je,RED_RGTC1_Format:Ge,REVISION:T,RGBADepthPacking:3201,RGBAFormat:ae,RGBAIntegerFormat:pe,RGBA_ASTC_10x10_Format:Oe,RGBA_ASTC_10x5_Format:Ne,RGBA_ASTC_10x6_Format:Ue,RGBA_ASTC_10x8_Format:De,RGBA_ASTC_12x10_Format:Fe,RGBA_ASTC_12x12_Format:Be,RGBA_ASTC_4x4_Format:we,RGBA_ASTC_5x4_Format:Ae,RGBA_ASTC_5x5_Format:Re,RGBA_ASTC_6x5_Format:Ce,RGBA_ASTC_6x6_Format:ke,RGBA_ASTC_8x5_Format:Ie,RGBA_ASTC_8x6_Format:Pe,RGBA_ASTC_8x8_Format:Le,RGBA_BPTC_Format:ze,RGBA_ETC2_EAC_Format:Ee,RGBA_PVRTC_2BPPV1_Format:Se,RGBA_PVRTC_4BPPV1_Format:Me,RGBA_S3TC_DXT1_Format:me,RGBA_S3TC_DXT3_Format:ge,RGBA_S3TC_DXT5_Format:ye,RGBDepthPacking:3202,RGBFormat:re,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:He,RGB_BPTC_UNSIGNED_Format:Ve,RGB_ETC1_Format:be,RGB_ETC2_Format:Te,RGB_PVRTC_2BPPV1_Format:xe,RGB_PVRTC_4BPPV1_Format:_e,RGB_S3TC_DXT1_Format:ve,RGDepthPacking:3203,RGFormat:de,RGIntegerFormat:fe,RawShaderMaterial:Zs,Ray:In,Raycaster:ic,RectAreaLight:iu,RedFormat:ce,RedIntegerFormat:he,ReinhardToneMapping:2,RenderTarget:Yt,RenderTarget3D:Zu,RenderTargetArray:Ku,RepeatWrapping:D,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Fs,SIGNED_RED_GREEN_RGTC2_Format:Xe,SIGNED_RED_RGTC1_Format:We,SRGBColorSpace:nt,SRGBTransfer:at,Scene:Ir,ShaderChunk:Jc,ShaderLib:$c,ShaderMaterial:_r,ShadowMaterial:Ys,Shape:rs,ShapeGeometry:Bs,ShapePath:jc,ShapeUtils:ks,ShortType:q,Skeleton:fa,SkeletonHelper:_c,SkinnedMesh:la,Source:Gt,Sphere:bn,SphereGeometry:zs,Spherical:oc,SphericalHarmonics3:ru,SplineCurve:Vo,SpotLight:ql,SpotLightHelper:vc,Sprite:Yr,SpriteMaterial:Ur,SrcAlphaFactor:w,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:st,StaticReadUsage:35045,StereoCamera:xu,StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:Sl,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:Hs,Texture:Xt,TextureLoader:Bl,TextureUtils:Yc,TorusGeometry:Vs,TorusKnotGeometry:Gs,Triangle:_i,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Ws,UVMapping:k,Uint16BufferAttribute:Hi,Uint32BufferAttribute:Gi,Uint8BufferAttribute:Fi,Uint8ClampedBufferAttribute:Bi,Uniform:Ju,UniformsGroup:$u,UniformsLib:Qc,UniformsUtils:yr,UnsignedByteType:j,UnsignedInt248Type:te,UnsignedInt5999Type:ne,UnsignedIntType:K,UnsignedShort4444Type:$,UnsignedShort5551Type:ee,UnsignedShortType:Y,VSMShadowMap:3,Vector2:bt,Vector3:tn,Vector4:qt,VectorKeyframeTrack:bl,VideoTexture:go,WebGL3DRenderTarget:$t,WebGLArrayRenderTarget:Jt,WebGLCoordinateSystem:ut,WebGLCubeRenderTarget:Rr,WebGLRenderTarget:Zt,WebGLRenderer:Pf,WebGLUtils:bf,WebGPUCoordinateSystem:ct,WireframeGeometry:js,WrapAroundEnding:Qe,ZeroCurvatureEnding:Ke,ZeroFactor:200,ZeroSlopeEnding:Je,ZeroStencilOp:0,createCanvasElement:kt};function Nf(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}var Uf=function(e){function t(e){var n;return r(this,t),(n=i(this,t,[e])).dracoLoader=null,n.ktx2Loader=null,n.meshoptDecoder=null,n.pluginCallbacks=[],n.register((function(e){return new Hf(e)})),n.register((function(e){return new Vf(e)})),n.register((function(e){return new Jf(e)})),n.register((function(e){return new Qf(e)})),n.register((function(e){return new $f(e)})),n.register((function(e){return new Wf(e)})),n.register((function(e){return new jf(e)})),n.register((function(e){return new Xf(e)})),n.register((function(e){return new qf(e)})),n.register((function(e){return new zf(e)})),n.register((function(e){return new Yf(e)})),n.register((function(e){return new Gf(e)})),n.register((function(e){return new Kf(e)})),n.register((function(e){return new Zf(e)})),n.register((function(e){return new Ff(e)})),n.register((function(e){return new ep(e)})),n.register((function(e){return new tp(e)})),n}return h(t,e),o(t,[{key:"load",value:function(e,t,n,i){var r,a=this;if(""!==this.resourcePath)r=this.resourcePath;else if(""!==this.path){var o=su.extractUrlBase(e);r=su.resolveURL(o,this.path)}else r=su.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 Ll(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(e){s(e)}}),n,s)}},{key:"setDRACOLoader",value:function(e){return this.dracoLoader=e,this}},{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))===np){try{a[Of.KHR_BINARY_GLTF]=new ap(e)}catch(e){return void(i&&i(e))}r=JSON.parse(a[Of.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 kp(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 Of.KHR_MATERIALS_UNLIT:a[d]=new Bf;break;case Of.KHR_DRACO_MESH_COMPRESSION:a[d]=new op(r,this.dracoLoader);break;case Of.KHR_TEXTURE_TRANSFORM:a[d]=new sp;break;case Of.KHR_MESH_QUANTIZATION:a[d]=new lp;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)}))}}])}(Cl);function Df(){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 Of={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_DISPERSION:"KHR_materials_dispersion",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"},Ff=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}),[{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 Ti(16777215);void 0!==o.color&&s.setRGB(o.color[0],o.color[1],o.color[2],it);var l=void 0!==o.range?o.range:0;switch(o.type){case"directional":(r=new tu(s)).target.position.set(0,0,-1),r.add(r.target);break;case"point":(r=new Ql(s)).distance=l;break;case"spot":(r=new ql(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,Tp(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)}))}}])}(),Bf=function(){return o((function e(){r(this,e),this.name=Of.KHR_MATERIALS_UNLIT}),[{key:"getMaterialType",value:function(){return Ri}},{key:"extendParams",value:function(e,t,n){var i=[];e.color=new Ti(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],it),e.opacity=a[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,nt))}return Promise.all(i)}}])}(),zf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_EMISSIVE_STRENGTH}),[{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()}}])}(),Hf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_CLEARCOAT}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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 bt(o,o)}return Promise.all(r)}}])}(),Vf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_DISPERSION}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}])}(),Gf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_IRIDESCENCE}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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)}}])}(),Wf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_SHEEN}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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 Ti(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],it)}return void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,nt)),void 0!==a.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}])}(),jf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_TRANSMISSION}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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)}}])}(),Xf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_VOLUME}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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 Ti).setRGB(o[0],o[1],o[2],it),Promise.all(r)}}])}(),qf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_IOR}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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()}}])}(),Yf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_SPECULAR}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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 Ti).setRGB(o[0],o[1],o[2],it),void 0!==a.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,nt)),Promise.all(r)}}])}(),Zf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.EXT_MATERIALS_BUMP}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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)}}])}(),Kf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_MATERIALS_ANISOTROPY}),[{key:"getMaterialType",value:function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Js: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)}}])}(),Jf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.KHR_TEXTURE_BASISU}),[{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)}}])}(),Qf=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.EXT_TEXTURE_WEBP,this.isSupported=null}),[{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}}])}(),$f=function(){return o((function e(t){r(this,e),this.parser=t,this.name=Of.EXT_TEXTURE_AVIF,this.isSupported=null}),[{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}}])}(),ep=function(){return o((function e(t){r(this,e),this.name=Of.EXT_MESHOPT_COMPRESSION,this.parser=t}),[{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}}])}(),tp=function(){return o((function e(t){r(this,e),this.name=Of.EXT_MESH_GPU_INSTANCING,this.parser=t}),[{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=s(n.meshes[i.mesh].primitives);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(o.mode!==dp.TRIANGLES&&o.mode!==dp.TRIANGLE_STRIP&&o.mode!==dp.TRIANGLE_FAN&&void 0!==o.mode)return null}}catch(e){a.e(e)}finally{a.f()}var l=i.extensions[this.name].attributes,u=[],c={},h=function(e){u.push(t.parser.getDependency("accessor",l[e]).then((function(t){return c[e]=t,c[e]})))};for(var d in l)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=[],l=s(r);try{for(l.s();!(n=l.n()).done;){for(var u=n.value,h=new Pn,d=new tn,f=new en,p=new tn(1,1,1),v=new Sa(u.geometry,u.material,a),m=0;m<a;m++)c.TRANSLATION&&d.fromBufferAttribute(c.TRANSLATION,m),c.ROTATION&&f.fromBufferAttribute(c.ROTATION,m),c.SCALE&&p.fromBufferAttribute(c.SCALE,m),v.setMatrixAt(m,h.compose(d,f,p));for(var g in c)if("_COLOR_0"===g){var y=c[g];v.instanceColor=new pa(y.array,y.itemSize,y.normalized)}else"TRANSLATION"!==g&&"ROTATION"!==g&&"SCALE"!==g&&u.geometry.setAttribute(g,c[g]);ai.prototype.copy.call(v,u),t.parser.assignFinalMaterial(v),o.push(v)}}catch(e){l.e(e)}finally{l.f()}return i.isGroup?(i.clear(),i.add.apply(i,o),i):o[0]})))}}])}(),np="glTF",ip=1313821514,rp=5130562,ap=o((function e(t){r(this,e),this.name=Of.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!==np)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 a=this.header.length-12,o=new DataView(t,12),s=0;s<a;){var l=o.getUint32(s,!0);s+=4;var u=o.getUint32(s,!0);if(s+=4,u===ip){var c=new Uint8Array(t,12+s,l);this.content=i.decode(c)}else if(u===rp){var h=12+s;this.body=t.slice(h,h+l)}s+=l}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")})),op=function(){return o((function e(t,n){if(r(this,e),!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Of.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=n,this.dracoLoader.preload()}),[{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=gp[u]||u.toLowerCase();o[c]=a[u]}for(var h in e.attributes){var d=gp[h]||h.toLowerCase();if(void 0!==a[h]){var f=n.accessors[e.attributes[h]],p=fp[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,it,n)}))}))}}])}(),sp=function(){return o((function e(){r(this,e),this.name=Of.KHR_TEXTURE_TRANSFORM}),[{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}}])}(),lp=o((function e(){r(this,e),this.name=Of.KHR_MESH_QUANTIZATION})),up=function(e){function t(e,n,a,o){return r(this,t),i(this,t,[e,n,a,o])}return h(t,e),o(t,[{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,v=-2*d+3*h,m=d-h,g=1-v,y=m-h+c,_=0;_!==o;_++){var x=a[p+_+o],M=a[p+_+s]*u,S=a[f+_+o],b=a[f+_]*u;r[_]=g*x+y*M+v*S+m*b}return r}}])}(dl),cp=new en,hp=function(e){function t(){return r(this,t),i(this,t,arguments)}return h(t,e),o(t,[{key:"interpolate_",value:function(e,n,i,r){var a=y(t,"interpolate_",this)([e,n,i,r]);return cp.fromArray(a).normalize().toArray(a),a}}])}(up),dp={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},fp={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},pp={9728:B,9729:V,9984:z,9985:G,9986:H,9987:W},vp={33071:O,33648:F,10497:D},mp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gp={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"},yp={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_p={CUBICSPLINE:void 0,LINEAR:Ye,STEP:qe},xp="OPAQUE",Mp="MASK",Sp="BLEND";function bp(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 Tp(e,t){void 0!==t.extras&&("object"===M(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Ep(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 wp(e){var t,n=e.extensions&&e.extensions[Of.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+Ap(n.attributes):e.indices+":"+Ap(e.attributes)+":"+e.mode,void 0!==e.targets)for(var i=0,r=e.targets.length;i<r;i++)t+=":"+Ap(e.targets[i]);return t}function Ap(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 Rp(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 Cp=new Pn,kp=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,e),this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new Df,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,a=-1,o=!1,s=-1;if("undefined"!=typeof navigator){var l=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(l);var u=l.match(/Version\/(\d+)/);a=i&&u?parseInt(u[1],10):-1,s=(o=l.indexOf("Firefox")>-1)?l.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&a<17||o&&s<98?this.textureLoader=new Bl(this.options.manager):this.textureLoader=new pu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ll(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}),[{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 bp(r,a,i),Tp(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){var t,n=s(a.scenes);try{for(n.s();!(t=n.n()).done;){t.value.updateMatrixWorld()}}catch(e){n.e(e)}finally{n.f()}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(),a=function(e,t){var n=i.associations.get(e);null!=n&&i.associations.set(t,n);var r,o=s(e.children.entries());try{for(o.s();!(r=o.n()).done;){var l=g(r.value,2),u=l[0],c=l[1];a(c,t.children[u])}}catch(e){o.e(e)}finally{o.f()}};return a(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[Of.KHR_BINARY_GLTF].body);var i=this.options;return new Promise((function(e,r){n.load(su.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=mp[i.type],a=fp[i.componentType],o=!0===i.normalized,s=new a(i.count*r);return Promise.resolve(new Di(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=mp[i.type],l=fp[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),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,m=t.cache.get(v);m||(r=new l(o,p*d,i.count*d/u),m=new Pr(r,d/u),t.cache.add(v,m)),a=new Nr(m,s,h%d/u,f)}else r=null===o?new l(i.count*s):new l(o,h,i.count*s),a=new Di(r,s,f);if(void 0!==i.sparse){var g=mp.SCALAR,y=fp[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,M=new y(e[1],_,i.sparse.count*g),S=new l(e[2],x,i.sparse.count*s);null!==o&&(a=new Di(a.array.slice(),a.itemSize,a.normalized)),a.normalized=!1;for(var b=0,T=M.length;b<T;b++){var E=M[b];if(a.setX(E,S[b*s]),s>=2&&a.setY(E,S[b*s+1]),s>=3&&a.setZ(E,S[b*s+2]),s>=4&&a.setW(E,S[b*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}a.normalized=f}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=pp[n.magFilter]||V,t.minFilter=pp[n.minFilter]||W,t.wrapS=vp[n.wrapS]||D,t.wrapT=vp[n.wrapT]||D,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==B&&t.minFilter!==V,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 Xt(e);t.needsUpdate=!0,n(t)}),t.load(su.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===s&&a.revokeObjectURL(o),Tp(e,r),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":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"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[Of.KHR_TEXTURE_TRANSFORM]){var o=void 0!==n.extensions?n.extensions[Of.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var s=r.associations.get(a);a=r.extensions[Of.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 lo,Ai.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 Ya,Ai.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 Ks}},{key:"loadMaterial",value:function(e){var t,n=this,i=this.json,r=this.extensions,a=i.materials[e],o={},s=[];if((a.extensions||{})[Of.KHR_MATERIALS_UNLIT]){var l=r[Of.KHR_MATERIALS_UNLIT];t=l.getMaterialType(),s.push(l.extendParams(o,a,n))}else{var u=a.pbrMetallicRoughness||{};if(o.color=new Ti(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){var c=u.baseColorFactor;o.color.setRGB(c[0],c[1],c[2],it),o.opacity=c[3]}void 0!==u.baseColorTexture&&s.push(n.assignTexture(o,"map",u.baseColorTexture,nt)),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||xp;if(h===Sp?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Mp&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==Ri&&(s.push(n.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new bt(1,1),void 0!==a.normalTexture.scale)){var d=a.normalTexture.scale;o.normalScale.set(d,d)}if(void 0!==a.occlusionTexture&&t!==Ri&&(s.push(n.assignTexture(o,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==Ri){var f=a.emissiveFactor;o.emissive=(new Ti).setRGB(f[0],f[1],f[2],it)}return void 0!==a.emissiveTexture&&t!==Ri&&s.push(n.assignTexture(o,"emissiveMap",a.emissiveTexture,nt)),Promise.all(s).then((function(){var i=new t(o);return a.name&&(i.name=a.name),Tp(i,a),n.associations.set(i,{materials:e}),a.extensions&&bp(r,i,a),i}))}},{key:"createUniqueName",value:function(e){var t=Wu.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[Of.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Ip(n,e,t)}))}for(var a=[],o=0,s=e.length;o<s;o++){var l=e[o],u=wp(l),c=i[u];if(c)a.push(c.promise);else{var h=void 0;h=l.extensions&&l.extensions[Of.KHR_DRACO_MESH_COMPRESSION]?r(l):Ip(new $i,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 Ks({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),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===dp.TRIANGLES||d.mode===dp.TRIANGLE_STRIP||d.mode===dp.TRIANGLE_FAN||void 0===d.mode)!0===(f=!0===a.isSkinnedMesh?new la(h,p):new hr(h,p)).isSkinnedMesh&&f.normalizeSkinWeights(),d.mode===dp.TRIANGLE_STRIP?f.geometry=Nf(f.geometry,1):d.mode===dp.TRIANGLE_FAN&&(f.geometry=Nf(f.geometry,2));else if(d.mode===dp.LINES)f=new oo(h,p);else if(d.mode===dp.LINE_STRIP)f=new no(h,p);else if(d.mode===dp.LINE_LOOP)f=new so(h,p);else{if(d.mode!==dp.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);f=new po(h,p)}Object.keys(f.geometry.morphAttributes).length>0&&Ep(f,a),f.name=n.createUniqueName(a.name||"mesh_"+e),Tp(f,a),d.extensions&&bp(r,f,d),n.assignFinalMaterial(f),l.push(f)}for(var v=0,m=l.length;v<m;v++)n.associations.set(l[v],{meshes:e,primitives:v});if(1===l.length)return a.extensions&&bp(r,l[0],a),l[0];var g=new mo;a.extensions&&bp(r,g,a),n.associations.set(g,{meshes:e});for(var y=0,_=l.length;y<_;y++)g.add(l[y]);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 Tr(St.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new $l(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Tp(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 Pn;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 fa(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,v=p.node,m=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",v)),o.push(this.getDependency("accessor",m)),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],v=s[u];if(void 0!==h){h.updateMatrix&&h.updateMatrix();var m=n._createAnimationTracks(h,d,f,p,v);if(m)for(var g=0;g<m.length;g++)l.push(m[g])}}return new Tl(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,Cp)}));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 ua:t.length>1?new mo:1===t.length?t[0]:new ai)!==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),Tp(o,r),r.extensions&&bp(n,o,r),void 0!==r.matrix){var u=new Pn;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 mo;n.name&&(r.name=i.createUniqueName(n.name)),Tp(r,n),n.extensions&&bp(t,r,n);for(var a=n.nodes||[],o=[],l=0,u=a.length;l<u;l++)o.push(i.getDependency("node",a[l]));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=s(i.associations);try{for(r.s();!(t=r.n()).done;){var a=g(t.value,2),o=a[0],l=a[1];(o instanceof Ai||o instanceof Xt)&&n.set(o,l)}}catch(e){r.e(e)}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(yp[r.path]===yp.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(s),yp[r.path]){case yp.weights:a=_l;break;case yp.rotation:a=Ml;break;case yp.position:case yp.scale:a=bl;break;default:if(1===n.itemSize)a=_l;else a=bl}for(var u=void 0!==i.interpolation?_p[i.interpolation]:Ye,c=this._getArrayFromAccessor(n),h=0,d=l.length;h<d;h++){var f=new a(l[h]+"."+yp[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=Rp(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 Ml?hp:up)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}])}();function Ip(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=gp[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 Ft.workingColorSpace!==it&&"COLOR_0"in i&&console.warn('THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "'.concat(Ft.workingColorSpace,'" not supported.')),Tp(e,t),function(e,t,n){var i=t.attributes,r=new an;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 tn(o[0],o[1],o[2]),new tn(s[0],s[1],s[2])),a.normalized){var l=Rp(fp[a.componentType]);r.min.multiplyScalar(l),r.max.multiplyScalar(l)}var u=t.targets;if(void 0!==u){for(var c=new tn,h=new tn,d=0,f=u.length;d<f;d++){var p=u[d];if(void 0!==p.POSITION){var v=n.json.accessors[p.POSITION],m=v.min,g=v.max;if(void 0!==m&&void 0!==g){if(h.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),h.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),h.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),v.normalized){var y=Rp(fp[v.componentType]);h.multiplyScalar(y)}c.max(h)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(c)}e.boundingBox=r;var _=new bn;r.getCenter(_.center),_.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=_}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 v=void 0!==p.POSITION?n.getDependency("accessor",p.POSITION):e.attributes.position;u.push(v)}if(r){var m=void 0!==p.NORMAL?n.getDependency("accessor",p.NORMAL):e.attributes.normal;c.push(m)}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}))}var Pp={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};function Lp(e){return Np.apply(this,arguments)}function Np(){return Np=n(v().mark((function e(t){var n;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:if((n=e.sent).ok){e.next=7;break}throw new Error(n.statusText);case 7:return e.abrupt("return",n.json());case 8:case"end":return e.stop()}}),e)}))),Np.apply(this,arguments)}function Up(e){return Dp.apply(this,arguments)}function Dp(){return(Dp=n(v().mark((function e(t){var n;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error("No basePath supplied");case 2:return e.next=5,Lp("".concat(t,"/").concat("profilesList.json"));case 5:return n=e.sent,e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Op(){return Op=n(v().mark((function e(t,n){var i,r,a,o,s,l,u,c,h=arguments;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=h.length>2&&void 0!==h[2]?h[2]:null,r=!(h.length>3&&void 0!==h[3])||h[3],t){e.next=4;break}throw new Error("No xrInputSource supplied");case 4:if(n){e.next=6;break}throw new Error("No basePath supplied");case 6:return e.next=8,Up(n);case 8:if(a=e.sent,t.profiles.some((function(e){var t=a[e];return t&&(o={profileId:e,profilePath:"".concat(n,"/").concat(t.path),deprecated:!!t.deprecated}),!!o})),o){e.next=17;break}if(i){e.next=13;break}throw new Error("No matching profile name found");case 13:if(s=a[i]){e.next=16;break}throw new Error('No matching profile name found and default profile "'.concat(i,'" missing.'));case 16:o={profileId:i,profilePath:"".concat(n,"/").concat(s.path),deprecated:!!s.deprecated};case 17:return e.next=19,Lp(o.profilePath);case 19:if(l=e.sent,!r){e.next=25;break}if(c="any"===t.handedness?l.layouts[Object.keys(l.layouts)[0]]:l.layouts[t.handedness]){e.next=24;break}throw new Error("No matching handedness, ".concat(t.handedness,", in profile ").concat(o.profileId));case 24:c.assetPath&&(u=o.profilePath.replace("profile.json",c.assetPath));case 25:return e.abrupt("return",{profile:l,assetPath:u});case 26:case"end":return e.stop()}}),e)}))),Op.apply(this,arguments)}var Fp={xAxis:0,yAxis:0,button:0,state:Pp.ComponentState.DEFAULT};var Bp=function(){return o((function e(t){r(this,e),this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===Pp.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(Fp)}),[{key:"updateFromComponent",value:function(e){var t=e.xAxis,n=e.yAxis,i=e.button,r=e.state,a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e,i=t;if(Math.sqrt(e*e+t*t)>1){var r=Math.atan2(t,e);n=Math.cos(r),i=Math.sin(r)}return{normalizedXAxis:.5*n+.5,normalizedYAxis:.5*i+.5}}(t,n),o=a.normalizedXAxis,s=a.normalizedYAxis;switch(this.componentProperty){case Pp.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?o:.5;break;case Pp.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?s:.5;break;case Pp.ComponentProperty.BUTTON:this.value=this.states.includes(r)?i:0;break;case Pp.ComponentProperty.STATE:this.valueNodeProperty===Pp.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error("Unexpected visualResponse componentProperty ".concat(this.componentProperty))}}}])}(),zp=function(){return o((function e(t,n){var i=this;if(r(this,e),!(t&&n&&n.visualResponses&&n.gamepadIndices&&0!==Object.keys(n.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=t,this.type=n.type,this.rootNodeName=n.rootNodeName,this.touchPointNodeName=n.touchPointNodeName,this.visualResponses={},Object.keys(n.visualResponses).forEach((function(e){var t=new Bp(n.visualResponses[e]);i.visualResponses[e]=t})),this.gamepadIndices=Object.assign({},n.gamepadIndices),this.values={state:Pp.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}),[{key:"data",get:function(){return p({id:this.id},this.values)}},{key:"updateFromGamepad",value:function(e){var t=this;if(this.values.state=Pp.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){var n=e.buttons[this.gamepadIndices.button];this.values.button=n.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,n.pressed||1===this.values.button?this.values.state=Pp.ComponentState.PRESSED:(n.touched||this.values.button>Pp.ButtonTouchThreshold)&&(this.values.state=Pp.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Pp.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Pp.AxisTouchThreshold&&(this.values.state=Pp.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Pp.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Pp.AxisTouchThreshold&&(this.values.state=Pp.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((function(e){e.updateFromComponent(t.values)}))}}])}(),Hp=function(){return o((function e(t,n,i){var a=this;if(r(this,e),!t)throw new Error("No xrInputSource supplied");if(!n)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=n.profileId,this.layoutDescription=n.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((function(e){var t=a.layoutDescription.components[e];a.components[e]=new zp(e,t)})),this.updateFromGamepad()}),[{key:"gripSpace",get:function(){return this.xrInputSource.gripSpace}},{key:"targetRaySpace",get:function(){return this.xrInputSource.targetRaySpace}},{key:"data",get:function(){var e=[];return Object.values(this.components).forEach((function(t){e.push(t.data)})),e}},{key:"updateFromGamepad",value:function(){var e=this;Object.values(this.components).forEach((function(t){t.updateFromGamepad(e.xrInputSource.gamepad)}))}}])}(),Vp=function(e){function t(){var e;return r(this,t),(e=i(this,t)).motionController=null,e.envMap=null,e}return h(t,e),o(t,[{key:"setEnvironmentMap",value:function(e){var t=this;return this.envMap==e||(this.envMap=e,this.traverse((function(e){e.isMesh&&(e.material.envMap=t.envMap,e.material.needsUpdate=!0)}))),this}},{key:"updateMatrixWorld",value:function(e){y(t,"updateMatrixWorld",this)([e]),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((function(e){Object.values(e.visualResponses).forEach((function(e){var t=e.valueNode,n=e.minNode,i=e.maxNode,r=e.value,a=e.valueNodeProperty;t&&(a===Pp.VisualResponseProperty.VISIBILITY?t.visible=r:a===Pp.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(n.quaternion,i.quaternion,r),t.position.lerpVectors(n.position,i.position,r)))}))})))}}])}(ai);function Gp(e,t){!function(e,t){Object.values(e.components).forEach((function(e){var n=e.type,i=e.touchPointNodeName,r=e.visualResponses;if(n===Pp.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){var a=new zs(.001),o=new Ri({color:255}),s=new hr(a,o);e.touchPointNode.add(s)}else console.warn("Could not find touch dot, ".concat(e.touchPointNodeName,", in touchpad component ").concat(e.id));Object.values(r).forEach((function(e){var n=e.valueNodeName,i=e.minNodeName,r=e.maxNodeName;if(e.valueNodeProperty===Pp.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(r),!e.minNode)return void console.warn("Could not find ".concat(i," in the model"));if(!e.maxNode)return void console.warn("Could not find ".concat(r," in the model"))}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn("Could not find ".concat(n," in the model"))}))}))}(e.motionController,t),e.envMap&&t.traverse((function(t){t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}var Wp=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;r(this,e),this.gltfLoader=t,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.onLoad=n,this.gltfLoader||(this.gltfLoader=new Uf)}),[{key:"setPath",value:function(e){return this.path=e,this}},{key:"createControllerModel",value:function(e){var t=this,n=new Vp,i=null;return e.addEventListener("connected",(function(e){var r=e.data;"tracked-pointer"===r.targetRayMode&&r.gamepad&&!r.hand&&function(e,t){return Op.apply(this,arguments)}(r,t.path,"generic-trigger").then((function(e){var a=e.profile,o=e.assetPath;n.motionController=new Hp(r,a,o);var s=t._assetCache[n.motionController.assetUrl];if(s)i=s.scene.clone(),Gp(n,i),t.onLoad&&t.onLoad(i);else{if(!t.gltfLoader)throw new Error("GLTFLoader not set.");t.gltfLoader.setPath(""),t.gltfLoader.load(n.motionController.assetUrl,(function(e){t._assetCache[n.motionController.assetUrl]=e,i=e.scene.clone(),Gp(n,i),t.onLoad&&t.onLoad(i)}),null,(function(){throw new Error("Asset ".concat(n.motionController.assetUrl," missing or malformed."))}))}})).catch((function(e){console.warn(e)}))})),e.addEventListener("disconnected",(function(){n.motionController=null,n.remove(i),i=null})),n}}])}(),jp=new Pn,Xp=new tn,qp=function(){return o((function e(t,n,i,a,o){var s;r(this,e),this.controller=n,this.handModel=t,this.envMap=null,o&&o.primitive&&"sphere"!==o.primitive?"box"===o.primitive&&(s=new fr(1,1,1)):s=new zs(1,10,10);var l=new Ks;this.handMesh=new Sa(s,l,30),this.handMesh.frustumCulled=!1,this.handMesh.instanceMatrix.setUsage(35048),this.handMesh.castShadow=!0,this.handMesh.receiveShadow=!0,this.handModel.add(this.handMesh),this.joints=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"]}),[{key:"updateMesh",value:function(){for(var e=this.controller.joints,t=0,n=0;n<this.joints.length;n++){var i=e[this.joints[n]];i.visible&&(Xp.setScalar(i.jointRadius||.008),jp.compose(i.position,i.quaternion,Xp),this.handMesh.setMatrixAt(n,jp),t++)}this.handMesh.count=t,this.handMesh.instanceMatrix.needsUpdate=!0}}])}(),Yp=function(){return o((function e(t,n,i,a){var o=this,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;r(this,e),this.controller=n,this.handModel=t,this.bones=[],null===s&&(s=new Uf).setPath(i||"https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/"),s.load("".concat(a,".glb"),(function(e){var t=e.scene.children[0];o.handModel.add(t);var n=t.getObjectByProperty("type","SkinnedMesh");n.frustumCulled=!1,n.castShadow=!0,n.receiveShadow=!0;["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"].forEach((function(e){var n=t.getObjectByName(e);void 0!==n?n.jointName=e:console.warn("Couldn't find ".concat(e," in ").concat(a," hand mesh")),o.bones.push(n)})),l&&l(t)}))}),[{key:"updateMesh",value:function(){for(var e=this.controller.joints,t=0;t<this.bones.length;t++){var n=this.bones[t];if(n){var i=e[n.jointName];if(i.visible){var r=i.position;n.position.copy(r),n.quaternion.copy(i.quaternion)}}}}}])}(),Zp=function(e){function t(e){var n;return r(this,t),(n=i(this,t)).controller=e,n.motionController=null,n.envMap=null,n.mesh=null,n}return h(t,e),o(t,[{key:"updateMatrixWorld",value:function(e){y(t,"updateMatrixWorld",this)([e]),this.motionController&&this.motionController.updateMesh()}}])}(ai),Kp=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;r(this,e),this.gltfLoader=t,this.path=null,this.onLoad=n}),[{key:"setPath",value:function(e){return this.path=e,this}},{key:"createHandModel",value:function(e,t){var n=this,i=new Zp(e);return e.addEventListener("connected",(function(r){var a=r.data;a.hand&&!i.motionController&&(i.xrInputSource=a,void 0===t||"spheres"===t?i.motionController=new qp(i,e,n.path,a.handedness,{primitive:"sphere"}):"boxes"===t?i.motionController=new qp(i,e,n.path,a.handedness,{primitive:"box"}):"mesh"===t&&(i.motionController=new Yp(i,e,n.path,a.handedness,n.gltfLoader,n.onLoad))),e.visible=!0})),e.addEventListener("disconnected",(function(){e.visible=!1})),i}}])}();return window.THREEX={XRControllerModelFactory:Wp,XRHandModelFactory:Kp},Lf}));
//# sourceMappingURL=three.umd.js.map
