From ad7c7d505324a5f5c3f8f02a4af58a024c0ee82d Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Thu, 11 Oct 2018 04:26:22 -0400 Subject: [PATCH] Updates --- app.js | 88 +++++++++++++++++++++++++++--------------------------- index.html | 1 + 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/app.js b/app.js index 229d014..81deb2b 100644 --- a/app.js +++ b/app.js @@ -1,52 +1,52 @@ -!function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},r={},i={},n={}.hasOwnProperty,a=/^\.\.?(\/|$)/,o=function(e,t){for(var r,i=[],n=(a.test(t)?e+"/"+t:t).split("/"),o=0,s=n.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function r(e){var r=t(e),i=r[0],n=r[1];return 3*(i+n)/4-n}function i(e,t,r){return 3*(t+r)/4-r}function n(e){for(var r,n=t(e),a=n[0],o=n[1],s=new u(i(e,a,o)),l=0,h=o>0?a-4:a,d=0;d>16&255,s[l++]=r>>8&255,s[l++]=255&r;return 2===o&&(r=c[e.charCodeAt(d)]<<2|c[e.charCodeAt(d+1)]>>4,s[l++]=255&r),1===o&&(r=c[e.charCodeAt(d)]<<10|c[e.charCodeAt(d+1)]<<4|c[e.charCodeAt(d+2)]>>2,s[l++]=r>>8&255,s[l++]=255&r),s}function a(e){return l[e>>18&63]+l[e>>12&63]+l[e>>6&63]+l[63&e]}function o(e,t,r){for(var i,n=[],o=t;oc?c:s+a));return 1===i?(t=e[r-1],n.push(l[t>>2]+l[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],n.push(l[t>>10]+l[t>>4&63]+l[t<<2&63]+"=")),n.join("")}e.byteLength=r,e.toByteArray=n,e.fromByteArray=s;for(var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=h.length;d1?arguments[1]:"utf8"):l(this,e)):arguments.length>1?new a(e,arguments[1]):new a(e)}function o(e,t){if(e=m(e,t<0?0:0|v(t)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;r>>1;return r&&(e.parent=Z),e}function v(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function g(e,t){if(!(this instanceof g))return new g(e,t);var r=new a(e,t);return delete r.parent,r}function y(e,t){"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(i)return G(e).length;t=(""+t).toLowerCase(),i=!0}}function x(e,t,r){var i=!1;if(t=0|t,r=void 0===r||r===1/0?this.length:0|r,e||(e="utf8"),t<0&&(t=0),r>this.length&&(r=this.length),r<=t)return"";for(;;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return L(this,t,r);case"binary":return P(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function b(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(n+s<=r){var l,c,u,h;switch(s){case 1:a<128&&(o=a);break;case 2:l=e[n+1],128===(192&l)&&(h=(31&a)<<6|63&l,h>127&&(o=h));break;case 3:l=e[n+1],c=e[n+2],128===(192&l)&&128===(192&c)&&(h=(15&a)<<12|(63&l)<<6|63&c,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:l=e[n+1],c=e[n+2],u=e[n+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(h=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,h>65535&&h<1114112&&(o=h))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return C(i)}function C(e){var t=e.length;if(t<=K)return String.fromCharCode.apply(String,e);for(var r="",i=0;ii)&&(r=i);for(var n="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,r,i,n,o){if(!a.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>n||te.length)throw new RangeError("index out of range")}function I(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-r,2);n>>8*(i?n:1-n)}function R(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-r,4);n>>8*(i?n:3-n)&255}function U(e,t,r,i,n,a){if(t>n||te.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function k(e,t,r,i,n){return n||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(e,t,r,i,23,4),r+4}function B(e,t,r,i,n){return n||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(e,t,r,i,52,8),r+8}function z(e){if(e=j(e).replace($,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function j(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function G(e,t){t=t||1/0;for(var r,i=e.length,n=null,a=[],o=0;o55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function W(e){for(var t=[],r=0;r>8,n=r%256,a.push(n),a.push(i);return a}function H(e){return q.toByteArray(z(e))}function Y(e,t,r,i){for(var n=0;n=t.length||n>=e.length);n++)t[n+r]=e[n];return n}var q=i("base64-js"),Q=i("ieee754"),J=i("isarray");e.Buffer=a,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,a.poolSize=8192;var Z={};a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),a._augment=function(e){return e.__proto__=a.prototype,e},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},a.prototype.compare=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:a.compare(this,e)},a.prototype.indexOf=function(e,t){function r(e,t,r){for(var i=-1,n=0;r+n2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(t<0&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(a.isBuffer(e))return r(this,e,t);if("number"==typeof e)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(r)?(r=0|r,void 0===i&&(i="utf8")):(i=r,r=void 0);else{var n=i;i=t,t=0|r,r=n}var a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return _(this,e,t,r);case"binary":return S(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;a.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t0&&(n*=256);)i+=this[e+--t]*n;return i},a.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||D(e,t,this.length);for(var i=this[e],n=1,a=0;++a=n&&(i-=Math.pow(2,8*t)),i},a.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||D(e,t,this.length);for(var i=t,n=1,a=this[e+--i];i>0&&(n*=256);)a+=this[e+--i]*n;return n*=128,a>=n&&(a-=Math.pow(2,8*t)),a},a.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),Q.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),Q.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),Q.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),Q.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,i){e=+e,t=0|t,r=0|r,i||F(this,e,t,r,Math.pow(2,8*r),0);var n=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+n]=e/a&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);F(this,e,t,r,n-1,-n)}var a=0,o=1,s=e<0?1:0;for(this[t]=255&e;++a>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);F(this,e,t,r,n-1,-n)}var a=r-1,o=1,s=e<0?1:0;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=(e/o>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;n--)e[n+t]=this[n+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(n=0;n=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof e)for(i=t;i=0;i--)r=[e[i].apply(this,r)];return r[0]}},each:function(t,r,i){if(e&&t.forEach===e)t.forEach(r,i);else if(t.length===t.length+0){for(var n=0,a=t.length;n1?t.toArray(arguments):arguments[0];return t.each(a,function(n){if(n.litmus(e))return t.each(n.conversions,function(n,a){if(r=n.read(e),i===!1&&r!==!1)return i=r,r.conversionName=a,r.conversion=n,t.BREAK}),t.BREAK}),i},a=[{litmus:t.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString())}},write:e},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:e},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:e}}},{litmus:t.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:t.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:t.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b)&&t.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v)&&t.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}];return n}(e.color.toString,e.utils.common),e.color.math=function(){var e;return{hsv_to_rgb:function(e,t,r){var i=Math.floor(e/60)%6,n=e/60-Math.floor(e/60),a=r*(1-t),o=r*(1-n*t),s=r*(1-(1-n)*t),l=[[r,s,a],[o,r,a],[a,r,s],[a,o,r],[s,a,r],[r,a,o]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,r){var i,n,a=Math.min(e,t,r),o=Math.max(e,t,r),s=o-a;return 0==o?{h:NaN,s:0,v:0}:(n=s/o,i=e==o?(t-r)/s:t==o?2+(r-e)/s:4+(e-t)/s,i/=6,i<0&&(i+=1),{h:360*i,s:n,v:o/255})},rgb_to_hex:function(e,t,r){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),i=this.hex_with_component(i,0,r)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(t,r,i){return i<<(e=8*r)|t&~(255<=0;i--)r=[e[i].apply(this,r)];return r[0]}},each:function(t,r,i){if(e&&t.forEach===e)t.forEach(r,i);else if(t.length===t.length+0){for(var n=0,a=t.length;n-1?e.length-e.indexOf(".")-1:0}var i=function(e,n,a){i.superclass.call(this,e,n),a=a||{},this.__min=a.min,this.__max=a.max,this.__step=a.step,t.isUndefined(this.__step)?0==this.initialValue?this.__impliedStep=1:this.__impliedStep=Math.pow(10,Math.floor(Math.log(this.initialValue)/Math.LN10))/10:this.__impliedStep=this.__step,this.__precision=r(this.__impliedStep)};return i.superclass=e,t.extend(i.prototype,e.prototype,{setValue:function(e){return void 0!==this.__min&&ethis.__max&&(e=this.__max),void 0!==this.__step&&e%this.__step!=0&&(e=Math.round(e/this.__step)*this.__step),i.superclass.prototype.setValue.call(this,e)},min:function(e){return this.__min=e,this},max:function(e){return this.__max=e,this},step:function(e){return this.__step=e,this}}),i}(e.controllers.Controller,e.utils.common),e.controllers.NumberControllerBox=function(e,t,r){function i(e,t){var r=Math.pow(10,t);return Math.round(e*r)/r}var n=function(e,i,a){function o(){var e=parseFloat(d.__input.value);r.isNaN(e)||d.setValue(e)}function s(){o(),d.__onFinishChange&&d.__onFinishChange.call(d,d.getValue())}function l(e){t.bind(window,"mousemove",c),t.bind(window,"mouseup",u),h=e.clientY}function c(e){var t=h-e.clientY;d.setValue(d.getValue()+t*d.__impliedStep),h=e.clientY}function u(){t.unbind(window,"mousemove",c),t.unbind(window,"mouseup",u)}this.__truncationSuspended=!1,n.superclass.call(this,e,i,a);var h,d=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),t.bind(this.__input,"change",o),t.bind(this.__input,"blur",s),t.bind(this.__input,"mousedown",l),t.bind(this.__input,"keydown",function(e){13===e.keyCode&&(d.__truncationSuspended=!0,this.blur(),d.__truncationSuspended=!1)}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return n.superclass=e,r.extend(n.prototype,e.prototype,{updateDisplay:function(){return this.__input.value=this.__truncationSuspended?this.getValue():i(this.getValue(),this.__precision),n.superclass.prototype.updateDisplay.call(this)}}),n}(e.controllers.NumberController,e.dom.dom,e.utils.common),e.controllers.NumberControllerSlider=function(e,t,r,i,n){function a(e,t,r,i,n){return i+(n-i)*((e-t)/(r-t))}var o=function(e,r,i,n,s){function l(e){t.bind(window,"mousemove",c),t.bind(window,"mouseup",u),c(e)}function c(e){e.preventDefault();var r=t.getOffset(h.__background),i=t.getWidth(h.__background);return h.setValue(a(e.clientX,r.left,r.left+i,h.__min,h.__max)),!1}function u(){t.unbind(window,"mousemove",c),t.unbind(window,"mouseup",u),h.__onFinishChange&&h.__onFinishChange.call(h,h.getValue())}o.superclass.call(this,e,r,{min:i,max:n,step:s});var h=this;this.__background=document.createElement("div"),this.__foreground=document.createElement("div"),t.bind(this.__background,"mousedown",l),t.addClass(this.__background,"slider"),t.addClass(this.__foreground,"slider-fg"),this.updateDisplay(),this.__background.appendChild(this.__foreground),this.domElement.appendChild(this.__background)};return o.superclass=e,o.useDefaultStyles=function(){r.inject(n)},i.extend(o.prototype,e.prototype,{updateDisplay:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",o.superclass.prototype.updateDisplay.call(this)}}),o}(e.controllers.NumberController,e.dom.dom,e.utils.css,e.utils.common,".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"),e.controllers.FunctionController=function(e,t,r){var i=function(e,r,n){i.superclass.call(this,e,r);var a=this;this.__button=document.createElement("div"),this.__button.innerHTML=void 0===n?"Fire":n,t.bind(this.__button,"click",function(e){return e.preventDefault(),a.fire(),!1}),t.addClass(this.__button,"button"),this.domElement.appendChild(this.__button)};return i.superclass=e,r.extend(i.prototype,e.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.getValue().call(this.object)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.controllers.BooleanController=function(e,t,r){var i=function(e,r){function n(){a.setValue(!a.__prev)}i.superclass.call(this,e,r);var a=this;this.__prev=this.getValue(),this.__checkbox=document.createElement("input"),this.__checkbox.setAttribute("type","checkbox"),t.bind(this.__checkbox,"change",n,!1),this.domElement.appendChild(this.__checkbox),this.updateDisplay()};return i.superclass=e,r.extend(i.prototype,e.prototype,{setValue:function(e){var t=i.superclass.prototype.setValue.call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),t},updateDisplay:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0):this.__checkbox.checked=!1,i.superclass.prototype.updateDisplay.call(this)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.color.toString=function(e){return function(t){if(1==t.a||e.isUndefined(t.a)){for(var r=t.hex.toString(16);r.length<6;)r="0"+r;return"#"+r}return"rgba("+Math.round(t.r)+","+Math.round(t.g)+","+Math.round(t.b)+","+t.a+")"}}(e.utils.common),e.color.interpret=function(e,t){var r,i,n=function(){i=!1;var e=arguments.length>1?t.toArray(arguments):arguments[0];return t.each(a,function(n){if(n.litmus(e))return t.each(n.conversions,function(n,a){if(r=n.read(e),i===!1&&r!==!1)return i=r,r.conversionName=a,r.conversion=n,t.BREAK}),t.BREAK}),i},a=[{litmus:t.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString())}},write:e},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:e},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:e}}},{litmus:t.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:t.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:t.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b)&&t.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v)&&t.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}];return n}(e.color.toString,e.utils.common),e.GUI=e.gui.GUI=function(e,t,r,i,n,a,o,s,l,c,u,h,d,p,f){function m(e,t,r,a){if(void 0===t[r])throw new Error("Object "+t+' has no property "'+r+'"');var o;if(a.color)o=new u(t,r);else{var s=[t,r].concat(a.factoryArgs);o=i.apply(e,s)}a.before instanceof n&&(a.before=a.before.__li),y(e,o),p.addClass(o.domElement,"c");var l=document.createElement("span");p.addClass(l,"property-name"),l.innerHTML=o.property;var c=document.createElement("div");c.appendChild(l),c.appendChild(o.domElement);var h=v(e,c,a.before);return p.addClass(h,k.CLASS_CONTROLLER_ROW),p.addClass(h,typeof o.getValue()),g(e,h,o),e.__controllers.push(o),o}function v(e,t,r){var i=document.createElement("li");return t&&i.appendChild(t),r?e.__ul.insertBefore(i,params.before):e.__ul.appendChild(i),e.onResize(),i}function g(e,t,r){if(r.__li=t,r.__gui=e,f.extend(r,{options:function(t){return arguments.length>1?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[f.toArray(arguments)]})):f.isArray(t)||f.isObject(t)?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[t]})):void 0},name:function(e){return r.__li.firstElementChild.firstElementChild.innerHTML=e,r},listen:function(){return r.__gui.listen(r),r},remove:function(){return r.__gui.remove(r),r}}),r instanceof l){var i=new s(r.object,r.property,{min:r.__min,max:r.__max,step:r.__step});f.each(["updateDisplay","onChange","onFinishChange"],function(e){var t=r[e],n=i[e];r[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return t.apply(r,e),n.apply(i,e)}}),p.addClass(t,"has-slider"),r.domElement.insertBefore(i.domElement,r.domElement.firstElementChild)}else if(r instanceof s){var n=function(t){return f.isNumber(r.__min)&&f.isNumber(r.__max)?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[r.__min,r.__max,r.__step]})):t};r.min=f.compose(n,r.min),r.max=f.compose(n,r.max)}else r instanceof a?(p.bind(t,"click",function(){p.fakeEvent(r.__checkbox,"click")}),p.bind(r.__checkbox,"click",function(e){e.stopPropagation()})):r instanceof o?(p.bind(t,"click",function(){p.fakeEvent(r.__button,"click")}),p.bind(t,"mouseover",function(){p.addClass(r.__button,"hover")}),p.bind(t,"mouseout",function(){p.removeClass(r.__button,"hover")})):r instanceof u&&(p.addClass(t,"color"),r.updateDisplay=f.compose(function(e){return t.style.borderLeftColor=r.__color.toString(),e},r.updateDisplay),r.updateDisplay());r.setValue=f.compose(function(t){return e.getRoot().__preset_select&&r.isModified()&&T(e.getRoot(),!0),t},r.setValue)}function y(e,t){var r=e.getRoot(),i=r.__rememberedObjects.indexOf(t.object);if(i!=-1){var n=r.__rememberedObjectIndecesToControllers[i];if(void 0===n&&(n={},r.__rememberedObjectIndecesToControllers[i]=n),n[t.property]=t,r.load&&r.load.remembered){var a,o=r.load.remembered;if(o[e.preset])a=o[e.preset];else{if(!o[D])return;a=o[D]}if(a[i]&&void 0!==a[i][t.property]){var s=a[i][t.property];t.initialValue=s,t.setValue(s)}}}}function x(e,t){return document.location.href+"."+t}function b(e){function t(){c.style.display=e.useLocalStorage?"block":"none"}var r=e.__save_row=document.createElement("li");p.addClass(e.domElement,"has-save"),e.__ul.insertBefore(r,e.__ul.firstChild),p.addClass(r,"save-row");var i=document.createElement("span");i.innerHTML=" ",p.addClass(i,"button gears");var n=document.createElement("span");n.innerHTML="Save",p.addClass(n,"button"),p.addClass(n,"save");var a=document.createElement("span");a.innerHTML="New",p.addClass(a,"button"),p.addClass(a,"save-as");var o=document.createElement("span");o.innerHTML="Revert",p.addClass(o,"button"),p.addClass(o,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?f.each(e.load.remembered,function(t,r){A(e,r,r==e.preset)}):A(e,D,!1),p.bind(s,"change",function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=S(this)),e.folders={},f.each(this.__folders,function(t,r){e.folders[r]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=S(this),T(this,!1)},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[D]=S(this,!0)),this.load.remembered[e]=S(this),this.preset=e,A(this,e,!0)},revert:function(e){f.each(this.__controllers,function(t){this.getRoot().load.remembered?y(e||this.getRoot(),t):t.setValue(t.initialValue)},this),f.each(this.__folders,function(e){e.revert(e)}),e||T(this.getRoot(),!1)},listen:function(e){var t=0==this.__listening.length;this.__listening.push(e),t&&E(this.__listening)}}),k}(e.utils.css,'
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
',".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n",e.controllers.factory=function(e,t,r,i,n,a,o){return function(s,l){var c=s[l];return o.isArray(arguments[2])||o.isObject(arguments[2])?new e(s,l,arguments[2]):o.isNumber(c)?o.isNumber(arguments[2])&&o.isNumber(arguments[3])?new r(s,l,arguments[2],arguments[3]):new t(s,l,{min:arguments[2],max:arguments[3]}):o.isString(c)?new i(s,l):o.isFunction(c)?new n(s,l,""):o.isBoolean(c)?new a(s,l):void 0}}(e.controllers.OptionController,e.controllers.NumberControllerBox,e.controllers.NumberControllerSlider,e.controllers.StringController=function(e,t,r){var i=function(e,r){function n(){o.setValue(o.__input.value)}function a(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}i.superclass.call(this,e,r);var o=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),t.bind(this.__input,"keyup",n),t.bind(this.__input,"change",n),t.bind(this.__input,"blur",a),t.bind(this.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return i.superclass=e,r.extend(i.prototype,e.prototype,{updateDisplay:function(){return t.isActive(this.__input)||(this.__input.value=this.getValue()),i.superclass.prototype.updateDisplay.call(this)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.controllers.FunctionController,e.controllers.BooleanController,e.utils.common),e.controllers.Controller,e.controllers.BooleanController,e.controllers.FunctionController,e.controllers.NumberControllerBox,e.controllers.NumberControllerSlider,e.controllers.OptionController,e.controllers.ColorController=function(e,t,r,i,n){function a(e,t,r,i){e.style.background="",n.each(l,function(n){e.style.cssText+="background: "+n+"linear-gradient("+t+", "+r+" 0%, "+i+" 100%); "})}function o(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var s=function(e,l){function c(e){p(e),t.bind(window,"mousemove",p),t.bind(window,"mouseup",u)}function u(){t.unbind(window,"mousemove",p),t.unbind(window,"mouseup",u)}function h(){var e=i(this.value);e!==!1?(m.__color.__state=e,m.setValue(m.__color.toOriginal())):this.value=m.__color.toString()}function d(){t.unbind(window,"mousemove",f),t.unbind(window,"mouseup",d)}function p(e){e.preventDefault();var r=t.getWidth(m.__saturation_field),i=t.getOffset(m.__saturation_field),n=(e.clientX-i.left+document.body.scrollLeft)/r,a=1-(e.clientY-i.top+document.body.scrollTop)/r;return a>1?a=1:a<0&&(a=0),n>1?n=1:n<0&&(n=0),m.__color.v=a,m.__color.s=n,m.setValue(m.__color.toOriginal()),!1}function f(e){e.preventDefault();var r=t.getHeight(m.__hue_field),i=t.getOffset(m.__hue_field),n=1-(e.clientY-i.top+document.body.scrollTop)/r;return n>1?n=1:n<0&&(n=0),m.__color.h=360*n,m.setValue(m.__color.toOriginal()),!1}s.superclass.call(this,e,l),this.__color=new r(this.getValue()),this.__temp=new r(0);var m=this;this.domElement=document.createElement("div"),t.makeSelectable(this.domElement,!1),this.__selector=document.createElement("div"),this.__selector.className="selector",this.__saturation_field=document.createElement("div"),this.__saturation_field.className="saturation-field",this.__field_knob=document.createElement("div"),this.__field_knob.className="field-knob",this.__field_knob_border="2px solid ",this.__hue_knob=document.createElement("div"),this.__hue_knob.className="hue-knob",this.__hue_field=document.createElement("div"), -this.__hue_field.className="hue-field",this.__input=document.createElement("input"),this.__input.type="text",this.__input_textShadow="0 1px 1px ",t.bind(this.__input,"keydown",function(e){13===e.keyCode&&h.call(this)}),t.bind(this.__input,"blur",h),t.bind(this.__selector,"mousedown",function(e){t.addClass(this,"drag").bind(window,"mouseup",function(e){t.removeClass(m.__selector,"drag")})});var v=document.createElement("div");n.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),n.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),n.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),n.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),n.extend(v.style,{width:"100%",height:"100%",background:"none"}),a(v,"top","rgba(0,0,0,0)","#000"),n.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"}),o(this.__hue_field),n.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"}),t.bind(this.__saturation_field,"mousedown",c),t.bind(this.__field_knob,"mousedown",c),t.bind(this.__hue_field,"mousedown",function(e){f(e),t.bind(window,"mousemove",f),t.bind(window,"mouseup",d)}),this.__saturation_field.appendChild(v),this.__selector.appendChild(this.__field_knob),this.__selector.appendChild(this.__saturation_field),this.__selector.appendChild(this.__hue_field),this.__hue_field.appendChild(this.__hue_knob),this.domElement.appendChild(this.__input),this.domElement.appendChild(this.__selector),this.updateDisplay()};s.superclass=e,n.extend(s.prototype,e.prototype,{updateDisplay:function(){var e=i(this.getValue());if(e!==!1){var t=!1;n.each(r.COMPONENTS,function(r){if(!n.isUndefined(e[r])&&!n.isUndefined(this.__color.__state[r])&&e[r]!==this.__color.__state[r])return t=!0,{}},this),t&&n.extend(this.__color.__state,e)}n.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var o=this.__color.v<.5||this.__color.s>.5?255:0,s=255-o;n.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+"rgb("+o+","+o+","+o+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,a(this.__saturation_field,"left","#fff",this.__temp.toString()),n.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+o+","+o+","+o+")",textShadow:this.__input_textShadow+"rgba("+s+","+s+","+s+",.7)"})}});var l=["-moz-","-o-","-webkit-","-ms-",""];return s}(e.controllers.Controller,e.dom.dom,e.color.Color=function(e,t,r,i){function n(e,t,r){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space?this.__state[t]:(o(this,t,r),this.__state[t])},set:function(e){"RGB"!==this.__state.space&&(o(this,t,r),this.__state.space="RGB"),this.__state[t]=e}})}function a(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space?this.__state[t]:(s(this),this.__state[t])},set:function(e){"HSV"!==this.__state.space&&(s(this),this.__state.space="HSV"),this.__state[t]=e}})}function o(e,r,n){if("HEX"===e.__state.space)e.__state[r]=t.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw"Corrupted color state";i.extend(e.__state,t.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}}function s(e){var r=t.rgb_to_hsv(e.r,e.g,e.b);i.extend(e.__state,{s:r.s,v:r.v}),i.isNaN(r.h)?i.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=r.h}var l=function(){if(this.__state=e.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return l.COMPONENTS=["r","g","b","h","s","v","hex","a"],i.extend(l.prototype,{toString:function(){return r(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),n(l.prototype,"r",2),n(l.prototype,"g",1),n(l.prototype,"b",0),a(l.prototype,"h"),a(l.prototype,"s"),a(l.prototype,"v"),Object.defineProperty(l.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(l.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=t.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}}),l}(e.color.interpret,e.color.math=function(){var e;return{hsv_to_rgb:function(e,t,r){var i=Math.floor(e/60)%6,n=e/60-Math.floor(e/60),a=r*(1-t),o=r*(1-n*t),s=r*(1-(1-n)*t),l=[[r,s,a],[o,r,a],[a,r,s],[a,o,r],[s,a,r],[r,a,o]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,r){var i,n,a=Math.min(e,t,r),o=Math.max(e,t,r),s=o-a;return 0==o?{h:NaN,s:0,v:0}:(n=s/o,i=e==o?(t-r)/s:t==o?2+(r-e)/s:4+(e-t)/s,i/=6,i<0&&(i+=1),{h:360*i,s:n,v:o/255})},rgb_to_hex:function(e,t,r){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),i=this.hex_with_component(i,0,r)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(t,r,i){return i<<(e=8*r)|t&~(255<>1,u=-7,h=r?n-1:0,d=r?-1:1,p=e[t+h];for(h+=d,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+e[t+h],h+=d,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=i;u>0;o=256*o+e[t+h],h+=d,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),a-=c}return(p?-1:1)*o*Math.pow(2,a-i)},e.write=function(e,t,r,i,n,a){var o,s,l,c=8*a-n-1,u=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),t+=o+h>=1?d/l:d*Math.pow(2,1-h),t*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(t*l-1)*Math.pow(2,n),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),o=0));n>=8;e[r+p]=255&s,p+=f,s/=256,n-=8);for(o=o<0;e[r+p]=255&o,p+=f,o/=256,c-=8);e[r+p-f]|=128*m}}()}),require.register("isarray/index.js",function(e,t,i){t=r(t,{},"isarray"),function(){var e={}.toString;i.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}}()}),require.register("process/browser.js",function(e,t,i){t=r(t,{},"process"),function(){function e(){throw new Error("setTimeout has not been defined")}function t(){throw new Error("clearTimeout has not been defined")}function r(t){if(c===setTimeout)return setTimeout(t,0);if((c===e||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(r){try{return c.call(null,t,0)}catch(r){return c.call(this,t,0)}}}function n(e){if(u===clearTimeout)return clearTimeout(e);if((u===t||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch(r){try{return u.call(null,e)}catch(r){return u.call(this,e)}}}function a(){f&&d&&(f=!1,d.length?p=d.concat(p):m=-1,p.length&&o())}function o(){if(!f){var e=r(a);f=!0;for(var t=p.length;t;){for(d=p,p=[];++m1)for(var i=1;i0&&console.error("Matrix4: the constructor no longer reads arguments. use .set() instead.")}function i(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0}function n(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==i?i:1}function a(){}function o(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._order=i||o.DefaultOrder}function s(){this.mask=1}function l(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("Matrix3: the constructor no longer reads arguments. use .set() instead.")}function c(){function e(){h.setFromEuler(u,!1)}function t(){u.setFromQuaternion(h,void 0,!1)}Object.defineProperty(this,"id",{value:Is++}),this.uuid=Fs.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DefaultUp.clone();var a=new i,u=new o,h=new n,d=new i(1,1,1);u.onChange(e),h.onChange(t),Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:u},quaternion:{enumerable:!0,value:h},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new r},normalMatrix:{value:new l}}),this.matrix=new r,this.matrixWorld=new r,this.matrixAutoUpdate=c.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new s,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function u(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}function h(e,t,r,n,a,o){this.a=e,this.b=t,this.c=r,this.normal=n&&n.isVector3?n:new i,this.vertexNormals=Array.isArray(n)?n:[],this.color=a&&a.isColor?a:new u,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=void 0!==o?o:0}function d(e,t){this.min=void 0!==e?e:new i((+(1/0)),(+(1/0)),(+(1/0))),this.max=void 0!==t?t:new i((-(1/0)),(-(1/0)),(-(1/0)))}function p(e,t){this.center=void 0!==e?e:new i,this.radius=void 0!==t?t:0}function f(e,t){this.x=e||0,this.y=t||0}function m(){Object.defineProperty(this,"id",{value:Us+=2}),this.uuid=Fs.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function v(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1}function g(e,t,r){if(Array.isArray(e))throw new TypeError("BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=r===!0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function y(e,t,r){g.call(this,new Int8Array(e),t,r)}function x(e,t,r){g.call(this,new Uint8Array(e),t,r)}function b(e,t,r){g.call(this,new Uint8ClampedArray(e),t,r)}function w(e,t,r){g.call(this,new Int16Array(e),t,r)}function _(e,t,r){g.call(this,new Uint16Array(e),t,r)}function S(e,t,r){g.call(this,new Int32Array(e),t,r)}function A(e,t,r){g.call(this,new Uint32Array(e),t,r)}function M(e,t,r){g.call(this,new Float32Array(e),t,r)}function T(e,t,r){g.call(this,new Float64Array(e),t,r)}function E(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function C(e){if(0===e.length)return 1/0;for(var t=e[0],r=1,i=e.length;rt&&(t=e[r]);return t}function P(){Object.defineProperty(this,"id",{value:ks+=2}),this.uuid=Fs.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function N(e,t,r,i,n,a,o){m.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:n,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new O(e,t,r,i,n,a,o)),this.mergeVertices()}function O(e,t,r,n,a,o,s){P.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:n,phiLength:a,thetaStart:o,thetaLength:s},e=e||1,t=Math.max(3,Math.floor(t)||8),r=Math.max(2,Math.floor(r)||6),n=void 0!==n?n:0,a=void 0!==a?a:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;var l,c,u=o+s,h=0,d=[],p=new i,f=new i,m=[],v=[],g=[],y=[];for(c=0;c<=r;c++){var x=[],b=c/r;for(l=0;l<=t;l++){var w=l/t;p.x=-e*Math.cos(n+w*a)*Math.sin(o+b*s),p.y=e*Math.cos(o+b*s),p.z=e*Math.sin(n+w*a)*Math.sin(o+b*s),v.push(p.x,p.y,p.z),f.set(p.x,p.y,p.z).normalize(),g.push(f.x,f.y,f.z),y.push(w,1-b),x.push(h++)}d.push(x)}for(c=0;c0)&&m.push(_,S,T),(c!==r-1||u0?1:-1,h.push(P.x,P.y,P.z),d.push(x/v),d.push(1-b/g),C+=1}}for(b=0;b0&&u(!0),t>0&&u(!1)),this.setIndex(d),this.addAttribute("position",new M(p,3)),this.addAttribute("normal",new M(m,3)),this.addAttribute("uv",new M(v,2))}function he(){c.call(this),this.type="Camera",this.matrixWorldInverse=new r,this.projectionMatrix=new r,this.projectionMatrixInverse=new r}function de(e,t,r,i){he.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==r?r:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function pe(e){D.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("ShaderMaterial: attributes should now be defined in BufferGeometry instead."),this.setValues(e))}function fe(){c.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function me(e,t,r,i,n,a){he.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=void 0!==n?n:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function ve(e,t,r,i,n,a,o,s,c,u){Object.defineProperty(this,"id",{value:Eu++}),this.uuid=Fs.generateUUID(),this.name="",this.image=void 0!==e?e:ve.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:ve.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:Zl,this.wrapT=void 0!==i?i:Zl,this.magFilter=void 0!==n?n:rc,this.minFilter=void 0!==a?a:nc,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:xc,this.type=void 0!==s?s:ac,this.offset=new f(0,0),this.repeat=new f(1,1),this.center=new f(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new l,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:ou,this.version=0,this.onUpdate=null}function ge(e,t,r){this.width=e,this.height=t,this.scissor=new v(0,0,e,t),this.scissorTest=!1,this.viewport=new v(0,0,e,t),r=r||{},void 0===r.minFilter&&(r.minFilter=rc),this.texture=new ve((void 0),(void 0),r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.generateMipmaps=void 0===r.generateMipmaps||r.generateMipmaps,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function ye(e,t,r,i){m.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i},this.fromBufferGeometry(new xe(e,t,r,i)),this.mergeVertices()}function xe(e,t,r,i){P.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i},e=e||1,t=t||1;var n,a,o=e/2,s=t/2,l=Math.floor(r)||1,c=Math.floor(i)||1,u=l+1,h=c+1,d=e/l,p=t/c,f=[],m=[],v=[],g=[];for(a=0;a.9&&a<.1&&(t<.2&&(y[e+0]+=1),r<.2&&(y[e+2]+=1),i<.2&&(y[e+4]+=1))}}function u(e){g.push(e.x,e.y,e.z)}function h(t,r){var i=3*t;r.x=e[i+0],r.y=e[i+1],r.z=e[i+2]}function d(){for(var e=new i,t=new i,r=new i,n=new i,a=new f,o=new f,s=new f,l=0,c=0;l0,s=v>0,l=g>0,f=(o?1:0)+(s?1:0)+(l?1:0)){case 0:r.push(e[n]),r.push(e[n+1]),r.push(e[n+2]);break;case 1:if(o&&(u=e[n+1],h=e[n+2],d=c(e[n],u,t,i),p=c(e[n],h,t,i)),s){u=e[n],h=e[n+2],d=c(e[n+1],u,t,i),p=c(e[n+1],h,t,i),r.push(d),r.push(h.clone()),r.push(u.clone()),r.push(h.clone()),r.push(d.clone()),r.push(p);break}l&&(u=e[n],h=e[n+1],d=c(e[n+2],u,t,i),p=c(e[n+2],h,t,i)),r.push(u.clone()),r.push(h.clone()),r.push(d),r.push(p),r.push(d.clone()),r.push(h.clone());break;case 2:o||(u=e[n].clone(),h=c(u,e[n+1],t,i),d=c(u,e[n+2],t,i),r.push(u),r.push(h),r.push(d)),s||(u=e[n+1].clone(),h=c(u,e[n+2],t,i),d=c(u,e[n],t,i),r.push(u),r.push(h),r.push(d)),l||(u=e[n+2].clone(),h=c(u,e[n],t,i),d=c(u,e[n+1],t,i),r.push(u),r.push(h),r.push(d));break;case 3:}}return r}function c(e,t,r,n){var a=e.position.dot(r)-n,o=t.position.dot(r)-n,s=a/(a-o),l=new _t(new i(e.position.x+s*(t.position.x-e.position.x),e.position.y+s*(t.position.y-e.position.y),e.position.z+s*(t.position.z-e.position.z)),new i(e.normal.x+s*(t.normal.x-e.normal.x),e.normal.y+s*(t.normal.y-e.normal.y),e.normal.z+s*(t.normal.z-e.normal.z)));return l}P.call(this);var u=[],h=[],d=[],p=new i,f=new r;f.makeRotationFromEuler(n),f.setPosition(t);var m=(new r).getInverse(f);o(),this.addAttribute("position",new M(u,3)),this.addAttribute("normal",new M(h,3)),this.addAttribute("uv",new M(d,2))}function _t(e,t){this.position=e,this.normal=t}function St(e,t,r,n,a,o,s){var e=void 0!==e?e:new i(0,0,0),t=void 0!==t?t:10,l=t/2,r=void 0!==r?r:1,n=void 0!==n?n:0,a=void 0!==a?a:1,o=void 0!==o?o:2,s=void 0!==s?s:3,c=[new i(e.x-l,e.y,e.z-l),new i(e.x-l,e.y,e.z+l),new i(e.x+l,e.y,e.z+l),new i(e.x+l,e.y,e.z-l)],u=[c[n],c[a],c[o],c[s]];if(0<=--r){var h=[];return Array.prototype.push.apply(h,St(u[0],l,r,n,s,o,a)),Array.prototype.push.apply(h,St(u[1],l,r,n,a,o,s)),Array.prototype.push.apply(h,St(u[2],l,r,n,a,o,s)),Array.prototype.push.apply(h,St(u[3],l,r,o,a,n,s)),h}return u}function At(e,t,r,n,a,o,s,l,c,u,h){var e=void 0!==e?e:new i(0,0,0),t=void 0!==t?t:10,d=t/2,r=void 0!==r?r:1,n=void 0!==n?n:0,a=void 0!==a?a:1,o=void 0!==o?o:2,s=void 0!==s?s:3,l=void 0!==l?l:4,c=void 0!==c?c:5,u=void 0!==u?u:6,h=void 0!==h?h:7,p=[new i(e.x-d,e.y+d,e.z-d),new i(e.x-d,e.y+d,e.z+d),new i(e.x-d,e.y-d,e.z+d),new i(e.x-d,e.y-d,e.z-d),new i(e.x+d,e.y-d,e.z-d),new i(e.x+d,e.y-d,e.z+d),new i(e.x+d,e.y+d,e.z+d),new i(e.x+d,e.y+d,e.z-d)],f=[p[n],p[a],p[o],p[s],p[l],p[c],p[u],p[h]];if(--r>=0){var m=[];return Array.prototype.push.apply(m,At(f[0],d,r,n,s,l,h,u,c,o,a)),Array.prototype.push.apply(m,At(f[1],d,r,n,h,u,a,o,c,l,s)),Array.prototype.push.apply(m,At(f[2],d,r,n,h,u,a,o,c,l,s)),Array.prototype.push.apply(m,At(f[3],d,r,o,s,n,a,u,h,l,c)),Array.prototype.push.apply(m,At(f[4],d,r,o,s,n,a,u,h,l,c)),Array.prototype.push.apply(m,At(f[5],d,r,l,s,o,c,u,a,n,h)),Array.prototype.push.apply(m,At(f[6],d,r,l,s,o,c,u,a,n,h)),Array.prototype.push.apply(m,At(f[7],d,r,u,c,o,a,n,s,l,h)),m}return f}function Mt(e,t,r,i,n,a,o,s,l,c,u,h){ve.call(this,null,a,o,s,l,c,i,n,u,h),this.image={data:e,width:t,height:r},this.magFilter=void 0!==l?l:$l,this.minFilter=void 0!==c?c:$l,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Tt(e,t,r){function i(r){r.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}function n(e,t){t=t||{};var r=new pe({uniforms:t,vertexShader:a(),fragmentShader:e});return i(r),r}function a(){return"void main()\t{\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n"}function o(){return"uniform sampler2D texture;\n\nvoid main() {\n\n\tvec2 uv = gl_FragCoord.xy / resolution.xy;\n\n\tgl_FragColor = texture2D( texture, uv );\n\n}\n"}this.variables=[],this.currentTextureIndex=0;var s=new fe,l=new he;l.position.z=1;var c={texture:{value:null}},u=n(o(),c),h=new k(new xe(2,2),u);s.add(h),this.addVariable=function(e,t,r){var i=this.createShaderMaterial(t),n={name:e,initialValueTexture:r,material:i,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:$l,magFilter:$l};return this.variables.push(n),n},this.setVariableDependencies=function(e,t){e.dependencies=t},this.init=function(){var i=this;if(!r.extensions.get("OES_texture_float"))return"No OES_texture_float support for float textures.";if(0===r.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(var n=0;n>7&1),a=i>>6&1,o=1===(i>>5&1),s=31&i,l=0,c=0;if(o?(l=(t[2]<<16)+(t[3]<<8)+t[4],c=(t[5]<<16)+(t[6]<<8)+t[7]):(l=t[2]+(t[3]<<8)+(t[4]<<16),c=t[5]+(t[6]<<8)+(t[7]<<16)),0===r)throw new Error("PRWM decoder: Invalid format version: 0");if(1!==r)throw new Error("PRWM decoder: Unsupported format version: "+r);if(!n){if(0!==a)throw new Error("PRWM decoder: Indices type must be set to 0 for non-indexed geometries");if(0!==c)throw new Error("PRWM decoder: Number of indices must be set to 0 for non-indexed geometries")}var u,h,d,p,f,m,v,g,y,x=8,b={};for(y=0;y>7&1,p=(i>>4&3)+1,f=15&i,m=tm[f],x++,x=4*Math.ceil(x/4),v=hr(e,m,x,p*l,o),x+=m.BYTES_PER_ELEMENT*p*l,b[u]={type:d,cardinality:p,values:v}}return x=4*Math.ceil(x/4),g=null,n&&(g=hr(e,1===a?Uint32Array:Uint16Array,x,c,o)),{version:r,attributes:b,indices:g}}function pr(e,t,r,i,n,a,o,s){at.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=r||1,this.yRadius=i||1,this.aStartAngle=n||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function fr(e,t,r,i,n,a){pr.call(this,e,t,r,r,i,n,a),this.type="ArcCurve"}function mr(){function e(e,a,o,s){t=e,r=o,i=-3*e+3*a-2*o-s,n=2*e-2*a+o+s}var t=0,r=0,i=0,n=0;return{initCatmullRom:function(t,r,i,n,a){e(r,i,a*(i-t),a*(n-r))},initNonuniformCatmullRom:function(t,r,i,n,a,o,s){var l=(r-t)/a-(i-t)/(a+o)+(i-r)/o,c=(i-r)/o-(n-r)/(o+s)+(n-i)/s;l*=o,c*=o,e(r,i,l,c)},calc:function(e){var a=e*e,o=a*e;return t+r*e+i*a+n*o}}}function vr(e,t,r,i){at.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=r||"centripetal",this.tension=i||.5}function gr(e,t,r,i,n){var a=.5*(i-t),o=.5*(n-r),s=e*e,l=e*s;return(2*r-2*i+a+o)*l+(-3*r+3*i-2*a-o)*s+a*e+r}function yr(e,t){var r=1-e;return r*r*t}function xr(e,t){return 2*(1-e)*e*t}function br(e,t){return e*e*t}function wr(e,t,r,i){return yr(e,t)+xr(e,r)+br(e,i)}function _r(e,t){var r=1-e;return r*r*r*t}function Sr(e,t){var r=1-e;return 3*r*r*e*t}function Ar(e,t){return 3*(1-e)*e*e*t}function Mr(e,t){return e*e*e*t}function Tr(e,t,r,i,n){return _r(e,t)+Sr(e,r)+Ar(e,i)+Mr(e,n)}function Er(e,t,r,i){at.call(this),this.type="CubicBezierCurve",this.v0=e||new f,this.v1=t||new f,this.v2=r||new f,this.v3=i||new f}function Cr(e,t,r,n){at.call(this),this.type="CubicBezierCurve3",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i,this.v3=n||new i}function Lr(e,t){at.call(this),this.type="LineCurve",this.v1=e||new f,this.v2=t||new f}function Pr(e,t){at.call(this),this.type="LineCurve3",this.v1=e||new i,this.v2=t||new i}function Nr(e,t,r){at.call(this),this.type="QuadraticBezierCurve",this.v0=e||new f,this.v1=t||new f,this.v2=r||new f}function Or(e,t,r){at.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i}function Dr(e){at.call(this),this.type="SplineCurve",this.points=e||[]}function Fr(){at.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Ir(e){Fr.call(this),this.type="Path",this.currentPoint=new f,e&&this.setFromPoints(e)}function Rr(e){Ir.call(this,e),this.uuid=Fs.generateUUID(),this.type="Shape",this.holes=[]}function Ur(e,t,r,i,n){var a,o;if(n===ui(e,t,r,i)>0)for(a=t;a=t;a-=i)o=si(a,e[a],e[a+1],o);return o&&ti(o,o.next)&&(li(o),o=o.next),o}function kr(e,t){if(!e)return e;t||(t=e);var r,i=e;do if(r=!1,i.steiner||!ti(i,i.next)&&0!==ei(i.prev,i,i.next))i=i.next;else{if(li(i),i=t=i.prev,i===i.next)break;r=!0}while(r||i!==t);return t}function Br(e,t,r,i,n,a,o){if(e){!o&&a&&qr(e,i,n,a);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?jr(e,i,n,a):zr(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),li(e),e=l.next,c=l.next;else if(e=l,e===c){o?1===o?(e=Vr(e,t,r),Br(e,t,r,i,n,a,2)):2===o&&Gr(e,t,r,i,n,a):Br(kr(e),t,r,i,n,a,1);break}}}function zr(e){var t=e.prev,r=e,i=e.next;if(ei(t,r,i)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Kr(t.x,t.y,r.x,r.y,i.x,i.y,n.x,n.y)&&ei(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function jr(e,t,r,i){var n=e.prev,a=e,o=e.next;if(ei(n,a,o)>=0)return!1;for(var s=n.xa.x?n.x>o.x?n.x:o.x:a.x>o.x?a.x:o.x,u=n.y>a.y?n.y>o.y?n.y:o.y:a.y>o.y?a.y:o.y,h=Jr(s,l,t,r,i),d=Jr(c,u,t,r,i),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Kr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ei(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Kr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ei(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Vr(e,t,r){var i=e;do{var n=i.prev,a=i.next.next;!ti(n,a)&&ri(n,i,i.next,a)&&ni(n,a)&&ni(a,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(a.i/r),li(i),li(i.next),i=e=a),i=i.next}while(i!==e);return i}function Gr(e,t,r,i,n,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&$r(o,s)){var l=oi(o,s);return o=kr(o,o.next),l=kr(l,l.next),Br(o,t,r,i,n,a),void Br(l,t,r,i,n,a)}s=s.next}o=o.next}while(o!==e)}function Wr(e,t,r,i){var n,a,o,s,l,c=[];for(n=0,a=t.length;n=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o){if(o=s,s===n){if(a===i.y)return i;if(a===i.next.y)return i.next}r=i.x=i.x&&i.x>=u&&n!==i.x&&Kr(ar.x)&&ni(i,e)&&(r=i,d=l)),i=i.next;return r}function qr(e,t,r,i){var n=e;do null===n.z&&(n.z=Jr(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,Qr(n)}function Qr(e){var t,r,i,n,a,o,s,l,c=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,i=r,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(n=r,r=r.nextZ,s--):(n=i,i=i.nextZ,l--),a?a.nextZ=n:e=n,n.prevZ=a,a=n;r=i}a.nextZ=null,c*=2}while(o>1);return e}function Jr(e,t,r,i,n){return e=32767*(e-r)*n,t=32767*(t-i)*n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function Zr(e){var t=e,r=e;do t.x=0&&(e-o)*(i-s)-(r-o)*(t-s)>=0&&(r-o)*(a-s)-(n-o)*(i-s)>=0}function $r(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ii(e,t)&&ni(e,t)&&ni(t,e)&&ai(e,t)}function ei(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function ti(e,t){return e.x===t.x&&e.y===t.y}function ri(e,t,r,i){return!!(ti(e,t)&&ti(r,i)||ti(e,i)&&ti(r,t))||ei(e,t,r)>0!=ei(e,t,i)>0&&ei(r,i,e)>0!=ei(r,i,t)>0}function ii(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&ri(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function ni(e,t){return ei(e.prev,e,e.next)<0?ei(e,t,e.next)>=0&&ei(e,e.prev,t)>=0:ei(e,t,e.prev)<0||ei(e,e.next,t)<0}function ai(e,t){var r=e,i=!1,n=(e.x+t.x)/2,a=(e.y+t.y)/2;do r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==e);return i}function oi(e,t){var r=new ci(e.i,e.x,e.y),i=new ci(t.i,t.x,t.y),n=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function si(e,t,r,i){var n=new ci(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function li(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 ci(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ui(e,t,r,i){for(var n=0,a=t,o=r-i;a2&&e[t-1].equals(e[0])&&e.pop()}function di(e,t){for(var r=0;r","#include "].join("\n"),this.parsCode={vertex:"",fragment:""},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={},this.updaters=[],this.nodes=[],this.parsing=!1,this.optimize=!0}function Oi(e,t,r){ar.call(this,"c"),this.value=e instanceof u?e:new u(e||0,t,r)}function Di(e){er.call(this,"v4"),this.value=e}function Fi(e,t){pe.call(this),this.vertex=e||new Di(new ir(ir.PROJECTION)),this.fragment=t||new Di(new Oi(16711680)),this.updaters=[]}function Ii(e,t){ar.call(this,"v2"),this.value=e instanceof f?e:new f(e,t)}function Ri(){Ii.call(this)}function Ui(e){tr.call(this,"v2"),this.resolution=e||new Ri}function ki(e){or.call(this),this.texture=e,this.maxMIPLevel=0}function Bi(e){tr.call(this,"f"),this.texture=e,this.maxMIPLevel=new ki(e),this.blinnShininessExponent=new Ei}function zi(e,t){er.call(this,t),this.name=e}function ji(e,t,r,i,n){Vf.call(this,e,n,i,r,t)}function Vi(e,t){tr.call(this),this.setFunction(e,t)}function Gi(e){this.time=void 0!==e?e:0,this.id=0}function Wi(e,t){er.call(this,e),this.value=t}function Xi(e,t,r,i){tr.call(this,"v4"),this.value=e,this.uv=t||new rr,this.radius=new Ii(1,1),this.size=i,this.blurX=!0,this.blurY=!0,this.horizontal=new or(1/64),this.vertical=new or(1/64)}function Hi(e){tr.call(this,"f"),this.rgb=e}function Yi(e,t,r){tr.call(this,"v3"), -this.rgb=e,this.adjustment=t,this.method=r||Yi.SATURATION}function qi(e){ar.call(this,"i"),this.value=Math.floor(e||0)}function Qi(e){ar.call(this,"m3"),this.value=e||new l}function Ji(e){ar.call(this,"m4"),this.value=e||new r}function Zi(e,t,r){ar.call(this,r),this.object=e,this.property=t}function Ki(e,t,r){tr.call(this),this.a=e,this.b=t,this.op=r}function $i(e){tr.call(this,"v4"),e&&this.setMirror(e)}function en(e,t,r,i){i=i||{},this.input=r,this.clear=void 0===i.clear||i.clear,this.renderTarget=new ge(e,t,i),this.material=new Fi,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),this.material),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.render=!0,Mi.call(this,this.renderTarget.texture)}function tn(e){Mi.call(this,void 0,e)}function rn(){er.call(this),this.color=new Oi(15658734),this.roughness=new or(.5),this.metalness=new or(.5)}function nn(e,t){er.call(this),this.node=e,this.components=t||"x"}function an(e,t){tr.call(this,"v3"),this.value=e,this.scale=t||new Ii(1,1)}function on(){rn.call(this),this.properties={color:new u(16777215),roughness:.5,metalness:.5,normalScale:new f(1,1)},this.inputs={color:new Zi(this.properties,"color","c"),roughness:new Zi(this.properties,"roughness","f"),metalness:new Zi(this.properties,"metalness","f"),normalScale:new Zi(this.properties,"normalScale","v2")}}function sn(){var e=new on;Fi.call(this,e,e),this.type="MeshStandardNodeMaterial"}function ln(){er.call(this),this.color=new Oi(15658734),this.specular=new Oi(1118481),this.shininess=new or(30)}function cn(){er.call(this),this.color=new Oi(15658734),this.spherical=!0}function un(){var e=new ln;Fi.call(this,e,e),this.type="PhongNodeMaterial"}function hn(){var e=new cn;Fi.call(this,e,e),this.type="SpriteNodeMaterial"}function dn(){var e=new rn;Fi.call(this,e,e),this.type="StandardNodeMaterial"}function pn(e,t,r,i,n){tr.call(this),this.a=e,this.b=t,this.ifNode=r,this.elseNode=i,this.op=n}function fn(e,t){tr.call(this),this.a=e,this.method=t}function mn(e,t,r){tr.call(this),this.a=e,this.b=t,this.method=r}function vn(e,t,r,i){tr.call(this),this.a=e,this.b=t,this.c=r,this.method=i}function gn(e,t){tr.call(this,"v3"),this.value=e,this.scale=t||new or(1),this.toNormalMap=!1}function yn(){Ev.call(this),this.name="",this.uuid=Fs.generateUUID(),this.userData={},this.textureID="renderTexture",this.input=new tn,this.material=new Fi,this.needsUpdate=!0}function xn(e,t){if(void 0===t){var r={minFilter:rc,magFilter:rc,format:xc,stencilBuffer:!1},i=e.getDrawingBufferSize();t=new ge(i.width,i.height,r)}this.renderer=e,this.renderTarget=t,this.output=new tn,this.material=new Fi,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),this.material),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.needsUpdate=!0}function bn(e){tr.call(this,"f"),this.uv=e||new rr}function wn(e){tr.call(this,"f"),this.uv=e||new rr}function _n(e,t){er.call(this),this.code=e,this.value=t}function Sn(e,t,r,i){tr.call(this,"f"),this.x=e,this.y=t,this.z=r,this.w=i}function An(e,t){ji.call(this,"( uvTransform * vec3( uvNode, 1 ) ).xy","vec2"),this.uv=e||new rr,this.position=t||new Qi}function Mn(e,t){_i.call(this),this.params={},this.velocity=new i,this.setTarget(e),this.setParams(t)}function Tn(e,t){this.min=void 0!==e?e:new f((+(1/0)),(+(1/0))),this.max=void 0!==t?t:new f((-(1/0)),(-(1/0)))}function En(e){this.autoStart=void 0===e||e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function Cn(e,t){function i(e){S.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),S.multiply(e.projectionMatrix),S.multiply(e.matrixWorldInverse),S.multiply(a.matrixWorld)}function n(){var e=A.getDelta(),t=a.material.uniforms.config;t.value.x+=d*e,t.value.y=t.value.x+_,t.value.x>=w?(t.value.x=0,t.value.y=_):t.value.y>=w&&(t.value.y=t.value.y-w)}k.call(this,e),this.type="Water2";var a=this;t=t||{};var o=new u(void 0!==t.color?t.color:16777215),s=t.textureWidth||512,l=t.textureHeight||512,c=t.clipBias||0,h=t.flowDirection||new f(1,0),d=t.flowSpeed||.03,p=t.reflectivity||.02,m=t.scale||1,v=t.shader||Cn.Water2Shader,g=new Ue,y=t.flowMap||void 0,x=t.normalMap0||g.load("textures/water/Water2_1_M_Normal.jpg"),b=t.normalMap1||g.load("textures/water/Water2_2_M_Normal.jpg"),w=.15,_=.5*w,S=new r,A=new En;if(void 0===Nv)return void console.error("Water2: Required component Reflector not found.");if(void 0===Dv)return void console.error("Water2: Required component Refractor not found.");var M=new Nv(e,{textureWidth:s,textureHeight:l,clipBias:c}),T=new Dv(e,{textureWidth:s,textureHeight:l,clipBias:c});M.matrixAutoUpdate=!1,T.matrixAutoUpdate=!1,this.material=new pe({uniforms:Mu.merge([mp.fog,v.uniforms]),vertexShader:v.vertexShader,fragmentShader:v.fragmentShader,transparent:!0,fog:!0}),void 0!==y?(this.material.defines.USE_FLOWMAP="",this.material.uniforms.tFlowMap={type:"t",value:y}):this.material.uniforms.flowDirection={type:"v2",value:h},x.wrapS=x.wrapT=Jl,b.wrapS=b.wrapT=Jl,this.material.uniforms.tReflectionMap.value=M.getRenderTarget().texture,this.material.uniforms.tRefractionMap.value=T.getRenderTarget().texture,this.material.uniforms.tNormalMap0.value=x,this.material.uniforms.tNormalMap1.value=b,this.material.uniforms.color.value=o,this.material.uniforms.reflectivity.value=p,this.material.uniforms.textureMatrix.value=S,this.material.uniforms.config.value.x=0,this.material.uniforms.config.value.y=_,this.material.uniforms.config.value.z=_,this.material.uniforms.config.value.w=m,this.onBeforeRender=function(e,t,r){i(r),n(),a.visible=!1,M.matrixWorld.copy(a.matrixWorld),T.matrixWorld.copy(a.matrixWorld),M.onBeforeRender(e,t,r),T.onBeforeRender(e,t,r),a.visible=!0}}function Ln(e,t){this.object=e,void 0===t&&(t=16776960);var r=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]),i=new Float32Array(24),n=new P;n.setIndex(new g(r,1)),n.addAttribute("position",new g(i,3)),Yt.call(this,n,new I({color:t})),this.matrixAutoUpdate=!1,this.update()}function Pn(e){return!isNaN(e)&&isFinite(e)}function Nn(e){return"[object Array]"===Object.prototype.toString.call(e)}function On(e){return e?Nn(e)!==!0?[e]:e:[]}function Dn(e,t){for(var r=0,i=e.length;r0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,s=void 0!==r.precision?r.precision:"highp",l=n(s);l!==s&&(console.warn("WebGLRenderer:",s,"not supported, using",l,"instead."),s=l);var c=r.logarithmicDepthBuffer===!0,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=h>0,x=o||!!t.get("OES_texture_float"),b=y&&x;return{isWebGL2:o,getMaxAnisotropy:i,getMaxPrecision:n,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:b}}function Vn(){function e(){u.value!==i&&(u.value=i,u.needsUpdate=n>0),r.numPlanes=n,r.numIntersection=0}function t(e,t,i,n){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=u.value,n!==!0||null===o){var l=i+4*a,h=t.matrixWorldInverse;c.getNormalMatrix(h),(null===o||o.length65535?A:_)(n,1),t.update(i,e.ELEMENT_ARRAY_BUFFER),l[r.id]=i,i}var s={},l={};return{get:n,update:a,getWireframeAttribute:o}}function Xn(e,t,r,i){function n(e){l=e}function a(e){c=e.type,u=e.bytesPerElement}function o(t,i){e.drawElements(l,i,c,t*u),r.update(i,l)}function s(n,a,o){var s;if(i.isWebGL2)s=e;else{var s=t.get("ANGLE_instanced_arrays");if(null===s)return void console.error("WebGLIndexedBufferRenderer: using InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}s[i.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](l,o,c,a*u,n.maxInstancedCount),r.update(o,l,n.maxInstancedCount)}var l,c,u;this.setMode=n,this.setIndex=a,this.render=o,this.renderInstances=s}function Hn(e){function t(t,r,i){switch(i=i||1,n.calls++,r){case e.TRIANGLES:n.triangles+=i*(t/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:n.triangles+=i*(t-2);break;case e.LINES:n.lines+=i*(t/2);break;case e.LINE_STRIP:n.lines+=i*(t-1);break;case e.LINE_LOOP:n.lines+=i*t;break;case e.POINTS:n.points+=i*t;break;default:console.error("WebGLInfo: Unknown draw mode:",r)}}function r(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}var i={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:i,render:n,programs:null,autoReset:!0,reset:r,update:t}}function Yn(e,t){return Math.abs(t[1])-Math.abs(e[1])}function qn(e){function t(t,n,a,o){var s=t.morphTargetInfluences,l=s.length,c=r[n.id];if(void 0===c){c=[];for(var u=0;u0)return e;var n=t*r,a=qg[n];if(void 0===a&&(a=new Float32Array(n),qg[n]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=r,e[o].toArray(a,s)}return a}function Kn(e,t){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r");return Wa(r)}var r=/^[ \t]*#include +<([\w\d.\/]+)>/gm;return e.replace(r,t)}function Xa(e){function t(e,t,r,i){for(var n="",a=parseInt(t);a0?e.gammaFactor:1,y=o.isWebGL2?"":ka(i.extensions,a,t),x=Ba(l),b=s.createProgram();if(i.isRawShaderMaterial?(m=[x].filter(ja).join("\n"),m.length>0&&(m+="\n"),v=[y,x].filter(ja).join("\n"),v.length>0&&(v+="\n")):(m=["precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+n.name,x,a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+p:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&a.flatShading===!1?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ja).join("\n"),v=[y,"precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+n.name,x,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+d:"",a.envMap?"#define "+p:"",a.envMap?"#define "+f:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",a.envMap&&(o.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",a.toneMapping!==Ul?"#define TONE_MAPPING":"",a.toneMapping!==Ul?fp.tonemapping_pars_fragment:"",a.toneMapping!==Ul?Ua("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.envMapEncoding||a.emissiveMapEncoding?fp.encodings_pars_fragment:"",a.mapEncoding?Ia("mapTexelToLinear",a.mapEncoding):"",a.envMapEncoding?Ia("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Ia("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?Ra("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ja).join("\n")),c=Wa(c),c=Va(c,a),c=Ga(c,a),u=Wa(u),u=Va(u,a),u=Ga(u,a),c=Xa(c),u=Xa(u),o.isWebGL2&&!i.isRawShaderMaterial){var w=!1,_=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==c.match(_)&&null!==u.match(_)&&(w=!0,c=c.replace(_,""),u=u.replace(_,"")),m=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,v=["#version 300 es\n","#define varying in",w?"":"out highp vec4 pc_fragColor;",w?"":"#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"+v}var S=m+c,A=v+u,M=Da(s,s.VERTEX_SHADER,S),T=Da(s,s.FRAGMENT_SHADER,A);s.attachShader(b,M),s.attachShader(b,T),void 0!==i.index0AttributeName?s.bindAttribLocation(b,0,i.index0AttributeName):a.morphTargets===!0&&s.bindAttribLocation(b,0,"position"),s.linkProgram(b);var E=s.getProgramInfoLog(b).trim(),C=s.getShaderInfoLog(M).trim(),L=s.getShaderInfoLog(T).trim(),P=!0,N=!0;s.getProgramParameter(b,s.LINK_STATUS)===!1?(P=!1,console.error("WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(b,s.VALIDATE_STATUS),"gl.getProgramInfoLog",E,C,L)):""!==E?console.warn("WebGLProgram: gl.getProgramInfoLog()",E):""!==C&&""!==L||(N=!1), -N&&(this.diagnostics={runnable:P,material:i,programLog:E,vertexShader:{log:C,prefix:m},fragmentShader:{log:L,prefix:v}}),s.deleteShader(M),s.deleteShader(T);var O;this.getUniforms=function(){return void 0===O&&(O=new Na(s,b,e)),O};var D;return this.getAttributes=function(){return void 0===D&&(D=za(s,b)),D},this.destroy=function(){s.deleteProgram(b),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=n.name,this.id=ey++,this.code=r,this.usedTimes=1,this.program=b,this.vertexShader=M,this.fragmentShader=T,this}function Ya(e,t,r){function i(e){var t=e.skeleton,i=t.bones;if(r.floatVertexTextures)return 1024;var n=r.maxVertexUniforms,a=Math.floor((n-20)/4),o=Math.min(a,i.length);return o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:c,numClipIntersection:u,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===Ks,flipSided:t.side===Zs,depthPacking:void 0!==t.depthPacking&&t.depthPacking};return v},this.getProgramCode=function(t,r){var i=[];if(r.shaderID?i.push(r.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)i.push(n),i.push(t.defines[n]);for(var a=0;a1&&a.sort(Qa),o.length>1&&o.sort(Ja)}var i=[],n=0,a=[],o=[];return{opaque:a,transparent:o,init:e,push:t,sort:r}}function Ka(){function e(e,t){var i=e.id+","+t.id,n=r[i];return void 0===n&&(n=new Za,r[i]=n),n}function t(){r={}}var r={};return{get:e,dispose:t}}function $a(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var r;switch(t.type){case"DirectionalLight":r={direction:new i,color:new u,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f};break;case"SpotLight":r={position:new i,direction:new i,color:new u,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f};break;case"PointLight":r={position:new i,color:new u,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new i,skyColor:new u,groundColor:new u};break;case"RectAreaLight":r={color:new u,position:new i,halfWidth:new i,halfHeight:new i}}return e[t.id]=r,r}}}function eo(){function e(e,r,i){for(var l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=i.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&r.skinning===!1&&console.warn("WebGLShadowMap: SkinnedMesh with material.skinning set to false:",t);var d=t.isSkinnedMesh&&r.skinning,f=0;h&&(f|=p),d&&(f|=m),l=c[f]}if(e.localClippingEnabled&&r.clipShadows===!0&&0!==r.clippingPlanes.length){var v=l.uuid,g=r.uuid,_=b[v];void 0===_&&(_={},b[v]=_);var S=_[g];void 0===S&&(S=l.clone(),_[g]=S),l=S}return l.visible=r.visible,l.wireframe=r.wireframe,l.side=null!=r.shadowSide?r.shadowSide:w[r.side],l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,i&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(n),l.nearDistance=a,l.farDistance=o),l}function o(r,i,n,l){if(r.visible!==!1){var c=r.layers.test(i.layers);if(c&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||s.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,r.matrixWorld);var u=t.update(r),h=r.material;if(Array.isArray(h))for(var p=u.groups,f=0,m=p.length;f=1):ne.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ne)[1]),re=ie>=2);var ae=null,oe={},se=new v,le=new v,ce={};return ce[e.TEXTURE_2D]=s(e.TEXTURE_2D,e.TEXTURE_2D,1),ce[e.TEXTURE_CUBE_MAP]=s(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),N.setClear(0,0,0,1),O.setClear(1),D.setClear(0),d(e.DEPTH_TEST),O.setFunc(Ll),x(!1),b(Vs),d(e.CULL_FACE),g(nl),{buffers:{color:N,depth:O,stencil:D},initAttributes:l,enableAttribute:c,enableAttributeAndDivisor:u,disableUnusedAttributes:h,enable:d,disable:p,getCompressedTextureFormats:f,useProgram:m,setBlending:g,setMaterial:y,setFlipSided:x,setCullFace:b,setLineWidth:w,setPolygonOffset:_,setScissorTest:S,activeTexture:A,bindTexture:M,compressedTexImage2D:T,texImage2D:E,scissor:C,viewport:L,reset:P}}function ao(e,t,r,i,n,a,o){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var r=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=Math.floor(e.width*r),i.height=Math.floor(e.height*r);var n=i.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height),i}return e}function l(e){return Fs.isPowerOfTwo(e.width)&&Fs.isPowerOfTwo(e.height)}function c(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){void 0===N&&(N=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),N.width=Fs.floorPowerOfTwo(e.width),N.height=Fs.floorPowerOfTwo(e.height);var t=N.getContext("2d");return t.drawImage(e,0,0,N.width,N.height),console.warn("WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+N.width+"x"+N.height),N}return e}function u(e){return!n.isWebGL2&&(e.wrapS!==Zl||e.wrapT!==Zl||e.minFilter!==$l&&e.minFilter!==rc)}function h(e,t){return e.generateMipmaps&&t&&e.minFilter!==$l&&e.minFilter!==rc}function d(t,r,n,a){e.generateMipmap(t);var o=i.get(r);o.__maxMipLevel=Math.log(Math.max(n,a))*Math.LOG2E}function p(t,r){if(!n.isWebGL2)return t;if(t===e.RGB){if(r===e.FLOAT)return e.RGB32F;if(r===e.HALF_FLOAT)return e.RGB16F;if(r===e.UNSIGNED_BYTE)return e.RGB8}if(t===e.RGBA){if(r===e.FLOAT)return e.RGBA32F;if(r===e.HALF_FLOAT)return e.RGBA16F;if(r===e.UNSIGNED_BYTE)return e.RGBA8}return t}function f(t){return t===$l||t===ec||t===tc?e.NEAREST:e.LINEAR}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),t.isVideoTexture&&delete O[t.id],o.memory.textures--}function v(e){var t=e.target;t.removeEventListener("dispose",v),y(t),o.memory.textures--}function g(t){var r=i.get(t);if(t.image&&r.__image__webglTextureCube)e.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;e.deleteTexture(r.__webglTexture)}i.remove(t)}function y(t){var r=i.get(t),n=i.get(t.texture);if(t){if(void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(r.__webglFramebuffer[a]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[a]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}}function x(t,n){var a=i.get(t);if(t.isVideoTexture&&P(t),t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("WebGLRenderer: Texture marked for update but image is undefined");else{if(o.complete!==!1)return void S(a,t,n);console.warn("WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function b(t,c){var u=i.get(t);if(6===t.image.length)if(t.version>0&&u.__version!==t.version){u.__image__webglTextureCube||(t.addEventListener("dispose",m),u.__image__webglTextureCube=e.createTexture(),o.memory.textures++),r.activeTexture(e.TEXTURE0+c),r.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var f=t&&t.isCompressedTexture,v=t.image[0]&&t.image[0].isDataTexture,g=[],y=0;y<6;y++)f||v?g[y]=v?t.image[y].image:t.image[y]:g[y]=s(t.image[y],n.maxCubemapSize);var x=g[0],b=l(x),w=a.convert(t.format),S=a.convert(t.type),A=p(w,S);_(e.TEXTURE_CUBE_MAP,t,b);for(var y=0;y<6;y++)if(f)for(var M,T=g[y].mipmaps,E=0,C=T.length;E-1?r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,E,A,M.width,M.height,0,M.data):console.warn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,E,A,M.width,M.height,0,w,S,M.data);else v?r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,A,g[y].width,g[y].height,0,w,S,g[y].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,A,w,S,g[y]);f?u.__maxMipLevel=T.length-1:u.__maxMipLevel=0,h(t,b)&&d(e.TEXTURE_CUBE_MAP,t,x.width,x.height),u.__version=t.version,t.onUpdate&&t.onUpdate(t)}else r.activeTexture(e.TEXTURE0+c),r.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)}function w(t,n){r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)}function _(r,o,s){var l;if(s?(e.texParameteri(r,e.TEXTURE_WRAP_S,a.convert(o.wrapS)),e.texParameteri(r,e.TEXTURE_WRAP_T,a.convert(o.wrapT)),e.texParameteri(r,e.TEXTURE_MAG_FILTER,a.convert(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a.convert(o.minFilter))):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),o.wrapS===Zl&&o.wrapT===Zl||console.warn("WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to ClampToEdgeWrapping."),e.texParameteri(r,e.TEXTURE_MAG_FILTER,f(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,f(o.minFilter)),o.minFilter!==$l&&o.minFilter!==rc&&console.warn("WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to NearestFilter or LinearFilter.")),l=t.get("EXT_texture_filter_anisotropic")){if(o.type===hc&&null===t.get("OES_texture_float_linear"))return;if(o.type===dc&&null===(n.isWebGL2||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(r,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function S(t,i,f){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",m),t.__webglTexture=e.createTexture(),o.memory.textures++),r.activeTexture(e.TEXTURE0+f),r.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var v=s(i.image,n.maxTextureSize);u(i)&&l(v)===!1&&(v=c(v));var g=l(v),y=a.convert(i.format),x=a.convert(i.type),b=p(y,x);_(e.TEXTURE_2D,i,g);var w,S=i.mipmaps;if(i.isDepthTexture){if(b=e.DEPTH_COMPONENT,i.type===hc){if(!n.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else n.isWebGL2&&(b=e.DEPTH_COMPONENT16);i.format===Sc&&b===e.DEPTH_COMPONENT&&i.type!==lc&&i.type!==uc&&(console.warn("WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=lc,x=a.convert(i.type)),i.format===Ac&&(b=e.DEPTH_STENCIL,i.type!==vc&&(console.warn("WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=vc,x=a.convert(i.type))),r.texImage2D(e.TEXTURE_2D,0,b,v.width,v.height,0,y,x,null)}else if(i.isDataTexture)if(S.length>0&&g){for(var A=0,M=S.length;A-1?r.compressedTexImage2D(e.TEXTURE_2D,A,b,w.width,w.height,0,w.data):console.warn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(e.TEXTURE_2D,A,b,w.width,w.height,0,y,x,w.data);t.__maxMipLevel=S.length-1}else if(S.length>0&&g){for(var A=0,M=S.length;A=0){var l=i[o];if(void 0!==l){var c=l.normalized,u=l.itemSize,h=Te.get(l);if(void 0===h)continue;var d=h.buffer,p=h.type,f=h.bytesPerElement;if(l.isInterleavedBufferAttribute){var m=l.data,v=m.stride,g=l.offset;m&&m.isInstancedInterleavedBuffer?(_e.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):_e.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,d),H.vertexAttribPointer(s,u,p,c,v*f,g*f)}else l.isInstancedBufferAttribute?(_e.enableAttributeAndDivisor(s,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):_e.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,d),H.vertexAttribPointer(s,u,p,c,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:H.vertexAttrib2fv(s,y);break;case 3:H.vertexAttrib3fv(s,y);break;case 4:H.vertexAttrib4fv(s,y);break;default:H.vertexAttrib1fv(s,y)}}}}_e.disableUnusedAttributes()}function d(e){Ue.isPresenting()||Be&&Be(e)}function p(e,t,r){if(e.visible!==!1){var i=e.layers.test(t.layers);if(i)if(e.isLight)X.pushLight(e),e.castShadow&&X.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||de.intersectsSprite(e)){r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve);var n=Ce.update(e),a=e.material;W.push(e,n,a,ge.z,null)}}else if(e.isImmediateRenderObject)r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve),W.push(e,null,e.material,ge.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||de.intersectsObject(e))){r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve);var n=Ce.update(e),a=e.material;if(Array.isArray(a))for(var o=n.groups,s=0,l=o.length;s=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var v=0;v=0&&e.numSupportedMorphNormals++}var g=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&e.clipping!==!0||(i.numClippingPlanes=pe.numPlanes,i.numIntersection=pe.numIntersection,g.clippingPlanes=pe.uniform),i.fog=t,void 0===o&&(i.lightsHash=o={}),o.stateID=l.stateID,o.directionalLength=l.directionalLength,o.pointLength=l.pointLength,o.spotLength=l.spotLength,o.rectAreaLength=l.rectAreaLength,o.hemiLength=l.hemiLength,o.shadowsLength=l.shadowsLength,e.lights&&(g.ambientLightColor.value=n.state.ambient,g.directionalLights.value=n.state.directional,g.spotLights.value=n.state.spot,g.rectAreaLights.value=n.state.rectArea,g.pointLights.value=n.state.point,g.hemisphereLights.value=n.state.hemi,g.directionalShadowMap.value=n.state.directionalShadowMap,g.directionalShadowMatrix.value=n.state.directionalShadowMatrix,g.spotShadowMap.value=n.state.spotShadowMap,g.spotShadowMatrix.value=n.state.spotShadowMatrix,g.pointShadowMap.value=n.state.pointShadowMap,g.pointShadowMatrix.value=n.state.pointShadowMatrix);var y=i.program.getUniforms(),x=Na.seqWithValue(y.seq,g);i.uniformsList=x}function y(e,t,r,i){ae=0;var n=Ae.get(r),a=X.state.lights,o=n.lightsHash,s=a.state.hash;if(fe&&(me||e!==ee)){var l=e===ee&&r.id===K;pe.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,e,n,l)}r.needsUpdate===!1&&(void 0===n.program?r.needsUpdate=!0:r.fog&&n.fog!==t?r.needsUpdate=!0:!r.lights||o.stateID===s.stateID&&o.directionalLength===s.directionalLength&&o.pointLength===s.pointLength&&o.spotLength===s.spotLength&&o.rectAreaLength===s.rectAreaLength&&o.hemiLength===s.hemiLength&&o.shadowsLength===s.shadowsLength?void 0===n.numClippingPlanes||n.numClippingPlanes===pe.numPlanes&&n.numIntersection===pe.numIntersection||(r.needsUpdate=!0):r.needsUpdate=!0),r.needsUpdate&&(g(r,t,i),r.needsUpdate=!1);var c=!1,u=!1,h=!1,d=n.program,p=d.getUniforms(),f=n.shader.uniforms;if(_e.useProgram(d.program)&&(c=!0,u=!0,h=!0),r.id!==K&&(K=r.id,u=!0),c||ee!==e){if(p.setValue(H,"projectionMatrix",e.projectionMatrix),we.logarithmicDepthBuffer&&p.setValue(H,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),ee!==e&&(ee=e,u=!0,h=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var m=p.map.cameraPosition;void 0!==m&&m.setValue(H,ge.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&p.setValue(H,"viewMatrix",e.matrixWorldInverse)}if(r.skinning){p.setOptional(H,i,"bindMatrix"),p.setOptional(H,i,"bindMatrixInverse");var v=i.skeleton;if(v){var y=v.bones;if(we.floatVertexTextures){if(void 0===v.boneTexture){var F=Math.sqrt(4*y.length);F=Fs.ceilPowerOfTwo(F),F=Math.max(F,4);var I=new Float32Array(F*F*4);I.set(v.boneMatrices);var R=new Mt(I,F,F,xc,hc);R.needsUpdate=!0,v.boneMatrices=I,v.boneTexture=R,v.boneTextureSize=F}p.setValue(H,"boneTexture",v.boneTexture),p.setValue(H,"boneTextureSize",v.boneTextureSize)}else p.setOptional(H,v,"boneMatrices")}}return u&&(p.setValue(H,"toneMappingExposure",Y.toneMappingExposure),p.setValue(H,"toneMappingWhitePoint",Y.toneMappingWhitePoint),r.lights&&D(f,h),t&&r.fog&&A(f,t),r.isMeshBasicMaterial?x(f,r):r.isMeshLambertMaterial?(x(f,r),M(f,r)):r.isMeshPhongMaterial?(x(f,r),r.isMeshToonMaterial?E(f,r):T(f,r)):r.isMeshStandardMaterial?(x(f,r),r.isMeshPhysicalMaterial?L(f,r):C(f,r)):r.isMeshDepthMaterial?(x(f,r),P(f,r)):r.isMeshDistanceMaterial?(x(f,r),N(f,r)):r.isMeshNormalMaterial?(x(f,r),O(f,r)):r.isLineBasicMaterial?(b(f,r),r.isLineDashedMaterial&&w(f,r)):r.isPointsMaterial?_(f,r):r.isSpriteMaterial?S(f,r):r.isShadowMaterial&&(f.color.value=r.color,f.opacity.value=r.opacity),void 0!==f.ltc_1&&(f.ltc_1.value=mp.LTC_1),void 0!==f.ltc_2&&(f.ltc_2.value=mp.LTC_2),Na.upload(H,n.uniformsList,f,Y)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Na.upload(H,n.uniformsList,f,Y),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&p.setValue(H,"center",i.center),p.setValue(H,"modelViewMatrix",i.modelViewMatrix),p.setValue(H,"normalMatrix",i.normalMatrix),p.setValue(H,"modelMatrix",i.matrixWorld),d}function x(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=Ae.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var r;t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),r.matrixAutoUpdate===!0&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}function b(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function w(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function _(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*le,e.scale.value=.5*se,e.map.value=t.map,null!==t.map&&(t.map.matrixAutoUpdate===!0&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function S(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.rotation.value=t.rotation,e.map.value=t.map,null!==t.map&&(t.map.matrixAutoUpdate===!0&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function A(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function M(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function T(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function E(e,t){T(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function C(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function L(e,t){C(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}function P(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function N(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function O(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function D(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function F(){var e=ae;return e>=we.maxTextures&&console.warn("WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+we.maxTextures),ae+=1,e}console.log("WebGLRenderer",Bs),e=e||{};var I=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),R=void 0!==e.context?e.context:null,U=void 0!==e.alpha&&e.alpha,k=void 0===e.depth||e.depth,B=void 0===e.stencil||e.stencil,z=void 0!==e.antialias&&e.antialias,j=void 0===e.premultipliedAlpha||e.premultipliedAlpha,V=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,G=void 0!==e.powerPreference?e.powerPreference:"default",W=null,X=null;this.domElement=I,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=kl,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var H,Y=this,q=!1,Q=null,J=null,Z=null,K=-1,$={geometry:null,program:null,wireframe:!1},ee=null,te=null,re=new v,ie=new v,ne=null,ae=0,oe=I.width,se=I.height,le=1,ce=new v(0,0,oe,se),ue=new v(0,0,oe,se),he=!1,de=new Rn,pe=new Vn,fe=!1,me=!1,ve=new r,ge=new i;try{var ye={alpha:U,depth:k,stencil:B,antialias:z,premultipliedAlpha:j,preserveDrawingBuffer:V,powerPreference:G};if(I.addEventListener("webglcontextlost",a,!1),I.addEventListener("webglcontextrestored",o,!1),H=R||I.getContext("webgl",ye)||I.getContext("experimental-webgl",ye),null===H)throw null!==I.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===H.getShaderPrecisionFormat&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(xe){console.error("WebGLRenderer: "+xe.message)}var be,we,_e,Se,Ae,Me,Te,Ee,Ce,Le,Pe,Ne,Oe,De,Fe,Ie,Re;n();var Ue="xr"in navigator?new co(Y):new lo(Y);this.vr=Ue;var ke=new io(Y,Ce,we.maxTextureSize);this.shadowMap=ke,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){var e=be.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=be.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(e){void 0!==e&&(le=e,this.setSize(oe,se,!1))},this.getSize=function(){return{width:oe,height:se}},this.setSize=function(e,t,r){return Ue.isPresenting()?void console.warn("WebGLRenderer: Can't change size while VR device is presenting."):(oe=e,se=t,I.width=e*le,I.height=t*le,r!==!1&&(I.style.width=e+"px",I.style.height=t+"px"),void this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(){return{width:oe*le,height:se*le}},this.setDrawingBufferSize=function(e,t,r){oe=e,se=t,le=r,I.width=e*r,I.height=t*r,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return re},this.setViewport=function(e,t,r,i){ce.set(e,se-t-i,r,i),_e.viewport(re.copy(ce).multiplyScalar(le))},this.setScissor=function(e,t,r,i){ue.set(e,se-t-i,r,i),_e.scissor(ie.copy(ue).multiplyScalar(le))},this.setScissorTest=function(e){_e.setScissorTest(he=e)},this.getClearColor=function(){return Oe.getClearColor()},this.setClearColor=function(){Oe.setClearColor.apply(Oe,arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha.apply(Oe,arguments)},this.clear=function(e,t,r){var i=0;(void 0===e||e)&&(i|=H.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=H.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=H.STENCIL_BUFFER_BIT),H.clear(i)},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.clearTarget=function(e,t,r,i){this.setRenderTarget(e),this.clear(t,r,i)},this.dispose=function(){I.removeEventListener("webglcontextlost",a,!1),I.removeEventListener("webglcontextrestored",o,!1),Pe.dispose(),Ne.dispose(),Ae.dispose(),Ce.dispose(),Ue.dispose(),ze.stop()},this.renderBufferImmediate=function(e,t){_e.initAttributes();var r=Ae.get(e);e.hasPositions&&!r.position&&(r.position=H.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=H.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=H.createBuffer()),e.hasColors&&!r.color&&(r.color=H.createBuffer());var i=t.getAttributes();e.hasPositions&&(H.bindBuffer(H.ARRAY_BUFFER,r.position),H.bufferData(H.ARRAY_BUFFER,e.positionArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.position),H.vertexAttribPointer(i.position,3,H.FLOAT,!1,0,0)),e.hasNormals&&(H.bindBuffer(H.ARRAY_BUFFER,r.normal),H.bufferData(H.ARRAY_BUFFER,e.normalArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.normal),H.vertexAttribPointer(i.normal,3,H.FLOAT,!1,0,0)),e.hasUvs&&(H.bindBuffer(H.ARRAY_BUFFER,r.uv),H.bufferData(H.ARRAY_BUFFER,e.uvArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.uv),H.vertexAttribPointer(i.uv,2,H.FLOAT,!1,0,0)),e.hasColors&&(H.bindBuffer(H.ARRAY_BUFFER,r.color),H.bufferData(H.ARRAY_BUFFER,e.colorArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.color),H.vertexAttribPointer(i.color,3,H.FLOAT,!1,0,0)),_e.disableUnusedAttributes(),H.drawArrays(H.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,r,i,n,a,o){var s=a.isMesh&&a.normalMatrix.determinant()<0;_e.setMaterial(n,s);var l=y(e,r,n,a),c=!1;$.geometry===i.id&&$.program===l.id&&$.wireframe===(n.wireframe===!0)||($.geometry=i.id,$.program=l.id,$.wireframe=n.wireframe===!0,c=!0),a.morphTargetInfluences&&(De.update(a,i,n,l),c=!0);var u=i.index,d=i.attributes.position,p=1;n.wireframe===!0&&(u=Ee.getWireframeAttribute(i),p=2);var f,m=Fe;null!==u&&(f=Te.get(u),m=Ie,m.setIndex(f)),c&&(h(n,l,i),null!==u&&H.bindBuffer(H.ELEMENT_ARRAY_BUFFER,f.buffer));var v=1/0;null!==u?v=u.count:void 0!==d&&(v=d.count);var g=i.drawRange.start*p,x=i.drawRange.count*p,b=null!==o?o.start*p:0,w=null!==o?o.count*p:1/0,_=Math.max(g,b),S=Math.min(v,g+x,b+w)-1,A=Math.max(0,S-_+1);if(0!==A){if(a.isMesh)if(n.wireframe===!0)_e.setLineWidth(n.wireframeLinewidth*t()),m.setMode(H.LINES);else switch(a.drawMode){case iu:m.setMode(H.TRIANGLES);break;case nu:m.setMode(H.TRIANGLE_STRIP);break;case au:m.setMode(H.TRIANGLE_FAN)}else if(a.isLine){var M=n.linewidth;void 0===M&&(M=1),_e.setLineWidth(M*t()),a.isLineSegments?m.setMode(H.LINES):a.isLineLoop?m.setMode(H.LINE_LOOP):m.setMode(H.LINE_STRIP)}else a.isPoints?m.setMode(H.POINTS):a.isSprite&&m.setMode(H.TRIANGLES);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&m.renderInstances(i,_,A):m.render(_,A)}},this.compile=function(e,t){X=Ne.get(e,t),X.init(),e.traverse(function(e){e.isLight&&(X.pushLight(e),e.castShadow&&X.pushShadow(e))}),X.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var r=0;r=0&&t<=e.width-i&&r>=0&&r<=e.height-n&&H.readPixels(t,r,i,n,Re.convert(c),Re.convert(u),a):console.error("WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&H.bindFramebuffer(H.FRAMEBUFFER,Z)}}},this.copyFramebufferToTexture=function(e,t,r){var i=t.image.width,n=t.image.height,a=Re.convert(t.format);this.setTexture2D(t,0),H.copyTexImage2D(H.TEXTURE_2D,r||0,a,e.x,e.y,i,n,0)},this.copyTextureToTexture=function(e,t,r,i){var n=t.image.width,a=t.image.height,o=Re.convert(r.format),s=Re.convert(r.type);this.setTexture2D(r,0),t.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,n,a,o,s,t.image.data):H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image)}}function ho(e){"string"==typeof e&&(console.warn("Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function po(e,t){function r(e,t){E.set(0,0,-1).applyQuaternion(f);for(var r=0;r=0;r--)T.copy(e[r]),T.applyQuaternion(f),T.add(v),o.push(T.x,T.y,T.z),s.push(E.x,E.y,E.z),l.push(t[0],t[1],t[2])}function a(e,t,r){for(var i=0,n=e.length;i10?(S.set(-.75,-.35,0),S.applyQuaternion(s),S.add(c),A.set(.75,-.35,0),A.applyQuaternion(s),A.add(c),r(h,S,A),S.set(-.7,-.3,0),S.applyQuaternion(s),S.add(c),A.set(-.7,-c.y,0),A.applyQuaternion(s),A.add(c),r(d,S,A),S.set(.7,-.3,0),S.applyQuaternion(s),S.add(c),A.set(.7,-c.y,0),A.applyQuaternion(s),A.add(c),r(p,S,A)):(S.set(0,-.2,0),S.applyQuaternion(s),S.add(c),A.set(0,-c.y,0),A.applyQuaternion(s),A.add(c),r(p,S,A))}this.addAttribute("position",new g(new Float32Array(a),3)),this.addAttribute("normal",new g(new Float32Array(o),3))}function mo(e,t){P.call(this);var r=[],a=new i(0,1,0),o=new i,s=new n,l=new n;l.setFromAxisAngle(a,Math.PI/2);var c=new i,u=new i;u.copy(e.getPointAt(0)),u.y=0;for(var h=new i,d=new i,p=new i,f=new i,m=1;m<=t;m++){c.copy(e.getPointAt(m/t)),c.y=0,o.subVectors(c,u);var v=Math.atan2(o.x,o.z);s.setFromAxisAngle(a,v),h.set(-.3,0,0),h.applyQuaternion(s),h.add(c),d.set(.3,0,0),d.applyQuaternion(s),d.add(c),p.set(.3,0,0),p.applyQuaternion(l),p.add(u),f.set(-.3,0,0),f.applyQuaternion(l),f.add(u),r.push(h.x,h.y,h.z),r.push(d.x,d.y,d.z),r.push(f.x,f.y,f.z),r.push(d.x,d.y,d.z),r.push(p.x,p.y,p.z),r.push(f.x,f.y,f.z),u.copy(c),l.copy(s)}this.addAttribute("position",new g(new Float32Array(r),3))}function vo(){P.call(this);for(var e=[],t=0;t<100;t++){var r=800*Math.random()-400,i=50*Math.random()+50,n=800*Math.random()-400,a=40*Math.random()+20;e.push(r-a,i,n-a),e.push(r+a,i,n-a),e.push(r-a,i,n+a),e.push(r+a,i,n-a),e.push(r+a,i,n+a),e.push(r-a,i,n+a)}this.addAttribute("position",new g(new Float32Array(e),3))}function go(e){P.call(this);var t=[],r=[],i=new je;i.ray.direction.set(0,-1,0);for(var n=0;n<2e3;n++){var a=500*Math.random()-250,o=500*Math.random()-250;i.ray.origin.set(a,50,o);var s=i.intersectObject(e);if(0!==s.length){var l=s[0].point.y,c=5*Math.random()+.5,u=Math.random()*Math.PI*2;t.push(a+Math.sin(u),l,o+Math.cos(u)),t.push(a,l+c,o),t.push(a+Math.sin(u+Math.PI),l,o+Math.cos(u+Math.PI)),u+=Math.PI/2,t.push(a+Math.sin(u),l,o+Math.cos(u)),t.push(a,l+c,o),t.push(a+Math.sin(u+Math.PI),l,o+Math.cos(u+Math.PI));for(var h=.1*Math.random(),d=0;d<6;d++)r.push(.2+h,.4+h,0)}}this.addAttribute("position",new g(new Float32Array(t),3)),this.addAttribute("color",new g(new Float32Array(r),3))}function yo(e){var t=[];e&&e.isBone&&t.push(e);for(var r=0;rNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(l*l+c*c),m=t.x-s/d,v=t.y+o/d,g=r.x-c/p,y=r.y+l/p,x=((g-m)*c-(y-v)*l)/(o*c-s*l);i=m+o*x-e.x,n=v+s*x-e.y;var b=i*i+n*n;if(b<=2)return new f(i,n);a=Math.sqrt(b/2)}else{var w=!1;o>Number.EPSILON?l>Number.EPSILON&&(w=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(w=!0):Math.sign(s)===Math.sign(c)&&(w=!0),w?(i=-s,n=o,a=Math.sqrt(u)):(i=o,n=s,a=Math.sqrt(u/2))}return new f(i/a,n/a)}function l(){var e=a.length/3;if(w){var t=0,r=q*t;for(Z=0;Z=0;){r=Z,i=Z-1,i<0&&(i=e.length-1);var n=0,a=x+2*A;for(n=0;n=0;V--){for(W=V/A,X=_*Math.cos(W*Math.PI/2),G=S*Math.sin(W*Math.PI/2),Z=0,K=j.length;Z=0?(e(y-u,g,p),f.subVectors(d,p)):(e(y+u,g,p),f.subVectors(p,d)),g-u>=0?(e(y,g-u,p),m.subVectors(d,p)):(e(y,g+u,p),m.subVectors(p,d)),h.crossVectors(f,m).normalize(),l.push(h.x,h.y,h.z),c.push(y,g)}}for(n=0;n0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&!function(){Object.assign=function(e){var t=arguments;if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&r]+e[r>>8&255]+"-"+e[r>>16&15|64]+e[r>>24&255]+"-"+e[63&i|128]+e[i>>8&255]+"-"+e[i>>16&255]+e[i>>24&255]+e[255&n]+e[n>>8&255]+e[n>>16&255]+e[n>>24&255];return a.toUpperCase()}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},lerp:function(e,t,r){return(1-r)*e+r*t},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*e*(3-2*e))},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*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())},degToRad:function(e){return e*Fs.DEG2RAD},radToDeg:function(e){return e*Fs.RAD2DEG},isPowerOfTwo:function(e){return 0===(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))}};Object.assign(r.prototype,{isMatrix4:!0,set:function(e,t,r,i,n,a,o,s,l,c,u,h,d,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=r,v[12]=i,v[1]=n,v[5]=a,v[9]=o,v[13]=s,v[2]=l,v[6]=c,v[10]=u,v[14]=h,v[3]=d,v[7]=p,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new r).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(){var e=new i;return function(t){var r=this.elements,i=t.elements,n=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[3]=0,r[4]=i[4]*a,r[5]=i[5]*a,r[6]=i[6]*a,r[7]=0,r[8]=i[8]*o,r[9]=i[9]*o,r[10]=i[10]*o,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,i=e.y,n=e.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(i),l=Math.sin(i),c=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){var h=a*c,d=a*u,p=o*c,f=o*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=d+p*l,t[5]=h-f*l,t[9]=-o*s,t[2]=f-h*l,t[6]=p+d*l,t[10]=a*s}else if("YXZ"===e.order){var m=s*c,v=s*u,g=l*c,y=l*u;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*l,t[1]=a*u,t[5]=a*c,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var m=s*c,v=s*u,g=l*c,y=l*u;t[0]=m-y*o,t[4]=-a*u,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*c,t[9]=y-m*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var h=a*c,d=a*u,p=o*c,f=o*u;t[0]=s*c,t[4]=p*l-d,t[8]=h*l+f,t[1]=s*u,t[5]=f*l+h,t[9]=d*l-p,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*c,t[4]=_-x*u,t[8]=w*u+b,t[1]=u,t[5]=a*c,t[9]=-o*c,t[2]=-l*c,t[6]=b*u+w,t[10]=x-_*u}else if("XZY"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=x*u+_,t[5]=a*c,t[9]=b*u-w,t[2]=w*u-b,t[6]=o*c,t[10]=_*u+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(){var e=new i(0,0,0),t=new i(1,1,1);return function(r){return this.compose(e,r,t)}}(),lookAt:function(){var e=new i,t=new i,r=new i;return function(i,n,a){var o=this.elements;return r.subVectors(i,n),0===r.lengthSq()&&(r.z=1),r.normalize(),e.crossVectors(a,r),0===e.lengthSq()&&(1===Math.abs(a.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),e.crossVectors(a,r)),e.normalize(),t.crossVectors(r,e),o[0]=e.x,o[4]=t.x,o[8]=r.x,o[1]=e.y,o[5]=t.y,o[9]=r.y,o[2]=e.z,o[6]=t.z,o[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,a=r[0],o=r[4],s=r[8],l=r[12],c=r[1],u=r[5],h=r[9],d=r[13],p=r[2],f=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],b=r[15],w=i[0],_=i[4],S=i[8],A=i[12],M=i[1],T=i[5],E=i[9],C=i[13],L=i[2],P=i[6],N=i[10],O=i[14],D=i[3],F=i[7],I=i[11],R=i[15];return n[0]=a*w+o*M+s*L+l*D,n[4]=a*_+o*T+s*P+l*F,n[8]=a*S+o*E+s*N+l*I,n[12]=a*A+o*C+s*O+l*R,n[1]=c*w+u*M+h*L+d*D,n[5]=c*_+u*T+h*P+d*F,n[9]=c*S+u*E+h*N+d*I,n[13]=c*A+u*C+h*O+d*R,n[2]=p*w+f*M+m*L+v*D,n[6]=p*_+f*T+m*P+v*F,n[10]=p*S+f*E+m*N+v*I,n[14]=p*A+f*C+m*O+v*R,n[3]=g*w+y*M+x*L+b*D,n[7]=g*_+y*T+x*P+b*F,n[11]=g*S+y*E+x*N+b*I,n[15]=g*A+y*C+x*O+b*R,this},multiplyScalar: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},applyToBufferAttribute:function(){var e=new i;return function(t){for(var r=this,i=0,n=t.count;i=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,l=l*m+d*w,c=c*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=_,l*=_,c*=_,u*=_}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}}),Object.defineProperties(n.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(n.prototype,{set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,i=e._y,n=e._z,a=e.order,o=Math.cos,s=Math.sin,l=o(r/2),c=o(i/2),u=o(n/2),h=s(r/2),d=s(i/2),p=s(n/2);return"XYZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"YXZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"ZXY"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"ZYX"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"YZX"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p):"XZY"===a&&(this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p),t!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,r=e.elements,i=r[0],n=r[4],a=r[8],o=r[1],s=r[5],l=r[9],c=r[2],u=r[6],h=r[10],d=i+s+h;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(u-l)*t,this._y=(a-c)*t,this._z=(o-n)*t):i>s&&i>h?(t=2*Math.sqrt(1+i-s-h),this._w=(u-l)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(a+c)/t):s>h?(t=2*Math.sqrt(1+s-i-h),this._w=(a-c)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(l+u)/t):(t=2*Math.sqrt(1+h-i-s),this._w=(o-n)/t,this._x=(a+c)/t,this._y=(l+u)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new i,r=1e-6;return function(n,a){return void 0===t&&(t=new i),e=n.dot(a)+1,eMath.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,a),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),angleTo:function(e){return 2*Math.acos(Math.abs(Fs.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var r=this.angleTo(e);if(0===r)return this;var i=Math.min(1,t/r);return this.slerp(e,i),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize: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},multiply:function(e,t){return void 0!==t?(console.warn("Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,i=e._y,n=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=r*c+a*o+i*l-n*s,this._y=i*c+a*s+n*o-r*l,this._z=n*c+a*l+r*s-i*o,this._w=a*c-r*o-i*s-n*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,i=this._y,n=this._z,a=this._w,o=a*e._w+r*e._x+i*e._y+n*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=r,this._y=i,this._z=n,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*r+t*this._x,this._y=l*i+t*this._y,this._z=l*n+t*this._z,this.normalize()}var c=Math.sqrt(s),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=r*h+this._x*d,this._y=i*h+this._y*d,this._z=n*h+this._z*d,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(a.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[e]&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var r=this._listeners;return void 0!==r[e]&&r[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(void 0!==this._listeners){var r=this._listeners,i=r[e];if(void 0!==i){var n=i.indexOf(t);n!==-1&&i.splice(n,1)}}},dispatchEvent:function(e){var t=this;if(void 0!==this._listeners){var r=this._listeners,i=r[e.type];if(void 0!==i){e.target=this;for(var n=i.slice(0),a=0,o=n.length;a1){for(var i=0;i1){for(var i=0;i0){o.children=[];for(var c=0;c0&&(a.geometries=p),f.length>0&&(a.materials=f),m.length>0&&(a.textures=m),v.length>0&&(a.images=v),l.length>0&&(a.shapes=l)}return a.object=o,a},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){var r=this;if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),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.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.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var i=0;i>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(){function e(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}return function(t,r,i){if(t=Fs.euclideanModulo(t,1),r=Fs.clamp(r,0,1),i=Fs.clamp(i,0,1),0===r)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+r):i+r-i*r,a=2*i-n;this.r=e(a,n,t+1/3),this.g=e(a,n,t),this.b=e(a,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,n=r[1],a=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var c=r[1],u=c.length;if(3===u)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}if(e&&e.length>0){var c=Rs[e];void 0!==c?this.setHex(c):console.warn("Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(){function e(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),copyLinearToSRGB:function(){function e(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,r,i=this.r,n=this.g,a=this.b,o=Math.max(i,n,a),s=Math.min(i,n,a),l=(s+o)/2;if(s===o)t=0,r=0;else{var c=o-s;switch(r=l<=.5?c/(o+s):c/(2-o-s),o){case i:t=(n-a)/c+(nn&&(n=c),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,r,i),this.max.set(n,a,o),this},setFromBufferAttribute:function(e){for(var t=+(1/0),r=+(1/0),i=+(1/0),n=-(1/0),a=-(1/0),o=-(1/0),s=0,l=e.count;sn&&(n=c),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,r,i),this.max.set(n,a,o),this},setFromPoints:function(e){var t=this;this.makeEmpty();for(var r=0,i=e.length;rthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox: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},getParameter:function(e,t){return void 0===t&&(console.warn("Box3: .getParameter() target is now required"),t=new i),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e=new i;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=e.constant&&r>=e.constant},intersectsTriangle:function(){function e(e){var i,a;for(i=0,a=e.length-3;i<=a;i+=3){l.fromArray(e,i);var o=u.x*Math.abs(l.x)+u.y*Math.abs(l.y)+u.z*Math.abs(l.z),s=t.dot(l),c=r.dot(l),h=n.dot(l);if(Math.max(-Math.max(s,c,h),Math.min(s,c,h))>o)return!1}return!0}var t=new i,r=new i,n=new i,a=new i,o=new i,s=new i,l=new i,c=new i,u=new i,h=new i;return function(i){if(this.isEmpty())return!1;this.getCenter(c),u.subVectors(this.max,c),t.subVectors(i.a,c),r.subVectors(i.b,c),n.subVectors(i.c,c),a.subVectors(r,t),o.subVectors(n,r),s.subVectors(t,n);var l=[0,-a.z,a.y,0,-o.z,o.y,0,-s.z,s.y,a.z,0,-a.x,o.z,0,-o.x,s.z,0,-s.x,-a.y,a.x,0,-o.y,o.x,0,-s.y,s.x,0];return!!e(l)&&(l=[1,0,0,0,1,0,0,0,1],!!e(l)&&(h.crossVectors(a,o),l=[h.x,h.y,h.z],e(l)))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("Box3: .clampPoint() target is now required"),t=new i),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new i;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),getBoundingSphere:function(){var e=new i;return function(t){return void 0===t&&(console.warn("Box3: .getBoundingSphere() target is now required"),t=new p),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new i,new i,new i,new i,new i,new i,new i,new i];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(p.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new d;return function(t,r){var i=this.center;void 0!==r?i.copy(r):e.setFromPoints(t).getCenter(i);for(var n=0,a=0,o=t.length;athis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("Sphere: .getBoundingBox() target is now required"),e=new d),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.defineProperties(f.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(f.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent: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},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e=new f,t=new f;return function(r,i){return e.set(r,r),t.set(i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){ +!function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},r={},i={},n={}.hasOwnProperty,a=/^\.\.?(\/|$)/,o=function(e,t){for(var r,i=[],n=(a.test(t)?e+"/"+t:t).split("/"),o=0,s=n.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function r(e){var r=t(e),i=r[0],n=r[1];return 3*(i+n)/4-n}function i(e,t,r){return 3*(t+r)/4-r}function n(e){for(var r,n=t(e),a=n[0],o=n[1],s=new u(i(e,a,o)),l=0,h=o>0?a-4:a,d=0;d>16&255,s[l++]=r>>8&255,s[l++]=255&r;return 2===o&&(r=c[e.charCodeAt(d)]<<2|c[e.charCodeAt(d+1)]>>4,s[l++]=255&r),1===o&&(r=c[e.charCodeAt(d)]<<10|c[e.charCodeAt(d+1)]<<4|c[e.charCodeAt(d+2)]>>2,s[l++]=r>>8&255,s[l++]=255&r),s}function a(e){return l[e>>18&63]+l[e>>12&63]+l[e>>6&63]+l[63&e]}function o(e,t,r){for(var i,n=[],o=t;oc?c:s+a));return 1===i?(t=e[r-1],n.push(l[t>>2]+l[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],n.push(l[t>>10]+l[t>>4&63]+l[t<<2&63]+"=")),n.join("")}e.byteLength=r,e.toByteArray=n,e.fromByteArray=s;for(var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=h.length;d1?arguments[1]:"utf8"):l(this,e)):arguments.length>1?new a(e,arguments[1]):new a(e)}function o(e,t){if(e=m(e,t<0?0:0|v(t)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;r>>1;return r&&(e.parent=Z),e}function v(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function g(e,t){if(!(this instanceof g))return new g(e,t);var r=new a(e,t);return delete r.parent,r}function y(e,t){"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(i)return G(e).length;t=(""+t).toLowerCase(),i=!0}}function x(e,t,r){var i=!1;if(t=0|t,r=void 0===r||r===1/0?this.length:0|r,e||(e="utf8"),t<0&&(t=0),r>this.length&&(r=this.length),r<=t)return"";for(;;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return L(this,t,r);case"binary":return P(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function b(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(n+s<=r){var l,c,u,h;switch(s){case 1:a<128&&(o=a);break;case 2:l=e[n+1],128===(192&l)&&(h=(31&a)<<6|63&l,h>127&&(o=h));break;case 3:l=e[n+1],c=e[n+2],128===(192&l)&&128===(192&c)&&(h=(15&a)<<12|(63&l)<<6|63&c,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:l=e[n+1],c=e[n+2],u=e[n+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(h=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,h>65535&&h<1114112&&(o=h))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return C(i)}function C(e){var t=e.length;if(t<=K)return String.fromCharCode.apply(String,e);for(var r="",i=0;ii)&&(r=i);for(var n="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,r,i,n,o){if(!a.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>n||te.length)throw new RangeError("index out of range")}function R(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-r,2);n>>8*(i?n:1-n)}function I(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-r,4);n>>8*(i?n:3-n)&255}function U(e,t,r,i,n,a){if(t>n||te.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function k(e,t,r,i,n){return n||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(e,t,r,i,23,4),r+4}function B(e,t,r,i,n){return n||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(e,t,r,i,52,8),r+8}function z(e){if(e=j(e).replace($,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function j(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function G(e,t){t=t||1/0;for(var r,i=e.length,n=null,a=[],o=0;o55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function W(e){for(var t=[],r=0;r>8,n=r%256,a.push(n),a.push(i);return a}function H(e){return q.toByteArray(z(e))}function Y(e,t,r,i){for(var n=0;n=t.length||n>=e.length);n++)t[n+r]=e[n];return n}var q=i("base64-js"),Q=i("ieee754"),J=i("isarray");e.Buffer=a,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,a.poolSize=8192;var Z={};a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),a._augment=function(e){return e.__proto__=a.prototype,e},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},a.prototype.compare=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:a.compare(this,e)},a.prototype.indexOf=function(e,t){function r(e,t,r){for(var i=-1,n=0;r+n2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(t<0&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(a.isBuffer(e))return r(this,e,t);if("number"==typeof e)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(r)?(r=0|r,void 0===i&&(i="utf8")):(i=r,r=void 0);else{var n=i;i=t,t=0|r,r=n}var a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return _(this,e,t,r);case"binary":return S(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;a.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t0&&(n*=256);)i+=this[e+--t]*n;return i},a.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||D(e,t,this.length);for(var i=this[e],n=1,a=0;++a=n&&(i-=Math.pow(2,8*t)),i},a.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||D(e,t,this.length);for(var i=t,n=1,a=this[e+--i];i>0&&(n*=256);)a+=this[e+--i]*n;return n*=128,a>=n&&(a-=Math.pow(2,8*t)),a},a.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),Q.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),Q.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),Q.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),Q.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,i){e=+e,t=0|t,r=0|r,i||F(this,e,t,r,Math.pow(2,8*r),0);var n=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+n]=e/a&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):I(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):I(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);F(this,e,t,r,n-1,-n)}var a=0,o=1,s=e<0?1:0;for(this[t]=255&e;++a>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);F(this,e,t,r,n-1,-n)}var a=r-1,o=1,s=e<0?1:0;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=(e/o>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):I(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):I(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;n--)e[n+t]=this[n+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(n=0;n=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof e)for(i=t;i=0;i--)r=[e[i].apply(this,r)];return r[0]}},each:function(t,r,i){if(e&&t.forEach===e)t.forEach(r,i);else if(t.length===t.length+0){for(var n=0,a=t.length;n1?t.toArray(arguments):arguments[0];return t.each(a,function(n){if(n.litmus(e))return t.each(n.conversions,function(n,a){if(r=n.read(e),i===!1&&r!==!1)return i=r,r.conversionName=a,r.conversion=n,t.BREAK}),t.BREAK}),i},a=[{litmus:t.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString())}},write:e},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:e},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:e}}},{litmus:t.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:t.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:t.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b)&&t.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v)&&t.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}];return n}(e.color.toString,e.utils.common),e.color.math=function(){var e;return{hsv_to_rgb:function(e,t,r){var i=Math.floor(e/60)%6,n=e/60-Math.floor(e/60),a=r*(1-t),o=r*(1-n*t),s=r*(1-(1-n)*t),l=[[r,s,a],[o,r,a],[a,r,s],[a,o,r],[s,a,r],[r,a,o]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,r){var i,n,a=Math.min(e,t,r),o=Math.max(e,t,r),s=o-a;return 0==o?{h:NaN,s:0,v:0}:(n=s/o,i=e==o?(t-r)/s:t==o?2+(r-e)/s:4+(e-t)/s,i/=6,i<0&&(i+=1),{h:360*i,s:n,v:o/255})},rgb_to_hex:function(e,t,r){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),i=this.hex_with_component(i,0,r)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(t,r,i){return i<<(e=8*r)|t&~(255<=0;i--)r=[e[i].apply(this,r)];return r[0]}},each:function(t,r,i){if(e&&t.forEach===e)t.forEach(r,i);else if(t.length===t.length+0){for(var n=0,a=t.length;n-1?e.length-e.indexOf(".")-1:0}var i=function(e,n,a){i.superclass.call(this,e,n),a=a||{},this.__min=a.min,this.__max=a.max,this.__step=a.step,t.isUndefined(this.__step)?0==this.initialValue?this.__impliedStep=1:this.__impliedStep=Math.pow(10,Math.floor(Math.log(this.initialValue)/Math.LN10))/10:this.__impliedStep=this.__step,this.__precision=r(this.__impliedStep)};return i.superclass=e,t.extend(i.prototype,e.prototype,{setValue:function(e){return void 0!==this.__min&&ethis.__max&&(e=this.__max),void 0!==this.__step&&e%this.__step!=0&&(e=Math.round(e/this.__step)*this.__step),i.superclass.prototype.setValue.call(this,e)},min:function(e){return this.__min=e,this},max:function(e){return this.__max=e,this},step:function(e){return this.__step=e,this}}),i}(e.controllers.Controller,e.utils.common),e.controllers.NumberControllerBox=function(e,t,r){function i(e,t){var r=Math.pow(10,t);return Math.round(e*r)/r}var n=function(e,i,a){function o(){var e=parseFloat(d.__input.value);r.isNaN(e)||d.setValue(e)}function s(){o(),d.__onFinishChange&&d.__onFinishChange.call(d,d.getValue())}function l(e){t.bind(window,"mousemove",c),t.bind(window,"mouseup",u),h=e.clientY}function c(e){var t=h-e.clientY;d.setValue(d.getValue()+t*d.__impliedStep),h=e.clientY}function u(){t.unbind(window,"mousemove",c),t.unbind(window,"mouseup",u)}this.__truncationSuspended=!1,n.superclass.call(this,e,i,a);var h,d=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),t.bind(this.__input,"change",o),t.bind(this.__input,"blur",s),t.bind(this.__input,"mousedown",l),t.bind(this.__input,"keydown",function(e){13===e.keyCode&&(d.__truncationSuspended=!0,this.blur(),d.__truncationSuspended=!1)}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return n.superclass=e,r.extend(n.prototype,e.prototype,{updateDisplay:function(){return this.__input.value=this.__truncationSuspended?this.getValue():i(this.getValue(),this.__precision),n.superclass.prototype.updateDisplay.call(this)}}),n}(e.controllers.NumberController,e.dom.dom,e.utils.common),e.controllers.NumberControllerSlider=function(e,t,r,i,n){function a(e,t,r,i,n){return i+(n-i)*((e-t)/(r-t))}var o=function(e,r,i,n,s){function l(e){t.bind(window,"mousemove",c),t.bind(window,"mouseup",u),c(e)}function c(e){e.preventDefault();var r=t.getOffset(h.__background),i=t.getWidth(h.__background);return h.setValue(a(e.clientX,r.left,r.left+i,h.__min,h.__max)),!1}function u(){t.unbind(window,"mousemove",c),t.unbind(window,"mouseup",u),h.__onFinishChange&&h.__onFinishChange.call(h,h.getValue())}o.superclass.call(this,e,r,{min:i,max:n,step:s});var h=this;this.__background=document.createElement("div"),this.__foreground=document.createElement("div"),t.bind(this.__background,"mousedown",l),t.addClass(this.__background,"slider"),t.addClass(this.__foreground,"slider-fg"),this.updateDisplay(),this.__background.appendChild(this.__foreground),this.domElement.appendChild(this.__background)};return o.superclass=e,o.useDefaultStyles=function(){r.inject(n)},i.extend(o.prototype,e.prototype,{updateDisplay:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",o.superclass.prototype.updateDisplay.call(this)}}),o}(e.controllers.NumberController,e.dom.dom,e.utils.css,e.utils.common,".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"),e.controllers.FunctionController=function(e,t,r){var i=function(e,r,n){i.superclass.call(this,e,r);var a=this;this.__button=document.createElement("div"),this.__button.innerHTML=void 0===n?"Fire":n,t.bind(this.__button,"click",function(e){return e.preventDefault(),a.fire(),!1}),t.addClass(this.__button,"button"),this.domElement.appendChild(this.__button)};return i.superclass=e,r.extend(i.prototype,e.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.getValue().call(this.object)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.controllers.BooleanController=function(e,t,r){var i=function(e,r){function n(){a.setValue(!a.__prev)}i.superclass.call(this,e,r);var a=this;this.__prev=this.getValue(),this.__checkbox=document.createElement("input"),this.__checkbox.setAttribute("type","checkbox"),t.bind(this.__checkbox,"change",n,!1),this.domElement.appendChild(this.__checkbox),this.updateDisplay()};return i.superclass=e,r.extend(i.prototype,e.prototype,{setValue:function(e){var t=i.superclass.prototype.setValue.call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),t},updateDisplay:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0):this.__checkbox.checked=!1,i.superclass.prototype.updateDisplay.call(this)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.color.toString=function(e){return function(t){if(1==t.a||e.isUndefined(t.a)){for(var r=t.hex.toString(16);r.length<6;)r="0"+r;return"#"+r}return"rgba("+Math.round(t.r)+","+Math.round(t.g)+","+Math.round(t.b)+","+t.a+")"}}(e.utils.common),e.color.interpret=function(e,t){var r,i,n=function(){i=!1;var e=arguments.length>1?t.toArray(arguments):arguments[0];return t.each(a,function(n){if(n.litmus(e))return t.each(n.conversions,function(n,a){if(r=n.read(e),i===!1&&r!==!1)return i=r,r.conversionName=a,r.conversion=n,t.BREAK}),t.BREAK}),i},a=[{litmus:t.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString())}},write:e},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:e},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:e}}},{litmus:t.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:t.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4==e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:t.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b)&&t.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(t.isNumber(e.r)&&t.isNumber(e.g)&&t.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v)&&t.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(t.isNumber(e.h)&&t.isNumber(e.s)&&t.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}];return n}(e.color.toString,e.utils.common),e.GUI=e.gui.GUI=function(e,t,r,i,n,a,o,s,l,c,u,h,d,p,f){function m(e,t,r,a){if(void 0===t[r])throw new Error("Object "+t+' has no property "'+r+'"');var o;if(a.color)o=new u(t,r);else{var s=[t,r].concat(a.factoryArgs);o=i.apply(e,s)}a.before instanceof n&&(a.before=a.before.__li),y(e,o),p.addClass(o.domElement,"c");var l=document.createElement("span");p.addClass(l,"property-name"),l.innerHTML=o.property;var c=document.createElement("div");c.appendChild(l),c.appendChild(o.domElement);var h=v(e,c,a.before);return p.addClass(h,k.CLASS_CONTROLLER_ROW),p.addClass(h,typeof o.getValue()),g(e,h,o),e.__controllers.push(o),o}function v(e,t,r){var i=document.createElement("li");return t&&i.appendChild(t),r?e.__ul.insertBefore(i,params.before):e.__ul.appendChild(i),e.onResize(),i}function g(e,t,r){if(r.__li=t,r.__gui=e,f.extend(r,{options:function(t){return arguments.length>1?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[f.toArray(arguments)]})):f.isArray(t)||f.isObject(t)?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[t]})):void 0},name:function(e){return r.__li.firstElementChild.firstElementChild.innerHTML=e,r},listen:function(){return r.__gui.listen(r),r},remove:function(){return r.__gui.remove(r),r}}),r instanceof l){var i=new s(r.object,r.property,{min:r.__min,max:r.__max,step:r.__step});f.each(["updateDisplay","onChange","onFinishChange"],function(e){var t=r[e],n=i[e];r[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return t.apply(r,e),n.apply(i,e)}}),p.addClass(t,"has-slider"),r.domElement.insertBefore(i.domElement,r.domElement.firstElementChild)}else if(r instanceof s){var n=function(t){return f.isNumber(r.__min)&&f.isNumber(r.__max)?(r.remove(),m(e,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[r.__min,r.__max,r.__step]})):t};r.min=f.compose(n,r.min),r.max=f.compose(n,r.max)}else r instanceof a?(p.bind(t,"click",function(){p.fakeEvent(r.__checkbox,"click")}),p.bind(r.__checkbox,"click",function(e){e.stopPropagation()})):r instanceof o?(p.bind(t,"click",function(){p.fakeEvent(r.__button,"click")}),p.bind(t,"mouseover",function(){p.addClass(r.__button,"hover")}),p.bind(t,"mouseout",function(){p.removeClass(r.__button,"hover")})):r instanceof u&&(p.addClass(t,"color"),r.updateDisplay=f.compose(function(e){return t.style.borderLeftColor=r.__color.toString(),e},r.updateDisplay),r.updateDisplay());r.setValue=f.compose(function(t){return e.getRoot().__preset_select&&r.isModified()&&T(e.getRoot(),!0),t},r.setValue)}function y(e,t){var r=e.getRoot(),i=r.__rememberedObjects.indexOf(t.object);if(i!=-1){var n=r.__rememberedObjectIndecesToControllers[i];if(void 0===n&&(n={},r.__rememberedObjectIndecesToControllers[i]=n),n[t.property]=t,r.load&&r.load.remembered){var a,o=r.load.remembered;if(o[e.preset])a=o[e.preset];else{if(!o[D])return;a=o[D]}if(a[i]&&void 0!==a[i][t.property]){var s=a[i][t.property];t.initialValue=s,t.setValue(s)}}}}function x(e,t){return document.location.href+"."+t}function b(e){function t(){c.style.display=e.useLocalStorage?"block":"none"}var r=e.__save_row=document.createElement("li");p.addClass(e.domElement,"has-save"),e.__ul.insertBefore(r,e.__ul.firstChild),p.addClass(r,"save-row");var i=document.createElement("span");i.innerHTML=" ",p.addClass(i,"button gears");var n=document.createElement("span");n.innerHTML="Save",p.addClass(n,"button"),p.addClass(n,"save");var a=document.createElement("span");a.innerHTML="New",p.addClass(a,"button"),p.addClass(a,"save-as");var o=document.createElement("span");o.innerHTML="Revert",p.addClass(o,"button"),p.addClass(o,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?f.each(e.load.remembered,function(t,r){A(e,r,r==e.preset)}):A(e,D,!1),p.bind(s,"change",function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=S(this)),e.folders={},f.each(this.__folders,function(t,r){e.folders[r]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=S(this),T(this,!1)},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[D]=S(this,!0)),this.load.remembered[e]=S(this),this.preset=e,A(this,e,!0)},revert:function(e){f.each(this.__controllers,function(t){this.getRoot().load.remembered?y(e||this.getRoot(),t):t.setValue(t.initialValue)},this),f.each(this.__folders,function(e){e.revert(e)}),e||T(this.getRoot(),!1)},listen:function(e){var t=0==this.__listening.length;this.__listening.push(e),t&&E(this.__listening)}}),k}(e.utils.css,'
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
',".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n",e.controllers.factory=function(e,t,r,i,n,a,o){return function(s,l){var c=s[l];return o.isArray(arguments[2])||o.isObject(arguments[2])?new e(s,l,arguments[2]):o.isNumber(c)?o.isNumber(arguments[2])&&o.isNumber(arguments[3])?new r(s,l,arguments[2],arguments[3]):new t(s,l,{min:arguments[2],max:arguments[3]}):o.isString(c)?new i(s,l):o.isFunction(c)?new n(s,l,""):o.isBoolean(c)?new a(s,l):void 0}}(e.controllers.OptionController,e.controllers.NumberControllerBox,e.controllers.NumberControllerSlider,e.controllers.StringController=function(e,t,r){var i=function(e,r){function n(){o.setValue(o.__input.value)}function a(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}i.superclass.call(this,e,r);var o=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),t.bind(this.__input,"keyup",n),t.bind(this.__input,"change",n),t.bind(this.__input,"blur",a),t.bind(this.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return i.superclass=e,r.extend(i.prototype,e.prototype,{updateDisplay:function(){return t.isActive(this.__input)||(this.__input.value=this.getValue()),i.superclass.prototype.updateDisplay.call(this)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.controllers.FunctionController,e.controllers.BooleanController,e.utils.common),e.controllers.Controller,e.controllers.BooleanController,e.controllers.FunctionController,e.controllers.NumberControllerBox,e.controllers.NumberControllerSlider,e.controllers.OptionController,e.controllers.ColorController=function(e,t,r,i,n){function a(e,t,r,i){e.style.background="",n.each(l,function(n){e.style.cssText+="background: "+n+"linear-gradient("+t+", "+r+" 0%, "+i+" 100%); "})}function o(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var s=function(e,l){function c(e){p(e),t.bind(window,"mousemove",p),t.bind(window,"mouseup",u)}function u(){t.unbind(window,"mousemove",p),t.unbind(window,"mouseup",u)}function h(){var e=i(this.value);e!==!1?(m.__color.__state=e,m.setValue(m.__color.toOriginal())):this.value=m.__color.toString()}function d(){t.unbind(window,"mousemove",f),t.unbind(window,"mouseup",d)}function p(e){e.preventDefault();var r=t.getWidth(m.__saturation_field),i=t.getOffset(m.__saturation_field),n=(e.clientX-i.left+document.body.scrollLeft)/r,a=1-(e.clientY-i.top+document.body.scrollTop)/r;return a>1?a=1:a<0&&(a=0),n>1?n=1:n<0&&(n=0),m.__color.v=a,m.__color.s=n,m.setValue(m.__color.toOriginal()),!1}function f(e){e.preventDefault();var r=t.getHeight(m.__hue_field),i=t.getOffset(m.__hue_field),n=1-(e.clientY-i.top+document.body.scrollTop)/r;return n>1?n=1:n<0&&(n=0),m.__color.h=360*n,m.setValue(m.__color.toOriginal()),!1}s.superclass.call(this,e,l),this.__color=new r(this.getValue()),this.__temp=new r(0);var m=this;this.domElement=document.createElement("div"),t.makeSelectable(this.domElement,!1),this.__selector=document.createElement("div"),this.__selector.className="selector",this.__saturation_field=document.createElement("div"),this.__saturation_field.className="saturation-field",this.__field_knob=document.createElement("div"),this.__field_knob.className="field-knob",this.__field_knob_border="2px solid ",this.__hue_knob=document.createElement("div"),this.__hue_knob.className="hue-knob",this.__hue_field=document.createElement("div"), +this.__hue_field.className="hue-field",this.__input=document.createElement("input"),this.__input.type="text",this.__input_textShadow="0 1px 1px ",t.bind(this.__input,"keydown",function(e){13===e.keyCode&&h.call(this)}),t.bind(this.__input,"blur",h),t.bind(this.__selector,"mousedown",function(e){t.addClass(this,"drag").bind(window,"mouseup",function(e){t.removeClass(m.__selector,"drag")})});var v=document.createElement("div");n.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),n.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),n.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),n.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),n.extend(v.style,{width:"100%",height:"100%",background:"none"}),a(v,"top","rgba(0,0,0,0)","#000"),n.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"}),o(this.__hue_field),n.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"}),t.bind(this.__saturation_field,"mousedown",c),t.bind(this.__field_knob,"mousedown",c),t.bind(this.__hue_field,"mousedown",function(e){f(e),t.bind(window,"mousemove",f),t.bind(window,"mouseup",d)}),this.__saturation_field.appendChild(v),this.__selector.appendChild(this.__field_knob),this.__selector.appendChild(this.__saturation_field),this.__selector.appendChild(this.__hue_field),this.__hue_field.appendChild(this.__hue_knob),this.domElement.appendChild(this.__input),this.domElement.appendChild(this.__selector),this.updateDisplay()};s.superclass=e,n.extend(s.prototype,e.prototype,{updateDisplay:function(){var e=i(this.getValue());if(e!==!1){var t=!1;n.each(r.COMPONENTS,function(r){if(!n.isUndefined(e[r])&&!n.isUndefined(this.__color.__state[r])&&e[r]!==this.__color.__state[r])return t=!0,{}},this),t&&n.extend(this.__color.__state,e)}n.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var o=this.__color.v<.5||this.__color.s>.5?255:0,s=255-o;n.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+"rgb("+o+","+o+","+o+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,a(this.__saturation_field,"left","#fff",this.__temp.toString()),n.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+o+","+o+","+o+")",textShadow:this.__input_textShadow+"rgba("+s+","+s+","+s+",.7)"})}});var l=["-moz-","-o-","-webkit-","-ms-",""];return s}(e.controllers.Controller,e.dom.dom,e.color.Color=function(e,t,r,i){function n(e,t,r){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space?this.__state[t]:(o(this,t,r),this.__state[t])},set:function(e){"RGB"!==this.__state.space&&(o(this,t,r),this.__state.space="RGB"),this.__state[t]=e}})}function a(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space?this.__state[t]:(s(this),this.__state[t])},set:function(e){"HSV"!==this.__state.space&&(s(this),this.__state.space="HSV"),this.__state[t]=e}})}function o(e,r,n){if("HEX"===e.__state.space)e.__state[r]=t.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw"Corrupted color state";i.extend(e.__state,t.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}}function s(e){var r=t.rgb_to_hsv(e.r,e.g,e.b);i.extend(e.__state,{s:r.s,v:r.v}),i.isNaN(r.h)?i.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=r.h}var l=function(){if(this.__state=e.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return l.COMPONENTS=["r","g","b","h","s","v","hex","a"],i.extend(l.prototype,{toString:function(){return r(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),n(l.prototype,"r",2),n(l.prototype,"g",1),n(l.prototype,"b",0),a(l.prototype,"h"),a(l.prototype,"s"),a(l.prototype,"v"),Object.defineProperty(l.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(l.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=t.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}}),l}(e.color.interpret,e.color.math=function(){var e;return{hsv_to_rgb:function(e,t,r){var i=Math.floor(e/60)%6,n=e/60-Math.floor(e/60),a=r*(1-t),o=r*(1-n*t),s=r*(1-(1-n)*t),l=[[r,s,a],[o,r,a],[a,r,s],[a,o,r],[s,a,r],[r,a,o]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,r){var i,n,a=Math.min(e,t,r),o=Math.max(e,t,r),s=o-a;return 0==o?{h:NaN,s:0,v:0}:(n=s/o,i=e==o?(t-r)/s:t==o?2+(r-e)/s:4+(e-t)/s,i/=6,i<0&&(i+=1),{h:360*i,s:n,v:o/255})},rgb_to_hex:function(e,t,r){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),i=this.hex_with_component(i,0,r)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(t,r,i){return i<<(e=8*r)|t&~(255<>1,u=-7,h=r?n-1:0,d=r?-1:1,p=e[t+h];for(h+=d,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+e[t+h],h+=d,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=i;u>0;o=256*o+e[t+h],h+=d,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),a-=c}return(p?-1:1)*o*Math.pow(2,a-i)},e.write=function(e,t,r,i,n,a){var o,s,l,c=8*a-n-1,u=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),t+=o+h>=1?d/l:d*Math.pow(2,1-h),t*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(t*l-1)*Math.pow(2,n),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),o=0));n>=8;e[r+p]=255&s,p+=f,s/=256,n-=8);for(o=o<0;e[r+p]=255&o,p+=f,o/=256,c-=8);e[r+p-f]|=128*m}}()}),require.register("isarray/index.js",function(e,t,i){t=r(t,{},"isarray"),function(){var e={}.toString;i.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}}()}),require.register("process/browser.js",function(e,t,i){t=r(t,{},"process"),function(){function e(){throw new Error("setTimeout has not been defined")}function t(){throw new Error("clearTimeout has not been defined")}function r(t){if(c===setTimeout)return setTimeout(t,0);if((c===e||!c)&&setTimeout)return c=setTimeout,setTimeout(t,0);try{return c(t,0)}catch(r){try{return c.call(null,t,0)}catch(r){return c.call(this,t,0)}}}function n(e){if(u===clearTimeout)return clearTimeout(e);if((u===t||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch(r){try{return u.call(null,e)}catch(r){return u.call(this,e)}}}function a(){f&&d&&(f=!1,d.length?p=d.concat(p):m=-1,p.length&&o())}function o(){if(!f){var e=r(a);f=!0;for(var t=p.length;t;){for(d=p,p=[];++m1)for(var i=1;i0&&console.error("Matrix4: the constructor no longer reads arguments. use .set() instead.")}function i(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0}function n(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==i?i:1}function a(){}function o(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._order=i||o.DefaultOrder}function s(){this.mask=1}function l(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("Matrix3: the constructor no longer reads arguments. use .set() instead.")}function c(){function e(){h.setFromEuler(u,!1)}function t(){u.setFromQuaternion(h,void 0,!1)}Object.defineProperty(this,"id",{value:Rs++}),this.uuid=Fs.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DefaultUp.clone();var a=new i,u=new o,h=new n,d=new i(1,1,1);u.onChange(e),h.onChange(t),Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:u},quaternion:{enumerable:!0,value:h},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new r},normalMatrix:{value:new l}}),this.matrix=new r,this.matrixWorld=new r,this.matrixAutoUpdate=c.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new s,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function u(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}function h(e,t,r,n,a,o){this.a=e,this.b=t,this.c=r,this.normal=n&&n.isVector3?n:new i,this.vertexNormals=Array.isArray(n)?n:[],this.color=a&&a.isColor?a:new u,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=void 0!==o?o:0}function d(e,t){this.min=void 0!==e?e:new i((+(1/0)),(+(1/0)),(+(1/0))),this.max=void 0!==t?t:new i((-(1/0)),(-(1/0)),(-(1/0)))}function p(e,t){this.center=void 0!==e?e:new i,this.radius=void 0!==t?t:0}function f(e,t){this.x=e||0,this.y=t||0}function m(){Object.defineProperty(this,"id",{value:Us+=2}),this.uuid=Fs.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function v(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1}function g(e,t,r){if(Array.isArray(e))throw new TypeError("BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=r===!0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function y(e,t,r){g.call(this,new Int8Array(e),t,r)}function x(e,t,r){g.call(this,new Uint8Array(e),t,r)}function b(e,t,r){g.call(this,new Uint8ClampedArray(e),t,r)}function w(e,t,r){g.call(this,new Int16Array(e),t,r)}function _(e,t,r){g.call(this,new Uint16Array(e),t,r)}function S(e,t,r){g.call(this,new Int32Array(e),t,r)}function A(e,t,r){g.call(this,new Uint32Array(e),t,r)}function M(e,t,r){g.call(this,new Float32Array(e),t,r)}function T(e,t,r){g.call(this,new Float64Array(e),t,r)}function E(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function C(e){if(0===e.length)return 1/0;for(var t=e[0],r=1,i=e.length;rt&&(t=e[r]);return t}function P(){Object.defineProperty(this,"id",{value:ks+=2}),this.uuid=Fs.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function N(e,t,r,i,n,a,o){m.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:n,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new O(e,t,r,i,n,a,o)),this.mergeVertices()}function O(e,t,r,n,a,o,s){P.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:n,phiLength:a,thetaStart:o,thetaLength:s},e=e||1,t=Math.max(3,Math.floor(t)||8),r=Math.max(2,Math.floor(r)||6),n=void 0!==n?n:0,a=void 0!==a?a:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;var l,c,u=o+s,h=0,d=[],p=new i,f=new i,m=[],v=[],g=[],y=[];for(c=0;c<=r;c++){var x=[],b=c/r;for(l=0;l<=t;l++){var w=l/t;p.x=-e*Math.cos(n+w*a)*Math.sin(o+b*s),p.y=e*Math.cos(o+b*s),p.z=e*Math.sin(n+w*a)*Math.sin(o+b*s),v.push(p.x,p.y,p.z),f.set(p.x,p.y,p.z).normalize(),g.push(f.x,f.y,f.z),y.push(w,1-b),x.push(h++)}d.push(x)}for(c=0;c0)&&m.push(_,S,T),(c!==r-1||u0?1:-1,h.push(P.x,P.y,P.z),d.push(x/v),d.push(1-b/g),C+=1}}for(b=0;b0&&u(!0),t>0&&u(!1)),this.setIndex(d),this.addAttribute("position",new M(p,3)),this.addAttribute("normal",new M(m,3)),this.addAttribute("uv",new M(v,2))}function he(){c.call(this),this.type="Camera",this.matrixWorldInverse=new r,this.projectionMatrix=new r,this.projectionMatrixInverse=new r}function de(e,t,r,i){he.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==r?r:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function pe(e){D.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("ShaderMaterial: attributes should now be defined in BufferGeometry instead."),this.setValues(e))}function fe(){c.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function me(e,t,r,i,n,a){he.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=void 0!==n?n:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function ve(e,t,r,i,n,a,o,s,c,u){Object.defineProperty(this,"id",{value:Eu++}),this.uuid=Fs.generateUUID(),this.name="",this.image=void 0!==e?e:ve.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:ve.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:Zl,this.wrapT=void 0!==i?i:Zl,this.magFilter=void 0!==n?n:rc,this.minFilter=void 0!==a?a:nc,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:xc,this.type=void 0!==s?s:ac,this.offset=new f(0,0),this.repeat=new f(1,1),this.center=new f(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new l,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:ou,this.version=0,this.onUpdate=null}function ge(e,t,r){this.width=e,this.height=t,this.scissor=new v(0,0,e,t),this.scissorTest=!1,this.viewport=new v(0,0,e,t),r=r||{},void 0===r.minFilter&&(r.minFilter=rc),this.texture=new ve((void 0),(void 0),r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.generateMipmaps=void 0===r.generateMipmaps||r.generateMipmaps,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function ye(e,t,r,i){m.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i},this.fromBufferGeometry(new xe(e,t,r,i)),this.mergeVertices()}function xe(e,t,r,i){P.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i},e=e||1,t=t||1;var n,a,o=e/2,s=t/2,l=Math.floor(r)||1,c=Math.floor(i)||1,u=l+1,h=c+1,d=e/l,p=t/c,f=[],m=[],v=[],g=[];for(a=0;a.9&&a<.1&&(t<.2&&(y[e+0]+=1),r<.2&&(y[e+2]+=1),i<.2&&(y[e+4]+=1))}}function u(e){g.push(e.x,e.y,e.z)}function h(t,r){var i=3*t;r.x=e[i+0],r.y=e[i+1],r.z=e[i+2]}function d(){for(var e=new i,t=new i,r=new i,n=new i,a=new f,o=new f,s=new f,l=0,c=0;l0,s=v>0,l=g>0,f=(o?1:0)+(s?1:0)+(l?1:0)){case 0:r.push(e[n]),r.push(e[n+1]),r.push(e[n+2]);break;case 1:if(o&&(u=e[n+1],h=e[n+2],d=c(e[n],u,t,i),p=c(e[n],h,t,i)),s){u=e[n],h=e[n+2],d=c(e[n+1],u,t,i),p=c(e[n+1],h,t,i),r.push(d),r.push(h.clone()),r.push(u.clone()),r.push(h.clone()),r.push(d.clone()),r.push(p);break}l&&(u=e[n],h=e[n+1],d=c(e[n+2],u,t,i),p=c(e[n+2],h,t,i)),r.push(u.clone()),r.push(h.clone()),r.push(d),r.push(p),r.push(d.clone()),r.push(h.clone());break;case 2:o||(u=e[n].clone(),h=c(u,e[n+1],t,i),d=c(u,e[n+2],t,i),r.push(u),r.push(h),r.push(d)),s||(u=e[n+1].clone(),h=c(u,e[n+2],t,i),d=c(u,e[n],t,i),r.push(u),r.push(h),r.push(d)),l||(u=e[n+2].clone(),h=c(u,e[n],t,i),d=c(u,e[n+1],t,i),r.push(u),r.push(h),r.push(d));break;case 3:}}return r}function c(e,t,r,n){var a=e.position.dot(r)-n,o=t.position.dot(r)-n,s=a/(a-o),l=new _t(new i(e.position.x+s*(t.position.x-e.position.x),e.position.y+s*(t.position.y-e.position.y),e.position.z+s*(t.position.z-e.position.z)),new i(e.normal.x+s*(t.normal.x-e.normal.x),e.normal.y+s*(t.normal.y-e.normal.y),e.normal.z+s*(t.normal.z-e.normal.z)));return l}P.call(this);var u=[],h=[],d=[],p=new i,f=new r;f.makeRotationFromEuler(n),f.setPosition(t);var m=(new r).getInverse(f);o(),this.addAttribute("position",new M(u,3)),this.addAttribute("normal",new M(h,3)),this.addAttribute("uv",new M(d,2))}function _t(e,t){this.position=e,this.normal=t}function St(e,t,r,n,a,o,s){var e=void 0!==e?e:new i(0,0,0),t=void 0!==t?t:10,l=t/2,r=void 0!==r?r:1,n=void 0!==n?n:0,a=void 0!==a?a:1,o=void 0!==o?o:2,s=void 0!==s?s:3,c=[new i(e.x-l,e.y,e.z-l),new i(e.x-l,e.y,e.z+l),new i(e.x+l,e.y,e.z+l),new i(e.x+l,e.y,e.z-l)],u=[c[n],c[a],c[o],c[s]];if(0<=--r){var h=[];return Array.prototype.push.apply(h,St(u[0],l,r,n,s,o,a)),Array.prototype.push.apply(h,St(u[1],l,r,n,a,o,s)),Array.prototype.push.apply(h,St(u[2],l,r,n,a,o,s)),Array.prototype.push.apply(h,St(u[3],l,r,o,a,n,s)),h}return u}function At(e,t,r,n,a,o,s,l,c,u,h){var e=void 0!==e?e:new i(0,0,0),t=void 0!==t?t:10,d=t/2,r=void 0!==r?r:1,n=void 0!==n?n:0,a=void 0!==a?a:1,o=void 0!==o?o:2,s=void 0!==s?s:3,l=void 0!==l?l:4,c=void 0!==c?c:5,u=void 0!==u?u:6,h=void 0!==h?h:7,p=[new i(e.x-d,e.y+d,e.z-d),new i(e.x-d,e.y+d,e.z+d),new i(e.x-d,e.y-d,e.z+d),new i(e.x-d,e.y-d,e.z-d),new i(e.x+d,e.y-d,e.z-d),new i(e.x+d,e.y-d,e.z+d),new i(e.x+d,e.y+d,e.z+d),new i(e.x+d,e.y+d,e.z-d)],f=[p[n],p[a],p[o],p[s],p[l],p[c],p[u],p[h]];if(--r>=0){var m=[];return Array.prototype.push.apply(m,At(f[0],d,r,n,s,l,h,u,c,o,a)),Array.prototype.push.apply(m,At(f[1],d,r,n,h,u,a,o,c,l,s)),Array.prototype.push.apply(m,At(f[2],d,r,n,h,u,a,o,c,l,s)),Array.prototype.push.apply(m,At(f[3],d,r,o,s,n,a,u,h,l,c)),Array.prototype.push.apply(m,At(f[4],d,r,o,s,n,a,u,h,l,c)),Array.prototype.push.apply(m,At(f[5],d,r,l,s,o,c,u,a,n,h)),Array.prototype.push.apply(m,At(f[6],d,r,l,s,o,c,u,a,n,h)),Array.prototype.push.apply(m,At(f[7],d,r,u,c,o,a,n,s,l,h)),m}return f}function Mt(e,t,r,i,n,a,o,s,l,c,u,h){ve.call(this,null,a,o,s,l,c,i,n,u,h),this.image={data:e,width:t,height:r},this.magFilter=void 0!==l?l:$l,this.minFilter=void 0!==c?c:$l,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Tt(e,t,r){function i(r){r.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}function n(e,t){t=t||{};var r=new pe({uniforms:t,vertexShader:a(),fragmentShader:e});return i(r),r}function a(){return"void main()\t{\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n"}function o(){return"uniform sampler2D texture;\n\nvoid main() {\n\n\tvec2 uv = gl_FragCoord.xy / resolution.xy;\n\n\tgl_FragColor = texture2D( texture, uv );\n\n}\n"}this.variables=[],this.currentTextureIndex=0;var s=new fe,l=new he;l.position.z=1;var c={texture:{value:null}},u=n(o(),c),h=new k(new xe(2,2),u);s.add(h),this.addVariable=function(e,t,r){var i=this.createShaderMaterial(t),n={name:e,initialValueTexture:r,material:i,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:$l,magFilter:$l};return this.variables.push(n),n},this.setVariableDependencies=function(e,t){e.dependencies=t},this.init=function(){var i=this;if(!r.extensions.get("OES_texture_float"))return"No OES_texture_float support for float textures.";if(0===r.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(var n=0;n>7&1),a=i>>6&1,o=1===(i>>5&1),s=31&i,l=0,c=0;if(o?(l=(t[2]<<16)+(t[3]<<8)+t[4],c=(t[5]<<16)+(t[6]<<8)+t[7]):(l=t[2]+(t[3]<<8)+(t[4]<<16),c=t[5]+(t[6]<<8)+(t[7]<<16)),0===r)throw new Error("PRWM decoder: Invalid format version: 0");if(1!==r)throw new Error("PRWM decoder: Unsupported format version: "+r);if(!n){if(0!==a)throw new Error("PRWM decoder: Indices type must be set to 0 for non-indexed geometries");if(0!==c)throw new Error("PRWM decoder: Number of indices must be set to 0 for non-indexed geometries")}var u,h,d,p,f,m,v,g,y,x=8,b={};for(y=0;y>7&1,p=(i>>4&3)+1,f=15&i,m=tm[f],x++,x=4*Math.ceil(x/4),v=hr(e,m,x,p*l,o),x+=m.BYTES_PER_ELEMENT*p*l,b[u]={type:d,cardinality:p,values:v}}return x=4*Math.ceil(x/4),g=null,n&&(g=hr(e,1===a?Uint32Array:Uint16Array,x,c,o)),{version:r,attributes:b,indices:g}}function pr(e,t,r,i,n,a,o,s){at.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=r||1,this.yRadius=i||1,this.aStartAngle=n||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function fr(e,t,r,i,n,a){pr.call(this,e,t,r,r,i,n,a),this.type="ArcCurve"}function mr(){function e(e,a,o,s){t=e,r=o,i=-3*e+3*a-2*o-s,n=2*e-2*a+o+s}var t=0,r=0,i=0,n=0;return{initCatmullRom:function(t,r,i,n,a){e(r,i,a*(i-t),a*(n-r))},initNonuniformCatmullRom:function(t,r,i,n,a,o,s){var l=(r-t)/a-(i-t)/(a+o)+(i-r)/o,c=(i-r)/o-(n-r)/(o+s)+(n-i)/s;l*=o,c*=o,e(r,i,l,c)},calc:function(e){var a=e*e,o=a*e;return t+r*e+i*a+n*o}}}function vr(e,t,r,i){at.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=r||"centripetal",this.tension=i||.5}function gr(e,t,r,i,n){var a=.5*(i-t),o=.5*(n-r),s=e*e,l=e*s;return(2*r-2*i+a+o)*l+(-3*r+3*i-2*a-o)*s+a*e+r}function yr(e,t){var r=1-e;return r*r*t}function xr(e,t){return 2*(1-e)*e*t}function br(e,t){return e*e*t}function wr(e,t,r,i){return yr(e,t)+xr(e,r)+br(e,i)}function _r(e,t){var r=1-e;return r*r*r*t}function Sr(e,t){var r=1-e;return 3*r*r*e*t}function Ar(e,t){return 3*(1-e)*e*e*t}function Mr(e,t){return e*e*e*t}function Tr(e,t,r,i,n){return _r(e,t)+Sr(e,r)+Ar(e,i)+Mr(e,n)}function Er(e,t,r,i){at.call(this),this.type="CubicBezierCurve",this.v0=e||new f,this.v1=t||new f,this.v2=r||new f,this.v3=i||new f}function Cr(e,t,r,n){at.call(this),this.type="CubicBezierCurve3",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i,this.v3=n||new i}function Lr(e,t){at.call(this),this.type="LineCurve",this.v1=e||new f,this.v2=t||new f}function Pr(e,t){at.call(this),this.type="LineCurve3",this.v1=e||new i,this.v2=t||new i}function Nr(e,t,r){at.call(this),this.type="QuadraticBezierCurve",this.v0=e||new f,this.v1=t||new f,this.v2=r||new f}function Or(e,t,r){at.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i}function Dr(e){at.call(this),this.type="SplineCurve",this.points=e||[]}function Fr(){at.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Rr(e){Fr.call(this),this.type="Path",this.currentPoint=new f,e&&this.setFromPoints(e)}function Ir(e){Rr.call(this,e),this.uuid=Fs.generateUUID(),this.type="Shape",this.holes=[]}function Ur(e,t,r,i,n){var a,o;if(n===ui(e,t,r,i)>0)for(a=t;a=t;a-=i)o=si(a,e[a],e[a+1],o);return o&&ti(o,o.next)&&(li(o),o=o.next),o}function kr(e,t){if(!e)return e;t||(t=e);var r,i=e;do if(r=!1,i.steiner||!ti(i,i.next)&&0!==ei(i.prev,i,i.next))i=i.next;else{if(li(i),i=t=i.prev,i===i.next)break;r=!0}while(r||i!==t);return t}function Br(e,t,r,i,n,a,o){if(e){!o&&a&&qr(e,i,n,a);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?jr(e,i,n,a):zr(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),li(e),e=l.next,c=l.next;else if(e=l,e===c){o?1===o?(e=Vr(e,t,r),Br(e,t,r,i,n,a,2)):2===o&&Gr(e,t,r,i,n,a):Br(kr(e),t,r,i,n,a,1);break}}}function zr(e){var t=e.prev,r=e,i=e.next;if(ei(t,r,i)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Kr(t.x,t.y,r.x,r.y,i.x,i.y,n.x,n.y)&&ei(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function jr(e,t,r,i){var n=e.prev,a=e,o=e.next;if(ei(n,a,o)>=0)return!1;for(var s=n.xa.x?n.x>o.x?n.x:o.x:a.x>o.x?a.x:o.x,u=n.y>a.y?n.y>o.y?n.y:o.y:a.y>o.y?a.y:o.y,h=Jr(s,l,t,r,i),d=Jr(c,u,t,r,i),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Kr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ei(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Kr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ei(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Vr(e,t,r){var i=e;do{var n=i.prev,a=i.next.next;!ti(n,a)&&ri(n,i,i.next,a)&&ni(n,a)&&ni(a,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(a.i/r),li(i),li(i.next),i=e=a),i=i.next}while(i!==e);return i}function Gr(e,t,r,i,n,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&$r(o,s)){var l=oi(o,s);return o=kr(o,o.next),l=kr(l,l.next),Br(o,t,r,i,n,a),void Br(l,t,r,i,n,a)}s=s.next}o=o.next}while(o!==e)}function Wr(e,t,r,i){var n,a,o,s,l,c=[];for(n=0,a=t.length;n=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o){if(o=s,s===n){if(a===i.y)return i;if(a===i.next.y)return i.next}r=i.x=i.x&&i.x>=u&&n!==i.x&&Kr(ar.x)&&ni(i,e)&&(r=i,d=l)),i=i.next;return r}function qr(e,t,r,i){var n=e;do null===n.z&&(n.z=Jr(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,Qr(n)}function Qr(e){var t,r,i,n,a,o,s,l,c=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,i=r,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(n=r,r=r.nextZ,s--):(n=i,i=i.nextZ,l--),a?a.nextZ=n:e=n,n.prevZ=a,a=n;r=i}a.nextZ=null,c*=2}while(o>1);return e}function Jr(e,t,r,i,n){return e=32767*(e-r)*n,t=32767*(t-i)*n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function Zr(e){var t=e,r=e;do t.x=0&&(e-o)*(i-s)-(r-o)*(t-s)>=0&&(r-o)*(a-s)-(n-o)*(i-s)>=0}function $r(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ii(e,t)&&ni(e,t)&&ni(t,e)&&ai(e,t)}function ei(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function ti(e,t){return e.x===t.x&&e.y===t.y}function ri(e,t,r,i){return!!(ti(e,t)&&ti(r,i)||ti(e,i)&&ti(r,t))||ei(e,t,r)>0!=ei(e,t,i)>0&&ei(r,i,e)>0!=ei(r,i,t)>0}function ii(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&ri(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function ni(e,t){return ei(e.prev,e,e.next)<0?ei(e,t,e.next)>=0&&ei(e,e.prev,t)>=0:ei(e,t,e.prev)<0||ei(e,e.next,t)<0}function ai(e,t){var r=e,i=!1,n=(e.x+t.x)/2,a=(e.y+t.y)/2;do r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==e);return i}function oi(e,t){var r=new ci(e.i,e.x,e.y),i=new ci(t.i,t.x,t.y),n=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function si(e,t,r,i){var n=new ci(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function li(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 ci(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ui(e,t,r,i){for(var n=0,a=t,o=r-i;a2&&e[t-1].equals(e[0])&&e.pop()}function di(e,t){for(var r=0;r","#include "].join("\n"),this.parsCode={vertex:"",fragment:""},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={},this.updaters=[],this.nodes=[],this.parsing=!1,this.optimize=!0}function Oi(e,t,r){ar.call(this,"c"),this.value=e instanceof u?e:new u(e||0,t,r)}function Di(e){er.call(this,"v4"),this.value=e}function Fi(e,t){pe.call(this),this.vertex=e||new Di(new ir(ir.PROJECTION)),this.fragment=t||new Di(new Oi(16711680)),this.updaters=[]}function Ri(e,t){ar.call(this,"v2"),this.value=e instanceof f?e:new f(e,t)}function Ii(){Ri.call(this)}function Ui(e){tr.call(this,"v2"),this.resolution=e||new Ii}function ki(e){or.call(this),this.texture=e,this.maxMIPLevel=0}function Bi(e){tr.call(this,"f"),this.texture=e,this.maxMIPLevel=new ki(e),this.blinnShininessExponent=new Ei}function zi(e,t){er.call(this,t),this.name=e}function ji(e,t,r,i,n){Vf.call(this,e,n,i,r,t)}function Vi(e,t){tr.call(this),this.setFunction(e,t)}function Gi(e){this.time=void 0!==e?e:0,this.id=0}function Wi(e,t){er.call(this,e),this.value=t}function Xi(e,t,r,i){tr.call(this,"v4"),this.value=e,this.uv=t||new rr,this.radius=new Ri(1,1),this.size=i,this.blurX=!0,this.blurY=!0,this.horizontal=new or(1/64),this.vertical=new or(1/64)}function Hi(e){tr.call(this,"f"),this.rgb=e}function Yi(e,t,r){tr.call(this,"v3"), +this.rgb=e,this.adjustment=t,this.method=r||Yi.SATURATION}function qi(e){ar.call(this,"i"),this.value=Math.floor(e||0)}function Qi(e){ar.call(this,"m3"),this.value=e||new l}function Ji(e){ar.call(this,"m4"),this.value=e||new r}function Zi(e,t,r){ar.call(this,r),this.object=e,this.property=t}function Ki(e,t,r){tr.call(this),this.a=e,this.b=t,this.op=r}function $i(e){tr.call(this,"v4"),e&&this.setMirror(e)}function en(e,t,r,i){i=i||{},this.input=r,this.clear=void 0===i.clear||i.clear,this.renderTarget=new ge(e,t,i),this.material=new Fi,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),this.material),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.render=!0,Mi.call(this,this.renderTarget.texture)}function tn(e){Mi.call(this,void 0,e)}function rn(){er.call(this),this.color=new Oi(15658734),this.roughness=new or(.5),this.metalness=new or(.5)}function nn(e,t){er.call(this),this.node=e,this.components=t||"x"}function an(e,t){tr.call(this,"v3"),this.value=e,this.scale=t||new Ri(1,1)}function on(){rn.call(this),this.properties={color:new u(16777215),roughness:.5,metalness:.5,normalScale:new f(1,1)},this.inputs={color:new Zi(this.properties,"color","c"),roughness:new Zi(this.properties,"roughness","f"),metalness:new Zi(this.properties,"metalness","f"),normalScale:new Zi(this.properties,"normalScale","v2")}}function sn(){var e=new on;Fi.call(this,e,e),this.type="MeshStandardNodeMaterial"}function ln(){er.call(this),this.color=new Oi(15658734),this.specular=new Oi(1118481),this.shininess=new or(30)}function cn(){er.call(this),this.color=new Oi(15658734),this.spherical=!0}function un(){var e=new ln;Fi.call(this,e,e),this.type="PhongNodeMaterial"}function hn(){var e=new cn;Fi.call(this,e,e),this.type="SpriteNodeMaterial"}function dn(){var e=new rn;Fi.call(this,e,e),this.type="StandardNodeMaterial"}function pn(e,t,r,i,n){tr.call(this),this.a=e,this.b=t,this.ifNode=r,this.elseNode=i,this.op=n}function fn(e,t){tr.call(this),this.a=e,this.method=t}function mn(e,t,r){tr.call(this),this.a=e,this.b=t,this.method=r}function vn(e,t,r,i){tr.call(this),this.a=e,this.b=t,this.c=r,this.method=i}function gn(e,t){tr.call(this,"v3"),this.value=e,this.scale=t||new or(1),this.toNormalMap=!1}function yn(){Ev.call(this),this.name="",this.uuid=Fs.generateUUID(),this.userData={},this.textureID="renderTexture",this.input=new tn,this.material=new Fi,this.needsUpdate=!0}function xn(e,t){if(void 0===t){var r={minFilter:rc,magFilter:rc,format:xc,stencilBuffer:!1},i=e.getDrawingBufferSize();t=new ge(i.width,i.height,r)}this.renderer=e,this.renderTarget=t,this.output=new tn,this.material=new Fi,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),this.material),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.needsUpdate=!0}function bn(e){tr.call(this,"f"),this.uv=e||new rr}function wn(e){tr.call(this,"f"),this.uv=e||new rr}function _n(e,t){er.call(this),this.code=e,this.value=t}function Sn(e,t,r,i){tr.call(this,"f"),this.x=e,this.y=t,this.z=r,this.w=i}function An(e,t){ji.call(this,"( uvTransform * vec3( uvNode, 1 ) ).xy","vec2"),this.uv=e||new rr,this.position=t||new Qi}function Mn(e,t){_i.call(this),this.params={},this.velocity=new i,this.setTarget(e),this.setParams(t)}function Tn(e,t){this.min=void 0!==e?e:new f((+(1/0)),(+(1/0))),this.max=void 0!==t?t:new f((-(1/0)),(-(1/0)))}function En(e){this.autoStart=void 0===e||e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function Cn(e,t){function i(e){S.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),S.multiply(e.projectionMatrix),S.multiply(e.matrixWorldInverse),S.multiply(a.matrixWorld)}function n(){var e=A.getDelta(),t=a.material.uniforms.config;t.value.x+=d*e,t.value.y=t.value.x+_,t.value.x>=w?(t.value.x=0,t.value.y=_):t.value.y>=w&&(t.value.y=t.value.y-w)}k.call(this,e),this.type="Water2";var a=this;t=t||{};var o=new u(void 0!==t.color?t.color:16777215),s=t.textureWidth||512,l=t.textureHeight||512,c=t.clipBias||0,h=t.flowDirection||new f(1,0),d=t.flowSpeed||.03,p=t.reflectivity||.02,m=t.scale||1,v=t.shader||Cn.Water2Shader,g=new Ue,y=t.flowMap||void 0,x=t.normalMap0||g.load("textures/water/Water2_1_M_Normal.jpg"),b=t.normalMap1||g.load("textures/water/Water2_2_M_Normal.jpg"),w=.15,_=.5*w,S=new r,A=new En;if(void 0===Nv)return void console.error("Water2: Required component Reflector not found.");if(void 0===Dv)return void console.error("Water2: Required component Refractor not found.");var M=new Nv(e,{textureWidth:s,textureHeight:l,clipBias:c}),T=new Dv(e,{textureWidth:s,textureHeight:l,clipBias:c});M.matrixAutoUpdate=!1,T.matrixAutoUpdate=!1,this.material=new pe({uniforms:Mu.merge([mp.fog,v.uniforms]),vertexShader:v.vertexShader,fragmentShader:v.fragmentShader,transparent:!0,fog:!0}),void 0!==y?(this.material.defines.USE_FLOWMAP="",this.material.uniforms.tFlowMap={type:"t",value:y}):this.material.uniforms.flowDirection={type:"v2",value:h},x.wrapS=x.wrapT=Jl,b.wrapS=b.wrapT=Jl,this.material.uniforms.tReflectionMap.value=M.getRenderTarget().texture,this.material.uniforms.tRefractionMap.value=T.getRenderTarget().texture,this.material.uniforms.tNormalMap0.value=x,this.material.uniforms.tNormalMap1.value=b,this.material.uniforms.color.value=o,this.material.uniforms.reflectivity.value=p,this.material.uniforms.textureMatrix.value=S,this.material.uniforms.config.value.x=0,this.material.uniforms.config.value.y=_,this.material.uniforms.config.value.z=_,this.material.uniforms.config.value.w=m,this.onBeforeRender=function(e,t,r){i(r),n(),a.visible=!1,M.matrixWorld.copy(a.matrixWorld),T.matrixWorld.copy(a.matrixWorld),M.onBeforeRender(e,t,r),T.onBeforeRender(e,t,r),a.visible=!0}}function Ln(e,t){this.object=e,void 0===t&&(t=16776960);var r=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]),i=new Float32Array(24),n=new P;n.setIndex(new g(r,1)),n.addAttribute("position",new g(i,3)),Yt.call(this,n,new R({color:t})),this.matrixAutoUpdate=!1,this.update()}function Pn(e){return!isNaN(e)&&isFinite(e)}function Nn(e){return"[object Array]"===Object.prototype.toString.call(e)}function On(e){return e?Nn(e)!==!0?[e]:e:[]}function Dn(e,t){for(var r=0,i=e.length;r0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,s=void 0!==r.precision?r.precision:"highp",l=n(s);l!==s&&(console.warn("WebGLRenderer:",s,"not supported, using",l,"instead."),s=l);var c=r.logarithmicDepthBuffer===!0,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=h>0,x=o||!!t.get("OES_texture_float"),b=y&&x;return{isWebGL2:o,getMaxAnisotropy:i,getMaxPrecision:n,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:b}}function Vn(){function e(){u.value!==i&&(u.value=i,u.needsUpdate=n>0),r.numPlanes=n,r.numIntersection=0}function t(e,t,i,n){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=u.value,n!==!0||null===o){var l=i+4*a,h=t.matrixWorldInverse;c.getNormalMatrix(h),(null===o||o.length65535?A:_)(n,1),t.update(i,e.ELEMENT_ARRAY_BUFFER),l[r.id]=i,i}var s={},l={};return{get:n,update:a,getWireframeAttribute:o}}function Xn(e,t,r,i){function n(e){l=e}function a(e){c=e.type,u=e.bytesPerElement}function o(t,i){e.drawElements(l,i,c,t*u),r.update(i,l)}function s(n,a,o){var s;if(i.isWebGL2)s=e;else{var s=t.get("ANGLE_instanced_arrays");if(null===s)return void console.error("WebGLIndexedBufferRenderer: using InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}s[i.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](l,o,c,a*u,n.maxInstancedCount),r.update(o,l,n.maxInstancedCount)}var l,c,u;this.setMode=n,this.setIndex=a,this.render=o,this.renderInstances=s}function Hn(e){function t(t,r,i){switch(i=i||1,n.calls++,r){case e.TRIANGLES:n.triangles+=i*(t/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:n.triangles+=i*(t-2);break;case e.LINES:n.lines+=i*(t/2);break;case e.LINE_STRIP:n.lines+=i*(t-1);break;case e.LINE_LOOP:n.lines+=i*t;break;case e.POINTS:n.points+=i*t;break;default:console.error("WebGLInfo: Unknown draw mode:",r)}}function r(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}var i={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:i,render:n,programs:null,autoReset:!0,reset:r,update:t}}function Yn(e,t){return Math.abs(t[1])-Math.abs(e[1])}function qn(e){function t(t,n,a,o){var s=t.morphTargetInfluences,l=s.length,c=r[n.id];if(void 0===c){c=[];for(var u=0;u0)return e;var n=t*r,a=qg[n];if(void 0===a&&(a=new Float32Array(n),qg[n]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=r,e[o].toArray(a,s)}return a}function Kn(e,t){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r");return Wa(r)}var r=/^[ \t]*#include +<([\w\d.\/]+)>/gm;return e.replace(r,t)}function Xa(e){function t(e,t,r,i){for(var n="",a=parseInt(t);a0?e.gammaFactor:1,y=o.isWebGL2?"":ka(i.extensions,a,t),x=Ba(l),b=s.createProgram();if(i.isRawShaderMaterial?(m=[x].filter(ja).join("\n"),m.length>0&&(m+="\n"),v=[y,x].filter(ja).join("\n"),v.length>0&&(v+="\n")):(m=["precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+n.name,x,a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+p:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&a.flatShading===!1?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ja).join("\n"),v=[y,"precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+n.name,x,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+d:"",a.envMap?"#define "+p:"",a.envMap?"#define "+f:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",a.envMap&&(o.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",a.toneMapping!==Ul?"#define TONE_MAPPING":"",a.toneMapping!==Ul?fp.tonemapping_pars_fragment:"",a.toneMapping!==Ul?Ua("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.envMapEncoding||a.emissiveMapEncoding?fp.encodings_pars_fragment:"",a.mapEncoding?Ra("mapTexelToLinear",a.mapEncoding):"",a.envMapEncoding?Ra("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Ra("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?Ia("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ja).join("\n")),c=Wa(c),c=Va(c,a),c=Ga(c,a),u=Wa(u),u=Va(u,a),u=Ga(u,a),c=Xa(c),u=Xa(u),o.isWebGL2&&!i.isRawShaderMaterial){var w=!1,_=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==c.match(_)&&null!==u.match(_)&&(w=!0,c=c.replace(_,""),u=u.replace(_,"")),m=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,v=["#version 300 es\n","#define varying in",w?"":"out highp vec4 pc_fragColor;",w?"":"#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"+v}var S=m+c,A=v+u,M=Da(s,s.VERTEX_SHADER,S),T=Da(s,s.FRAGMENT_SHADER,A);s.attachShader(b,M),s.attachShader(b,T),void 0!==i.index0AttributeName?s.bindAttribLocation(b,0,i.index0AttributeName):a.morphTargets===!0&&s.bindAttribLocation(b,0,"position"),s.linkProgram(b);var E=s.getProgramInfoLog(b).trim(),C=s.getShaderInfoLog(M).trim(),L=s.getShaderInfoLog(T).trim(),P=!0,N=!0;s.getProgramParameter(b,s.LINK_STATUS)===!1?(P=!1,console.error("WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(b,s.VALIDATE_STATUS),"gl.getProgramInfoLog",E,C,L)):""!==E?console.warn("WebGLProgram: gl.getProgramInfoLog()",E):""!==C&&""!==L||(N=!1), +N&&(this.diagnostics={runnable:P,material:i,programLog:E,vertexShader:{log:C,prefix:m},fragmentShader:{log:L,prefix:v}}),s.deleteShader(M),s.deleteShader(T);var O;this.getUniforms=function(){return void 0===O&&(O=new Na(s,b,e)),O};var D;return this.getAttributes=function(){return void 0===D&&(D=za(s,b)),D},this.destroy=function(){s.deleteProgram(b),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=n.name,this.id=ey++,this.code=r,this.usedTimes=1,this.program=b,this.vertexShader=M,this.fragmentShader=T,this}function Ya(e,t,r){function i(e){var t=e.skeleton,i=t.bones;if(r.floatVertexTextures)return 1024;var n=r.maxVertexUniforms,a=Math.floor((n-20)/4),o=Math.min(a,i.length);return o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:c,numClipIntersection:u,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===Ks,flipSided:t.side===Zs,depthPacking:void 0!==t.depthPacking&&t.depthPacking};return v},this.getProgramCode=function(t,r){var i=[];if(r.shaderID?i.push(r.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)i.push(n),i.push(t.defines[n]);for(var a=0;a1&&a.sort(Qa),o.length>1&&o.sort(Ja)}var i=[],n=0,a=[],o=[];return{opaque:a,transparent:o,init:e,push:t,sort:r}}function Ka(){function e(e,t){var i=e.id+","+t.id,n=r[i];return void 0===n&&(n=new Za,r[i]=n),n}function t(){r={}}var r={};return{get:e,dispose:t}}function $a(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var r;switch(t.type){case"DirectionalLight":r={direction:new i,color:new u,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f};break;case"SpotLight":r={position:new i,direction:new i,color:new u,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f};break;case"PointLight":r={position:new i,color:new u,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new f,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new i,skyColor:new u,groundColor:new u};break;case"RectAreaLight":r={color:new u,position:new i,halfWidth:new i,halfHeight:new i}}return e[t.id]=r,r}}}function eo(){function e(e,r,i){for(var l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=i.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&r.skinning===!1&&console.warn("WebGLShadowMap: SkinnedMesh with material.skinning set to false:",t);var d=t.isSkinnedMesh&&r.skinning,f=0;h&&(f|=p),d&&(f|=m),l=c[f]}if(e.localClippingEnabled&&r.clipShadows===!0&&0!==r.clippingPlanes.length){var v=l.uuid,g=r.uuid,_=b[v];void 0===_&&(_={},b[v]=_);var S=_[g];void 0===S&&(S=l.clone(),_[g]=S),l=S}return l.visible=r.visible,l.wireframe=r.wireframe,l.side=null!=r.shadowSide?r.shadowSide:w[r.side],l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,i&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(n),l.nearDistance=a,l.farDistance=o),l}function o(r,i,n,l){if(r.visible!==!1){var c=r.layers.test(i.layers);if(c&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||s.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,r.matrixWorld);var u=t.update(r),h=r.material;if(Array.isArray(h))for(var p=u.groups,f=0,m=p.length;f=1):ne.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ne)[1]),re=ie>=2);var ae=null,oe={},se=new v,le=new v,ce={};return ce[e.TEXTURE_2D]=s(e.TEXTURE_2D,e.TEXTURE_2D,1),ce[e.TEXTURE_CUBE_MAP]=s(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),N.setClear(0,0,0,1),O.setClear(1),D.setClear(0),d(e.DEPTH_TEST),O.setFunc(Ll),x(!1),b(Vs),d(e.CULL_FACE),g(nl),{buffers:{color:N,depth:O,stencil:D},initAttributes:l,enableAttribute:c,enableAttributeAndDivisor:u,disableUnusedAttributes:h,enable:d,disable:p,getCompressedTextureFormats:f,useProgram:m,setBlending:g,setMaterial:y,setFlipSided:x,setCullFace:b,setLineWidth:w,setPolygonOffset:_,setScissorTest:S,activeTexture:A,bindTexture:M,compressedTexImage2D:T,texImage2D:E,scissor:C,viewport:L,reset:P}}function ao(e,t,r,i,n,a,o){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var r=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=Math.floor(e.width*r),i.height=Math.floor(e.height*r);var n=i.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height),i}return e}function l(e){return Fs.isPowerOfTwo(e.width)&&Fs.isPowerOfTwo(e.height)}function c(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){void 0===N&&(N=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),N.width=Fs.floorPowerOfTwo(e.width),N.height=Fs.floorPowerOfTwo(e.height);var t=N.getContext("2d");return t.drawImage(e,0,0,N.width,N.height),console.warn("WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+N.width+"x"+N.height),N}return e}function u(e){return!n.isWebGL2&&(e.wrapS!==Zl||e.wrapT!==Zl||e.minFilter!==$l&&e.minFilter!==rc)}function h(e,t){return e.generateMipmaps&&t&&e.minFilter!==$l&&e.minFilter!==rc}function d(t,r,n,a){e.generateMipmap(t);var o=i.get(r);o.__maxMipLevel=Math.log(Math.max(n,a))*Math.LOG2E}function p(t,r){if(!n.isWebGL2)return t;if(t===e.RGB){if(r===e.FLOAT)return e.RGB32F;if(r===e.HALF_FLOAT)return e.RGB16F;if(r===e.UNSIGNED_BYTE)return e.RGB8}if(t===e.RGBA){if(r===e.FLOAT)return e.RGBA32F;if(r===e.HALF_FLOAT)return e.RGBA16F;if(r===e.UNSIGNED_BYTE)return e.RGBA8}return t}function f(t){return t===$l||t===ec||t===tc?e.NEAREST:e.LINEAR}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),t.isVideoTexture&&delete O[t.id],o.memory.textures--}function v(e){var t=e.target;t.removeEventListener("dispose",v),y(t),o.memory.textures--}function g(t){var r=i.get(t);if(t.image&&r.__image__webglTextureCube)e.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;e.deleteTexture(r.__webglTexture)}i.remove(t)}function y(t){var r=i.get(t),n=i.get(t.texture);if(t){if(void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(r.__webglFramebuffer[a]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[a]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}}function x(t,n){var a=i.get(t);if(t.isVideoTexture&&P(t),t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("WebGLRenderer: Texture marked for update but image is undefined");else{if(o.complete!==!1)return void S(a,t,n);console.warn("WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function b(t,c){var u=i.get(t);if(6===t.image.length)if(t.version>0&&u.__version!==t.version){u.__image__webglTextureCube||(t.addEventListener("dispose",m),u.__image__webglTextureCube=e.createTexture(),o.memory.textures++),r.activeTexture(e.TEXTURE0+c),r.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var f=t&&t.isCompressedTexture,v=t.image[0]&&t.image[0].isDataTexture,g=[],y=0;y<6;y++)f||v?g[y]=v?t.image[y].image:t.image[y]:g[y]=s(t.image[y],n.maxCubemapSize);var x=g[0],b=l(x),w=a.convert(t.format),S=a.convert(t.type),A=p(w,S);_(e.TEXTURE_CUBE_MAP,t,b);for(var y=0;y<6;y++)if(f)for(var M,T=g[y].mipmaps,E=0,C=T.length;E-1?r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,E,A,M.width,M.height,0,M.data):console.warn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,E,A,M.width,M.height,0,w,S,M.data);else v?r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,A,g[y].width,g[y].height,0,w,S,g[y].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,A,w,S,g[y]);f?u.__maxMipLevel=T.length-1:u.__maxMipLevel=0,h(t,b)&&d(e.TEXTURE_CUBE_MAP,t,x.width,x.height),u.__version=t.version,t.onUpdate&&t.onUpdate(t)}else r.activeTexture(e.TEXTURE0+c),r.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)}function w(t,n){r.activeTexture(e.TEXTURE0+n),r.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)}function _(r,o,s){var l;if(s?(e.texParameteri(r,e.TEXTURE_WRAP_S,a.convert(o.wrapS)),e.texParameteri(r,e.TEXTURE_WRAP_T,a.convert(o.wrapT)),e.texParameteri(r,e.TEXTURE_MAG_FILTER,a.convert(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a.convert(o.minFilter))):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),o.wrapS===Zl&&o.wrapT===Zl||console.warn("WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to ClampToEdgeWrapping."),e.texParameteri(r,e.TEXTURE_MAG_FILTER,f(o.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,f(o.minFilter)),o.minFilter!==$l&&o.minFilter!==rc&&console.warn("WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to NearestFilter or LinearFilter.")),l=t.get("EXT_texture_filter_anisotropic")){if(o.type===hc&&null===t.get("OES_texture_float_linear"))return;if(o.type===dc&&null===(n.isWebGL2||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(r,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function S(t,i,f){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",m),t.__webglTexture=e.createTexture(),o.memory.textures++),r.activeTexture(e.TEXTURE0+f),r.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var v=s(i.image,n.maxTextureSize);u(i)&&l(v)===!1&&(v=c(v));var g=l(v),y=a.convert(i.format),x=a.convert(i.type),b=p(y,x);_(e.TEXTURE_2D,i,g);var w,S=i.mipmaps;if(i.isDepthTexture){if(b=e.DEPTH_COMPONENT,i.type===hc){if(!n.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else n.isWebGL2&&(b=e.DEPTH_COMPONENT16);i.format===Sc&&b===e.DEPTH_COMPONENT&&i.type!==lc&&i.type!==uc&&(console.warn("WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=lc,x=a.convert(i.type)),i.format===Ac&&(b=e.DEPTH_STENCIL,i.type!==vc&&(console.warn("WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=vc,x=a.convert(i.type))),r.texImage2D(e.TEXTURE_2D,0,b,v.width,v.height,0,y,x,null)}else if(i.isDataTexture)if(S.length>0&&g){for(var A=0,M=S.length;A-1?r.compressedTexImage2D(e.TEXTURE_2D,A,b,w.width,w.height,0,w.data):console.warn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(e.TEXTURE_2D,A,b,w.width,w.height,0,y,x,w.data);t.__maxMipLevel=S.length-1}else if(S.length>0&&g){for(var A=0,M=S.length;A=0){var l=i[o];if(void 0!==l){var c=l.normalized,u=l.itemSize,h=Te.get(l);if(void 0===h)continue;var d=h.buffer,p=h.type,f=h.bytesPerElement;if(l.isInterleavedBufferAttribute){var m=l.data,v=m.stride,g=l.offset;m&&m.isInstancedInterleavedBuffer?(_e.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):_e.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,d),H.vertexAttribPointer(s,u,p,c,v*f,g*f)}else l.isInstancedBufferAttribute?(_e.enableAttributeAndDivisor(s,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):_e.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,d),H.vertexAttribPointer(s,u,p,c,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:H.vertexAttrib2fv(s,y);break;case 3:H.vertexAttrib3fv(s,y);break;case 4:H.vertexAttrib4fv(s,y);break;default:H.vertexAttrib1fv(s,y)}}}}_e.disableUnusedAttributes()}function d(e){Ue.isPresenting()||Be&&Be(e)}function p(e,t,r){if(e.visible!==!1){var i=e.layers.test(t.layers);if(i)if(e.isLight)X.pushLight(e),e.castShadow&&X.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||de.intersectsSprite(e)){r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve);var n=Ce.update(e),a=e.material;W.push(e,n,a,ge.z,null)}}else if(e.isImmediateRenderObject)r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve),W.push(e,null,e.material,ge.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||de.intersectsObject(e))){r&&ge.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ve);var n=Ce.update(e),a=e.material;if(Array.isArray(a))for(var o=n.groups,s=0,l=o.length;s=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var v=0;v=0&&e.numSupportedMorphNormals++}var g=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&e.clipping!==!0||(i.numClippingPlanes=pe.numPlanes,i.numIntersection=pe.numIntersection,g.clippingPlanes=pe.uniform),i.fog=t,void 0===o&&(i.lightsHash=o={}),o.stateID=l.stateID,o.directionalLength=l.directionalLength,o.pointLength=l.pointLength,o.spotLength=l.spotLength,o.rectAreaLength=l.rectAreaLength,o.hemiLength=l.hemiLength,o.shadowsLength=l.shadowsLength,e.lights&&(g.ambientLightColor.value=n.state.ambient,g.directionalLights.value=n.state.directional,g.spotLights.value=n.state.spot,g.rectAreaLights.value=n.state.rectArea,g.pointLights.value=n.state.point,g.hemisphereLights.value=n.state.hemi,g.directionalShadowMap.value=n.state.directionalShadowMap,g.directionalShadowMatrix.value=n.state.directionalShadowMatrix,g.spotShadowMap.value=n.state.spotShadowMap,g.spotShadowMatrix.value=n.state.spotShadowMatrix,g.pointShadowMap.value=n.state.pointShadowMap,g.pointShadowMatrix.value=n.state.pointShadowMatrix);var y=i.program.getUniforms(),x=Na.seqWithValue(y.seq,g);i.uniformsList=x}function y(e,t,r,i){ae=0;var n=Ae.get(r),a=X.state.lights,o=n.lightsHash,s=a.state.hash;if(fe&&(me||e!==ee)){var l=e===ee&&r.id===K;pe.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,e,n,l)}r.needsUpdate===!1&&(void 0===n.program?r.needsUpdate=!0:r.fog&&n.fog!==t?r.needsUpdate=!0:!r.lights||o.stateID===s.stateID&&o.directionalLength===s.directionalLength&&o.pointLength===s.pointLength&&o.spotLength===s.spotLength&&o.rectAreaLength===s.rectAreaLength&&o.hemiLength===s.hemiLength&&o.shadowsLength===s.shadowsLength?void 0===n.numClippingPlanes||n.numClippingPlanes===pe.numPlanes&&n.numIntersection===pe.numIntersection||(r.needsUpdate=!0):r.needsUpdate=!0),r.needsUpdate&&(g(r,t,i),r.needsUpdate=!1);var c=!1,u=!1,h=!1,d=n.program,p=d.getUniforms(),f=n.shader.uniforms;if(_e.useProgram(d.program)&&(c=!0,u=!0,h=!0),r.id!==K&&(K=r.id,u=!0),c||ee!==e){if(p.setValue(H,"projectionMatrix",e.projectionMatrix),we.logarithmicDepthBuffer&&p.setValue(H,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),ee!==e&&(ee=e,u=!0,h=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var m=p.map.cameraPosition;void 0!==m&&m.setValue(H,ge.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&p.setValue(H,"viewMatrix",e.matrixWorldInverse)}if(r.skinning){p.setOptional(H,i,"bindMatrix"),p.setOptional(H,i,"bindMatrixInverse");var v=i.skeleton;if(v){var y=v.bones;if(we.floatVertexTextures){if(void 0===v.boneTexture){var F=Math.sqrt(4*y.length);F=Fs.ceilPowerOfTwo(F),F=Math.max(F,4);var R=new Float32Array(F*F*4);R.set(v.boneMatrices);var I=new Mt(R,F,F,xc,hc);I.needsUpdate=!0,v.boneMatrices=R,v.boneTexture=I,v.boneTextureSize=F}p.setValue(H,"boneTexture",v.boneTexture),p.setValue(H,"boneTextureSize",v.boneTextureSize)}else p.setOptional(H,v,"boneMatrices")}}return u&&(p.setValue(H,"toneMappingExposure",Y.toneMappingExposure),p.setValue(H,"toneMappingWhitePoint",Y.toneMappingWhitePoint),r.lights&&D(f,h),t&&r.fog&&A(f,t),r.isMeshBasicMaterial?x(f,r):r.isMeshLambertMaterial?(x(f,r),M(f,r)):r.isMeshPhongMaterial?(x(f,r),r.isMeshToonMaterial?E(f,r):T(f,r)):r.isMeshStandardMaterial?(x(f,r),r.isMeshPhysicalMaterial?L(f,r):C(f,r)):r.isMeshDepthMaterial?(x(f,r),P(f,r)):r.isMeshDistanceMaterial?(x(f,r),N(f,r)):r.isMeshNormalMaterial?(x(f,r),O(f,r)):r.isLineBasicMaterial?(b(f,r),r.isLineDashedMaterial&&w(f,r)):r.isPointsMaterial?_(f,r):r.isSpriteMaterial?S(f,r):r.isShadowMaterial&&(f.color.value=r.color,f.opacity.value=r.opacity),void 0!==f.ltc_1&&(f.ltc_1.value=mp.LTC_1),void 0!==f.ltc_2&&(f.ltc_2.value=mp.LTC_2),Na.upload(H,n.uniformsList,f,Y)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Na.upload(H,n.uniformsList,f,Y),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&p.setValue(H,"center",i.center),p.setValue(H,"modelViewMatrix",i.modelViewMatrix),p.setValue(H,"normalMatrix",i.normalMatrix),p.setValue(H,"modelMatrix",i.matrixWorld),d}function x(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=Ae.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var r;t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),r.matrixAutoUpdate===!0&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}function b(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function w(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function _(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*le,e.scale.value=.5*se,e.map.value=t.map,null!==t.map&&(t.map.matrixAutoUpdate===!0&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function S(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.rotation.value=t.rotation,e.map.value=t.map,null!==t.map&&(t.map.matrixAutoUpdate===!0&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function A(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function M(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function T(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function E(e,t){T(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function C(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function L(e,t){C(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}function P(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function N(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function O(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Zs&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Zs&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function D(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function F(){var e=ae;return e>=we.maxTextures&&console.warn("WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+we.maxTextures),ae+=1,e}console.log("WebGLRenderer",Bs),e=e||{};var R=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),I=void 0!==e.context?e.context:null,U=void 0!==e.alpha&&e.alpha,k=void 0===e.depth||e.depth,B=void 0===e.stencil||e.stencil,z=void 0!==e.antialias&&e.antialias,j=void 0===e.premultipliedAlpha||e.premultipliedAlpha,V=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,G=void 0!==e.powerPreference?e.powerPreference:"default",W=null,X=null;this.domElement=R,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=kl,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var H,Y=this,q=!1,Q=null,J=null,Z=null,K=-1,$={geometry:null,program:null,wireframe:!1},ee=null,te=null,re=new v,ie=new v,ne=null,ae=0,oe=R.width,se=R.height,le=1,ce=new v(0,0,oe,se),ue=new v(0,0,oe,se),he=!1,de=new In,pe=new Vn,fe=!1,me=!1,ve=new r,ge=new i;try{var ye={alpha:U,depth:k,stencil:B,antialias:z,premultipliedAlpha:j,preserveDrawingBuffer:V,powerPreference:G};if(R.addEventListener("webglcontextlost",a,!1),R.addEventListener("webglcontextrestored",o,!1),H=I||R.getContext("webgl",ye)||R.getContext("experimental-webgl",ye),null===H)throw null!==R.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===H.getShaderPrecisionFormat&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(xe){console.error("WebGLRenderer: "+xe.message)}var be,we,_e,Se,Ae,Me,Te,Ee,Ce,Le,Pe,Ne,Oe,De,Fe,Re,Ie;n();var Ue="xr"in navigator?new co(Y):new lo(Y);this.vr=Ue;var ke=new io(Y,Ce,we.maxTextureSize);this.shadowMap=ke,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){var e=be.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=be.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(e){void 0!==e&&(le=e,this.setSize(oe,se,!1))},this.getSize=function(){return{width:oe,height:se}},this.setSize=function(e,t,r){return Ue.isPresenting()?void console.warn("WebGLRenderer: Can't change size while VR device is presenting."):(oe=e,se=t,R.width=e*le,R.height=t*le,r!==!1&&(R.style.width=e+"px",R.style.height=t+"px"),void this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(){return{width:oe*le,height:se*le}},this.setDrawingBufferSize=function(e,t,r){oe=e,se=t,le=r,R.width=e*r,R.height=t*r,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return re},this.setViewport=function(e,t,r,i){ce.set(e,se-t-i,r,i),_e.viewport(re.copy(ce).multiplyScalar(le))},this.setScissor=function(e,t,r,i){ue.set(e,se-t-i,r,i),_e.scissor(ie.copy(ue).multiplyScalar(le))},this.setScissorTest=function(e){_e.setScissorTest(he=e)},this.getClearColor=function(){return Oe.getClearColor()},this.setClearColor=function(){Oe.setClearColor.apply(Oe,arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha.apply(Oe,arguments)},this.clear=function(e,t,r){var i=0;(void 0===e||e)&&(i|=H.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=H.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=H.STENCIL_BUFFER_BIT),H.clear(i)},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.clearTarget=function(e,t,r,i){this.setRenderTarget(e),this.clear(t,r,i)},this.dispose=function(){R.removeEventListener("webglcontextlost",a,!1),R.removeEventListener("webglcontextrestored",o,!1),Pe.dispose(),Ne.dispose(),Ae.dispose(),Ce.dispose(),Ue.dispose(),ze.stop()},this.renderBufferImmediate=function(e,t){_e.initAttributes();var r=Ae.get(e);e.hasPositions&&!r.position&&(r.position=H.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=H.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=H.createBuffer()),e.hasColors&&!r.color&&(r.color=H.createBuffer());var i=t.getAttributes();e.hasPositions&&(H.bindBuffer(H.ARRAY_BUFFER,r.position),H.bufferData(H.ARRAY_BUFFER,e.positionArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.position),H.vertexAttribPointer(i.position,3,H.FLOAT,!1,0,0)),e.hasNormals&&(H.bindBuffer(H.ARRAY_BUFFER,r.normal),H.bufferData(H.ARRAY_BUFFER,e.normalArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.normal),H.vertexAttribPointer(i.normal,3,H.FLOAT,!1,0,0)),e.hasUvs&&(H.bindBuffer(H.ARRAY_BUFFER,r.uv),H.bufferData(H.ARRAY_BUFFER,e.uvArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.uv),H.vertexAttribPointer(i.uv,2,H.FLOAT,!1,0,0)),e.hasColors&&(H.bindBuffer(H.ARRAY_BUFFER,r.color),H.bufferData(H.ARRAY_BUFFER,e.colorArray,H.DYNAMIC_DRAW),_e.enableAttribute(i.color),H.vertexAttribPointer(i.color,3,H.FLOAT,!1,0,0)),_e.disableUnusedAttributes(),H.drawArrays(H.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,r,i,n,a,o){var s=a.isMesh&&a.normalMatrix.determinant()<0;_e.setMaterial(n,s);var l=y(e,r,n,a),c=!1;$.geometry===i.id&&$.program===l.id&&$.wireframe===(n.wireframe===!0)||($.geometry=i.id,$.program=l.id,$.wireframe=n.wireframe===!0,c=!0),a.morphTargetInfluences&&(De.update(a,i,n,l),c=!0);var u=i.index,d=i.attributes.position,p=1;n.wireframe===!0&&(u=Ee.getWireframeAttribute(i),p=2);var f,m=Fe;null!==u&&(f=Te.get(u),m=Re,m.setIndex(f)),c&&(h(n,l,i),null!==u&&H.bindBuffer(H.ELEMENT_ARRAY_BUFFER,f.buffer));var v=1/0;null!==u?v=u.count:void 0!==d&&(v=d.count);var g=i.drawRange.start*p,x=i.drawRange.count*p,b=null!==o?o.start*p:0,w=null!==o?o.count*p:1/0,_=Math.max(g,b),S=Math.min(v,g+x,b+w)-1,A=Math.max(0,S-_+1);if(0!==A){if(a.isMesh)if(n.wireframe===!0)_e.setLineWidth(n.wireframeLinewidth*t()),m.setMode(H.LINES);else switch(a.drawMode){case iu:m.setMode(H.TRIANGLES);break;case nu:m.setMode(H.TRIANGLE_STRIP);break;case au:m.setMode(H.TRIANGLE_FAN)}else if(a.isLine){var M=n.linewidth;void 0===M&&(M=1),_e.setLineWidth(M*t()),a.isLineSegments?m.setMode(H.LINES):a.isLineLoop?m.setMode(H.LINE_LOOP):m.setMode(H.LINE_STRIP)}else a.isPoints?m.setMode(H.POINTS):a.isSprite&&m.setMode(H.TRIANGLES);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&m.renderInstances(i,_,A):m.render(_,A)}},this.compile=function(e,t){X=Ne.get(e,t),X.init(),e.traverse(function(e){e.isLight&&(X.pushLight(e),e.castShadow&&X.pushShadow(e))}),X.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var r=0;r=0&&t<=e.width-i&&r>=0&&r<=e.height-n&&H.readPixels(t,r,i,n,Ie.convert(c),Ie.convert(u),a):console.error("WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&H.bindFramebuffer(H.FRAMEBUFFER,Z)}}},this.copyFramebufferToTexture=function(e,t,r){var i=t.image.width,n=t.image.height,a=Ie.convert(t.format);this.setTexture2D(t,0),H.copyTexImage2D(H.TEXTURE_2D,r||0,a,e.x,e.y,i,n,0)},this.copyTextureToTexture=function(e,t,r,i){var n=t.image.width,a=t.image.height,o=Ie.convert(r.format),s=Ie.convert(r.type);this.setTexture2D(r,0),t.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,n,a,o,s,t.image.data):H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image)}}function ho(e){"string"==typeof e&&(console.warn("Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function po(e,t){function r(e,t){E.set(0,0,-1).applyQuaternion(f);for(var r=0;r=0;r--)T.copy(e[r]),T.applyQuaternion(f),T.add(v),o.push(T.x,T.y,T.z),s.push(E.x,E.y,E.z),l.push(t[0],t[1],t[2])}function a(e,t,r){for(var i=0,n=e.length;i10?(S.set(-.75,-.35,0),S.applyQuaternion(s),S.add(c),A.set(.75,-.35,0),A.applyQuaternion(s),A.add(c),r(h,S,A),S.set(-.7,-.3,0),S.applyQuaternion(s),S.add(c),A.set(-.7,-c.y,0),A.applyQuaternion(s),A.add(c),r(d,S,A),S.set(.7,-.3,0),S.applyQuaternion(s),S.add(c),A.set(.7,-c.y,0),A.applyQuaternion(s),A.add(c),r(p,S,A)):(S.set(0,-.2,0),S.applyQuaternion(s),S.add(c),A.set(0,-c.y,0),A.applyQuaternion(s),A.add(c),r(p,S,A))}this.addAttribute("position",new g(new Float32Array(a),3)),this.addAttribute("normal",new g(new Float32Array(o),3))}function mo(e,t){P.call(this);var r=[],a=new i(0,1,0),o=new i,s=new n,l=new n;l.setFromAxisAngle(a,Math.PI/2);var c=new i,u=new i;u.copy(e.getPointAt(0)),u.y=0;for(var h=new i,d=new i,p=new i,f=new i,m=1;m<=t;m++){c.copy(e.getPointAt(m/t)),c.y=0,o.subVectors(c,u);var v=Math.atan2(o.x,o.z);s.setFromAxisAngle(a,v),h.set(-.3,0,0),h.applyQuaternion(s),h.add(c),d.set(.3,0,0),d.applyQuaternion(s),d.add(c),p.set(.3,0,0),p.applyQuaternion(l),p.add(u),f.set(-.3,0,0),f.applyQuaternion(l),f.add(u),r.push(h.x,h.y,h.z),r.push(d.x,d.y,d.z),r.push(f.x,f.y,f.z),r.push(d.x,d.y,d.z),r.push(p.x,p.y,p.z),r.push(f.x,f.y,f.z),u.copy(c),l.copy(s)}this.addAttribute("position",new g(new Float32Array(r),3))}function vo(){P.call(this);for(var e=[],t=0;t<100;t++){var r=800*Math.random()-400,i=50*Math.random()+50,n=800*Math.random()-400,a=40*Math.random()+20;e.push(r-a,i,n-a),e.push(r+a,i,n-a),e.push(r-a,i,n+a),e.push(r+a,i,n-a),e.push(r+a,i,n+a),e.push(r-a,i,n+a)}this.addAttribute("position",new g(new Float32Array(e),3))}function go(e){P.call(this);var t=[],r=[],i=new je;i.ray.direction.set(0,-1,0);for(var n=0;n<2e3;n++){var a=500*Math.random()-250,o=500*Math.random()-250;i.ray.origin.set(a,50,o);var s=i.intersectObject(e);if(0!==s.length){var l=s[0].point.y,c=5*Math.random()+.5,u=Math.random()*Math.PI*2;t.push(a+Math.sin(u),l,o+Math.cos(u)),t.push(a,l+c,o),t.push(a+Math.sin(u+Math.PI),l,o+Math.cos(u+Math.PI)),u+=Math.PI/2,t.push(a+Math.sin(u),l,o+Math.cos(u)),t.push(a,l+c,o),t.push(a+Math.sin(u+Math.PI),l,o+Math.cos(u+Math.PI));for(var h=.1*Math.random(),d=0;d<6;d++)r.push(.2+h,.4+h,0)}}this.addAttribute("position",new g(new Float32Array(t),3)),this.addAttribute("color",new g(new Float32Array(r),3))}function yo(e){var t=[];e&&e.isBone&&t.push(e);for(var r=0;rNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(l*l+c*c),m=t.x-s/d,v=t.y+o/d,g=r.x-c/p,y=r.y+l/p,x=((g-m)*c-(y-v)*l)/(o*c-s*l);i=m+o*x-e.x,n=v+s*x-e.y;var b=i*i+n*n;if(b<=2)return new f(i,n);a=Math.sqrt(b/2)}else{var w=!1;o>Number.EPSILON?l>Number.EPSILON&&(w=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(w=!0):Math.sign(s)===Math.sign(c)&&(w=!0),w?(i=-s,n=o,a=Math.sqrt(u)):(i=o,n=s,a=Math.sqrt(u/2))}return new f(i/a,n/a)}function l(){var e=a.length/3;if(w){var t=0,r=q*t;for(Z=0;Z=0;){r=Z,i=Z-1,i<0&&(i=e.length-1);var n=0,a=x+2*A;for(n=0;n=0;V--){for(W=V/A,X=_*Math.cos(W*Math.PI/2),G=S*Math.sin(W*Math.PI/2),Z=0,K=j.length;Z=0?(e(y-u,g,p),f.subVectors(d,p)):(e(y+u,g,p),f.subVectors(p,d)),g-u>=0?(e(y,g-u,p),m.subVectors(d,p)):(e(y,g+u,p),m.subVectors(p,d)),h.crossVectors(f,m).normalize(),l.push(h.x,h.y,h.z),c.push(y,g)}}for(n=0;n0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&!function(){Object.assign=function(e){var t=arguments;if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&r]+e[r>>8&255]+"-"+e[r>>16&15|64]+e[r>>24&255]+"-"+e[63&i|128]+e[i>>8&255]+"-"+e[i>>16&255]+e[i>>24&255]+e[255&n]+e[n>>8&255]+e[n>>16&255]+e[n>>24&255];return a.toUpperCase()}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},lerp:function(e,t,r){return(1-r)*e+r*t},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*e*(3-2*e))},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*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())},degToRad:function(e){return e*Fs.DEG2RAD},radToDeg:function(e){return e*Fs.RAD2DEG},isPowerOfTwo:function(e){return 0===(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))}};Object.assign(r.prototype,{isMatrix4:!0,set:function(e,t,r,i,n,a,o,s,l,c,u,h,d,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=r,v[12]=i,v[1]=n,v[5]=a,v[9]=o,v[13]=s,v[2]=l,v[6]=c,v[10]=u,v[14]=h,v[3]=d,v[7]=p,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new r).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(){var e=new i;return function(t){var r=this.elements,i=t.elements,n=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[3]=0,r[4]=i[4]*a,r[5]=i[5]*a,r[6]=i[6]*a,r[7]=0,r[8]=i[8]*o,r[9]=i[9]*o,r[10]=i[10]*o,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,i=e.y,n=e.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(i),l=Math.sin(i),c=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){var h=a*c,d=a*u,p=o*c,f=o*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=d+p*l,t[5]=h-f*l,t[9]=-o*s,t[2]=f-h*l,t[6]=p+d*l,t[10]=a*s}else if("YXZ"===e.order){var m=s*c,v=s*u,g=l*c,y=l*u;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*l,t[1]=a*u,t[5]=a*c,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var m=s*c,v=s*u,g=l*c,y=l*u;t[0]=m-y*o,t[4]=-a*u,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*c,t[9]=y-m*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var h=a*c,d=a*u,p=o*c,f=o*u;t[0]=s*c,t[4]=p*l-d,t[8]=h*l+f,t[1]=s*u,t[5]=f*l+h,t[9]=d*l-p,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*c,t[4]=_-x*u,t[8]=w*u+b,t[1]=u,t[5]=a*c,t[9]=-o*c,t[2]=-l*c,t[6]=b*u+w,t[10]=x-_*u}else if("XZY"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=x*u+_,t[5]=a*c,t[9]=b*u-w,t[2]=w*u-b,t[6]=o*c,t[10]=_*u+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(){var e=new i(0,0,0),t=new i(1,1,1);return function(r){return this.compose(e,r,t)}}(),lookAt:function(){var e=new i,t=new i,r=new i;return function(i,n,a){var o=this.elements;return r.subVectors(i,n),0===r.lengthSq()&&(r.z=1),r.normalize(),e.crossVectors(a,r),0===e.lengthSq()&&(1===Math.abs(a.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),e.crossVectors(a,r)),e.normalize(),t.crossVectors(r,e),o[0]=e.x,o[4]=t.x,o[8]=r.x,o[1]=e.y,o[5]=t.y,o[9]=r.y,o[2]=e.z,o[6]=t.z,o[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,a=r[0],o=r[4],s=r[8],l=r[12],c=r[1],u=r[5],h=r[9],d=r[13],p=r[2],f=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],b=r[15],w=i[0],_=i[4],S=i[8],A=i[12],M=i[1],T=i[5],E=i[9],C=i[13],L=i[2],P=i[6],N=i[10],O=i[14],D=i[3],F=i[7],R=i[11],I=i[15];return n[0]=a*w+o*M+s*L+l*D,n[4]=a*_+o*T+s*P+l*F,n[8]=a*S+o*E+s*N+l*R,n[12]=a*A+o*C+s*O+l*I,n[1]=c*w+u*M+h*L+d*D,n[5]=c*_+u*T+h*P+d*F,n[9]=c*S+u*E+h*N+d*R,n[13]=c*A+u*C+h*O+d*I,n[2]=p*w+f*M+m*L+v*D,n[6]=p*_+f*T+m*P+v*F,n[10]=p*S+f*E+m*N+v*R,n[14]=p*A+f*C+m*O+v*I,n[3]=g*w+y*M+x*L+b*D,n[7]=g*_+y*T+x*P+b*F,n[11]=g*S+y*E+x*N+b*R,n[15]=g*A+y*C+x*O+b*I,this},multiplyScalar: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},applyToBufferAttribute:function(){var e=new i;return function(t){for(var r=this,i=0,n=t.count;i=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,l=l*m+d*w,c=c*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=_,l*=_,c*=_,u*=_}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}}),Object.defineProperties(n.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(n.prototype,{set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,i=e._y,n=e._z,a=e.order,o=Math.cos,s=Math.sin,l=o(r/2),c=o(i/2),u=o(n/2),h=s(r/2),d=s(i/2),p=s(n/2);return"XYZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"YXZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"ZXY"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"ZYX"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"YZX"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p):"XZY"===a&&(this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p),t!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,r=e.elements,i=r[0],n=r[4],a=r[8],o=r[1],s=r[5],l=r[9],c=r[2],u=r[6],h=r[10],d=i+s+h;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(u-l)*t,this._y=(a-c)*t,this._z=(o-n)*t):i>s&&i>h?(t=2*Math.sqrt(1+i-s-h),this._w=(u-l)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(a+c)/t):s>h?(t=2*Math.sqrt(1+s-i-h),this._w=(a-c)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(l+u)/t):(t=2*Math.sqrt(1+h-i-s),this._w=(o-n)/t,this._x=(a+c)/t,this._y=(l+u)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new i,r=1e-6;return function(n,a){return void 0===t&&(t=new i),e=n.dot(a)+1,eMath.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,a),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),angleTo:function(e){return 2*Math.acos(Math.abs(Fs.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var r=this.angleTo(e);if(0===r)return this;var i=Math.min(1,t/r);return this.slerp(e,i),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize: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},multiply:function(e,t){return void 0!==t?(console.warn("Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,i=e._y,n=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=r*c+a*o+i*l-n*s,this._y=i*c+a*s+n*o-r*l,this._z=n*c+a*l+r*s-i*o,this._w=a*c-r*o-i*s-n*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,i=this._y,n=this._z,a=this._w,o=a*e._w+r*e._x+i*e._y+n*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=r,this._y=i,this._z=n,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*r+t*this._x,this._y=l*i+t*this._y,this._z=l*n+t*this._z,this.normalize()}var c=Math.sqrt(s),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=r*h+this._x*d,this._y=i*h+this._y*d,this._z=n*h+this._z*d,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(a.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[e]&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var r=this._listeners;return void 0!==r[e]&&r[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(void 0!==this._listeners){var r=this._listeners,i=r[e];if(void 0!==i){var n=i.indexOf(t);n!==-1&&i.splice(n,1)}}},dispatchEvent:function(e){var t=this;if(void 0!==this._listeners){var r=this._listeners,i=r[e.type];if(void 0!==i){e.target=this;for(var n=i.slice(0),a=0,o=n.length;a1){for(var i=0;i1){for(var i=0;i0){o.children=[];for(var c=0;c0&&(a.geometries=p),f.length>0&&(a.materials=f),m.length>0&&(a.textures=m),v.length>0&&(a.images=v),l.length>0&&(a.shapes=l)}return a.object=o,a},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){var r=this;if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),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.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.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var i=0;i>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(){function e(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}return function(t,r,i){if(t=Fs.euclideanModulo(t,1),r=Fs.clamp(r,0,1),i=Fs.clamp(i,0,1),0===r)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+r):i+r-i*r,a=2*i-n;this.r=e(a,n,t+1/3),this.g=e(a,n,t),this.b=e(a,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,n=r[1],a=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var c=r[1],u=c.length;if(3===u)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}if(e&&e.length>0){var c=Is[e];void 0!==c?this.setHex(c):console.warn("Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(){function e(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),copyLinearToSRGB:function(){function e(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,r,i=this.r,n=this.g,a=this.b,o=Math.max(i,n,a),s=Math.min(i,n,a),l=(s+o)/2;if(s===o)t=0,r=0;else{var c=o-s;switch(r=l<=.5?c/(o+s):c/(2-o-s),o){case i:t=(n-a)/c+(nn&&(n=c),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,r,i),this.max.set(n,a,o),this},setFromBufferAttribute:function(e){for(var t=+(1/0),r=+(1/0),i=+(1/0),n=-(1/0),a=-(1/0),o=-(1/0),s=0,l=e.count;sn&&(n=c),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,r,i),this.max.set(n,a,o),this},setFromPoints:function(e){var t=this;this.makeEmpty();for(var r=0,i=e.length;rthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox: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},getParameter:function(e,t){return void 0===t&&(console.warn("Box3: .getParameter() target is now required"),t=new i),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e=new i;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=e.constant&&r>=e.constant},intersectsTriangle:function(){function e(e){var i,a;for(i=0,a=e.length-3;i<=a;i+=3){l.fromArray(e,i);var o=u.x*Math.abs(l.x)+u.y*Math.abs(l.y)+u.z*Math.abs(l.z),s=t.dot(l),c=r.dot(l),h=n.dot(l);if(Math.max(-Math.max(s,c,h),Math.min(s,c,h))>o)return!1}return!0}var t=new i,r=new i,n=new i,a=new i,o=new i,s=new i,l=new i,c=new i,u=new i,h=new i;return function(i){if(this.isEmpty())return!1;this.getCenter(c),u.subVectors(this.max,c),t.subVectors(i.a,c),r.subVectors(i.b,c),n.subVectors(i.c,c),a.subVectors(r,t),o.subVectors(n,r),s.subVectors(t,n);var l=[0,-a.z,a.y,0,-o.z,o.y,0,-s.z,s.y,a.z,0,-a.x,o.z,0,-o.x,s.z,0,-s.x,-a.y,a.x,0,-o.y,o.x,0,-s.y,s.x,0];return!!e(l)&&(l=[1,0,0,0,1,0,0,0,1],!!e(l)&&(h.crossVectors(a,o),l=[h.x,h.y,h.z],e(l)))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("Box3: .clampPoint() target is now required"),t=new i),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new i;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),getBoundingSphere:function(){var e=new i;return function(t){return void 0===t&&(console.warn("Box3: .getBoundingSphere() target is now required"),t=new p),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new i,new i,new i,new i,new i,new i,new i,new i];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(p.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new d;return function(t,r){var i=this.center;void 0!==r?i.copy(r):e.setFromPoints(t).getCenter(i);for(var n=0,a=0,o=t.length;athis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("Sphere: .getBoundingBox() target is now required"),e=new d),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.defineProperties(f.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(f.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent: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},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e=new f,t=new f;return function(r,i){return e.set(r,r),t.set(i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){ return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*r-a*i+e.x,this.y=n*i+a*r+e.y,this}});var Us=0;m.prototype=Object.assign(Object.create(a.prototype),{constructor:m,isGeometry:!0,applyMatrix:function(e){for(var t=this,r=(new l).getNormalMatrix(e),i=0,n=this.vertices.length;i0)for(var g=0;g0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,r,i=this;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,r,n,a,o=this;for(r=0,n=this.faces.length;r=0;r--){var v=f[r];for(l.faces.splice(v,1),o=0,s=this.faceVertexUvs.length;o0,S=y.vertexNormals.length>0,A=1!==y.color.r||1!==y.color.g||1!==y.color.b,M=y.vertexColors.length>0,T=0;if(T=e(T,0,0),T=e(T,1,x),T=e(T,2,b),T=e(T,3,w),T=e(T,4,_),T=e(T,5,S),T=e(T,6,A),T=e(T,7,M),h.push(T),h.push(y.a,y.b,y.c),h.push(y.materialIndex),w){var E=n.faceVertexUvs[0][c];h.push(i(E[0]),i(E[1]),i(E[2]))}if(_&&h.push(t(y.normal)),S){var C=y.vertexNormals;h.push(t(C[0]),t(C[1]),t(C[2]))}if(A&&h.push(r(y.color)),M){var L=y.vertexColors;h.push(r(L[0]),r(L[1]),r(L[2]))}}return a.data={},a.data.vertices=l,a.data.normals=d,f.length>0&&(a.data.colors=f),v.length>0&&(a.data.uvs=[v]),a.data.faces=h,a},clone:function(){return(new m).copy(this)},copy:function(e){var t,r,i,n,a,o,s=this;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var l=e.vertices;for(t=0,r=l.length;ty&&g>x?gx?y0,s=a[1]&&a[1].length>0,l=e.morphTargets,c=l.length;if(c>0){t=[];for(var u=0;u0){h=[];for(var u=0;u0&&0===i.length&&console.error("DirectGeometry: Faceless geometries are not supported.");for(var u=0;u65535?A:_)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):(this.attributes[e]=t,this):(console.warn("BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(e,new g(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,r){this.groups.push({start:e,count:t,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){var i=(new l).getNormalMatrix(e);i.applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new r;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new r;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new r;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new r;return function(t,r,i){return e.makeTranslation(t,r,i),this.applyMatrix(e),this}}(),scale:function(){var e=new r;return function(t,r,i){return e.makeScale(t,r,i),this.applyMatrix(e),this}}(),lookAt:function(){var e=new c;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new i;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var r=new M(3*t.vertices.length,3),i=new M(3*t.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new M(t.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],r=0,i=e.length;r0){var i=new Float32Array(3*e.normals.length);this.addAttribute("normal",new g(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var n=new Float32Array(3*e.colors.length);this.addAttribute("color",new g(n,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var a=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new g(a,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new g(o,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var s in e.morphTargets){for(var l=[],c=e.morphTargets[s],u=0,h=c.length;u0){var f=new M(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new M(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new d);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new d,t=new i;return function(){null===this.boundingSphere&&(this.boundingSphere=new p);var r=this.attributes.position;if(r){var i=this.boundingSphere.center;e.setFromBufferAttribute(r),e.getCenter(i);for(var n=0,a=0,o=r.count;a0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var r in t)void 0!==t[r]&&(e[r]=t[r]);return e}e.data={attributes:{}};var i=this.index;if(null!==i){var n=Array.prototype.slice.call(i.array);e.data.index={type:i.array.constructor.name,array:n}}var a=this.attributes;for(var r in a){var o=a[r],n=Array.prototype.slice.call(o.array);e.data.attributes[r]={itemSize:o.itemSize,type:o.array.constructor.name,array:n,normalized:o.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e},clone:function(){return(new P).copy(this)},copy:function(e){var t,r,i,n=this;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var a=e.index;null!==a&&this.setIndex(a.clone());var o=e.attributes;for(t in o){var s=o[t];n.addAttribute(t,s.clone())}var l=e.morphAttributes;for(t in l){var c=[],u=l[t];for(r=0,i=u.length;r0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),r){var n=t(e.textures),a=t(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,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.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,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.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,r=null;if(null!==t){var i=t.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=t[n].clone()}return this.clippingPlanes=r,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),F.prototype=Object.create(D.prototype),F.prototype.constructor=F,F.prototype.isMeshBasicMaterial=!0,F.prototype.copy=function(e){return D.prototype.copy.call(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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this},I.prototype=Object.create(D.prototype),I.prototype.constructor=I,I.prototype.isLineBasicMaterial=!0,I.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this},Object.assign(R.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("Ray: .at() target is now required"),t=new i),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new i;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn("Ray: .closestPointToPoint() target is now required"),t=new i),t.subVectors(e,this.origin);var r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new i;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new i,t=new i,r=new i;return function(i,n,a,o){e.copy(i).add(n).multiplyScalar(.5),t.copy(n).sub(i).normalize(),r.copy(this.origin).sub(e);var s,l,c,u,h=.5*i.distanceTo(n),d=-this.direction.dot(t),p=r.dot(this.direction),f=-r.dot(t),m=r.lengthSq(),v=Math.abs(1-d*d);if(v>0)if(s=d*f-p,l=d*p-f,u=h*v,s>=0)if(l>=-u)if(l<=u){var g=1/v;s*=g,l*=g,c=s*(s+d*l+2*p)+l*(d*s+l+2*f)+m}else l=h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;else l=-h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;else l<=-u?(s=Math.max(0,-(-d*h+p)),l=s>0?-h:Math.min(Math.max(-h,-f),h),c=-s*s+l*(l+2*f)+m):l<=u?(s=0,l=Math.min(Math.max(-h,-f),h),c=l*(l+2*f)+m):(s=Math.max(0,-(d*h+p)),l=s>0?h:Math.min(Math.max(-h,-f),h),c=-s*s+l*(l+2*f)+m);else l=d>0?-h:h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(l).add(e),c}}(),intersectSphere:function(){var e=new i;return function(t,r){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),n=e.dot(e)-i*i,a=t.radius*t.radius;if(n>a)return null;var o=Math.sqrt(a-n),s=i-o,l=i+o;return s<0&&l<0?null:s<0?this.at(l,r):this.at(s,r)}}(),intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var r=e.normal.dot(this.direction);return r*t<0},intersectBox:function(e,t){var r,i,n,a,o,s,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(r=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),c>=0?(n=(e.min.y-h.y)*c,a=(e.max.y-h.y)*c):(n=(e.max.y-h.y)*c,a=(e.min.y-h.y)*c),r>a||n>i?null:((n>r||r!==r)&&(r=n),(a=0?(o=(e.min.z-h.z)*u,s=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,s=(e.min.z-h.z)*u),r>s||o>i?null:((o>r||r!==r)&&(r=o),(s=0?r:i,t)))},intersectsBox:function(){var e=new i;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new i,t=new i,r=new i,n=new i;return function(i,a,o,s,l){t.subVectors(a,i),r.subVectors(o,i),n.crossVectors(t,r);var c,u=this.direction.dot(n);if(u>0){if(s)return null;c=1}else{if(!(u<0))return null;c=-1,u=-u}e.subVectors(this.origin,i);var h=c*this.direction.dot(r.crossVectors(e,r));if(h<0)return null;var d=c*this.direction.dot(t.cross(e));if(d<0)return null;if(h+d>u)return null;var p=-c*e.dot(n);return p<0?null:this.at(p/u,l)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(U,{getNormal:function(){var e=new i;return function(t,r,n,a){void 0===a&&(console.warn("Triangle: .getNormal() target is now required"),a=new i),a.subVectors(n,r),e.subVectors(t,r),a.cross(e);var o=a.lengthSq();return o>0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}}(),getBarycoord:function(){var e=new i,t=new i,r=new i;return function(n,a,o,s,l){e.subVectors(s,a),t.subVectors(o,a),r.subVectors(n,a);var c=e.dot(e),u=e.dot(t),h=e.dot(r),d=t.dot(t),p=t.dot(r),f=c*d-u*u;if(void 0===l&&(console.warn("Triangle: .getBarycoord() target is now required"),l=new i),0===f)return l.set(-2,-1,-1);var m=1/f,v=(d*h-u*p)*m,g=(c*p-u*h)*m;return l.set(1-v-g,g,v)}}(),containsPoint:function(){var e=new i;return function(t,r,i,n){return U.getBarycoord(t,r,i,n,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}(),getUV:function(){var e=new i;return function(t,r,i,n,a,o,s,l){return this.getBarycoord(t,r,i,n,e),l.set(0,0),l.addScaledVector(a,e.x),l.addScaledVector(o,e.y),l.addScaledVector(s,e.z),l}}()}),Object.assign(U.prototype,{set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new i,t=new i;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("Triangle: .getMidpoint() target is now required"),e=new i),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return U.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("Triangle: .getPlane() target is now required"),e=new i),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return U.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return U.containsPoint(e,this.a,this.b,this.c)},getUV:function(e,t,r,i,n){return U.getUV(e,this.a,this.b,this.c,t,r,i,n)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new i,t=new i,r=new i,n=new i,a=new i,o=new i;return function(s,l){void 0===l&&(console.warn("Triangle: .closestPointToPoint() target is now required"),l=new i);var c,u,h=this.a,d=this.b,p=this.c;e.subVectors(d,h),t.subVectors(p,h),n.subVectors(s,h);var f=e.dot(n),m=t.dot(n);if(f<=0&&m<=0)return l.copy(h);a.subVectors(s,d);var v=e.dot(a),g=t.dot(a);if(v>=0&&g<=v)return l.copy(d);var y=f*g-v*m;if(y<=0&&f>=0&&v<=0)return c=f/(f-v),l.copy(h).addScaledVector(e,c);o.subVectors(s,p);var x=e.dot(o),b=t.dot(o);if(b>=0&&x<=b)return l.copy(p);var w=x*m-f*b;if(w<=0&&m>=0&&b<=0)return u=m/(m-b),l.copy(h).addScaledVector(t,u);var _=v*b-x*g;if(_<=0&&g-v>=0&&x-b>=0)return r.subVectors(p,d),u=(g-v)/(g-v+(x-b)),l.copy(d).addScaledVector(r,u);var S=1/(_+w+y);return c=w*S,u=y*S,l.copy(h).addScaledVector(e,c).addScaledVector(t,u)}}(),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}),k.prototype=Object.assign(Object.create(c.prototype),{constructor:k,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return c.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,r,i=this,n=this.geometry;if(n.isBufferGeometry){var a=n.morphAttributes,o=Object.keys(a);if(o.length>0){var s=a[o[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=l.length;er.far?null:{distance:c,point:b.clone(),object:e}}function t(t,r,i,n,a,o,u,d,p){s.fromBufferAttribute(a,u),l.fromBufferAttribute(a,d),c.fromBufferAttribute(a,p);var m=e(t,r,i,n,s,l,c,x);if(m){o&&(v.fromBufferAttribute(o,u),g.fromBufferAttribute(o,d),y.fromBufferAttribute(o,p),m.uv=U.getUV(x,s,l,c,v,g,y,new f));var b=new h(u,d,p);U.getNormal(s,l,c,b.normal),m.face=b}return m}var n=new r,a=new R,o=new p,s=new i,l=new i,c=new i,u=new i,d=new i,m=new i,v=new f,g=new f,y=new f,x=new i,b=new i;return function(r,i){var h=this,p=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===p.boundingSphere&&p.computeBoundingSphere(),o.copy(p.boundingSphere),o.applyMatrix4(w),r.ray.intersectsSphere(o)!==!1&&(n.getInverse(w),a.copy(r.ray).applyMatrix4(n),null===p.boundingBox||a.intersectsBox(p.boundingBox)!==!1))){var _;if(p.isBufferGeometry){var S,A,M,T,E,C,L,P,N,O,D,F=p.index,I=p.attributes.position,R=p.attributes.uv,k=p.groups,B=p.drawRange;if(null!==F)if(Array.isArray(b))for(T=0,C=k.length;T0&&(G=Y);for(var q=0,Q=H.length;qh)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}else for(var w=0,_=x.length/3-1;w<_;w+=v){d.fromArray(x,3*w),p.fromArray(x,3*w+3);var M=t.distanceSqToSegment(d,p,m,f);if(!(M>h)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}}else if(l.isGeometry)for(var E=l.vertices,C=E.length,w=0;wh)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var xu=function(){function e(e,t){this.mesh=e,this.iks=t||[],this._valid()}function t(e,t){c.call(this),this.root=e,this.iks=t||[],this.matrix.copy(e.matrixWorld),this.matrixAutoUpdate=!1,this.sphereGeometry=new O(.25,16,8),this.targetSphereMaterial=new F({color:new u(16746632),depthTest:!1,depthWrite:!1,transparent:!0}),this.effectorSphereMaterial=new F({color:new u(8978312),depthTest:!1,depthWrite:!1,transparent:!0}),this.linkSphereMaterial=new F({color:new u(8947967),depthTest:!1,depthWrite:!1,transparent:!0}),this.lineMaterial=new I({color:new u(16711680),depthTest:!1,depthWrite:!1,transparent:!0}),this._init()}return e.prototype={constructor:e,update:function(){var e=new n,t=new i,r=new i,a=new i,o=new i,s=new i,l=new n,c=new i,u=new i,h=new i;return function(){for(var i=this.mesh.skeleton.bones,n=this.iks,d=Math,p=0,f=n.length;p1?C=1:C<-1&&(C=-1),C=d.acos(C),!(C<1e-5)){if(void 0!==m.minAngle&&Cm.maxAngle&&(C=m.maxAngle),u.crossVectors(o,r),u.normalize(),e.setFromAxisAngle(u,C),A.quaternion.multiply(e),void 0!==M){var L=A.quaternion.w;L>1&&(L=1);var P=d.sqrt(1-L*L);A.quaternion.set(M.x*P,M.y*P,M.z*P,L)}void 0!==T&&A.rotation.setFromVector3(A.rotation.toVector3(h).max(T)),void 0!==E&&A.rotation.setFromVector3(A.rotation.toVector3(h).min(E)),A.updateMatrixWorld(!0),w=!0}}if(!w)break}}return this}}(),createHelper:function(){return new t(this.mesh,this.mesh.geometry.userData.MMD.iks)},_valid:function(){for(var e=this.iks,t=this.mesh.skeleton.bones,r=0,i=e.length;r0)for(var l=this._interpolants,c=this._propertyBindings,u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var r=this._weightInterpolant;if(null!==r){var i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){var i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,r=this._clip.duration,i=this.loop,n=this._loopCount,a=i===Jc;if(0===e)return n===-1?t:a&&1===(1&n)?r-t:t;if(i===qc){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=r)t=r;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=r||t<0){var o=Math.floor(t/r);t-=r*o,n+=Math.abs(o);var s=this.repetitions-n;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?r:0,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=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1===(1&n))return this.time=t,r-t}return this.time=t,t},_setEndings:function(e,t,r){var i=this._interpolantSettings;r?(i.endingStart=tu,i.endingEnd=tu):(e?i.endingStart=this.zeroSlopeAtStart?tu:eu:i.endingStart=ru,t?i.endingEnd=this.zeroSlopeAtEnd?tu:eu:i.endingEnd=ru)},_scheduleFading:function(e,t,r){var i=this._mixer,n=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(), +u++)a[u]=s[c];return this},normalizeNormals:function(){var e=new i;return function(){for(var t=this.attributes.normal,r=0,i=t.count;r0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var r in t)void 0!==t[r]&&(e[r]=t[r]);return e}e.data={attributes:{}};var i=this.index;if(null!==i){var n=Array.prototype.slice.call(i.array);e.data.index={type:i.array.constructor.name,array:n}}var a=this.attributes;for(var r in a){var o=a[r],n=Array.prototype.slice.call(o.array);e.data.attributes[r]={itemSize:o.itemSize,type:o.array.constructor.name,array:n,normalized:o.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e},clone:function(){return(new P).copy(this)},copy:function(e){var t,r,i,n=this;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var a=e.index;null!==a&&this.setIndex(a.clone());var o=e.attributes;for(t in o){var s=o[t];n.addAttribute(t,s.clone())}var l=e.morphAttributes;for(t in l){var c=[],u=l[t];for(r=0,i=u.length;r0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),r){var n=t(e.textures),a=t(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,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.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,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.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,r=null;if(null!==t){var i=t.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=t[n].clone()}return this.clippingPlanes=r,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),F.prototype=Object.create(D.prototype),F.prototype.constructor=F,F.prototype.isMeshBasicMaterial=!0,F.prototype.copy=function(e){return D.prototype.copy.call(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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this},R.prototype=Object.create(D.prototype),R.prototype.constructor=R,R.prototype.isLineBasicMaterial=!0,R.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this},Object.assign(I.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("Ray: .at() target is now required"),t=new i),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new i;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn("Ray: .closestPointToPoint() target is now required"),t=new i),t.subVectors(e,this.origin);var r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new i;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new i,t=new i,r=new i;return function(i,n,a,o){e.copy(i).add(n).multiplyScalar(.5),t.copy(n).sub(i).normalize(),r.copy(this.origin).sub(e);var s,l,c,u,h=.5*i.distanceTo(n),d=-this.direction.dot(t),p=r.dot(this.direction),f=-r.dot(t),m=r.lengthSq(),v=Math.abs(1-d*d);if(v>0)if(s=d*f-p,l=d*p-f,u=h*v,s>=0)if(l>=-u)if(l<=u){var g=1/v;s*=g,l*=g,c=s*(s+d*l+2*p)+l*(d*s+l+2*f)+m}else l=h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;else l=-h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;else l<=-u?(s=Math.max(0,-(-d*h+p)),l=s>0?-h:Math.min(Math.max(-h,-f),h),c=-s*s+l*(l+2*f)+m):l<=u?(s=0,l=Math.min(Math.max(-h,-f),h),c=l*(l+2*f)+m):(s=Math.max(0,-(d*h+p)),l=s>0?h:Math.min(Math.max(-h,-f),h),c=-s*s+l*(l+2*f)+m);else l=d>0?-h:h,s=Math.max(0,-(d*l+p)),c=-s*s+l*(l+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(l).add(e),c}}(),intersectSphere:function(){var e=new i;return function(t,r){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),n=e.dot(e)-i*i,a=t.radius*t.radius;if(n>a)return null;var o=Math.sqrt(a-n),s=i-o,l=i+o;return s<0&&l<0?null:s<0?this.at(l,r):this.at(s,r)}}(),intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var r=e.normal.dot(this.direction);return r*t<0},intersectBox:function(e,t){var r,i,n,a,o,s,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(r=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),c>=0?(n=(e.min.y-h.y)*c,a=(e.max.y-h.y)*c):(n=(e.max.y-h.y)*c,a=(e.min.y-h.y)*c),r>a||n>i?null:((n>r||r!==r)&&(r=n),(a=0?(o=(e.min.z-h.z)*u,s=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,s=(e.min.z-h.z)*u),r>s||o>i?null:((o>r||r!==r)&&(r=o),(s=0?r:i,t)))},intersectsBox:function(){var e=new i;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new i,t=new i,r=new i,n=new i;return function(i,a,o,s,l){t.subVectors(a,i),r.subVectors(o,i),n.crossVectors(t,r);var c,u=this.direction.dot(n);if(u>0){if(s)return null;c=1}else{if(!(u<0))return null;c=-1,u=-u}e.subVectors(this.origin,i);var h=c*this.direction.dot(r.crossVectors(e,r));if(h<0)return null;var d=c*this.direction.dot(t.cross(e));if(d<0)return null;if(h+d>u)return null;var p=-c*e.dot(n);return p<0?null:this.at(p/u,l)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(U,{getNormal:function(){var e=new i;return function(t,r,n,a){void 0===a&&(console.warn("Triangle: .getNormal() target is now required"),a=new i),a.subVectors(n,r),e.subVectors(t,r),a.cross(e);var o=a.lengthSq();return o>0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}}(),getBarycoord:function(){var e=new i,t=new i,r=new i;return function(n,a,o,s,l){e.subVectors(s,a),t.subVectors(o,a),r.subVectors(n,a);var c=e.dot(e),u=e.dot(t),h=e.dot(r),d=t.dot(t),p=t.dot(r),f=c*d-u*u;if(void 0===l&&(console.warn("Triangle: .getBarycoord() target is now required"),l=new i),0===f)return l.set(-2,-1,-1);var m=1/f,v=(d*h-u*p)*m,g=(c*p-u*h)*m;return l.set(1-v-g,g,v)}}(),containsPoint:function(){var e=new i;return function(t,r,i,n){return U.getBarycoord(t,r,i,n,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}(),getUV:function(){var e=new i;return function(t,r,i,n,a,o,s,l){return this.getBarycoord(t,r,i,n,e),l.set(0,0),l.addScaledVector(a,e.x),l.addScaledVector(o,e.y),l.addScaledVector(s,e.z),l}}()}),Object.assign(U.prototype,{set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new i,t=new i;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("Triangle: .getMidpoint() target is now required"),e=new i),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return U.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("Triangle: .getPlane() target is now required"),e=new i),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return U.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return U.containsPoint(e,this.a,this.b,this.c)},getUV:function(e,t,r,i,n){return U.getUV(e,this.a,this.b,this.c,t,r,i,n)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new i,t=new i,r=new i,n=new i,a=new i,o=new i;return function(s,l){void 0===l&&(console.warn("Triangle: .closestPointToPoint() target is now required"),l=new i);var c,u,h=this.a,d=this.b,p=this.c;e.subVectors(d,h),t.subVectors(p,h),n.subVectors(s,h);var f=e.dot(n),m=t.dot(n);if(f<=0&&m<=0)return l.copy(h);a.subVectors(s,d);var v=e.dot(a),g=t.dot(a);if(v>=0&&g<=v)return l.copy(d);var y=f*g-v*m;if(y<=0&&f>=0&&v<=0)return c=f/(f-v),l.copy(h).addScaledVector(e,c);o.subVectors(s,p);var x=e.dot(o),b=t.dot(o);if(b>=0&&x<=b)return l.copy(p);var w=x*m-f*b;if(w<=0&&m>=0&&b<=0)return u=m/(m-b),l.copy(h).addScaledVector(t,u);var _=v*b-x*g;if(_<=0&&g-v>=0&&x-b>=0)return r.subVectors(p,d),u=(g-v)/(g-v+(x-b)),l.copy(d).addScaledVector(r,u);var S=1/(_+w+y);return c=w*S,u=y*S,l.copy(h).addScaledVector(e,c).addScaledVector(t,u)}}(),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}),k.prototype=Object.assign(Object.create(c.prototype),{constructor:k,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return c.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,r,i=this,n=this.geometry;if(n.isBufferGeometry){var a=n.morphAttributes,o=Object.keys(a);if(o.length>0){var s=a[o[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=l.length;er.far?null:{distance:c,point:b.clone(),object:e}}function t(t,r,i,n,a,o,u,d,p){s.fromBufferAttribute(a,u),l.fromBufferAttribute(a,d),c.fromBufferAttribute(a,p);var m=e(t,r,i,n,s,l,c,x);if(m){o&&(v.fromBufferAttribute(o,u),g.fromBufferAttribute(o,d),y.fromBufferAttribute(o,p),m.uv=U.getUV(x,s,l,c,v,g,y,new f));var b=new h(u,d,p);U.getNormal(s,l,c,b.normal),m.face=b}return m}var n=new r,a=new I,o=new p,s=new i,l=new i,c=new i,u=new i,d=new i,m=new i,v=new f,g=new f,y=new f,x=new i,b=new i;return function(r,i){var h=this,p=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===p.boundingSphere&&p.computeBoundingSphere(),o.copy(p.boundingSphere),o.applyMatrix4(w),r.ray.intersectsSphere(o)!==!1&&(n.getInverse(w),a.copy(r.ray).applyMatrix4(n),null===p.boundingBox||a.intersectsBox(p.boundingBox)!==!1))){var _;if(p.isBufferGeometry){var S,A,M,T,E,C,L,P,N,O,D,F=p.index,R=p.attributes.position,I=p.attributes.uv,k=p.groups,B=p.drawRange;if(null!==F)if(Array.isArray(b))for(T=0,C=k.length;T0&&(G=Y);for(var q=0,Q=H.length;qh)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}else for(var w=0,_=x.length/3-1;w<_;w+=v){d.fromArray(x,3*w),p.fromArray(x,3*w+3);var M=t.distanceSqToSegment(d,p,m,f);if(!(M>h)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}}else if(l.isGeometry)for(var E=l.vertices,C=E.length,w=0;wh)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);Tr.far||a.push({distance:T,point:f.clone().applyMatrix4(o.matrixWorld),index:w,face:null,faceIndex:null,object:o})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var xu=function(){function e(e,t){this.mesh=e,this.iks=t||[],this._valid()}function t(e,t){c.call(this),this.root=e,this.iks=t||[],this.matrix.copy(e.matrixWorld),this.matrixAutoUpdate=!1,this.sphereGeometry=new O(.25,16,8),this.targetSphereMaterial=new F({color:new u(16746632),depthTest:!1,depthWrite:!1,transparent:!0}),this.effectorSphereMaterial=new F({color:new u(8978312),depthTest:!1,depthWrite:!1,transparent:!0}),this.linkSphereMaterial=new F({color:new u(8947967),depthTest:!1,depthWrite:!1,transparent:!0}),this.lineMaterial=new R({color:new u(16711680),depthTest:!1,depthWrite:!1,transparent:!0}),this._init()}return e.prototype={constructor:e,update:function(){var e=new n,t=new i,r=new i,a=new i,o=new i,s=new i,l=new n,c=new i,u=new i,h=new i;return function(){for(var i=this.mesh.skeleton.bones,n=this.iks,d=Math,p=0,f=n.length;p1?C=1:C<-1&&(C=-1),C=d.acos(C),!(C<1e-5)){if(void 0!==m.minAngle&&Cm.maxAngle&&(C=m.maxAngle),u.crossVectors(o,r),u.normalize(),e.setFromAxisAngle(u,C),A.quaternion.multiply(e),void 0!==M){var L=A.quaternion.w;L>1&&(L=1);var P=d.sqrt(1-L*L);A.quaternion.set(M.x*P,M.y*P,M.z*P,L)}void 0!==T&&A.rotation.setFromVector3(A.rotation.toVector3(h).max(T)),void 0!==E&&A.rotation.setFromVector3(A.rotation.toVector3(h).min(E)),A.updateMatrixWorld(!0),w=!0}}if(!w)break}}return this}}(),createHelper:function(){return new t(this.mesh,this.mesh.geometry.userData.MMD.iks)},_valid:function(){for(var e=this.iks,t=this.mesh.skeleton.bones,r=0,i=e.length;r0)for(var l=this._interpolants,c=this._propertyBindings,u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var r=this._weightInterpolant;if(null!==r){var i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){var i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,r=this._clip.duration,i=this.loop,n=this._loopCount,a=i===Jc;if(0===e)return n===-1?t:a&&1===(1&n)?r-t:t;if(i===qc){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=r)t=r;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=r||t<0){var o=Math.floor(t/r);t-=r*o,n+=Math.abs(o);var s=this.repetitions-n;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?r:0,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=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1===(1&n))return this.time=t,r-t}return this.time=t,t},_setEndings:function(e,t,r){var i=this._interpolantSettings;r?(i.endingStart=tu,i.endingEnd=tu):(e?i.endingStart=this.zeroSlopeAtStart?tu:eu:i.endingStart=ru,t?i.endingEnd=this.zeroSlopeAtEnd?tu:eu:i.endingEnd=ru)},_scheduleFading:function(e,t,r){var i=this._mixer,n=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(), this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=n,s[0]=t,o[1]=n+e,s[1]=r,this}}),Object.assign(j.prototype,{evaluate:function(e){var t=this,r=this.parameterPositions,i=this._cachedIndex,n=r[i],a=r[i-1];e:{t:{var o;r:{i:if(!(e=a)break e;var l=r[1];e=a)break t}o=i,i=0}}for(;i>>1;e=.5)for(var a=0;a!==n;++a)e[t+a]=e[r+a]},_slerp:function(e,t,r,i){n.slerpFlat(e,t,e,t,e,r,i)},_lerp:function(e,t,r,i,n){for(var a=1-i,o=0;o!==n;++o){var s=t+o;e[s]=e[s]*a+e[r+o]*i}}});var wu={arraySlice:function(e,t,r){return wu.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==r?r:e.length)):e.slice(t,r)},convertArray:function(e,t,r){return!e||!r&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(t,r){return e[t]-e[r]}for(var r=e.length,i=new Array(r),n=0;n!==r;++n)i[n]=n;return i.sort(t),i},sortedArray:function(e,t,r){for(var i=e.length,n=new e.constructor(i),a=0,o=0;o!==i;++a)for(var s=r[a]*t,l=0;l!==t;++l)n[o++]=e[s+l];return n},flattenJSON:function(e,t,r,i){for(var n=1,a=e[0];void 0!==a&&void 0===a[i];)a=e[n++];if(void 0!==a){var o=a[i];if(void 0!==o)if(Array.isArray(o)){do o=a[i],void 0!==o&&(t.push(a.time),r.push.apply(r,o)),a=e[n++];while(void 0!==a)}else if(void 0!==o.toArray){do o=a[i],void 0!==o&&(t.push(a.time),o.toArray(r,r.length)),a=e[n++];while(void 0!==a)}else do o=a[i],void 0!==o&&(t.push(a.time),r.push(o)),a=e[n++];while(void 0!==a)}}};H.prototype=Object.assign(Object.create(j.prototype),{constructor:H,DefaultSettings_:{endingStart:eu,endingEnd:eu},intervalChanged_:function(e,t,r){var i=this.parameterPositions,n=e-2,a=e+1,o=i[n],s=i[a];if(void 0===o)switch(this.getSettings_().endingStart){case tu:n=e,o=2*t-r;break;case ru:n=i.length-2,o=t+i[n]-i[n+1];break;default:n=e,o=r}if(void 0===s)switch(this.getSettings_().endingEnd){case tu:a=e,s=2*r-t;break;case ru:a=1,s=r+i[1]-i[0];break;default:a=e-1,s=t}var l=.5*(r-t),c=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(s-r),this._offsetPrev=n*c,this._offsetNext=a*c},interpolate_:function(e,t,r,i){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(r-t)/(i-t),f=p*p,m=f*p,v=-h*m+2*h*f-h*p,g=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f,b=0;b!==o;++b)n[b]=v*a[c+b]+g*a[l+b]+y*a[s+b]+x*a[u+b];return n}}),Y.prototype=Object.assign(Object.create(j.prototype),{constructor:Y,interpolate_:function(e){return this.copySampleValue_(e-1)}}),Object.assign(q,{toJSON:function(e){var t,r=e.constructor;if(void 0!==r.toJSON)t=r.toJSON(e);else{t={name:e.name,times:wu.convertArray(e.times,Array),values:wu.convertArray(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t}}),Object.assign(q.prototype,{constructor:q,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Kc,InterpolantFactoryMethodDiscrete:function(e){return new Y(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new V(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new H(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t;switch(e){case Zc:t=this.InterpolantFactoryMethodDiscrete;break;case Kc:t=this.InterpolantFactoryMethodLinear;break;case $c:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(r);this.setInterpolation(this.DefaultInterpolation)}return console.warn("KeyframeTrack:",r),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Zc;case this.InterpolantFactoryMethodLinear:return Kc;case this.InterpolantFactoryMethodSmooth:return $c}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,r=0,i=t.length;r!==i;++r)t[r]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,r=0,i=t.length;r!==i;++r)t[r]*=e;return this},trim:function(e,t){for(var r=this.times,i=r.length,n=0,a=i-1;n!==i&&r[n]t;)--a;if(++a,0!==n||a!==i){n>=a&&(a=Math.max(a,1),n=a-1);var o=this.getValueSize();this.times=wu.arraySlice(r,n,a),this.values=wu.arraySlice(this.values,n*o,a*o)}return this},validate:function(){var e=this,t=!0,r=this.getValueSize();r-Math.floor(r)!==0&&(console.error("KeyframeTrack: Invalid value size in track.",this),t=!1);var i=this.times,n=this.values,a=i.length;0===a&&(console.error("KeyframeTrack: Track is empty.",this),t=!1);for(var o=null,s=0;s!==a;s++){var l=i[s];if("number"==typeof l&&isNaN(l)){console.error("KeyframeTrack: Time is not a valid number.",e,s,l),t=!1;break}if(null!==o&&o>l){console.error("KeyframeTrack: Out of order keys.",e,s,l,o),t=!1;break}o=l}if(void 0!==n&&wu.isTypedArray(n))for(var s=0,c=n.length;s!==c;++s){var u=n[s];if(isNaN(u)){console.error("KeyframeTrack: Value is not a valid number.",e,s,u),t=!1;break}}return t},optimize:function(){for(var e=this.times,t=this.values,r=this.getValueSize(),i=this.getInterpolation()===$c,n=1,a=e.length-1,o=1;o0){e[n]=e[a];for(var m=a*r,v=n*r,p=0;p!==r;++p)t[v+p]=t[m+p];++n}return n!==e.length&&(this.times=wu.arraySlice(e,0,n),this.values=wu.arraySlice(t,0,n*r)),this}}),Q.prototype=Object.assign(Object.create(q.prototype),{constructor:Q,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Zc,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),J.prototype=Object.assign(Object.create(q.prototype),{constructor:J,ValueTypeName:"color"}),Z.prototype=Object.assign(Object.create(q.prototype),{constructor:Z,ValueTypeName:"number"}),K.prototype=Object.assign(Object.create(j.prototype),{constructor:K,interpolate_:function(e,t,r,i){for(var a=this.resultBuffer,o=this.sampleValues,s=this.valueSize,l=e*s,c=(r-t)/(i-t),u=l+s;l!==u;l+=4)n.slerpFlat(a,0,o,l-s,o,l,c);return a}}),$.prototype=Object.assign(Object.create(q.prototype),{constructor:$,ValueTypeName:"quaternion",DefaultInterpolation:Kc,InterpolantFactoryMethodLinear:function(e){return new K(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),ee.prototype=Object.assign(Object.create(q.prototype),{constructor:ee,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Zc,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),te.prototype=Object.assign(Object.create(q.prototype),{constructor:te,ValueTypeName:"vector"}),Object.assign(re,{parse:function(e){for(var t=[],r=e.tracks,i=1/(e.fps||1),n=0,a=r.length;n!==a;++n)t.push(ne(r[n]).scale(i));return new re(e.name,e.duration,t)},toJSON:function(e){for(var t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},n=0,a=r.length;n!==a;++n)t.push(q.toJSON(r[n]));return i},CreateFromMorphTargetSequence:function(e,t,r,i){for(var n=t.length,a=[],o=0;o1){var c=l[1],u=i[c];u||(i[c]=u=[]),u.push(s)}}var h=[];for(var c in i)h.push(re.CreateFromMorphTargetSequence(c,i[c],t,r));return h},parseAnimation:function(e,t){if(!e)return console.error("AnimationClip: No animation in JSONLoader data."),null;for(var r=function(e,t,r,i,n){if(0!==r.length){var a=[],o=[];wu.flattenJSON(r,a,o,i),0!==a.length&&n.push(new e(t,a,o))}},i=[],n=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],l=0;lthis.maxStepNum&&(i=this.maxStepNum),this.world.stepSimulation(r,i,t)},_updateRigidBodies:function(){for(var e=this,t=0,r=this.bodies.length;t0?this.threeVector3s.pop():new i},freeThreeVector3:function(e){this.threeVector3s.push(e)},allocThreeMatrix4:function(){return this.threeMatrix4s.length>0?this.threeMatrix4s.pop():new r},freeThreeMatrix4:function(e){this.threeMatrix4s.push(e)},allocThreeQuaternion:function(){return this.threeQuaternions.length>0?this.threeQuaternions.pop():new n},freeThreeQuaternion:function(e){this.threeQuaternions.push(e)},allocThreeEuler:function(){return this.threeEulers.length>0?this.threeEulers.pop():new o},freeThreeEuler:function(e){this.threeEulers.push(e)},allocTransform:function(){return this.transforms.length>0?this.transforms.pop():new Ammo.btTransform},freeTransform:function(e){this.transforms.push(e)},allocQuaternion:function(){return this.quaternions.length>0?this.quaternions.pop():new Ammo.btQuaternion},freeQuaternion:function(e){this.quaternions.push(e)},allocVector3:function(){return this.vector3s.length>0?this.vector3s.pop():new Ammo.btVector3},freeVector3:function(e){this.vector3s.push(e)},setIdentity:function(e){e.setIdentity()},getBasis:function(e){var t=this.allocQuaternion();return e.getBasis().getRotation(t),t},getBasisAsMatrix3:function(e){var t=this.getBasis(e),r=this.quaternionToMatrix3(t);return this.freeQuaternion(t),r},getOrigin:function(e){return e.getOrigin()},setOrigin:function(e,t){e.getOrigin().setValue(t.x(),t.y(),t.z())},copyOrigin:function(e,t){var r=t.getOrigin();this.setOrigin(e,r)},setBasis:function(e,t){e.setRotation(t)},setBasisFromMatrix3:function(e,t){var r=this.matrix3ToQuaternion(t);this.setBasis(e,r),this.freeQuaternion(r)},setOriginFromArray3:function(e,t){e.getOrigin().setValue(t[0],t[1],t[2])},setOriginFromThreeVector3:function(e,t){e.getOrigin().setValue(t.x,t.y,t.z)},setBasisFromArray3:function(e,t){var r=this.allocThreeQuaternion(),i=this.allocThreeEuler();i.set(t[0],t[1],t[2]),this.setBasisFromThreeQuaternion(e,r.setFromEuler(i)),this.freeThreeEuler(i),this.freeThreeQuaternion(r)},setBasisFromThreeQuaternion:function(e,t){var r=this.allocQuaternion();r.setX(t.x),r.setY(t.y),r.setZ(t.z),r.setW(t.w),this.setBasis(e,r),this.freeQuaternion(r)},multiplyTransforms:function(e,t){var r=this.allocTransform();this.setIdentity(r);var i=this.getBasisAsMatrix3(e),n=this.getBasisAsMatrix3(t),a=this.getOrigin(e),o=this.getOrigin(t),s=this.multiplyMatrix3ByVector3(i,o),l=this.addVector3(s,a);this.setOrigin(r,l);var c=this.multiplyMatrices3(i,n);return this.setBasisFromMatrix3(r,c),this.freeVector3(s),this.freeVector3(l),r},inverseTransform:function(e){var t=this.allocTransform(),r=this.getBasisAsMatrix3(e),i=this.getOrigin(e),n=this.transposeMatrix3(r),a=this.negativeVector3(i),o=this.multiplyMatrix3ByVector3(n,a);return this.setOrigin(t,o),this.setBasisFromMatrix3(t,n),this.freeVector3(a),this.freeVector3(o),t},multiplyMatrices3:function(e,t){var r=[],i=this.rowOfMatrix3(e,0),n=this.rowOfMatrix3(e,1),a=this.rowOfMatrix3(e,2),o=this.columnOfMatrix3(t,0),s=this.columnOfMatrix3(t,1),l=this.columnOfMatrix3(t,2);return r[0]=this.dotVectors3(i,o),r[1]=this.dotVectors3(i,s),r[2]=this.dotVectors3(i,l),r[3]=this.dotVectors3(n,o),r[4]=this.dotVectors3(n,s),r[5]=this.dotVectors3(n,l), r[6]=this.dotVectors3(a,o),r[7]=this.dotVectors3(a,s),r[8]=this.dotVectors3(a,l),this.freeVector3(i),this.freeVector3(n),this.freeVector3(a),this.freeVector3(o),this.freeVector3(s),this.freeVector3(l),r},addVector3:function(e,t){var r=this.allocVector3();return r.setValue(e.x()+t.x(),e.y()+t.y(),e.z()+t.z()),r},dotVectors3:function(e,t){return e.x()*t.x()+e.y()*t.y()+e.z()*t.z()},rowOfMatrix3:function(e,t){var r=this.allocVector3();return r.setValue(e[3*t+0],e[3*t+1],e[3*t+2]),r},columnOfMatrix3:function(e,t){var r=this.allocVector3();return r.setValue(e[t+0],e[t+3],e[t+6]),r},negativeVector3:function(e){var t=this.allocVector3();return t.setValue(-e.x(),-e.y(),-e.z()),t},multiplyMatrix3ByVector3:function(e,t){var r=this.allocVector3(),i=this.rowOfMatrix3(e,0),n=this.rowOfMatrix3(e,1),a=this.rowOfMatrix3(e,2),o=this.dotVectors3(i,t),s=this.dotVectors3(n,t),l=this.dotVectors3(a,t);return r.setValue(o,s,l),this.freeVector3(i),this.freeVector3(n),this.freeVector3(a),r},transposeMatrix3:function(e){var t=[];return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],t},quaternionToMatrix3:function(e){var t=[],r=e.x(),i=e.y(),n=e.z(),a=e.w(),o=r*r,s=i*i,l=n*n,c=r*i,u=i*n,h=n*r,d=r*a,p=i*a,f=n*a;return t[0]=1-2*(s+l),t[1]=2*(c-f),t[2]=2*(h+p),t[3]=2*(c+f),t[4]=1-2*(l+o),t[5]=2*(u-d),t[6]=2*(h-p),t[7]=2*(u+d),t[8]=1-2*(o+s),t},matrix3ToQuaternion:function(e){var t,r,i,n,a,o=e[0]+e[4]+e[8];o>0?(t=2*Math.sqrt(o+1),a=.25*t,r=(e[7]-e[5])/t,i=(e[2]-e[6])/t,n=(e[3]-e[1])/t):e[0]>e[4]&&e[0]>e[8]?(t=2*Math.sqrt(1+e[0]-e[4]-e[8]),a=(e[7]-e[5])/t,r=.25*t,i=(e[1]+e[3])/t,n=(e[2]+e[6])/t):e[4]>e[8]?(t=2*Math.sqrt(1+e[4]-e[0]-e[8]),a=(e[2]-e[6])/t,r=(e[1]+e[3])/t,i=.25*t,n=(e[5]+e[7])/t):(t=2*Math.sqrt(1+e[8]-e[0]-e[4]),a=(e[3]-e[1])/t,r=(e[2]+e[6])/t,i=(e[5]+e[7])/t,n=.25*t);var s=this.allocQuaternion();return s.setX(r),s.setY(i),s.setZ(n),s.setW(a),s}},a.prototype={constructor:e.RigidBody,reset:function(){return this._setTransformFromBone(),this},updateFromBone:function(){return this.params.boneIndex!==-1&&0===this.params.type&&this._setTransformFromBone(),this},updateBone:function(){return 0===this.params.type||this.params.boneIndex===-1?this:(this._updateBoneRotation(),1===this.params.type&&this._updateBonePosition(),this.bone.updateMatrixWorld(!0),2===this.params.type&&this._setPositionFromBone(),this)},_init:function(){function e(e){switch(e.shapeType){case 0:return new Ammo.btSphereShape(e.width);case 1:return new Ammo.btBoxShape(new Ammo.btVector3(e.width,e.height,e.depth));case 2:return new Ammo.btCapsuleShape(e.width,e.height);default:throw"unknown shape type "+e.shapeType}}var t=this.manager,r=this.params,i=this.mesh.skeleton.bones,n=r.boneIndex===-1?new oe:i[r.boneIndex],a=e(r),o=0===r.type?0:r.weight,s=t.allocVector3();s.setValue(0,0,0),0!==o&&a.calculateLocalInertia(o,s);var l=t.allocTransform();t.setIdentity(l),t.setOriginFromArray3(l,r.position),t.setBasisFromArray3(l,r.rotation);var c=t.allocThreeVector3(),u=t.allocTransform();t.setIdentity(u),t.setOriginFromThreeVector3(u,n.getWorldPosition(c));var h=t.multiplyTransforms(u,l),d=new Ammo.btDefaultMotionState(h),p=new Ammo.btRigidBodyConstructionInfo(o,d,a,s);p.set_m_friction(r.friction),p.set_m_restitution(r.restitution);var f=new Ammo.btRigidBody(p);0===r.type&&(f.setCollisionFlags(2|f.getCollisionFlags()),f.setActivationState(4)),f.setDamping(r.positionDamping,r.rotationDamping),f.setSleepingThresholds(0,0),this.world.addRigidBody(f,1<=0)throw new Error("MMDAnimationHelper._addMesh: SkinnedMesh '"+e.name+"' has already been added.");return this.meshes.push(e),this.objects.set(e,{looped:!1}),this._setupMeshAnimation(e,t.animation),t.physics!==!1&&this._setupMeshPhysics(e,t),this},_setupCamera:function(e,t){if(this.camera===e)throw new Error("MMDAnimationHelper._setupCamera: Camera '"+e.name+"' has already been set.");return this.camera&&this.clearCamera(this.camera),this.camera=e,e.add(this.cameraTarget),this.objects.set(e,{}),void 0!==t.animation&&this._setupCameraAnimation(e,t.animation),this},_setupAudio:function(e,r){if(this.audio===e)throw new Error("MMDAnimationHelper._setupAudio: Audio '"+e.name+"' has already been set.");return this.audio&&this.clearAudio(this.audio),this.audio=e,this.audioManager=new t(e,r),this.objects.set(this.audioManager,{duration:this.audioManager.duration}),this},_removeMesh:function(e){for(var t=this,r=!1,i=0,n=0,a=this.meshes.length;n0&&".bones"!==t[0].name.slice(0,6)||(r.looped=!0)})}return r.ikSolver=this._createCCDIKSolver(e),r.grantSolver=this.createGrantSolver(e),this},_setupCameraAnimation:function(e,t){var r=Array.isArray(t)?t:[t],i=this.objects.get(e);i.mixer=new ae(e);for(var n=0,a=r.length;n0):u.enabled=!0}},_createCCDIKSolver:function(e){if(void 0===xu)throw new Error("MMDAnimationHelper: Import CCDIKSolver.");return new xu(e,e.geometry.userData.MMD.iks)},_createMMDPhysics:function(e,t){if(void 0===_u)throw new Error("MMDPhysics: Import MMDPhysics.");return new _u(e,e.geometry.userData.MMD.rigidBodies,e.geometry.userData.MMD.constraints,t)},_syncDuration:function(){for(var e=this,t=0,r=this.objects,i=this.meshes,n=this.camera,a=this.audioManager,o=0,s=i.length;o=this.duration;)e.currentTime-=e.duration;return!(this.currentTime=this.duration}},r.prototype={constructor:r,update:function(){var e=new n;return function(){for(var t=this.mesh.skeleton.bones,r=this.grants,i=0,n=r.length;i0&&(r.defines=this.defines),r.vertexShader=this.vertexShader,r.fragmentShader=this.fragmentShader,r},fe.prototype=Object.assign(Object.create(c.prototype),{constructor:fe,copy:function(e,t){return c.prototype.copy.call(this,e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var t=c.prototype.toJSON.call(this,e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}),me.prototype=Object.assign(Object.create(he.prototype),{constructor:me,isOrthographicCamera:!0,copy:function(e,t){return he.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,r,i,n,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=r,this.view.offsetY=i,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2,n=r-e,a=r+e,o=i+t,s=i-t;if(null!==this.view&&this.view.enabled){var l=this.zoom/(this.view.width/this.view.fullWidth),c=this.zoom/(this.view.height/this.view.fullHeight),u=(this.right-this.left)/this.view.width,h=(this.top-this.bottom)/this.view.height;n+=u*(this.view.offsetX/l),a=n+u*(this.view.width/l),o-=h*(this.view.offsetY/c),s=o-h*(this.view.height/c)}this.projectionMatrix.makeOrthographic(n,a,o,s,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=c.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}});var Tu={getDataURL:function(e){var t;if(e instanceof HTMLCanvasElement)t=e;else{t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),t.width=e.width,t.height=e.height;var r=t.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height)}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},Eu=0;ve.DEFAULT_IMAGE=void 0,ve.DEFAULT_MAPPING=Vl,ve.prototype=Object.assign(Object.create(a.prototype),{constructor:ve,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,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.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.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=Fs.generateUUID()),!t&&void 0===e.images[i.uuid]){var n;if(Array.isArray(i)){n=[];for(var a=0,o=i.length;a1)switch(this.wrapS){case Jl:e.x=e.x-Math.floor(e.x);break;case Zl:e.x=e.x<0?0:1;break;case Kl: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 Jl:e.y=e.y-Math.floor(e.y);break;case Zl:e.y=e.y<0?0:1;break;case Kl: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}}),Object.defineProperty(ve.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),ge.prototype=Object.assign(Object.create(a.prototype),{constructor:ge,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ye.prototype=Object.create(m.prototype),ye.prototype.constructor=ye,xe.prototype=Object.create(P.prototype),xe.prototype.constructor=xe;var Cu={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:1},nearClip:{value:1},farClip:{value:1e3}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float maxblur;","uniform float aperture;","uniform float nearClip;","uniform float farClip;","uniform float focus;","uniform float aspect;","#include ","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );","\t#else","\treturn orthographicDepthToViewZ( depth, nearClip, farClip );","\t#endif","}","void main() {","vec2 aspectcorrect = vec2( 1.0, aspect );","float viewZ = getViewZ( getDepth( vUv ) );","float factor = ( focus + viewZ );","vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );","vec2 dofblur9 = dofblur * 0.9;","vec2 dofblur7 = dofblur * 0.7;","vec2 dofblur4 = dofblur * 0.4;","vec4 col = vec4( 0.0 );","col += texture2D( tColor, vUv.xy );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );","col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );","gl_FragColor = col / 41.0;","gl_FragColor.a = 1.0;","}"].join("\n") -},Lu={uniforms:{textureWidth:{value:1},textureHeight:{value:1},focalDepth:{value:1},focalLength:{value:24},fstop:{value:.9},tColor:{value:null},tDepth:{value:null},maxblur:{value:1},showFocus:{value:0},manualdof:{value:0},vignetting:{value:0},depthblur:{value:0},threshold:{value:.5},gain:{value:2},bias:{value:.5},fringe:{value:.7},znear:{value:.1},zfar:{value:100},noise:{value:1},dithering:{value:1e-4},pentagon:{value:0},shaderFocus:{value:1},focusCoords:{value:new f}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float textureWidth;","uniform float textureHeight;","uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below","uniform float focalLength; //focal length in mm","uniform float fstop; //f-stop value","uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)","","uniform float znear; // camera clipping start","uniform float zfar; // camera clipping end","//------------------------------------------","//user variables","const int samples = SAMPLES; //samples on the first ring","const int rings = RINGS; //ring count","const int maxringsamples = rings * samples;","uniform bool manualdof; // manual dof calculation","float ndofstart = 1.0; // near dof blur start","float ndofdist = 2.0; // near dof blur falloff distance","float fdofstart = 1.0; // far dof blur start","float fdofdist = 3.0; // far dof blur falloff distance","float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)","uniform bool vignetting; // use optical lens vignetting","float vignout = 1.3; // vignetting outer border","float vignin = 0.0; // vignetting inner border","float vignfade = 22.0; // f-stops till vignete fades","uniform bool shaderFocus;","// disable if you use external focalDepth value","uniform vec2 focusCoords;","// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)","// if center of screen use vec2(0.5, 0.5);","uniform float maxblur;","//clamp value of max blur (0.0 = no blur, 1.0 default)","uniform float threshold; // highlight threshold;","uniform float gain; // highlight gain;","uniform float bias; // bokeh edge bias","uniform float fringe; // bokeh chromatic aberration / fringing","uniform bool noise; //use noise instead of pattern for sample dithering","uniform float dithering;","uniform bool depthblur; // blur the depth buffer","float dbsize = 1.25; // depth blur size","","uniform bool pentagon; //use pentagon as bokeh shape?","float feather = 0.4; //pentagon shape feather","//------------------------------------------","float penta(vec2 coords) {","//pentagonal shape","float scale = float(rings) - 1.3;","vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);","vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);","vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);","vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);","vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);","vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);","vec4 one = vec4( 1.0 );","vec4 P = vec4((coords),vec2(scale, scale));","vec4 dist = vec4(0.0);","float inorout = -4.0;","dist.x = dot( P, HS0 );","dist.y = dot( P, HS1 );","dist.z = dot( P, HS2 );","dist.w = dot( P, HS3 );","dist = smoothstep( -feather, feather, dist );","inorout += dot( dist, one );","dist.x = dot( P, HS4 );","dist.y = HS5.w - abs( P.z );","dist = smoothstep( -feather, feather, dist );","inorout += dist.x;","return clamp( inorout, 0.0, 1.0 );","}","float bdepth(vec2 coords) {","// Depth buffer blur","float d = 0.0;","float kernel[9];","vec2 offset[9];","vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;","offset[0] = vec2(-wh.x,-wh.y);","offset[1] = vec2( 0.0, -wh.y);","offset[2] = vec2( wh.x -wh.y);","offset[3] = vec2(-wh.x, 0.0);","offset[4] = vec2( 0.0, 0.0);","offset[5] = vec2( wh.x, 0.0);","offset[6] = vec2(-wh.x, wh.y);","offset[7] = vec2( 0.0, wh.y);","offset[8] = vec2( wh.x, wh.y);","kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;","kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;","kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;","for( int i=0; i<9; i++ ) {","float tmp = texture2D(tDepth, coords + offset[i]).r;","d += tmp * kernel[i];","}","return d;","}","vec3 color(vec2 coords,float blur) {","//processing the sample","vec3 col = vec3(0.0);","vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);","col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;","col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;","col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;","vec3 lumcoeff = vec3(0.299,0.587,0.114);","float lum = dot(col.rgb, lumcoeff);","float thresh = max((lum-threshold)*gain, 0.0);","return col+mix(vec3(0.0),col,thresh*blur);","}","vec3 debugFocus(vec3 col, float blur, float depth) {","float edge = 0.002*depth; //distance based edge smoothing","float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);","float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);","col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);","col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);","return col;","}","float linearize(float depth) {","return -zfar * znear / (depth * (zfar - znear) - zfar);","}","float vignette() {","float dist = distance(vUv.xy, vec2(0.5,0.5));","dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);","return clamp(dist,0.0,1.0);","}","float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {","float rings2 = float(rings);","float step = PI*2.0 / float(ringsamples);","float pw = cos(j*step)*i;","float ph = sin(j*step)*i;","float p = 1.0;","if (pentagon) {","p = penta(vec2(pw,ph));","}","col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;","return 1.0 * mix(1.0, i /rings2, bias) * p;","}","void main() {","//scene depth calculation","float depth = linearize(texture2D(tDepth,vUv.xy).x);","// Blur depth?","if ( depthblur ) {","depth = linearize(bdepth(vUv.xy));","}","//focal plane calculation","float fDepth = focalDepth;","if (shaderFocus) {","fDepth = linearize(texture2D(tDepth,focusCoords).x);","}","// dof blur factor calculation","float blur = 0.0;","if (manualdof) {","float a = depth-fDepth; // Focal plane","float b = (a-fdofstart)/fdofdist; // Far DoF","float c = (-a-ndofstart)/ndofdist; // Near Dof","blur = (a>0.0) ? b : c;","} else {","float f = focalLength; // focal length in mm","float d = fDepth*1000.0; // focal plane in mm","float o = depth*1000.0; // depth in mm","float a = (o*f)/(o-f);","float b = (d*f)/(d-f);","float c = (d-f)/(d*fstop*CoC);","blur = abs(a-b)*c;","}","blur = clamp(blur,0.0,1.0);","// calculation of pattern for dithering","vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;","// getting blur x and y step factor","float w = (1.0/textureWidth)*blur*maxblur+noise.x;","float h = (1.0/textureHeight)*blur*maxblur+noise.y;","// calculation of final color","vec3 col = vec3(0.0);","if(blur < 0.05) {","//some optimization thingy","col = texture2D(tColor, vUv.xy).rgb;","} else {","col = texture2D(tColor, vUv.xy).rgb;","float s = 1.0;","int ringsamples;","for (int i = 1; i <= rings; i++) {","","ringsamples = i * samples;","for (int j = 0 ; j < maxringsamples ; j++) {","if (j >= ringsamples) break;","s += gather(float(i), float(j), ringsamples, col, w, h, blur);","}","","}","col /= s; //divide by sample count","}","if (showFocus) {","col = debugFocus(col, blur, depth);","}","if (vignetting) {","col *= vignette();","}","gl_FragColor.rgb = col;","gl_FragColor.a = 1.0;","} "].join("\n")},Pu={uniforms:{mNear:{value:1},mFar:{value:1e3}},vertexShader:["varying float vViewZDepth;","void main() {","\t#include ","\t#include ","\tvViewZDepth = - mvPosition.z;","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","varying float vViewZDepth;","void main() {","\tfloat color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );","\tgl_FragColor = vec4( vec3( color ), 1.0 );","} "].join("\n")},Nu=function(e,t,r,i){de.call(this,e,t,r,i),this.type="CinematicCamera",this.postprocessing={enabled:!0},this.shaderSettings={rings:3,samples:4};var n=Pu;this.materialDepth=new pe({uniforms:n.uniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader}),this.materialDepth.uniforms.mNear.value=r,this.materialDepth.uniforms.mFar.value=i,this.setLens(),this.initPostProcessing()};Nu.prototype=Object.create(de.prototype),Nu.prototype.constructor=Nu,Nu.prototype.setLens=function(e,t,r,i){void 0===e&&(e=35),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e),void 0===r&&(r=8),void 0===i&&(i=.019),this.fNumber=r,this.coc=i,this.aperture=e/this.fNumber,this.hyperFocal=e*e/(this.aperture*this.coc)},Nu.prototype.linearize=function(e){var t=this.far,r=this.near;return-t*r/(e*(t-r)-t)},Nu.prototype.smoothstep=function(e,t,r){var i=this.saturate((r-e)/(t-e));return i*i*(3-2*i)},Nu.prototype.saturate=function(e){return Math.max(0,Math.min(1,e))},Nu.prototype.focusAt=function(e){void 0===e&&(e=20);var t=this.getFocalLength();this.focus=e,this.nearPoint=this.hyperFocal*this.focus/(this.hyperFocal+(this.focus-t)),this.farPoint=this.hyperFocal*this.focus/(this.hyperFocal-(this.focus-t)),this.depthOfField=this.farPoint-this.nearPoint,this.depthOfField<0&&(this.depthOfField=0),this.sdistance=this.smoothstep(this.near,this.far,this.focus),this.ldistance=this.linearize(1-this.sdistance),this.postprocessing.bokeh_uniforms.focalDepth.value=this.ldistance},Nu.prototype.initPostProcessing=function(){if(this.postprocessing.enabled){this.postprocessing.scene=new fe,this.postprocessing.camera=new me(Ds.innerWidth/-2,Ds.innerWidth/2,Ds.innerHeight/2,Ds.innerHeight/-2,(-1e4),1e4),this.postprocessing.scene.add(this.postprocessing.camera);var e={minFilter:rc,magFilter:rc,format:yc};this.postprocessing.rtTextureDepth=new ge(Ds.innerWidth,Ds.innerHeight,e),this.postprocessing.rtTextureColor=new ge(Ds.innerWidth,Ds.innerHeight,e);var t=Cu;this.postprocessing.bokeh_uniforms=Mu.clone(t.uniforms),this.postprocessing.bokeh_uniforms.tColor.value=this.postprocessing.rtTextureColor.texture,this.postprocessing.bokeh_uniforms.tDepth.value=this.postprocessing.rtTextureDepth.texture,this.postprocessing.bokeh_uniforms.manualdof.value=0,this.postprocessing.bokeh_uniforms.shaderFocus.value=0,this.postprocessing.bokeh_uniforms.fstop.value=2.8,this.postprocessing.bokeh_uniforms.showFocus.value=1,this.postprocessing.bokeh_uniforms.focalDepth.value=.1,this.postprocessing.bokeh_uniforms.znear.value=this.near,this.postprocessing.bokeh_uniforms.zfar.value=this.near,this.postprocessing.bokeh_uniforms.textureWidth.value=Ds.innerWidth,this.postprocessing.bokeh_uniforms.textureHeight.value=Ds.innerHeight,this.postprocessing.materialBokeh=new pe({uniforms:this.postprocessing.bokeh_uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,defines:{RINGS:this.shaderSettings.rings,SAMPLES:this.shaderSettings.samples,DEPTH_PACKING:1}}),this.postprocessing.quad=new k(new xe(Ds.innerWidth,Ds.innerHeight),this.postprocessing.materialBokeh),this.postprocessing.quad.position.z=-500,this.postprocessing.scene.add(this.postprocessing.quad)}},Nu.prototype.renderCinematic=function(e,t){this.postprocessing.enabled&&(t.clear(),e.overrideMaterial=null,t.render(e,camera,this.postprocessing.rtTextureColor,!0),e.overrideMaterial=this.materialDepth,t.render(e,camera,this.postprocessing.rtTextureDepth,!0),t.render(this.postprocessing.scene,this.postprocessing.camera))};var Ou={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Du=new be,Fu={};Object.assign(we.prototype,{load:function(e,t,r,i){var n=this;void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var a=this,o=Ou.get(e);if(void 0!==o)return a.manager.itemStart(e),setTimeout(function(){t&&t(o),a.manager.itemEnd(e)},0),o;if(void 0!==Fu[e])return void Fu[e].push({onLoad:t,onProgress:r,onError:i});var s=/^data:(.*?)(;base64)?,(.*)$/,l=e.match(s);if(l){var c=l[1],u=!!l[2],h=l[3];h=Ds.decodeURIComponent(h),u&&(h=Ds.atob(h));try{var d,p=(this.responseType||"").toLowerCase();switch(p){case"arraybuffer":case"blob":for(var f=new Uint8Array(h.length),m=0;m0||0===e.search(/^data\:image\/jpeg/);n.format=i?yc:xc,n.needsUpdate=!0,void 0!==t&&t(n)},r,i),n},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),ke.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,r=0,i=t.length;r1?e.skinWeights[i+1]:0,s=r>2?e.skinWeights[i+2]:0,l=r>3?e.skinWeights[i+3]:0;t.skinWeights.push(new v(a,o,s,l))}if(e.skinIndices)for(var i=0,n=e.skinIndices.length;i1?e.skinIndices[i+1]:0,h=r>2?e.skinIndices[i+2]:0,d=r>3?e.skinIndices[i+3]:0;t.skinIndices.push(new v(c,u,h,d))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}function r(e,t){var r=e.scale;if(void 0!==e.morphTargets)for(var n=0,a=e.morphTargets.length;n0){console.warn('JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=t.faces,d=e.morphColors[0].colors,n=0,a=h.length;n0&&(t.animations=r)}return function(i,a){void 0!==i.data&&(i=i.data),void 0!==i.scale?i.scale=1/i.scale:i.scale=1;var o=new m;if(e(i,o),t(i,o),r(i,o),n(i,o),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===i.materials||0===i.materials.length)return{geometry:o};var s=ke.prototype.initMaterials(i.materials,a,this.crossOrigin);return{geometry:o,materials:s}}}()});var Ru=function(e){"boolean"==typeof e&&(console.warn("BinaryLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Du};Ru.prototype={constructor:Ru,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this.texturePath||Iu.extractUrlBase(e),a=this.binaryPath||Iu.extractUrlBase(e),o=this,s=new we(this.manager);s.load(e,function(e){var s=JSON.parse(e),l=a+s.buffers,c=new we(o.manager);c.setResponseType("arraybuffer"),c.load(l,function(e){o.parse(e,t,n,s.materials)},r,i)},r,i)},setBinaryPath:function(e){return this.binaryPath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},setTexturePath:function(e){return this.texturePath=e,this},parse:function(e,t,r,n){var a=function(){function t(e){return e%4?4-e%4:0}function r(e,t){var r={signature:n(e,t,12),header_bytes:a(e,t+12),vertex_coordinate_bytes:a(e,t+13),normal_coordinate_bytes:a(e,t+14),uv_coordinate_bytes:a(e,t+15),vertex_index_bytes:a(e,t+16),normal_index_bytes:a(e,t+17),uv_index_bytes:a(e,t+18),material_index_bytes:a(e,t+19),nvertices:o(e,t+20),nnormals:o(e,t+20+4),nuvs:o(e,t+20+8),ntri_flat:o(e,t+20+12),ntri_smooth:o(e,t+20+16),ntri_flat_uv:o(e,t+20+20),ntri_smooth_uv:o(e,t+20+24),nquad_flat:o(e,t+20+28),nquad_smooth:o(e,t+20+32),nquad_flat_uv:o(e,t+20+36),nquad_smooth_uv:o(e,t+20+40)};return r}function n(e,t,r){return Iu.decodeText(new Uint8Array(e,t,r))}function a(e,t){var r=new Uint8Array(e,t,1);return r[0]}function o(e,t){var r=new Uint32Array(e,t,1);return r[0]}function s(t){var r,n,a,o,s=E.nvertices,l=new Float32Array(e,t,3*s);for(r=0;r0){var r=n(this.speed/this.MAX_SPEED);this.speed=Fs.clamp(this.speed-r*e*this.FRONT_DECCELERATION,0,this.MAX_SPEED),this.acceleration=Fs.clamp(this.acceleration-r*e,0,1)}else{var r=n(this.speed/this.MAX_REVERSE_SPEED);this.speed=Fs.clamp(this.speed+r*e*this.BACK_ACCELERATION,this.MAX_REVERSE_SPEED,0),this.acceleration=Fs.clamp(this.acceleration+r*e,-1,0)}t.moveLeft||t.moveRight||(this.wheelOrientation>0?this.wheelOrientation=Fs.clamp(this.wheelOrientation-e*this.WHEEL_ANGULAR_DECCELERATION,0,this.MAX_WHEEL_ROTATION):this.wheelOrientation=Fs.clamp(this.wheelOrientation+e*this.WHEEL_ANGULAR_DECCELERATION,-this.MAX_WHEEL_ROTATION,0));var i=this.speed*e;this.carOrientation+=i*this.STEERING_RADIUS_RATIO*this.wheelOrientation,this.root.position.x+=Math.sin(this.carOrientation)*i,this.root.position.z+=Math.cos(this.carOrientation)*i,this.root.rotation.y=this.carOrientation,this.loaded&&(this.bodyMesh.rotation.z=this.MAX_TILT_SIDES*this.wheelOrientation*(this.speed/this.MAX_SPEED),this.bodyMesh.rotation.x=-this.MAX_TILT_FRONTBACK*this.acceleration);var a=1/(this.modelScale*(this.wheelDiameter/2)),o=i*a;this.loaded&&(this.frontLeftWheelMesh.rotation.x+=o,this.frontRightWheelMesh.rotation.x+=o,this.backLeftWheelMesh.rotation.x+=o,this.backRightWheelMesh.rotation.x+=o),this.frontLeftWheelRoot.rotation.y=this.wheelOrientation,this.frontRightWheelRoot.rotation.y=this.wheelOrientation}},ku=function(e){var t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;var r=function(e){t.deviceOrientation=e},a=function(){t.screenOrientation=Ds.orientation||0},s=function(){var e=new i(0,0,1),t=new o,r=new n,a=new n((-Math.sqrt(.5)),0,0,Math.sqrt(.5));return function(i,n,o,s,l){t.set(o,n,-s,"YXZ"),i.setFromEuler(t),i.multiply(a),i.multiply(r.setFromAxisAngle(e,-l))}}();this.connect=function(){a(),Ds.addEventListener("orientationchange",a,!1),Ds.addEventListener("deviceorientation",r,!1),t.enabled=!0},this.disconnect=function(){Ds.removeEventListener("orientationchange",a,!1),Ds.removeEventListener("deviceorientation",r,!1),t.enabled=!1},this.update=function(){if(t.enabled!==!1){var e=t.deviceOrientation;if(e){var r=e.alpha?Fs.degToRad(e.alpha)+t.alphaOffset:0,i=e.beta?Fs.degToRad(e.beta):0,n=e.gamma?Fs.degToRad(e.gamma):0,a=t.screenOrientation?Fs.degToRad(t.screenOrientation):0;s(t.object.quaternion,r,i,n,a)}}},this.dispose=function(){t.disconnect()},this.connect()};Object.assign(ze.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new i,t=new i;return function(r,i,n){var a=e.subVectors(n,i).cross(t.subVectors(r,i)).normalize();return this.setFromNormalAndCoplanarPoint(a,r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("Plane: .projectPoint() target is now required"),t=new i),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new i;return function(t,r){void 0===r&&(console.warn("Plane: .intersectLine() target is now required"),r=new i);var n=t.delta(e),a=this.normal.dot(n);if(0!==a){var o=-(t.start.dot(this.normal)+this.constant)/a;if(!(o<0||o>1))return r.copy(n).multiplyScalar(o).add(t.start)}else if(0===this.distanceToPoint(t.start))return r.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("Plane: .coplanarPoint() target is now required"),e=new i),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new i,t=new l;return function(r,i){var n=i||t.getNormalMatrix(r),a=this.coplanarPoint(e).applyMatrix4(r),o=this.normal.applyMatrix3(n).normalize();return this.constant=-a.dot(o),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(je.prototype,{linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){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()):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)):console.error("Raycaster: Unsupported camera type.")},intersectObject:function(e,t,r){var i=r||[];return Ge(e,this,i,t),i.sort(Ve),i},intersectObjects:function(e,t,r){var i=this,n=r||[];if(Array.isArray(e)===!1)return console.warn("Raycaster.intersectObjects: objects is not an Array."),n;for(var a=0,o=e.length;a0){var o=a[0].object;m.setFromNormalAndCoplanarPoint(t.getWorldDirection(m.normal),o.position),w!==o&&(_.dispatchEvent({type:"hoveron",object:o}),r.style.cursor="pointer",w=o)}else null!==w&&(_.dispatchEvent({type:"hoveroff",object:w}),r.style.cursor="auto",w=null)}function l(i){i.preventDefault(),v.setFromCamera(g,t);var n=v.intersectObjects(e);n.length>0&&(b=n[0].object,v.ray.intersectPlane(m,x)&&y.copy(x).sub(b.position),r.style.cursor="move",_.dispatchEvent({type:"dragstart",object:b}))}function c(e){e.preventDefault(),b&&(_.dispatchEvent({type:"dragend",object:b}),b=null),r.style.cursor=w?"pointer":"auto"}function u(e){e.preventDefault(),e=e.changedTouches[0];var i=r.getBoundingClientRect();if(g.x=(e.clientX-i.left)/i.width*2-1,g.y=2*-((e.clientY-i.top)/i.height)+1,v.setFromCamera(g,t),b&&_.enabled)return v.ray.intersectPlane(m,x)&&b.position.copy(x.sub(y)),void _.dispatchEvent({type:"drag",object:b})}function h(i){i.preventDefault(),i=i.changedTouches[0];var n=r.getBoundingClientRect();g.x=(i.clientX-n.left)/n.width*2-1,g.y=2*-((i.clientY-n.top)/n.height)+1,v.setFromCamera(g,t);var a=v.intersectObjects(e);a.length>0&&(b=a[0].object,m.setFromNormalAndCoplanarPoint(t.getWorldDirection(m.normal),b.position),v.ray.intersectPlane(m,x)&&y.copy(x).sub(b.position),r.style.cursor="move",_.dispatchEvent({type:"dragstart",object:b}))}function d(e){e.preventDefault(),b&&(_.dispatchEvent({type:"dragend",object:b}),b=null),r.style.cursor="auto"}if(e instanceof he){console.warn("DragControls: Constructor now expects ( objects, camera, domElement )");var p=e;e=t,t=p}var m=new ze,v=new je,g=new f,y=new i,x=new i,b=null,w=null,_=this;n(),this.enabled=!0,this.activate=n,this.deactivate=a,this.dispose=o,this.setObjects=function(){console.error("DragControls: setObjects() has been removed.")},this.on=function(e,t){console.warn("DragControls: on() has been deprecated. Use addEventListener() instead."),_.addEventListener(e,t)},this.off=function(e,t){console.warn("DragControls: off() has been deprecated. Use removeEventListener() instead."),_.removeEventListener(e,t)},this.notify=function(e){console.error("DragControls: notify() has been deprecated. Use dispatchEvent() instead."),_.dispatchEvent({type:e})}};Bu.prototype=Object.create(a.prototype),Bu.prototype.constructor=Bu,Object.assign(We.prototype,{set:function(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Fs.clamp(t/this.radius,-1,1))),this}});var zu=function(e,t){function r(e){h.enabled!==!1&&(0===e.button?y=g.ROTATE:1===e.button?y=g.ZOOM:2===e.button&&(y=g.PAN),_.set(e.clientX,e.clientY),t.addEventListener("mousemove",n,!1),t.addEventListener("mouseup",a,!1),t.addEventListener("mouseout",a,!1),t.addEventListener("dblclick",a,!1))}function n(e){if(h.enabled!==!1){w.set(e.clientX,e.clientY);var t=w.x-_.x,r=w.y-_.y;y===g.ROTATE?h.rotate(m.set(-t*h.rotationSpeed,-r*h.rotationSpeed,0)):y===g.ZOOM?h.zoom(m.set(0,0,r)):y===g.PAN&&h.pan(m.set(-t,r,0)),_.set(e.clientX,e.clientY)}}function a(e){t.removeEventListener("mousemove",n,!1),t.removeEventListener("mouseup",a,!1),t.removeEventListener("mouseout",a,!1),t.removeEventListener("dblclick",a,!1),y=g.NONE}function o(e){e.preventDefault(),h.zoom(m.set(0,0,e.deltaY>0?1:-1))}function s(e){e.preventDefault()}function c(e){if(h.enabled!==!1){switch(e.touches.length){case 1:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[0].pageX,e.touches[0].pageY,0);break;case 2:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[1].pageX,e.touches[1].pageY,0),E=M[0].distanceTo(M[1])}T[0].copy(M[0]),T[1].copy(M[1])}}function u(e){function t(e,t){var r=t[0];for(var i in t)r.distanceTo(e)>t[i].distanceTo(e)&&(r=t[i]);return r}if(h.enabled!==!1){switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[0].pageX,e.touches[0].pageY,0),h.rotate(M[0].sub(t(M[0],T)).multiplyScalar(-h.rotationSpeed));break;case 2:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[1].pageX,e.touches[1].pageY,0);var r=M[0].distanceTo(M[1]);h.zoom(m.set(0,0,E-r)),E=r;var i=M[0].clone().sub(t(M[0],T)),n=M[1].clone().sub(t(M[1],T));i.x=-i.x,n.x=-n.x,h.pan(i.add(n).multiplyScalar(.5))}T[0].copy(M[0]),T[1].copy(M[1])}}t=void 0!==t?t:document,this.enabled=!0,this.center=new i,this.panSpeed=.001,this.zoomSpeed=.1,this.rotationSpeed=.005;var h=this,p=new i,m=new i,v=new d,g={NONE:-1,ROTATE:0,ZOOM:1,PAN:2},y=g.NONE,x=this.center,b=new l,w=new f,_=new f,S=new We,A={type:"change"};this.focus=function(t){var r;v.setFromObject(t),v.isEmpty()===!1?(x.copy(v.getCenter()),r=v.getBoundingSphere().radius):(x.setFromMatrixPosition(t.matrixWorld),r=.1),m.set(0,0,1),m.applyQuaternion(e.quaternion),m.multiplyScalar(4*r),e.position.copy(x).add(m),h.dispatchEvent(A)},this.pan=function(t){var r=e.position.distanceTo(x);t.multiplyScalar(r*h.panSpeed),t.applyMatrix3(b.getNormalMatrix(e.matrix)),e.position.add(t),x.add(t),h.dispatchEvent(A)},this.zoom=function(t){var r=e.position.distanceTo(x);t.multiplyScalar(r*h.zoomSpeed),t.length()>r||(t.applyMatrix3(b.getNormalMatrix(e.matrix)),e.position.add(t),h.dispatchEvent(A))},this.rotate=function(t){p.copy(e.position).sub(x),S.setFromVector3(p),S.theta+=t.x,S.phi+=t.y,S.makeSafe(),p.setFromSpherical(S),e.position.copy(x).add(p),e.lookAt(x),h.dispatchEvent(A)},this.dispose=function(){t.removeEventListener("contextmenu",s,!1),t.removeEventListener("mousedown",r,!1),t.removeEventListener("wheel",o,!1),t.removeEventListener("mousemove",n,!1),t.removeEventListener("mouseup",a,!1),t.removeEventListener("mouseout",a,!1),t.removeEventListener("dblclick",a,!1),t.removeEventListener("touchstart",c,!1),t.removeEventListener("touchmove",u,!1)},t.addEventListener("contextmenu",s,!1),t.addEventListener("mousedown",r,!1),t.addEventListener("wheel",o,!1);var M=[new i,new i,new i],T=[new i,new i,new i],E=null;t.addEventListener("touchstart",c,!1),t.addEventListener("touchmove",u,!1)};zu.prototype=Object.create(a.prototype),zu.prototype.constructor=zu;var ju=function(e,t){function r(e){e.preventDefault()}function n(e,t){return function(){t.apply(e,arguments)}}this.object=e,this.target=new i(0,0,0),this.domElement=void 0!==t?t:document,this.enabled=!0,this.movementSpeed=1,this.lookSpeed=.005,this.lookVertical=!0,this.autoForward=!1,this.activeLook=!0,this.heightSpeed=!1,this.heightCoef=1,this.heightMin=0,this.heightMax=1,this.constrainVertical=!1,this.verticalMin=0,this.verticalMax=Math.PI,this.autoSpeedFactor=0,this.mouseX=0,this.mouseY=0,this.lat=0,this.lon=0,this.phi=0,this.theta=0,this.moveForward=!1,this.moveBackward=!1,this.moveLeft=!1,this.moveRight=!1,this.mouseDragOn=!1,this.viewHalfX=0,this.viewHalfY=0,this.domElement!==document&&this.domElement.setAttribute("tabindex",-1),this.handleResize=function(){this.domElement===document?(this.viewHalfX=Ds.innerWidth/2,this.viewHalfY=Ds.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2)},this.onMouseDown=function(e){if(this.domElement!==document&&this.domElement.focus(),e.preventDefault(),e.stopPropagation(),this.activeLook)switch(e.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0},this.onMouseUp=function(e){if(e.preventDefault(),e.stopPropagation(),this.activeLook)switch(e.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1},this.onMouseMove=function(e){this.domElement===document?(this.mouseX=e.pageX-this.viewHalfX,this.mouseY=e.pageY-this.viewHalfY):(this.mouseX=e.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=e.pageY-this.domElement.offsetTop-this.viewHalfY)},this.onKeyDown=function(e){switch(e.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0}},this.onKeyUp=function(e){switch(e.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}},this.update=function(e){if(this.enabled!==!1){if(this.heightSpeed){var t=Fs.clamp(this.object.position.y,this.heightMin,this.heightMax),r=t-this.heightMin;this.autoSpeedFactor=e*(r*this.heightCoef)}else this.autoSpeedFactor=0;var i=e*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(i+this.autoSpeedFactor)),this.moveBackward&&this.object.translateZ(i),this.moveLeft&&this.object.translateX(-i),this.moveRight&&this.object.translateX(i),this.moveUp&&this.object.translateY(i),this.moveDown&&this.object.translateY(-i);var n=e*this.lookSpeed;this.activeLook||(n=0);var a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin)),this.lon+=this.mouseX*n,this.lookVertical&&(this.lat-=this.mouseY*n*a),this.lat=Math.max(-85,Math.min(85,this.lat)),this.phi=Fs.degToRad(90-this.lat),this.theta=Fs.degToRad(this.lon),this.constrainVertical&&(this.phi=Fs.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax));var o=this.target,s=this.object.position;o.x=s.x+100*Math.sin(this.phi)*Math.cos(this.theta),o.y=s.y+100*Math.cos(this.phi),o.z=s.z+100*Math.sin(this.phi)*Math.sin(this.theta),this.object.lookAt(o)}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",r,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("mousemove",a,!1),this.domElement.removeEventListener("mouseup",s,!1),Ds.removeEventListener("keydown",l,!1),Ds.removeEventListener("keyup",c,!1)};var a=n(this,this.onMouseMove),o=n(this,this.onMouseDown),s=n(this,this.onMouseUp),l=n(this,this.onKeyDown),c=n(this,this.onKeyUp);this.domElement.addEventListener("contextmenu",r,!1),this.domElement.addEventListener("mousemove",a,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mouseup",s,!1),Ds.addEventListener("keydown",l,!1),Ds.addEventListener("keyup",c,!1),this.handleResize()},Vu=function(e,t){function r(e,t){return function(){t.apply(e,arguments)}}function a(e){e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,t&&this.domElement.setAttribute("tabindex",-1),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this.tmpQuaternion=new n,this.mouseStatus=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new i(0,0,0),this.rotationVector=new i(0,0,0),this.keydown=function(e){ -if(!e.altKey){switch(e.keyCode){case 16:this.movementSpeedMultiplier=.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(e){switch(e.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector(),this.updateRotationVector()},this.mousedown=function(e){if(this.domElement!==document&&this.domElement.focus(),e.preventDefault(),e.stopPropagation(),this.dragToLook)this.mouseStatus++;else{switch(e.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1}this.updateMovementVector()}},this.mousemove=function(e){if(!this.dragToLook||this.mouseStatus>0){var t=this.getContainerDimensions(),r=t.size[0]/2,i=t.size[1]/2;this.moveState.yawLeft=-(e.pageX-t.offset[0]-r)/r,this.moveState.pitchDown=(e.pageY-t.offset[1]-i)/i,this.updateRotationVector()}},this.mouseup=function(e){if(e.preventDefault(),e.stopPropagation(),this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(e.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0}this.updateMovementVector()}this.updateRotationVector()},this.update=function(e){var t=e*this.movementSpeed,r=e*this.rollSpeed;this.object.translateX(this.moveVector.x*t),this.object.translateY(this.moveVector.y*t),this.object.translateZ(this.moveVector.z*t),this.tmpQuaternion.set(this.rotationVector.x*r,this.rotationVector.y*r,this.rotationVector.z*r,1).normalize(),this.object.quaternion.multiply(this.tmpQuaternion),this.object.rotation.setFromQuaternion(this.object.quaternion,this.object.rotation.order)},this.updateMovementVector=function(){var e=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-e+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[Ds.innerWidth,Ds.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",a,!1),this.domElement.removeEventListener("mousedown",s,!1),this.domElement.removeEventListener("mousemove",o,!1),this.domElement.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",c,!1),Ds.removeEventListener("keyup",u,!1)};var o=r(this,this.mousemove),s=r(this,this.mousedown),l=r(this,this.mouseup),c=r(this,this.keydown),u=r(this,this.keyup);this.domElement.addEventListener("contextmenu",a,!1),this.domElement.addEventListener("mousemove",o,!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mouseup",l,!1),Ds.addEventListener("keydown",c,!1),Ds.addEventListener("keyup",u,!1),this.updateMovementVector(),this.updateRotationVector()},Gu=function(e,t){function r(){return 2*Math.PI/60/60*I.autoRotateSpeed}function a(){return Math.pow(.95,I.zoomSpeed)}function o(e){G.theta-=e}function s(e){G.phi-=e}function l(e){I.object.isPerspectiveCamera?W/=e:I.object.isOrthographicCamera?(I.object.zoom=Math.max(I.minZoom,Math.min(I.maxZoom,I.object.zoom*e)),I.object.updateProjectionMatrix(),H=!0):(console.warn("WARNING: MapControls.js encountered an unknown camera type - dolly/zoom disabled."),I.enableZoom=!1)}function c(e){I.object.isPerspectiveCamera?W*=e:I.object.isOrthographicCamera?(I.object.zoom=Math.max(I.minZoom,Math.min(I.maxZoom,I.object.zoom/e)),I.object.updateProjectionMatrix(),H=!0):(console.warn("WARNING: MapControls.js encountered an unknown camera type - dolly/zoom disabled."),I.enableZoom=!1)}function u(e){Y.set(e.clientX,e.clientY)}function h(e){ne.set(e.clientX,e.clientY)}function d(e){te.set(e.clientX,e.clientY)}function p(e){Q.set(e.clientX,e.clientY),Z.subVectors(Q,Y).multiplyScalar(I.rotateSpeed);var t=I.domElement===document?I.domElement.body:I.domElement;o(2*Math.PI*Z.x/t.clientHeight),s(2*Math.PI*Z.y/t.clientHeight),Y.copy(Q),I.update()}function m(e){ae.set(e.clientX,e.clientY),oe.subVectors(ae,ne),oe.y>0?l(a()):oe.y<0&&c(a()),ne.copy(ae),I.update()}function v(e){re.set(e.clientX,e.clientY),ie.subVectors(re,te).multiplyScalar(I.panSpeed),ce(ie.x,ie.y),te.copy(re),I.update()}function g(e){e.deltaY<0?c(a()):e.deltaY>0&&l(a()),I.update()}function y(e){switch(e.keyCode){case I.keys.UP:ce(0,I.keyPanSpeed),I.update();break;case I.keys.BOTTOM:ce(0,-I.keyPanSpeed),I.update();break;case I.keys.LEFT:ce(I.keyPanSpeed,0),I.update();break;case I.keys.RIGHT:ce(-I.keyPanSpeed,0),I.update()}}function x(e){Y.set(e.touches[0].pageX,e.touches[0].pageY),q.set(e.touches[1].pageX,e.touches[1].pageY)}function b(e){if(I.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);ne.set(0,i)}}function w(e){I.enablePan&&te.set(e.touches[0].pageX,e.touches[0].pageY)}function _(e){if(I.enableRotate!==!1&&0!==(z&B.ROTATE)){if(Q.set(e.touches[0].pageX,e.touches[0].pageY),J.set(e.touches[1].pageX,e.touches[1].pageY),Z.subVectors(Q,Y),K.subVectors(J,q),$.subVectors(q,Y),ee.subVectors(J,Q),S()){var t=I.domElement===document?I.domElement.body:I.domElement;s(2*Math.PI*Z.y/t.clientHeight),z=B.ROTATE_UP}else 0!==(z&B.ROTATE_LEFT)&&o(($.angle()-ee.angle())*I.rotateSpeed);Y.copy(Q),q.copy(J)}}function S(){return!!ue($)&&(!!ue(ee)&&(!!he(Z)&&(!!he(K)&&Z.dot(K)>0)))}function A(e){if(I.enableZoom!==!1&&0!==(z&B.DOLLY)){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);ae.set(0,i),oe.set(0,Math.pow(ae.y/ne.y,I.zoomSpeed)),l(oe.y),ne.copy(ae)}}function M(e){I.enablePan!==!1&&0!==(z&B.PAN)&&(re.set(e.touches[0].pageX,e.touches[0].pageY),ie.subVectors(re,te).multiplyScalar(I.panSpeed),ce(ie.x,ie.y),te.copy(re))}function T(e){if(I.enabled!==!1){switch(e.preventDefault(),e.button){case I.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey){if(I.enableRotate===!1)return;u(e),z=B.ROTATE}else{if(I.enablePan===!1)return;d(e),z=B.PAN}break;case I.mouseButtons.MIDDLE:if(I.enableZoom===!1)return;h(e),z=B.DOLLY;break;case I.mouseButtons.RIGHT:if(I.enableRotate===!1)return;u(e),z=B.ROTATE}z!==B.NONE&&(document.addEventListener("mousemove",E,!1),document.addEventListener("mouseup",C,!1),I.dispatchEvent(U))}}function E(e){if(I.enabled!==!1)switch(e.preventDefault(),z){case B.ROTATE:if(I.enableRotate===!1)return;p(e);break;case B.DOLLY:if(I.enableZoom===!1)return;m(e);break;case B.PAN:if(I.enablePan===!1)return;v(e)}}function C(e){I.enabled!==!1&&(document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",C,!1),I.dispatchEvent(k),z=B.NONE)}function L(e){I.enabled===!1||I.enableZoom===!1||z!==B.NONE&&z!==B.ROTATE||(e.preventDefault(),e.stopPropagation(),I.dispatchEvent(U),g(e),I.dispatchEvent(k))}function P(e){I.enabled!==!1&&I.enableKeys!==!1&&I.enablePan!==!1&&y(e)}function N(e){if(I.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:if(I.enablePan===!1)return;w(e),z=B.PAN;break;case 2:if(I.enableZoom===!1&&I.enableRotate===!1)return;x(e),b(e),z=B.DOLLY_ROTATE;break;default:z=B.NONE}z!==B.NONE&&I.dispatchEvent(U)}}function O(e){if(I.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(I.enablePan===!1)return;if(z!==B.PAN)return;M(e),I.update();break;case 2:if(I.enableZoom===!1&&I.enableRotate===!1)return;if(0===(z&B.DOLLY_ROTATE))return;_(e),A(e),I.update();break;default:z=B.NONE}}function D(e){I.enabled!==!1&&(I.dispatchEvent(k),z=B.NONE)}function F(e){I.enabled!==!1&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new i,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:zs.LEFT,MIDDLE:zs.MIDDLE,RIGHT:zs.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return V.phi},this.getAzimuthalAngle=function(){return V.theta},this.saveState=function(){I.target0.copy(I.target),I.position0.copy(I.object.position),I.zoom0=I.object.zoom},this.reset=function(){I.target.copy(I.target0),I.object.position.copy(I.position0),I.object.zoom=I.zoom0,I.object.updateProjectionMatrix(),I.dispatchEvent(R),I.update(),z=B.NONE},this.update=function(){var t=new i,a=(new n).setFromUnitVectors(e.up,new i(0,1,0)),s=a.clone().inverse(),l=new i,c=new n;return function(){var e=I.object.position;return t.copy(e).sub(I.target),t.applyQuaternion(a),V.setFromVector3(t),I.autoRotate&&z===B.NONE&&o(r()),V.theta+=G.theta,V.phi+=G.phi,V.theta=Math.max(I.minAzimuthAngle,Math.min(I.maxAzimuthAngle,V.theta)),V.phi=Math.max(I.minPolarAngle,Math.min(I.maxPolarAngle,V.phi)),V.makeSafe(),V.radius*=W,V.radius=Math.max(I.minDistance,Math.min(I.maxDistance,V.radius)),I.target.add(X),t.setFromSpherical(V),t.applyQuaternion(s),e.copy(I.target).add(t),I.object.lookAt(I.target),I.enableDamping===!0?(G.theta*=1-I.dampingFactor,G.phi*=1-I.dampingFactor,X.multiplyScalar(1-I.dampingFactor)):(G.set(0,0,0),X.set(0,0,0)),W=1,!!(H||l.distanceToSquared(I.object.position)>j||8*(1-c.dot(I.object.quaternion))>j)&&(I.dispatchEvent(R),l.copy(I.object.position),c.copy(I.object.quaternion),H=!1,!0)}}(),this.dispose=function(){I.domElement.removeEventListener("contextmenu",F,!1),I.domElement.removeEventListener("mousedown",T,!1),I.domElement.removeEventListener("wheel",L,!1),I.domElement.removeEventListener("touchstart",N,!1),I.domElement.removeEventListener("touchend",D,!1),I.domElement.removeEventListener("touchmove",O,!1),document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",C,!1),Ds.removeEventListener("keydown",P,!1)};var I=this,R={type:"change"},U={type:"start"},k={type:"end"},B={NONE:0,ROTATE_UP:1,ROTATE_LEFT:2,ROTATE:3,DOLLY:4,DOLLY_ROTATE:7,PAN:8,DOLLY_PAN:12},z=B.NONE,j=1e-6,V=new We,G=new We,W=1,X=new i,H=!1,Y=new f,q=new f,Q=new f,J=new f,Z=new f,K=new f,$=new f,ee=new f,te=new f,re=new f,ie=new f,ne=new f,ae=new f,oe=new f,se=function(){var e=new i;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),X.add(e)}}(),le=function(){var e=new i;return function(t,r){I.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(I.object.up,e)),e.multiplyScalar(t),X.add(e)}}(),ce=function(){var e=new i;return function(t,r){var i=I.domElement===document?I.domElement.body:I.domElement;if(I.object.isPerspectiveCamera){var n=I.object.position;e.copy(n).sub(I.target);var a=e.length();a*=Math.tan(I.object.fov/2*Math.PI/180),se(2*t*a/i.clientHeight,I.object.matrix),le(2*r*a/i.clientHeight,I.object.matrix)}else I.object.isOrthographicCamera?(se(t*(I.object.right-I.object.left)/I.object.zoom/i.clientWidth,I.object.matrix),le(r*(I.object.top-I.object.bottom)/I.object.zoom/i.clientHeight,I.object.matrix)):(console.warn("WARNING: MapControls.js encountered an unknown camera type - pan disabled."),I.enablePan=!1)}}(),ue=function(){var e=Math.sin(Math.PI/6);return function(t){return Math.abs(Math.sin(t.angle()))0?l(a()):K.y<0&&c(a()),J.copy(Z),O.update()}function v(e){q.set(e.clientX,e.clientY),Q.subVectors(q,Y).multiplyScalar(O.panSpeed),te(Q.x,Q.y),Y.copy(q),O.update()}function g(e){e.deltaY<0?c(a()):e.deltaY>0&&l(a()),O.update()}function y(e){switch(e.keyCode){case O.keys.UP:te(0,O.keyPanSpeed),O.update();break;case O.keys.BOTTOM:te(0,-O.keyPanSpeed),O.update();break;case O.keys.LEFT:te(O.keyPanSpeed,0),O.update();break;case O.keys.RIGHT:te(-O.keyPanSpeed,0),O.update()}}function x(e){W.set(e.touches[0].pageX,e.touches[0].pageY)}function b(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);J.set(0,i)}if(O.enablePan){var n=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);Y.set(n,a)}}function w(e){X.set(e.touches[0].pageX,e.touches[0].pageY),H.subVectors(X,W).multiplyScalar(O.rotateSpeed);var t=O.domElement===document?O.domElement.body:O.domElement;o(2*Math.PI*H.x/t.clientHeight),s(2*Math.PI*H.y/t.clientHeight),W.copy(X),O.update()}function _(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);Z.set(0,i),K.set(0,Math.pow(Z.y/J.y,O.zoomSpeed)),l(K.y),J.copy(Z)}if(O.enablePan){var n=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);q.set(n,a),Q.subVectors(q,Y).multiplyScalar(O.panSpeed),te(Q.x,Q.y),Y.copy(q)}O.update()}function S(e){if(O.enabled!==!1){switch(e.preventDefault(),e.button){case O.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey){if(O.enablePan===!1)return;d(e),U=R.PAN}else{if(O.enableRotate===!1)return;u(e),U=R.ROTATE}break;case O.mouseButtons.MIDDLE:if(O.enableZoom===!1)return;h(e),U=R.DOLLY;break;case O.mouseButtons.RIGHT:if(O.enablePan===!1)return;d(e),U=R.PAN}U!==R.NONE&&(document.addEventListener("mousemove",A,!1),document.addEventListener("mouseup",M,!1),O.dispatchEvent(F))}}function A(e){if(O.enabled!==!1)switch(e.preventDefault(),U){case R.ROTATE:if(O.enableRotate===!1)return;p(e);break;case R.DOLLY:if(O.enableZoom===!1)return;m(e);break;case R.PAN:if(O.enablePan===!1)return;v(e)}}function M(e){O.enabled!==!1&&(document.removeEventListener("mousemove",A,!1),document.removeEventListener("mouseup",M,!1),O.dispatchEvent(I),U=R.NONE)}function T(e){O.enabled===!1||O.enableZoom===!1||U!==R.NONE&&U!==R.ROTATE||(e.preventDefault(),e.stopPropagation(),O.dispatchEvent(F),g(e),O.dispatchEvent(I))}function E(e){O.enabled!==!1&&O.enableKeys!==!1&&O.enablePan!==!1&&y(e)}function C(e){if(O.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:if(O.enableRotate===!1)return;x(e),U=R.TOUCH_ROTATE;break;case 2:if(O.enableZoom===!1&&O.enablePan===!1)return;b(e),U=R.TOUCH_DOLLY_PAN;break;default:U=R.NONE}U!==R.NONE&&O.dispatchEvent(F)}}function L(e){if(O.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(O.enableRotate===!1)return;if(U!==R.TOUCH_ROTATE)return;w(e);break;case 2:if(O.enableZoom===!1&&O.enablePan===!1)return;if(U!==R.TOUCH_DOLLY_PAN)return;_(e);break;default:U=R.NONE}}function P(e){O.enabled!==!1&&(O.dispatchEvent(I),U=R.NONE)}function N(e){O.enabled!==!1&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new i,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:zs.LEFT,MIDDLE:zs.MIDDLE,RIGHT:zs.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return B.phi},this.getAzimuthalAngle=function(){return B.theta},this.saveState=function(){O.target0.copy(O.target),O.position0.copy(O.object.position),O.zoom0=O.object.zoom},this.reset=function(){O.target.copy(O.target0),O.object.position.copy(O.position0),O.object.zoom=O.zoom0,O.object.updateProjectionMatrix(),O.dispatchEvent(D),O.update(),U=R.NONE},this.update=function(){var t=new i,a=(new n).setFromUnitVectors(e.up,new i(0,1,0)),s=a.clone().inverse(),l=new i,c=new n;return function(){var e=O.object.position;return t.copy(e).sub(O.target),t.applyQuaternion(a),B.setFromVector3(t),O.autoRotate&&U===R.NONE&&o(r()),B.theta+=z.theta,B.phi+=z.phi,B.theta=Math.max(O.minAzimuthAngle,Math.min(O.maxAzimuthAngle,B.theta)),B.phi=Math.max(O.minPolarAngle,Math.min(O.maxPolarAngle,B.phi)),B.makeSafe(),B.radius*=j,B.radius=Math.max(O.minDistance,Math.min(O.maxDistance,B.radius)),O.target.add(V),t.setFromSpherical(B),t.applyQuaternion(s),e.copy(O.target).add(t),O.object.lookAt(O.target),O.enableDamping===!0?(z.theta*=1-O.dampingFactor,z.phi*=1-O.dampingFactor,V.multiplyScalar(1-O.dampingFactor)):(z.set(0,0,0),V.set(0,0,0)),j=1,!!(G||l.distanceToSquared(O.object.position)>k||8*(1-c.dot(O.object.quaternion))>k)&&(O.dispatchEvent(D),l.copy(O.object.position),c.copy(O.object.quaternion),G=!1,!0)}}(),this.dispose=function(){O.domElement.removeEventListener("contextmenu",N,!1),O.domElement.removeEventListener("mousedown",S,!1),O.domElement.removeEventListener("wheel",T,!1),O.domElement.removeEventListener("touchstart",C,!1),O.domElement.removeEventListener("touchend",P,!1),O.domElement.removeEventListener("touchmove",L,!1),document.removeEventListener("mousemove",A,!1),document.removeEventListener("mouseup",M,!1),Ds.removeEventListener("keydown",E,!1)};var O=this,D={type:"change"},F={type:"start"},I={type:"end"},R={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},U=R.NONE,k=1e-6,B=new We,z=new We,j=1,V=new i,G=!1,W=new f,X=new f,H=new f,Y=new f,q=new f,Q=new f,J=new f,Z=new f,K=new f,$=function(){var e=new i;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),V.add(e)}}(),ee=function(){var e=new i;return function(t,r){O.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(O.object.up,e)),e.multiplyScalar(t),V.add(e)}}(),te=function(){var e=new i;return function(t,r){var i=O.domElement===document?O.domElement.body:O.domElement;if(O.object.isPerspectiveCamera){var n=O.object.position;e.copy(n).sub(O.target);var a=e.length();a*=Math.tan(O.object.fov/2*Math.PI/180),$(2*t*a/i.clientHeight,O.object.matrix),ee(2*r*a/i.clientHeight,O.object.matrix)}else O.object.isOrthographicCamera?($(t*(O.object.right-O.object.left)/O.object.zoom/i.clientWidth,O.object.matrix),ee(r*(O.object.top-O.object.bottom)/O.object.zoom/i.clientHeight,O.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),O.enablePan=!1)}}();O.domElement.addEventListener("contextmenu",N,!1),O.domElement.addEventListener("mousedown",S,!1),O.domElement.addEventListener("wheel",T,!1),O.domElement.addEventListener("touchstart",C,!1),O.domElement.addEventListener("touchend",P,!1),O.domElement.addEventListener("touchmove",L,!1),Ds.addEventListener("keydown",E,!1),this.update()};Wu.prototype=Object.create(a.prototype),Wu.prototype.constructor=Wu,Object.defineProperties(Wu.prototype,{center:{get:function(){return console.warn("OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}}});var Xu=function(e,t){function r(e){m.enabled!==!1&&(Ds.removeEventListener("keydown",r),b=x,x===v.NONE&&(e.keyCode!==m.keys[v.ROTATE]||m.noRotate?e.keyCode!==m.keys[v.ZOOM]||m.noZoom?e.keyCode!==m.keys[v.PAN]||m.noPan||(x=v.PAN):x=v.ZOOM:x=v.ROTATE))}function a(e){m.enabled!==!1&&(x=b,Ds.addEventListener("keydown",r,!1))}function o(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x===v.NONE&&(x=e.button),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||(C.copy(D(e.pageX,e.pageY)),L.copy(C)):(A.copy(D(e.pageX,e.pageY)),M.copy(A)):(_.copy(F(e.pageX,e.pageY)),S.copy(_)),document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",l,!1),m.dispatchEvent(N))}function s(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||L.copy(D(e.pageX,e.pageY)):M.copy(D(e.pageX,e.pageY)):S.copy(F(e.pageX,e.pageY)))}function l(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x=v.NONE,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),m.dispatchEvent(O))}function c(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),A.y+=.01*e.deltaY,m.dispatchEvent(N),m.dispatchEvent(O))}function u(e){if(m.enabled!==!1){switch(e.touches.length){case 1:x=v.TOUCH_ROTATE,_.copy(F(e.touches[0].pageX,e.touches[0].pageY)),S.copy(_);break;case 2:x=v.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;E=T=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;C.copy(D(i,n)),L.copy(C);break;default:x=v.NONE}m.dispatchEvent(N)}}function h(e){if(m.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:S.copy(F(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;E=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;L.copy(D(i,n));break;default:x=v.NONE}}function d(e){if(m.enabled!==!1){switch(e.touches.length){case 1:S.copy(F(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S);break;case 2:T=E=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;L.copy(D(t,r)),C.copy(L)}x=v.NONE,m.dispatchEvent(O)}}function p(e){e.preventDefault()}var m=this,v={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.radius=0,this.rotateSpeed=1,this.zoomSpeed=1.2,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new i;var g=1e-6,y=!0,x=v.NONE,b=v.NONE,w=new i,_=new i,S=new i,A=new f,M=new f,T=0,E=0,C=new f,L=new f;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom;var P={type:"change"},N={type:"start"},O={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=Ds.innerWidth,this.screen.height=Ds.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+Ds.pageXOffset-t.clientLeft,this.screen.top=e.top+Ds.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.radius=.5*Math.min(this.screen.width,this.screen.height),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom};var D=function(){var e=new f;return function(t,r){return e.set((t-m.screen.left)/m.screen.width,(r-m.screen.top)/m.screen.height),e}}(),F=function(){var e=new i,t=new i,r=new i;return function(i,n){r.set((i-.5*m.screen.width-m.screen.left)/m.radius,(.5*m.screen.height+m.screen.top-n)/m.radius,0);var a=r.length();return m.noRoll?a1?r.normalize():r.z=Math.sqrt(1-a*a),w.copy(m.object.position).sub(m.target),e.copy(m.object.up).setLength(r.y),e.add(t.copy(m.object.up).cross(w).setLength(r.x)),e.add(w.setLength(r.z)),e}}();this.rotateCamera=function(){var e=new i,t=new n;return function(){var r=Math.acos(_.dot(S)/_.length()/S.length());r&&(e.crossVectors(_,S).normalize(),r*=m.rotateSpeed,t.setFromAxisAngle(e,-r),w.applyQuaternion(t),m.object.up.applyQuaternion(t),S.applyQuaternion(t),m.staticMoving?_.copy(S):(t.setFromAxisAngle(e,r*(m.dynamicDampingFactor-1)),_.applyQuaternion(t)),y=!0)}}(),this.zoomCamera=function(){if(x===v.TOUCH_ZOOM_PAN){var e=E/T;T=E,m.object.zoom*=e,y=!0}else{var e=1+(M.y-A.y)*m.zoomSpeed;Math.abs(e-1)>g&&e>0&&(m.object.zoom/=e,m.staticMoving?A.copy(M):A.y+=(M.y-A.y)*this.dynamicDampingFactor,y=!0)}},this.panCamera=function(){var e=new f,t=new i,r=new i;return function(){if(e.copy(L).sub(C),e.lengthSq()){var i=(m.object.right-m.object.left)/m.object.zoom,n=(m.object.top-m.object.bottom)/m.object.zoom;e.x*=i,e.y*=n,r.copy(w).cross(m.object.up).setLength(e.x),r.add(t.copy(m.object.up).setLength(e.y)),m.object.position.add(r),m.target.add(r),m.staticMoving?C.copy(L):C.add(e.subVectors(L,C).multiplyScalar(m.dynamicDampingFactor)),y=!0}}}(),this.update=function(){w.subVectors(m.object.position,m.target),m.noRotate||m.rotateCamera(),m.noZoom||(m.zoomCamera(),y&&m.object.updateProjectionMatrix()),m.noPan||m.panCamera(),m.object.position.addVectors(m.target,w),m.object.lookAt(m.target),y&&(m.dispatchEvent(P),y=!1)},this.reset=function(){x=v.NONE,b=v.NONE,m.target.copy(m.target0),m.object.position.copy(m.position0),m.object.up.copy(m.up0),w.subVectors(m.object.position,m.target),m.object.left=m.left0,m.object.right=m.right0,m.object.top=m.top0,m.object.bottom=m.bottom0,m.object.lookAt(m.target),m.dispatchEvent(P),y=!1},this.dispose=function(){this.domElement.removeEventListener("contextmenu",p,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("wheel",c,!1),this.domElement.removeEventListener("touchstart",u,!1),this.domElement.removeEventListener("touchend",d,!1),this.domElement.removeEventListener("touchmove",h,!1),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",r,!1),Ds.removeEventListener("keyup",a,!1)},this.domElement.addEventListener("contextmenu",p,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("wheel",c,!1),this.domElement.addEventListener("touchstart",u,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",h,!1),Ds.addEventListener("keydown",r,!1),Ds.addEventListener("keyup",a,!1),this.handleResize(), -this.update()};Xu.prototype=Object.create(a.prototype),Xu.prototype.constructor=Xu;var Hu=function(e){var t=this;e.rotation.set(0,0,0);var r=new c;r.add(e);var n=new c;n.position.y=10,n.add(r);var a=Math.PI/2,s=function(e){if(t.enabled!==!1){var i=e.movementX||e.mozMovementX||e.webkitMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||0;n.rotation.y-=.002*i,r.rotation.x-=.002*o,r.rotation.x=Math.max(-a,Math.min(a,r.rotation.x))}};this.dispose=function(){document.removeEventListener("mousemove",s,!1)},document.addEventListener("mousemove",s,!1),this.enabled=!1,this.getObject=function(){return n},this.getDirection=function(){var e=new i(0,0,(-1)),t=new o(0,0,0,"YXZ");return function(i){return t.set(r.rotation.x,n.rotation.y,0),i.copy(e).applyEuler(t),i}}()},Yu=function(e,t){function r(e){m.enabled!==!1&&(Ds.removeEventListener("keydown",r),b=x,x===v.NONE&&(e.keyCode!==m.keys[v.ROTATE]||m.noRotate?e.keyCode!==m.keys[v.ZOOM]||m.noZoom?e.keyCode!==m.keys[v.PAN]||m.noPan||(x=v.PAN):x=v.ZOOM:x=v.ROTATE))}function a(e){m.enabled!==!1&&(x=b,Ds.addEventListener("keydown",r,!1))}function o(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x===v.NONE&&(x=e.button),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||(P.copy(I(e.pageX,e.pageY)),N.copy(P)):(T.copy(I(e.pageX,e.pageY)),E.copy(T)):(S.copy(R(e.pageX,e.pageY)),_.copy(S)),document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",l,!1),m.dispatchEvent(D))}function s(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||N.copy(I(e.pageX,e.pageY)):E.copy(I(e.pageX,e.pageY)):(_.copy(S),S.copy(R(e.pageX,e.pageY))))}function l(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x=v.NONE,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),m.dispatchEvent(F))}function c(e){if(m.enabled!==!1&&m.noZoom!==!0){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:T.y-=.025*e.deltaY;break;case 1:T.y-=.01*e.deltaY;break;default:T.y-=25e-5*e.deltaY}m.dispatchEvent(D),m.dispatchEvent(F)}}function u(e){if(m.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:x=v.TOUCH_ROTATE,S.copy(R(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S);break;default:x=v.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;L=C=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;P.copy(I(i,n)),N.copy(P)}m.dispatchEvent(D)}}function h(e){if(m.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:_.copy(S),S.copy(R(e.touches[0].pageX,e.touches[0].pageY));break;default:var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;L=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;N.copy(I(i,n))}}function d(e){if(m.enabled!==!1){switch(e.touches.length){case 0:x=v.NONE;break;case 1:x=v.TOUCH_ROTATE,S.copy(R(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S)}m.dispatchEvent(F)}}function p(e){m.enabled!==!1&&e.preventDefault()}var m=this,v={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new i;var g=1e-6,y=new i,x=v.NONE,b=v.NONE,w=new i,_=new f,S=new f,A=new i,M=0,T=new f,E=new f,C=0,L=0,P=new f,N=new f;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var O={type:"change"},D={type:"start"},F={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=Ds.innerWidth,this.screen.height=Ds.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+Ds.pageXOffset-t.clientLeft,this.screen.top=e.top+Ds.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}};var I=function(){var e=new f;return function(t,r){return e.set((t-m.screen.left)/m.screen.width,(r-m.screen.top)/m.screen.height),e}}(),R=function(){var e=new f;return function(t,r){return e.set((t-.5*m.screen.width-m.screen.left)/(.5*m.screen.width),(m.screen.height+2*(m.screen.top-r))/m.screen.width),e}}();this.rotateCamera=function(){var e,t=new i,r=new n,a=new i,o=new i,s=new i,l=new i;return function(){l.set(S.x-_.x,S.y-_.y,0),e=l.length(),e?(w.copy(m.object.position).sub(m.target),a.copy(w).normalize(),o.copy(m.object.up).normalize(),s.crossVectors(o,a).normalize(),o.setLength(S.y-_.y),s.setLength(S.x-_.x),l.copy(o.add(s)),t.crossVectors(l,w).normalize(),e*=m.rotateSpeed,r.setFromAxisAngle(t,e),w.applyQuaternion(r),m.object.up.applyQuaternion(r),A.copy(t),M=e):!m.staticMoving&&M&&(M*=Math.sqrt(1-m.dynamicDampingFactor),w.copy(m.object.position).sub(m.target),r.setFromAxisAngle(A,M),w.applyQuaternion(r),m.object.up.applyQuaternion(r)),_.copy(S)}}(),this.zoomCamera=function(){var e;x===v.TOUCH_ZOOM_PAN?(e=C/L,C=L,w.multiplyScalar(e)):(e=1+(E.y-T.y)*m.zoomSpeed,1!==e&&e>0&&w.multiplyScalar(e),m.staticMoving?T.copy(E):T.y+=(E.y-T.y)*this.dynamicDampingFactor)},this.panCamera=function(){var e=new f,t=new i,r=new i;return function(){e.copy(N).sub(P),e.lengthSq()&&(e.multiplyScalar(w.length()*m.panSpeed),r.copy(w).cross(m.object.up).setLength(e.x),r.add(t.copy(m.object.up).setLength(e.y)),m.object.position.add(r),m.target.add(r),m.staticMoving?P.copy(N):P.add(e.subVectors(N,P).multiplyScalar(m.dynamicDampingFactor)))}}(),this.checkDistances=function(){m.noZoom&&m.noPan||(w.lengthSq()>m.maxDistance*m.maxDistance&&(m.object.position.addVectors(m.target,w.setLength(m.maxDistance)),T.copy(E)),w.lengthSq()g&&(m.dispatchEvent(O),y.copy(m.object.position))},this.reset=function(){x=v.NONE,b=v.NONE,m.target.copy(m.target0),m.object.position.copy(m.position0),m.object.up.copy(m.up0),w.subVectors(m.object.position,m.target),m.object.lookAt(m.target),m.dispatchEvent(O),y.copy(m.object.position)},this.dispose=function(){this.domElement.removeEventListener("contextmenu",p,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("wheel",c,!1),this.domElement.removeEventListener("touchstart",u,!1),this.domElement.removeEventListener("touchend",d,!1),this.domElement.removeEventListener("touchmove",h,!1),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",r,!1),Ds.removeEventListener("keyup",a,!1)},this.domElement.addEventListener("contextmenu",p,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("wheel",c,!1),this.domElement.addEventListener("touchstart",u,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",h,!1),Ds.addEventListener("keydown",r,!1),Ds.addEventListener("keyup",a,!1),this.handleResize(),this.update()};Yu.prototype=Object.create(a.prototype),Yu.prototype.constructor=Yu,Xe.prototype=Object.create(m.prototype),Xe.prototype.constructor=Xe,He.prototype=Object.create(P.prototype),He.prototype.constructor=He,Ye.prototype=Object.create(m.prototype),Ye.prototype.constructor=Ye,qe.prototype=Object.create(He.prototype),qe.prototype.constructor=qe,Qe.prototype=Object.create(m.prototype),Qe.prototype.constructor=Qe,Je.prototype=Object.create(P.prototype),Je.prototype.constructor=Je;var qu=function(e,t){function r(e,t){var r=t;Object.defineProperty(f,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,p[e]=t,d[e]=t,f.dispatchEvent({type:e+"-changed",value:t}),f.dispatchEvent(m))}}),f[e]=t,p[e]=t,d[e]=t}function a(e){var r=e.changedTouches?e.changedTouches[0]:e,i=t.getBoundingClientRect();return{x:(r.clientX-i.left)/i.width*2-1,y:-(r.clientY-i.top)/i.height*2+1,button:e.button}}function o(e){e.preventDefault()}function s(e){f.enabled&&f.pointerHover(a(e))}function l(e){f.enabled&&(e.preventDefault(),f.pointerHover(a(e)),f.pointerDown(a(e)))}function u(e){f.enabled&&(e.preventDefault(),f.pointerMove(a(e)))}function h(e){f.enabled&&(e.preventDefault(),f.pointerUp(a(e)))}c.call(this),t=void 0!==t?t:document,this.visible=!1;var d=new Qu;this.add(d);var p=new Ju;this.add(p);var f=this;r("camera",e),r("object",void 0),r("enabled",!0),r("axis",null),r("mode","translate"),r("translationSnap",null),r("rotationSnap",null),r("space","world"),r("size",1),r("dragging",!1),r("showX",!0),r("showY",!0),r("showZ",!0);var m={type:"change"},v={type:"mouseDown"},g={type:"mouseUp",mode:f.mode},y={type:"objectChange"},x=new je,b=new i,w=new i,_=new n,S={X:new i(1,0,0),Y:new i(0,1,0),Z:new i(0,0,1)},A=new n,M=new i,T=new i,E=new i,C=new i,L=0,P=new i,N=new n,O=new i,D=new i,F=new n,I=new i,R=new i,U=new n,k=new i,B=new i,z=new n,j=new i,V=new i,G=new i,W=new n,X=new i;r("parentQuaternion",F),r("worldPosition",B),r("worldPositionStart",R),r("worldQuaternion",z),r("worldQuaternionStart",U),r("cameraPosition",P),r("cameraQuaternion",N),r("pointStart",T),r("pointEnd",E),r("rotationAxis",C),r("rotationAngle",L),r("eye",V),t.addEventListener("mousedown",l,!1),t.addEventListener("touchstart",l,!1),t.addEventListener("mousemove",s,!1),t.addEventListener("touchmove",s,!1),document.addEventListener("mousemove",u,!1),t.addEventListener("touchmove",u,!1),document.addEventListener("mouseup",h,!1),t.addEventListener("touchend",h,!1),t.addEventListener("touchcancel",h,!1),t.addEventListener("touchleave",h,!1),t.addEventListener("contextmenu",o,!1),this.dispose=function(){t.removeEventListener("mousedown",l),t.removeEventListener("touchstart",l),t.removeEventListener("mousemove",s),t.removeEventListener("touchmove",s),document.removeEventListener("mousemove",u),t.removeEventListener("touchmove",u),document.removeEventListener("mouseup",h),t.removeEventListener("touchend",h),t.removeEventListener("touchcancel",h),t.removeEventListener("touchleave",h),t.removeEventListener("contextmenu",o)},this.attach=function(e){this.object=e,this.visible=!0},this.detach=function(){this.object=void 0,this.visible=!1,this.axis=null},this.updateMatrixWorld=function(){void 0!==this.object&&(this.object.updateMatrixWorld(),this.object.parent.matrixWorld.decompose(D,F,I),this.object.matrixWorld.decompose(B,z,j)),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(P,N,O),this.camera instanceof de?V.copy(P).sub(B).normalize():this.camera instanceof me&&V.copy(P).normalize(),c.prototype.updateMatrixWorld.call(this)},this.pointerHover=function(e){if(void 0!==this.object&&this.dragging!==!0&&(void 0===e.button||0===e.button)){x.setFromCamera(e,this.camera);var t=x.intersectObjects(d.picker[this.mode].children,!0)[0]||!1;t?this.axis=t.object.name:this.axis=null}},this.pointerDown=function(e){if(!(void 0===this.object||this.dragging===!0||void 0!==e.button&&0!==e.button||0!==e.button&&void 0!==e.button||null===this.axis)){x.setFromCamera(e,this.camera);var t=x.intersectObjects([p],!0)[0]||!1;if(t){var r=this.space;if("scale"===this.mode?r="local":"E"!==this.axis&&"XYZE"!==this.axis&&"XYZ"!==this.axis||(r="world"),"local"===r&&"rotate"===this.mode){var i=this.rotationSnap;"X"===this.axis&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),"Y"===this.axis&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),"Z"===this.axis&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),G.copy(this.object.position),W.copy(this.object.quaternion),X.copy(this.object.scale),this.object.matrixWorld.decompose(R,U,k),T.copy(t.point).sub(R),"local"===r&&T.applyQuaternion(U.clone().inverse())}this.dragging=!0,v.mode=this.mode,this.dispatchEvent(v)}},this.pointerMove=function(e){var t=this.axis,r=this.mode,i=this.object,n=this.space;if("scale"===r?n="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(n="world"),void 0!==i&&null!==t&&this.dragging!==!1&&(void 0===e.button||0===e.button)){x.setFromCamera(e,this.camera);var a=x.intersectObjects([p],!0)[0]||!1;if(a!==!1){if(E.copy(a.point).sub(R),"local"===n&&E.applyQuaternion(U.clone().inverse()),"translate"===r)t.search("X")===-1&&(E.x=T.x),t.search("Y")===-1&&(E.y=T.y),t.search("Z")===-1&&(E.z=T.z),"local"===n?i.position.copy(E).sub(T).applyQuaternion(W):i.position.copy(E).sub(T),i.position.add(G),this.translationSnap&&("local"===n&&(i.position.applyQuaternion(_.copy(W).inverse()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(W)),"world"===n&&(i.parent&&i.position.add(b.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(b.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===r){if(t.search("XYZ")!==-1){var o=E.length()/T.length();E.dot(T)<0&&(o*=-1),b.set(o,o,o)}else b.copy(E).divide(T),t.search("X")===-1&&(b.x=1),t.search("Y")===-1&&(b.y=1),t.search("Z")===-1&&(b.z=1);i.scale.copy(X).multiply(b)}else if("rotate"===r){var s=20/B.distanceTo(b.setFromMatrixPosition(this.camera.matrixWorld)),l="local"===this.space?z:A,c=S[t];"E"===t?(b.copy(E).cross(T),C.copy(V),L=E.angleTo(T)*(b.dot(V)<0?1:-1)):"XYZE"===t?(b.copy(E).sub(T).cross(V).normalize(),C.copy(b),L=E.sub(T).dot(b.cross(V))*s):"X"!==t&&"Y"!==t&&"Z"!==t||(M.copy(c).applyQuaternion(l),C.copy(c),b=c.clone(),w=E.clone().sub(T),"local"===n&&(b.applyQuaternion(l),w.applyQuaternion(U)),L=w.dot(b.cross(V).normalize())*s),this.rotationSnap&&(L=Math.round(L/this.rotationSnap)*this.rotationSnap),this.rotationAngle=L,"local"===n?(i.quaternion.copy(W),i.quaternion.multiply(_.setFromAxisAngle(C,L))):(i.quaternion.copy(_.setFromAxisAngle(C,L)),i.quaternion.multiply(W))}this.dispatchEvent(m),this.dispatchEvent(y)}}},this.pointerUp=function(e){void 0!==e.button&&0!==e.button||(this.dragging&&null!==this.axis&&(g.mode=this.mode,this.dispatchEvent(g)),this.dragging=!1,void 0===e.button&&(this.axis=null))},this.getMode=function(){return f.mode},this.setMode=function(e){f.mode=e},this.setTranslationSnap=function(e){f.translationSnap=e},this.setRotationSnap=function(e){f.rotationSnap=e},this.setSize=function(e){f.size=e},this.setSpace=function(e){f.space=e},this.update=function(){console.warn("TransformControls: update function has been depricated.")}};qu.prototype=Object.assign(Object.create(c.prototype),{constructor:qu,isTransformControls:!0});var Qu=function(){c.call(this),this.type="TransformControlsGizmo";var e=new F({depthTest:!1,depthWrite:!1,transparent:!0,side:Ks,fog:!1}),t=new I({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1}),a=e.clone();a.opacity=.15;var s=e.clone();s.opacity=.33;var l=e.clone();l.color.set(16711680);var h=e.clone();h.color.set(65280);var d=e.clone();d.color.set(255);var p=e.clone();p.opacity=.25;var f=p.clone();f.color.set(16776960);var m=p.clone();m.color.set(65535);var v=p.clone();v.color.set(16711935);var g=e.clone();g.color.set(16776960);var y=t.clone();y.color.set(16711680);var x=t.clone();x.color.set(65280);var b=t.clone();b.color.set(255);var w=t.clone();w.color.set(65535);var _=t.clone();_.color.set(16711935);var S=t.clone();S.color.set(16776960);var A=t.clone();A.color.set(7895160);var T=S.clone();T.opacity=.25;var E=new ue(0,.05,.2,12,1,(!1)),C=new le(.125,.125,.125),L=new P;L.addAttribute("position",new M([0,0,0,1,0,0],3));var N=function(e,t){for(var r=new P,i=[],n=0;n<=64*t;++n)i.push(0,Math.cos(n/32*Math.PI)*e,Math.sin(n/32*Math.PI)*e);return r.addAttribute("position",new M(i,3)),r},D=function(e,t){var r=new P;return r.addAttribute("position",new M([0,0,0,1,1,1],3)),r},R={X:[[new k(E,l),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new k(E,l),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new B(L,y)]],Y:[[new k(E,h),[0,1,0],null,null,"fwd"],[new k(E,h),[0,1,0],[Math.PI,0,0],null,"bwd"],[new B(L,x),null,[0,0,Math.PI/2]]],Z:[[new k(E,d),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new k(E,d),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new B(L,b),null,[0,-Math.PI/2,0]]],XYZ:[[new k(new qe(.1,0),p),[0,0,0],[0,0,0]]],XY:[[new k(new xe(.295,.295),f),[.15,.15,0]],[new B(L,S),[.18,.3,0],null,[.125,1,1]],[new B(L,S),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new k(new xe(.295,.295),m),[0,.15,.15],[0,Math.PI/2,0]],[new B(L,w),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new B(L,w),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new k(new xe(.295,.295),v),[.15,0,.15],[-Math.PI/2,0,0]],[new B(L,_),[.18,0,.3],null,[.125,1,1]],[new B(L,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},U={X:[[new k(new ue(.2,0,1,4,1,(!1)),a),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new k(new ue(.2,0,1,4,1,(!1)),a),[0,.6,0]]],Z:[[new k(new ue(.2,0,1,4,1,(!1)),a),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new k(new qe(.2,0),a)]],XY:[[new k(new xe(.4,.4),a),[.2,.2,0]]],YZ:[[new k(new xe(.4,.4),a),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new k(new xe(.4,.4),a),[.2,0,.2],[-Math.PI/2,0,0]]]},z={START:[[new k(new qe(.01,2),s),null,null,null,"helper"]],END:[[new k(new qe(.01,2),s),null,null,null,"helper"]],DELTA:[[new B(D(),s),null,null,null,"helper"]],X:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new B(L,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new B(L,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},j={X:[[new B(N(1,.5),y)],[new k(new qe(.04,0),l),[0,0,.99],null,[1,3,1]]],Y:[[new B(N(1,.5),x),null,[0,0,-Math.PI/2]],[new k(new qe(.04,0),h),[0,0,.99],null,[3,1,1]]],Z:[[new B(N(1,.5),b),null,[0,Math.PI/2,0]],[new k(new qe(.04,0),d),[.99,0,0],null,[1,3,1]]],E:[[new B(N(1.25,1),T),null,[0,Math.PI/2,0]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new B(N(1,1),A),null,[0,Math.PI/2,0]]]},V={AXIS:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={X:[[new k(new Je(1,.1,4,24),a),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new k(new Je(1,.1,4,24),a),[0,0,0],[Math.PI/2,0,0]]],Z:[[new k(new Je(1,.1,4,24),a),[0,0,0],[0,0,-Math.PI/2]]],E:[[new k(new Je(1.25,.1,2,24),a)]],XYZE:[[new k(new O(.7,10,8),a)]]},W={X:[[new k(C,l),[.8,0,0],[0,0,-Math.PI/2]],[new B(L,y),null,null,[.8,1,1]]],Y:[[new k(C,h),[0,.8,0]],[new B(L,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new k(C,d),[0,0,.8],[Math.PI/2,0,0]],[new B(L,b),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new k(C,f),[.85,.85,0],null,[2,2,.2]],[new B(L,S),[.855,.98,0],null,[.125,1,1]],[new B(L,S),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new k(C,m),[0,.85,.85],null,[.2,2,2]],[new B(L,w),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new B(L,w),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new k(C,v),[.85,0,.85],null,[2,.2,2]],[new B(L,_),[.855,0,.98],null,[.125,1,1]],[new B(L,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new k(new le(.125,.125,.125),p),[1.1,0,0]]],XYZY:[[new k(new le(.125,.125,.125),p),[0,1.1,0]]],XYZZ:[[new k(new le(.125,.125,.125),p),[0,0,1.1]]]},X={X:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[0,.5,0]]],Z:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new k(C,a),[.85,.85,0],null,[3,3,.2]]],YZ:[[new k(C,a),[0,.85,.85],null,[.2,3,3]]],XZ:[[new k(C,a),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new k(new le(.2,.2,.2),a),[1.1,0,0]]],XYZY:[[new k(new le(.2,.2,.2),a),[0,1.1,0]]],XYZZ:[[new k(new le(.2,.2,.2),a),[0,0,1.1]]]},H={X:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new B(L,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new B(L,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},Y=function(e){var t=new c;for(var r in e)for(var i=e[r].length;i--;){var n=e[r][i][0].clone(),a=e[r][i][1],o=e[r][i][2],s=e[r][i][3],l=e[r][i][4];n.name=r,n.tag=l,a&&n.position.set(a[0],a[1],a[2]),o&&n.rotation.set(o[0],o[1],o[2]),s&&n.scale.set(s[0],s[1],s[2]),n.updateMatrix();var u=n.geometry.clone();u.applyMatrix(n.matrix),n.geometry=u,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),t.add(n)}return t},q=new i(0,0,0),Q=new o,J=new i(0,1,0),Z=new i(0,0,0),K=new r,$=new n,ee=new n,te=new n,re=new i(1,0,0),ie=new i(0,1,0),ne=new i(0,0,1);this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Y(R)),this.add(this.gizmo.rotate=Y(j)),this.add(this.gizmo.scale=Y(W)),this.add(this.picker.translate=Y(U)),this.add(this.picker.rotate=Y(G)),this.add(this.picker.scale=Y(X)),this.add(this.helper.translate=Y(z)),this.add(this.helper.rotate=Y(V)),this.add(this.helper.scale=Y(H)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1,this.updateMatrixWorld=function(){var e=this,t=this.space;"scale"===this.mode&&(t="local");var r="local"===t?this.worldQuaternion:te;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;var i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(var n=0;ns&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"Y"!==a.name&&"XYZY"!==a.name||Math.abs(J.copy(ie).applyQuaternion(r).dot(e.eye))>s&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"Z"!==a.name&&"XYZZ"!==a.name||Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye))>s&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"XY"===a.name&&Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye)).9&&(a.visible=!1)),"Y"===e.axis&&($.setFromEuler(Q.set(0,0,Math.PI/2)),a.quaternion.copy(r).multiply($),Math.abs(J.copy(ie).applyQuaternion(r).dot(e.eye))>.9&&(a.visible=!1)),"Z"===e.axis&&($.setFromEuler(Q.set(0,Math.PI/2,0)),a.quaternion.copy(r).multiply($),Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye))>.9&&(a.visible=!1)),"XYZE"===e.axis&&($.setFromEuler(Q.set(0,Math.PI/2,0)),J.copy(e.rotationAxis),a.quaternion.setFromRotationMatrix(K.lookAt(Z,J,ie)),a.quaternion.multiply($),a.visible=e.dragging),"E"===e.axis&&(a.visible=!1)):"START"===a.name?(a.position.copy(e.worldPositionStart),a.visible=e.dragging):"END"===a.name?(a.position.copy(e.worldPosition),a.visible=e.dragging):"DELTA"===a.name?(a.position.copy(e.worldPositionStart),a.quaternion.copy(e.worldQuaternionStart),q.set(1e-10,1e-10,1e-10).add(e.worldPositionStart).sub(e.worldPosition).multiplyScalar(-1),q.applyQuaternion(e.worldQuaternionStart.clone().inverse()),a.scale.copy(q),a.visible=e.dragging):(a.quaternion.copy(r),e.dragging?a.position.copy(e.worldPositionStart):a.position.copy(e.worldPosition),e.axis&&(a.visible=e.axis.search(a.name)!==-1))}c.prototype.updateMatrixWorld.call(this)}};Qu.prototype=Object.assign(Object.create(c.prototype),{constructor:Qu,isTransformControlsGizmo:!0});var Ju=function(){k.call(this,new xe(1e5,1e5,2,2),new F({visible:!1,wireframe:!0,side:Ks,transparent:!0,opacity:.1})),this.type="TransformControlsPlane";var e=new i(1,0,0),t=new i(0,1,0),a=new i(0,0,1),o=new i,s=new i,l=new i,u=new r,h=new n;this.updateMatrixWorld=function(){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),e.set(1,0,0).applyQuaternion("local"===r?this.worldQuaternion:h),t.set(0,1,0).applyQuaternion("local"===r?this.worldQuaternion:h),a.set(0,0,1).applyQuaternion("local"===r?this.worldQuaternion:h),l.copy(t),this.mode){case"translate":case"scale":switch(this.axis){case"X":l.copy(this.eye).cross(e),s.copy(e).cross(l);break;case"Y":l.copy(this.eye).cross(t),s.copy(t).cross(l);break;case"Z":l.copy(this.eye).cross(a),s.copy(a).cross(l);break;case"XY":s.copy(a);break;case"YZ":s.copy(e);break;case"XZ":l.copy(a),s.copy(t);break;case"XYZ":case"E":s.set(0,0,0)}break;case"rotate":default:s.set(0,0,0)}0===s.length()?this.quaternion.copy(this.cameraQuaternion):(u.lookAt(o.set(0,0,0),s,l),this.quaternion.setFromRotationMatrix(u)),c.prototype.updateMatrixWorld.call(this)}};Ju.prototype=Object.assign(Object.create(k.prototype),{constructor:Ju,isTransformControlsPlane:!0}),Object.assign(Ze.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("Line3: .getCenter() target is now required"),e=new i),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("Line3: .delta() target is now required"),e=new i),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("Line3: .at() target is now required"),t=new i),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new i,t=new i;return function(r,i){e.subVectors(r,this.start),t.subVectors(this.end,this.start);var n=t.dot(t),a=t.dot(e),o=a/n;return i&&(o=Fs.clamp(o,0,1)),o}}(),closestPointToPoint:function(e,t,r){var n=this.closestPointToPointParameter(e,t);return void 0===r&&(console.warn("Line3: .closestPointToPoint() target is now required"),r=new i),this.delta(r).multiplyScalar(n).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}});var Zu=0,Ku=1;Object.assign(Ke.prototype,{setFromPoints:function(e){var t=this;Array.isArray(e)!==!0&&console.error("QuickHull: Points parameter is not an array."),e.length<4&&console.error("QuickHull: The algorithm needs at least four points."),this.makeEmpty();for(var r=0,i=e.length;rr.tolerance?r.addVertexToFace(n,t):r.unassigned.append(n),n=a}while(null!==n)}return this},resolveUnassignedPoints:function(e){var t=this;if(this.unassigned.isEmpty()===!1){var r=this.unassigned.first();do{for(var i=r.next,n=t.tolerance,a=null,o=0;on&&(n=l,a=s),n>1e3*t.tolerance)break}}null!==a&&t.addVertexToFace(r,a),r=i}while(null!==r)}return this},computeExtremes:function(){var e,t,r,n=this,a=new i,o=new i,s=[],l=[];for(e=0;e<3;e++)s[e]=l[e]=n.vertices[0];for(a.copy(this.vertices[0].point),o.copy(this.vertices[0].point),e=0,t=this.vertices.length;eo.getComponent(r)&&(o.setComponent(r,u.getComponent(r)),l[r]=c)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(a.x),Math.abs(o.x))+Math.max(Math.abs(a.y),Math.abs(o.y))+Math.max(Math.abs(a.z),Math.abs(o.z))),{min:s,max:l}},computeInitialHull:function(){var e,t,r;return function(){var n=this;void 0===e&&(e=new Ze,t=new ze,r=new i);var a,o,s,l,c,u,h,d,p,f=this.vertices,m=this.computeExtremes(),v=m.min,g=m.max,y=0,x=0; -for(u=0;u<3;u++)p=g[u].point.getComponent(u)-v[u].point.getComponent(u),p>y&&(y=p,x=u);for(o=v[x],s=g[x],y=0,e.set(o.point,s.point),u=0,h=this.vertices.length;uy&&(y=p,l=a));for(y=-1,t.setFromCoplanarPoints(o.point,s.point,l.point),u=0,h=this.vertices.length;uy&&(y=p,c=a));var b=[];if(t.distanceToPoint(c.point)<0)for(b.push($e.create(o,s,l),$e.create(c,s,o),$e.create(c,l,s),$e.create(c,o,l)),u=0;u<3;u++)d=(u+1)%3,b[u+1].getEdge(2).setTwin(b[0].getEdge(d)),b[u+1].getEdge(1).setTwin(b[d+1].getEdge(0));else for(b.push($e.create(o,l,s),$e.create(c,o,s),$e.create(c,s,l),$e.create(c,l,o)),u=0;u<3;u++)d=(u+1)%3,b[u+1].getEdge(2).setTwin(b[0].getEdge((3-u)%3)),b[u+1].getEdge(0).setTwin(b[d+1].getEdge(1));for(u=0;u<4;u++)n.faces.push(b[u]);for(u=0,h=f.length;uy&&(y=p,w=n.faces[d]);null!==w&&n.addVertexToFace(a,w)}return this}}(),reindexFaces:function(){for(var e=this,t=[],r=0;rt&&(t=n,e=i),i=i.next}while(null!==i&&i.face===r);return e}},computeHorizon:function(e,t,r,i){var n=this;this.deleteFaceVertices(r),r.mark=Ku;var a;a=null===t?t=r.getEdge(0):t.next;do{var o=a.twin,s=o.face;s.mark===Zu&&(s.distanceToPoint(e)>n.tolerance?n.computeHorizon(e,o,s,i):i.push(a)),a=a.next}while(a!==t);return this},addAdjoiningFace:function(e,t){var r=$e.create(e,t.tail(),t.head());return this.faces.push(r),r.getEdge(-1).setTwin(t.twin),r.getEdge(0)},addNewFaces:function(e,t){var r=this;this.newFaces=[];for(var i=null,n=null,a=0;a0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t},compute:function(){var e;return function(){void 0===e&&(e=new U);var t=this.edge.tail(),r=this.edge.head(),i=this.edge.next.head();return e.set(t.point,r.point,i.point),e.getNormal(this.normal),e.getMidpoint(this.midpoint),this.area=e.getArea(),this.constant=this.normal.dot(this.midpoint),this}}(),distanceToPoint:function(e){return this.normal.dot(e)-this.constant}}),Object.assign(et.prototype,{head:function(){return this.vertex},tail:function(){return this.prev?this.prev.vertex:null},length:function(){var e=this.head(),t=this.tail();return null!==t?t.point.distanceTo(e.point):-1},lengthSquared:function(){var e=this.head(),t=this.tail();return null!==t?t.point.distanceToSquared(e.point):-1},setTwin:function(e){return this.twin=e,e.twin=this,this}}),Object.assign(rt.prototype,{first:function(){return this.head},last:function(){return this.tail},clear:function(){return this.head=this.tail=null,this},insertBefore:function(e,t){return t.prev=e.prev,t.next=e,null===t.prev?this.head=t:t.prev.next=t,e.prev=t,this},insertAfter:function(e,t){return t.prev=e,t.next=e.next,null===t.next?this.tail=t:t.next.prev=t,e.next=t,this},append:function(e){return null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this},appendChain:function(e){for(null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail;null!==e.next;)e=e.next;return this.tail=e,this},remove:function(e){return null===e.prev?this.head=e.next:e.prev.next=e.next,null===e.next?this.tail=e.prev:e.next.prev=e.prev,this},removeSubList:function(e,t){return null===e.prev?this.head=t.next:e.prev.next=t.next,null===t.next?this.tail=e.prev:t.next.prev=e.prev,this},isEmpty:function(){return null===this.head}}),it.prototype=Object.create(m.prototype),it.prototype.constructor=it,nt.prototype=Object.create(P.prototype),nt.prototype.constructor=nt;var $u=function(e,t){var r=this;this.minSizeForBreak=e||1.4,this.smallDelta=t||1e-4,this.tempLine1=new Ze,this.tempPlane1=new ze,this.tempPlane2=new ze,this.tempPlane_Cut=new ze,this.tempCM1=new i,this.tempCM2=new i,this.tempVector3=new i,this.tempVector3_2=new i,this.tempVector3_3=new i,this.tempVector3_P0=new i,this.tempVector3_P1=new i,this.tempVector3_P2=new i,this.tempVector3_N0=new i,this.tempVector3_N1=new i,this.tempVector3_AB=new i,this.tempVector3_CB=new i,this.tempResultObjects={object1:null,object2:null},this.segments=[];for(var n=900,a=0;ac)return void o.push(n);var f=Math.PI;0===p?(l.normal.copy(s.normal),l.constant=s.constant):p<=i?(f=(d-h)*(.2+.6*Math.random())+h,u.tempVector3_2.copy(e.position).sub(t).applyAxisAngle(r,f).add(t),l.setFromCoplanarPoints(t,u.tempVector3,u.tempVector3_2)):(f=(.5*(1&p)+.2*(2-Math.random()))*Math.PI,u.tempVector3_2.copy(t).sub(n.position).applyAxisAngle(r,f).add(n.position),u.tempVector3_3.copy(r).add(n.position),l.setFromCoplanarPoints(n.position,u.tempVector3_3,u.tempVector3_2)),u.cutByPlane(n,l,u.tempResultObjects);var m=u.tempResultObjects.object1,v=u.tempResultObjects.object2;m&&a(m,h,f,p+1),v&&a(v,f,d,p+1)}var o=[],s=this.tempPlane1,l=this.tempPlane2;this.tempVector3.addVectors(t,r),s.setFromCoplanarPoints(t,e.position,this.tempVector3);var c=n+i,u=this;return a(e,0,2*Math.PI,0),o},cutByPlane:function(e,t,r){function n(e,t){var r=3*e+t;return h?h[r]:r}var a=this,o=e.geometry,s=o.attributes.position.array,l=o.attributes.normal.array,c=s.length/3,u=c/3,h=o.getIndex();h&&(h=h.array,u=h.length/3);for(var d=[],p=[],f=this.smallDelta,m=c*c,v=0;vf?(U=2,p.push(g.clone())):B<-f?(U=1,d.push(g.clone())):(U=3,d.push(g.clone()),p.push(g.clone()));var z=0,B=L.distanceToPoint(y);if(B>f?(z=2,p.push(y.clone())):B<-f?(z=1,d.push(y.clone())):(z=3,d.push(y.clone()),p.push(y.clone())),1===U&&2===z||2===U&&1===z){a.tempLine1.start.copy(g),a.tempLine1.end.copy(y);var j=new i;if(j=L.intersectLine(a.tempLine1,j),void 0===j)return console.error("Internal error: segment does not intersect plane."),r.segmentedObject1=null,r.segmentedObject2=null,0;d.push(j),p.push(j.clone())}}}var V=.5*e.userData.mass;this.tempCM1.set(0,0,0);var G=0,W=d.length;if(W>0){for(var v=0;v0){for(var v=0;v4&&(q=new k(new nt(d),e.material),q.position.copy(this.tempCM1),q.quaternion.copy(e.quaternion),this.prepareBreakableObject(q,V,e.userData.velocity,e.userData.angularVelocity,2*G>this.minSizeForBreak),J++),Y>4&&(Q=new k(new nt(p),e.material),Q.position.copy(this.tempCM2),Q.quaternion.copy(e.quaternion),this.prepareBreakableObject(Q,V,e.userData.velocity,e.userData.angularVelocity,2*H>this.minSizeForBreak),J++),r.object1=q,r.object2=Q,J}},$u.transformFreeVector=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[4]*i+a[8]*n,e.y=a[1]*r+a[5]*i+a[9]*n,e.z=a[2]*r+a[6]*i+a[10]*n,e},$u.transformFreeVectorInverse=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[1]*i+a[2]*n,e.y=a[4]*r+a[5]*i+a[6]*n,e.z=a[8]*r+a[9]*i+a[10]*n,e},$u.transformTiedVectorInverse=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[1]*i+a[2]*n-a[12],e.y=a[4]*r+a[5]*i+a[6]*n-a[13],e.z=a[8]*r+a[9]*i+a[10]*n-a[14],e},$u.transformPlaneToLocalSpace=function(){var e=new i;return function(t,r,i){i.normal.copy(t.normal),i.constant=t.constant;var n=$u.transformTiedVectorInverse(t.coplanarPoint(e),r);$u.transformFreeVectorInverse(i.normal,r),i.constant=-n.dot(i.normal)}}(),Object.assign(at.prototype,{getPoint:function(){return console.warn("Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var r=this.getUtoTmapping(e);return this.getPoint(r,t)},getPoints:function(e){var t=this;void 0===e&&(e=5);for(var r=[],i=0;i<=e;i++)r.push(t.getPoint(i/e));return r},getSpacedPoints:function(e){var t=this;void 0===e&&(e=5);for(var r=[],i=0;i<=e;i++)r.push(t.getPointAt(i/e));return r},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){var t=this;if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var r,i,n=[],a=this.getPoint(0),o=0;for(n.push(0),i=1;i<=e;i++)r=t.getPoint(i/e),o+=r.distanceTo(a),n.push(o),a=r;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var r,i=this.getLengths(),n=0,a=i.length;r=t?t:e*i[a-1];for(var o,s=0,l=a-1;s<=l;)if(n=Math.floor(s+(l-s)/2),o=i[n]-r,o<0)s=n+1;else{if(!(o>0)){l=n;break}l=n-1}if(n=l,i[n]===r)return n/(a-1);var c=i[n],u=i[n+1],h=u-c,d=(r-c)/h,p=(n+d)/(a-1);return p},getTangent:function(e){var t=1e-4,r=e-t,i=e+t;r<0&&(r=0),i>1&&(i=1);var n=this.getPoint(r),a=this.getPoint(i),o=a.clone().sub(n);return o.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,a,o,s=this,l=new i,c=[],u=[],h=[],d=new i,p=new r;for(n=0;n<=e;n++)a=n/e,c[n]=s.getTangentAt(a),c[n].normalize();u[0]=new i,h[0]=new i;var f=Number.MAX_VALUE,m=Math.abs(c[0].x),v=Math.abs(c[0].y),g=Math.abs(c[0].z);for(m<=f&&(f=m,l.set(1,0,0)),v<=f&&(f=v,l.set(0,1,0)),g<=f&&l.set(0,0,1),d.crossVectors(c[0],l).normalize(),u[0].crossVectors(c[0],d),h[0].crossVectors(c[0],u[0]),n=1;n<=e;n++)u[n]=u[n-1].clone(),h[n]=h[n-1].clone(),d.crossVectors(c[n-1],c[n]),d.length()>Number.EPSILON&&(d.normalize(),o=Math.acos(Fs.clamp(c[n-1].dot(c[n]),-1,1)),u[n].applyMatrix4(p.makeRotationAxis(d,o))),h[n].crossVectors(c[n],u[n]);if(t===!0)for(o=Math.acos(Fs.clamp(u[0].dot(u[e]),-1,1)),o/=e,c[0].dot(d.crossVectors(u[0],u[e]))>0&&(o=-o),n=1;n<=e;n++)u[n].applyMatrix4(p.makeRotationAxis(c[n],o*n)),h[n].crossVectors(c[n],u[n]);return{tangents:c,normals:u,binormals:h}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),ot.prototype=Object.create(at.prototype),ot.prototype.constructor=ot,ot.prototype.getPoint=function(e,t){var r=t||new i;e=2*Math.PI*e;var n=-.22*Math.cos(e)-1.28*Math.sin(e)-.44*Math.cos(3*e)-.78*Math.sin(3*e),a=-.1*Math.cos(2*e)-.27*Math.sin(2*e)+.38*Math.cos(4*e)+.46*Math.sin(4*e),o=.7*Math.cos(3*e)-.4*Math.sin(3*e);return r.set(n,a,o).multiplyScalar(20)},st.prototype=Object.create(at.prototype),st.prototype.constructor=st,st.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=16*Math.pow(Math.sin(e),3),a=13*Math.cos(e)-5*Math.cos(2*e)-2*Math.cos(3*e)-Math.cos(4*e),o=0;return r.set(n,a,o).multiplyScalar(this.scale)},lt.prototype=Object.create(at.prototype),lt.prototype.constructor=lt,lt.prototype.getPoint=function(e,t){var r=t||new i;e=4*e*Math.PI;var n=this.scale/2,a=n*(1+Math.cos(e)),o=n*Math.sin(e),s=2*n*Math.sin(e/2);return r.set(a,o,s)},ct.prototype=Object.create(at.prototype),ct.prototype.constructor=ct,ct.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=10,a=50,o=a*Math.sin(e),s=Math.cos(e)*(n+a*Math.cos(e)),l=Math.sin(e)*(n+a*Math.cos(e));return r.set(o,s,l)},ut.prototype=Object.create(at.prototype),ut.prototype.constructor=ut,ut.prototype.getPoint=function(e,t){var r=t||new i,n=30,a=150,o=2*Math.PI*e*a/30,s=Math.cos(o)*n,l=Math.sin(o)*n,c=a*e;return r.set(s,l,c)},ht.prototype=Object.create(at.prototype),ht.prototype.constructor=ht,ht.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=(2+Math.cos(3*e))*Math.cos(2*e),a=(2+Math.cos(3*e))*Math.sin(2*e),o=Math.sin(3*e);return r.set(n,a,o).multiplyScalar(this.scale)},dt.prototype=Object.create(at.prototype),dt.prototype.constructor=dt,dt.prototype.getPoint=function(e,t){var r=t||new i,n=3,a=4;e*=2*Math.PI;var o=(2+Math.cos(a*e))*Math.cos(n*e),s=(2+Math.cos(a*e))*Math.sin(n*e),l=Math.sin(a*e);return r.set(o,s,l).multiplyScalar(this.scale)},pt.prototype=Object.create(at.prototype),pt.prototype.constructor=pt,pt.prototype.getPoint=function(e,t){var r=t||new i,n=2,a=5;e*=2*Math.PI;var o=(2+Math.cos(a*e))*Math.cos(n*e),s=(2+Math.cos(a*e))*Math.sin(n*e),l=Math.sin(a*e);return r.set(o,s,l).multiplyScalar(this.scale)},ft.prototype=Object.create(at.prototype),ft.prototype.constructor=ft,ft.prototype.getPoint=function(e,t){var r=t||new i;e=4*e-2;var n=Math.pow(e,3)-3*e,a=Math.pow(e,4)-4*e*e,o=.2*Math.pow(e,5)-2*e;return r.set(n,a,o).multiplyScalar(this.scale)};var eh=function(e,t,r){var i=t-e;return r*i+e};mt.prototype=Object.create(at.prototype),mt.prototype.constructor=mt,mt.prototype.getPoint=function(e,t){var r=t||new i;e=eh(-4,4,e);var n=.4*e*(e*e-7)*(e*e-10),a=Math.pow(e,4)-13*e*e,o=.1*e*(e*e-4)*(e*e-9)*(e*e-12);return r.set(n,a,o).multiplyScalar(this.scale)},vt.prototype=Object.create(at.prototype),vt.prototype.constructor=vt,vt.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=Math.cos(2*e)*(1+.6*(Math.cos(5*e)+.75*Math.cos(10*e))),a=Math.sin(2*e)*(1+.6*(Math.cos(5*e)+.75*Math.cos(10*e))),o=.35*Math.sin(5*e);return r.set(n,a,o).multiplyScalar(this.scale)},gt.prototype=Object.create(at.prototype),gt.prototype.constructor=gt,gt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(2*n)*(1+.45*Math.cos(3*n)+.4*Math.cos(9*n)),o=Math.sin(2*n)*(1+.45*Math.cos(3*n)+.4*Math.cos(9*n)),s=.2*Math.sin(9*n);return r.set(a,o,s).multiplyScalar(this.scale)},yt.prototype=Object.create(at.prototype),yt.prototype.constructor=yt,yt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(3*n)*(1+.3*Math.cos(5*n)+.5*Math.cos(10*n)),o=Math.sin(3*n)*(1+.3*Math.cos(5*n)+.5*Math.cos(10*n)),s=.2*Math.sin(20*n);return r.set(a,o,s).multiplyScalar(this.scale)},xt.prototype=Object.create(at.prototype),xt.prototype.constructor=xt,xt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(4*n)*(1+.5*(Math.cos(5*n)+.4*Math.cos(20*n))),o=Math.sin(4*n)*(1+.5*(Math.cos(5*n)+.4*Math.cos(20*n))),s=.35*Math.sin(15*n);return r.set(a,o,s).multiplyScalar(this.scale)};var th={findSpan:function(e,t,r){var i=r.length-e-1;if(t>=r[i])return i-1;if(t<=r[e])return e;for(var n=e,a=i,o=Math.floor((n+a)/2);t=r[o+1];)t=b&&(x[y][0]=x[g][0]/l[S+1][_],w=x[y][0]*l[_][S]);for(var A=_>=-1?1:-_,M=p-1<=S?b-1:r-p,h=A;h<=M;++h)x[y][h]=(x[g][h]-x[g][h-1])/l[S+1][_+h],w+=x[y][h]*l[_+h][S];p<=S&&(x[y][b]=-x[g][b-1]/l[S+1][p],w+=x[y][b]*l[p][S]),s[b][p]=w;var h=g;g=y,y=h}}for(var p=r,b=1;b<=i;++b){for(var h=0;h<=r;++h)s[b][h]*=p;p*=r-b}return s},calcBSplineDerivatives:function(e,t,r,i,n){for(var a=nWebGL.
','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.'].join("\n")),e},addGetWebGLMessage:function(e){var t,r,i;e=e||{},t=void 0!==e.parent?e.parent:document.body,r=void 0!==e.id?e.id:"oldie",i=nh.getWebGLErrorMessage(),i.id=r,t.appendChild(i)}};Object.assign(bt.prototype,{update:function(){var e,t,i,n,a,o,s,l,c=new r,u=new r;return function(r){var h=e!==this||t!==r.focus||i!==r.fov||n!==r.aspect*this.aspect||a!==r.near||o!==r.far||s!==r.zoom||l!==this.eyeSep;if(h){e=this,t=r.focus,i=r.fov,n=r.aspect*this.aspect,a=r.near,o=r.far,s=r.zoom;var d=r.projectionMatrix.clone();l=this.eyeSep/2;var p,f,m=l*a/t,v=a*Math.tan(Fs.DEG2RAD*i*.5)/s;u.elements[12]=-l,c.elements[12]=l,p=-v*n+m,f=v*n+m,d.elements[0]=2*a/(f-p),d.elements[8]=(f+p)/(f-p),this.cameraL.projectionMatrix.copy(d),p=-v*n-m,f=v*n-m,d.elements[0]=2*a/(f-p),d.elements[8]=(f+p)/(f-p),this.cameraR.projectionMatrix.copy(d)}this.cameraL.matrixWorld.copy(r.matrixWorld).multiply(u),this.cameraR.matrixWorld.copy(r.matrixWorld).multiply(c)}}()});var ah=function(e,t,r){this.colorMatrixLeft=(new l).fromArray([1.0671679973602295,-.0016435992438346148,.0001777536963345483,-.028107794001698494,-.00019593400065787137,-.0002875397040043026,-.04279090091586113,15809757314855233e-21,-.00024287120322696865]),this.colorMatrixRight=(new l).fromArray([-.0355340838432312,-.06440307199954987,.018319187685847282,-.10269022732973099,.8079727292060852,-.04835830628871918,.0001224992738571018,-.009558862075209618,.567823588848114]);var i=new me((-1),1,1,(-1),0,1),n=new fe,a=new bt,o={minFilter:rc,magFilter:$l,format:xc};void 0===t&&(t=512),void 0===r&&(r=512);var s=new ge(t,r,o),c=new ge(t,r,o),u=new pe({uniforms:{mapLeft:{value:s.texture},mapRight:{value:c.texture},colorMatrixLeft:{value:this.colorMatrixLeft},colorMatrixRight:{value:this.colorMatrixRight}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = vec2( uv.x, uv.y );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","uniform mat3 colorMatrixLeft;","uniform mat3 colorMatrixRight;","float lin( float c ) {","\treturn c <= 0.04045 ? c * 0.0773993808 :","\t\t\tpow( c * 0.9478672986 + 0.0521327014, 2.4 );","}","vec4 lin( vec4 c ) {","\treturn vec4( lin( c.r ), lin( c.g ), lin( c.b ), c.a );","}","float dev( float c ) {","\treturn c <= 0.0031308 ? c * 12.92","\t\t\t: pow( c, 0.41666 ) * 1.055 - 0.055;","}","void main() {","\tvec2 uv = vUv;","\tvec4 colorL = lin( texture2D( mapLeft, uv ) );","\tvec4 colorR = lin( texture2D( mapRight, uv ) );","\tvec3 color = clamp(","\t\t\tcolorMatrixLeft * colorL.rgb +","\t\t\tcolorMatrixRight * colorR.rgb, 0., 1. );","\tgl_FragColor = vec4(","\t\t\tdev( color.r ), dev( color.g ), dev( color.b ),","\t\t\tmax( colorL.a, colorR.a ) );","}"].join("\n")}),h=new k(new xe(2,2),u);n.add(h),this.setSize=function(t,r){e.setSize(t,r);var i=e.getPixelRatio();s.setSize(t*i,r*i),c.setSize(t*i,r*i)},this.render=function(t,r){t.updateMatrixWorld(),null===r.parent&&r.updateMatrixWorld(),a.update(r),e.render(t,a.cameraL,s,!0),e.render(t,a.cameraR,c,!0),e.render(n,i)},this.dispose=function(){s&&s.dispose(),c&&c.dispose(),h&&h.geometry.dispose(),u&&u.dispose()}},oh=function(e,t,r){function i(){v=Math.round(a*T),g=Math.round(o*T),S.width=v,S.height=g,y=e.domElement,y.style.backgroundColor&&(m.rows[0].cells[0].style.backgroundColor=y.style.backgroundColor,m.rows[0].cells[0].style.color=y.style.color),m.cellSpacing=0,m.cellPadding=0;var t=m.style;t.display="inline",t.width=Math.round(v/T*l)+"px",t.height=Math.round(g/T*l)+"px",t.whiteSpace="pre",t.margin="0px",t.padding="0px",t.letterSpacing=L+"px",t.fontFamily=w,t.fontSize=E+"px",t.lineHeight=C+"px",t.textAlign="left",t.textDecoration="none"}function n(e,t){A.clearRect(0,0,v,g),A.drawImage(_,0,0,v,g);for(var r=A.getImageData(0,0,v,g).data,i="",n=0;n"+x+"":x}i+="
"}t.innerHTML=""+i+""}t=void 0===t?" .:-=+*#%@":t,r||(r={});var a,o,s=r.resolution?r.resolution:.15,l=r.scale?r.scale:1,c=!!r.color&&r.color,u=!!r.alpha&&r.alpha,h=!!r.block&&r.block,d=!!r.invert&&r.invert,p="low",f=document.createElement("div");f.style.cursor="default";var m=document.createElement("table");f.appendChild(m);var v,g,y;this.setSize=function(t,r){a=t,o=r,e.setSize(t,r),i()},this.render=function(t,r){e.render(t,r),n(e,m)},this.domElement=f;var x=" .,:;i1tfLCG08@".split(""),b=" CGO08@".split(""),w="courier new, monospace",_=e.domElement,S=document.createElement("canvas");if(S.getContext){var A=S.getContext("2d");if(A.getImageData){var M=c?b:x;t&&(M=t);var T=.5;switch(p){case"low":T=.25;break;case"medium":T=.5;break;case"high":T=1}s&&(T=s);var E=2/T*l,C=2/T*l,L=0;switch(l){case 1:L=-1;break;case 2:case 3:L=-2.1;break;case 4:L=-3.1;break;case 5:L=-4.15}}}},sh="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",lh="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",ch="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",uh="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",hh="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",dh="\nvec3 transformed = vec3( position );\n",ph="\nvec3 objectNormal = vec3( normal );\n",fh="float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_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}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * 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}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.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 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat 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_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",mh="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\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\n",vh="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",gh="#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",yh="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",xh="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",bh="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",wh="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",_h="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",Sh="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",Ah="#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float 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 average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\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}\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\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}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",Mh="#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",Th="vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",Eh="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",Ch="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",Lh="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",Ph="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",Nh=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",Oh="\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n",Dh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\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\n",Fh="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",Ih="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",Rh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\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\n",Uh="#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif\n",kh="#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif\n",Bh="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",zh="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\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\n",jh="#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",Vh="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",Gh="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",Wh="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",Xh="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.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 GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",Hh="#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",Yh="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",qh="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",Qh="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",Jh="struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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.specularRoughness;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\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\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\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}\n",Zh="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",Kh="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",$h="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",ed="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",td="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n#endif\n",rd="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif\n",id="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",nd="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",ad="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",od="#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",sd="#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",ld="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",cd="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",ud="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",hd="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",dd="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",pd="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",fd="#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",md="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n",vd="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",gd="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",yd="vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",xd="#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",bd="#if defined( 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\n",wd="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",_d="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",Sd="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\t\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\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\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",Ad="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\t\n#endif\n",Md="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t\n#endif\n",Td="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t\n\t#endif\n\treturn shadow;\n}\n",Ed="#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",Cd="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",Ld="#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\n",Pd="#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#endif\n",Nd="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",Od="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",Dd="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",Fd="#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",Id="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",Rd="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",Ud="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",kd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",Bd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",zd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",jd="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",Vd="uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",Gd="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",Wd="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",Xd="#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Hd="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",Yd="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",qd="uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",Qd="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",Jd="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Zd="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",Kd="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",$d="#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ep="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",tp="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",rp="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ip="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",np="#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ap="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",op="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",sp="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",lp="uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",cp="uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",up="uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",hp="#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",dp="uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}\n",pp="uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\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 \n\t#include \n\t#include \n}\n",fp={ -alphamap_fragment:sh,alphamap_pars_fragment:lh,alphatest_fragment:ch,aomap_fragment:uh,aomap_pars_fragment:hh,begin_vertex:dh,beginnormal_vertex:ph,bsdfs:fh,bumpmap_pars_fragment:mh,clipping_planes_fragment:vh,clipping_planes_pars_fragment:gh,clipping_planes_pars_vertex:yh,clipping_planes_vertex:xh,color_fragment:bh,color_pars_fragment:wh,color_pars_vertex:_h,color_vertex:Sh,common:Ah,cube_uv_reflection_fragment:Mh,defaultnormal_vertex:Th,displacementmap_pars_vertex:Eh,displacementmap_vertex:Ch,emissivemap_fragment:Lh,emissivemap_pars_fragment:Ph,encodings_fragment:Nh,encodings_pars_fragment:Oh,envmap_fragment:Dh,envmap_pars_fragment:Fh,envmap_pars_vertex:Ih,envmap_physical_pars_fragment:Hh,envmap_vertex:Rh,fog_vertex:Uh,fog_pars_vertex:kh,fog_fragment:Bh,fog_pars_fragment:zh,gradientmap_pars_fragment:jh,lightmap_fragment:Vh,lightmap_pars_fragment:Gh,lights_lambert_vertex:Wh,lights_pars_begin:Xh,lights_phong_fragment:Yh,lights_phong_pars_fragment:qh,lights_physical_fragment:Qh,lights_physical_pars_fragment:Jh,lights_fragment_begin:Zh,lights_fragment_maps:Kh,lights_fragment_end:$h,logdepthbuf_fragment:ed,logdepthbuf_pars_fragment:td,logdepthbuf_pars_vertex:rd,logdepthbuf_vertex:id,map_fragment:nd,map_pars_fragment:ad,map_particle_fragment:od,map_particle_pars_fragment:sd,metalnessmap_fragment:ld,metalnessmap_pars_fragment:cd,morphnormal_vertex:ud,morphtarget_pars_vertex:hd,morphtarget_vertex:dd,normal_fragment_begin:pd,normal_fragment_maps:fd,normalmap_pars_fragment:md,packing:vd,premultiplied_alpha_fragment:gd,project_vertex:yd,dithering_fragment:xd,dithering_pars_fragment:bd,roughnessmap_fragment:wd,roughnessmap_pars_fragment:_d,shadowmap_pars_fragment:Sd,shadowmap_pars_vertex:Ad,shadowmap_vertex:Md,shadowmask_pars_fragment:Td,skinbase_vertex:Ed,skinning_pars_vertex:Cd,skinning_vertex:Ld,skinnormal_vertex:Pd,specularmap_fragment:Nd,specularmap_pars_fragment:Od,tonemapping_fragment:Dd,tonemapping_pars_fragment:Fd,uv_pars_fragment:Id,uv_pars_vertex:Rd,uv_vertex:Ud,uv2_pars_fragment:kd,uv2_pars_vertex:Bd,uv2_vertex:zd,worldpos_vertex:jd,cube_frag:Vd,cube_vert:Gd,depth_frag:Wd,depth_vert:Xd,distanceRGBA_frag:Hd,distanceRGBA_vert:Yd,equirect_frag:qd,equirect_vert:Qd,linedashed_frag:Jd,linedashed_vert:Zd,meshbasic_frag:Kd,meshbasic_vert:$d,meshlambert_frag:ep,meshlambert_vert:tp,meshphong_frag:rp,meshphong_vert:ip,meshphysical_frag:np,meshphysical_vert:ap,normal_frag:op,normal_vert:sp,points_frag:lp,points_vert:cp,shadow_frag:up,shadow_vert:hp,sprite_frag:dp,sprite_vert:pp},mp={common:{diffuse:{value:new u(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new l},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new f(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new u(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new u(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new l}},sprite:{diffuse:{value:new u(15658734)},opacity:{value:1},center:{value:new f(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new l}}},vp={basic:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.fog]),vertexShader:fp.meshbasic_vert,fragmentShader:fp.meshbasic_frag},lambert:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.fog,mp.lights,{emissive:{value:new u(0)}}]),vertexShader:fp.meshlambert_vert,fragmentShader:fp.meshlambert_frag},phong:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.bumpmap,mp.normalmap,mp.displacementmap,mp.gradientmap,mp.fog,mp.lights,{emissive:{value:new u(0)},specular:{value:new u(1118481)},shininess:{value:30}}]),vertexShader:fp.meshphong_vert,fragmentShader:fp.meshphong_frag},standard:{uniforms:Mu.merge([mp.common,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.bumpmap,mp.normalmap,mp.displacementmap,mp.roughnessmap,mp.metalnessmap,mp.fog,mp.lights,{emissive:{value:new u(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:fp.meshphysical_vert,fragmentShader:fp.meshphysical_frag},points:{uniforms:Mu.merge([mp.points,mp.fog]),vertexShader:fp.points_vert,fragmentShader:fp.points_frag},dashed:{uniforms:Mu.merge([mp.common,mp.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:fp.linedashed_vert,fragmentShader:fp.linedashed_frag},depth:{uniforms:Mu.merge([mp.common,mp.displacementmap]),vertexShader:fp.depth_vert,fragmentShader:fp.depth_frag},normal:{uniforms:Mu.merge([mp.common,mp.bumpmap,mp.normalmap,mp.displacementmap,{opacity:{value:1}}]),vertexShader:fp.normal_vert,fragmentShader:fp.normal_frag},sprite:{uniforms:Mu.merge([mp.sprite,mp.fog]),vertexShader:fp.sprite_vert,fragmentShader:fp.sprite_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:fp.cube_vert,fragmentShader:fp.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:fp.equirect_vert,fragmentShader:fp.equirect_frag},distanceRGBA:{uniforms:Mu.merge([mp.common,mp.displacementmap,{referencePosition:{value:new i},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:fp.distanceRGBA_vert,fragmentShader:fp.distanceRGBA_frag},shadow:{uniforms:Mu.merge([mp.lights,mp.fog,{color:{value:new u(0)},opacity:{value:1}}]),vertexShader:fp.shadow_vert,fragmentShader:fp.shadow_frag}};vp.physical={uniforms:Mu.merge([vp.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:fp.meshphysical_vert,fragmentShader:fp.meshphysical_frag};var gp=function(e,t){function r(){return new pe({name:"invisible",visible:!1})}function i(e){var t,i,n=w[e.type];e.userData.outlineParameters;if(void 0!==n){var a=vp[n];t=a.uniforms,i=a.vertexShader}else if(e.isRawShaderMaterial===!0){if(t=e.uniforms,i=e.vertexShader,!/attribute\s+vec3\s+position\s*;/.test(i)||!/attribute\s+vec3\s+normal\s*;/.test(i))return console.warn("OutlineEffect requires both vec3 position and normal attributes in vertex shader, does not draw outline for "+e.name+"(uuid:"+e.uuid+") material."),r()}else{if(e.isShaderMaterial!==!0)return r();t=e.uniforms,i=e.vertexShader}var o=Object.assign({},t,_),s=i.replace(/void\s+main\s*\(\s*\)/,S+"\nvoid main()").replace(/\}\s*$/,A+"\n}").replace(/#include\s+<[\w_]*light[\w_]*>/g,""),l={};return/vec3\s+transformed\s*=/.test(i)||/#include\s+/.test(i)||(l.DECLARE_TRANSFORMED=!0),new pe({defines:l,uniforms:o,vertexShader:s,fragmentShader:M,side:Zs,skinning:!1,morphTargets:!1,morphNormals:!1,fog:!1})}function n(e){var t=g[e.uuid];return void 0===t&&(t={material:i(e),used:!0,keepAlive:v,count:0},g[e.uuid]=t),t.used=!0,t.material}function a(e){var t=n(e);return x[t.uuid]=e,h(t,e),t}function o(e){if(void 0!==e.material){if(Array.isArray(e.material))for(var t=0,r=e.material.length;ty&&delete g[i]):(g[i].used=!1,g[i].count=0)}}t=t||{},this.enabled=!0;var p=void 0!==t.defaultThickness?t.defaultThickness:.003,f=(new u).fromArray(void 0!==t.defaultColor?t.defaultColor:[0,0,0]),m=void 0!==t.defaultAlpha?t.defaultAlpha:1,v=void 0!==t.defaultKeepAlive&&t.defaultKeepAlive,g={},y=60,x={},b={},w={MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical"},_={outlineThickness:{type:"f",value:p},outlineColor:{type:"c",value:f},outlineAlpha:{type:"f",value:m}},S=["#include ","uniform float outlineThickness;","vec4 calculateOutline( vec4 pos, vec3 objectNormal, vec4 skinned ) {","\tfloat thickness = outlineThickness;","\tconst float ratio = 1.0;","\tvec4 pos2 = projectionMatrix * modelViewMatrix * vec4( skinned.xyz + objectNormal, 1.0 );","\tvec4 norm = normalize( pos - pos2 );","\treturn pos + norm * thickness * pos.w * ratio;","}"].join("\n"),A=["#if ! defined( LAMBERT ) && ! defined( PHONG ) && ! defined( TOON ) && ! defined( PHYSICAL )","\t#ifndef USE_ENVMAP","\t\tvec3 objectNormal = normalize( normal );","\t#endif","#endif","#ifdef FLIP_SIDED","\tobjectNormal = -objectNormal;","#endif","#ifdef DECLARE_TRANSFORMED","\tvec3 transformed = vec3( position );","#endif","gl_Position = calculateOutline( gl_Position, objectNormal, vec4( transformed, 1.0 ) );","#include "].join("\n"),M=["#include ","#include ","uniform vec3 outlineColor;","uniform float outlineAlpha;","void main() {","\tgl_FragColor = vec4( outlineColor, outlineAlpha );","\t#include ","}"].join("\n");this.render=function(t,r,i,n){if(this.enabled===!1)return void e.render(t,r,i,n);var a=e.autoClear;e.autoClear=this.autoClear,e.render(t,r,i,n);var l=t.autoUpdate,c=t.background,u=e.shadowMap.enabled;t.autoUpdate=!1,t.background=null,e.autoClear=!1,e.shadowMap.enabled=!1,t.traverse(o),e.render(t,r,i),t.traverse(s),d(),t.autoUpdate=l,t.background=c,e.autoClear=a,e.shadowMap.enabled=u},this.autoClear=e.autoClear,this.domElement=e.domElement,this.shadowMap=e.shadowMap,this.clear=function(t,r,i){e.clear(t,r,i)},this.getPixelRatio=function(){return e.getPixelRatio()},this.setPixelRatio=function(t){e.setPixelRatio(t)},this.getSize=function(){return e.getSize()},this.setSize=function(t,r,i){e.setSize(t,r,i)},this.setViewport=function(t,r,i,n){e.setViewport(t,r,i,n)},this.setScissor=function(t,r,i,n){e.setScissor(t,r,i,n)},this.setScissorTest=function(t){e.setScissorTest(t)},this.setRenderTarget=function(t){e.setRenderTarget(t)}},yp=function(e){var t=new me((-1),1,1,(-1),0,1),r=new fe,i=new bt,n={minFilter:rc,magFilter:$l,format:xc},a=new ge(512,512,n),o=new ge(512,512,n),s=new pe({uniforms:{mapLeft:{value:a.texture},mapRight:{value:o.texture}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = vec2( uv.x, uv.y );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","void main() {","\tvec2 uv = vUv;","\tif ( ( mod( gl_FragCoord.y, 2.0 ) ) > 1.00 ) {","\t\tgl_FragColor = texture2D( mapLeft, uv );","\t} else {","\t\tgl_FragColor = texture2D( mapRight, uv );","\t}","}"].join("\n")}),l=new k(new xe(2,2),s);r.add(l),this.setSize=function(t,r){e.setSize(t,r);var i=e.getPixelRatio();a.setSize(t*i,r*i),o.setSize(t*i,r*i)},this.render=function(n,s){n.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),i.update(s),e.render(n,i.cameraL,a,!0),e.render(n,i.cameraR,o,!0),e.render(r,t)}},xp=function(e){var t=this;t.cameraDistance=15,t.reflectFromAbove=!1;var r,a,o,s=new de,l=new de,c=new de,u=new de,h=new i,d=new n,p=new i;e.autoClear=!1,this.setSize=function(t,i){r=t/2,t$)|(\/>$)/,i=/<[^>]+>[^<]*<\/[^<]+>/,n=function(e,t){return t>0?e+n(e,t-1):""},a=0;return e.match(/(<[^>]+>[^<]+<\/[^<]+>)|(<[^>]+>)/g).map(function(e){i.test(e)||r.test(e)||!t.test(e)||a--;var o=""+n(" ",a)+e;return i.test(e)||r.test(e)||t.test(e)||a++,o}).join("\n")}function a(e){for(var t=atob(e),r=new Uint8Array(t.length),i=0,n=r.length;i'+n.join(" ")+''+r.map(function(e){return''}).join("")+"";return a}function h(e){return e.updateMatrix(),b=b||new r,b.copy(e.matrix),b.transpose(),""+b.toArray().join(" ")+""}function d(e){var t=_.get(e);if(!t){var r=e;r instanceof m&&(r=(new P).fromGeometry(r));var i="Mesh"+(E.length+1),n=r.index?r.index.count*r.index.itemSize:r.attributes.position.count,a=null!=r.groups&&0!==r.groups.length?r.groups:[{start:0,count:n,materialIndex:0}],o='',u=i+"-position",h=i+"-vertices";o+=c(r.attributes.position,u,["X","Y","Z"],"float"),o+='';var d='';if("normal"in r.attributes){var p=i+"-normal";o+=c(r.attributes.normal,p,["X","Y","Z"],"float"),d+=''}if("uv"in r.attributes){var f=i+"-texcoord";o+=c(r.attributes.uv,f,["S","T"],"float"),d+=''}if("color"in r.attributes){var v=i+"-color";o+=c(r.attributes.color,v,["X","Y","Z"],"uint8"),d+=''}var g=null;if(r.index)g=s(r.index);else{g=new Array(n);for(var y=0,x=g.length;y',o+=d,o+="

"+w.join(" ")+"

",o+=""}o+="
",E.push(o),t={meshid:i,bufferGeometry:r},_.set(e,t)}return t}function p(e){var t=A.get(e);if(null==t){t="image-"+(T.length+1);var r="png",n=e.name||t,a='';a+="1.5.0"===g?""+i.textureDirectory+n+"."+r+"":""+i.textureDirectory+n+"."+r+"",a+="",T.push(a),A.set(e,t),M.push({directory:i.textureDirectory,name:n,ext:r,data:o(e.image,r),original:e})}return t}function f(e){var t=S.get(e);if(null==t){t="Mat"+(C.length+1);var r="phong";e instanceof Me?r="lambert":e instanceof F&&(r="constant");var i=e.emissive?e.emissive:new u(0,0,0),n=e.color?e.color:new u(0,0,0),a=e.specular?e.specular:new u(1,1,1),o=e.shininess||0,s=e.reflectivity||0,l="";e.transparent===!0&&(l+=""+(e.map?'':"1")+"",e.opacity<1&&(l+=""+e.opacity+""));var c='<'+r+">"+(e.emissiveMap?'':''+i.r+" "+i.g+" "+i.b+" 1")+""+(e.map?'':''+n.r+" "+n.g+" "+n.b+" 1")+''+a.r+" "+a.g+" "+a.b+" 1"+(e.specularMap?'':''+o+"")+""+n.r+" "+n.g+" "+n.b+" 1"+s+""+l+"",h=''+(e.map?''+p(e.map)+'diffuse-surface':"")+(e.specularMap?''+p(e.specularMap)+'specular-surface':"")+(e.emissiveMap?''+p(e.emissiveMap)+'emissive-surface':"")+c+(e.side===Ks?'1':"")+"";L.push(''),C.push(h),S.set(e,t)}return t}function v(e){var t='';if(t+=h(e),e instanceof k&&null!=e.geometry){var r=d(e.geometry),i=r.meshid,n=r.bufferGeometry,a=null,o=e.material||new F,s=Array.isArray(o)?o:[o];a=new Array(n.groups.length).fill().map(function(e,t){return f(s[t%s.length])}),t+=''+(null!=a?""+a.map(function(e,t){return''}).join("")+"":"")+""}return e.children.forEach(function(e){return t+=v(e)}),t+=""}void 0===i&&(i={}),i=Object.assign({version:"1.4.1",author:null,textureDirectory:""},i),""!==i.textureDirectory&&(i.textureDirectory=(i.textureDirectory+"/").replace(/\\/g,"/").replace(/\/+/g,"/"));var g=i.version;if("1.4.1"!==g&&"1.5.0"!==g)return console.warn("ColladaExporter : Version "+g+" not supported for export. Only 1.4.1 and 1.5.0."),null;var y,x,b,w=["getX","getY","getZ","getW"],_=new WeakMap,S=new WeakMap,A=new WeakMap,M=[],T=[],E=[],C=[],L=[],N=v(e),O="1.4.1"===g?"http://www.collada.org/2005/11/COLLADASchema":"https://www.khronos.org/collada/",D=''+("js Collada Exporter"+(null!==i.author?""+i.author+"":"")+""+(new Date).toISOString()+""+(new Date).toISOString()+"Y_UP")+"";D+=""+T.join("")+"",D+=""+C.join("")+"",D+=""+L.join("")+"",D+=""+E.join("")+"",D+=''+N+"",D+='',D+="";var I={data:n(D),textures:M};return"function"==typeof t&&requestAnimationFrame(function(){return t(I)}),I}};var _p={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987},Sp={1003:_p.NEAREST,1004:_p.NEAREST_MIPMAP_NEAREST,1005:_p.NEAREST_MIPMAP_LINEAR,1006:_p.LINEAR,1007:_p.LINEAR_MIPMAP_NEAREST,1008:_p.LINEAR_MIPMAP_LINEAR},Ap={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Mp=function(){};Mp.prototype={constructor:Mp,parse:function(e,t,r){function n(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}function a(e){if(void 0!==Ds.TextEncoder)return(new TextEncoder).encode(e).buffer;for(var t=new Uint8Array(new ArrayBuffer(e.length)),r=0,i=e.length;r255?32:n}return t.buffer}function o(e,t,r){for(var i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},n=t;n5e-4)return!1;return!0}function c(e){if(z.attributes.has(e))return z.attributes.get(e);for(var t=e.clone(),r=new i,n=0,a=t.count;n0)&&(t.alphaMode=e.opacity<1?"BLEND":"MASK",e.alphaTest>0&&.5!==e.alphaTest&&(t.alphaCutoff=e.alphaTest)),e.side===Ks&&(t.doubleSided=!0),""!==e.name&&(t.name=e.name),Object.keys(e.userData).length>0&&(t.extras=d(e)),D.materials.push(t);var a=D.materials.length-1;return z.materials.set(e,a),a}function _(e){var t,i=e.geometry;if(e.isLineSegments)t=_p.LINES;else if(e.isLineLoop)t=_p.LINE_LOOP;else if(e.isLine)t=_p.LINE_STRIP;else if(e.isPoints)t=_p.POINTS;else{if(!i.isBufferGeometry){var n=new P;n.fromGeometry(i),i=n}e.drawMode===au?(console.warn("GLTFExporter: TriangleFanDrawMode and wireframe incompatible."),t=_p.TRIANGLE_FAN):t=e.drawMode===nu?e.material.wireframe?_p.LINE_STRIP:_p.TRIANGLE_STRIP:e.material.wireframe?_p.LINES:_p.TRIANGLES}var a={},o={},s=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=i.getAttribute("normal");void 0===p||l(p)||(console.warn("GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.addAttribute("normal",c(p)));for(var f in i.attributes){var m=i.attributes[f];f=h[f]||f.toUpperCase();var y=m.array;if("JOINTS_0"!==f||y instanceof Uint16Array||y instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new g(new Uint16Array(y),m.itemSize,m.normalized)),"MORPH"!==f.substr(0,5)){var x=v(m,i);null!==x&&(o[f]=x)}}if(void 0!==p&&i.addAttribute("normal",p),0===Object.keys(o).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){var b=[],_=[],S={};if(void 0!==e.morphTargetDictionary)for(var A in e.morphTargetDictionary)S[e.morphTargetDictionary[A]]=A;for(var M=0;M0&&(a.extras={},a.extras.targetNames=_)}var F=Object.keys(i.userData).length>0?d(i):void 0,I=r.forceIndices,R=Array.isArray(e.material);if(R&&0===i.groups.length)return null;!I&&null===i.index&&R&&(console.warn("GLTFExporter: Creating index for non-indexed multi-material mesh."),I=!0);var U=!1;if(null===i.index&&I){for(var k=[],M=0,B=i.attributes.position.count;M0&&(V.targets=u),null!==i.index&&(V.indices=v(i.index,i,j[M].start,j[M].count));var G=w(z[j[M].materialIndex]);null!==G&&(V.material=G),s.push(V)}return U&&i.setIndex(null),a.primitives=s,D.meshes||(D.meshes=[]),D.meshes.push(a),D.meshes.length-1}function S(e){D.cameras||(D.cameras=[]);var t=e.isOrthographicCamera,r={type:t?"orthographic":"perspective"};return t?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:Fs.degToRad(e.fov)/e.aspect,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),D.cameras.push(r),D.cameras.length-1}function A(e,t){D.animations||(D.animations=[]);for(var r=[],i=[],n=0;n0&&(t.extras=d(e)),e.isMesh||e.isLine||e.isPoints){var s=_(e);null!==s&&(t.mesh=s)}else e.isCamera&&(t.camera=S(e));if(e.isSkinnedMesh&&k.push(e),e.children.length>0){for(var l=[],c=0,u=e.children.length;c0&&(t.children=l)}D.nodes.push(t);var f=D.nodes.length-1;return U.set(e,f),f}function E(e){D.scenes||(D.scenes=[],D.scene=0);var t={nodes:[]};""!==e.name&&(t.name=e.name),D.scenes.push(t);for(var i=[],n=0,a=e.children.length;n0&&(t.nodes=i)}function C(e){var t=new fe;t.name="AuxScene";for(var r=0;r0&&C(t);for(var i=0;i0&&(r.trs=!0);var O,D={asset:{version:"2.0",generator:"GLTFExporter"}},F=0,I=[],R=[],U=new Map,k=[],B={},z={attributes:new Map,materials:new Map,textures:new Map,images:new Map};L(e),Promise.all(R).then(function(){var e=new Blob(I,{type:"application/octet-stream"}),i=Object.keys(B);if(i.length>0&&(D.extensionsUsed=i),D.buffers&&D.buffers.length>0){D.buffers[0].byteLength=e.size;var n=new Ds.FileReader;if(r.binary===!0){var o=12,s=1179937895,l=2,c=8,u=1313821514,d=5130562;n.readAsArrayBuffer(e),n.onloadend=function(){var e=h(n.result),r=new DataView(new ArrayBuffer(c));r.setUint32(0,e.byteLength,!0),r.setUint32(4,d,!0);var i=h(a(JSON.stringify(D)),32),p=new DataView(new ArrayBuffer(c));p.setUint32(0,i.byteLength,!0),p.setUint32(4,u,!0);var f=new ArrayBuffer(o),m=new DataView(f);m.setUint32(0,s,!0),m.setUint32(4,l,!0);var v=o+p.byteLength+i.byteLength+r.byteLength+e.byteLength;m.setUint32(8,v,!0);var g=new Blob([f,p,i,r,e],{type:"application/octet-stream"}),y=new Ds.FileReader;y.readAsArrayBuffer(g),y.onloadend=function(){t(y.result)}}}else n.readAsDataURL(e),n.onloadend=function(){var e=n.result;D.buffers[0].uri=e,t(D)}}else t(D)})}};var Tp=function(){function e(e){if(void 0===a){var t=new MMDParser.CharsetEncoder,r=t.s2uTable;a={};for(var i=Object.keys(r),n=0,o=i.length;n255?(c.push(l>>8&255),c.push(255&l)):c.push(255&l)}return new Uint8Array(c)}function t(e){var t=e.clone();return t.pose(),t.skeleton.bones}var a;this.parseVpd=function(a,o,s){function l(e){Math.abs(e)<1e-6&&(e=0);var t=e.toString();t.indexOf(".")===-1&&(t+="."),t+="000000";var r=t.indexOf("."),i=t.slice(0,r),n=t.slice(r+1,r+7);return i+"."+n}function c(e){for(var t=[],r=0,i=e.length;r256&&(m=2),d>65536&&(m=4);var v="ply\nformat "+(r.binary?"binary_big_endian":"ascii")+" 1.0\nelement vertex "+d+"\nproperty float x\nproperty float y\nproperty float z\n";c===!0&&(v+="property float nx\nproperty float ny\nproperty float nz\n"),h===!0&&(v+="property float s\nproperty float t\n"),u===!0&&(v+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),f===!0&&(v+="element face "+p+"\nproperty list uchar uint"+8*m+" vertex_index\n"),v+="end_header\n";var g=new i,y=new l,x=null;if(r.binary===!0){var b=(new TextEncoder).encode(v),w=d*(12+(c?12:0)+(u?3:0)+(h?8:0)),_=f?p*(3*m+1):0,S=new DataView(new ArrayBuffer(b.length+w+_));new Uint8Array(S.buffer).set(b,0);var A=b.length,M=b.length+w,T=0;n(function(e,t){var r=t.getAttribute("position"),i=t.getAttribute("normal"),n=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex();y.getNormalMatrix(e.matrixWorld);for(var s=0,l=r.count;s=28){for(A=0;A<3;A++){for(M=0;M<4;M++)for(T=0;T<4;T++)j[4*T+M]=u[3*c[16*ge+4*M+T]+A],s&&ge>=20&&ge<28&&2!==A&&(j[4*T+M]*=1.077),l||2!==A||(j[4*T+M]*=h);ee.set(j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],j[8],j[9],j[10],j[11],j[12],j[13],j[14],j[15]),te.multiplyMatrices(ee,S),H[A].multiplyMatrices(le,te)}for(C=0;C<=t;C++)for(O=C/t,L=0;L<=t;L++){for(D=L/t,R=4,F=I=1;R--;)V[R]=F,G[R]=I,F*=O,I*=D,3===R?(W[R]=X[R]=0,Z=K=1):(W[R]=Z*(3-R),X[R]=K*(3-R),Z*=O,K*=D);for(re.fromArray(V),ie.fromArray(G),ne.fromArray(W),ae.fromArray(X),A=0;A<3;A++)E=re.clone(),E.applyMatrix4(H[A]),Y[A]=E.dot(ie),E=ne.clone(),E.applyMatrix4(H[A]),q[A]=E.dot(ie),E=re.clone(),E.applyMatrix4(H[A]),Q[A]=E.dot(ae);oe.fromArray(q),se.fromArray(Q),J.crossVectors(se,oe),J.normalize(),0===Y[0]&&0===Y[1]?$.set(0,Y[2]>p?1:-1,0):$.set(J.x,J.z,-J.y),b[pe++]=f*Y[0],b[pe++]=f*(Y[2]-p),b[pe++]=-f*Y[1],w[fe++]=$.x,w[fe++]=$.y,w[fe++]=$.z,_[me++]=1-D,_[me++]=1-O}for(C=0;Cr.far)return;a.push({distance:o,distanceToRay:Math.sqrt(n),point:f.clone(),index:i,face:null,object:s})}}var s=this,l=this.geometry,c=this.matrixWorld,u=r.params.Points.threshold;if(null===l.boundingSphere&&l.computeBoundingSphere(),n.copy(l.boundingSphere),n.applyMatrix4(c),n.radius+=u,r.ray.intersectsSphere(n)!==!1){e.getInverse(c),t.copy(r.ray).applyMatrix4(e);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),d=h*h,p=new i,f=new i;if(l.isBufferGeometry){var m=l.index,v=l.attributes,g=v.position.array;if(null!==m)for(var y=m.array,x=0,b=y.length;x 0. && v.y < .05 ) {","\t\tlifeLeft = 0.0;","\t}","\tif( v.x < - 1.45 ) {","\t\tlifeLeft = 0.0;","\t}","\tif( timeElapsed > 0.0 ) {","\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );","\t} else {","\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\t\tlifeLeft = 0.0;","\t\tgl_PointSize = 0.;","\t}","}"].join("\n"),fragmentShader:["float scaleLinear( float value, vec2 valueDomain ) {","\treturn ( value - valueDomain.x ) / ( valueDomain.y - valueDomain.x );","}","float scaleLinear( float value, vec2 valueDomain, vec2 valueRange ) {","\treturn mix( valueRange.x, valueRange.y, scaleLinear( value, valueDomain ) );","}","varying vec4 vColor;","varying float lifeLeft;","uniform sampler2D tSprite;","void main() {","\tfloat alpha = 0.;","\tif( lifeLeft > 0.995 ) {","\t\talpha = scaleLinear( lifeLeft, vec2( 1.0, 0.995 ), vec2( 0.0, 1.0 ) );","\t} else {","\t\talpha = lifeLeft * 0.75;","\t}","\tvec4 tex = texture2D( tSprite, gl_PointCoord );","\tgl_FragColor = vec4( vColor.rgb * tex.a, alpha * tex.a );","}"].join("\n")};for(r=1e5;r>0;r--)t.rand.push(Math.random()-.5);this.random=function(){return++r>=this.rand.length?this.rand[r=1]:this.rand[r]};var n=new Ue;this.particleNoiseTex=this.PARTICLE_NOISE_TEXTURE||n.load("textures/perlin-512.png"),this.particleNoiseTex.wrapS=this.particleNoiseTex.wrapT=Jl,this.particleSpriteTex=this.PARTICLE_SPRITE_TEXTURE||n.load("textures/particle2.png"),this.particleSpriteTex.wrapS=this.particleSpriteTex.wrapT=Jl,this.particleShaderMat=new pe({transparent:!0,depthWrite:!1,uniforms:{uTime:{value:0},uScale:{value:1},tNoise:{value:this.particleNoiseTex},tSprite:{value:this.particleSpriteTex}},blending:ol,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader}),this.particleShaderMat.defaultAttributeValues.particlePositionsStartTime=[0,0,0,0],this.particleShaderMat.defaultAttributeValues.particleVelColSizeLife=[0,0,0,0],this.init=function(){for(var e=this,t=0;t=this.PARTICLE_COUNT&&(this.PARTICLE_CURSOR=1);var t=this.particleContainers[Math.floor(this.PARTICLE_CURSOR/this.PARTICLES_PER_CONTAINER)];t.spawnParticle(e)},this.update=function(e){for(var t=this,r=0;r=this.PARTICLE_COUNT&&(this.PARTICLE_CURSOR=0),this.particleUpdate=!0},this.init=function(){this.particleSystem=new Et(this.particleShaderGeo,this.particleShaderMat),this.particleSystem.frustumCulled=!1,this.add(this.particleSystem)},this.update=function(e){this.time=e,this.particleShaderMat.uniforms.uTime.value=e,this.geometryUpdate()},this.geometryUpdate=function(){if(this.particleUpdate===!0){this.particleUpdate=!1;var e=this.particleShaderGeo.getAttribute("positionStart"),t=this.particleShaderGeo.getAttribute("startTime"),r=this.particleShaderGeo.getAttribute("velocity"),i=this.particleShaderGeo.getAttribute("turbulence"),n=this.particleShaderGeo.getAttribute("color"),a=this.particleShaderGeo.getAttribute("size"),o=this.particleShaderGeo.getAttribute("lifeTime"); -this.offset+this.count\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};var Up=function(e){pe.call(this,{type:"LineMaterial",uniforms:Mu.clone(vp.line.uniforms),vertexShader:vp.line.vertexShader,fragmentShader:vp.line.fragmentShader}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)};Up.prototype=Object.create(pe.prototype),Up.prototype.constructor=Up,Up.prototype.isLineMaterial=!0,Up.prototype.copy=function(e){return pe.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.resolution=e.resolution,this};var kp=function(e,t){k.call(this),this.type="LineSegments2",this.geometry=void 0!==e?e:new Rp,this.material=void 0!==t?t:new Up({color:16777215*Math.random()})};kp.prototype=Object.assign(Object.create(k.prototype),{constructor:kp,isLineSegments2:!0,computeLineDistances:function(){var e=new i,t=new i;return function(){for(var r=this.geometry,i=r.attributes.instanceStart,n=r.attributes.instanceEnd,a=new Float32Array(2*i.data.count),o=0,s=0,l=i.data.count;o=200)return void i("AssimpJSONLoader: Unsupported assimp2json file format version.")}t(n.parse(r,a))},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){function i(e,t){for(var r=this,i=new Array(e.length),n=0;n0&&n.addAttribute("normal",new M(s,3)),l.length>0&&n.addAttribute("uv",new M(l,2)),c.length>0&&n.addAttribute("color",new M(c,3)),n.computeBoundingSphere(),n}function a(e){var t=new Ee;for(var r in e.properties){var i=e.properties[r],n=i.key,a=i.value;switch(n){case"$tex.file":var o=i.semantic;if(1===o||2===o||5===o||6===o){var l;switch(o){case 1:l="map";break;case 2:l="specularMap";break;case 5:l="bumpMap";break;case 6:l="normalMap"}var c=s.load(a);c.wrapS=c.wrapT=Jl,t[l]=c}break;case"?mat.name":t.name=a;break;case"$clr.diffuse":t.color.fromArray(a);break;case"$clr.specular":t.specular.fromArray(a);break;case"$clr.emissive":t.emissive.fromArray(a);break;case"$mat.shininess":t.shininess=a;break;case"$mat.shadingm":t.flatShading=1===a;break;case"$mat.opacity":a<1&&(t.opacity=a,t.transparent=!0)}}return t}function o(e,t,i,n){var a,s,l=new c;for(l.name=t.name||"",l.matrix=(new r).fromArray(t.transformation).transpose(),l.matrix.decompose(l.position,l.quaternion,l.scale),a=0;t.meshes&&a4&&(r.length=4);for(var n=0,i=0;i<4;i++)n+=r[i].w*r[i].w;n=Math.sqrt(n);for(var i=0;i<4;i++)r[i].w=r[i].w/n,e[i]=r[i].i,t[i]=r[i].w}function d(e,t){if(0==e.name.indexOf("bone_"+t))return e;for(var r in e.children){var i=d(e.children[r],t);if(i)return i}}function p(){this.mPrimitiveTypes=0,this.mNumVertices=0,this.mNumFaces=0,this.mNumBones=0,this.mMaterialIndex=0,this.mVertices=[],this.mNormals=[],this.mTangents=[],this.mBitangents=[],this.mColors=[[]],this.mTextureCoords=[[]],this.mFaces=[],this.mBones=[],this.hookupSkeletons=function(e,t){var i=this;if(0!=this.mBones.length){for(var n=[],a=[],o=e.findNode(this.mBones[0].mName);o.mParent&&o.mParent.isBone;)o=o.mParent;var s=o.toTHREE(e),c=l(s,e);this.threeNode.add(c);for(var u=0;u0&&i.addAttribute("normal",new g(this.mNormalBuffer,3)),this.mColorBuffer&&this.mColorBuffer.length>0&&i.addAttribute("color",new g(this.mColorBuffer,4)),this.mTexCoordsBuffers[0]&&this.mTexCoordsBuffers[0].length>0&&i.addAttribute("uv",new g(new Float32Array(this.mTexCoordsBuffers[0]),2)),this.mTexCoordsBuffers[1]&&this.mTexCoordsBuffers[1].length>0&&i.addAttribute("uv1",new g(new Float32Array(this.mTexCoordsBuffers[1]),2)),this.mTangentBuffer&&this.mTangentBuffer.length>0&&i.addAttribute("tangents",new g(this.mTangentBuffer,3)),this.mBitangentBuffer&&this.mBitangentBuffer.length>0&&i.addAttribute("bitangents",new g(this.mBitangentBuffer,3)),this.mBones.length>0){for(var n=[],a=[],o=0;o0&&(d=new It(i,r)),this.threeNode=d,d}}function f(){this.mNumIndices=0,this.mIndices=[]}function m(){this.x=0,this.y=0,this.z=0,this.toTHREE=function(){return new i(this.x,this.y,this.z)}}function v(){this.r=0,this.g=0,this.b=0,this.a=0,this.toTHREE=function(){return new u(this.r,this.g,this.b,1)}}function y(){this.x=0,this.y=0,this.z=0,this.w=0,this.toTHREE=function(){return new n(this.x,this.y,this.z,this.w)}}function x(){this.mVertexId=0,this.mWeight=0}function b(){this.data=[],this.toString=function(){var e="";return this.data.forEach(function(t){e+=String.fromCharCode(t)}),e.replace(/[^\x20-\x7E]+/g,"")}}function w(){this.mTime=0,this.mValue=null}function _(){this.mTime=0,this.mValue=null}function S(){this.mName="",this.mTransformation=[],this.mNumChildren=0,this.mNumMeshes=0,this.mMeshes=[],this.mChildren=[],this.toTHREE=function(e){var t=this;if(this.threeNode)return this.threeNode;var r=new c;r.name=this.mName,r.matrix=this.mTransformation.toTHREE();for(var i=0;i0)var i=this.mAnimations[0].toTHREE(this);return{object:t,animation:i}}}function U(){this.elements=[[],[],[],[]],this.toTHREE=function(){for(var e=this,t=new r,i=0;i<4;++i)for(var n=0;n<4;++n)t.elements[4*i+n]=e.elements[n][i];return t}}function B(e){var t=e.getFloat32(e.readOffset,Ke);return e.readOffset+=4,t}function z(e){var t=e.getFloat64(e.readOffset,Ke);return e.readOffset+=8,t}function j(e){var t=e.getUint8(e.readOffset);return e.readOffset+=1,t}function V(e){var t=e.getUint16(e.readOffset,Ke);return e.readOffset+=2,t}function G(e){var t=e.getUint32(e.readOffset,Ke);return e.readOffset+=4,t}function W(e){var t=e.getUint32(e.readOffset,Ke);return e.readOffset+=4,t}function X(e){var t=new m;return t.x=B(e),t.y=B(e),t.z=B(e),t}function H(e){var t=new v;return t.r=B(e),t.g=B(e),t.b=B(e),t}function Y(e){var t=new y;return t.w=B(e),t.x=B(e),t.y=B(e),t.z=B(e),t}function q(e){var t=new b,r=G(e);return e.ReadBytes(t.data,1,r),t.toString()}function Q(e){var t=new x;return t.mVertexId=G(e),t.mWeight=B(e),t}function J(e){for(var t=new U,r=0;r<4;++r)for(var i=0;i<4;++i)t.elements[r][i]=B(e);return t}function Z(e){var t=new w;return t.mTime=z(e),t.mValue=X(e),t}function K(e){var t=new _;return t.mTime=z(e),t.mValue=Y(e),t}function $(e,t,r){for(var i=0;i0,we=V(r)>0,be)throw"Shortened binaries are not supported!";if(r.Seek(256,$e),r.Seek(128,$e),r.Seek(64,$e),!we)return me(r,t),t.toTHREE();var i=W(r),n=r.FileSize()-r.Tell(),a=[];r.Read(a,1,n);var o=[];uncompress(o,i,a,n);var s=new ArrayBuffer(o);me(s,t)}var ye=new Ue(this.manager);ye.setPath(t).setCrossOrigin(this.crossOrigin);var xe={};xe.KeyFrame=function(e,t){this.time=e,this.matrix=t.clone(),this.position=new i,this.quaternion=new n,this.scale=new i(1,1,1),this.matrix.decompose(this.position,this.quaternion,this.scale),this.clone=function(){var e=new xe.KeyFrame(this.time,this.matrix);return e},this.lerp=function(e,t){t-=this.time;var r=e.time-this.time,i=t/r,n=1-i,a=this.position,o=this.quaternion,s=e.position,l=e.quaternion;return xe.KeyFrame.tempAniPos.x=a.x*n+s.x*i,xe.KeyFrame.tempAniPos.y=a.y*n+s.y*i,xe.KeyFrame.tempAniPos.z=a.z*n+s.z*i,xe.KeyFrame.tempAniQuat.set(o.x,o.y,o.z,o.w),xe.KeyFrame.tempAniQuat.slerp(l,i),xe.KeyFrame.tempAniMatrix.compose(xe.KeyFrame.tempAniPos,xe.KeyFrame.tempAniQuat,xe.KeyFrame.tempAniScale)}},xe.KeyFrame.tempAniPos=new i,xe.KeyFrame.tempAniQuat=new n,xe.KeyFrame.tempAniScale=new i(1,1,1),xe.KeyFrame.tempAniMatrix=new r,xe.KeyFrameTrack=function(){this.keys=[],this.target=null,this.time=0,this.length=0,this._accelTable={},this.fps=20,this.addKey=function(e){this.keys.push(e)},this.init=function(){var e=this;if(this.sortKeys(),this.keys.length>0?this.length=this.keys[this.keys.length-1].time:this.length=0,this.fps)for(var t=0;t=t/e.fps){e._accelTable[t]=r;break}}},this.parseFromThree=function(e){var t=this,r=e.fps;this.target=e.node;for(var i=e.hierarchy[0].keys,n=0;ne){r=t.keys[n],i=t.keys[n+1];break}if(t.keys[n].time1)for(r=new c,m=0;m191&&n<224){var a=t._data.getUint8(t._ptr++,gf);r[i++]=String.fromCharCode((31&n)<<6|63&a)}else{var a=t._data.getUint8(t._ptr++,gf),o=t._data.getUint8(t._ptr++,gf);r[i++]=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o)}}return r.join("")}},kt.prototype=Object.assign(Object.create(c.prototype),{constructor:kt,isLight:!0,copy:function(e){return c.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=c.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Object.assign(Bt.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),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}}),zt.prototype=Object.assign(Object.create(kt.prototype),{constructor:zt,isPointLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),jt.prototype=Object.assign(Object.create(Bt.prototype),{constructor:jt}),Vt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Vt,isDirectionalLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Gt.prototype=Object.assign(Object.create(Bt.prototype),{constructor:Gt,isSpotLightShadow:!0,update:function(e){var t=this.camera,r=2*Fs.RAD2DEG*e.angle,i=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix())}}),Wt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Wt,isSpotLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),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}}),Xt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Xt,isHemisphereLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}});var xf=function(e){this.manager=void 0!==e?e:Du};xf.prototype={constructor:xf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},parse:function(e){function t(e){for(var t={},r=0,i=e.materials.length;r256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case m:case v:e.colormap_type&&console.error("TGALoader: Invalid type colormap data for colormap type.");break;case u:console.error("TGALoader: No data.");default:console.error('TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('TGALoader: Invalid pixel size "%s".',e.pixel_size)}function r(e,t,r,i,n){var a,o,s,l;if(o=r.pixel_size>>3,s=r.width*r.height*o,t&&(l=n.subarray(i,i+=r.colormap_length*(r.colormap_size>>3))),e){a=new Uint8Array(s);for(var c,u,h,d=0,p=new Uint8Array(o);d>7,e[4*(c+d*u)+1]=(992&l)>>2,e[4*(c+d*u)+2]=(31&l)>>3,e[4*(c+d*u)+3]=32768&l?0:255;return e}function a(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+1]=s[u+1],e[4*(l+h*c)+0]=s[u+2];return e}function o(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=4)e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+1]=s[u+1],e[4*(l+h*c)+0]=s[u+2],e[4*(l+h*c)+3]=s[u+3];return e}function s(e,t,r,i,n,a,o,s){var l,c,u,h=0,d=M.width;for(u=t;u!==i;u+=r)for(c=n;c!==o;c+=a,h++)l=s[h],e[4*(c+d*u)+0]=l,e[4*(c+d*u)+1]=l,e[4*(c+d*u)+2]=l,e[4*(c+d*u)+3]=255;return e}function l(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=2)e[4*(l+h*c)+0]=s[u+0],e[4*(l+h*c)+1]=s[u+0],e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+3]=s[u+1];return e}function c(e,t,r,c,u){var h,d,p,f,m,v;switch((M.flags&g)>>y){default:case w:h=0,p=1,m=t,d=0,f=1,v=r;break;case x:h=0,p=1,m=t,d=r-1,f=-1,v=-1;break;case _:h=t-1,p=-1,m=-1,d=0,f=1,v=r;break;case b:h=t-1,p=-1,m=-1,d=r-1,f=-1,v=-1}if(C)switch(M.pixel_size){case 8:s(e,d,f,v,h,p,m,c);break;case 16:l(e,d,f,v,h,p,m,c);break;default:console.error("TGALoader: Format not supported.")}else switch(M.pixel_size){case 8:i(e,d,f,v,h,p,m,c,u);break;case 16:n(e,d,f,v,h,p,m,c);break;case 24:a(e,d,f,v,h,p,m,c);break;case 32:o(e,d,f,v,h,p,m,c);break;default:console.error("TGALoader: Format not supported.")}return e}var u=0,h=1,d=2,p=3,f=9,m=10,v=11,g=48,y=4,x=0,b=1,w=2,_=3;e.length<19&&console.error("TGALoader: Not enough data to contain header.");var S=new Uint8Array(e),A=0,M={id_length:S[A++],colormap_type:S[A++],image_type:S[A++],colormap_index:S[A++]|S[A++]<<8,colormap_length:S[A++]|S[A++]<<8,colormap_size:S[A++],origin:[S[A++]|S[A++]<<8,S[A++]|S[A++]<<8],width:S[A++]|S[A++]<<8,height:S[A++]|S[A++]<<8,pixel_size:S[A++],flags:S[A++]};t(M),M.id_length+A>e.length&&console.error("TGALoader: No data."),A+=M.id_length;var T=!1,E=!1,C=!1;switch(M.image_type){case f:T=!0,E=!0;break;case h:E=!0;break;case m:T=!0;break;case d:break;case v:T=!0,C=!0;break;case p:C=!0}var L=document.createElement("canvas");L.width=M.width,L.height=M.height;var P=L.getContext("2d"),N=P.createImageData(M.width,M.height),O=r(T,E,M,A,S);c(N.data,M.width,M.height,O.pixel_data,O.palettes);return P.putImageData(N,0,0),L},setPath:function(e){return this.path=e,this}};var _f=function(e){this.manager=void 0!==e?e:Du};_f.prototype={constructor:_f,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=void 0===n.path?Iu.extractUrlBase(e):n.path,o=new we(n.manager);o.load(e,function(e){t(n.parse(e,a))},r,i)},setPath:function(e){return this.path=e,this},options:{set convertUpAxis(e){console.warn("ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.")}},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){function a(e,t){for(var r=[],i=e.childNodes,n=0,a=i.length;n0&&t.push(new te(i+".position",n,a)),o.length>0&&t.push(new $(i+".quaternion",n,o)),s.length>0&&t.push(new te(i+".scale",n,s)),t}function L(e,t,r){var i,n,a,o=!0;for(n=0,a=e.length;n=0;){var i=e[t];if(null!==i.value[r])return i;t--}return null}function D(e,t,r){for(;t>>0)+2);switch(r=r.toLowerCase()){case"tga":t=Xt;break;default:t=Gt}return t}function _e(e){function t(e){var t=i.profile.samplers[e.id],r=null;if(void 0!==t){var n=i.profile.surfaces[t.source];r=Z(n.init_from)}else console.warn("ColladaLoader: Undefined sampler. Access image directly (see #12530)."),r=Z(e.id);if(null!==r){var a=we(r);if(void 0!==a){var o=a.load(r),s=e.extra;if(void 0!==s&&void 0!==s.technique&&p(s.technique)===!1){var l=s.technique;o.wrapS=l.wrapU?Jl:Zl,o.wrapT=l.wrapV?Jl:Zl,o.offset.set(l.offsetU||0,l.offsetV||0),o.repeat.set(l.repeatU||1,l.repeatV||1)}else o.wrapS=Jl,o.wrapT=Jl;return o}return console.warn("ColladaLoader: Loader for texture %s not found.",r),null}return console.warn("ColladaLoader: Couldn't create texture with ID:",e.id),null}var r,i=xe(e.url),n=i.profile.technique,a=i.profile.extra;switch(n.type){case"phong":case"blinn":r=new Ee;break;case"lambert":r=new Me;break;default:r=new F}r.name=e.name;var o=n.parameters;for(var s in o){var l=o[s];switch(s){case"diffuse":l.color&&r.color.fromArray(l.color),l.texture&&(r.map=t(l.texture));break;case"specular":l.color&&r.specular&&r.specular.fromArray(l.color),l.texture&&(r.specularMap=t(l.texture));break;case"shininess":l["float"]&&r.shininess&&(r.shininess=l["float"]);break;case"emission":l.color&&r.emissive&&r.emissive.fromArray(l.color),l.texture&&(r.emissiveMap=t(l.texture))}}var c=o.transparent,u=o.transparency;if(void 0===u&&c&&(u={"float":1}),void 0===c&&u&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&u)if(c.data.texture)r.transparent=!0;else{var h=c.data.color;switch(c.opaque){case"A_ONE":r.opacity=h[3]*u["float"];break;case"RGB_ZERO":r.opacity=1-h[0]*u["float"];break;case"A_ZERO":r.opacity=1-h[3]*u["float"];break;case"RGB_ONE":r.opacity=h[0]*u["float"];break;default:console.warn('ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}r.opacity<1&&(r.transparent=!0)}return void 0!==a&&void 0!==a.technique&&1===a.technique.double_sided&&(r.side=Ks),r}function Se(e){return x(Zt.materials[e],_e)}function Ae(e){for(var t={name:e.getAttribute("name")},r=0,i=e.childNodes.length;r0&&t0&&u.addAttribute("position",new M(n.array,n.stride)),a.array.length>0&&u.addAttribute("normal",new M(a.array,a.stride)),s.array.length>0&&u.addAttribute("color",new M(s.array,s.stride)),o.array.length>0&&u.addAttribute("uv",new M(o.array,o.stride)),l.array.length>0&&u.addAttribute("skinIndex",new M(l.array,l.stride)),c.array.length>0&&u.addAttribute("skinWeight",new M(c.array,c.stride)),i.data=u,i.type=e[0].type,i.materialKeys=h,i}function He(e,t,r,i){function n(e){for(var t=a[e+r]*c,n=t+c;t4)for(var y=1,x=p-2;y<=x;y++){var f=u+0*o,m=u+o*y,v=u+o*(y+1);n(f),n(m),n(v)}u+=o*p}else for(var h=0,d=a.length;h=t.limits.max&&(t["static"]=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function et(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},r=0;ri.limits.max||t>8&255,e>>16&255,e>>24&255)}function n(e,t,r,i){for(var n=r*i*4,a=new Uint8Array(e,t,n),o=new Uint8Array(n),s=0,l=0,c=0;c>1,1),W=Math.max(W>>1,1)}return a},Jt.prototype=Object.assign(Object.create(B.prototype),{constructor:Jt,isLineLoop:!0});var Af=function(){function e(e){this.manager=void 0!==e?e:Du}function t(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}},update:function(t,r){for(var i in e){var n=e[i];n.update&&n.update(t,r)}}}}function n(e,t){var i={},n=e.material.uniforms;for(var a in n){var o=n[a];if(o.semantic){var s=o.node,l=e;s&&(l=t[s]),i[a]={semantic:o.semantic,sourceNode:l,targetNode:e,uniform:o}}}this.boundUniforms=i,this._m4=new r}function a(e){var t=this;this.name=x.KHR_MATERIALS_COMMON,this.lights={};var r=e.extensions&&e.extensions[x.KHR_MATERIALS_COMMON]||{},i=r.lights||{};for(var n in i){var a,o=i[n],s=o[o.type],l=(new u).fromArray(s.color);switch(o.type){case"directional":a=new Vt(l),a.position.set(0,0,1);break;case"point":a=new zt(l);break;case"spot":a=new Wt(l),a.position.set(0,0,1);break;case"ambient":a=new Ht(l)}a&&(t.lights[n]=a)}}function o(e){this.name=x.KHR_BINARY_GLTF;var t=new DataView(e,0,_),r={magic:Iu.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0),contentLength:t.getUint32(12,!0),contentFormat:t.getUint32(16,!0)};for(var i in w){var n=w[i];if(r[i]!==n)throw new Error('Unsupported glTF-Binary header: Expected "%s" to be "%s".',i,n)}var a=new Uint8Array(e,_,r.contentLength);this.header=r,this.content=Iu.decodeText(a),this.body=e.slice(_+r.contentLength,r.length)}function s(e,t,r){var i=this;if(!e)return Promise.resolve();var n,a=[];if("[object Array]"===Object.prototype.toString.call(e)){n=[];for(var o=e.length,s=0;s=0&&(n[x.KHR_MATERIALS_COMMON]=new a(l));var c=new y(l,n,{crossOrigin:this.crossOrigin,manager:this.manager,path:t||this.path});c.parse(function(e,t,i,n){var a={scene:e,scenes:t,cameras:i,animations:n};r(a)})}},e.Shaders={update:function(){console.warn("LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},n.prototype.update=function(e,t){var r=this,i=this.boundUniforms;for(var n in i){var a=i[n];switch(a.semantic){case"MODELVIEW":var o=a.uniform.value;o.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var s=a.uniform.value;r._m4.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld),s.getNormalMatrix(r._m4);break;case"PROJECTION":var o=a.uniform.value;o.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var l=a.uniform.value,c=0;c0&&console.log("Loaded a mesh.");else{if(s!=t.POINT_CLOUD){var l="DRACOLoader: Unknown geometry type.";throw console.error(l),new Error(l)}this.verbosity>0&&console.log("Loaded a point cloud.")}r(this.convertDracoGeometryTo3JS(t,o,s,a,i,n))},addAttributeToGeometry:function(e,t,r,i,n,a,o,s){if(0===a.ptr){var l="DRACOLoader: No attribute "+i;throw console.error(l),new Error(l)}var c,u,h=a.num_components(),d=r.num_points(),p=d*h;switch(n){case Float32Array:c=new e.DracoFloat32Array,t.GetAttributeFloatForAllPoints(r,a,c),s[i]=new Float32Array(p),u=M;break;case Int8Array:c=new e.DracoInt8Array,t.GetAttributeInt8ForAllPoints(r,a,c),s[i]=new Int8Array(p),u=y;break;case Int16Array:c=new e.DracoInt16Array,t.GetAttributeInt16ForAllPoints(r,a,c),s[i]=new Int16Array(p),u=w;break;case Int32Array:c=new e.DracoInt32Array,t.GetAttributeInt32ForAllPoints(r,a,c),s[i]=new Int32Array(p),u=S;break;case Uint8Array:c=new e.DracoUInt8Array,t.GetAttributeUInt8ForAllPoints(r,a,c),s[i]=new Uint8Array(p),u=x;break;case Uint16Array:c=new e.DracoUInt16Array,t.GetAttributeUInt16ForAllPoints(r,a,c),s[i]=new Uint16Array(p),u=_;break;case Uint32Array:c=new e.DracoUInt32Array,t.GetAttributeUInt32ForAllPoints(r,a,c),s[i]=new Uint32Array(p),u=A;break;default:var l="DRACOLoader: Unexpected attribute type.";throw console.error(l),new Error(l)}for(var f=0;f0&&console.log("Number of faces loaded: "+d.toString())):d=0;var p=s.num_points(),f=s.num_attributes();this.verbosity>0&&(console.log("Number of points loaded: "+p.toString()),console.log("Number of attributes loaded: "+f.toString()));var m=t.GetAttributeId(s,e.POSITION);if(m==-1){var u="DRACOLoader: No position attribute found.";throw console.error(u),e.destroy(t),e.destroy(s),new Error(u)}var v=t.GetAttribute(s,m),g={},y=new P;for(var x in o.nativeAttributeMap)if(void 0===n[x]){var b=t.GetAttributeId(s,e[o.nativeAttributeMap[x]]);if(b!==-1){o.verbosity>0&&console.log("Loaded "+x+" attribute.");var w=t.GetAttribute(s,b);o.addAttributeToGeometry(e,t,s,x,Float32Array,w,y,g)}}for(var x in n){var S=a[x]||Float32Array,M=n[x],w=t.GetAttributeByUniqueId(s,M);o.addAttributeToGeometry(e,t,s,x,S,w,y,g)}if(r==e.TRIANGULAR_MESH)if(this.drawMode===nu){var T=new e.DracoInt32Array;t.GetTriangleStripsFromMesh(s,T);g.indices=new Uint32Array(T.size());for(var E=0;E65535?A:_)(g.indices,1));var O=new e.AttributeQuantizationTransform;if(O.InitFromAttribute(v)){y.attributes.position.isQuantized=!0,y.attributes.position.maxRange=O.range(),y.attributes.position.numQuantizationBits=O.quantization_bits(),y.attributes.position.minValues=new Float32Array(3);for(var E=0;E<3;++E)y.attributes.position.minValues[E]=O.min_value(E)}return e.destroy(O),e.destroy(t),e.destroy(s),this.decode_time=h-c,this.import_time=performance.now()-h,this.verbosity>0&&(console.log("Decode time: "+this.decode_time),console.log("Import time: "+this.import_time)),y},isVersionSupported:function(e,t){Mf.getDecoderModule().then(function(r){t(r.decoder.isVersionSupported(e))})},getAttributeOptions:function(e){return"undefined"==typeof this.attributeOptions[e]&&(this.attributeOptions[e]={}),this.attributeOptions[e]}},Mf.decoderPath="./",Mf.decoderConfig={},Mf.decoderModulePromise=null,Mf.setDecoderPath=function(e){Mf.decoderPath=e},Mf.setDecoderConfig=function(e){var t=Mf.decoderConfig.wasmBinary;Mf.decoderConfig=e||{},Mf.releaseDecoderModule(),t&&(Mf.decoderConfig.wasmBinary=t)},Mf.releaseDecoderModule=function(){Mf.decoderModulePromise=null},Mf.getDecoderModule=function(){var e=this,t=Mf.decoderPath,r=Mf.decoderConfig,i=Mf.decoderModulePromise;return i?i:("undefined"!=typeof DracoDecoderModule?i=Promise.resolve():"object"!=typeof WebAssembly||"js"===r.type?i=Mf._loadScript(t+"draco_decoder.js"):(r.wasmBinaryFile=t+"draco_decoder.wasm",i=Mf._loadScript(t+"draco_wasm_wrapper.js").then(function(){return Mf._loadArrayBuffer(r.wasmBinaryFile)}).then(function(e){r.wasmBinary=e})),i=i.then(function(){return new Promise(function(t){r.onModuleLoaded=function(r){e.timeLoaded=performance.now(),t({decoder:r})},DracoDecoderModule(r)})}),Mf.decoderModulePromise=i,i)},Mf._loadScript=function(e){var t=document.getElementById("decoder_script");null!==t&&t.parentNode.removeChild(t);var r=document.getElementsByTagName("head")[0],i=document.createElement("script");return i.id="decoder_script",i.type="text/javascript",i.src=e,new Promise(function(e){i.onload=e,r.appendChild(i)})},Mf._loadArrayBuffer=function(e){var t=new we;return t.setResponseType("arraybuffer"),new Promise(function(r,i){t.load(e,r,void 0,i)})},Zt.prototype=Object.create(ge.prototype),Zt.prototype.constructor=Zt,Zt.prototype.isWebGLRenderTargetCube=!0;var Tf=function(e,t){this.sourceTexture=e,this.resolution=t.resolution||512,this.views=[{t:[1,0,0],u:[0,-1,0]},{t:[-1,0,0],u:[0,-1,0]},{t:[0,1,0],u:[0,0,1]},{t:[0,-1,0],u:[0,0,-1]},{t:[0,0,1],u:[0,-1,0]},{t:[0,0,-1],u:[0,-1,0]}],this.camera=new de(90,1,.1,10),this.boxMesh=new k(new le(1,1,1),this.getShader()),this.boxMesh.material.side=Zs,this.scene=new fe,this.scene.add(this.boxMesh);var r={format:t.format||this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:t.type||this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.renderTarget=new Zt(this.resolution,this.resolution,r)};Tf.prototype={constructor:Tf,update:function(e){for(var t=this,r=0;r<6;r++){t.renderTarget.activeCubeFace=r;var i=t.views[r];t.camera.position.set(0,0,0),t.camera.up.set(i.u[0],i.u[1],i.u[2]),t.camera.lookAt(i.t[0],i.t[1],i.t[2]),e.render(t.scene,t.camera,t.renderTarget,!0)}return this.renderTarget.texture},getShader:function(){var e=new pe({uniforms:{equirectangularMap:{value:this.sourceTexture}},vertexShader:"varying vec3 localPosition;\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tlocalPosition = position;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec3 localPosition;\n\t\t\t\tuniform sampler2D equirectangularMap;\n\t\t\t\t\n\t\t\t\tvec2 EquirectangularSampleUV(vec3 v) {\n\t\t\t vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n\t\t\t uv *= vec2(0.1591, 0.3183); // inverse atan\n\t\t\t uv += 0.5;\n\t\t\t return uv;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 uv = EquirectangularSampleUV(normalize(localPosition));\n \t\t\tvec3 color = texture2D(equirectangularMap, uv).rgb;\n \t\t\t\n\t\t\t\t\tgl_FragColor = vec4( color, 1.0 );\n\t\t\t\t}",blending:nl});return e.type="EquirectangularToCubeGenerator",e},dispose:function(){this.boxMesh.geometry.dispose(),this.boxMesh.material.dispose(),this.renderTarget.dispose()}},Object.assign(Kt.prototype,{load:function(e,t,r,i){var n=this,a=new Mt,o=new we(this.manager);return o.setResponseType("arraybuffer"),o.load(e,function(e){var r=n._parser(e);r&&(void 0!==r.image?a.image=r.image:void 0!==r.data&&(a.image.width=r.width,a.image.height=r.height,a.image.data=r.data),a.wrapS=void 0!==r.wrapS?r.wrapS:Zl,a.wrapT=void 0!==r.wrapT?r.wrapT:Zl,a.magFilter=void 0!==r.magFilter?r.magFilter:rc,a.minFilter=void 0!==r.minFilter?r.minFilter:nc,a.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,void 0!==r.format&&(a.format=r.format),void 0!==r.type&&(a.type=r.type),void 0!==r.mipmaps&&(a.mipmaps=r.mipmaps),1===r.mipmapCount&&(a.minFilter=rc),a.needsUpdate=!0,t&&t(a,r))},r,i),a}});var Ef=function(e){this.manager=void 0!==e?e:Du};Ef.prototype=Object.create(Kt.prototype),Ef.prototype._parser=function(e){function t(e,t){for(var r=0,i=0;i>3]&1<<(7&i))&&(t[r++]=i);for(var n=r-1;r>r&(1<0;--t){var i=r+$[t]>>1;$[t]=r,r=i}for(var t=0;t0&&(e[t]=n|$[n]++<<6)}}function a(e,t,r,a,o,s,l){for(var c=r,u=0,h=0;o<=s;o++){if(c.value-r.value>a)return!1;i(6,u,h,e,c);var d=K.l;if(u=K.c,h=K.lc,l[o]=d,d==W){if(c.value-r.value>a)throw"Something wrong with hufUnpackEncTable";i(8,u,h,e,c);var p=K.l+X;if(u=K.c,h=K.lc,o+p>s+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[o++]=0;o--}else if(d>=G){var p=d-G+2;if(o+p>s+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[o++]=0;o--}}n(l)}function o(e){return 63&e}function s(e){return e>>6}function l(e,t,r,i){for(;t<=r;t++){var n=s(e[t]),a=o(e[t]);if(n>>a)throw"Invalid table entry";if(a>B){var l=i[n>>a-B];if(l.len)throw"Invalid table entry";if(l.lit++,l.p){var c=l.p;l.p=new Array(l.lit);for(var u=0;u0;u--){var l=i[(n<>i,h=new Uint8Array([h])[0];if(l.value+h>u)return!1;for(var d=s[l.value-1];h-- >0;)s[l.value++]=d}else{if(!(l.value32767?t-65536:t}function p(e,t){var r=d(e),i=d(t),n=i,a=r+(1&n)+(n>>1),o=a,s=a-n;re.a=o,re.b=s}function f(e,t,r,i,n,a,o){for(var s,l=r>n?n:r,c=1;c<=l;)c<<=1;for(c>>=1,s=c,c>>=1;c>=1;){for(var u,h,d,f,m=0,v=m+a*(n-s),g=a*c,y=a*s,x=i*c,b=i*s;m<=v;m+=y){for(var w=m,_=m+i*(r-s);w<=_;w+=b){var S=w+x,A=w+g,M=A+x;p(t[w+e],t[A+e]),u=re.a,d=re.b,p(t[S+e],t[M+e]),h=re.a,f=re.b,p(u,h),t[w+e]=re.a,t[S+e]=re.b,p(d,f),t[A+e]=re.a,t[M+e]=re.b}if(r&c){var A=w+g;p(t[w+e],t[A+e]),u=re.a,t[A+e]=re.b,t[w+e]=u}}if(n&c)for(var w=m,_=m+i*(r-s);w<=_;w+=b){var S=w+x;p(t[w+e],t[S+e]),u=re.a,t[S+e]=re.b,t[w+e]=u}s=c,c>>=1}return m}function m(e,t,r,i,n,a,l,h,d,p){for(var f=0,m=0,v=h,g=Math.trunc(n.value+(a+7)/8);n.value=B;){var y=f>>m-B&V,x=t[y];if(x.len)m-=x.len,u(x.lit,l,f,m,r,i,n,d,p,v),f=te.c,m=te.lc;else{if(!x.p)throw"hufDecode issues";var b;for(b=0;b=w&&s(e[x.p[b]])==(f>>m-w&(1<>=_,m-=_;m>0;){var x=t[f<=z||d<0||d>=z)throw"Something wrong with HUF_ENCSIZE";var f=new Array(z),v=new Array(j);r(v);var g=n-(i.value-u);if(a(e,t,i,g,h,d,f),p>8*(n-(i.value-u)))throw"Something wrong with hufUncompress";l(f,h,d,v),m(f,v,e,t,i,p,d,c,o,s)}function g(e,t,r){for(var i=0;i=U)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(d<=p)for(var m=0;m>10,r=1023&e;return(e>>15?-1:1)*(t?31===t?r?NaN:1/0:Math.pow(2,t-15)*(1+r/1024):6103515625e-14*(r/1024))}function E(e,t){var r=e.getUint16(t.value,!0);return t.value+=J,r}function C(e,t){return T(E(e,t))}function L(e,t,r,i){for(var n=r.value,a=[];r.value>3,k=16,B=14,z=(1<=t.length&&t===E(e,0,t.length)}function y(e){function t(t){var r=e[t-1];return e=e.slice(i+t),i++,r}for(var r=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],i=0,n=0;n0,l="string"==typeof a.Content&&""!==a.Content;if(s||l){var c=e.parseImage(i[n]);r[a.RelativeFilename||a.Filename]=c}}}}for(var o in t){var u=t[o];void 0!==r[u]?t[o]=r[u]:t[o]=t[o].split("\\").pop()}return t},parseImage:function(e){var t,r=e.Content,i=e.RelativeFilename||e.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(n){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":if("function"!=typeof wf)return void console.warn("FBXLoader: TGALoader is required to load TGA textures");null===Loader.Handlers.get(".tga")&&Loader.Handlers.add(/\.tga$/i,new wf),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof r)return"data:"+t+";base64,"+r;var a=new Uint8Array(r);return Ds.URL.createObjectURL(new Blob([a],{type:t}))},parseTextures:function(e){var t=this,r=new Map;if("Texture"in O.Objects){var i=O.Objects.Texture;for(var n in i){var a=t.parseTexture(i[n],e);r.set(parseInt(n),a)}}return r},parseTexture:function(e,t){var r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;var i=e.WrapModeU,n=e.WrapModeV,a=void 0!==i?i.value:0,o=void 0!==n?n.value:0;if(r.wrapS=0===a?Jl:Zl,r.wrapT=0===o?Jl:Zl,"Scaling"in e){var s=e.Scaling.value;r.repeat.x=s[0],r.repeat.y=s[1]}return r},loadTexture:function(e,t){var r,i=this.textureLoader.path,n=D.get(e.id).children;void 0!==n&&n.length>0&&void 0!==t[n[0].ID]&&(r=t[n[0].ID],0!==r.indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));var a,o=e.FileName.slice(-3).toLowerCase();if("tga"===o){var s=Loader.Handlers.get(".tga");null===s?(console.warn("FBXLoader: TGALoader not found, creating empty placeholder texture for",r),a=new ve):a=s.load(r)}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating empty placeholder texture for",r),a=new ve):a=this.textureLoader.load(r);return this.textureLoader.setPath(i),a},parseMaterials:function(e){var t=this,r=new Map;if("Material"in O.Objects){var i=O.Objects.Material;for(var n in i){var a=t.parseMaterial(i[n],e);null!==a&&r.set(parseInt(n),a)}}return r},parseMaterial:function(e,t){var r=e.id,i=e.attrName,n=e.ShadingModel;if("object"==typeof n&&(n=n.value),!D.has(r))return null;var a,o=this.parseParameters(e,t,r);switch(n.toLowerCase()){case"phong":a=new Ee;break;case"lambert":a=new Me;break;default:console.warn('FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',n),a=new Ee({color:3342591})}return a.setValues(o),a.name=i,a},parseParameters:function(e,t,r){var i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new u).fromArray(e.Diffuse.value):e.DiffuseColor&&"Color"===e.DiffuseColor.type&&(i.color=(new u).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new u).fromArray(e.Emissive.value):e.EmissiveColor&&"Color"===e.EmissiveColor.type&&(i.emissive=(new u).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new u).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new u).fromArray(e.SpecularColor.value));var n=this;return D.get(r).children.forEach(function(e){var r=e.relationship;switch(r){case"Bump":i.bumpMap=n.getTexture(t,e.ID);break;case"DiffuseColor":i.map=n.getTexture(t,e.ID);break;case"DisplacementColor":i.displacementMap=n.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=n.getTexture(t,e.ID);break;case"NormalMap":i.normalMap=n.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=n.getTexture(t,e.ID),i.envMap.mapping=Xl;break;case"SpecularColor":i.specularMap=n.getTexture(t,e.ID);break;case"TransparentColor":i.alphaMap=n.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("FBXLoader: %s map is not supported in three.js, skipping texture.",r)}}),i},getTexture:function(e,t){return"LayeredTexture"in O.Objects&&t in O.Objects.LayeredTexture&&(console.warn("FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=D.get(t).children[0].ID),e.get(t)},parseDeformers:function(){var e=this,t={},r={};if("Deformer"in O.Objects){var i=O.Objects.Deformer;for(var n in i){var a=i[n],o=D.get(parseInt(n));if("Skin"===a.attrType){var s=e.parseSkeleton(o,i);s.ID=n,o.parents.length>1&&console.warn("FBXLoader: skeleton attached to more than one geometry is not supported."),s.geometryID=o.parents[0].ID,t[n]=s}else if("BlendShape"===a.attrType){var l={id:n};l.rawTargets=e.parseMorphTargets(o,i),l.id=n,o.parents.length>1&&console.warn("FBXLoader: morph target attached to more than one geometry is not supported."),r[n]=l}}}return{skeletons:t,morphTargets:r}},parseSkeleton:function(e,t){var i=[];return e.children.forEach(function(e){var n=t[e.ID];if("Cluster"===n.attrType){var a={ID:e.ID,indices:[],weights:[],transform:(new r).fromArray(n.Transform.a),transformLink:(new r).fromArray(n.TransformLink.a),linkMode:n.Mode};"Indexes"in n&&(a.indices=n.Indexes.a,a.weights=n.Weights.a),i.push(a)}}),{rawBones:i,bones:[]}},parseMorphTargets:function(e,t){for(var r=[],i=0;i1?a=o:o.length>0?a=o[0]:(a=new Ee({color:13421772}),o.push(a)),"color"in n.attributes&&o.forEach(function(e){e.vertexColors=il}),n.FBX_Deformer?(o.forEach(function(e){e.skinning=!0}),i=new It(n,a)):i=new k(n,a),i},createCurve:function(e,t){var r=e.children.reduce(function(e,r){return t.has(r.ID)&&(e=t.get(r.ID)),e},null),i=new I({color:3342591,linewidth:1});return new B(r,i)},setModelTransforms:function(e,t){var r={};"RotationOrder"in t&&(r.eulerOrder=parseInt(t.RotationOrder.value)),"Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value);var i=S(r);e.applyMatrix(i)},setLookAtProperties:function(e,t){if("LookAtProperty"in t){var r=D.get(e.ID).children;r.forEach(function(t){if("LookAtProperty"===t.relationship){var r=O.Objects.Model[t.ID];if("Lcl_Translation"in r){var n=r.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(n),F.add(e.target)):e.lookAt((new i).fromArray(n))}}})}},bindSkeleton:function(e,t,r){var i=this.parsePoseNodes();for(var n in e){var a=e[n],o=D.get(parseInt(a.ID)).parents;o.forEach(function(e){if(t.has(e.ID)){var n=e.ID,o=D.get(n);o.parents.forEach(function(e){if(r.has(e.ID)){var t=r.get(e.ID);t.bind(new Ft(a.bones),i[e.ID])}})}})}},parsePoseNodes:function(){var e={};if("Pose"in O.Objects){var t=O.Objects.Pose;for(var i in t)if("BindPose"===t[i].attrType){var n=t[i].PoseNode;Array.isArray(n)?n.forEach(function(t){e[t.Node]=(new r).fromArray(t.Matrix.a)}):e[n.Node]=(new r).fromArray(n.Matrix.a)}}return e},createAmbientLight:function(){if("GlobalSettings"in O&&"AmbientColor"in O.GlobalSettings){var e=O.GlobalSettings.AmbientColor.value,t=e[0],r=e[1],i=e[2];if(0!==t||0!==r||0!==i){var n=new u(t,r,i);F.add(new Ht(n,1))}}},setupMorphMaterials:function(){F.traverse(function(e){if(e.isMesh&&(e.geometry.morphAttributes.position||e.geometry.morphAttributes.normal)){var t=e.uuid,r=e.material.uuid,i=!1;F.traverse(function(e){e.isMesh&&e.material.uuid===r&&e.uuid!==t&&(i=!0)}),i===!0&&(e.material=e.material.clone()),e.material.morphTargets=!0}})}},a.prototype={constructor:a,parse:function(e){var t=this,r=new Map;if("Geometry"in O.Objects){var i=O.Objects.Geometry;for(var n in i){var a=D.get(parseInt(n)),o=t.parseGeometry(a,i[n],e);r.set(parseInt(n),o)}}return r},parseGeometry:function(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(e,t,r){var i=r.skeletons,n=r.morphTargets,a=e.parents.map(function(e){return O.Objects.Model[e.ID]});if(0!==a.length){var o=e.children.reduce(function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e},null),s=e.children.reduce(function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e},null),l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=l.RotationOrder.value),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);var u=S(c);return this.genGeometry(t,o,s,u)}},genGeometry:function(e,t,r,i){var n=new P;e.attrName&&(n.name=e.attrName);var a=this.parseGeoNode(e,t),o=this.genBuffers(a),s=new M(o.vertex,3);if(i.applyToBufferAttribute(s),n.addAttribute("position",s),o.colors.length>0&&n.addAttribute("color",new M(o.colors,3)),t&&(n.addAttribute("skinIndex",new _(o.weightsIndices,4)),n.addAttribute("skinWeight",new M(o.vertexWeights,4)),n.FBX_Deformer=t),o.normal.length>0){var c=new M(o.normal,3),u=(new l).getNormalMatrix(i);u.applyToBufferAttribute(c),n.addAttribute("normal",c)}if(o.uvs.forEach(function(e,t){var r="uv"+(t+1).toString();0===t&&(r="uv"),n.addAttribute(r,new M(o.uvs[t],2))}),a.material&&"AllSame"!==a.material.mappingType){var h=o.materialIndex[0],d=0;if(o.materialIndex.forEach(function(e,t){e!==h&&(n.addGroup(d,t-d,h),h=e,d=t)}),n.groups.length>0){var p=n.groups[n.groups.length-1],f=p.start+p.count;f!==o.materialIndex.length&&n.addGroup(f,o.materialIndex.length-f,h)}0===n.groups.length&&n.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(n,e,r,i),n},parseGeoNode:function(e,t){var r=this,i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];for(var n=0;e.LayerElementUV[n];)i.uv.push(r.parseUVs(e.LayerElementUV[n])),n++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,n){void 0===i.weightTable[r]&&(i.weightTable[r]=[]),i.weightTable[r].push({id:t,weight:e.weights[n]})})})),i},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},r=0,i=0,n=!1,a=[],o=[],s=[],l=[],c=[],u=[],h=this;return e.vertexIndices.forEach(function(d,p){var f=!1;d<0&&(d^=-1,f=!0);var m=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){var g=w(p,r,d,e.color);s.push(g[0],g[1],g[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach(function(e){v.push(e.weight),m.push(e.id)}),v.length>4){n||(console.warn("FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),n=!0);var y=[0,0,0,0],x=[0,0,0,0];v.forEach(function(e,t){var r=e,i=m[t];x.forEach(function(e,t,n){if(r>e){n[t]=r,r=e;var a=y[t];y[t]=i,i=a}})}),m=y,v=x}for(;v.length<4;)v.push(0),m.push(0);for(var b=0;b<4;++b)c.push(v[b]),u.push(m[b])}if(e.normal){var g=w(p,r,d,e.normal);o.push(g[0],g[1],g[2])}if(e.material&&"AllSame"!==e.material.mappingType)var _=w(p,r,d,e.material)[0];e.uv&&e.uv.forEach(function(e,t){var i=w(p,r,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])}),i++,f&&(h.genFace(t,e,a,_,o,s,l,c,u,i),r++,i=0,a=[],o=[],s=[],l=[],c=[],u=[])}),t},genFace:function(e,t,r,i,n,a,o,s,l,c){for(var u=2;u1&&console.warn("FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var a=e.get(n[0].ID);r[i]={name:t[i].attrName,layer:a}}return r},addClip:function(e){var t=[],r=this;return e.layer.forEach(function(e){t=t.concat(r.generateTracks(e))}),new re(e.name,(-1),t)},generateTracks:function(e){var t=[],r=new i,a=new n,s=new i;if(e.transform&&e.transform.decompose(r,a,s),r=r.toArray(),a=(new o).setFromQuaternion(a).toArray(),s=s.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var l=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");void 0!==l&&t.push(l)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var c=this.generateRotationTrack(e.modelName,e.R.curves,a,e.preRotations,e.postRotations);void 0!==c&&t.push(c)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var u=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");void 0!==u&&t.push(u)}if(void 0!==e.DeformPercent){var h=this.generateMorphTrack(e);void 0!==h&&t.push(h)}return t},generateVectorTrack:function(e,t,r,i){var n=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(n,t,r);return new te(e+"."+i,n,a)},generateRotationTrack:function(e,t,r,i,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Fs.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Fs.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Fs.degToRad));var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,r);void 0!==i&&(i=i.map(Fs.degToRad),i.push("ZYX"),i=(new o).fromArray(i),i=(new n).setFromEuler(i)),void 0!==a&&(a=a.map(Fs.degToRad),a.push("ZYX"),a=(new o).fromArray(a),a=(new n).setFromEuler(a).inverse());for(var c=new n,u=new o,h=[],d=0;d=180){for(var a=n/180,o=i/a,s=r+o,l=e.times[t-1],c=e.times[t]-l,u=c/a,h=l+u,d=[],p=[];h1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r,type:i}},parseNodeProperty:function(e,t,r){var i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),n=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===n&&(n=r.replace(/"/g,"").replace(/,$/,"").trim());var a=this.getCurrentNode(),o=a.name;if("Properties70"===o)return void this.parseNodeSpecialProperty(e,i,n);if("C"===i){var s=n.split(",").slice(1),l=parseInt(s[0]),c=parseInt(s[1]),u=n.split(",").slice(3);u=u.map(function(e){return e.trim().replace(/^"/,"")}),i="connections",n=[l,c],C(n,u),void 0===a[i]&&(a[i]=[])}"Node"===i&&(a.id=n),i in a&&Array.isArray(a[i])?a[i].push(n):"a"!==i?a[i]=n:a.a=n,this.setCurrentProp(a,i),"a"===i&&","!==n.slice(-1)&&(a.a=T(n))},parseNodePropertyContinued:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=T(t.a))},parseNodeSpecialProperty:function(e,t,r){var i=r.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),n=i[0],a=i[1],o=i[2],s=i[3],l=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=T(l)}this.getPrevNode()[n]={type:a,type2:o,flag:s,value:l},this.setCurrentProp(this.getPrevNode(),n)}},d.prototype={constructor:d,parse:function(e){var t=this,r=new p(e);r.skip(23);var i=r.getUint32();console.log("FBXLoader: FBX binary version: "+i);for(var n=new f;!this.endOfContent(r);){var a=t.parseNode(r,i);null!==a&&n.add(a.name,a)}return n},endOfContent:function(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var r=this,i={},n=t>=7500?e.getUint64():e.getUint32(),a=t>=7500?e.getUint64():e.getUint32(),o=(t>=7500?e.getUint64():e.getUint32(),e.getUint8()),s=e.getString(o);if(0===n)return null;for(var l=[],c=0;c0?l[0]:"",h=l.length>1?l[1]:"",d=l.length>2?l[2]:"";for(i.singleProperty=1===a&&e.getOffset()===n;n>e.getOffset();){var p=r.parseNode(e,t);null!==p&&r.parseSubNode(s,i,p)}return i.propertyList=l,"number"==typeof u&&(i.id=u),""!==h&&(i.attrName=h),""!==d&&(i.attrType=d),""!==s&&(i.name=s),i},parseSubNode:function(e,t,r){if(r.singleProperty===!0){var i=r.propertyList[0];Array.isArray(i)?(t[r.name]=r,r.a=i):t[r.name]=i}else if("Connections"===e&&"C"===r.name){var n=[];r.propertyList.forEach(function(e,t){0!==t&&n.push(e)}),void 0===t.connections&&(t.connections=[]),t.connections.push(n)}else if("Properties70"===r.name){var a=Object.keys(r);a.forEach(function(e){t[e]=r[e]})}else if("Properties70"===e&&"P"===r.name){var o,s=r.propertyList[0],l=r.propertyList[1],c=r.propertyList[2],u=r.propertyList[3];0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),0===l.indexOf("Lcl ")&&(l=l.replace("Lcl ","Lcl_")),o="Color"===l||"ColorRGB"===l||"Vector"===l||"Vector3D"===l||0===l.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[s]={type:l,type2:c,flag:u,value:o}}else void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)},parseProperty:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":var r=e.getUint32();return e.getArrayBuffer(r);case"S":var r=e.getUint32();return e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var i=e.getUint32(),n=e.getUint32(),a=e.getUint32();if(0===n)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}"undefined"==typeof Zlib&&console.error("FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js");var o=new Zlib.Inflate(new Uint8Array(e.getArrayBuffer(a))),s=new p(o.decompress().buffer);switch(t){case"b":case"c":return s.getBooleanArray(i);case"d":return s.getFloat64Array(i);case"f":return s.getFloat32Array(i);case"i":return s.getInt32Array(i);case"l":return s.getInt64Array(i)}default:throw new Error("FBXLoader: Unknown property type "+t)}}},p.prototype={constructor:p,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1===(1&this.getUint8())},getBooleanArray:function(e){for(var t=this,r=[],i=0;i=0&&(r=r.slice(0,n)),Iu.decodeText(new Uint8Array(r))}},f.prototype={constructor:f,add:function(e,t){this[e]=t}};var R=[],U=new r,z=new o,j=new i,V=new i,G=new r;return e}(),Lf=function(e){this.manager=void 0!==e?e:Du,this.splitLayer=!1};Lf.prototype.load=function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(e))},r,i)},Lf.prototype.parse=function(e){function t(e){c={vertex:[],pathVertex:[],z:e.z},l.push(c)}function r(e,r){void 0===c&&t(e),g.extruding?(c.vertex.push(e.x,e.y,e.z),c.vertex.push(r.x,r.y,r.z)):(c.pathVertex.push(e.x,e.y,e.z),c.pathVertex.push(r.x,r.y,r.z))}function i(e,t){return s.relative?t:t-e}function n(e,t){return s.relative?e+t:t}function a(e,t){var r=new P;r.addAttribute("position",new M(e,3));var i=new Yt(r,t?h:u);i.name="layer"+p,y.add(i)}var s={x:0,y:0,z:0,e:0,f:0,extruding:!1,relative:!1},l=[],c=void 0,u=new I({color:16711680});u.name="path";var h=new I({color:65280});h.name="extruded";for(var d=e.replace(/;.+/g,"").split("\n"),p=0;p0&&(g.extruding=i(s.e,g.e)>0,void 0!=c&&g.z==c.z||t(g)),r(s,g),s=g}else if("G2"===m||"G3"===m)console.warn("GCodeLoader: Arc command not supported");else if("G90"===m)s.relative=!1;else if("G91"===m)s.relative=!0;else if("G92"===m){var g=s;g.x=void 0!==v.x?v.x:g.x,g.y=void 0!==v.y?v.y:g.y,g.z=void 0!==v.z?v.z:g.z,g.e=void 0!==v.e?v.e:g.e,s=g}else console.warn("GCodeLoader: Command not supported:"+m)}var y=new Dt;if(y.name="gcode",this.splitLayer)for(var p=0;p",o).replace("#include ",s).replace("#include ",l).replace("#include ",c).replace("#include ",h);delete a.roughness,delete a.metalness,delete a.roughnessMap,delete a.metalnessMap,a.specular={value:(new u).setHex(1118481)},a.glossiness={value:.5},a.specularMap={value:null},a.glossinessMap={value:null},e.vertexShader=n.vertexShader,e.fragmentShader=d,e.uniforms=a,e.defines={STANDARD:""},e.color=new u(1,1,1),e.opacity=1;var p=[];if(Array.isArray(i.diffuseFactor)){var f=i.diffuseFactor;e.color.fromArray(f),e.opacity=f[3]}if(void 0!==i.diffuseTexture&&p.push(r.assignTexture(e,"map",i.diffuseTexture.index)),e.emissive=new u(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new u(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var m=i.specularGlossinessTexture.index;p.push(r.assignTexture(e,"glossinessMap",m)),p.push(r.assignTexture(e,"specularMap",m))}return Promise.all(p)},createMaterial:function(e){var t=new pe({defines:e.defines,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms,fog:!0,lights:!0,opacity:e.opacity,transparent:e.transparent});return t.isGLTFSpecularGlossinessMaterial=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t.extensions.derivatives=!0,t},cloneMaterial:function(e){var t=e.clone();t.isGLTFSpecularGlossinessMaterial=!0;for(var r=this.specularGlossinessParams,i=0,n=r.length;i=2&&(i[n+1]=e.getY(n)),r>=3&&(i[n+2]=e.getZ(n)),r>=4&&(i[n+3]=e.getW(n));return new g(i,r,e.normalized)}return e.clone()}function E(e){if(e.length<2)return!1;var t=e[0],r=t.targets||[];if(void 0===t.indices)return!1;for(var i=1,n=e.length;i=2.0 are supported. Use LegacyGLTFLoader instead.")));if(v.extensionsUsed)for(var g=0;g=0&&console.warn('GLTFLoader: Unknown extension "'+y+'".')}}var b=new C(v,d,{path:t||this.path||"",crossOrigin:this.crossOrigin,manager:this.manager});b.parse(function(e,t,i,n,a){var o={scene:e,scenes:t,cameras:i,animations:n,asset:a.asset,parser:b,userData:{}};m(d,o,a),r(o)},c)}};var N={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};a.prototype.getMaterialType=function(e){return F},a.prototype.extendParams=function(e,t,r){var i=[];e.color=new u(1,1,1),e.opacity=1;var n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){var a=n.baseColorFactor;e.color.fromArray(a),e.opacity=a[3]}void 0!==n.baseColorTexture&&i.push(r.assignTexture(e,"map",n.baseColorTexture.index))}return Promise.all(i)};var O="glTF",R=12,U={JSON:1313821514,BIN:5130562};s.prototype.decodePrimitive=function(e,t){var r=this.json,i=this.dracoLoader,n=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var c in a)c in Y&&(o[Y[c]]=a[c]);for(c in e.attributes)if(void 0!==Y[c]&&void 0!==a[c]){var u=r.accessors[e.attributes[c]],h=V[u.componentType];l[Y[c]]=h,s[Y[c]]=u.normalized===!0}return t.getDependency("bufferView",n).then(function(e){return new Promise(function(t){i.decodeDracoFile(e,function(e){for(var r in e.attributes){var i=e.attributes[r],n=s[r];void 0!==n&&(i.normalized=n)}t(e)},o,l)})})},h.prototype=Object.create(j.prototype),h.prototype.constructor=h,h.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i*3+i,a=0;a!==i;a++)t[a]=r[n+a];return t},h.prototype.beforeStart_=h.prototype.copySampleValue_,h.prototype.afterEnd_=h.prototype.copySampleValue_,h.prototype.interpolate_=function(e,t,r,i){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,c=i-t,u=(r-t)/c,h=u*u,d=h*u,p=e*l,f=p-l,m=2*d-3*h+1,v=d-2*h+u,g=-2*d+3*h,y=d-h,x=0;x!==o;x++){var b=a[f+x+o],w=a[f+x+s]*c,_=a[p+x+o],S=a[p+x]*c;n[x]=m*b+v*w+g*_+y*S}return n};var z={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},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},G={9728:$l,9729:rc,9984:ec,9985:ic,9986:tc,9987:nc},X={33071:Zl,33648:Kl,10497:Jl},H={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Y={POSITION:"position",NORMAL:"normal",TEXCOORD_0:"uv",TEXCOORD0:"uv",TEXCOORD:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",COLOR0:"color",COLOR:"color",WEIGHTS_0:"skinWeight",WEIGHT:"skinWeight",JOINTS_0:"skinIndex",JOINT:"skinIndex"},q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Q={CUBICSPLINE:$c,LINEAR:Kc,STEP:Zc},J={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},K={"image/png":xc,"image/jpeg":yc};return C.prototype.parse=function(e,t){var r=this.json;this.cache.removeAll(),this.markDefs(),this.getMultiDependencies(["scene","animation","camera"]).then(function(t){var i=t.scenes||[],n=i[r.scene||0],a=t.animations||[],o=t.cameras||[];e(n,i,o,a,r)})["catch"](t)},C.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],i={},n={},a=0,o=t.length;a=2&&a.setY(M,_[S*s+1]),s>=3&&a.setZ(M,_[S*s+2]),s>=4&&a.setW(M,_[S*s+3]),s>=5)throw new Error("GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a})},C.prototype.loadTexture=function(e){var t,r=this,i=this.json,n=this.options,a=this.textureLoader,o=Ds.URL||Ds.webkitURL,s=i.textures[e],l=s.extensions||{};t=l[N.MSFT_TEXTURE_DDS]?i.images[l[N.MSFT_TEXTURE_DDS].source]:i.images[s.source];var c=t.uri,u=!1;return void 0!==t.bufferView&&(c=r.getDependency("bufferView",t.bufferView).then(function(e){u=!0;var r=new Blob([e],{type:t.mimeType});return c=o.createObjectURL(r)})),Promise.resolve(c).then(function(e){var t=ke.Handlers.get(e);return t||(t=l[N.MSFT_TEXTURE_DDS]?r.extensions[N.MSFT_TEXTURE_DDS].ddsLoader:a),new Promise(function(r,i){t.load(d(e,n.path),r,void 0,i)})}).then(function(e){u===!0&&o.revokeObjectURL(c),e.flipY=!1,void 0!==s.name&&(e.name=s.name),t.mimeType in K&&(e.format=K[t.mimeType]);var r=i.samplers||{},n=r[s.sampler]||{};return e.magFilter=G[n.magFilter]||rc,e.minFilter=G[n.minFilter]||nc,e.wrapS=X[n.wrapS]||Jl,e.wrapT=X[n.wrapT]||Jl,e})},C.prototype.assignTexture=function(e,t,r){return this.getDependency("texture",r).then(function(r){e[t]=r})},C.prototype.loadMaterial=function(e){var t,r=this,i=this.json,n=this.extensions,a=i.materials[e],o={},s=a.extensions||{},l=[];if(s[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var c=n[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=c.getMaterialType(a),l.push(c.extendParams(o,a,r))}else if(s[N.KHR_MATERIALS_UNLIT]){var h=n[N.KHR_MATERIALS_UNLIT];t=h.getMaterialType(a),l.push(h.extendParams(o,a,r))}else{t=Ce;var d=a.pbrMetallicRoughness||{};if(o.color=new u(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){var p=d.baseColorFactor;o.color.fromArray(p),o.opacity=p[3]}if(void 0!==d.baseColorTexture&&l.push(r.assignTexture(o,"map",d.baseColorTexture.index)),o.metalness=void 0!==d.metallicFactor?d.metallicFactor:1,o.roughness=void 0!==d.roughnessFactor?d.roughnessFactor:1,void 0!==d.metallicRoughnessTexture){var g=d.metallicRoughnessTexture.index;l.push(r.assignTexture(o,"metalnessMap",g)),l.push(r.assignTexture(o,"roughnessMap",g))}}a.doubleSided===!0&&(o.side=Ks);var y=a.alphaMode||J.OPAQUE;return y===J.BLEND?o.transparent=!0:(o.transparent=!1,y===J.MASK&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==F&&(l.push(r.assignTexture(o,"normalMap",a.normalTexture.index)),o.normalScale=new f(1,1),void 0!==a.normalTexture.scale&&o.normalScale.set(a.normalTexture.scale,a.normalTexture.scale)),void 0!==a.occlusionTexture&&t!==F&&(l.push(r.assignTexture(o,"aoMap",a.occlusionTexture.index)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==F&&(o.emissive=(new u).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==F&&l.push(r.assignTexture(o,"emissiveMap",a.emissiveTexture.index)),Promise.all(l).then(function(){var e;return e=t===pe?n[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new t(o),void 0!==a.name&&(e.name=a.name),e.normalScale&&(e.normalScale.y=-e.normalScale.y),e.map&&(e.map.encoding=su),e.emissiveMap&&(e.emissiveMap.encoding=su),e.specularMap&&(e.specularMap.encoding=su),v(e,a),a.extensions&&m(n,e,a),e})},C.prototype.loadGeometries=function(e){var t,r=this,i=this.extensions,n=this.primitiveCache,a=E(e);return a&&(t=e,e=[e[0]]),this.getDependencies("accessor").then(function(o){for(var s=[],l=0,c=e.length;l1&&void 0!==Pf){for(var p=1,f=e.length;p0,l=[],c=0,u=r.length;c0&&x(h,n),h.name=n.name||"mesh_"+e,r.length>1&&(h.name+="_"+c),v(h,n),l.push(h);for(var m=s?h.material:[h.material],y=void 0!==d.attributes.color,b=void 0===d.attributes.normal,w=h.isSkinnedMesh===!0,_=Object.keys(d.morphAttributes).length>0,S=_&&void 0!==d.morphAttributes.normal,A=0,M=m.length;A1){var l=a[o.mesh]++;t=s.clone(),t.name+="_instance_"+l,t.onBeforeRender=s.onBeforeRender;for(var u=0,h=t.children.length;u(n=l.indexOf(u))&&a=e.byteLength||!(t=h(e)))return o(r,"no header found");if(!(i=t.match(a)))return o(n,"bad initial token");for(m.valid|=s,m.programtype=i[1],m.string+=t+"\n";;){if(t=h(e),!1===t)break;if(m.string+=t+"\n","#"!==t.charAt(0)){if((i=t.match(u))&&(m.gamma=parseFloat(i[1],10)),(i=t.match(d))&&(m.exposure=parseFloat(i[1],10)),(i=t.match(p))&&(m.valid|=l,m.format=i[1]),(i=t.match(f))&&(m.valid|=c,m.height=parseInt(i[1],10),m.width=parseInt(i[2],10)),m.valid&l&&m.valid&c)break}else m.comments+=t+"\n"}return m.valid&l?m.valid&c?m:o(n,"missing image size specifier"):o(n,"missing format specifier")},p=function(e,t,i){var s,l,c,u,h,d,p,f,m,v,g,y,x,b=t,w=i;if(b<8||b>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(b!==(e[2]<<8|e[3]))return o(n,"wrong scanline width");if(s=new Uint8Array(4*t*i),!s||!s.length)return o(a,"unable to allocate buffer space");for(l=0,c=0,f=4*b,x=new Uint8Array(4),d=new Uint8Array(f);w>0&&ce.byteLength)return o(r);if(x[0]=e[c++],x[1]=e[c++],x[2]=e[c++],x[3]=e[c++],2!=x[0]||2!=x[1]||(x[2]<<8|x[3])!=b)return o(n,"bad rgbe scanline format");for(p=0;p128,y&&(u-=128),0===u||p+u>f)return o(n,"bad scanline data");if(y)for(h=e[c++],m=0;m>16&32768,a=i>>12&2047,o=i>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&i):o<113?(a|=2048,n|=(a>>114-o)+(a>>113-o&1)):(n|=o-112<<10|a>>1,n+=1&a)}var t=new Float32Array(1),r=new Int32Array(t.buffer);return function(t,r,i,n){var a=t[r+3],o=Math.pow(2,a-128)/255;i[n+0]=e(t[r+0]*o),i[n+1]=e(t[r+1]*o),i[n+2]=e(t[r+2]*o)}}(),l=new $t;l.type=e,l.encoding=e===ac?cu:ou,l.format=e===ac?xc:yc,l.minFilter=l.encoding===cu?$l:rc,l.magFilter=l.encoding===cu?$l:rc,l.generateMipmaps=l.encoding!==cu,l.anisotropy=0;for(var c=this.hdrLoader,u=0,h=0;h>8&65280|e>>24&255},e.prototype.mipmaps=function(t){for(var r=this,i=[],n=e.HEADER_LEN+this.bytesOfKeyValueData,a=this.pixelWidth,o=this.pixelHeight,s=t?this.numberOfMipmapLevels:1,l=0;l0){var S=[];for(var w in v)f=v[w],S[w]=f.name;_="Adding mesh(es) ("+S.length+": "+S+") from input mesh: "+i,_+=" ("+(100*e.progress.numericalValue).toFixed(2)+"%)"}else _="Not adding mesh: "+i,_+=" ("+(100*e.progress.numericalValue).toFixed(2)+"%)";var A=this.callbacks.onProgress;if(r.isValid(A)){var M=new CustomEvent("MeshBuilderEvent",{detail:{type:"progress",modelName:e.params.meshName,text:_,numericalValue:e.progress.numericalValue}});A(M)}return v},e.prototype.updateMaterials=function(e){var t,i,n=this,a=e.materials.materialCloneInstructions;if(r.isValid(a)){var o=a.materialNameOrg,s=this.materials[o];if(r.isValid(o)){t=s.clone(),i=a.materialName,t.name=i;var l=a.materialProperties;for(var c in l)t.hasOwnProperty(c)&&l.hasOwnProperty(c)&&(t[c]=l[c]);this.materials[i]=t}else console.warn('Requested material "'+o+'" is not available!')}var u=e.materials.serializedMaterials;if(r.isValid(u)&&Object.keys(u).length>0){var h,d=new Ie;for(i in u)h=u[i],r.isValid(h)&&(t=d.parse(h),n.logging.enabled&&console.info('De-serialized material with name "'+i+'" will be added.'),n.materials[i]=t)}if(u=e.materials.runtimeMaterials,r.isValid(u)&&Object.keys(u).length>0)for(i in u)t=u[i],n.logging.enabled&&console.info('Material with name "'+i+'" will be added.'),n.materials[i]=t},e.prototype.getMaterialsJSON=function(){var e,t=this,r={};for(var i in t.materials)e=t.materials[i],r[i]=e.toJSON();return r},e.prototype.getMaterials=function(){return this.materials},e}(),kf.WorkerRunnerRefImpl=function(){function e(){var e=this,t=function(t){e.processMessage(t.data)};self.addEventListener("message",t,!1)}return e.prototype.applyProperties=function(e,t){var r,i,n;for(r in t)i="set"+r.substring(0,1).toLocaleUpperCase()+r.substring(1),n=t[r],"function"==typeof e[i]?e[i](n):e.hasOwnProperty(r)&&(e[r]=n)},e.prototype.processMessage=function(e){if("run"===e.cmd){var t={callbackMeshBuilder:function(e){self.postMessage(e)},callbackProgress:function(t){e.logging.enabled&&e.logging.debug&&console.debug("WorkerRunner: progress: "+t)}},r=new Parser;"function"==typeof r.setLogging&&r.setLogging(e.logging.enabled,e.logging.debug),this.applyProperties(r,e.params),this.applyProperties(r,e.materials),this.applyProperties(r,t),r.workerScope=self,r.parse(e.data.input,e.data.options),e.logging.enabled&&console.log("WorkerRunner: Run complete!"),t.callbackMeshBuilder({cmd:"complete",msg:"WorkerRunner completed run."})}else console.error("WorkerRunner: Received unknown command: "+e.cmd)},e}(),kf.WorkerSupport=function(){function e(){if(console.info("Using LoaderSupport.WorkerSupport version: "+t),this.logging={enabled:!0,debug:!1},void 0===Ds.Worker)throw"This browser does not support web workers!";if(void 0===Ds.Blob)throw"This browser does not support Blob!";if("function"!=typeof Ds.URL.createObjectURL)throw"This browser does not support Object creation from URL!";this.loaderWorker=new i}var t="2.2.1",r=kf.Validator,i=function(){function e(){this._reset()}return e.prototype._reset=function(){this.logging={enabled:!0,debug:!1},this.worker=null,this.runnerImplName=null,this.callbacks={meshBuilder:null,onLoad:null},this.terminateRequested=!1,this.queuedMessage=null,this.started=!1,this.forceCopy=!1},e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.setForceCopy=function(e){this.forceCopy=e===!0},e.prototype.initWorker=function(e,t){this.runnerImplName=t;var r=new Blob([e],{type:"application/javascript"});this.worker=new Worker(Ds.URL.createObjectURL(r)),this.worker.onmessage=this._receiveWorkerMessage,this.worker.runtimeRef=this,this._postMessage()},e.prototype._receiveWorkerMessage=function(e){var t=e.data;switch(t.cmd){case"meshData":case"materialData":case"imageData":this.runtimeRef.callbacks.meshBuilder(t);break;case"complete":this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(t.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logging.enabled&&console.info("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run is complete. Terminating application on request!"),this.runtimeRef._terminate());break;case"error":console.error("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Reported error: "+t.msg),this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(t.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logging.enabled&&console.info("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run reported error. Terminating application on request!"),this.runtimeRef._terminate());break;default:console.error("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Received unknown command: "+t.cmd)}},e.prototype.setCallbacks=function(e,t){this.callbacks.meshBuilder=r.verifyInput(e,this.callbacks.meshBuilder),this.callbacks.onLoad=r.verifyInput(t,this.callbacks.onLoad)},e.prototype.run=function(e){if(r.isValid(this.queuedMessage))return void console.warn("Already processing message. Rejecting new run instruction");if(this.queuedMessage=e,this.started=!0,!r.isValid(this.callbacks.meshBuilder))throw'Unable to run as no "MeshBuilder" callback is set.';if(!r.isValid(this.callbacks.onLoad))throw'Unable to run as no "onLoad" callback is set.';"run"!==e.cmd&&(e.cmd="run"),r.isValid(e.logging)?(e.logging.enabled=e.logging.enabled===!0,e.logging.debug=e.logging.debug===!0):e.logging={enabled:!0,debug:!1},this._postMessage()},e.prototype._postMessage=function(){if(r.isValid(this.queuedMessage)&&r.isValid(this.worker))if(this.queuedMessage.data.input instanceof ArrayBuffer){var e;e=this.forceCopy?this.queuedMessage.data.input.slice(0):this.queuedMessage.data.input,this.worker.postMessage(this.queuedMessage,[e])}else this.worker.postMessage(this.queuedMessage)},e.prototype.setTerminateRequested=function(e){this.terminateRequested=e===!0,this.terminateRequested&&r.isValid(this.worker)&&!r.isValid(this.queuedMessage)&&this.started&&(this.logging.enabled&&console.info("Worker is terminated immediately as it is not running!"),this._terminate())},e.prototype._terminate=function(){this.worker.terminate(),this._reset()},e}();e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0,this.loaderWorker.setLogging(this.logging.enabled,this.logging.debug)},e.prototype.setForceWorkerDataCopy=function(e){this.loaderWorker.setForceCopy(e)},e.prototype.validate=function(e,t,i,o,s){if(!r.isValid(this.loaderWorker.worker)){this.logging.enabled&&(console.info("WorkerSupport: Building worker code..."),console.time("buildWebWorkerCode")),r.isValid(s)?this.logging.enabled&&console.info('WorkerSupport: Using "'+s.name+'" as Runner class for worker.'):(s=kf.WorkerRunnerRefImpl,this.logging.enabled&&console.info('WorkerSupport: Using DEFAULT "LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.'));var l=e(n,a);l+="var Parser = "+t+";\n\n",l+=a(s.name,s),l+="new "+s.name+"();\n\n";var c=this;if(r.isValid(i)&&i.length>0){var u="",h=function(e,t){if(0===t.length)c.loaderWorker.initWorker(u+l,s.name),c.logging.enabled&&console.timeEnd("buildWebWorkerCode");else{var r=function(r){u+=r,h(e,t)},i=new we;i.setPath(e),i.setResponseType("text"),i.load(t[0],r),t.shift()}};h(o,i)}else this.loaderWorker.initWorker(l,s.name),this.logging.enabled&&console.timeEnd("buildWebWorkerCode")}},e.prototype.setCallbacks=function(e,t){this.loaderWorker.setCallbacks(e,t)},e.prototype.run=function(e){this.loaderWorker.run(e)},e.prototype.setTerminateRequested=function(e){this.loaderWorker.setTerminateRequested(e)};var n=function(e,t){var r,i=e+" = {\n";for(var n in t)r=t[n],"string"==typeof r||r instanceof String?(r=r.replace("\n","\\n"),r=r.replace("\r","\\r"),i+="\t"+n+': "'+r+'",\n'):r instanceof Array?i+="\t"+n+": ["+r+"],\n":Number.isInteger(r)?i+="\t"+n+": "+r+",\n":"function"==typeof r&&(i+="\t"+n+": "+r+",\n");return i+="}\n\n"},a=function(e,t,i,n,a){var o,s,l,c="",u=r.isValid(i)?i:t.name;a=r.verifyInput(a,[]);for(var h in t.prototype)s=t.prototype[h],"constructor"===h?(o=s.toString(),o=o.replace("function",""),l="\tfunction "+u+o+";\n\n"):"function"==typeof s&&a.indexOf(h)<0&&(o=s.toString(),c+="\t"+u+".prototype."+h+" = "+o+";\n\n");c+="\treturn "+u+";\n",c+="})();\n\n";var d="";return r.isValid(n)&&(d+="\n",d+=u+".prototype = Object.create( "+n+".prototype );\n",d+=u+".constructor = "+u+";\n",d+="\n"),r.isValid(l)?c=e+" = (function () {\n\n"+d+l+c:(l=e+" = (function () {\n\n",l+=d+"\t"+t.prototype.constructor.toString()+"\n\n",c=l+c),c};return e}(),kf.WorkerDirector=function(){function e(e){if(console.info("Using LoaderSupport.WorkerDirector version: "+t),this.logging={enabled:!0,debug:!1},this.maxQueueSize=n,this.maxWebWorkers=i,this.crossOrigin=null,!r.isValid(e))throw"Provided invalid classDef: "+e;this.workerDescription={classDef:e,globalCallbacks:{},workerSupports:{},forceWorkerDataCopy:!0},this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0,this.callbackOnFinishedProcessing=null}var t="2.2.2",r=kf.Validator,i=16,n=8192;return e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.getMaxQueueSize=function(){return this.maxQueueSize},e.prototype.getMaxWebWorkers=function(){return this.maxWebWorkers},e.prototype.setCrossOrigin=function(e){this.crossOrigin=e},e.prototype.setForceWorkerDataCopy=function(e){this.workerDescription.forceWorkerDataCopy=e===!0},e.prototype.prepareWorkers=function(e,t,a){var o=this;r.isValid(e)&&(this.workerDescription.globalCallbacks=e),this.maxQueueSize=Math.min(t,n),this.maxWebWorkers=Math.min(a,i),this.maxWebWorkers=Math.min(this.maxWebWorkers,this.maxQueueSize),this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0;for(var s=0;s0&&this.instructionQueuePointer0},e.prototype.processQueue=function(){var e,t,r=this;for(var i in r.workerDescription.workerSupports)t=r.workerDescription.workerSupports[i],t.inUse||(r.instructionQueuePointer0){for(var E=[],x=0,V=p.length;x0){for(var C=[],x=0,V=p.length;x=w?b.skinIndices[w]:0);for(var w=0;w<4;w++)u.push(b.skinWeights.length-1>=w?b.skinWeights[w]:0)}for(var x=0;x=0&&(F.limitation=new i(1,0,0)),D.links.push(F)}p.push(D)}else for(var x=0;x0,h.morphTargets=t.morphTargets.length>0,h.lights=!0,h.fog=!0,h.blending=cl,h.blendSrc=xl,h.blendDst=bl,h.blendSrcAlpha=xl,h.blendDstAlpha=wl,"pmx"===e.metadata.format&&1===(1&c.flag)?h.side=Ks:h.side=1===h.opacity?Js:Ks,"pmd"===e.metadata.format){if(c.fileName){var d=c.fileName,p=d.split("*");if(h.map=a._loadTexture(p[0],s),p.length>1){var f=p[1].slice(-4).toLowerCase();h.envMap=a._loadTexture(p[1],s,{sphericalReflectionMapping:!0}),h.combine=".sph"===f?Fl:Rl}}var m=c.toonIndex===-1?"toon00.bmp":e.toonTextures[c.toonIndex].fileName;h.gradientMap=a._loadTexture(m,s,{isToonTexture:!0,isDefaultToonTexture:a._isDefaultToonTexture(m)}),h.userData.outlineParameters={thickness:1===c.edgeFlag?.003:0,color:[0,0,0],alpha:1,visible:1===c.edgeFlag}}else{c.textureIndex!==-1&&(h.map=a._loadTexture(e.textures[c.textureIndex],s)),c.envTextureIndex===-1||1!==c.envFlag&&2!=c.envFlag||(h.envMap=a._loadTexture(e.textures[c.envTextureIndex],s,{sphericalReflectionMapping:!0}),h.combine=1===c.envFlag?Fl:Rl);var m,v;c.toonIndex===-1||0!==c.toonFlag?(m="toon"+("0"+(c.toonIndex+1)).slice(-2)+".bmp",v=!0):(m=e.textures[c.toonIndex],v=!1),h.gradientMap=a._loadTexture(m,s,{isToonTexture:!0,isDefaultToonTexture:v}),h.userData.outlineParameters={thickness:c.edgeSize/300,color:c.edgeColor.slice(0,3),alpha:c.edgeColor[3],visible:0!==(16&c.flag)&&c.edgeSize>0}}void 0!==h.map&&(h.transparent||a._checkImageTransparency(h.map,t,l),h.emissive.multiplyScalar(.2)),o.push(new Pe(h))}if("pmx"===e.metadata.format)for(var l=0,g=e.morphs.length;l2){r=r.slice(),i=i.slice(),n=n.slice();for(var a=i.length/r.length,o=n.length/r.length,s=1,c=2,u=r.length;cs){r[s]=r[c];for(var h=0;h=0?o.substring(0,s):o;l=l.toLowerCase();var c=s>=0?o.substring(s+1):"";if(c=c.trim(),"newmtl"===l)r={name:c},n[c]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var u=c.split(i,3);r[l]=[parseFloat(u[0]),parseFloat(u[1]),parseFloat(u[2])]}else r[l]=c}}var h=new jf.MaterialCreator(this.texturePath||this.path,this.materialOptions);return h.setCrossOrigin(this.crossOrigin),h.setManager(this.manager),h.setMaterials(n),h}},jf.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:Js,this.wrap=this.options&&this.options.wrap?this.options.wrap:Jl},jf.MaterialCreator.prototype={constructor:jf.MaterialCreator,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){var t=this;if(!this.options)return e;var r={};for(var i in e){var n=e[i],a={};r[i]=a;for(var o in n){var s=!0,l=n[o],c=o.toLowerCase();switch(c){case"kd":case"ka":case"ks":t.options&&t.options.normalizeRGB&&(l=[l[0]/255,l[1]/255,l[2]/255]),t.options&&t.options.ignoreZeroRGBs&&0===l[0]&&0===l[1]&&0===l[2]&&(s=!1)}s&&(a[c]=l)}}return r},preload:function(){var e=this;for(var t in e.materialsInfo)e.create(t)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=this,t=0;for(var r in e.materialsInfo)e.materialsArray[t]=e.create(r),e.nameLookup[r]=t,t++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!o[e]){var i=n.getTextureParams(r,o),a=n.loadTexture(t(n.baseUrl,i.url));a.repeat.copy(i.scale),a.offset.copy(i.offset),a.wrapS=n.wrap,a.wrapT=n.wrap,o[e]=a}}var i=this,n=this,a=this.materialsInfo[e],o={name:e,side:this.side};for(var s in a){var l,c=a[s];if(""!==c)switch(s.toLowerCase()){case"kd":o.color=(new u).fromArray(c);break;case"ks":o.specular=(new u).fromArray(c);break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"ns":o.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(o.opacity=l,o.transparent=!0);break;case"tr":l=parseFloat(c),i.options&&i.options.invertTrProperty&&(l=1-l),l>0&&(o.opacity=1-l,o.transparent=!0)}}return this.materials[e]=new Ee(o),this.materials[e]},getTextureParams:function(e,t){var r,i={scale:new f(1,1),offset:new f(0,0)},n=e.split(/\s+/);return r=n.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(n[r+1]),n.splice(r,2)),r=n.indexOf("-s"),r>=0&&(i.scale.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),r=n.indexOf("-o"),r>=0&&(i.offset.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),i.url=n.join(" ").trim(),i},loadTexture:function(e,t,r,i,n){var a,o=ke.Handlers.get(e),s=void 0!==this.manager?this.manager:Du;return null===o&&(o=new Ue(s)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin),a=o.load(e,r,i,n),void 0!==t&&(a.mapping=t),a}},er.prototype={constructor:er,isNode:!0,parse:function(e,t){t=t||{},e.parsing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.parsing=!1},parseAndBuildCode:function(e,t,r){return r=r||{},this.parse(e,r),this.buildCode(e,t,r)},buildCode:function(e,t,r){r=r||{};var i={result:this.build(e.addFlow(r.slot,r.cache,r.context),t)};return i.code=e.clearNodeCode(),e.removeFlow(),i},build:function(e,t,r){t=t||this.getType(e,t);var i=e.getNodeData(r||this);return e.parsing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),void 0!==this.updateFrame&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)},appendDepsNode:function(e,t,r){t.deps=(t.deps||0)+1;var i=e.getTypeLength(r);(i>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=i,t.output=r)},setName:function(e){return this.name=e,this},getName:function(e){return this.name},getType:function(e,t){return"sampler2D"===t||"samplerCube"===t?t:this.type},getJSONNode:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.nodes[this.uuid])return e.nodes[this.uuid]},copy:function(e){void 0!==e.name&&(this.name=e.name),void 0!==e.userData&&(this.userData=JSON.parse(JSON.stringify(e.userData)))},createJSONNode:function(e){var t=void 0===e||"string"==typeof e,r={};if("string"!=typeof this.nodeType)throw new Error("Node does not allow serialization.");return r.uuid=this.uuid,r.nodeType=this.nodeType,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t||(e.nodes[this.uuid]=r),r},toJSON:function(e){return this.getJSONNode(e)||this.createJSONNode(e)}},tr.prototype=Object.create(er.prototype),tr.prototype.constructor=tr,tr.prototype.build=function(e,t,r,i){if(t=t||this.getType(e),this.isShared(e,t)){var n=this.isUnique(e,t);n&&void 0===this.constructor.uuid&&(this.constructor.uuid=Fs.generateUUID()),r=e.getUuid(r||this.getUuid(),!n);var a=e.getNodeData(r),o=a.output||this.getType(e);if(e.parsing)return(a.deps||0)>0?(this.appendDepsNode(e,a,t),this.generate(e,t,r)):er.prototype.build.call(this,e,t,r);if(n)return a.name=a.name||er.prototype.build.call(this,e,t,r),a.name;if(!this.isShared(e,o)||!e.optimize||1==a.deps)return er.prototype.build.call(this,e,t,r);r=this.getUuid(!1);var s=this.getTemp(e,r);if(s)return e.format(s,o,t);s=tr.prototype.generate.call(this,e,t,r,a.output,i);var l=this.generate(e,o,r);return e.addNodeCode(s+" = "+l+";"),e.format(s,o,t)}return er.prototype.build.call(this,e,t,r)},tr.prototype.isShared=function(e,t){return"sampler2D"!==t&&"samplerCube"!==t&&this.shared},tr.prototype.isUnique=function(e,t){return this.unique},tr.prototype.getUuid=function(e){var t=e||void 0==e?this.constructor.uuid||this.uuid:this.uuid;return"string"==typeof this.scope&&(t=this.scope+"-"+t),t},tr.prototype.getTemp=function(e,t){t=t||this.uuid;var r=e.getVars()[t];return r?r.name:void 0},tr.prototype.generate=function(e,t,r,i,n){return this.isShared(e,t)||console.error("TempNode is not shared!"),r=r||this.uuid,e.getTempVar(r,i||this.getType(e),n).name};var Vf=function(e,t,r,i){e=e||"",this.isMethod="string"!=typeof t,this.useKeywords=!0,tr.call(this,this.isMethod?null:t),this.isMethod?this.eval(e,t,r,i):this.eval(e,r,i)};Vf.rDeclaration=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\((.*?)\)/i,Vf.rProperties=/[a-z_0-9]+/gi,Vf.prototype=Object.create(tr.prototype),Vf.prototype.constructor=Vf,Vf.prototype.nodeType="Function",Vf.prototype.eval=function(e,t,r,i){var n=this;if(e=(e||"").trim(),this.includes=t||[],this.extensions=r||{},this.keywords=i||{},this.isMethod){var a=e.match(Vf.rDeclaration);if(this.inputs=[],a&&4==a.length){this.type=a[1],this.name=a[2];var o=a[3].match(Vf.rProperties);if(o)for(var s=0;s1?(i=a[1],r=a[2],n=a[3]):(r=this.src,i="f"),this.name=r,this.type=i,this.value=n},lr.prototype.build=function(e,t){return"source"!==t?(e.include(this),e.format(this.name,this.getType(e),t)):this.value?this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";":this.useDefine?this.src:void 0},lr.prototype.generate=function(e,t){return e.format(this.name,this.getType(e),t)},lr.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.eval(e.src,e.useDefine)},lr.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src,t.useDefine===!0&&(t.useDefine=!0)),t},Gf.addKeyword("uv",function(){return new rr}),Gf.addKeyword("uv2",function(){return new rr(1)}),Gf.addKeyword("position",function(){return new ir}),Gf.addKeyword("worldPosition",function(){return new ir(ir.WORLD)}),Gf.addKeyword("normal",function(){return new nr}),Gf.addKeyword("worldNormal",function(){return new nr(nr.WORLD)}),Gf.addKeyword("viewPosition",function(){return new ir(nr.VIEW)}),Gf.addKeyword("viewNormal",function(){return new nr(nr.VIEW)}),Gf.addKeyword("time",function(){return new sr}),Gf.add(new lr("vec3 LUMA vec3(0.2125, 0.7154, 0.0721)")),Gf.add(new Vf(["vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, vec2 scale ) {","\tvec3 q0 = dFdx( eye_pos );","\tvec3 q1 = dFdy( eye_pos );","\tvec2 st0 = dFdx( mUv.st );","\tvec2 st1 = dFdy( mUv.st );","\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );","\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );","\tvec3 N = normalize( surf_norm );","\tvec3 mapN = map * 2.0 - 1.0;","\tmapN.xy = scale * mapN.xy;","\tmat3 tsn = mat3( S, T, N );","\treturn normalize( tsn * mapN );","}"].join("\n"),null,{derivatives:!0})),Gf.add(new Vf(["float snoise(vec2 co) {","\treturn fract( sin( dot(co.xy, vec2(12.9898,78.233) ) ) * 43758.5453 );","}"].join("\n"))),Gf.add(new Vf(["vec3 hue_rgb(vec3 rgb, float adjustment) {","\tconst mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);","\tconst mat3 YIQtoRGB = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046);","\tvec3 yiq = RGBtoYIQ * rgb;","\tfloat hue = atan(yiq.z, yiq.y) + adjustment;","\tfloat chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);","\treturn YIQtoRGB * vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));","}"].join("\n"))),Gf.add(new Vf(["vec3 saturation_rgb(vec3 rgb, float adjustment) {","\tvec3 intensity = vec3(dot(rgb, LUMA));","\treturn mix(intensity, rgb, adjustment);","}"].join("\n"))),Gf.add(new Vf(["float luminance_rgb(vec3 rgb) {","\treturn dot(rgb, LUMA);","}"].join("\n"))),Gf.add(new Vf(["vec3 vibrance_rgb(vec3 rgb, float adjustment) {","\tfloat average = (rgb.r + rgb.g + rgb.b) / 3.0;","\tfloat mx = max(rgb.r, max(rgb.g, rgb.b));","\tfloat amt = (mx - average) * (-3.0 * adjustment);","\treturn mix(rgb.rgb, vec3(mx), amt);","}"].join("\n"))),Vf.prototype.isShared=function(e,t){return!this.isMethod},Vf.prototype.getType=function(e){return e.getTypeByFormat(this.type)},Vf.prototype.getInputByName=function(e){for(var t=this,r=this.inputs.length;r--;)if(t.inputs[r].name===e)return t.inputs[r]},Vf.prototype.getIncludeByName=function(e){for(var t=this,r=this.includes.length;r--;)if(t.includes[r].name===e)return t.includes[r]},Vf.prototype.generate=function(e,t){for(var r,i=this,n=0,a=this.value,o=0;o0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this,r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),e&&this.materials.length>1)for(var i=this.materials.length-1;i>=0;i--)t.materials[i].groupCount<=0&&t.materials.splice(i,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),r}},r&&r.name&&"function"==typeof r.clone){var i=r.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var i=this.vertices,n=this.object.geometry.vertices;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addVertexPoint:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,r){var i=this.normals,n=this.object.geometry.normals;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addColor:function(e,t,r){var i=this.colors,n=this.object.geometry.colors;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addUV:function(e,t,r){var i=this.uvs,n=this.object.geometry.uvs;n.push(i[e+0],i[e+1]),n.push(i[t+0],i[t+1]),n.push(i[r+0],i[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0],t[e+1])},addFace:function(e,t,r,i,n,a,o,s,l){var c=this.vertices.length,u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),d=this.parseVertexIndex(r,c);if(this.addVertex(u,h,d),void 0!==i&&""!==i){var p=this.uvs.length;u=this.parseUVIndex(i,p),h=this.parseUVIndex(n,p),d=this.parseUVIndex(a,p),this.addUV(u,h,d)}if(void 0!==o&&""!==o){var f=this.normals.length;u=this.parseNormalIndex(o,f),h=o===s?u:this.parseNormalIndex(s,f),d=o===l?u:this.parseNormalIndex(l,f),this.addNormal(u,h,d)}this.colors.length>0&&this.addColor(u,h,d)},addPointGeometry:function(e){var t=this;this.object.geometry.type="Points";for(var r=this.vertices.length,i=0,n=e.length;i0){var _=w.split("/");y.push(_)}}for(var S=y[0],x=1,b=y.length-1;x1){var U=h[1].trim().toLowerCase();o.object.smooth="0"!==U&&"off"!==U}else o.object.smooth=!0;var B=o.object.currentMaterial();B&&(B.smooth=o.object.smooth)}o.finalize();var z=new Dt;z.materialLibraries=[].concat(o.materialLibraries);for(var p=0,f=o.objects.length;p0?Y.addAttribute("normal",new M(V.normals,3)):Y.computeVertexNormals(),V.colors.length>0&&(H=!0,Y.addAttribute("color",new M(V.colors,3))),V.uvs.length>0&&Y.addAttribute("uv",new M(V.uvs,2));for(var q=[],Q=0,J=G.length;Q1){for(var Q=0,J=G.length;Qc)){c=u;var r='Download of "'+e.url+'": '+(100*u).toFixed(2)+"%";s.onProgress("progressLoad",r,u)}}}var h=new we(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.load(e.url,l,i,n)}},e.prototype.run=function(e,t){this._applyPrepData(e);var i=e.checkResourceDescriptorFiles(e.resources,[{ext:"obj",type:"ArrayBuffer",ignore:!1},{ext:"mtl",type:"String",ignore:!1},{ext:"zip",type:"String",ignore:!0}]);r.isValid(t)&&(this.terminateWorkerOnLoad=!1,this.workerSupport=t,this.logging.enabled=this.workerSupport.logging.enabled,this.logging.debug=this.workerSupport.logging.debug);var n=this,a=function(t){null!==t&&n.meshBuilder.setMaterials(t),n._loadObj(i.obj,n.callbacks.onLoad,null,null,n.callbacks.onMeshAlter,e.useAsync)};this._loadMtl(i.mtl,a,null,null,e.crossOrigin,e.materialOptions)},e.prototype._applyPrepData=function(e){r.isValid(e)&&(this.setLogging(e.logging.enabled,e.logging.debug),this.setModelName(e.modelName),this.setStreamMeshesTo(e.streamMeshesTo),this.meshBuilder.setMaterials(e.materials),this.setUseIndices(e.useIndices),this.setDisregardNormals(e.disregardNormals),this.setMaterialPerSmoothingGroup(e.materialPerSmoothingGroup),this.setUseOAsMesh(e.useOAsMesh),this._setCallbacks(e.getCallbacks()))},e.prototype.parse=function(e){if(!r.isValid(e))return console.warn("Provided content is not a valid ArrayBuffer or String."),this.loaderRootNode;this.logging.enabled&&console.time("OBJLoader2 parse: "+this.modelName),this.meshBuilder.init();var t=new i;t.setLogging(this.logging.enabled,this.logging.debug),t.setMaterialPerSmoothingGroup(this.materialPerSmoothingGroup),t.setUseOAsMesh(this.useOAsMesh),t.setUseIndices(this.useIndices),t.setDisregardNormals(this.disregardNormals),t.setMaterials(this.meshBuilder.getMaterials());var n=this,a=function(e){var t,r=n.meshBuilder.processPayload(e);for(var i in r)t=r[i],n.loaderRootNode.add(t)};t.setCallbackMeshBuilder(a);var o=function(e,t){n.onProgress("progressParse",e,t)};return t.setCallbackProgress(o),e instanceof ArrayBuffer||e instanceof Uint8Array?(this.logging.enabled&&console.info("Parsing arrayBuffer..."),t.parse(e)):"string"==typeof e||e instanceof String?(this.logging.enabled&&console.info("Parsing text..."),t.parseText(e)):this._throwError("Provided content was neither of type String nor Uint8Array! Aborting..."),this.logging.enabled&&console.timeEnd("OBJLoader2 parse: "+this.modelName),this.loaderRootNode},e.prototype.parseAsync=function(e,t){var n=this,a=!1,o=function(){t({detail:{loaderRootNode:n.loaderRootNode,modelName:n.modelName,instanceNo:n.instanceNo}}),a&&n.logging.enabled&&console.timeEnd("OBJLoader2 parseAsync: "+n.modelName)};r.isValid(e)?a=!0:(console.warn("Provided content is not a valid ArrayBuffer."),o()),a&&this.logging.enabled&&console.time("OBJLoader2 parseAsync: "+this.modelName),this.meshBuilder.init();var s=function(e){var t,r=n.meshBuilder.processPayload(e);for(var i in r)t=r[i],n.loaderRootNode.add(t)},l=function(e,t){var n="";return n+="\n\n",n+="THREE = { "+kf.constructor.name+": {} };\n\n",n+=e(""+kf.constructor.name+"."+kf.Validator.constructor.name,r),n+=t("Parser",i)};this.workerSupport.validate(l,"Parser"),this.workerSupport.setCallbacks(s,o),n.terminateWorkerOnLoad&&this.workerSupport.setTerminateRequested(!0);var c={},u=this.meshBuilder.getMaterials();for(var h in u)c[h]=h;this.workerSupport.run({params:{useAsync:!0,materialPerSmoothingGroup:this.materialPerSmoothingGroup,useOAsMesh:this.useOAsMesh,useIndices:this.useIndices,disregardNormals:this.disregardNormals},logging:{enabled:this.logging.enabled,debug:this.logging.debug},materials:{materials:c},data:{input:e,options:null}})};var i=function(){function e(){this.callbackProgress=null,this.callbackMeshBuilder=null,this.contentRef=null,this.legacyMode=!1,this.materials={},this.useAsync=!1,this.materialPerSmoothingGroup=!1,this.useOAsMesh=!1,this.useIndices=!1,this.disregardNormals=!1,this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.rawMesh={objectName:"",groupName:"",activeMtlName:"",mtllibName:"",faceType:-1,subGroups:[],subGroupInUse:null,smoothingGroup:{splitMaterials:!1,normalized:-1,real:-1},counts:{doubleIndicesCount:0,faceCount:0,mtlCount:0,smoothingGroupCount:0}},this.inputObjectCount=1,this.outputObjectCount=1,this.globalCounts={vertices:0,faces:0,doubleIndicesCount:0,lineByte:0,currentByte:0,totalBytes:0},this.logging={enabled:!0,debug:!1}}return e.prototype.resetRawMesh=function(){this.rawMesh.subGroups=[],this.rawMesh.subGroupInUse=null,this.rawMesh.smoothingGroup.normalized=-1,this.rawMesh.smoothingGroup.real=-1,this.pushSmoothingGroup(1),this.rawMesh.counts.doubleIndicesCount=0,this.rawMesh.counts.faceCount=0,this.rawMesh.counts.mtlCount=0,this.rawMesh.counts.smoothingGroupCount=0},e.prototype.setUseAsync=function(e){this.useAsync=e},e.prototype.setMaterialPerSmoothingGroup=function(e){this.materialPerSmoothingGroup=e},e.prototype.setUseOAsMesh=function(e){this.useOAsMesh=e},e.prototype.setUseIndices=function(e){this.useIndices=e},e.prototype.setDisregardNormals=function(e){this.disregardNormals=e},e.prototype.setMaterials=function(e){this.materials=kf.Validator.verifyInput(e,this.materials),this.materials=kf.Validator.verifyInput(this.materials,{})},e.prototype.setCallbackMeshBuilder=function(e){kf.Validator.isValid(e)||this._throwError('Unable to run as no "MeshBuilder" callback is set.'),this.callbackMeshBuilder=e},e.prototype.setCallbackProgress=function(e){this.callbackProgress=e},e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.configure=function(){if(this.pushSmoothingGroup(1),this.logging.enabled){var e=Object.keys(this.materials),t=e.length>0?"\n\tmaterialNames:\n\t\t- "+e.join("\n\t\t- "):"\n\tmaterialNames: None",r="OBJLoader2.Parser configuration:"+t+"\n\tuseAsync: "+this.useAsync+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseOAsMesh: "+this.useOAsMesh+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals+"\n\tcallbackMeshBuilderName: "+this.callbackMeshBuilder.name+"\n\tcallbackProgressName: "+this.callbackProgress.name;console.info(r)}},e.prototype.parse=function(e){var t=this;this.logging.enabled&&console.time("OBJLoader2.Parser.parse"),this.configure();var r=new Uint8Array(e);this.contentRef=r;var i=r.byteLength;this.globalCounts.totalBytes=i;for(var n,a=new Array(128),o="",s=0,l=0,c=0;c0&&(a[s++]=o),o="";break;case 47:o.length>0&&(a[s++]=o),l++,o="";break;case 10:o.length>0&&(a[s++]=o),o="",t.globalCounts.lineByte=t.globalCounts.currentByte,t.globalCounts.currentByte=c,t.processLine(a,s,l),s=0,l=0;break;case 13:break;default:o+=String.fromCharCode(n)}this.finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2.Parser.parse")},e.prototype.parseText=function(e){var t=this;this.logging.enabled&&console.time("OBJLoader2.Parser.parseText"),this.configure(),this.legacyMode=!0,this.contentRef=e;var r=e.length;this.globalCounts.totalBytes=r;for(var i,n=new Array(128),a="",o=0,s=0,l=0;l0&&(n[o++]=a),a="";break;case"/":a.length>0&&(n[o++]=a),s++,a="";break;case"\n":a.length>0&&(n[o++]=a),a="",t.globalCounts.lineByte=t.globalCounts.currentByte,t.globalCounts.currentByte=l,t.processLine(n,o,s),o=0,s=0;break;case"\r":break;default:a+=i}this.finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2.Parser.parseText")},e.prototype.processLine=function(e,t,r){var i=this;if(!(t<1)){var n,a,o,s,l=function(e,t,r,i){var n="";if(i>r){var a;if(t)for(a=r;a4&&(this.colors.push(parseFloat(e[4])),this.colors.push(parseFloat(e[5])),this.colors.push(parseFloat(e[6])));break;case"vt":this.uvs.push(parseFloat(e[1])),this.uvs.push(parseFloat(e[2]));break;case"vn":this.normals.push(parseFloat(e[1])),this.normals.push(parseFloat(e[2])),this.normals.push(parseFloat(e[3]));break;case"f":if(n=t-1,0===r)for(this.checkFaceType(0),o=2,a=n;o0?n-1:n+i.vertices.length/3),o=i.rawMesh.subGroupInUse.vertices;o.push(i.vertices[a++]),o.push(i.vertices[a++]),o.push(i.vertices[a]);var s=i.colors.length>0?a+1:null;if(null!==s){var l=i.rawMesh.subGroupInUse.colors;l.push(i.colors[s++]),l.push(i.colors[s++]),l.push(i.colors[s])}if(t){var c=parseInt(t),u=2*(c>0?c-1:c+i.uvs.length/2),h=i.rawMesh.subGroupInUse.uvs;h.push(i.uvs[u++]),h.push(i.uvs[u])}if(r){var d=parseInt(r),p=3*(d>0?d-1:d+i.normals.length/3),f=i.rawMesh.subGroupInUse.normals;f.push(i.normals[p++]),f.push(i.normals[p++]),f.push(i.normals[p])}};if(this.useIndices){var a=e+(t?"_"+t:"_n")+(r?"_"+r:"_n"),o=this.rawMesh.subGroupInUse.indexMappings[a];kf.Validator.isValid(o)?this.rawMesh.counts.doubleIndicesCount++:(o=this.rawMesh.subGroupInUse.vertices.length/3,n(),this.rawMesh.subGroupInUse.indexMappings[a]=o,this.rawMesh.subGroupInUse.indexMappingsCount++),this.rawMesh.subGroupInUse.indices.push(o)}else n();this.rawMesh.counts.faceCount++},e.prototype.createRawMeshReport=function(e){return"Input Object number: "+e+"\n\tObject name: "+this.rawMesh.objectName+"\n\tGroup name: "+this.rawMesh.groupName+"\n\tMtllib name: "+this.rawMesh.mtllibName+"\n\tVertex count: "+this.vertices.length/3+"\n\tNormal count: "+this.normals.length/3+"\n\tUV count: "+this.uvs.length/2+"\n\tSmoothingGroup count: "+this.rawMesh.counts.smoothingGroupCount+"\n\tMaterial count: "+this.rawMesh.counts.mtlCount+"\n\tReal MeshOutputGroup count: "+this.rawMesh.subGroups.length},e.prototype.finalizeRawMesh=function(){var e,t,r=this,i=[],n=0,a=0,o=0,s=0,l=0,c=0;for(var u in r.rawMesh.subGroups)if(e=r.rawMesh.subGroups[u],e.vertices.length>0){if(t=e.indices,t.length>0&&a>0)for(var h in t)t[h]=t[h]+a;i.push(e),n+=e.vertices.length,a+=e.indexMappingsCount,o+=e.indices.length,s+=e.colors.length,c+=e.uvs.length,l+=e.normals.length}var d=null;return i.length>0&&(d={ -name:""!==this.rawMesh.groupName?this.rawMesh.groupName:this.rawMesh.objectName,subGroups:i,absoluteVertexCount:n,absoluteIndexCount:o,absoluteColorCount:s,absoluteNormalCount:l,absoluteUvCount:c,faceCount:this.rawMesh.counts.faceCount,doubleIndicesCount:this.rawMesh.counts.doubleIndicesCount}),d},e.prototype.processCompletedMesh=function(){var e=this.finalizeRawMesh();if(kf.Validator.isValid(e)){this.colors.length>0&&this.colors.length!==this.vertices.length&&this._throwError("Vertex Colors were detected, but vertex count and color count do not match!"),this.logging.enabled&&this.logging.debug&&console.debug(this.createRawMeshReport(this.inputObjectCount)),this.inputObjectCount++,this.buildMesh(e);var t=this.globalCounts.currentByte/this.globalCounts.totalBytes;return this.callbackProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*t).toFixed(2)+"%",t),this.resetRawMesh(),!0}return!1},e.prototype.buildMesh=function(e){var t=this,r=e.subGroups,i=new Float32Array(e.absoluteVertexCount);this.globalCounts.vertices+=e.absoluteVertexCount/3,this.globalCounts.faces+=e.faceCount,this.globalCounts.doubleIndicesCount+=e.doubleIndicesCount;var n,a,o,s,l,c,u,h=e.absoluteIndexCount>0?new Uint32Array(e.absoluteIndexCount):null,d=e.absoluteColorCount>0?new Float32Array(e.absoluteColorCount):null,p=e.absoluteNormalCount>0?new Float32Array(e.absoluteNormalCount):null,f=e.absoluteUvCount>0?new Float32Array(e.absoluteUvCount):null,m=kf.Validator.isValid(d),v=[],g=r.length>1,y=0,x=[],b=[],w=0,_=0,S=0,A=0,M=0,T=0,E=0;for(var C in r)if(r.hasOwnProperty(C)){if(n=r[C],u=n.materialName,c=t.rawMesh.faceType<4?u+(m?"_vertexColor":"")+(0===n.smoothingGroup?"_flat":""):6===t.rawMesh.faceType?"defaultPointMaterial":"defaultLineMaterial",s=t.materials[u],l=t.materials[c],!kf.Validator.isValid(s)&&!kf.Validator.isValid(l)){var L=m?"defaultVertexColorMaterial":"defaultMaterial";s=t.materials[L],t.logging.enabled&&console.warn('object_group "'+n.objectName+"_"+n.groupName+'" was defined with unresolvable material "'+u+'"! Assigning "'+L+'".'),u=L,u===c&&(l=s,c=L)}if(!kf.Validator.isValid(l)){var P={materialNameOrg:u,materialName:c,materialProperties:{vertexColors:m?2:0,flatShading:0===n.smoothingGroup}},N={cmd:"materialData",materials:{materialCloneInstructions:P}};t.callbackMeshBuilder(N),t.useAsync&&(t.materials[c]=P)}if(g?(a=x[c],a||(a=y,x[c]=y,v.push(c),y++),E=t.useIndices?n.indices.length:n.vertices.length/3,o={start:T,count:E,index:a},b.push(o),T+=E):v.push(c),i.set(n.vertices,w),w+=n.vertices.length,h&&(h.set(n.indices,_),_+=n.indices.length),d&&(d.set(n.colors,S),S+=n.colors.length),p&&(p.set(n.normals,A),A+=n.normals.length),f&&(f.set(n.uvs,M),M+=n.uvs.length),t.logging.enabled&&t.logging.debug){var O=kf.Validator.isValid(a)?"\n\t\tmaterialIndex: "+a:"",D="\tOutput Object no.: "+t.outputObjectCount+"\n\t\tgroupName: "+n.groupName+"\n\t\tIndex: "+n.index+"\n\t\tfaceType: "+t.rawMesh.faceType+"\n\t\tmaterialName: "+n.materialName+"\n\t\tsmoothingGroup: "+n.smoothingGroup+O+"\n\t\tobjectName: "+n.objectName+"\n\t\t#vertices: "+n.vertices.length/3+"\n\t\t#indices: "+n.indices.length+"\n\t\t#colors: "+n.colors.length/3+"\n\t\t#uvs: "+n.uvs.length/2+"\n\t\t#normals: "+n.normals.length/3;console.debug(D)}}this.outputObjectCount++,this.callbackMeshBuilder({cmd:"meshData",progress:{numericalValue:this.globalCounts.currentByte/this.globalCounts.totalBytes},params:{meshName:e.name},materials:{multiMaterial:g,materialNames:v,materialGroups:b},buffers:{vertices:i,indices:h,colors:d,normals:p,uvs:f},geometryType:this.rawMesh.faceType<4?0:6===this.rawMesh.faceType?2:1},[i.buffer],kf.Validator.isValid(h)?[h.buffer]:null,kf.Validator.isValid(d)?[d.buffer]:null,kf.Validator.isValid(p)?[p.buffer]:null,kf.Validator.isValid(f)?[f.buffer]:null)},e.prototype.finalizeParsing=function(){if(this.logging.enabled&&console.info("Global output object count: "+this.outputObjectCount),this.processCompletedMesh()&&this.logging.enabled){var e="Overall counts: \n\tVertices: "+this.globalCounts.vertices+"\n\tFaces: "+this.globalCounts.faces+"\n\tMultiple definitions: "+this.globalCounts.doubleIndicesCount;console.info(e)}},e}();return e.prototype.loadMtl=function(e,t,r,i,n,a,o){var s=new kf.ResourceDescriptor(e,"MTL");s.setContent(t),this._loadMtl(s,r,i,n,a,o)},e.prototype._loadMtl=function(e,t,i,n,a,o){void 0===jf&&console.error('"MTLLoader" is not available. "OBJLoader2" requires it for loading MTL files.'),r.isValid(e)&&this.logging.enabled&&console.time("Loading MTL: "+e.name);var s=[],l=this,c=function(i){var n=[];if(r.isValid(i)){i.preload(),n=i.materials;for(var a in n)n.hasOwnProperty(a)&&(s[a]=n[a])}r.isValid(e)&&l.logging.enabled&&console.timeEnd("Loading MTL: "+e.name),t(s,i)};if(r.isValid(e)&&(r.isValid(e.content)||r.isValid(e.url))){var u=new jf(this.manager);a=r.verifyInput(a,"anonymous"),u.setCrossOrigin(a),u.setPath(e.path),r.isValid(o)&&u.setMaterialOptions(o);var h=function(e){var t=e;"string"==typeof e||e instanceof String||(e.length>0||e.byteLength>0?t=Iu.decodeText(e):this._throwError("Unable to parse mtl as it it seems to be neither a String, an Array or an ArrayBuffer!")),c(u.parse(t))};if(r.isValid(e.content))h(e.content);else if(r.isValid(e.url)){var d=new we(this.manager);if(r.isValid(n)||(n=function(e){l._onError(e)}),!r.isValid(i)){var p=0,f=0;i=function(t){if(t.lengthComputable&&(f=t.loaded/t.total,f>p)){p=f;var r='Download of "'+e.url+'": '+(100*f).toFixed(2)+"%";l.onProgress("progressLoad",r,f)}}}d.load(e.url,h,i,n)}}else c()},e}(),Jf=function(e){this.manager=void 0!==e?e:Du,this.littleEndian=!0};Jf.prototype={constructor:Jf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),a.load(e,function(r){try{t(n.parse(r,e))}catch(a){if(!i)throw a;i(a)}},r,i)},parse:function(e,t){function r(e){var t={},r=e.search(/[\r\n]DATA\s(\S*)\s/i),i=/[\r\n]DATA\s(\S*)\s/i.exec(e.substr(r-1));if(t.data=i[1],t.headerLen=i[0].length+r,t.str=e.substr(0,t.headerLen),t.str=t.str.replace(/\#.*/gi,""),t.version=/VERSION (.*)/i.exec(t.str),t.fields=/FIELDS (.*)/i.exec(t.str),t.size=/SIZE (.*)/i.exec(t.str),t.type=/TYPE (.*)/i.exec(t.str),t.count=/COUNT (.*)/i.exec(t.str),t.width=/WIDTH (.*)/i.exec(t.str),t.height=/HEIGHT (.*)/i.exec(t.str),t.viewpoint=/VIEWPOINT (.*)/i.exec(t.str),t.points=/POINTS (.*)/i.exec(t.str),null!==t.version&&(t.version=parseFloat(t.version[1])),null!==t.fields&&(t.fields=t.fields[1].split(" ")),null!==t.type&&(t.type=t.type[1].split(" ")),null!==t.width&&(t.width=parseInt(t.width[1])),null!==t.height&&(t.height=parseInt(t.height[1])),null!==t.viewpoint&&(t.viewpoint=t.viewpoint[1]),null!==t.points&&(t.points=parseInt(t.points[1],10)),null===t.points&&(t.points=t.width*t.height),null!==t.size&&(t.size=t.size[1].split(" ").map(function(e){return parseInt(e,10)})),null!==t.count)t.count=t.count[1].split(" ").map(function(e){return parseInt(e,10)});else{t.count=[];for(var n=0,a=t.fields.length;n0&&y.addAttribute("position",new M(o,3)),s.length>0&&y.addAttribute("normal",new M(s,3)),l.length>0&&y.addAttribute("color",new M(l,3)),y.computeBoundingSphere();var x=new Ne({size:.005});l.length>0?x.vertexColors=!0:x.color.setHex(16777215*Math.random());var b=new Et(y,x),w=t.split("").reverse().join("");return w=/([^\/]*)/.exec(w),w=w[1].split("").reverse().join(""),b.name=w,b}};var Zf=function(e){this.manager=void 0!==e?e:Du};Zf.prototype={constructor:Zf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){function t(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function r(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}function i(e,t){return"s"+Math.min(e,t)+"e"+Math.max(e,t)}function n(e,t){var r=parseInt(m[v].substr(e,t));if(r){var n=i(y,r);void 0===f[n]&&(p.push([y-1,r-1,1]),f[n]=p.length-1)}}function a(){var e,t,r={geometryAtoms:new P,geometryBonds:new P,json:{atoms:d,bonds:p}},i=r.geometryAtoms,n=r.geometryBonds,a=[],o=[],s=[];for(e=0,t=d.length;e=t.elements[u].count&&(u++,h=0);var f=i(t.elements[u].properties,p);o(n,t.elements[u].name,f),h++}}return a(n)}function a(e){var t=new P;return e.indices.length>0&&t.setIndex(e.indices),t.addAttribute("position",new M(e.vertices,3)),e.normals.length>0&&t.addAttribute("normal",new M(e.normals,3)),e.uvs.length>0&&t.addAttribute("uv",new M(e.uvs,2)),e.colors.length>0&&t.addAttribute("color",new M(e.colors,3)),t.computeBoundingSphere(),t}function o(e,t,r){if("vertex"===t)e.vertices.push(r.x,r.y,r.z),"nx"in r&&"ny"in r&&"nz"in r&&e.normals.push(r.nx,r.ny,r.nz),"s"in r&&"t"in r&&e.uvs.push(r.s,r.t),"red"in r&&"green"in r&&"blue"in r&&e.colors.push(r.red/255,r.green/255,r.blue/255);else if("face"===t){var i=r.vertex_indices||r.vertex_index;3===i.length?e.indices.push(i[0],i[1],i[2]):4===i.length&&(e.indices.push(i[0],i[1],i[3]),e.indices.push(i[1],i[2],i[3]))}}function s(e,t,r,i){switch(r){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,i),2];case"uint16":case"ushort":return[e.getUint16(t,i),2];case"int32":case"int":return[e.getInt32(t,i),4];case"uint32":case"uint":return[e.getUint32(t,i),4];case"float32":case"float":return[e.getFloat32(t,i),4];case"float64":case"double":return[e.getFloat64(t,i),8]}}function l(e,t,r,i){for(var n,a={},o=0,l=0;l0;return f===p?(r=m?Nc:Lc,t=4):f===d?(r=m?Oc:Pc,t=2):console.error("PVRLoader: Unknown PVR format:",f),e.dataPtr=n,e.bpp=t,e.format=r,e.width=o,e.height=a,e.numSurfaces=u,e.numMipmaps=s+1,e.isCubemap=6===u,nm._extract(e)},nm._extract=function(e){var t={mipmaps:[],width:e.width,height:e.height,format:e.format,mipmapCount:e.numMipmaps,isCubemap:e.isCubemap},r=e.buffer,i=e.dataPtr,n=e.bpp,a=e.numSurfaces,o=0,s=0,l=0,c=0,u=0,h=0;2===n?(l=8,c=4):(l=4,c=4),s=l*c*n/8,t.mipmaps.length=e.numMipmaps*a;for(var d=0;d>d,f=e.height>>d;u=p/l,h=f/c,u<2&&(u=2),h<2&&(h=2),o=u*h*s;for(var m=0;m>5&31)/31,i=(A>>10&31)/31):(t=a,r=o,i=s)}for(var M=1;M<=3;M++){var T=b+12*M;v.push(c.getFloat32(T,!0)),v.push(c.getFloat32(T+4,!0)),v.push(c.getFloat32(T+8,!0)),y.push(w,_,S),h&&n.push(t,r,i)}}return m.addAttribute("position",new g(new Float32Array(v),3)),m.addAttribute("normal",new g(new Float32Array(y),3)),h&&(m.addAttribute("color",new g(new Float32Array(n),3)),m.hasColors=!0,m.alpha=l),m}function a(e){for(var t,r=new P,n=/facet([\s\S]*?)endfacet/g,a=0,o=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,s=new RegExp("vertex"+o+o+o,"g"),l=new RegExp("normal"+o+o+o,"g"),c=[],u=[],h=new i;null!==(t=n.exec(e));){for(var d=0,p=0,f=t[0];null!==(t=l.exec(f));)h.x=parseFloat(t[1]),h.y=parseFloat(t[2]),h.z=parseFloat(t[3]),p++;for(;null!==(t=s.exec(f));)c.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),u.push(h.x,h.y,h.z),d++;1!==p&&console.error("STLLoader: Something isn't right with the normal of face number "+a),3!==d&&console.error("STLLoader: Something isn't right with the vertices of face number "+a),a++}return r.addAttribute("position",new M(c,3)),r.addAttribute("normal",new M(u,3)),r}function o(e){return"string"!=typeof e?Iu.decodeText(new Uint8Array(e)):e}function s(e){if("string"==typeof e){for(var t=new Uint8Array(e.length),r=0;ri;)n-=i;n0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===l&&s===a-1&&(s=a-2,l=1);var c,u,h,d;if(this.closed||s>0?c=n[(s-1)%a]:(om.subVectors(n[0],n[1]).add(n[0]),c=om),u=n[s%a],h=n[(s+1)%a],this.closed||s+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return r.set(gr(o,s.x,l.x,c.x,u.x),gr(o,s.y,l.y,c.y,u.y)),r},Dr.prototype.copy=function(e){var t=this;at.prototype.copy.call(this,e),this.points=[];for(var r=0,i=e.points.length;r=r){var a=i[n]-r,o=t.curves[n],s=o.getLength(),l=0===s?0:1-a/s;return o.getPointAt(l)}n++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){var e=this;if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],r=0,i=0,n=this.curves.length;i1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},copy:function(e){var t=this;at.prototype.copy.call(this,e),this.curves=[];for(var r=0,i=e.curves.length;r0){var c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);var u=l.getPoint(1);this.currentPoint.copy(u)},copy:function(e){return Fr.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=Fr.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return Fr.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Rr.prototype=Object.assign(Object.create(Ir.prototype),{constructor:Rr,getPointsHoles:function(e){for(var t=this,r=[],i=0,n=this.holes.length;i80*r){s=c=e[0],l=u=e[1];for(var f=r;fc&&(c=h),d>u&&(u=d);p=Math.max(c-s,u-l),p=0!==p?1/p:0}return Br(a,o,r,s,l,p),o}},dm={area:function(e){for(var t=e.length,r=0,i=t-1,n=0;nNumber.EPSILON){if(c<0&&(o=t[a],l=-l,s=t[n],c=-c),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var u=c*(e.x-o.x)-l*(e.y-o.y);if(0===u)return!0;if(u<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=dm.isClockWise,a=this.subPaths;if(0===a.length)return[];if(t===!0)return r(a);var o,s,l,c=[];if(1===a.length)return s=a[0],l=new Rr,l.curves=s.curves,c.push(l),c;var u=!n(a[0].getPoints());u=e?!u:u;var h,d=[],p=[],f=[],m=0;p[m]=void 0,f[m]=[];for(var v=0,g=a.length;v1){for(var y=!1,x=[],b=0,w=p.length;b0&&(y||(f=d))}for(var E,v=0,C=p.length;v0&&(i.copy(o),r.currentPath.currentPoint.copy(i),s=!0);break;default:console.warn(p)}l&&(o.copy(i),l=!1)}return r}function n(e,t,r,i,n,o,s,l){i=i*Math.PI/180,t=Math.abs(t),r=Math.abs(r);var c=(s.x-l.x)/2,u=(s.y-l.y)/2,h=Math.cos(i)*c+Math.sin(i)*u,d=-Math.sin(i)*c+Math.cos(i)*u,p=t*t,f=r*r,m=h*h,v=d*d,g=m/p+v/f;if(g>1){var y=Math.sqrt(g);t=y*t,r=y*r,p=t*t,f=r*r}var x=p*v+f*m,b=(p*f-x)/x,w=Math.sqrt(Math.max(0,b));n===o&&(w=-w);var _=w*t*d/r,S=-w*r*h/t,A=Math.cos(i)*_-Math.sin(i)*S+(s.x+l.x)/2,M=Math.sin(i)*_+Math.cos(i)*S+(s.y+l.y)/2,T=a(1,0,(h-_)/t,(d-S)/r),E=a((h-_)/t,(d-S)/r,(-h-_)/t,(-d-S)/r)%(2*Math.PI);e.currentPath.absellipse(A,M,t,r,T,T+E,0===o,i)}function a(e,t,r,i){var n=e*r+t*i,a=Math.sqrt(e*e+t*t)*Math.sqrt(r*r+i*i),o=Math.acos(Math.max(-1,Math.min(1,n/a)));return e*i-t*r<0&&(o=-o),o}function o(e,t){var r=parseFloat(e.getAttribute("x")||0),i=parseFloat(e.getAttribute("y")||0),n=parseFloat(e.getAttribute("rx")||0),a=parseFloat(e.getAttribute("ry")||0),o=parseFloat(e.getAttribute("width")),s=parseFloat(e.getAttribute("height")),l=new pi;return l.color.setStyle(t.fill),l.moveTo(r+2*n,i),l.lineTo(r+o-2*n,i),0===n&&0===a||l.bezierCurveTo(r+o,i,r+o,i,r+o,i+2*a),l.lineTo(r+o,i+s-2*a),0===n&&0===a||l.bezierCurveTo(r+o,i+s,r+o,i+s,r+o-2*n,i+s),l.lineTo(r+2*n,i+s),0===n&&0===a||l.bezierCurveTo(r,i+s,r,i+s,r,i+s-2*a),l.lineTo(r,i+2*a),0===n&&0===a||l.bezierCurveTo(r,i,r,i,r+2*n,i),l}function s(e,t){function r(e,t,r){var i=parseFloat(t),o=parseFloat(r);0===a?n.moveTo(i,o):n.lineTo(i,o),a++}var i=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,n=new pi;n.color.setStyle(t.fill);var a=0;return e.getAttribute("points").replace(i,r),n.currentPath.autoClose=!0,n}function c(e,t){function r(e,t,r){var i=parseFloat(t),o=parseFloat(r);0===a?n.moveTo(i,o):n.lineTo(i,o),a++}var i=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,n=new pi;n.color.setStyle(t.fill);var a=0;return e.getAttribute("points").replace(i,r),n.currentPath.autoClose=!1,n}function u(e,t){var r=parseFloat(e.getAttribute("cx")),i=parseFloat(e.getAttribute("cy")),n=parseFloat(e.getAttribute("r")),a=new Ir;a.absarc(r,i,n,0,2*Math.PI);var o=new pi;return o.color.setStyle(t.fill),o.subPaths.push(a),o}function h(e,t){var r=parseFloat(e.getAttribute("cx")),i=parseFloat(e.getAttribute("cy")),n=parseFloat(e.getAttribute("rx")),a=parseFloat(e.getAttribute("ry")),o=new Ir;o.absellipse(r,i,n,a,0,2*Math.PI);var s=new pi;return s.color.setStyle(t.fill),s.subPaths.push(o),s}function d(e,t){var r=parseFloat(e.getAttribute("x1")),i=parseFloat(e.getAttribute("y1")),n=parseFloat(e.getAttribute("x2")),a=parseFloat(e.getAttribute("y2")),o=new pi;return o.moveTo(r,i),o.lineTo(n,a),o.currentPath.autoClose=!1,o}function p(e,t){return t=Object.assign({},t),e.hasAttribute("fill")&&(t.fill=e.getAttribute("fill")),""!==e.style.fill&&(t.fill=e.style.fill),t}function m(e){return"none"!==e.fill&&"transparent"!==e.fill}function v(e,t){return e-(t-e)}function g(e){for(var t=e.split(/[\s,]+|(?=\s?[+\-])/),r=0;r0&&t.premultiply(M[M.length-1]),L.copy(t),M.push(t)),t}function x(e){var t=e.getAttribute("transform"),r=null,i=t.indexOf("("),n=t.indexOf(")");if(i>0&&i=1){r=new l;var s=o[0],c=s;o.length>=2&&(c=o[1]),r.translate(s,c)}break;case"rotate":if(o.length>=1){var u=0,h=0,d=0;r=new l,u=-o[0]*Math.PI/180,o.length>=3&&(h=o[1],d=o[2]),T.identity().translate(-h,-d),E.identity().rotate(u),C.multiplyMatrices(E,T),T.identity().translate(h,d),r.multiplyMatrices(T,C)}break;case"scale":if(o.length>=1){r=new l;var p=o[0],f=p;o.length>=2&&(f=o[1]),r.scale(p,f)}break;case"skewX":1===o.length&&(r=new l,r.set(1,Math.tan(o[0]*Math.PI/180),0,0,1,0,0,0,1));break;case"skewY":1===o.length&&(r=new l,r.set(1,0,0,Math.tan(o[0]*Math.PI/180),1,0,0,0,1));break;case"matrix":6===o.length&&(r=new l,r.set(o[0],o[2],o[4],o[1],o[3],o[5],0,0,1))}}return r}function b(e,t){function r(e){o.set(e.x,e.y,1).applyMatrix3(t),e.set(o.x,o.y)}for(var n=w(t),a=new f,o=new i,s=e.subPaths,l=0,c=s.length;l=t.end)return 0;this.position=t.cur;try{var r=this.readChunk(e);return t.cur+=r.size,r.id}catch(i){return this.debugMessage("Unable to read chunk at "+this.position),0}},resetPosition:function(){this.position-=6},readByte:function(e){var t=e.getUint8(this.position,!0);return this.position+=1,t},readFloat:function(e){try{var t=e.getFloat32(this.position,!0);return this.position+=4,t}catch(r){this.debugMessage(r+" "+this.position+" "+e.byteLength)}},readInt:function(e){var t=e.getInt32(this.position,!0);return this.position+=4,t},readShort:function(e){var t=e.getInt16(this.position,!0);return this.position+=2,t},readDWord:function(e){var t=e.getUint32(this.position,!0);return this.position+=4,t},readWord:function(e){var t=e.getUint16(this.position,!0);return this.position+=2,t},readString:function(e,t){for(var r=this,i="",n=0;n0;r--){var n=e[r],t={type:n.type};void 0!==n.x2&&void 0!==n.y2?(t.x1=n.x2,t.y1=n.y2,t.x2=n.x1,t.y2=n.y1):void 0!==n.x1&&void 0!==n.y1&&(t.x1=n.x1,t.y1=n.y1),t.x=e[r-1].x,t.y=e[r-1].y,i.push(t)}}),i}return"undefined"==typeof opentype?(console.warn("TTFLoader: The loader requires opentype.js. Make sure it's included before using the loader."),null):t(opentype.parse(e),this.reversed)}};var $m=function(e){this.manager=void 0!==e?e:Du};$m.prototype={constructor:$m,isRecordingPoints:!1,isRecordingFaces:!1,points:[],indexes:[],isRecordingAngles:!1,isRecordingColors:!1,angles:[],colors:[],recordingFieldname:null,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=new we(this.manager);a.load(e,function(e){t(n.parse(e))},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e){function t(e,t){function o(e,t,r,n,a){for(var o=a===!0?1:-1,s=[],l={},c={},h=!1,d=0;dc.y:y.y>=l.y&&y.y0)for(var c=0;c0&&r.indexes.push(y),y=[]):y.push(parseInt(o[c])));/]/.exec(t)&&(y.length>0&&r.indexes.push(y),y=[],r.isRecordingFaces=!1,e[r.recordingFieldname]=r.indexes)}else if(r.isRecordingPoints){if("Coordinate"==e.nodeType)for(;null!==(o=v.exec(t));)a={x:parseFloat(o[1]),y:parseFloat(o[2]),z:parseFloat(o[3])},r.points.push(a);if("TextureCoordinate"==e.nodeType)for(;null!==(o=m.exec(t));)a={x:parseFloat(o[1]),y:parseFloat(o[2])},r.points.push(a);/]/.exec(t)&&(r.isRecordingPoints=!1,e.points=r.points)}else if(r.isRecordingAngles){if(o.length>0)for(var c=0;c-1&&"PointLight"===e.nodeType&&(e.nodeType="AmbientLight");var l=void 0===e.on||e.on,p=void 0!==e.intensity?e.intensity:1,m=new u;if(e.color&&m.copy(e.color),"AmbientLight"===e.nodeType)s=new Ht(m,p),s.visible=l,r.add(s);else if("PointLight"===e.nodeType){var v=0;void 0!==e.radius&&e.radius<1e3&&(v=e.radius),s=new zt(m,p,v),s.visible=l,r.add(s)}else if("SpotLight"===e.nodeType){var p=1,v=0,g=Math.PI/3,y=0,l=!0;void 0!==e.radius&&e.radius<1e3&&(v=e.radius),void 0!==e.cutOffAngle&&(g=e.cutOffAngle),s=new Wt(m,p,v,g,y),s.visible=l,r.add(s)}else if("Transform"===e.nodeType||"Group"===e.nodeType){if(s=new c,/DEF/.exec(e.string)&&(s.name=/DEF\s+([^\s]+)/.exec(e.string)[1],d[s.name]=s),void 0!==e.translation){var x=e.translation;s.position.set(x.x,x.y,x.z)}if(void 0!==e.rotation){var b=e.rotation;s.quaternion.setFromAxisAngle(new i(b.x,b.y,b.z),b.w)}if(void 0!==e.scale){var w=e.scale;s.scale.set(w.x,w.y,w.z)}r.add(s)}else if("Shape"===e.nodeType)s=new k,/DEF/.exec(e.string)&&(s.name=/DEF\s+([^\s]+)/.exec(e.string)[1],d[s.name]=s),r.add(s);else if("Background"===e.nodeType){var _=20,S=2e4,A=new O(S,_,_),T=new F({fog:!1,side:Zs});if(e.skyColor.length>1)o(A,S,e.skyAngle,e.skyColor,!0),T.vertexColors=il;else{var E=e.skyColor[0];T.color.setRGB(E.r,E.b,E.g)}if(t.add(new k(A,T)),void 0!==e.groundColor){S=12e3;var C=new O(S,_,_,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),L=new F({fog:!1,side:Zs,vertexColors:il});o(C,S,e.groundAngle,e.groundColor,!1),t.add(new k(C,L))}}else{if(/geometry/.exec(e.string)){if("Box"===e.nodeType){var w=e.size;r.geometry=new le(w.x,w.y,w.z)}else if("Cylinder"===e.nodeType)r.geometry=new ue(e.radius,e.radius,e.height);else if("Cone"===e.nodeType)r.geometry=new ue(e.topRadius,e.bottomRadius,e.height);else if("Sphere"===e.nodeType)r.geometry=new O(e.radius);else if("IndexedFaceSet"===e.nodeType){var N,D,I,R,U,B,z=new P,j=[],V=[];for(I=0,R=e.children.length;I-1){var W=/DEF\s+([^\s]+)/.exec(G.string)[1];d[W]=j.slice(0)}if(G.string.indexOf("USE")>-1){var X=/USE\s+([^\s]+)/.exec(G.string)[1];j=d[X]}}}var H=0;if(e.coordIndex){var Y=[],q=[];for(N=new i,D=new f,I=0,R=e.coordIndex.length;I=3&&H0&&z.addAttribute("uv",new M(V,2)),z.computeVertexNormals(),z.computeBoundingSphere(),/DEF/.exec(e.string)&&(z.name=/DEF ([^\s]+)/.exec(e.string)[1],d[z.name]=z),r.geometry=z}return}if(/appearance/.exec(e.string)){for(var I=0;I-1;l--){var h=s[l];if(/{.*[{\[]/.test(h)){var d=h.split("{").join("{\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}else if(/\].*}/.test(h)){var d=h.split("]").join("]\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}if(/}.*}/.test(h)){var d=h.split("}").join("}\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}/^\b[^\s]+\b$/.test(h.trim())?(s[l+1]=h+" "+s[l+1].trim(),s.splice(l,1)):h.indexOf("coord")>-1&&h.indexOf("[")<0&&h.indexOf("{")<0&&(s[l]+=" Coordinate {}")}var p=s.shift();return/V1.0/.exec(p)?console.warn("VRMLLoader: V1.0 not supported yet."):/V2.0/.exec(p)&&t(s,o),o}};var ev=function(){function e(e){if(void 0===Nf)throw new Error("VRMLoader: Import GLTFLoader.");this.manager=void 0!==e?e:Du,this.gltfLoader=new Nf(this.manager)}return e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this;this.gltfLoader.load(e,function(e){n.parse(e,t)},r,i)},setCrossOrigin:function(e){return this.glTFLoader.setCrossOrigin(e),this},setPath:function(e){return this.glTFLoader.setPath(e),this},setDRACOLoader:function(e){return this.glTFLoader.setDRACOLoader(e),this},parse:function(e,t){var r=(e.parser,e.userData.gltfExtensions||{});r.VRM||{};t(e)}},e}(),tv=function(e){this.manager=void 0!==e?e:Du};Object.assign(tv.prototype,a.prototype,{load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){function t(e){var t,r=[],i=[],n=[],a=[],o=/(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g,s=/^(\d+)\s+([\s\d]*)/,l=/^POINTS /,c=/^POLYGONS /,u=/^TRIANGLE_STRIPS /,h=/^POINT_DATA[ ]+(\d+)/,d=/^CELL_DATA[ ]+(\d+)/,p=/^COLOR_SCALARS[ ]+(\w+)[ ]+3/,f=/^NORMALS[ ]+(\w+)[ ]+(\w+)/,m=!1,v=!1,g=!1,y=!1,x=!1,b=!1,w=!1,_=e.split("\n");for(var S in _){var A=_[S];if(m)for(;null!==(t=o.exec(A));){var T=parseFloat(t[1]),E=parseFloat(t[2]),C=parseFloat(t[3]);i.push(T,E,C)}else if(v){if(null!==(t=s.exec(A))){var L=parseInt(t[1]),N=t[2].split(/\s+/);if(L>=3)for(var O,D,F=parseInt(N[0]),I=1,R=0;R=3)for(var F,O,D,R=0;R=c.byteLength)break}var _=new P;return _.setIndex(new g(p,1)),_.addAttribute("position",new g(h,3)),d.length===h.length&&_.addAttribute("normal",new g(d,3)),_}function i(e,t){var r=e.length,i=new Float32Array(r+t.length);return i.set(e),i.set(t,r),i}function n(e,t){var r=e.length,i=new Int32Array(r+t.length);return i.set(e),i.set(t,r),i}function a(e){function t(e){var r={};if(1===e.nodeType){if(e.attributes&&e.attributes.length>0){r.attributes={};for(var i=0;i0)throw new Error("Invalid string. Length must be a multiple of 4");u="="===e[o-2]?2:"="===e[o-1]?1:0,h=new r(3*o/4-u),l=u>0?o-4:o;var d=0;for(t=0,s=0;t>16,h[d++]=(65280&c)>>8,h[d++]=255&c;return 2===u?(c=n[e.charCodeAt(t)]<<2|n[e.charCodeAt(t+1)]>>4,h[d++]=255&c):1===u&&(c=n[e.charCodeAt(t)]<<10|n[e.charCodeAt(t+1)]<<4|n[e.charCodeAt(t+2)]>>2,h[d++]=c>>8&255,h[d++]=255&c),h}function a(e,t){var a=0;if("UInt64"===c.attributes.header_type?a=8:"UInt32"===c.attributes.header_type&&(a=4),"binary"===e.attributes.format&&t){var o,s,l,u,h,d,p,f,m;if("Float32"===e.attributes.type)var v=new Float32Array;else if("Int64"===e.attributes.type)var v=new Int32Array;o=e["#text"],l=r(o),u=l[0];for(var g=1;g0?3-d%3:0,d+=p,f=[],m=d,f.push(m),h=3*a;for(var g=0;g0&&(b[w].text=a(b[w],f)),w++;switch(m[v]){case"PointData":var S=parseInt(p.attributes.NumberOfPoints),A=x.attributes.Normals;if(S>0)for(var M=0,T=b.length;M0){var E=x.DataArray.attributes.NumberOfComponents;u=new Float32Array(S*E),u.set(x.DataArray.text,0)}break;case"Strips":var C=parseInt(p.attributes.NumberOfStrips);if(C>0){var L=new Int32Array(x.DataArray[0].text.length),N=new Int32Array(x.DataArray[1].text.length);L.set(x.DataArray[0].text,0),N.set(x.DataArray[1].text,0);var O=C+L.length;d=new Uint32Array(3*O-9*C);for(var D=0,M=0,T=C;M0&&(U=N[M-1]);for(var k=0,R=N[M],U=0;k0&&(U=N[M-1])}}break;case"Polys":var B=parseInt(p.attributes.NumberOfPolys);if(B>0){var L=new Int32Array(x.DataArray[0].text.length),N=new Int32Array(x.DataArray[1].text.length);L.set(x.DataArray[0].text,0),N.set(x.DataArray[1].text,0);var O=B+L.length;d=new Uint32Array(3*O-9*B);for(var D=0,z=0,M=0,T=B,U=0;M=d.maxCount-3&&(d.hasPositions=!0,d.hasNormals=!0,d.enableUvs&&(d.hasUvs=!0),d.enableColors&&(d.hasColors=!0),a(d))}function h(e,t,r){var i=new Float32Array(e.length+r);return i.set(e,0),i.set(t.slice(0,r),e.length),i}fi.call(this,t);var d=this,p=new Float32Array(36),f=new Float32Array(36);this.enableUvs=void 0!==r&&r,this.enableColors=void 0!==i&&i,this.init=function(e){this.resolution=e,this.isolation=80,this.size=e,this.size2=this.size*this.size,this.size3=this.size2*this.size,this.halfsize=this.size/2,this.delta=2/this.size,this.yd=this.size,this.zd=this.size2,this.field=new Float32Array(this.size3),this.normal_cache=new Float32Array(3*this.size3),this.maxCount=4096,this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=new Float32Array(3*this.maxCount),this.normalArray=new Float32Array(3*this.maxCount),this.enableUvs&&(this.uvArray=new Float32Array(2*this.maxCount)),this.enableColors&&(this.colorArray=new Float32Array(3*this.maxCount))},this.begin=function(){this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasUvs=!1,this.hasColors=!1},this.end=function(e){var t=this;if(0!==this.count){for(var r=3*this.count;rthis.size-1&&(d=this.size-1);var p=Math.floor(c-s);p<1&&(p=1);var f=Math.floor(c+s);f>this.size-1&&(f=this.size-1);var m=Math.floor(u-s);m<1&&(m=1);var v=Math.floor(u+s);v>this.size-1&&(v=this.size-1);var g,y,x,b,w,_,S,A,M,T,E;for(x=h;x0&&(a.field[b+g]+=E*o)},this.addPlaneX=function(e,t){var r,i,n,a,o,s,l,c=this.size,u=this.yd,h=this.zd,d=this.field,p=c*Math.sqrt(e/t);for(p>c&&(p=c),r=0;r0)for(i=0;iu&&(f=u),i=0;i0)for(l=i*h,r=0;ru&&(f=u),n=0;n0)for(l=d*n,i=0;ir.far||i.push({distance:x,point:t.clone(),uv:U.getUV(t,c,u,h,d,p,m,new f),face:null, -object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return c.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var sv=function(e,t){var r=this;this.lut=[],this.map=lv[e],this.n=t,this.mapname=e;for(var i=1/this.n,n=0;n<=1;n+=i)for(var a=0;a=r.map[a][0]&&n=this.maxV&&(e=this.maxV),e=(e-this.minV)/(this.maxV-this.minV);var t=Math.round(e*this.n);return t==this.n?t-=1:t,this.lut[t]},addColorMap:function(e,t){lv[e]=t},setLegendOn:function(e){var t=this;void 0===e&&(e={}),this.legend={},this.legend.layout=e.hasOwnProperty("layout")?e.layout:"vertical",this.legend.position=e.hasOwnProperty("position")?e.position:{x:4,y:0,z:0},this.legend.dimensions=e.hasOwnProperty("dimensions")?e.dimensions:{width:.5,height:3},this.legend.canvas=document.createElement("canvas"),this.legend.canvas.setAttribute("id","legend"),this.legend.canvas.setAttribute("hidden",!0),document.body.appendChild(this.legend.canvas),this.legend.ctx=this.legend.canvas.getContext("2d"),this.legend.canvas.setAttribute("width",1),this.legend.canvas.setAttribute("height",this.n),this.legend.texture=new ve(this.legend.canvas);var r=this.legend.ctx.getImageData(0,0,1,this.n),i=r.data;this.map=lv[this.mapname];for(var n=0,a=1/this.n,o=1;o>=0;o-=a)for(var s=this.map.length-1;s>=0;s--)if(o=t.map[s-1][0]){var l=t.map[s-1][0],c=t.map[s][0],h=new u(16777215).setHex(t.map[s-1][1]),d=new u(16777215).setHex(t.map[s][1]),p=h.lerp(d,(o-l)/(c-l));i[4*n]=Math.round(255*p.r),i[4*n+1]=Math.round(255*p.g),i[4*n+2]=Math.round(255*p.b),i[4*n+3]=255,n+=1}return this.legend.ctx.putImageData(r,0,0),this.legend.texture.needsUpdate=!0,this.legend.legendGeometry=new xe(this.legend.dimensions.width,this.legend.dimensions.height),this.legend.legendMaterial=new F({map:this.legend.texture,side:Ks}),this.legend.mesh=new k(this.legend.legendGeometry,this.legend.legendMaterial),"horizontal"==this.legend.layout&&(this.legend.mesh.rotation.z=-90*(Math.PI/180)),this.legend.mesh.position.copy(this.legend.position),this.legend.mesh},setLegendOff:function(){return this.legend=null,this.legend},setLegendLayout:function(e){return!!this.legend&&(this.legend.layout!=e&&(("horizontal"==e||"vertical"==e)&&(this.layout=e,"horizontal"==e&&(this.legend.mesh.rotation.z=90*(Math.PI/180)),"vertical"==e&&(this.legend.mesh.rotation.z=-90*(Math.PI/180)),this.legend.mesh)))},setLegendPosition:function(e){return this.legend.position=new i(e.x,e.y,e.z),this.legend},setLegendLabels:function(e,t){var r=this;if(!this.legend)return!1;"function"==typeof e&&(t=e),void 0===e&&(e={}),this.legend.labels={},this.legend.labels.fontsize=e.hasOwnProperty("fontsize")?e.fontsize:24,this.legend.labels.fontface=e.hasOwnProperty("fontface")?e.fontface:"Arial",this.legend.labels.title=e.hasOwnProperty("title")?e.title:"",this.legend.labels.um=e.hasOwnProperty("um")?" [ "+e.um+" ]":"",this.legend.labels.ticks=e.hasOwnProperty("ticks")?e.ticks:0,this.legend.labels.decimal=e.hasOwnProperty("decimal")?e.decimal:2,this.legend.labels.notation=e.hasOwnProperty("notation")?e.notation:"standard";var n={r:255,g:100,b:100,a:.8},a={r:255,g:0,b:0,a:1},o=4,s=document.createElement("canvas"),l=s.getContext("2d");l.font="Normal "+1.2*this.legend.labels.fontsize+"px "+this.legend.labels.fontface,l.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",l.strokeStyle="rgba("+a.r+","+a.g+","+a.b+","+a.a+")",l.lineWidth=o,l.fillStyle="rgba( 0, 0, 0, 1.0 )",l.fillText(this.legend.labels.title.toString()+this.legend.labels.um.toString(),o,this.legend.labels.fontsize+o);var c=new mi(s);c.minFilter=rc;var u=new Fe({map:c}),h=new vi(u);if(h.scale.set(2,1,1),"vertical"==this.legend.layout&&h.position.set(this.legend.position.x+this.legend.dimensions.width,this.legend.position.y+.45*this.legend.dimensions.height,this.legend.position.z),"horizontal"==this.legend.layout&&h.position.set(1.015*this.legend.position.x,this.legend.position.y+.03*this.legend.dimensions.height,this.legend.position.z),this.legend.labels.ticks>0){var d={},p={};if("vertical"==this.legend.layout)var f=this.legend.position.y+.36*this.legend.dimensions.height,m=this.legend.position.y-.61*this.legend.dimensions.height;if("horizontal"==this.legend.layout)var v=this.legend.position.x+.75*this.legend.dimensions.height,g=this.legend.position.x-1.2*this.legend.dimensions.width;for(var y=0;y5)if(y%2===0)var T=1.7;else var T=2.1;else var T=1.7;A.position.set(M,r.legend.position.y-r.legend.dimensions.width*T,r.legend.position.z)}var E=new I({color:0,linewidth:2}),C=[];if("vertical"==r.legend.layout){var L=r.legend.position.y-.5*r.legend.dimensions.height+.01+r.legend.dimensions.height*((x-r.minV)/(r.maxV-r.minV)*.99);C.push(new i(r.legend.position.x+.55*r.legend.dimensions.width,L,r.legend.position.z)),C.push(new i(r.legend.position.x+.7*r.legend.dimensions.width,L,r.legend.position.z))}if("horizontal"==r.legend.layout){var L=r.legend.position.x-.5*r.legend.dimensions.height+.01+r.legend.dimensions.height*((x-r.minV)/(r.maxV-r.minV)*.99);C.push(new i(L,r.legend.position.y-.55*r.legend.dimensions.width,r.legend.position.z)),C.push(new i(L,r.legend.position.y-.7*r.legend.dimensions.width,r.legend.position.z))}var N=(new P).setFromPoints(C),O=new B(N,E);p[y]=O,d[y]=A}}return{title:h,ticks:d,lines:p}}};var lv={rainbow:[[0,"0x0000FF"],[.2,"0x00FFFF"],[.5,"0x00FF00"],[.8,"0xFFFF00"],[1,"0xFF0000"]],cooltowarm:[[0,"0x3C4EC2"],[.2,"0x9BBCFF"],[.5,"0xDCDCDC"],[.8,"0xF6A385"],[1,"0xB40426"]],blackbody:[[0,"0x000000"],[.2,"0x780000"],[.5,"0xE63200"],[.8,"0xFFFF00"],[1,"0xFFFFFF"]],grayscale:[[0,"0x000000"],[.2,"0x404040"],[.5,"0x7F7F80"],[.8,"0xBFBFBF"],[1,"0xFFFFFF"]]},cv=function(){function e(e,t){for(var i=new Ue,n=[],a=0;a1){var l=s[1];n[l]||(n[l]={start:1/0,end:-(1/0)});var c=n[l];ac.end&&(c.end=a),t||(t=l)}a++}for(var l in n){var c=n[l];r.createAnimation(l,c.start,c.end,e)}this.firstAnimation=t},setAnimationDirectionForward:function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},setAnimationDirectionBackward:function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},setAnimationFPS:function(e,t){var r=this.animationsMap[e];r&&(r.fps=t,r.duration=(r.end-r.start)/r.fps)},setAnimationDuration:function(e,t){var r=this.animationsMap[e];r&&(r.duration=t,r.fps=(r.end-r.start)/r.duration)},setAnimationWeight:function(e,t){var r=this.animationsMap[e];r&&(r.weight=t)},setAnimationTime:function(e,t){var r=this.animationsMap[e];r&&(r.time=t)},getAnimationTime:function(e){var t=0,r=this.animationsMap[e];return r&&(t=r.time),t},getAnimationDuration:function(e){var t=-1,r=this.animationsMap[e];return r&&(t=r.duration),t},playAnimation:function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},stopAnimation:function(e){var t=this.animationsMap[e];t&&(t.active=!1)},update:function(e){for(var t=this,r=0,i=this.animationsList.length;rn.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var o=n.start+Fs.clamp(Math.floor(n.time/a),0,n.length-1),s=n.weight;o!==n.currentFrame&&(t.morphTargetInfluences[n.lastFrame]=0,t.morphTargetInfluences[n.currentFrame]=1*s,t.morphTargetInfluences[o]=0,n.lastFrame=n.currentFrame,n.currentFrame=o);var l=n.time%a/a;n.directionBackwards&&(l=1-l),n.currentFrame!==n.lastFrame?(t.morphTargetInfluences[n.currentFrame]=l*s,t.morphTargetInfluences[n.lastFrame]=(1-l)*s):t.morphTargetInfluences[n.currentFrame]=s}}}});var hv=function(){function e(e,t){for(var i=new Ue,n=[],a=0;a0&&(t=(this.transitionFrames-this.blendCounter)/this.transitionFrames,this.blendCounter-=1),this.meshBody&&(this.meshBody.update(e),this.meshBody.setAnimationWeight(this.activeAnimation,t),this.meshBody.setAnimationWeight(this.oldAnimation,1-t)),this.meshWeapon&&(this.meshWeapon.update(e),this.meshWeapon.setAnimationWeight(this.activeAnimation,t),this.meshWeapon.setAnimationWeight(this.oldAnimation,1-t))},this.updateBehaviors=function(e){var t,r,i=this.controls,n=this.animations;i.crouch?(t=n.crouchMove,r=n.crouchIdle):(t=n.move,r=n.idle),i.jump&&(t=n.jump,r=n.jump),i.attack&&(i.crouch?(t=n.crouchAttack,r=n.crouchAttack):(t=n.attack,r=n.attack)),(i.moveForward||i.moveBackward||i.moveLeft||i.moveRight)&&this.activeAnimation!==t&&this.setAnimation(t),Math.abs(this.speed)<.2*this.maxSpeed&&!(i.moveLeft||i.moveRight||i.moveForward||i.moveBackward)&&this.activeAnimation!==r&&this.setAnimation(r),i.moveForward&&(this.meshBody&&(this.meshBody.setAnimationDirectionForward(this.activeAnimation),this.meshBody.setAnimationDirectionForward(this.oldAnimation)),this.meshWeapon&&(this.meshWeapon.setAnimationDirectionForward(this.activeAnimation),this.meshWeapon.setAnimationDirectionForward(this.oldAnimation))),i.moveBackward&&(this.meshBody&&(this.meshBody.setAnimationDirectionBackward(this.activeAnimation),this.meshBody.setAnimationDirectionBackward(this.oldAnimation)),this.meshWeapon&&(this.meshWeapon.setAnimationDirectionBackward(this.activeAnimation),this.meshWeapon.setAnimationDirectionBackward(this.oldAnimation)))},this.updateMovementModel=function(e){var t=this.controls;t.crouch?this.maxSpeed=this.crouchSpeed:this.maxSpeed=this.walkSpeed,this.maxReverseSpeed=-this.maxSpeed,t.moveForward&&(this.speed=Fs.clamp(this.speed+e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),t.moveBackward&&(this.speed=Fs.clamp(this.speed-e*this.backAcceleration,this.maxReverseSpeed,this.maxSpeed));var r=1;if(t.moveLeft&&(this.bodyOrientation+=e*this.angularSpeed,this.speed=Fs.clamp(this.speed+r*e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),t.moveRight&&(this.bodyOrientation-=e*this.angularSpeed,this.speed=Fs.clamp(this.speed+r*e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),!t.moveForward&&!t.moveBackward)if(this.speed>0){var n=i(this.speed/this.maxSpeed);this.speed=Fs.clamp(this.speed-n*e*this.frontDecceleration,0,this.maxSpeed)}else{var n=i(this.speed/this.maxReverseSpeed);this.speed=Fs.clamp(this.speed+n*e*this.backAcceleration,this.maxReverseSpeed,0)}var a=this.speed*e;this.root.position.x+=Math.sin(this.bodyOrientation)*a,this.root.position.z+=Math.cos(this.bodyOrientation)*a,this.root.rotation.y=this.bodyOrientation}},dv=function(){};dv.prototype.modify=function(e){for(var t=[],r=0,i=e.faces.length;r-1&&e.splice(r,1)}function r(e,t){var r,i,n,a=t.position.distanceTo(e.position),o=0,s=[],l=e.faces.length;for(r=0;r=0;s--)r.faces[s].hasVertex(i)&&o(r.faces[s],t);for(s=r.faces.length-1;s>=0;s--)r.faces[s].replaceVertex(r,i);for(a(r,e),s=0;s0;)t.smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e},function(){function e(e,t,r){var i=Math.min(e,t),n=Math.max(e,t),a=i+"_"+n;return r[a]}function t(e,t,r,i,n,a){var o,s=Math.min(e,t),l=Math.max(e,t),c=s+"_"+l;if(c in i)o=i[c];else{var u=r[s],h=r[l];o={a:u,b:h,newEdge:null,faces:[]},i[c]=o}o.faces.push(n),a[e].edges.push(o),a[t].edges.push(o)}function r(e,r,i,n){var a,o,s;for(a=0,o=e.length;a0;x=new Array(l.length),b={},r(l,c,x,b),w=[];var T,E,C,L,P,N,O;for(m in b){for(E=b[m],C=new i,P=3/8,N=1/8,O=E.faces.length,2!=O&&(P=.5,N=0),C.addVectors(E.a,E.b).multiplyScalar(P),S.set(0,0,0),g=0;g3&&(D=3/(8*p)),F=1-p*D,I=D,p<=2&&2==p&&(F=.75,I=1/8),B=k.clone().multiplyScalar(F),S.set(0,0,0),g=0;gn||v>n||g>n){var y=e.vertices.length,x=s.clone(),b=s.clone();if(m>=v&&m>=g){var w=d.clone();if(w.lerp(p,.5),x.a=l,x.b=y,x.c=u,b.a=y,b.b=c,b.c=u,3===s.vertexNormals.length){var _=s.vertexNormals[0].clone();_.lerp(s.vertexNormals[1],.5),x.vertexNormals[1].copy(_),b.vertexNormals[0].copy(_)}if(3===s.vertexColors.length){var S=s.vertexColors[0].clone();S.lerp(s.vertexColors[1],.5),x.vertexColors[1].copy(S),b.vertexColors[0].copy(S)}t=0}else if(v>=m&&v>=g){var w=p.clone();if(w.lerp(f,.5),x.a=l,x.b=c,x.c=y,b.a=y,b.b=u,b.c=l,3===s.vertexNormals.length){var _=s.vertexNormals[1].clone();_.lerp(s.vertexNormals[2],.5),x.vertexNormals[2].copy(_),b.vertexNormals[0].copy(_),b.vertexNormals[1].copy(s.vertexNormals[2]),b.vertexNormals[2].copy(s.vertexNormals[0])}if(3===s.vertexColors.length){var S=s.vertexColors[1].clone();S.lerp(s.vertexColors[2],.5),x.vertexColors[2].copy(S),b.vertexColors[0].copy(S),b.vertexColors[1].copy(s.vertexColors[2]),b.vertexColors[2].copy(s.vertexColors[0])}t=1}else{var w=d.clone();if(w.lerp(f,.5),x.a=l,x.b=c,x.c=y,b.a=y,b.b=c,b.c=u,3===s.vertexNormals.length){var _=s.vertexNormals[0].clone();_.lerp(s.vertexNormals[2],.5),x.vertexNormals[2].copy(_),b.vertexNormals[0].copy(_)}if(3===s.vertexColors.length){var S=s.vertexColors[0].clone();S.lerp(s.vertexColors[2],.5),x.vertexColors[2].copy(S),b.vertexColors[0].copy(S)}t=2}r.push(x,b),e.vertices.push(w);for(var A=0,M=e.faceVertexUvs.length;A absDirection.z ) {","\t\tif(absDirection.x > absDirection.y )","\t\t\tface = direction.x > 0.0 ? 0 : 3;","\t\telse","\t\t\tface = direction.y > 0.0 ? 1 : 4;","\t}","\telse {","\t\tif(absDirection.z > absDirection.y )","\t\t\tface = direction.z > 0.0 ? 2 : 5;","\t\telse","\t\t\tface = direction.y > 0.0 ? 1 : 4;","\t}","\treturn face;","}"].join("\n")),r=new lr("#define cubeUV_maxLods1 ( log2( cubeUV_textureSize * 0.25 ) - 1.0 )"),i=new lr("#define cubeUV_rangeClamp ( exp2( ( 6.0 - 1.0 ) * 2.0 ) )"),n=new Vf(["vec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness, in float cubeUV_textureSize ) {","\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);","\tfloat dxRoughness = dFdx(roughness);","\tfloat dyRoughness = dFdy(roughness);","\tvec3 dx = dFdx( vec * scale * dxRoughness );","\tvec3 dy = dFdy( vec * scale * dyRoughness );","\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );","\td = clamp(d, 1.0, cubeUV_rangeClamp);","\tfloat mipLevel = 0.5 * log2(d);","\treturn vec2(floor(mipLevel), fract(mipLevel));","}"].join("\n"),[r,i],{derivatives:!0}),a=new lr("#define cubeUV_maxLods2 ( log2( cubeUV_textureSize * 0.25 ) - 2.0 )"),o=new lr("#define cubeUV_rcpTextureSize ( 1.0 / cubeUV_textureSize )"),s=new Vf(["vec2 getCubeUV( vec3 direction, float roughnessLevel, float mipLevel, in float cubeUV_textureSize ) {","\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;","\tfloat a = 16.0 * cubeUV_rcpTextureSize;","","\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );","\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;","\tfloat powScale = exp2_packed.x * exp2_packed.y;","\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;","\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;","","\tbool bRes = mipLevel == 0.0;","\tscale = bRes && (scale < a) ? a : scale;","","\tvec3 r;","\tvec2 offset;","\tint face = getFaceFromDirection(direction);","","\tfloat rcpPowScale = 1.0 / powScale;","","\tif( face == 0) {","\t\tr = vec3(direction.x, -direction.z, direction.y);","\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 1) {","\t\tr = vec3(direction.y, direction.x, direction.z);","\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 2) {","\t\tr = vec3(direction.z, direction.x, direction.y);","\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 3) {","\t\tr = vec3(direction.x, direction.z, direction.y);","\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\telse if( face == 4) {","\t\tr = vec3(direction.y, direction.x, -direction.z);","\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\telse {","\t\tr = vec3(direction.z, -direction.x, direction.y);","\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\tr = normalize(r);","\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;","\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;","\tvec2 base = offset + vec2( texelOffset );","\treturn base + s * ( scale - 2.0 * texelOffset );","}"].join("\n"),[a,o,t]),l=new lr("#define cubeUV_maxLods3 ( log2( cubeUV_textureSize * 0.25 ) - 3.0 )"),c=new Vf(["TextureCubeUVData textureCubeUV( vec3 reflectedDirection, float roughness, in float cubeUV_textureSize ) {","\tfloat roughnessVal = roughness * cubeUV_maxLods3;","\tfloat r1 = floor(roughnessVal);","\tfloat r2 = r1 + 1.0;","\tfloat t = fract(roughnessVal);","\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness, cubeUV_textureSize);","\tfloat s = mipInfo.y;","\tfloat level0 = mipInfo.x;","\tfloat level1 = level0 + 1.0;","\tlevel1 = level1 > 5.0 ? 5.0 : level1;","","\tlevel0 += min( floor( s + 0.5 ), 5.0 );","","\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0, cubeUV_textureSize);","\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0, cubeUV_textureSize);","","\treturn TextureCubeUVData(uv_10, uv_20, t);","}"].join("\n"),[e,l,n,s]);return{TextureCubeUVData:e,textureCubeUV:c}}(),Li.prototype=Object.create(tr.prototype),Li.prototype.constructor=Li,Li.prototype.nodeType="TextureCubeUV",Li.prototype.generate=function(e,t){if(e.isShader("fragment")){var r=e.include(Li.Nodes.textureCubeUV);return e.format(r+"( "+this.uv.build(e,"v3")+", "+this.blinnExponentToRoughness.build(e,"f")+", "+this.textureSize.build(e,"f")+" )",this.getType(e),t)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)},Li.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.blinnExponentToRoughness=this.blinnExponentToRoughness.toJSON(e).uuid),t},Pi.prototype=Object.create(tr.prototype),Pi.prototype.constructor=Pi,Pi.prototype.nodeType="TextureCube",Pi.prototype.generate=function(e,t){if(e.isShader("fragment")){var r=this.uv.build(e)+".uv_10",i=this.uv.build(e)+".uv_20",n=this.uv.build(e)+".t",a=e.getTexelDecodingFunctionFromTexture("texture2D( "+this.value.build(e,"sampler2D")+", "+r+" )",this.value.value),o=e.getTexelDecodingFunctionFromTexture("texture2D( "+this.value.build(e,"sampler2D")+", "+i+" )",this.value.value);return e.format("vec4( mix( "+a+", "+o+", "+n+" ).rgb, 1.0 )",this.getType(e),t)}return console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)},Pi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.blinnExponentToRoughness=this.blinnExponentToRoughness.toJSON(e).uuid,this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid)),t};var _v=xv.elements,Sv=["float","vec2","vec3","vec4"],Av={"float":"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4","int":"i"},Mv={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4"};Ni.prototype={constructor:Ni,build:function(e,t){return this.buildShader("vertex",e),this.buildShader("fragment",t),this.requires.uv[0]&&(this.addVaryCode("varying vec2 vUv;"),this.addVertexFinalCode("vUv = uv;")),this.requires.uv[1]&&(this.addVaryCode("varying vec2 vUv2;"),this.addVertexParsCode("attribute vec2 uv2;"),this.addVertexFinalCode("vUv2 = uv2;")),this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;")),this},buildShader:function(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")},setMaterial:function(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this},addFlow:function(e,t,r){return this.addSlot(e).addCache(t).addContext(r)},removeFlow:function(){return this.removeSlot().removeCache().removeContext()},addCache:function(e){return this.cache=e||"",this.caches.push(this.cache),this},removeCache:function(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this},addContext:function(e){return this.context=Object.assign({},this.context,e),this.contexts.push(this.context),this},removeContext:function(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this},addSlot:function(e){return this.slot=e||"",this.slots.push(this.slot),this},removeSlot:function(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this},addVertexCode:function(e){this.addCode(e,"vertex")},addFragmentCode:function(e){this.addCode(e,"fragment")},addCode:function(e,t){this.code[t||this.shader]+=e+"\n"},addVertexNodeCode:function(e){this.addNodeCode(e,"vertex")},addFragmentNodeCode:function(e){this.addNodeCode(e,"fragment")},addNodeCode:function(e,t){this.nodeCode[t||this.shader]+=e+"\n"},clearNodeCode:function(e){e=e||this.shader;var t=this.nodeCode[e];return this.nodeCode[e]="",t},clearVertexNodeCode:function(){return this.clearNodeCode("vertex")},clearFragmentNodeCode:function(){return this.clearNodeCode("fragment")},addVertexFinalCode:function(e){this.addFinalCode(e,"vertex")},addFragmentFinalCode:function(e){this.addFinalCode(e,"fragment")},addFinalCode:function(e,t){this.finalCode[t||this.shader]+=e+"\n"},addVertexParsCode:function(e){this.addParsCode(e,"vertex")},addFragmentParsCode:function(e){this.addParsCode(e,"fragment")},addParsCode:function(e,t){this.parsCode[t||this.shader]+=e+"\n"},addVaryCode:function(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)},isCache:function(e){return this.caches.indexOf(e)!==-1},isSlot:function(e){return this.slots.indexOf(e)!==-1},define:function(e,t){this.defines[e]=void 0===t?1:t},isDefined:function(e){return void 0!==this.defines[e]},getVar:function(e,t,r,i){i=i||"varying";var n=this.getVars(i),a=n[e];if(!a){var o=n.length,s=r?r:"nVv"+o;a={name:s,type:t},n.push(a),n[e]=a}return a},getTempVar:function(e,t,r){return this.getVar(e,t,r,this.shader)},getAttribute:function(e,t){if(!this.attributes[e]){var r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]},getCode:function(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")},getVarListCode:function(e,t){var r=this;t=t||"";for(var i="",n=0,a=e.length;nal,this.needsUpdate=!1,this},Fi.prototype.copy=function(e){var t=this,r=this.uuid;for(var i in e)t[i]=e[i];this.uuid=r,void 0!==e.userData&&(this.userData=JSON.parse(JSON.stringify(e.userData)))},Fi.prototype.toJSON=function(e){var t=void 0===e||"string"==typeof e;if(t&&(e={nodes:{}}),e&&!e.materials&&(e.materials={}),!e.materials[this.uuid]){var r={};r.uuid=this.uuid,r.type=this.type,e.materials[r.uuid]=r,""!==this.name&&(r.name=this.name),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==al&&(r.blending=this.blending),this.flatShading===!0&&(r.flatShading=this.flatShading),this.side!==Js&&(r.side=this.side),this.vertexColors!==tl&&(r.vertexColors=this.vertexColors),this.depthFunc!==Ll&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.morphTargets===!0&&(r.morphTargets=!0),this.skinning===!0&&(r.skinning=!0),this.visible===!1&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.fog=this.fog,r.lights=this.lights,r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid}return e.material=this.uuid,e},Ii.prototype=Object.create(ar.prototype),Ii.prototype.constructor=Ii,Ii.prototype.nodeType="Vector2",xv.addShortcuts(Ii.prototype,"value",["x","y"]),Ii.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("vec2( "+this.x+", "+this.y+" )",i,t)},Ii.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.copy(e)},Ii.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.x,t.y=this.y,this.readonly===!0&&(t.readonly=!0)),t},Ri.prototype=Object.create(Ii.prototype),Ri.prototype.constructor=Ri,Ri.prototype.nodeType="Resolution",Ri.prototype.updateFrame=function(e){if(e.renderer){var t=e.renderer.getSize(),r=e.renderer.getPixelRatio();this.x=t.width*r,this.y=t.height*r}else console.warn("ResolutionNode need a renderer in NodeFrame")},Ri.prototype.copy=function(e){Ii.prototype.copy.call(this,e),this.renderer=e.renderer},Ri.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.renderer=this.renderer.uuid),t},Ui.prototype=Object.create(tr.prototype),Ui.prototype.constructor=Ui,Ui.prototype.nodeType="ScreenUV",Ui.prototype.generate=function(e,t){var r;return e.isShader("fragment")?r="( gl_FragCoord.xy / "+this.resolution.build(e,"v2")+")":(console.warn("ScreenUVNode is not compatible with "+e.shader+" shader."),r="vec2( 0.0 )"),e.format(r,this.getType(e),t)},Ui.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.resolution=e.resolution},Ui.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.resolution=this.resolution.toJSON(e).uuid),t},ki.prototype=Object.create(or.prototype),ki.prototype.constructor=ki,ki.prototype.nodeType="MaxMIPLevel",Object.defineProperties(ki.prototype,{value:{get:function(){if(0===this.maxMIPLevel){var e=this.texture.value.image?this.texture.value.image[0]:void 0;this.maxMIPLevel=void 0!==e?Math.log(Math.max(e.width,e.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}}),ki.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.uuid),t},Bi.Nodes=function(){var e=new Vf(["float getSpecularMIPLevel( const in float blinnShininessExponent, const in float maxMIPLevelScalar ) {","\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );","\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join("\n"));return{getSpecularMIPLevel:e}}(),Bi.prototype=Object.create(tr.prototype),Bi.prototype.constructor=Bi,Bi.prototype.nodeType="RoughnessToBlinnExponent",Bi.prototype.generate=function(e,t){if(e.isShader("fragment")){ +},Lu={uniforms:{textureWidth:{value:1},textureHeight:{value:1},focalDepth:{value:1},focalLength:{value:24},fstop:{value:.9},tColor:{value:null},tDepth:{value:null},maxblur:{value:1},showFocus:{value:0},manualdof:{value:0},vignetting:{value:0},depthblur:{value:0},threshold:{value:.5},gain:{value:2},bias:{value:.5},fringe:{value:.7},znear:{value:.1},zfar:{value:100},noise:{value:1},dithering:{value:1e-4},pentagon:{value:0},shaderFocus:{value:1},focusCoords:{value:new f}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float textureWidth;","uniform float textureHeight;","uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below","uniform float focalLength; //focal length in mm","uniform float fstop; //f-stop value","uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)","","uniform float znear; // camera clipping start","uniform float zfar; // camera clipping end","//------------------------------------------","//user variables","const int samples = SAMPLES; //samples on the first ring","const int rings = RINGS; //ring count","const int maxringsamples = rings * samples;","uniform bool manualdof; // manual dof calculation","float ndofstart = 1.0; // near dof blur start","float ndofdist = 2.0; // near dof blur falloff distance","float fdofstart = 1.0; // far dof blur start","float fdofdist = 3.0; // far dof blur falloff distance","float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)","uniform bool vignetting; // use optical lens vignetting","float vignout = 1.3; // vignetting outer border","float vignin = 0.0; // vignetting inner border","float vignfade = 22.0; // f-stops till vignete fades","uniform bool shaderFocus;","// disable if you use external focalDepth value","uniform vec2 focusCoords;","// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)","// if center of screen use vec2(0.5, 0.5);","uniform float maxblur;","//clamp value of max blur (0.0 = no blur, 1.0 default)","uniform float threshold; // highlight threshold;","uniform float gain; // highlight gain;","uniform float bias; // bokeh edge bias","uniform float fringe; // bokeh chromatic aberration / fringing","uniform bool noise; //use noise instead of pattern for sample dithering","uniform float dithering;","uniform bool depthblur; // blur the depth buffer","float dbsize = 1.25; // depth blur size","","uniform bool pentagon; //use pentagon as bokeh shape?","float feather = 0.4; //pentagon shape feather","//------------------------------------------","float penta(vec2 coords) {","//pentagonal shape","float scale = float(rings) - 1.3;","vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);","vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);","vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);","vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);","vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);","vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);","vec4 one = vec4( 1.0 );","vec4 P = vec4((coords),vec2(scale, scale));","vec4 dist = vec4(0.0);","float inorout = -4.0;","dist.x = dot( P, HS0 );","dist.y = dot( P, HS1 );","dist.z = dot( P, HS2 );","dist.w = dot( P, HS3 );","dist = smoothstep( -feather, feather, dist );","inorout += dot( dist, one );","dist.x = dot( P, HS4 );","dist.y = HS5.w - abs( P.z );","dist = smoothstep( -feather, feather, dist );","inorout += dist.x;","return clamp( inorout, 0.0, 1.0 );","}","float bdepth(vec2 coords) {","// Depth buffer blur","float d = 0.0;","float kernel[9];","vec2 offset[9];","vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;","offset[0] = vec2(-wh.x,-wh.y);","offset[1] = vec2( 0.0, -wh.y);","offset[2] = vec2( wh.x -wh.y);","offset[3] = vec2(-wh.x, 0.0);","offset[4] = vec2( 0.0, 0.0);","offset[5] = vec2( wh.x, 0.0);","offset[6] = vec2(-wh.x, wh.y);","offset[7] = vec2( 0.0, wh.y);","offset[8] = vec2( wh.x, wh.y);","kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;","kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;","kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;","for( int i=0; i<9; i++ ) {","float tmp = texture2D(tDepth, coords + offset[i]).r;","d += tmp * kernel[i];","}","return d;","}","vec3 color(vec2 coords,float blur) {","//processing the sample","vec3 col = vec3(0.0);","vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);","col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;","col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;","col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;","vec3 lumcoeff = vec3(0.299,0.587,0.114);","float lum = dot(col.rgb, lumcoeff);","float thresh = max((lum-threshold)*gain, 0.0);","return col+mix(vec3(0.0),col,thresh*blur);","}","vec3 debugFocus(vec3 col, float blur, float depth) {","float edge = 0.002*depth; //distance based edge smoothing","float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);","float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);","col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);","col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);","return col;","}","float linearize(float depth) {","return -zfar * znear / (depth * (zfar - znear) - zfar);","}","float vignette() {","float dist = distance(vUv.xy, vec2(0.5,0.5));","dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);","return clamp(dist,0.0,1.0);","}","float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {","float rings2 = float(rings);","float step = PI*2.0 / float(ringsamples);","float pw = cos(j*step)*i;","float ph = sin(j*step)*i;","float p = 1.0;","if (pentagon) {","p = penta(vec2(pw,ph));","}","col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;","return 1.0 * mix(1.0, i /rings2, bias) * p;","}","void main() {","//scene depth calculation","float depth = linearize(texture2D(tDepth,vUv.xy).x);","// Blur depth?","if ( depthblur ) {","depth = linearize(bdepth(vUv.xy));","}","//focal plane calculation","float fDepth = focalDepth;","if (shaderFocus) {","fDepth = linearize(texture2D(tDepth,focusCoords).x);","}","// dof blur factor calculation","float blur = 0.0;","if (manualdof) {","float a = depth-fDepth; // Focal plane","float b = (a-fdofstart)/fdofdist; // Far DoF","float c = (-a-ndofstart)/ndofdist; // Near Dof","blur = (a>0.0) ? b : c;","} else {","float f = focalLength; // focal length in mm","float d = fDepth*1000.0; // focal plane in mm","float o = depth*1000.0; // depth in mm","float a = (o*f)/(o-f);","float b = (d*f)/(d-f);","float c = (d-f)/(d*fstop*CoC);","blur = abs(a-b)*c;","}","blur = clamp(blur,0.0,1.0);","// calculation of pattern for dithering","vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;","// getting blur x and y step factor","float w = (1.0/textureWidth)*blur*maxblur+noise.x;","float h = (1.0/textureHeight)*blur*maxblur+noise.y;","// calculation of final color","vec3 col = vec3(0.0);","if(blur < 0.05) {","//some optimization thingy","col = texture2D(tColor, vUv.xy).rgb;","} else {","col = texture2D(tColor, vUv.xy).rgb;","float s = 1.0;","int ringsamples;","for (int i = 1; i <= rings; i++) {","","ringsamples = i * samples;","for (int j = 0 ; j < maxringsamples ; j++) {","if (j >= ringsamples) break;","s += gather(float(i), float(j), ringsamples, col, w, h, blur);","}","","}","col /= s; //divide by sample count","}","if (showFocus) {","col = debugFocus(col, blur, depth);","}","if (vignetting) {","col *= vignette();","}","gl_FragColor.rgb = col;","gl_FragColor.a = 1.0;","} "].join("\n")},Pu={uniforms:{mNear:{value:1},mFar:{value:1e3}},vertexShader:["varying float vViewZDepth;","void main() {","\t#include ","\t#include ","\tvViewZDepth = - mvPosition.z;","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","varying float vViewZDepth;","void main() {","\tfloat color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );","\tgl_FragColor = vec4( vec3( color ), 1.0 );","} "].join("\n")},Nu=function(e,t,r,i){de.call(this,e,t,r,i),this.type="CinematicCamera",this.postprocessing={enabled:!0},this.shaderSettings={rings:3,samples:4};var n=Pu;this.materialDepth=new pe({uniforms:n.uniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader}),this.materialDepth.uniforms.mNear.value=r,this.materialDepth.uniforms.mFar.value=i,this.setLens(),this.initPostProcessing()};Nu.prototype=Object.create(de.prototype),Nu.prototype.constructor=Nu,Nu.prototype.setLens=function(e,t,r,i){void 0===e&&(e=35),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e),void 0===r&&(r=8),void 0===i&&(i=.019),this.fNumber=r,this.coc=i,this.aperture=e/this.fNumber,this.hyperFocal=e*e/(this.aperture*this.coc)},Nu.prototype.linearize=function(e){var t=this.far,r=this.near;return-t*r/(e*(t-r)-t)},Nu.prototype.smoothstep=function(e,t,r){var i=this.saturate((r-e)/(t-e));return i*i*(3-2*i)},Nu.prototype.saturate=function(e){return Math.max(0,Math.min(1,e))},Nu.prototype.focusAt=function(e){void 0===e&&(e=20);var t=this.getFocalLength();this.focus=e,this.nearPoint=this.hyperFocal*this.focus/(this.hyperFocal+(this.focus-t)),this.farPoint=this.hyperFocal*this.focus/(this.hyperFocal-(this.focus-t)),this.depthOfField=this.farPoint-this.nearPoint,this.depthOfField<0&&(this.depthOfField=0),this.sdistance=this.smoothstep(this.near,this.far,this.focus),this.ldistance=this.linearize(1-this.sdistance),this.postprocessing.bokeh_uniforms.focalDepth.value=this.ldistance},Nu.prototype.initPostProcessing=function(){if(this.postprocessing.enabled){this.postprocessing.scene=new fe,this.postprocessing.camera=new me(Ds.innerWidth/-2,Ds.innerWidth/2,Ds.innerHeight/2,Ds.innerHeight/-2,(-1e4),1e4),this.postprocessing.scene.add(this.postprocessing.camera);var e={minFilter:rc,magFilter:rc,format:yc};this.postprocessing.rtTextureDepth=new ge(Ds.innerWidth,Ds.innerHeight,e),this.postprocessing.rtTextureColor=new ge(Ds.innerWidth,Ds.innerHeight,e);var t=Cu;this.postprocessing.bokeh_uniforms=Mu.clone(t.uniforms),this.postprocessing.bokeh_uniforms.tColor.value=this.postprocessing.rtTextureColor.texture,this.postprocessing.bokeh_uniforms.tDepth.value=this.postprocessing.rtTextureDepth.texture,this.postprocessing.bokeh_uniforms.manualdof.value=0,this.postprocessing.bokeh_uniforms.shaderFocus.value=0,this.postprocessing.bokeh_uniforms.fstop.value=2.8,this.postprocessing.bokeh_uniforms.showFocus.value=1,this.postprocessing.bokeh_uniforms.focalDepth.value=.1,this.postprocessing.bokeh_uniforms.znear.value=this.near,this.postprocessing.bokeh_uniforms.zfar.value=this.near,this.postprocessing.bokeh_uniforms.textureWidth.value=Ds.innerWidth,this.postprocessing.bokeh_uniforms.textureHeight.value=Ds.innerHeight,this.postprocessing.materialBokeh=new pe({uniforms:this.postprocessing.bokeh_uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,defines:{RINGS:this.shaderSettings.rings,SAMPLES:this.shaderSettings.samples,DEPTH_PACKING:1}}),this.postprocessing.quad=new k(new xe(Ds.innerWidth,Ds.innerHeight),this.postprocessing.materialBokeh),this.postprocessing.quad.position.z=-500,this.postprocessing.scene.add(this.postprocessing.quad)}},Nu.prototype.renderCinematic=function(e,t){this.postprocessing.enabled&&(t.clear(),e.overrideMaterial=null,t.render(e,camera,this.postprocessing.rtTextureColor,!0),e.overrideMaterial=this.materialDepth,t.render(e,camera,this.postprocessing.rtTextureDepth,!0),t.render(this.postprocessing.scene,this.postprocessing.camera))};var Ou={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Du=new be,Fu={};Object.assign(we.prototype,{load:function(e,t,r,i){var n=this;void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var a=this,o=Ou.get(e);if(void 0!==o)return a.manager.itemStart(e),setTimeout(function(){t&&t(o),a.manager.itemEnd(e)},0),o;if(void 0!==Fu[e])return void Fu[e].push({onLoad:t,onProgress:r,onError:i});var s=/^data:(.*?)(;base64)?,(.*)$/,l=e.match(s);if(l){var c=l[1],u=!!l[2],h=l[3];h=Ds.decodeURIComponent(h),u&&(h=Ds.atob(h));try{var d,p=(this.responseType||"").toLowerCase();switch(p){case"arraybuffer":case"blob":for(var f=new Uint8Array(h.length),m=0;m0||0===e.search(/^data\:image\/jpeg/);n.format=i?yc:xc,n.needsUpdate=!0,void 0!==t&&t(n)},r,i),n},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),ke.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,r=0,i=t.length;r1?e.skinWeights[i+1]:0,s=r>2?e.skinWeights[i+2]:0,l=r>3?e.skinWeights[i+3]:0;t.skinWeights.push(new v(a,o,s,l))}if(e.skinIndices)for(var i=0,n=e.skinIndices.length;i1?e.skinIndices[i+1]:0,h=r>2?e.skinIndices[i+2]:0,d=r>3?e.skinIndices[i+3]:0;t.skinIndices.push(new v(c,u,h,d))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}function r(e,t){var r=e.scale;if(void 0!==e.morphTargets)for(var n=0,a=e.morphTargets.length;n0){console.warn('JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=t.faces,d=e.morphColors[0].colors,n=0,a=h.length;n0&&(t.animations=r)}return function(i,a){void 0!==i.data&&(i=i.data),void 0!==i.scale?i.scale=1/i.scale:i.scale=1;var o=new m;if(e(i,o),t(i,o),r(i,o),n(i,o),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===i.materials||0===i.materials.length)return{geometry:o};var s=ke.prototype.initMaterials(i.materials,a,this.crossOrigin);return{geometry:o,materials:s}}}()});var Iu=function(e){"boolean"==typeof e&&(console.warn("BinaryLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Du};Iu.prototype={constructor:Iu,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this.texturePath||Ru.extractUrlBase(e),a=this.binaryPath||Ru.extractUrlBase(e),o=this,s=new we(this.manager);s.load(e,function(e){var s=JSON.parse(e),l=a+s.buffers,c=new we(o.manager);c.setResponseType("arraybuffer"),c.load(l,function(e){o.parse(e,t,n,s.materials)},r,i)},r,i)},setBinaryPath:function(e){return this.binaryPath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},setTexturePath:function(e){return this.texturePath=e,this},parse:function(e,t,r,n){var a=function(){function t(e){return e%4?4-e%4:0}function r(e,t){var r={signature:n(e,t,12),header_bytes:a(e,t+12),vertex_coordinate_bytes:a(e,t+13),normal_coordinate_bytes:a(e,t+14),uv_coordinate_bytes:a(e,t+15),vertex_index_bytes:a(e,t+16),normal_index_bytes:a(e,t+17),uv_index_bytes:a(e,t+18),material_index_bytes:a(e,t+19),nvertices:o(e,t+20),nnormals:o(e,t+20+4),nuvs:o(e,t+20+8),ntri_flat:o(e,t+20+12),ntri_smooth:o(e,t+20+16),ntri_flat_uv:o(e,t+20+20),ntri_smooth_uv:o(e,t+20+24),nquad_flat:o(e,t+20+28),nquad_smooth:o(e,t+20+32),nquad_flat_uv:o(e,t+20+36),nquad_smooth_uv:o(e,t+20+40)};return r}function n(e,t,r){return Ru.decodeText(new Uint8Array(e,t,r))}function a(e,t){var r=new Uint8Array(e,t,1);return r[0]}function o(e,t){var r=new Uint32Array(e,t,1);return r[0]}function s(t){var r,n,a,o,s=E.nvertices,l=new Float32Array(e,t,3*s);for(r=0;r0){var r=n(this.speed/this.MAX_SPEED);this.speed=Fs.clamp(this.speed-r*e*this.FRONT_DECCELERATION,0,this.MAX_SPEED),this.acceleration=Fs.clamp(this.acceleration-r*e,0,1)}else{var r=n(this.speed/this.MAX_REVERSE_SPEED);this.speed=Fs.clamp(this.speed+r*e*this.BACK_ACCELERATION,this.MAX_REVERSE_SPEED,0),this.acceleration=Fs.clamp(this.acceleration+r*e,-1,0)}t.moveLeft||t.moveRight||(this.wheelOrientation>0?this.wheelOrientation=Fs.clamp(this.wheelOrientation-e*this.WHEEL_ANGULAR_DECCELERATION,0,this.MAX_WHEEL_ROTATION):this.wheelOrientation=Fs.clamp(this.wheelOrientation+e*this.WHEEL_ANGULAR_DECCELERATION,-this.MAX_WHEEL_ROTATION,0));var i=this.speed*e;this.carOrientation+=i*this.STEERING_RADIUS_RATIO*this.wheelOrientation,this.root.position.x+=Math.sin(this.carOrientation)*i,this.root.position.z+=Math.cos(this.carOrientation)*i,this.root.rotation.y=this.carOrientation,this.loaded&&(this.bodyMesh.rotation.z=this.MAX_TILT_SIDES*this.wheelOrientation*(this.speed/this.MAX_SPEED),this.bodyMesh.rotation.x=-this.MAX_TILT_FRONTBACK*this.acceleration);var a=1/(this.modelScale*(this.wheelDiameter/2)),o=i*a;this.loaded&&(this.frontLeftWheelMesh.rotation.x+=o,this.frontRightWheelMesh.rotation.x+=o,this.backLeftWheelMesh.rotation.x+=o,this.backRightWheelMesh.rotation.x+=o),this.frontLeftWheelRoot.rotation.y=this.wheelOrientation,this.frontRightWheelRoot.rotation.y=this.wheelOrientation}},ku=function(e){var t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;var r=function(e){t.deviceOrientation=e},a=function(){t.screenOrientation=Ds.orientation||0},s=function(){var e=new i(0,0,1),t=new o,r=new n,a=new n((-Math.sqrt(.5)),0,0,Math.sqrt(.5));return function(i,n,o,s,l){t.set(o,n,-s,"YXZ"),i.setFromEuler(t),i.multiply(a),i.multiply(r.setFromAxisAngle(e,-l))}}();this.connect=function(){a(),Ds.addEventListener("orientationchange",a,!1),Ds.addEventListener("deviceorientation",r,!1),t.enabled=!0},this.disconnect=function(){Ds.removeEventListener("orientationchange",a,!1),Ds.removeEventListener("deviceorientation",r,!1),t.enabled=!1},this.update=function(){if(t.enabled!==!1){var e=t.deviceOrientation;if(e){var r=e.alpha?Fs.degToRad(e.alpha)+t.alphaOffset:0,i=e.beta?Fs.degToRad(e.beta):0,n=e.gamma?Fs.degToRad(e.gamma):0,a=t.screenOrientation?Fs.degToRad(t.screenOrientation):0;s(t.object.quaternion,r,i,n,a)}}},this.dispose=function(){t.disconnect()},this.connect()};Object.assign(ze.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new i,t=new i;return function(r,i,n){var a=e.subVectors(n,i).cross(t.subVectors(r,i)).normalize();return this.setFromNormalAndCoplanarPoint(a,r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("Plane: .projectPoint() target is now required"),t=new i),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new i;return function(t,r){void 0===r&&(console.warn("Plane: .intersectLine() target is now required"),r=new i);var n=t.delta(e),a=this.normal.dot(n);if(0!==a){var o=-(t.start.dot(this.normal)+this.constant)/a;if(!(o<0||o>1))return r.copy(n).multiplyScalar(o).add(t.start)}else if(0===this.distanceToPoint(t.start))return r.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("Plane: .coplanarPoint() target is now required"),e=new i),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new i,t=new l;return function(r,i){var n=i||t.getNormalMatrix(r),a=this.coplanarPoint(e).applyMatrix4(r),o=this.normal.applyMatrix3(n).normalize();return this.constant=-a.dot(o),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(je.prototype,{linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){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()):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)):console.error("Raycaster: Unsupported camera type.")},intersectObject:function(e,t,r){var i=r||[];return Ge(e,this,i,t),i.sort(Ve),i},intersectObjects:function(e,t,r){var i=this,n=r||[];if(Array.isArray(e)===!1)return console.warn("Raycaster.intersectObjects: objects is not an Array."),n;for(var a=0,o=e.length;a0){var o=a[0].object;m.setFromNormalAndCoplanarPoint(t.getWorldDirection(m.normal),o.position),w!==o&&(_.dispatchEvent({type:"hoveron",object:o}),r.style.cursor="pointer",w=o)}else null!==w&&(_.dispatchEvent({type:"hoveroff",object:w}),r.style.cursor="auto",w=null)}function l(i){i.preventDefault(),v.setFromCamera(g,t);var n=v.intersectObjects(e);n.length>0&&(b=n[0].object,v.ray.intersectPlane(m,x)&&y.copy(x).sub(b.position),r.style.cursor="move",_.dispatchEvent({type:"dragstart",object:b}))}function c(e){e.preventDefault(),b&&(_.dispatchEvent({type:"dragend",object:b}),b=null),r.style.cursor=w?"pointer":"auto"}function u(e){e.preventDefault(),e=e.changedTouches[0];var i=r.getBoundingClientRect();if(g.x=(e.clientX-i.left)/i.width*2-1,g.y=2*-((e.clientY-i.top)/i.height)+1,v.setFromCamera(g,t),b&&_.enabled)return v.ray.intersectPlane(m,x)&&b.position.copy(x.sub(y)),void _.dispatchEvent({type:"drag",object:b})}function h(i){i.preventDefault(),i=i.changedTouches[0];var n=r.getBoundingClientRect();g.x=(i.clientX-n.left)/n.width*2-1,g.y=2*-((i.clientY-n.top)/n.height)+1,v.setFromCamera(g,t);var a=v.intersectObjects(e);a.length>0&&(b=a[0].object,m.setFromNormalAndCoplanarPoint(t.getWorldDirection(m.normal),b.position),v.ray.intersectPlane(m,x)&&y.copy(x).sub(b.position),r.style.cursor="move",_.dispatchEvent({type:"dragstart",object:b}))}function d(e){e.preventDefault(),b&&(_.dispatchEvent({type:"dragend",object:b}),b=null),r.style.cursor="auto"}if(e instanceof he){console.warn("DragControls: Constructor now expects ( objects, camera, domElement )");var p=e;e=t,t=p}var m=new ze,v=new je,g=new f,y=new i,x=new i,b=null,w=null,_=this;n(),this.enabled=!0,this.activate=n,this.deactivate=a,this.dispose=o,this.setObjects=function(){console.error("DragControls: setObjects() has been removed.")},this.on=function(e,t){console.warn("DragControls: on() has been deprecated. Use addEventListener() instead."),_.addEventListener(e,t)},this.off=function(e,t){console.warn("DragControls: off() has been deprecated. Use removeEventListener() instead."),_.removeEventListener(e,t)},this.notify=function(e){console.error("DragControls: notify() has been deprecated. Use dispatchEvent() instead."),_.dispatchEvent({type:e})}};Bu.prototype=Object.create(a.prototype),Bu.prototype.constructor=Bu,Object.assign(We.prototype,{set:function(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Fs.clamp(t/this.radius,-1,1))),this}});var zu=function(e,t){function r(e){h.enabled!==!1&&(0===e.button?y=g.ROTATE:1===e.button?y=g.ZOOM:2===e.button&&(y=g.PAN),_.set(e.clientX,e.clientY),t.addEventListener("mousemove",n,!1),t.addEventListener("mouseup",a,!1),t.addEventListener("mouseout",a,!1),t.addEventListener("dblclick",a,!1))}function n(e){if(h.enabled!==!1){w.set(e.clientX,e.clientY);var t=w.x-_.x,r=w.y-_.y;y===g.ROTATE?h.rotate(m.set(-t*h.rotationSpeed,-r*h.rotationSpeed,0)):y===g.ZOOM?h.zoom(m.set(0,0,r)):y===g.PAN&&h.pan(m.set(-t,r,0)),_.set(e.clientX,e.clientY)}}function a(e){t.removeEventListener("mousemove",n,!1),t.removeEventListener("mouseup",a,!1),t.removeEventListener("mouseout",a,!1),t.removeEventListener("dblclick",a,!1),y=g.NONE}function o(e){e.preventDefault(),h.zoom(m.set(0,0,e.deltaY>0?1:-1))}function s(e){e.preventDefault()}function c(e){if(h.enabled!==!1){switch(e.touches.length){case 1:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[0].pageX,e.touches[0].pageY,0);break;case 2:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[1].pageX,e.touches[1].pageY,0),E=M[0].distanceTo(M[1])}T[0].copy(M[0]),T[1].copy(M[1])}}function u(e){function t(e,t){var r=t[0];for(var i in t)r.distanceTo(e)>t[i].distanceTo(e)&&(r=t[i]);return r}if(h.enabled!==!1){switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[0].pageX,e.touches[0].pageY,0),h.rotate(M[0].sub(t(M[0],T)).multiplyScalar(-h.rotationSpeed));break;case 2:M[0].set(e.touches[0].pageX,e.touches[0].pageY,0),M[1].set(e.touches[1].pageX,e.touches[1].pageY,0);var r=M[0].distanceTo(M[1]);h.zoom(m.set(0,0,E-r)),E=r;var i=M[0].clone().sub(t(M[0],T)),n=M[1].clone().sub(t(M[1],T));i.x=-i.x,n.x=-n.x,h.pan(i.add(n).multiplyScalar(.5))}T[0].copy(M[0]),T[1].copy(M[1])}}t=void 0!==t?t:document,this.enabled=!0,this.center=new i,this.panSpeed=.001,this.zoomSpeed=.1,this.rotationSpeed=.005;var h=this,p=new i,m=new i,v=new d,g={NONE:-1,ROTATE:0,ZOOM:1,PAN:2},y=g.NONE,x=this.center,b=new l,w=new f,_=new f,S=new We,A={type:"change"};this.focus=function(t){var r;v.setFromObject(t),v.isEmpty()===!1?(x.copy(v.getCenter()),r=v.getBoundingSphere().radius):(x.setFromMatrixPosition(t.matrixWorld),r=.1),m.set(0,0,1),m.applyQuaternion(e.quaternion),m.multiplyScalar(4*r),e.position.copy(x).add(m),h.dispatchEvent(A)},this.pan=function(t){var r=e.position.distanceTo(x);t.multiplyScalar(r*h.panSpeed),t.applyMatrix3(b.getNormalMatrix(e.matrix)),e.position.add(t),x.add(t),h.dispatchEvent(A)},this.zoom=function(t){var r=e.position.distanceTo(x);t.multiplyScalar(r*h.zoomSpeed),t.length()>r||(t.applyMatrix3(b.getNormalMatrix(e.matrix)),e.position.add(t),h.dispatchEvent(A))},this.rotate=function(t){p.copy(e.position).sub(x),S.setFromVector3(p),S.theta+=t.x,S.phi+=t.y,S.makeSafe(),p.setFromSpherical(S),e.position.copy(x).add(p),e.lookAt(x),h.dispatchEvent(A)},this.dispose=function(){t.removeEventListener("contextmenu",s,!1),t.removeEventListener("mousedown",r,!1),t.removeEventListener("wheel",o,!1),t.removeEventListener("mousemove",n,!1),t.removeEventListener("mouseup",a,!1),t.removeEventListener("mouseout",a,!1),t.removeEventListener("dblclick",a,!1),t.removeEventListener("touchstart",c,!1),t.removeEventListener("touchmove",u,!1)},t.addEventListener("contextmenu",s,!1),t.addEventListener("mousedown",r,!1),t.addEventListener("wheel",o,!1);var M=[new i,new i,new i],T=[new i,new i,new i],E=null;t.addEventListener("touchstart",c,!1),t.addEventListener("touchmove",u,!1)};zu.prototype=Object.create(a.prototype),zu.prototype.constructor=zu;var ju=function(e,t){function r(e){e.preventDefault()}function n(e,t){return function(){t.apply(e,arguments)}}this.object=e,this.target=new i(0,0,0),this.domElement=void 0!==t?t:document,this.enabled=!0,this.movementSpeed=1,this.lookSpeed=.005,this.lookVertical=!0,this.autoForward=!1,this.activeLook=!0,this.heightSpeed=!1,this.heightCoef=1,this.heightMin=0,this.heightMax=1,this.constrainVertical=!1,this.verticalMin=0,this.verticalMax=Math.PI,this.autoSpeedFactor=0,this.mouseX=0,this.mouseY=0,this.lat=0,this.lon=0,this.phi=0,this.theta=0,this.moveForward=!1,this.moveBackward=!1,this.moveLeft=!1,this.moveRight=!1,this.mouseDragOn=!1,this.viewHalfX=0,this.viewHalfY=0,this.domElement!==document&&this.domElement.setAttribute("tabindex",-1),this.handleResize=function(){this.domElement===document?(this.viewHalfX=Ds.innerWidth/2,this.viewHalfY=Ds.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2)},this.onMouseDown=function(e){if(this.domElement!==document&&this.domElement.focus(),e.preventDefault(),e.stopPropagation(),this.activeLook)switch(e.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0},this.onMouseUp=function(e){if(e.preventDefault(),e.stopPropagation(),this.activeLook)switch(e.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1},this.onMouseMove=function(e){this.domElement===document?(this.mouseX=e.pageX-this.viewHalfX,this.mouseY=e.pageY-this.viewHalfY):(this.mouseX=e.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=e.pageY-this.domElement.offsetTop-this.viewHalfY)},this.onKeyDown=function(e){switch(e.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0}},this.onKeyUp=function(e){switch(e.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}},this.update=function(e){if(this.enabled!==!1){if(this.heightSpeed){var t=Fs.clamp(this.object.position.y,this.heightMin,this.heightMax),r=t-this.heightMin;this.autoSpeedFactor=e*(r*this.heightCoef)}else this.autoSpeedFactor=0;var i=e*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(i+this.autoSpeedFactor)),this.moveBackward&&this.object.translateZ(i),this.moveLeft&&this.object.translateX(-i),this.moveRight&&this.object.translateX(i),this.moveUp&&this.object.translateY(i),this.moveDown&&this.object.translateY(-i);var n=e*this.lookSpeed;this.activeLook||(n=0);var a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin)),this.lon+=this.mouseX*n,this.lookVertical&&(this.lat-=this.mouseY*n*a),this.lat=Math.max(-85,Math.min(85,this.lat)),this.phi=Fs.degToRad(90-this.lat),this.theta=Fs.degToRad(this.lon),this.constrainVertical&&(this.phi=Fs.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax));var o=this.target,s=this.object.position;o.x=s.x+100*Math.sin(this.phi)*Math.cos(this.theta),o.y=s.y+100*Math.cos(this.phi),o.z=s.z+100*Math.sin(this.phi)*Math.sin(this.theta),this.object.lookAt(o)}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",r,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("mousemove",a,!1),this.domElement.removeEventListener("mouseup",s,!1),Ds.removeEventListener("keydown",l,!1),Ds.removeEventListener("keyup",c,!1)};var a=n(this,this.onMouseMove),o=n(this,this.onMouseDown),s=n(this,this.onMouseUp),l=n(this,this.onKeyDown),c=n(this,this.onKeyUp);this.domElement.addEventListener("contextmenu",r,!1),this.domElement.addEventListener("mousemove",a,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mouseup",s,!1),Ds.addEventListener("keydown",l,!1),Ds.addEventListener("keyup",c,!1),this.handleResize()},Vu=function(e,t){function r(e,t){return function(){t.apply(e,arguments)}}function a(e){e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,t&&this.domElement.setAttribute("tabindex",-1),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this.tmpQuaternion=new n,this.mouseStatus=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new i(0,0,0),this.rotationVector=new i(0,0,0),this.keydown=function(e){ +if(!e.altKey){switch(e.keyCode){case 16:this.movementSpeedMultiplier=.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(e){switch(e.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector(),this.updateRotationVector()},this.mousedown=function(e){if(this.domElement!==document&&this.domElement.focus(),e.preventDefault(),e.stopPropagation(),this.dragToLook)this.mouseStatus++;else{switch(e.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1}this.updateMovementVector()}},this.mousemove=function(e){if(!this.dragToLook||this.mouseStatus>0){var t=this.getContainerDimensions(),r=t.size[0]/2,i=t.size[1]/2;this.moveState.yawLeft=-(e.pageX-t.offset[0]-r)/r,this.moveState.pitchDown=(e.pageY-t.offset[1]-i)/i,this.updateRotationVector()}},this.mouseup=function(e){if(e.preventDefault(),e.stopPropagation(),this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(e.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0}this.updateMovementVector()}this.updateRotationVector()},this.update=function(e){var t=e*this.movementSpeed,r=e*this.rollSpeed;this.object.translateX(this.moveVector.x*t),this.object.translateY(this.moveVector.y*t),this.object.translateZ(this.moveVector.z*t),this.tmpQuaternion.set(this.rotationVector.x*r,this.rotationVector.y*r,this.rotationVector.z*r,1).normalize(),this.object.quaternion.multiply(this.tmpQuaternion),this.object.rotation.setFromQuaternion(this.object.quaternion,this.object.rotation.order)},this.updateMovementVector=function(){var e=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-e+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[Ds.innerWidth,Ds.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",a,!1),this.domElement.removeEventListener("mousedown",s,!1),this.domElement.removeEventListener("mousemove",o,!1),this.domElement.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",c,!1),Ds.removeEventListener("keyup",u,!1)};var o=r(this,this.mousemove),s=r(this,this.mousedown),l=r(this,this.mouseup),c=r(this,this.keydown),u=r(this,this.keyup);this.domElement.addEventListener("contextmenu",a,!1),this.domElement.addEventListener("mousemove",o,!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mouseup",l,!1),Ds.addEventListener("keydown",c,!1),Ds.addEventListener("keyup",u,!1),this.updateMovementVector(),this.updateRotationVector()},Gu=function(e,t){function r(){return 2*Math.PI/60/60*R.autoRotateSpeed}function a(){return Math.pow(.95,R.zoomSpeed)}function o(e){G.theta-=e}function s(e){G.phi-=e}function l(e){R.object.isPerspectiveCamera?W/=e:R.object.isOrthographicCamera?(R.object.zoom=Math.max(R.minZoom,Math.min(R.maxZoom,R.object.zoom*e)),R.object.updateProjectionMatrix(),H=!0):(console.warn("WARNING: MapControls.js encountered an unknown camera type - dolly/zoom disabled."),R.enableZoom=!1)}function c(e){R.object.isPerspectiveCamera?W*=e:R.object.isOrthographicCamera?(R.object.zoom=Math.max(R.minZoom,Math.min(R.maxZoom,R.object.zoom/e)),R.object.updateProjectionMatrix(),H=!0):(console.warn("WARNING: MapControls.js encountered an unknown camera type - dolly/zoom disabled."),R.enableZoom=!1)}function u(e){Y.set(e.clientX,e.clientY)}function h(e){ne.set(e.clientX,e.clientY)}function d(e){te.set(e.clientX,e.clientY)}function p(e){Q.set(e.clientX,e.clientY),Z.subVectors(Q,Y).multiplyScalar(R.rotateSpeed);var t=R.domElement===document?R.domElement.body:R.domElement;o(2*Math.PI*Z.x/t.clientHeight),s(2*Math.PI*Z.y/t.clientHeight),Y.copy(Q),R.update()}function m(e){ae.set(e.clientX,e.clientY),oe.subVectors(ae,ne),oe.y>0?l(a()):oe.y<0&&c(a()),ne.copy(ae),R.update()}function v(e){re.set(e.clientX,e.clientY),ie.subVectors(re,te).multiplyScalar(R.panSpeed),ce(ie.x,ie.y),te.copy(re),R.update()}function g(e){e.deltaY<0?c(a()):e.deltaY>0&&l(a()),R.update()}function y(e){switch(e.keyCode){case R.keys.UP:ce(0,R.keyPanSpeed),R.update();break;case R.keys.BOTTOM:ce(0,-R.keyPanSpeed),R.update();break;case R.keys.LEFT:ce(R.keyPanSpeed,0),R.update();break;case R.keys.RIGHT:ce(-R.keyPanSpeed,0),R.update()}}function x(e){Y.set(e.touches[0].pageX,e.touches[0].pageY),q.set(e.touches[1].pageX,e.touches[1].pageY)}function b(e){if(R.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);ne.set(0,i)}}function w(e){R.enablePan&&te.set(e.touches[0].pageX,e.touches[0].pageY)}function _(e){if(R.enableRotate!==!1&&0!==(z&B.ROTATE)){if(Q.set(e.touches[0].pageX,e.touches[0].pageY),J.set(e.touches[1].pageX,e.touches[1].pageY),Z.subVectors(Q,Y),K.subVectors(J,q),$.subVectors(q,Y),ee.subVectors(J,Q),S()){var t=R.domElement===document?R.domElement.body:R.domElement;s(2*Math.PI*Z.y/t.clientHeight),z=B.ROTATE_UP}else 0!==(z&B.ROTATE_LEFT)&&o(($.angle()-ee.angle())*R.rotateSpeed);Y.copy(Q),q.copy(J)}}function S(){return!!ue($)&&(!!ue(ee)&&(!!he(Z)&&(!!he(K)&&Z.dot(K)>0)))}function A(e){if(R.enableZoom!==!1&&0!==(z&B.DOLLY)){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);ae.set(0,i),oe.set(0,Math.pow(ae.y/ne.y,R.zoomSpeed)),l(oe.y),ne.copy(ae)}}function M(e){R.enablePan!==!1&&0!==(z&B.PAN)&&(re.set(e.touches[0].pageX,e.touches[0].pageY),ie.subVectors(re,te).multiplyScalar(R.panSpeed),ce(ie.x,ie.y),te.copy(re))}function T(e){if(R.enabled!==!1){switch(e.preventDefault(),e.button){case R.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey){if(R.enableRotate===!1)return;u(e),z=B.ROTATE}else{if(R.enablePan===!1)return;d(e),z=B.PAN}break;case R.mouseButtons.MIDDLE:if(R.enableZoom===!1)return;h(e),z=B.DOLLY;break;case R.mouseButtons.RIGHT:if(R.enableRotate===!1)return;u(e),z=B.ROTATE}z!==B.NONE&&(document.addEventListener("mousemove",E,!1),document.addEventListener("mouseup",C,!1),R.dispatchEvent(U))}}function E(e){if(R.enabled!==!1)switch(e.preventDefault(),z){case B.ROTATE:if(R.enableRotate===!1)return;p(e);break;case B.DOLLY:if(R.enableZoom===!1)return;m(e);break;case B.PAN:if(R.enablePan===!1)return;v(e)}}function C(e){R.enabled!==!1&&(document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",C,!1),R.dispatchEvent(k),z=B.NONE)}function L(e){R.enabled===!1||R.enableZoom===!1||z!==B.NONE&&z!==B.ROTATE||(e.preventDefault(),e.stopPropagation(),R.dispatchEvent(U),g(e),R.dispatchEvent(k))}function P(e){R.enabled!==!1&&R.enableKeys!==!1&&R.enablePan!==!1&&y(e)}function N(e){if(R.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:if(R.enablePan===!1)return;w(e),z=B.PAN;break;case 2:if(R.enableZoom===!1&&R.enableRotate===!1)return;x(e),b(e),z=B.DOLLY_ROTATE;break;default:z=B.NONE}z!==B.NONE&&R.dispatchEvent(U)}}function O(e){if(R.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(R.enablePan===!1)return;if(z!==B.PAN)return;M(e),R.update();break;case 2:if(R.enableZoom===!1&&R.enableRotate===!1)return;if(0===(z&B.DOLLY_ROTATE))return;_(e),A(e),R.update();break;default:z=B.NONE}}function D(e){R.enabled!==!1&&(R.dispatchEvent(k),z=B.NONE)}function F(e){R.enabled!==!1&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new i,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:zs.LEFT,MIDDLE:zs.MIDDLE,RIGHT:zs.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return V.phi},this.getAzimuthalAngle=function(){return V.theta},this.saveState=function(){R.target0.copy(R.target),R.position0.copy(R.object.position),R.zoom0=R.object.zoom},this.reset=function(){R.target.copy(R.target0),R.object.position.copy(R.position0),R.object.zoom=R.zoom0,R.object.updateProjectionMatrix(),R.dispatchEvent(I),R.update(),z=B.NONE},this.update=function(){var t=new i,a=(new n).setFromUnitVectors(e.up,new i(0,1,0)),s=a.clone().inverse(),l=new i,c=new n;return function(){var e=R.object.position;return t.copy(e).sub(R.target),t.applyQuaternion(a),V.setFromVector3(t),R.autoRotate&&z===B.NONE&&o(r()),V.theta+=G.theta,V.phi+=G.phi,V.theta=Math.max(R.minAzimuthAngle,Math.min(R.maxAzimuthAngle,V.theta)),V.phi=Math.max(R.minPolarAngle,Math.min(R.maxPolarAngle,V.phi)),V.makeSafe(),V.radius*=W,V.radius=Math.max(R.minDistance,Math.min(R.maxDistance,V.radius)),R.target.add(X),t.setFromSpherical(V),t.applyQuaternion(s),e.copy(R.target).add(t),R.object.lookAt(R.target),R.enableDamping===!0?(G.theta*=1-R.dampingFactor,G.phi*=1-R.dampingFactor,X.multiplyScalar(1-R.dampingFactor)):(G.set(0,0,0),X.set(0,0,0)),W=1,!!(H||l.distanceToSquared(R.object.position)>j||8*(1-c.dot(R.object.quaternion))>j)&&(R.dispatchEvent(I),l.copy(R.object.position),c.copy(R.object.quaternion),H=!1,!0)}}(),this.dispose=function(){R.domElement.removeEventListener("contextmenu",F,!1),R.domElement.removeEventListener("mousedown",T,!1),R.domElement.removeEventListener("wheel",L,!1),R.domElement.removeEventListener("touchstart",N,!1),R.domElement.removeEventListener("touchend",D,!1),R.domElement.removeEventListener("touchmove",O,!1),document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",C,!1),Ds.removeEventListener("keydown",P,!1)};var R=this,I={type:"change"},U={type:"start"},k={type:"end"},B={NONE:0,ROTATE_UP:1,ROTATE_LEFT:2,ROTATE:3,DOLLY:4,DOLLY_ROTATE:7,PAN:8,DOLLY_PAN:12},z=B.NONE,j=1e-6,V=new We,G=new We,W=1,X=new i,H=!1,Y=new f,q=new f,Q=new f,J=new f,Z=new f,K=new f,$=new f,ee=new f,te=new f,re=new f,ie=new f,ne=new f,ae=new f,oe=new f,se=function(){var e=new i;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),X.add(e)}}(),le=function(){var e=new i;return function(t,r){R.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(R.object.up,e)),e.multiplyScalar(t),X.add(e)}}(),ce=function(){var e=new i;return function(t,r){var i=R.domElement===document?R.domElement.body:R.domElement;if(R.object.isPerspectiveCamera){var n=R.object.position;e.copy(n).sub(R.target);var a=e.length();a*=Math.tan(R.object.fov/2*Math.PI/180),se(2*t*a/i.clientHeight,R.object.matrix),le(2*r*a/i.clientHeight,R.object.matrix)}else R.object.isOrthographicCamera?(se(t*(R.object.right-R.object.left)/R.object.zoom/i.clientWidth,R.object.matrix),le(r*(R.object.top-R.object.bottom)/R.object.zoom/i.clientHeight,R.object.matrix)):(console.warn("WARNING: MapControls.js encountered an unknown camera type - pan disabled."),R.enablePan=!1)}}(),ue=function(){var e=Math.sin(Math.PI/6);return function(t){return Math.abs(Math.sin(t.angle()))0?l(a()):K.y<0&&c(a()),J.copy(Z),O.update()}function v(e){q.set(e.clientX,e.clientY),Q.subVectors(q,Y).multiplyScalar(O.panSpeed),te(Q.x,Q.y),Y.copy(q),O.update()}function g(e){e.deltaY<0?c(a()):e.deltaY>0&&l(a()),O.update()}function y(e){switch(e.keyCode){case O.keys.UP:te(0,O.keyPanSpeed),O.update();break;case O.keys.BOTTOM:te(0,-O.keyPanSpeed),O.update();break;case O.keys.LEFT:te(O.keyPanSpeed,0),O.update();break;case O.keys.RIGHT:te(-O.keyPanSpeed,0),O.update()}}function x(e){W.set(e.touches[0].pageX,e.touches[0].pageY)}function b(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);J.set(0,i)}if(O.enablePan){var n=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);Y.set(n,a)}}function w(e){X.set(e.touches[0].pageX,e.touches[0].pageY),H.subVectors(X,W).multiplyScalar(O.rotateSpeed);var t=O.domElement===document?O.domElement.body:O.domElement;o(2*Math.PI*H.x/t.clientHeight),s(2*Math.PI*H.y/t.clientHeight),W.copy(X),O.update()}function _(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);Z.set(0,i),K.set(0,Math.pow(Z.y/J.y,O.zoomSpeed)),l(K.y),J.copy(Z)}if(O.enablePan){var n=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);q.set(n,a),Q.subVectors(q,Y).multiplyScalar(O.panSpeed),te(Q.x,Q.y),Y.copy(q)}O.update()}function S(e){if(O.enabled!==!1){switch(e.preventDefault(),e.button){case O.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey){if(O.enablePan===!1)return;d(e),U=I.PAN}else{if(O.enableRotate===!1)return;u(e),U=I.ROTATE}break;case O.mouseButtons.MIDDLE:if(O.enableZoom===!1)return;h(e),U=I.DOLLY;break;case O.mouseButtons.RIGHT:if(O.enablePan===!1)return;d(e),U=I.PAN}U!==I.NONE&&(document.addEventListener("mousemove",A,!1),document.addEventListener("mouseup",M,!1),O.dispatchEvent(F))}}function A(e){if(O.enabled!==!1)switch(e.preventDefault(),U){case I.ROTATE:if(O.enableRotate===!1)return;p(e);break;case I.DOLLY:if(O.enableZoom===!1)return;m(e);break;case I.PAN:if(O.enablePan===!1)return;v(e)}}function M(e){O.enabled!==!1&&(document.removeEventListener("mousemove",A,!1),document.removeEventListener("mouseup",M,!1),O.dispatchEvent(R),U=I.NONE)}function T(e){O.enabled===!1||O.enableZoom===!1||U!==I.NONE&&U!==I.ROTATE||(e.preventDefault(),e.stopPropagation(),O.dispatchEvent(F),g(e),O.dispatchEvent(R))}function E(e){O.enabled!==!1&&O.enableKeys!==!1&&O.enablePan!==!1&&y(e)}function C(e){if(O.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:if(O.enableRotate===!1)return;x(e),U=I.TOUCH_ROTATE;break;case 2:if(O.enableZoom===!1&&O.enablePan===!1)return;b(e),U=I.TOUCH_DOLLY_PAN;break;default:U=I.NONE}U!==I.NONE&&O.dispatchEvent(F)}}function L(e){if(O.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(O.enableRotate===!1)return;if(U!==I.TOUCH_ROTATE)return;w(e);break;case 2:if(O.enableZoom===!1&&O.enablePan===!1)return;if(U!==I.TOUCH_DOLLY_PAN)return;_(e);break;default:U=I.NONE}}function P(e){O.enabled!==!1&&(O.dispatchEvent(R),U=I.NONE)}function N(e){O.enabled!==!1&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new i,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:zs.LEFT,MIDDLE:zs.MIDDLE,RIGHT:zs.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return B.phi},this.getAzimuthalAngle=function(){return B.theta},this.saveState=function(){O.target0.copy(O.target),O.position0.copy(O.object.position),O.zoom0=O.object.zoom},this.reset=function(){O.target.copy(O.target0),O.object.position.copy(O.position0),O.object.zoom=O.zoom0,O.object.updateProjectionMatrix(),O.dispatchEvent(D),O.update(),U=I.NONE},this.update=function(){var t=new i,a=(new n).setFromUnitVectors(e.up,new i(0,1,0)),s=a.clone().inverse(),l=new i,c=new n;return function(){var e=O.object.position;return t.copy(e).sub(O.target),t.applyQuaternion(a),B.setFromVector3(t),O.autoRotate&&U===I.NONE&&o(r()),B.theta+=z.theta,B.phi+=z.phi,B.theta=Math.max(O.minAzimuthAngle,Math.min(O.maxAzimuthAngle,B.theta)),B.phi=Math.max(O.minPolarAngle,Math.min(O.maxPolarAngle,B.phi)),B.makeSafe(),B.radius*=j,B.radius=Math.max(O.minDistance,Math.min(O.maxDistance,B.radius)),O.target.add(V),t.setFromSpherical(B),t.applyQuaternion(s),e.copy(O.target).add(t),O.object.lookAt(O.target),O.enableDamping===!0?(z.theta*=1-O.dampingFactor,z.phi*=1-O.dampingFactor,V.multiplyScalar(1-O.dampingFactor)):(z.set(0,0,0),V.set(0,0,0)),j=1,!!(G||l.distanceToSquared(O.object.position)>k||8*(1-c.dot(O.object.quaternion))>k)&&(O.dispatchEvent(D),l.copy(O.object.position),c.copy(O.object.quaternion),G=!1,!0)}}(),this.dispose=function(){O.domElement.removeEventListener("contextmenu",N,!1),O.domElement.removeEventListener("mousedown",S,!1),O.domElement.removeEventListener("wheel",T,!1),O.domElement.removeEventListener("touchstart",C,!1),O.domElement.removeEventListener("touchend",P,!1),O.domElement.removeEventListener("touchmove",L,!1),document.removeEventListener("mousemove",A,!1),document.removeEventListener("mouseup",M,!1),Ds.removeEventListener("keydown",E,!1)};var O=this,D={type:"change"},F={type:"start"},R={type:"end"},I={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},U=I.NONE,k=1e-6,B=new We,z=new We,j=1,V=new i,G=!1,W=new f,X=new f,H=new f,Y=new f,q=new f,Q=new f,J=new f,Z=new f,K=new f,$=function(){var e=new i;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),V.add(e)}}(),ee=function(){var e=new i;return function(t,r){O.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(O.object.up,e)),e.multiplyScalar(t),V.add(e)}}(),te=function(){var e=new i;return function(t,r){var i=O.domElement===document?O.domElement.body:O.domElement;if(O.object.isPerspectiveCamera){var n=O.object.position;e.copy(n).sub(O.target);var a=e.length();a*=Math.tan(O.object.fov/2*Math.PI/180),$(2*t*a/i.clientHeight,O.object.matrix),ee(2*r*a/i.clientHeight,O.object.matrix)}else O.object.isOrthographicCamera?($(t*(O.object.right-O.object.left)/O.object.zoom/i.clientWidth,O.object.matrix),ee(r*(O.object.top-O.object.bottom)/O.object.zoom/i.clientHeight,O.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),O.enablePan=!1)}}();O.domElement.addEventListener("contextmenu",N,!1),O.domElement.addEventListener("mousedown",S,!1),O.domElement.addEventListener("wheel",T,!1),O.domElement.addEventListener("touchstart",C,!1),O.domElement.addEventListener("touchend",P,!1),O.domElement.addEventListener("touchmove",L,!1),Ds.addEventListener("keydown",E,!1),this.update()};Wu.prototype=Object.create(a.prototype),Wu.prototype.constructor=Wu,Object.defineProperties(Wu.prototype,{center:{get:function(){return console.warn("OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}}});var Xu=function(e,t){function r(e){m.enabled!==!1&&(Ds.removeEventListener("keydown",r),b=x,x===v.NONE&&(e.keyCode!==m.keys[v.ROTATE]||m.noRotate?e.keyCode!==m.keys[v.ZOOM]||m.noZoom?e.keyCode!==m.keys[v.PAN]||m.noPan||(x=v.PAN):x=v.ZOOM:x=v.ROTATE))}function a(e){m.enabled!==!1&&(x=b,Ds.addEventListener("keydown",r,!1))}function o(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x===v.NONE&&(x=e.button),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||(C.copy(D(e.pageX,e.pageY)),L.copy(C)):(A.copy(D(e.pageX,e.pageY)),M.copy(A)):(_.copy(F(e.pageX,e.pageY)),S.copy(_)),document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",l,!1),m.dispatchEvent(N))}function s(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||L.copy(D(e.pageX,e.pageY)):M.copy(D(e.pageX,e.pageY)):S.copy(F(e.pageX,e.pageY)))}function l(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x=v.NONE,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),m.dispatchEvent(O))}function c(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),A.y+=.01*e.deltaY,m.dispatchEvent(N),m.dispatchEvent(O))}function u(e){if(m.enabled!==!1){switch(e.touches.length){case 1:x=v.TOUCH_ROTATE,_.copy(F(e.touches[0].pageX,e.touches[0].pageY)),S.copy(_);break;case 2:x=v.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;E=T=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;C.copy(D(i,n)),L.copy(C);break;default:x=v.NONE}m.dispatchEvent(N)}}function h(e){if(m.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:S.copy(F(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;E=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;L.copy(D(i,n));break;default:x=v.NONE}}function d(e){if(m.enabled!==!1){switch(e.touches.length){case 1:S.copy(F(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S);break;case 2:T=E=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;L.copy(D(t,r)),C.copy(L)}x=v.NONE,m.dispatchEvent(O)}}function p(e){e.preventDefault()}var m=this,v={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.radius=0,this.rotateSpeed=1,this.zoomSpeed=1.2,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new i;var g=1e-6,y=!0,x=v.NONE,b=v.NONE,w=new i,_=new i,S=new i,A=new f,M=new f,T=0,E=0,C=new f,L=new f;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom;var P={type:"change"},N={type:"start"},O={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=Ds.innerWidth,this.screen.height=Ds.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+Ds.pageXOffset-t.clientLeft,this.screen.top=e.top+Ds.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.radius=.5*Math.min(this.screen.width,this.screen.height),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom};var D=function(){var e=new f;return function(t,r){return e.set((t-m.screen.left)/m.screen.width,(r-m.screen.top)/m.screen.height),e}}(),F=function(){var e=new i,t=new i,r=new i;return function(i,n){r.set((i-.5*m.screen.width-m.screen.left)/m.radius,(.5*m.screen.height+m.screen.top-n)/m.radius,0);var a=r.length();return m.noRoll?a1?r.normalize():r.z=Math.sqrt(1-a*a),w.copy(m.object.position).sub(m.target),e.copy(m.object.up).setLength(r.y),e.add(t.copy(m.object.up).cross(w).setLength(r.x)),e.add(w.setLength(r.z)),e}}();this.rotateCamera=function(){var e=new i,t=new n;return function(){var r=Math.acos(_.dot(S)/_.length()/S.length());r&&(e.crossVectors(_,S).normalize(),r*=m.rotateSpeed,t.setFromAxisAngle(e,-r),w.applyQuaternion(t),m.object.up.applyQuaternion(t),S.applyQuaternion(t),m.staticMoving?_.copy(S):(t.setFromAxisAngle(e,r*(m.dynamicDampingFactor-1)),_.applyQuaternion(t)),y=!0)}}(),this.zoomCamera=function(){if(x===v.TOUCH_ZOOM_PAN){var e=E/T;T=E,m.object.zoom*=e,y=!0}else{var e=1+(M.y-A.y)*m.zoomSpeed;Math.abs(e-1)>g&&e>0&&(m.object.zoom/=e,m.staticMoving?A.copy(M):A.y+=(M.y-A.y)*this.dynamicDampingFactor,y=!0)}},this.panCamera=function(){var e=new f,t=new i,r=new i;return function(){if(e.copy(L).sub(C),e.lengthSq()){var i=(m.object.right-m.object.left)/m.object.zoom,n=(m.object.top-m.object.bottom)/m.object.zoom;e.x*=i,e.y*=n,r.copy(w).cross(m.object.up).setLength(e.x),r.add(t.copy(m.object.up).setLength(e.y)),m.object.position.add(r),m.target.add(r),m.staticMoving?C.copy(L):C.add(e.subVectors(L,C).multiplyScalar(m.dynamicDampingFactor)),y=!0}}}(),this.update=function(){w.subVectors(m.object.position,m.target),m.noRotate||m.rotateCamera(),m.noZoom||(m.zoomCamera(),y&&m.object.updateProjectionMatrix()),m.noPan||m.panCamera(),m.object.position.addVectors(m.target,w),m.object.lookAt(m.target),y&&(m.dispatchEvent(P),y=!1)},this.reset=function(){x=v.NONE,b=v.NONE,m.target.copy(m.target0),m.object.position.copy(m.position0),m.object.up.copy(m.up0),w.subVectors(m.object.position,m.target),m.object.left=m.left0,m.object.right=m.right0,m.object.top=m.top0,m.object.bottom=m.bottom0,m.object.lookAt(m.target),m.dispatchEvent(P),y=!1},this.dispose=function(){this.domElement.removeEventListener("contextmenu",p,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("wheel",c,!1),this.domElement.removeEventListener("touchstart",u,!1),this.domElement.removeEventListener("touchend",d,!1),this.domElement.removeEventListener("touchmove",h,!1),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",r,!1),Ds.removeEventListener("keyup",a,!1)},this.domElement.addEventListener("contextmenu",p,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("wheel",c,!1),this.domElement.addEventListener("touchstart",u,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",h,!1),Ds.addEventListener("keydown",r,!1),Ds.addEventListener("keyup",a,!1),this.handleResize(), +this.update()};Xu.prototype=Object.create(a.prototype),Xu.prototype.constructor=Xu;var Hu=function(e){var t=this;e.rotation.set(0,0,0);var r=new c;r.add(e);var n=new c;n.position.y=10,n.add(r);var a=Math.PI/2,s=function(e){if(t.enabled!==!1){var i=e.movementX||e.mozMovementX||e.webkitMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||0;n.rotation.y-=.002*i,r.rotation.x-=.002*o,r.rotation.x=Math.max(-a,Math.min(a,r.rotation.x))}};this.dispose=function(){document.removeEventListener("mousemove",s,!1)},document.addEventListener("mousemove",s,!1),this.enabled=!1,this.getObject=function(){return n},this.getDirection=function(){var e=new i(0,0,(-1)),t=new o(0,0,0,"YXZ");return function(i){return t.set(r.rotation.x,n.rotation.y,0),i.copy(e).applyEuler(t),i}}()},Yu=function(e,t){function r(e){m.enabled!==!1&&(Ds.removeEventListener("keydown",r),b=x,x===v.NONE&&(e.keyCode!==m.keys[v.ROTATE]||m.noRotate?e.keyCode!==m.keys[v.ZOOM]||m.noZoom?e.keyCode!==m.keys[v.PAN]||m.noPan||(x=v.PAN):x=v.ZOOM:x=v.ROTATE))}function a(e){m.enabled!==!1&&(x=b,Ds.addEventListener("keydown",r,!1))}function o(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x===v.NONE&&(x=e.button),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||(P.copy(R(e.pageX,e.pageY)),N.copy(P)):(T.copy(R(e.pageX,e.pageY)),E.copy(T)):(S.copy(I(e.pageX,e.pageY)),_.copy(S)),document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",l,!1),m.dispatchEvent(D))}function s(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x!==v.ROTATE||m.noRotate?x!==v.ZOOM||m.noZoom?x!==v.PAN||m.noPan||N.copy(R(e.pageX,e.pageY)):E.copy(R(e.pageX,e.pageY)):(_.copy(S),S.copy(I(e.pageX,e.pageY))))}function l(e){m.enabled!==!1&&(e.preventDefault(),e.stopPropagation(),x=v.NONE,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),m.dispatchEvent(F))}function c(e){if(m.enabled!==!1&&m.noZoom!==!0){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:T.y-=.025*e.deltaY;break;case 1:T.y-=.01*e.deltaY;break;default:T.y-=25e-5*e.deltaY}m.dispatchEvent(D),m.dispatchEvent(F)}}function u(e){if(m.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:x=v.TOUCH_ROTATE,S.copy(I(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S);break;default:x=v.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;L=C=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;P.copy(R(i,n)),N.copy(P)}m.dispatchEvent(D)}}function h(e){if(m.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:_.copy(S),S.copy(I(e.touches[0].pageX,e.touches[0].pageY));break;default:var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;L=Math.sqrt(t*t+r*r);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;N.copy(R(i,n))}}function d(e){if(m.enabled!==!1){switch(e.touches.length){case 0:x=v.NONE;break;case 1:x=v.TOUCH_ROTATE,S.copy(I(e.touches[0].pageX,e.touches[0].pageY)),_.copy(S)}m.dispatchEvent(F)}}function p(e){m.enabled!==!1&&e.preventDefault()}var m=this,v={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new i;var g=1e-6,y=new i,x=v.NONE,b=v.NONE,w=new i,_=new f,S=new f,A=new i,M=0,T=new f,E=new f,C=0,L=0,P=new f,N=new f;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var O={type:"change"},D={type:"start"},F={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=Ds.innerWidth,this.screen.height=Ds.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+Ds.pageXOffset-t.clientLeft,this.screen.top=e.top+Ds.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}};var R=function(){var e=new f;return function(t,r){return e.set((t-m.screen.left)/m.screen.width,(r-m.screen.top)/m.screen.height),e}}(),I=function(){var e=new f;return function(t,r){return e.set((t-.5*m.screen.width-m.screen.left)/(.5*m.screen.width),(m.screen.height+2*(m.screen.top-r))/m.screen.width),e}}();this.rotateCamera=function(){var e,t=new i,r=new n,a=new i,o=new i,s=new i,l=new i;return function(){l.set(S.x-_.x,S.y-_.y,0),e=l.length(),e?(w.copy(m.object.position).sub(m.target),a.copy(w).normalize(),o.copy(m.object.up).normalize(),s.crossVectors(o,a).normalize(),o.setLength(S.y-_.y),s.setLength(S.x-_.x),l.copy(o.add(s)),t.crossVectors(l,w).normalize(),e*=m.rotateSpeed,r.setFromAxisAngle(t,e),w.applyQuaternion(r),m.object.up.applyQuaternion(r),A.copy(t),M=e):!m.staticMoving&&M&&(M*=Math.sqrt(1-m.dynamicDampingFactor),w.copy(m.object.position).sub(m.target),r.setFromAxisAngle(A,M),w.applyQuaternion(r),m.object.up.applyQuaternion(r)),_.copy(S)}}(),this.zoomCamera=function(){var e;x===v.TOUCH_ZOOM_PAN?(e=C/L,C=L,w.multiplyScalar(e)):(e=1+(E.y-T.y)*m.zoomSpeed,1!==e&&e>0&&w.multiplyScalar(e),m.staticMoving?T.copy(E):T.y+=(E.y-T.y)*this.dynamicDampingFactor)},this.panCamera=function(){var e=new f,t=new i,r=new i;return function(){e.copy(N).sub(P),e.lengthSq()&&(e.multiplyScalar(w.length()*m.panSpeed),r.copy(w).cross(m.object.up).setLength(e.x),r.add(t.copy(m.object.up).setLength(e.y)),m.object.position.add(r),m.target.add(r),m.staticMoving?P.copy(N):P.add(e.subVectors(N,P).multiplyScalar(m.dynamicDampingFactor)))}}(),this.checkDistances=function(){m.noZoom&&m.noPan||(w.lengthSq()>m.maxDistance*m.maxDistance&&(m.object.position.addVectors(m.target,w.setLength(m.maxDistance)),T.copy(E)),w.lengthSq()g&&(m.dispatchEvent(O),y.copy(m.object.position))},this.reset=function(){x=v.NONE,b=v.NONE,m.target.copy(m.target0),m.object.position.copy(m.position0),m.object.up.copy(m.up0),w.subVectors(m.object.position,m.target),m.object.lookAt(m.target),m.dispatchEvent(O),y.copy(m.object.position)},this.dispose=function(){this.domElement.removeEventListener("contextmenu",p,!1),this.domElement.removeEventListener("mousedown",o,!1),this.domElement.removeEventListener("wheel",c,!1),this.domElement.removeEventListener("touchstart",u,!1),this.domElement.removeEventListener("touchend",d,!1),this.domElement.removeEventListener("touchmove",h,!1),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",l,!1),Ds.removeEventListener("keydown",r,!1),Ds.removeEventListener("keyup",a,!1)},this.domElement.addEventListener("contextmenu",p,!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("wheel",c,!1),this.domElement.addEventListener("touchstart",u,!1),this.domElement.addEventListener("touchend",d,!1),this.domElement.addEventListener("touchmove",h,!1),Ds.addEventListener("keydown",r,!1),Ds.addEventListener("keyup",a,!1),this.handleResize(),this.update()};Yu.prototype=Object.create(a.prototype),Yu.prototype.constructor=Yu,Xe.prototype=Object.create(m.prototype),Xe.prototype.constructor=Xe,He.prototype=Object.create(P.prototype),He.prototype.constructor=He,Ye.prototype=Object.create(m.prototype),Ye.prototype.constructor=Ye,qe.prototype=Object.create(He.prototype),qe.prototype.constructor=qe,Qe.prototype=Object.create(m.prototype),Qe.prototype.constructor=Qe,Je.prototype=Object.create(P.prototype),Je.prototype.constructor=Je;var qu=function(e,t){function r(e,t){var r=t;Object.defineProperty(f,e,{get:function(){return void 0!==r?r:t},set:function(t){r!==t&&(r=t,p[e]=t,d[e]=t,f.dispatchEvent({type:e+"-changed",value:t}),f.dispatchEvent(m))}}),f[e]=t,p[e]=t,d[e]=t}function a(e){var r=e.changedTouches?e.changedTouches[0]:e,i=t.getBoundingClientRect();return{x:(r.clientX-i.left)/i.width*2-1,y:-(r.clientY-i.top)/i.height*2+1,button:e.button}}function o(e){e.preventDefault()}function s(e){f.enabled&&f.pointerHover(a(e))}function l(e){f.enabled&&(e.preventDefault(),f.pointerHover(a(e)),f.pointerDown(a(e)))}function u(e){f.enabled&&(e.preventDefault(),f.pointerMove(a(e)))}function h(e){f.enabled&&(e.preventDefault(),f.pointerUp(a(e)))}c.call(this),t=void 0!==t?t:document,this.visible=!1;var d=new Qu;this.add(d);var p=new Ju;this.add(p);var f=this;r("camera",e),r("object",void 0),r("enabled",!0),r("axis",null),r("mode","translate"),r("translationSnap",null),r("rotationSnap",null),r("space","world"),r("size",1),r("dragging",!1),r("showX",!0),r("showY",!0),r("showZ",!0);var m={type:"change"},v={type:"mouseDown"},g={type:"mouseUp",mode:f.mode},y={type:"objectChange"},x=new je,b=new i,w=new i,_=new n,S={X:new i(1,0,0),Y:new i(0,1,0),Z:new i(0,0,1)},A=new n,M=new i,T=new i,E=new i,C=new i,L=0,P=new i,N=new n,O=new i,D=new i,F=new n,R=new i,I=new i,U=new n,k=new i,B=new i,z=new n,j=new i,V=new i,G=new i,W=new n,X=new i;r("parentQuaternion",F),r("worldPosition",B),r("worldPositionStart",I),r("worldQuaternion",z),r("worldQuaternionStart",U),r("cameraPosition",P),r("cameraQuaternion",N),r("pointStart",T),r("pointEnd",E),r("rotationAxis",C),r("rotationAngle",L),r("eye",V),t.addEventListener("mousedown",l,!1),t.addEventListener("touchstart",l,!1),t.addEventListener("mousemove",s,!1),t.addEventListener("touchmove",s,!1),document.addEventListener("mousemove",u,!1),t.addEventListener("touchmove",u,!1),document.addEventListener("mouseup",h,!1),t.addEventListener("touchend",h,!1),t.addEventListener("touchcancel",h,!1),t.addEventListener("touchleave",h,!1),t.addEventListener("contextmenu",o,!1),this.dispose=function(){t.removeEventListener("mousedown",l),t.removeEventListener("touchstart",l),t.removeEventListener("mousemove",s),t.removeEventListener("touchmove",s),document.removeEventListener("mousemove",u),t.removeEventListener("touchmove",u),document.removeEventListener("mouseup",h),t.removeEventListener("touchend",h),t.removeEventListener("touchcancel",h),t.removeEventListener("touchleave",h),t.removeEventListener("contextmenu",o)},this.attach=function(e){this.object=e,this.visible=!0},this.detach=function(){this.object=void 0,this.visible=!1,this.axis=null},this.updateMatrixWorld=function(){void 0!==this.object&&(this.object.updateMatrixWorld(),this.object.parent.matrixWorld.decompose(D,F,R),this.object.matrixWorld.decompose(B,z,j)),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(P,N,O),this.camera instanceof de?V.copy(P).sub(B).normalize():this.camera instanceof me&&V.copy(P).normalize(),c.prototype.updateMatrixWorld.call(this)},this.pointerHover=function(e){if(void 0!==this.object&&this.dragging!==!0&&(void 0===e.button||0===e.button)){x.setFromCamera(e,this.camera);var t=x.intersectObjects(d.picker[this.mode].children,!0)[0]||!1;t?this.axis=t.object.name:this.axis=null}},this.pointerDown=function(e){if(!(void 0===this.object||this.dragging===!0||void 0!==e.button&&0!==e.button||0!==e.button&&void 0!==e.button||null===this.axis)){x.setFromCamera(e,this.camera);var t=x.intersectObjects([p],!0)[0]||!1;if(t){var r=this.space;if("scale"===this.mode?r="local":"E"!==this.axis&&"XYZE"!==this.axis&&"XYZ"!==this.axis||(r="world"),"local"===r&&"rotate"===this.mode){var i=this.rotationSnap;"X"===this.axis&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),"Y"===this.axis&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),"Z"===this.axis&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),G.copy(this.object.position),W.copy(this.object.quaternion),X.copy(this.object.scale),this.object.matrixWorld.decompose(I,U,k),T.copy(t.point).sub(I),"local"===r&&T.applyQuaternion(U.clone().inverse())}this.dragging=!0,v.mode=this.mode,this.dispatchEvent(v)}},this.pointerMove=function(e){var t=this.axis,r=this.mode,i=this.object,n=this.space;if("scale"===r?n="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(n="world"),void 0!==i&&null!==t&&this.dragging!==!1&&(void 0===e.button||0===e.button)){x.setFromCamera(e,this.camera);var a=x.intersectObjects([p],!0)[0]||!1;if(a!==!1){if(E.copy(a.point).sub(I),"local"===n&&E.applyQuaternion(U.clone().inverse()),"translate"===r)t.search("X")===-1&&(E.x=T.x),t.search("Y")===-1&&(E.y=T.y),t.search("Z")===-1&&(E.z=T.z),"local"===n?i.position.copy(E).sub(T).applyQuaternion(W):i.position.copy(E).sub(T),i.position.add(G),this.translationSnap&&("local"===n&&(i.position.applyQuaternion(_.copy(W).inverse()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(W)),"world"===n&&(i.parent&&i.position.add(b.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(b.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===r){if(t.search("XYZ")!==-1){var o=E.length()/T.length();E.dot(T)<0&&(o*=-1),b.set(o,o,o)}else b.copy(E).divide(T),t.search("X")===-1&&(b.x=1),t.search("Y")===-1&&(b.y=1),t.search("Z")===-1&&(b.z=1);i.scale.copy(X).multiply(b)}else if("rotate"===r){var s=20/B.distanceTo(b.setFromMatrixPosition(this.camera.matrixWorld)),l="local"===this.space?z:A,c=S[t];"E"===t?(b.copy(E).cross(T),C.copy(V),L=E.angleTo(T)*(b.dot(V)<0?1:-1)):"XYZE"===t?(b.copy(E).sub(T).cross(V).normalize(),C.copy(b),L=E.sub(T).dot(b.cross(V))*s):"X"!==t&&"Y"!==t&&"Z"!==t||(M.copy(c).applyQuaternion(l),C.copy(c),b=c.clone(),w=E.clone().sub(T),"local"===n&&(b.applyQuaternion(l),w.applyQuaternion(U)),L=w.dot(b.cross(V).normalize())*s),this.rotationSnap&&(L=Math.round(L/this.rotationSnap)*this.rotationSnap),this.rotationAngle=L,"local"===n?(i.quaternion.copy(W),i.quaternion.multiply(_.setFromAxisAngle(C,L))):(i.quaternion.copy(_.setFromAxisAngle(C,L)),i.quaternion.multiply(W))}this.dispatchEvent(m),this.dispatchEvent(y)}}},this.pointerUp=function(e){void 0!==e.button&&0!==e.button||(this.dragging&&null!==this.axis&&(g.mode=this.mode,this.dispatchEvent(g)),this.dragging=!1,void 0===e.button&&(this.axis=null))},this.getMode=function(){return f.mode},this.setMode=function(e){f.mode=e},this.setTranslationSnap=function(e){f.translationSnap=e},this.setRotationSnap=function(e){f.rotationSnap=e},this.setSize=function(e){f.size=e},this.setSpace=function(e){f.space=e},this.update=function(){console.warn("TransformControls: update function has been depricated.")}};qu.prototype=Object.assign(Object.create(c.prototype),{constructor:qu,isTransformControls:!0});var Qu=function(){c.call(this),this.type="TransformControlsGizmo";var e=new F({depthTest:!1,depthWrite:!1,transparent:!0,side:Ks,fog:!1}),t=new R({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1}),a=e.clone();a.opacity=.15;var s=e.clone();s.opacity=.33;var l=e.clone();l.color.set(16711680);var h=e.clone();h.color.set(65280);var d=e.clone();d.color.set(255);var p=e.clone();p.opacity=.25;var f=p.clone();f.color.set(16776960);var m=p.clone();m.color.set(65535);var v=p.clone();v.color.set(16711935);var g=e.clone();g.color.set(16776960);var y=t.clone();y.color.set(16711680);var x=t.clone();x.color.set(65280);var b=t.clone();b.color.set(255);var w=t.clone();w.color.set(65535);var _=t.clone();_.color.set(16711935);var S=t.clone();S.color.set(16776960);var A=t.clone();A.color.set(7895160);var T=S.clone();T.opacity=.25;var E=new ue(0,.05,.2,12,1,(!1)),C=new le(.125,.125,.125),L=new P;L.addAttribute("position",new M([0,0,0,1,0,0],3));var N=function(e,t){for(var r=new P,i=[],n=0;n<=64*t;++n)i.push(0,Math.cos(n/32*Math.PI)*e,Math.sin(n/32*Math.PI)*e);return r.addAttribute("position",new M(i,3)),r},D=function(e,t){var r=new P;return r.addAttribute("position",new M([0,0,0,1,1,1],3)),r},I={X:[[new k(E,l),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new k(E,l),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new B(L,y)]],Y:[[new k(E,h),[0,1,0],null,null,"fwd"],[new k(E,h),[0,1,0],[Math.PI,0,0],null,"bwd"],[new B(L,x),null,[0,0,Math.PI/2]]],Z:[[new k(E,d),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new k(E,d),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new B(L,b),null,[0,-Math.PI/2,0]]],XYZ:[[new k(new qe(.1,0),p),[0,0,0],[0,0,0]]],XY:[[new k(new xe(.295,.295),f),[.15,.15,0]],[new B(L,S),[.18,.3,0],null,[.125,1,1]],[new B(L,S),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new k(new xe(.295,.295),m),[0,.15,.15],[0,Math.PI/2,0]],[new B(L,w),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new B(L,w),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new k(new xe(.295,.295),v),[.15,0,.15],[-Math.PI/2,0,0]],[new B(L,_),[.18,0,.3],null,[.125,1,1]],[new B(L,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},U={X:[[new k(new ue(.2,0,1,4,1,(!1)),a),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new k(new ue(.2,0,1,4,1,(!1)),a),[0,.6,0]]],Z:[[new k(new ue(.2,0,1,4,1,(!1)),a),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new k(new qe(.2,0),a)]],XY:[[new k(new xe(.4,.4),a),[.2,.2,0]]],YZ:[[new k(new xe(.4,.4),a),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new k(new xe(.4,.4),a),[.2,0,.2],[-Math.PI/2,0,0]]]},z={START:[[new k(new qe(.01,2),s),null,null,null,"helper"]],END:[[new k(new qe(.01,2),s),null,null,null,"helper"]],DELTA:[[new B(D(),s),null,null,null,"helper"]],X:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new B(L,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new B(L,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},j={X:[[new B(N(1,.5),y)],[new k(new qe(.04,0),l),[0,0,.99],null,[1,3,1]]],Y:[[new B(N(1,.5),x),null,[0,0,-Math.PI/2]],[new k(new qe(.04,0),h),[0,0,.99],null,[3,1,1]]],Z:[[new B(N(1,.5),b),null,[0,Math.PI/2,0]],[new k(new qe(.04,0),d),[.99,0,0],null,[1,3,1]]],E:[[new B(N(1.25,1),T),null,[0,Math.PI/2,0]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new k(new ue(.03,0,.15,4,1,(!1)),T),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new B(N(1,1),A),null,[0,Math.PI/2,0]]]},V={AXIS:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={X:[[new k(new Je(1,.1,4,24),a),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new k(new Je(1,.1,4,24),a),[0,0,0],[Math.PI/2,0,0]]],Z:[[new k(new Je(1,.1,4,24),a),[0,0,0],[0,0,-Math.PI/2]]],E:[[new k(new Je(1.25,.1,2,24),a)]],XYZE:[[new k(new O(.7,10,8),a)]]},W={X:[[new k(C,l),[.8,0,0],[0,0,-Math.PI/2]],[new B(L,y),null,null,[.8,1,1]]],Y:[[new k(C,h),[0,.8,0]],[new B(L,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new k(C,d),[0,0,.8],[Math.PI/2,0,0]],[new B(L,b),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new k(C,f),[.85,.85,0],null,[2,2,.2]],[new B(L,S),[.855,.98,0],null,[.125,1,1]],[new B(L,S),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new k(C,m),[0,.85,.85],null,[.2,2,2]],[new B(L,w),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new B(L,w),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new k(C,v),[.85,0,.85],null,[2,.2,2]],[new B(L,_),[.855,0,.98],null,[.125,1,1]],[new B(L,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new k(new le(.125,.125,.125),p),[1.1,0,0]]],XYZY:[[new k(new le(.125,.125,.125),p),[0,1.1,0]]],XYZZ:[[new k(new le(.125,.125,.125),p),[0,0,1.1]]]},X={X:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[0,.5,0]]],Z:[[new k(new ue(.2,0,.8,4,1,(!1)),a),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new k(C,a),[.85,.85,0],null,[3,3,.2]]],YZ:[[new k(C,a),[0,.85,.85],null,[.2,3,3]]],XZ:[[new k(C,a),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new k(new le(.2,.2,.2),a),[1.1,0,0]]],XYZY:[[new k(new le(.2,.2,.2),a),[0,1.1,0]]],XYZZ:[[new k(new le(.2,.2,.2),a),[0,0,1.1]]]},H={X:[[new B(L,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new B(L,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new B(L,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},Y=function(e){var t=new c;for(var r in e)for(var i=e[r].length;i--;){var n=e[r][i][0].clone(),a=e[r][i][1],o=e[r][i][2],s=e[r][i][3],l=e[r][i][4];n.name=r,n.tag=l,a&&n.position.set(a[0],a[1],a[2]),o&&n.rotation.set(o[0],o[1],o[2]),s&&n.scale.set(s[0],s[1],s[2]),n.updateMatrix();var u=n.geometry.clone();u.applyMatrix(n.matrix),n.geometry=u,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),t.add(n)}return t},q=new i(0,0,0),Q=new o,J=new i(0,1,0),Z=new i(0,0,0),K=new r,$=new n,ee=new n,te=new n,re=new i(1,0,0),ie=new i(0,1,0),ne=new i(0,0,1);this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Y(I)),this.add(this.gizmo.rotate=Y(j)),this.add(this.gizmo.scale=Y(W)),this.add(this.picker.translate=Y(U)),this.add(this.picker.rotate=Y(G)),this.add(this.picker.scale=Y(X)),this.add(this.helper.translate=Y(z)),this.add(this.helper.rotate=Y(V)),this.add(this.helper.scale=Y(H)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1,this.updateMatrixWorld=function(){var e=this,t=this.space;"scale"===this.mode&&(t="local");var r="local"===t?this.worldQuaternion:te;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;var i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(var n=0;ns&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"Y"!==a.name&&"XYZY"!==a.name||Math.abs(J.copy(ie).applyQuaternion(r).dot(e.eye))>s&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"Z"!==a.name&&"XYZZ"!==a.name||Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye))>s&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"XY"===a.name&&Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye)).9&&(a.visible=!1)),"Y"===e.axis&&($.setFromEuler(Q.set(0,0,Math.PI/2)),a.quaternion.copy(r).multiply($),Math.abs(J.copy(ie).applyQuaternion(r).dot(e.eye))>.9&&(a.visible=!1)),"Z"===e.axis&&($.setFromEuler(Q.set(0,Math.PI/2,0)),a.quaternion.copy(r).multiply($),Math.abs(J.copy(ne).applyQuaternion(r).dot(e.eye))>.9&&(a.visible=!1)),"XYZE"===e.axis&&($.setFromEuler(Q.set(0,Math.PI/2,0)),J.copy(e.rotationAxis),a.quaternion.setFromRotationMatrix(K.lookAt(Z,J,ie)),a.quaternion.multiply($),a.visible=e.dragging),"E"===e.axis&&(a.visible=!1)):"START"===a.name?(a.position.copy(e.worldPositionStart),a.visible=e.dragging):"END"===a.name?(a.position.copy(e.worldPosition),a.visible=e.dragging):"DELTA"===a.name?(a.position.copy(e.worldPositionStart),a.quaternion.copy(e.worldQuaternionStart),q.set(1e-10,1e-10,1e-10).add(e.worldPositionStart).sub(e.worldPosition).multiplyScalar(-1),q.applyQuaternion(e.worldQuaternionStart.clone().inverse()),a.scale.copy(q),a.visible=e.dragging):(a.quaternion.copy(r),e.dragging?a.position.copy(e.worldPositionStart):a.position.copy(e.worldPosition),e.axis&&(a.visible=e.axis.search(a.name)!==-1))}c.prototype.updateMatrixWorld.call(this)}};Qu.prototype=Object.assign(Object.create(c.prototype),{constructor:Qu,isTransformControlsGizmo:!0});var Ju=function(){k.call(this,new xe(1e5,1e5,2,2),new F({visible:!1,wireframe:!0,side:Ks,transparent:!0,opacity:.1})),this.type="TransformControlsPlane";var e=new i(1,0,0),t=new i(0,1,0),a=new i(0,0,1),o=new i,s=new i,l=new i,u=new r,h=new n;this.updateMatrixWorld=function(){var r=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(r="local"),e.set(1,0,0).applyQuaternion("local"===r?this.worldQuaternion:h),t.set(0,1,0).applyQuaternion("local"===r?this.worldQuaternion:h),a.set(0,0,1).applyQuaternion("local"===r?this.worldQuaternion:h),l.copy(t),this.mode){case"translate":case"scale":switch(this.axis){case"X":l.copy(this.eye).cross(e),s.copy(e).cross(l);break;case"Y":l.copy(this.eye).cross(t),s.copy(t).cross(l);break;case"Z":l.copy(this.eye).cross(a),s.copy(a).cross(l);break;case"XY":s.copy(a);break;case"YZ":s.copy(e);break;case"XZ":l.copy(a),s.copy(t);break;case"XYZ":case"E":s.set(0,0,0)}break;case"rotate":default:s.set(0,0,0)}0===s.length()?this.quaternion.copy(this.cameraQuaternion):(u.lookAt(o.set(0,0,0),s,l),this.quaternion.setFromRotationMatrix(u)),c.prototype.updateMatrixWorld.call(this)}};Ju.prototype=Object.assign(Object.create(k.prototype),{constructor:Ju,isTransformControlsPlane:!0}),Object.assign(Ze.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("Line3: .getCenter() target is now required"),e=new i),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("Line3: .delta() target is now required"),e=new i),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("Line3: .at() target is now required"),t=new i),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new i,t=new i;return function(r,i){e.subVectors(r,this.start),t.subVectors(this.end,this.start);var n=t.dot(t),a=t.dot(e),o=a/n;return i&&(o=Fs.clamp(o,0,1)),o}}(),closestPointToPoint:function(e,t,r){var n=this.closestPointToPointParameter(e,t);return void 0===r&&(console.warn("Line3: .closestPointToPoint() target is now required"),r=new i),this.delta(r).multiplyScalar(n).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}});var Zu=0,Ku=1;Object.assign(Ke.prototype,{setFromPoints:function(e){var t=this;Array.isArray(e)!==!0&&console.error("QuickHull: Points parameter is not an array."),e.length<4&&console.error("QuickHull: The algorithm needs at least four points."),this.makeEmpty();for(var r=0,i=e.length;rr.tolerance?r.addVertexToFace(n,t):r.unassigned.append(n),n=a}while(null!==n)}return this},resolveUnassignedPoints:function(e){var t=this;if(this.unassigned.isEmpty()===!1){var r=this.unassigned.first();do{for(var i=r.next,n=t.tolerance,a=null,o=0;on&&(n=l,a=s),n>1e3*t.tolerance)break}}null!==a&&t.addVertexToFace(r,a),r=i}while(null!==r)}return this},computeExtremes:function(){var e,t,r,n=this,a=new i,o=new i,s=[],l=[];for(e=0;e<3;e++)s[e]=l[e]=n.vertices[0];for(a.copy(this.vertices[0].point),o.copy(this.vertices[0].point),e=0,t=this.vertices.length;eo.getComponent(r)&&(o.setComponent(r,u.getComponent(r)),l[r]=c)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(a.x),Math.abs(o.x))+Math.max(Math.abs(a.y),Math.abs(o.y))+Math.max(Math.abs(a.z),Math.abs(o.z))),{min:s,max:l}},computeInitialHull:function(){var e,t,r;return function(){var n=this;void 0===e&&(e=new Ze,t=new ze,r=new i);var a,o,s,l,c,u,h,d,p,f=this.vertices,m=this.computeExtremes(),v=m.min,g=m.max,y=0,x=0; +for(u=0;u<3;u++)p=g[u].point.getComponent(u)-v[u].point.getComponent(u),p>y&&(y=p,x=u);for(o=v[x],s=g[x],y=0,e.set(o.point,s.point),u=0,h=this.vertices.length;uy&&(y=p,l=a));for(y=-1,t.setFromCoplanarPoints(o.point,s.point,l.point),u=0,h=this.vertices.length;uy&&(y=p,c=a));var b=[];if(t.distanceToPoint(c.point)<0)for(b.push($e.create(o,s,l),$e.create(c,s,o),$e.create(c,l,s),$e.create(c,o,l)),u=0;u<3;u++)d=(u+1)%3,b[u+1].getEdge(2).setTwin(b[0].getEdge(d)),b[u+1].getEdge(1).setTwin(b[d+1].getEdge(0));else for(b.push($e.create(o,l,s),$e.create(c,o,s),$e.create(c,s,l),$e.create(c,l,o)),u=0;u<3;u++)d=(u+1)%3,b[u+1].getEdge(2).setTwin(b[0].getEdge((3-u)%3)),b[u+1].getEdge(0).setTwin(b[d+1].getEdge(1));for(u=0;u<4;u++)n.faces.push(b[u]);for(u=0,h=f.length;uy&&(y=p,w=n.faces[d]);null!==w&&n.addVertexToFace(a,w)}return this}}(),reindexFaces:function(){for(var e=this,t=[],r=0;rt&&(t=n,e=i),i=i.next}while(null!==i&&i.face===r);return e}},computeHorizon:function(e,t,r,i){var n=this;this.deleteFaceVertices(r),r.mark=Ku;var a;a=null===t?t=r.getEdge(0):t.next;do{var o=a.twin,s=o.face;s.mark===Zu&&(s.distanceToPoint(e)>n.tolerance?n.computeHorizon(e,o,s,i):i.push(a)),a=a.next}while(a!==t);return this},addAdjoiningFace:function(e,t){var r=$e.create(e,t.tail(),t.head());return this.faces.push(r),r.getEdge(-1).setTwin(t.twin),r.getEdge(0)},addNewFaces:function(e,t){var r=this;this.newFaces=[];for(var i=null,n=null,a=0;a0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t},compute:function(){var e;return function(){void 0===e&&(e=new U);var t=this.edge.tail(),r=this.edge.head(),i=this.edge.next.head();return e.set(t.point,r.point,i.point),e.getNormal(this.normal),e.getMidpoint(this.midpoint),this.area=e.getArea(),this.constant=this.normal.dot(this.midpoint),this}}(),distanceToPoint:function(e){return this.normal.dot(e)-this.constant}}),Object.assign(et.prototype,{head:function(){return this.vertex},tail:function(){return this.prev?this.prev.vertex:null},length:function(){var e=this.head(),t=this.tail();return null!==t?t.point.distanceTo(e.point):-1},lengthSquared:function(){var e=this.head(),t=this.tail();return null!==t?t.point.distanceToSquared(e.point):-1},setTwin:function(e){return this.twin=e,e.twin=this,this}}),Object.assign(rt.prototype,{first:function(){return this.head},last:function(){return this.tail},clear:function(){return this.head=this.tail=null,this},insertBefore:function(e,t){return t.prev=e.prev,t.next=e,null===t.prev?this.head=t:t.prev.next=t,e.prev=t,this},insertAfter:function(e,t){return t.prev=e,t.next=e.next,null===t.next?this.tail=t:t.next.prev=t,e.next=t,this},append:function(e){return null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this},appendChain:function(e){for(null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail;null!==e.next;)e=e.next;return this.tail=e,this},remove:function(e){return null===e.prev?this.head=e.next:e.prev.next=e.next,null===e.next?this.tail=e.prev:e.next.prev=e.prev,this},removeSubList:function(e,t){return null===e.prev?this.head=t.next:e.prev.next=t.next,null===t.next?this.tail=e.prev:t.next.prev=e.prev,this},isEmpty:function(){return null===this.head}}),it.prototype=Object.create(m.prototype),it.prototype.constructor=it,nt.prototype=Object.create(P.prototype),nt.prototype.constructor=nt;var $u=function(e,t){var r=this;this.minSizeForBreak=e||1.4,this.smallDelta=t||1e-4,this.tempLine1=new Ze,this.tempPlane1=new ze,this.tempPlane2=new ze,this.tempPlane_Cut=new ze,this.tempCM1=new i,this.tempCM2=new i,this.tempVector3=new i,this.tempVector3_2=new i,this.tempVector3_3=new i,this.tempVector3_P0=new i,this.tempVector3_P1=new i,this.tempVector3_P2=new i,this.tempVector3_N0=new i,this.tempVector3_N1=new i,this.tempVector3_AB=new i,this.tempVector3_CB=new i,this.tempResultObjects={object1:null,object2:null},this.segments=[];for(var n=900,a=0;ac)return void o.push(n);var f=Math.PI;0===p?(l.normal.copy(s.normal),l.constant=s.constant):p<=i?(f=(d-h)*(.2+.6*Math.random())+h,u.tempVector3_2.copy(e.position).sub(t).applyAxisAngle(r,f).add(t),l.setFromCoplanarPoints(t,u.tempVector3,u.tempVector3_2)):(f=(.5*(1&p)+.2*(2-Math.random()))*Math.PI,u.tempVector3_2.copy(t).sub(n.position).applyAxisAngle(r,f).add(n.position),u.tempVector3_3.copy(r).add(n.position),l.setFromCoplanarPoints(n.position,u.tempVector3_3,u.tempVector3_2)),u.cutByPlane(n,l,u.tempResultObjects);var m=u.tempResultObjects.object1,v=u.tempResultObjects.object2;m&&a(m,h,f,p+1),v&&a(v,f,d,p+1)}var o=[],s=this.tempPlane1,l=this.tempPlane2;this.tempVector3.addVectors(t,r),s.setFromCoplanarPoints(t,e.position,this.tempVector3);var c=n+i,u=this;return a(e,0,2*Math.PI,0),o},cutByPlane:function(e,t,r){function n(e,t){var r=3*e+t;return h?h[r]:r}var a=this,o=e.geometry,s=o.attributes.position.array,l=o.attributes.normal.array,c=s.length/3,u=c/3,h=o.getIndex();h&&(h=h.array,u=h.length/3);for(var d=[],p=[],f=this.smallDelta,m=c*c,v=0;vf?(U=2,p.push(g.clone())):B<-f?(U=1,d.push(g.clone())):(U=3,d.push(g.clone()),p.push(g.clone()));var z=0,B=L.distanceToPoint(y);if(B>f?(z=2,p.push(y.clone())):B<-f?(z=1,d.push(y.clone())):(z=3,d.push(y.clone()),p.push(y.clone())),1===U&&2===z||2===U&&1===z){a.tempLine1.start.copy(g),a.tempLine1.end.copy(y);var j=new i;if(j=L.intersectLine(a.tempLine1,j),void 0===j)return console.error("Internal error: segment does not intersect plane."),r.segmentedObject1=null,r.segmentedObject2=null,0;d.push(j),p.push(j.clone())}}}var V=.5*e.userData.mass;this.tempCM1.set(0,0,0);var G=0,W=d.length;if(W>0){for(var v=0;v0){for(var v=0;v4&&(q=new k(new nt(d),e.material),q.position.copy(this.tempCM1),q.quaternion.copy(e.quaternion),this.prepareBreakableObject(q,V,e.userData.velocity,e.userData.angularVelocity,2*G>this.minSizeForBreak),J++),Y>4&&(Q=new k(new nt(p),e.material),Q.position.copy(this.tempCM2),Q.quaternion.copy(e.quaternion),this.prepareBreakableObject(Q,V,e.userData.velocity,e.userData.angularVelocity,2*H>this.minSizeForBreak),J++),r.object1=q,r.object2=Q,J}},$u.transformFreeVector=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[4]*i+a[8]*n,e.y=a[1]*r+a[5]*i+a[9]*n,e.z=a[2]*r+a[6]*i+a[10]*n,e},$u.transformFreeVectorInverse=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[1]*i+a[2]*n,e.y=a[4]*r+a[5]*i+a[6]*n,e.z=a[8]*r+a[9]*i+a[10]*n,e},$u.transformTiedVectorInverse=function(e,t){var r=e.x,i=e.y,n=e.z,a=t.elements;return e.x=a[0]*r+a[1]*i+a[2]*n-a[12],e.y=a[4]*r+a[5]*i+a[6]*n-a[13],e.z=a[8]*r+a[9]*i+a[10]*n-a[14],e},$u.transformPlaneToLocalSpace=function(){var e=new i;return function(t,r,i){i.normal.copy(t.normal),i.constant=t.constant;var n=$u.transformTiedVectorInverse(t.coplanarPoint(e),r);$u.transformFreeVectorInverse(i.normal,r),i.constant=-n.dot(i.normal)}}(),Object.assign(at.prototype,{getPoint:function(){return console.warn("Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var r=this.getUtoTmapping(e);return this.getPoint(r,t)},getPoints:function(e){var t=this;void 0===e&&(e=5);for(var r=[],i=0;i<=e;i++)r.push(t.getPoint(i/e));return r},getSpacedPoints:function(e){var t=this;void 0===e&&(e=5);for(var r=[],i=0;i<=e;i++)r.push(t.getPointAt(i/e));return r},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){var t=this;if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var r,i,n=[],a=this.getPoint(0),o=0;for(n.push(0),i=1;i<=e;i++)r=t.getPoint(i/e),o+=r.distanceTo(a),n.push(o),a=r;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var r,i=this.getLengths(),n=0,a=i.length;r=t?t:e*i[a-1];for(var o,s=0,l=a-1;s<=l;)if(n=Math.floor(s+(l-s)/2),o=i[n]-r,o<0)s=n+1;else{if(!(o>0)){l=n;break}l=n-1}if(n=l,i[n]===r)return n/(a-1);var c=i[n],u=i[n+1],h=u-c,d=(r-c)/h,p=(n+d)/(a-1);return p},getTangent:function(e){var t=1e-4,r=e-t,i=e+t;r<0&&(r=0),i>1&&(i=1);var n=this.getPoint(r),a=this.getPoint(i),o=a.clone().sub(n);return o.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,a,o,s=this,l=new i,c=[],u=[],h=[],d=new i,p=new r;for(n=0;n<=e;n++)a=n/e,c[n]=s.getTangentAt(a),c[n].normalize();u[0]=new i,h[0]=new i;var f=Number.MAX_VALUE,m=Math.abs(c[0].x),v=Math.abs(c[0].y),g=Math.abs(c[0].z);for(m<=f&&(f=m,l.set(1,0,0)),v<=f&&(f=v,l.set(0,1,0)),g<=f&&l.set(0,0,1),d.crossVectors(c[0],l).normalize(),u[0].crossVectors(c[0],d),h[0].crossVectors(c[0],u[0]),n=1;n<=e;n++)u[n]=u[n-1].clone(),h[n]=h[n-1].clone(),d.crossVectors(c[n-1],c[n]),d.length()>Number.EPSILON&&(d.normalize(),o=Math.acos(Fs.clamp(c[n-1].dot(c[n]),-1,1)),u[n].applyMatrix4(p.makeRotationAxis(d,o))),h[n].crossVectors(c[n],u[n]);if(t===!0)for(o=Math.acos(Fs.clamp(u[0].dot(u[e]),-1,1)),o/=e,c[0].dot(d.crossVectors(u[0],u[e]))>0&&(o=-o),n=1;n<=e;n++)u[n].applyMatrix4(p.makeRotationAxis(c[n],o*n)),h[n].crossVectors(c[n],u[n]);return{tangents:c,normals:u,binormals:h}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),ot.prototype=Object.create(at.prototype),ot.prototype.constructor=ot,ot.prototype.getPoint=function(e,t){var r=t||new i;e=2*Math.PI*e;var n=-.22*Math.cos(e)-1.28*Math.sin(e)-.44*Math.cos(3*e)-.78*Math.sin(3*e),a=-.1*Math.cos(2*e)-.27*Math.sin(2*e)+.38*Math.cos(4*e)+.46*Math.sin(4*e),o=.7*Math.cos(3*e)-.4*Math.sin(3*e);return r.set(n,a,o).multiplyScalar(20)},st.prototype=Object.create(at.prototype),st.prototype.constructor=st,st.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=16*Math.pow(Math.sin(e),3),a=13*Math.cos(e)-5*Math.cos(2*e)-2*Math.cos(3*e)-Math.cos(4*e),o=0;return r.set(n,a,o).multiplyScalar(this.scale)},lt.prototype=Object.create(at.prototype),lt.prototype.constructor=lt,lt.prototype.getPoint=function(e,t){var r=t||new i;e=4*e*Math.PI;var n=this.scale/2,a=n*(1+Math.cos(e)),o=n*Math.sin(e),s=2*n*Math.sin(e/2);return r.set(a,o,s)},ct.prototype=Object.create(at.prototype),ct.prototype.constructor=ct,ct.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=10,a=50,o=a*Math.sin(e),s=Math.cos(e)*(n+a*Math.cos(e)),l=Math.sin(e)*(n+a*Math.cos(e));return r.set(o,s,l)},ut.prototype=Object.create(at.prototype),ut.prototype.constructor=ut,ut.prototype.getPoint=function(e,t){var r=t||new i,n=30,a=150,o=2*Math.PI*e*a/30,s=Math.cos(o)*n,l=Math.sin(o)*n,c=a*e;return r.set(s,l,c)},ht.prototype=Object.create(at.prototype),ht.prototype.constructor=ht,ht.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=(2+Math.cos(3*e))*Math.cos(2*e),a=(2+Math.cos(3*e))*Math.sin(2*e),o=Math.sin(3*e);return r.set(n,a,o).multiplyScalar(this.scale)},dt.prototype=Object.create(at.prototype),dt.prototype.constructor=dt,dt.prototype.getPoint=function(e,t){var r=t||new i,n=3,a=4;e*=2*Math.PI;var o=(2+Math.cos(a*e))*Math.cos(n*e),s=(2+Math.cos(a*e))*Math.sin(n*e),l=Math.sin(a*e);return r.set(o,s,l).multiplyScalar(this.scale)},pt.prototype=Object.create(at.prototype),pt.prototype.constructor=pt,pt.prototype.getPoint=function(e,t){var r=t||new i,n=2,a=5;e*=2*Math.PI;var o=(2+Math.cos(a*e))*Math.cos(n*e),s=(2+Math.cos(a*e))*Math.sin(n*e),l=Math.sin(a*e);return r.set(o,s,l).multiplyScalar(this.scale)},ft.prototype=Object.create(at.prototype),ft.prototype.constructor=ft,ft.prototype.getPoint=function(e,t){var r=t||new i;e=4*e-2;var n=Math.pow(e,3)-3*e,a=Math.pow(e,4)-4*e*e,o=.2*Math.pow(e,5)-2*e;return r.set(n,a,o).multiplyScalar(this.scale)};var eh=function(e,t,r){var i=t-e;return r*i+e};mt.prototype=Object.create(at.prototype),mt.prototype.constructor=mt,mt.prototype.getPoint=function(e,t){var r=t||new i;e=eh(-4,4,e);var n=.4*e*(e*e-7)*(e*e-10),a=Math.pow(e,4)-13*e*e,o=.1*e*(e*e-4)*(e*e-9)*(e*e-12);return r.set(n,a,o).multiplyScalar(this.scale)},vt.prototype=Object.create(at.prototype),vt.prototype.constructor=vt,vt.prototype.getPoint=function(e,t){var r=t||new i;e*=2*Math.PI;var n=Math.cos(2*e)*(1+.6*(Math.cos(5*e)+.75*Math.cos(10*e))),a=Math.sin(2*e)*(1+.6*(Math.cos(5*e)+.75*Math.cos(10*e))),o=.35*Math.sin(5*e);return r.set(n,a,o).multiplyScalar(this.scale)},gt.prototype=Object.create(at.prototype),gt.prototype.constructor=gt,gt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(2*n)*(1+.45*Math.cos(3*n)+.4*Math.cos(9*n)),o=Math.sin(2*n)*(1+.45*Math.cos(3*n)+.4*Math.cos(9*n)),s=.2*Math.sin(9*n);return r.set(a,o,s).multiplyScalar(this.scale)},yt.prototype=Object.create(at.prototype),yt.prototype.constructor=yt,yt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(3*n)*(1+.3*Math.cos(5*n)+.5*Math.cos(10*n)),o=Math.sin(3*n)*(1+.3*Math.cos(5*n)+.5*Math.cos(10*n)),s=.2*Math.sin(20*n);return r.set(a,o,s).multiplyScalar(this.scale)},xt.prototype=Object.create(at.prototype),xt.prototype.constructor=xt,xt.prototype.getPoint=function(e,t){var r=t||new i,n=e*Math.PI*2,a=Math.cos(4*n)*(1+.5*(Math.cos(5*n)+.4*Math.cos(20*n))),o=Math.sin(4*n)*(1+.5*(Math.cos(5*n)+.4*Math.cos(20*n))),s=.35*Math.sin(15*n);return r.set(a,o,s).multiplyScalar(this.scale)};var th={findSpan:function(e,t,r){var i=r.length-e-1;if(t>=r[i])return i-1;if(t<=r[e])return e;for(var n=e,a=i,o=Math.floor((n+a)/2);t=r[o+1];)t=b&&(x[y][0]=x[g][0]/l[S+1][_],w=x[y][0]*l[_][S]);for(var A=_>=-1?1:-_,M=p-1<=S?b-1:r-p,h=A;h<=M;++h)x[y][h]=(x[g][h]-x[g][h-1])/l[S+1][_+h],w+=x[y][h]*l[_+h][S];p<=S&&(x[y][b]=-x[g][b-1]/l[S+1][p],w+=x[y][b]*l[p][S]),s[b][p]=w;var h=g;g=y,y=h}}for(var p=r,b=1;b<=i;++b){for(var h=0;h<=r;++h)s[b][h]*=p;p*=r-b}return s},calcBSplineDerivatives:function(e,t,r,i,n){for(var a=nWebGL.
','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.'].join("\n")),e},addGetWebGLMessage:function(e){var t,r,i;e=e||{},t=void 0!==e.parent?e.parent:document.body,r=void 0!==e.id?e.id:"oldie",i=nh.getWebGLErrorMessage(),i.id=r,t.appendChild(i)}};Object.assign(bt.prototype,{update:function(){var e,t,i,n,a,o,s,l,c=new r,u=new r;return function(r){var h=e!==this||t!==r.focus||i!==r.fov||n!==r.aspect*this.aspect||a!==r.near||o!==r.far||s!==r.zoom||l!==this.eyeSep;if(h){e=this,t=r.focus,i=r.fov,n=r.aspect*this.aspect,a=r.near,o=r.far,s=r.zoom;var d=r.projectionMatrix.clone();l=this.eyeSep/2;var p,f,m=l*a/t,v=a*Math.tan(Fs.DEG2RAD*i*.5)/s;u.elements[12]=-l,c.elements[12]=l,p=-v*n+m,f=v*n+m,d.elements[0]=2*a/(f-p),d.elements[8]=(f+p)/(f-p),this.cameraL.projectionMatrix.copy(d),p=-v*n-m,f=v*n-m,d.elements[0]=2*a/(f-p),d.elements[8]=(f+p)/(f-p),this.cameraR.projectionMatrix.copy(d)}this.cameraL.matrixWorld.copy(r.matrixWorld).multiply(u),this.cameraR.matrixWorld.copy(r.matrixWorld).multiply(c)}}()});var ah=function(e,t,r){this.colorMatrixLeft=(new l).fromArray([1.0671679973602295,-.0016435992438346148,.0001777536963345483,-.028107794001698494,-.00019593400065787137,-.0002875397040043026,-.04279090091586113,15809757314855233e-21,-.00024287120322696865]),this.colorMatrixRight=(new l).fromArray([-.0355340838432312,-.06440307199954987,.018319187685847282,-.10269022732973099,.8079727292060852,-.04835830628871918,.0001224992738571018,-.009558862075209618,.567823588848114]);var i=new me((-1),1,1,(-1),0,1),n=new fe,a=new bt,o={minFilter:rc,magFilter:$l,format:xc};void 0===t&&(t=512),void 0===r&&(r=512);var s=new ge(t,r,o),c=new ge(t,r,o),u=new pe({uniforms:{mapLeft:{value:s.texture},mapRight:{value:c.texture},colorMatrixLeft:{value:this.colorMatrixLeft},colorMatrixRight:{value:this.colorMatrixRight}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = vec2( uv.x, uv.y );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","uniform mat3 colorMatrixLeft;","uniform mat3 colorMatrixRight;","float lin( float c ) {","\treturn c <= 0.04045 ? c * 0.0773993808 :","\t\t\tpow( c * 0.9478672986 + 0.0521327014, 2.4 );","}","vec4 lin( vec4 c ) {","\treturn vec4( lin( c.r ), lin( c.g ), lin( c.b ), c.a );","}","float dev( float c ) {","\treturn c <= 0.0031308 ? c * 12.92","\t\t\t: pow( c, 0.41666 ) * 1.055 - 0.055;","}","void main() {","\tvec2 uv = vUv;","\tvec4 colorL = lin( texture2D( mapLeft, uv ) );","\tvec4 colorR = lin( texture2D( mapRight, uv ) );","\tvec3 color = clamp(","\t\t\tcolorMatrixLeft * colorL.rgb +","\t\t\tcolorMatrixRight * colorR.rgb, 0., 1. );","\tgl_FragColor = vec4(","\t\t\tdev( color.r ), dev( color.g ), dev( color.b ),","\t\t\tmax( colorL.a, colorR.a ) );","}"].join("\n")}),h=new k(new xe(2,2),u);n.add(h),this.setSize=function(t,r){e.setSize(t,r);var i=e.getPixelRatio();s.setSize(t*i,r*i),c.setSize(t*i,r*i)},this.render=function(t,r){t.updateMatrixWorld(),null===r.parent&&r.updateMatrixWorld(),a.update(r),e.render(t,a.cameraL,s,!0),e.render(t,a.cameraR,c,!0),e.render(n,i)},this.dispose=function(){s&&s.dispose(),c&&c.dispose(),h&&h.geometry.dispose(),u&&u.dispose()}},oh=function(e,t,r){function i(){v=Math.round(a*T),g=Math.round(o*T),S.width=v,S.height=g,y=e.domElement,y.style.backgroundColor&&(m.rows[0].cells[0].style.backgroundColor=y.style.backgroundColor,m.rows[0].cells[0].style.color=y.style.color),m.cellSpacing=0,m.cellPadding=0;var t=m.style;t.display="inline",t.width=Math.round(v/T*l)+"px",t.height=Math.round(g/T*l)+"px",t.whiteSpace="pre",t.margin="0px",t.padding="0px",t.letterSpacing=L+"px",t.fontFamily=w,t.fontSize=E+"px",t.lineHeight=C+"px",t.textAlign="left",t.textDecoration="none"}function n(e,t){A.clearRect(0,0,v,g),A.drawImage(_,0,0,v,g);for(var r=A.getImageData(0,0,v,g).data,i="",n=0;n"+x+"":x}i+="
"}t.innerHTML=""+i+""}t=void 0===t?" .:-=+*#%@":t,r||(r={});var a,o,s=r.resolution?r.resolution:.15,l=r.scale?r.scale:1,c=!!r.color&&r.color,u=!!r.alpha&&r.alpha,h=!!r.block&&r.block,d=!!r.invert&&r.invert,p="low",f=document.createElement("div");f.style.cursor="default";var m=document.createElement("table");f.appendChild(m);var v,g,y;this.setSize=function(t,r){a=t,o=r,e.setSize(t,r),i()},this.render=function(t,r){e.render(t,r),n(e,m)},this.domElement=f;var x=" .,:;i1tfLCG08@".split(""),b=" CGO08@".split(""),w="courier new, monospace",_=e.domElement,S=document.createElement("canvas");if(S.getContext){var A=S.getContext("2d");if(A.getImageData){var M=c?b:x;t&&(M=t);var T=.5;switch(p){case"low":T=.25;break;case"medium":T=.5;break;case"high":T=1}s&&(T=s);var E=2/T*l,C=2/T*l,L=0;switch(l){case 1:L=-1;break;case 2:case 3:L=-2.1;break;case 4:L=-3.1;break;case 5:L=-4.15}}}},sh="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",lh="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",ch="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",uh="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",hh="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",dh="\nvec3 transformed = vec3( position );\n",ph="\nvec3 objectNormal = vec3( normal );\n",fh="float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_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}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * 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}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.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 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat 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_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",mh="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\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\n",vh="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",gh="#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",yh="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",xh="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",bh="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",wh="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",_h="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",Sh="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",Ah="#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float 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 average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\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}\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\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}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",Mh="#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",Th="vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",Eh="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",Ch="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",Lh="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",Ph="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",Nh=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",Oh="\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n",Dh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\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\n",Fh="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",Rh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",Ih="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\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\n",Uh="#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif\n",kh="#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif\n",Bh="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",zh="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\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\n",jh="#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",Vh="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",Gh="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",Wh="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",Xh="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.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 GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",Hh="#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",Yh="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",qh="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",Qh="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",Jh="struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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.specularRoughness;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\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\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\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}\n",Zh="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",Kh="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",$h="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",ed="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",td="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n#endif\n",rd="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif\n",id="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",nd="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",ad="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",od="#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",sd="#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",ld="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",cd="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",ud="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",hd="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",dd="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",pd="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",fd="#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",md="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n",vd="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",gd="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",yd="vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",xd="#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",bd="#if defined( 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\n",wd="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",_d="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",Sd="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\t\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\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\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",Ad="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\t\n#endif\n",Md="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t\n#endif\n",Td="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t\n\t#endif\n\treturn shadow;\n}\n",Ed="#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",Cd="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",Ld="#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\n",Pd="#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#endif\n",Nd="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",Od="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",Dd="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",Fd="#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",Rd="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",Id="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",Ud="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",kd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",Bd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",zd="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",jd="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",Vd="uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",Gd="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",Wd="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",Xd="#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Hd="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",Yd="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",qd="uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",Qd="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",Jd="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Zd="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",Kd="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",$d="#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ep="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",tp="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",rp="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ip="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",np="#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",ap="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",op="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",sp="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",lp="uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",cp="uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",up="uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",hp="#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",dp="uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}\n",pp="uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\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 \n\t#include \n\t#include \n}\n",fp={ +alphamap_fragment:sh,alphamap_pars_fragment:lh,alphatest_fragment:ch,aomap_fragment:uh,aomap_pars_fragment:hh,begin_vertex:dh,beginnormal_vertex:ph,bsdfs:fh,bumpmap_pars_fragment:mh,clipping_planes_fragment:vh,clipping_planes_pars_fragment:gh,clipping_planes_pars_vertex:yh,clipping_planes_vertex:xh,color_fragment:bh,color_pars_fragment:wh,color_pars_vertex:_h,color_vertex:Sh,common:Ah,cube_uv_reflection_fragment:Mh,defaultnormal_vertex:Th,displacementmap_pars_vertex:Eh,displacementmap_vertex:Ch,emissivemap_fragment:Lh,emissivemap_pars_fragment:Ph,encodings_fragment:Nh,encodings_pars_fragment:Oh,envmap_fragment:Dh,envmap_pars_fragment:Fh,envmap_pars_vertex:Rh,envmap_physical_pars_fragment:Hh,envmap_vertex:Ih,fog_vertex:Uh,fog_pars_vertex:kh,fog_fragment:Bh,fog_pars_fragment:zh,gradientmap_pars_fragment:jh,lightmap_fragment:Vh,lightmap_pars_fragment:Gh,lights_lambert_vertex:Wh,lights_pars_begin:Xh,lights_phong_fragment:Yh,lights_phong_pars_fragment:qh,lights_physical_fragment:Qh,lights_physical_pars_fragment:Jh,lights_fragment_begin:Zh,lights_fragment_maps:Kh,lights_fragment_end:$h,logdepthbuf_fragment:ed,logdepthbuf_pars_fragment:td,logdepthbuf_pars_vertex:rd,logdepthbuf_vertex:id,map_fragment:nd,map_pars_fragment:ad,map_particle_fragment:od,map_particle_pars_fragment:sd,metalnessmap_fragment:ld,metalnessmap_pars_fragment:cd,morphnormal_vertex:ud,morphtarget_pars_vertex:hd,morphtarget_vertex:dd,normal_fragment_begin:pd,normal_fragment_maps:fd,normalmap_pars_fragment:md,packing:vd,premultiplied_alpha_fragment:gd,project_vertex:yd,dithering_fragment:xd,dithering_pars_fragment:bd,roughnessmap_fragment:wd,roughnessmap_pars_fragment:_d,shadowmap_pars_fragment:Sd,shadowmap_pars_vertex:Ad,shadowmap_vertex:Md,shadowmask_pars_fragment:Td,skinbase_vertex:Ed,skinning_pars_vertex:Cd,skinning_vertex:Ld,skinnormal_vertex:Pd,specularmap_fragment:Nd,specularmap_pars_fragment:Od,tonemapping_fragment:Dd,tonemapping_pars_fragment:Fd,uv_pars_fragment:Rd,uv_pars_vertex:Id,uv_vertex:Ud,uv2_pars_fragment:kd,uv2_pars_vertex:Bd,uv2_vertex:zd,worldpos_vertex:jd,cube_frag:Vd,cube_vert:Gd,depth_frag:Wd,depth_vert:Xd,distanceRGBA_frag:Hd,distanceRGBA_vert:Yd,equirect_frag:qd,equirect_vert:Qd,linedashed_frag:Jd,linedashed_vert:Zd,meshbasic_frag:Kd,meshbasic_vert:$d,meshlambert_frag:ep,meshlambert_vert:tp,meshphong_frag:rp,meshphong_vert:ip,meshphysical_frag:np,meshphysical_vert:ap,normal_frag:op,normal_vert:sp,points_frag:lp,points_vert:cp,shadow_frag:up,shadow_vert:hp,sprite_frag:dp,sprite_vert:pp},mp={common:{diffuse:{value:new u(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new l},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new f(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new u(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new u(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new l}},sprite:{diffuse:{value:new u(15658734)},opacity:{value:1},center:{value:new f(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new l}}},vp={basic:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.fog]),vertexShader:fp.meshbasic_vert,fragmentShader:fp.meshbasic_frag},lambert:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.fog,mp.lights,{emissive:{value:new u(0)}}]),vertexShader:fp.meshlambert_vert,fragmentShader:fp.meshlambert_frag},phong:{uniforms:Mu.merge([mp.common,mp.specularmap,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.bumpmap,mp.normalmap,mp.displacementmap,mp.gradientmap,mp.fog,mp.lights,{emissive:{value:new u(0)},specular:{value:new u(1118481)},shininess:{value:30}}]),vertexShader:fp.meshphong_vert,fragmentShader:fp.meshphong_frag},standard:{uniforms:Mu.merge([mp.common,mp.envmap,mp.aomap,mp.lightmap,mp.emissivemap,mp.bumpmap,mp.normalmap,mp.displacementmap,mp.roughnessmap,mp.metalnessmap,mp.fog,mp.lights,{emissive:{value:new u(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:fp.meshphysical_vert,fragmentShader:fp.meshphysical_frag},points:{uniforms:Mu.merge([mp.points,mp.fog]),vertexShader:fp.points_vert,fragmentShader:fp.points_frag},dashed:{uniforms:Mu.merge([mp.common,mp.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:fp.linedashed_vert,fragmentShader:fp.linedashed_frag},depth:{uniforms:Mu.merge([mp.common,mp.displacementmap]),vertexShader:fp.depth_vert,fragmentShader:fp.depth_frag},normal:{uniforms:Mu.merge([mp.common,mp.bumpmap,mp.normalmap,mp.displacementmap,{opacity:{value:1}}]),vertexShader:fp.normal_vert,fragmentShader:fp.normal_frag},sprite:{uniforms:Mu.merge([mp.sprite,mp.fog]),vertexShader:fp.sprite_vert,fragmentShader:fp.sprite_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:fp.cube_vert,fragmentShader:fp.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:fp.equirect_vert,fragmentShader:fp.equirect_frag},distanceRGBA:{uniforms:Mu.merge([mp.common,mp.displacementmap,{referencePosition:{value:new i},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:fp.distanceRGBA_vert,fragmentShader:fp.distanceRGBA_frag},shadow:{uniforms:Mu.merge([mp.lights,mp.fog,{color:{value:new u(0)},opacity:{value:1}}]),vertexShader:fp.shadow_vert,fragmentShader:fp.shadow_frag}};vp.physical={uniforms:Mu.merge([vp.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:fp.meshphysical_vert,fragmentShader:fp.meshphysical_frag};var gp=function(e,t){function r(){return new pe({name:"invisible",visible:!1})}function i(e){var t,i,n=w[e.type];e.userData.outlineParameters;if(void 0!==n){var a=vp[n];t=a.uniforms,i=a.vertexShader}else if(e.isRawShaderMaterial===!0){if(t=e.uniforms,i=e.vertexShader,!/attribute\s+vec3\s+position\s*;/.test(i)||!/attribute\s+vec3\s+normal\s*;/.test(i))return console.warn("OutlineEffect requires both vec3 position and normal attributes in vertex shader, does not draw outline for "+e.name+"(uuid:"+e.uuid+") material."),r()}else{if(e.isShaderMaterial!==!0)return r();t=e.uniforms,i=e.vertexShader}var o=Object.assign({},t,_),s=i.replace(/void\s+main\s*\(\s*\)/,S+"\nvoid main()").replace(/\}\s*$/,A+"\n}").replace(/#include\s+<[\w_]*light[\w_]*>/g,""),l={};return/vec3\s+transformed\s*=/.test(i)||/#include\s+/.test(i)||(l.DECLARE_TRANSFORMED=!0),new pe({defines:l,uniforms:o,vertexShader:s,fragmentShader:M,side:Zs,skinning:!1,morphTargets:!1,morphNormals:!1,fog:!1})}function n(e){var t=g[e.uuid];return void 0===t&&(t={material:i(e),used:!0,keepAlive:v,count:0},g[e.uuid]=t),t.used=!0,t.material}function a(e){var t=n(e);return x[t.uuid]=e,h(t,e),t}function o(e){if(void 0!==e.material){if(Array.isArray(e.material))for(var t=0,r=e.material.length;ty&&delete g[i]):(g[i].used=!1,g[i].count=0)}}t=t||{},this.enabled=!0;var p=void 0!==t.defaultThickness?t.defaultThickness:.003,f=(new u).fromArray(void 0!==t.defaultColor?t.defaultColor:[0,0,0]),m=void 0!==t.defaultAlpha?t.defaultAlpha:1,v=void 0!==t.defaultKeepAlive&&t.defaultKeepAlive,g={},y=60,x={},b={},w={MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical"},_={outlineThickness:{type:"f",value:p},outlineColor:{type:"c",value:f},outlineAlpha:{type:"f",value:m}},S=["#include ","uniform float outlineThickness;","vec4 calculateOutline( vec4 pos, vec3 objectNormal, vec4 skinned ) {","\tfloat thickness = outlineThickness;","\tconst float ratio = 1.0;","\tvec4 pos2 = projectionMatrix * modelViewMatrix * vec4( skinned.xyz + objectNormal, 1.0 );","\tvec4 norm = normalize( pos - pos2 );","\treturn pos + norm * thickness * pos.w * ratio;","}"].join("\n"),A=["#if ! defined( LAMBERT ) && ! defined( PHONG ) && ! defined( TOON ) && ! defined( PHYSICAL )","\t#ifndef USE_ENVMAP","\t\tvec3 objectNormal = normalize( normal );","\t#endif","#endif","#ifdef FLIP_SIDED","\tobjectNormal = -objectNormal;","#endif","#ifdef DECLARE_TRANSFORMED","\tvec3 transformed = vec3( position );","#endif","gl_Position = calculateOutline( gl_Position, objectNormal, vec4( transformed, 1.0 ) );","#include "].join("\n"),M=["#include ","#include ","uniform vec3 outlineColor;","uniform float outlineAlpha;","void main() {","\tgl_FragColor = vec4( outlineColor, outlineAlpha );","\t#include ","}"].join("\n");this.render=function(t,r,i,n){if(this.enabled===!1)return void e.render(t,r,i,n);var a=e.autoClear;e.autoClear=this.autoClear,e.render(t,r,i,n);var l=t.autoUpdate,c=t.background,u=e.shadowMap.enabled;t.autoUpdate=!1,t.background=null,e.autoClear=!1,e.shadowMap.enabled=!1,t.traverse(o),e.render(t,r,i),t.traverse(s),d(),t.autoUpdate=l,t.background=c,e.autoClear=a,e.shadowMap.enabled=u},this.autoClear=e.autoClear,this.domElement=e.domElement,this.shadowMap=e.shadowMap,this.clear=function(t,r,i){e.clear(t,r,i)},this.getPixelRatio=function(){return e.getPixelRatio()},this.setPixelRatio=function(t){e.setPixelRatio(t)},this.getSize=function(){return e.getSize()},this.setSize=function(t,r,i){e.setSize(t,r,i)},this.setViewport=function(t,r,i,n){e.setViewport(t,r,i,n)},this.setScissor=function(t,r,i,n){e.setScissor(t,r,i,n)},this.setScissorTest=function(t){e.setScissorTest(t)},this.setRenderTarget=function(t){e.setRenderTarget(t)}},yp=function(e){var t=new me((-1),1,1,(-1),0,1),r=new fe,i=new bt,n={minFilter:rc,magFilter:$l,format:xc},a=new ge(512,512,n),o=new ge(512,512,n),s=new pe({uniforms:{mapLeft:{value:a.texture},mapRight:{value:o.texture}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = vec2( uv.x, uv.y );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","void main() {","\tvec2 uv = vUv;","\tif ( ( mod( gl_FragCoord.y, 2.0 ) ) > 1.00 ) {","\t\tgl_FragColor = texture2D( mapLeft, uv );","\t} else {","\t\tgl_FragColor = texture2D( mapRight, uv );","\t}","}"].join("\n")}),l=new k(new xe(2,2),s);r.add(l),this.setSize=function(t,r){e.setSize(t,r);var i=e.getPixelRatio();a.setSize(t*i,r*i),o.setSize(t*i,r*i)},this.render=function(n,s){n.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),i.update(s),e.render(n,i.cameraL,a,!0),e.render(n,i.cameraR,o,!0),e.render(r,t)}},xp=function(e){var t=this;t.cameraDistance=15,t.reflectFromAbove=!1;var r,a,o,s=new de,l=new de,c=new de,u=new de,h=new i,d=new n,p=new i;e.autoClear=!1,this.setSize=function(t,i){r=t/2,t$)|(\/>$)/,i=/<[^>]+>[^<]*<\/[^<]+>/,n=function(e,t){return t>0?e+n(e,t-1):""},a=0;return e.match(/(<[^>]+>[^<]+<\/[^<]+>)|(<[^>]+>)/g).map(function(e){i.test(e)||r.test(e)||!t.test(e)||a--;var o=""+n(" ",a)+e;return i.test(e)||r.test(e)||t.test(e)||a++,o}).join("\n")}function a(e){for(var t=atob(e),r=new Uint8Array(t.length),i=0,n=r.length;i'+n.join(" ")+''+r.map(function(e){return''}).join("")+"";return a}function h(e){return e.updateMatrix(),b=b||new r,b.copy(e.matrix),b.transpose(),""+b.toArray().join(" ")+""}function d(e){var t=_.get(e);if(!t){var r=e;r instanceof m&&(r=(new P).fromGeometry(r));var i="Mesh"+(E.length+1),n=r.index?r.index.count*r.index.itemSize:r.attributes.position.count,a=null!=r.groups&&0!==r.groups.length?r.groups:[{start:0,count:n,materialIndex:0}],o='',u=i+"-position",h=i+"-vertices";o+=c(r.attributes.position,u,["X","Y","Z"],"float"),o+='';var d='';if("normal"in r.attributes){var p=i+"-normal";o+=c(r.attributes.normal,p,["X","Y","Z"],"float"),d+=''}if("uv"in r.attributes){var f=i+"-texcoord";o+=c(r.attributes.uv,f,["S","T"],"float"),d+=''}if("color"in r.attributes){var v=i+"-color";o+=c(r.attributes.color,v,["X","Y","Z"],"uint8"),d+=''}var g=null;if(r.index)g=s(r.index);else{g=new Array(n);for(var y=0,x=g.length;y',o+=d,o+="

"+w.join(" ")+"

",o+=""}o+="
",E.push(o),t={meshid:i,bufferGeometry:r},_.set(e,t)}return t}function p(e){var t=A.get(e);if(null==t){t="image-"+(T.length+1);var r="png",n=e.name||t,a='';a+="1.5.0"===g?""+i.textureDirectory+n+"."+r+"":""+i.textureDirectory+n+"."+r+"",a+="",T.push(a),A.set(e,t),M.push({directory:i.textureDirectory,name:n,ext:r,data:o(e.image,r),original:e})}return t}function f(e){var t=S.get(e);if(null==t){t="Mat"+(C.length+1);var r="phong";e instanceof Me?r="lambert":e instanceof F&&(r="constant");var i=e.emissive?e.emissive:new u(0,0,0),n=e.color?e.color:new u(0,0,0),a=e.specular?e.specular:new u(1,1,1),o=e.shininess||0,s=e.reflectivity||0,l="";e.transparent===!0&&(l+=""+(e.map?'':"1")+"",e.opacity<1&&(l+=""+e.opacity+""));var c='<'+r+">"+(e.emissiveMap?'':''+i.r+" "+i.g+" "+i.b+" 1")+""+(e.map?'':''+n.r+" "+n.g+" "+n.b+" 1")+''+a.r+" "+a.g+" "+a.b+" 1"+(e.specularMap?'':''+o+"")+""+n.r+" "+n.g+" "+n.b+" 1"+s+""+l+"",h=''+(e.map?''+p(e.map)+'diffuse-surface':"")+(e.specularMap?''+p(e.specularMap)+'specular-surface':"")+(e.emissiveMap?''+p(e.emissiveMap)+'emissive-surface':"")+c+(e.side===Ks?'1':"")+"";L.push(''),C.push(h),S.set(e,t)}return t}function v(e){var t='';if(t+=h(e),e instanceof k&&null!=e.geometry){var r=d(e.geometry),i=r.meshid,n=r.bufferGeometry,a=null,o=e.material||new F,s=Array.isArray(o)?o:[o];a=new Array(n.groups.length).fill().map(function(e,t){return f(s[t%s.length])}),t+=''+(null!=a?""+a.map(function(e,t){return''}).join("")+"":"")+""}return e.children.forEach(function(e){return t+=v(e)}),t+=""}void 0===i&&(i={}),i=Object.assign({version:"1.4.1",author:null,textureDirectory:""},i),""!==i.textureDirectory&&(i.textureDirectory=(i.textureDirectory+"/").replace(/\\/g,"/").replace(/\/+/g,"/"));var g=i.version;if("1.4.1"!==g&&"1.5.0"!==g)return console.warn("ColladaExporter : Version "+g+" not supported for export. Only 1.4.1 and 1.5.0."),null;var y,x,b,w=["getX","getY","getZ","getW"],_=new WeakMap,S=new WeakMap,A=new WeakMap,M=[],T=[],E=[],C=[],L=[],N=v(e),O="1.4.1"===g?"http://www.collada.org/2005/11/COLLADASchema":"https://www.khronos.org/collada/",D=''+("js Collada Exporter"+(null!==i.author?""+i.author+"":"")+""+(new Date).toISOString()+""+(new Date).toISOString()+"Y_UP")+"";D+=""+T.join("")+"",D+=""+C.join("")+"",D+=""+L.join("")+"",D+=""+E.join("")+"",D+=''+N+"",D+='',D+="";var R={data:n(D),textures:M};return"function"==typeof t&&requestAnimationFrame(function(){return t(R)}),R}};var _p={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987},Sp={1003:_p.NEAREST,1004:_p.NEAREST_MIPMAP_NEAREST,1005:_p.NEAREST_MIPMAP_LINEAR,1006:_p.LINEAR,1007:_p.LINEAR_MIPMAP_NEAREST,1008:_p.LINEAR_MIPMAP_LINEAR},Ap={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Mp=function(){};Mp.prototype={constructor:Mp,parse:function(e,t,r){function n(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}function a(e){if(void 0!==Ds.TextEncoder)return(new TextEncoder).encode(e).buffer;for(var t=new Uint8Array(new ArrayBuffer(e.length)),r=0,i=e.length;r255?32:n}return t.buffer}function o(e,t,r){for(var i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},n=t;n5e-4)return!1;return!0}function c(e){if(z.attributes.has(e))return z.attributes.get(e);for(var t=e.clone(),r=new i,n=0,a=t.count;n0)&&(t.alphaMode=e.opacity<1?"BLEND":"MASK",e.alphaTest>0&&.5!==e.alphaTest&&(t.alphaCutoff=e.alphaTest)),e.side===Ks&&(t.doubleSided=!0),""!==e.name&&(t.name=e.name),Object.keys(e.userData).length>0&&(t.extras=d(e)),D.materials.push(t);var a=D.materials.length-1;return z.materials.set(e,a),a}function _(e){var t,i=e.geometry;if(e.isLineSegments)t=_p.LINES;else if(e.isLineLoop)t=_p.LINE_LOOP;else if(e.isLine)t=_p.LINE_STRIP;else if(e.isPoints)t=_p.POINTS;else{if(!i.isBufferGeometry){var n=new P;n.fromGeometry(i),i=n}e.drawMode===au?(console.warn("GLTFExporter: TriangleFanDrawMode and wireframe incompatible."),t=_p.TRIANGLE_FAN):t=e.drawMode===nu?e.material.wireframe?_p.LINE_STRIP:_p.TRIANGLE_STRIP:e.material.wireframe?_p.LINES:_p.TRIANGLES}var a={},o={},s=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=i.getAttribute("normal");void 0===p||l(p)||(console.warn("GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.addAttribute("normal",c(p)));for(var f in i.attributes){var m=i.attributes[f];f=h[f]||f.toUpperCase();var y=m.array;if("JOINTS_0"!==f||y instanceof Uint16Array||y instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new g(new Uint16Array(y),m.itemSize,m.normalized)),"MORPH"!==f.substr(0,5)){var x=v(m,i);null!==x&&(o[f]=x)}}if(void 0!==p&&i.addAttribute("normal",p),0===Object.keys(o).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){var b=[],_=[],S={};if(void 0!==e.morphTargetDictionary)for(var A in e.morphTargetDictionary)S[e.morphTargetDictionary[A]]=A;for(var M=0;M0&&(a.extras={},a.extras.targetNames=_)}var F=Object.keys(i.userData).length>0?d(i):void 0,R=r.forceIndices,I=Array.isArray(e.material);if(I&&0===i.groups.length)return null;!R&&null===i.index&&I&&(console.warn("GLTFExporter: Creating index for non-indexed multi-material mesh."),R=!0);var U=!1;if(null===i.index&&R){for(var k=[],M=0,B=i.attributes.position.count;M0&&(V.targets=u),null!==i.index&&(V.indices=v(i.index,i,j[M].start,j[M].count));var G=w(z[j[M].materialIndex]);null!==G&&(V.material=G),s.push(V)}return U&&i.setIndex(null),a.primitives=s,D.meshes||(D.meshes=[]),D.meshes.push(a),D.meshes.length-1}function S(e){D.cameras||(D.cameras=[]);var t=e.isOrthographicCamera,r={type:t?"orthographic":"perspective"};return t?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:Fs.degToRad(e.fov)/e.aspect,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),D.cameras.push(r),D.cameras.length-1}function A(e,t){D.animations||(D.animations=[]);for(var r=[],i=[],n=0;n0&&(t.extras=d(e)),e.isMesh||e.isLine||e.isPoints){var s=_(e);null!==s&&(t.mesh=s)}else e.isCamera&&(t.camera=S(e));if(e.isSkinnedMesh&&k.push(e),e.children.length>0){for(var l=[],c=0,u=e.children.length;c0&&(t.children=l)}D.nodes.push(t);var f=D.nodes.length-1;return U.set(e,f),f}function E(e){D.scenes||(D.scenes=[],D.scene=0);var t={nodes:[]};""!==e.name&&(t.name=e.name),D.scenes.push(t);for(var i=[],n=0,a=e.children.length;n0&&(t.nodes=i)}function C(e){var t=new fe;t.name="AuxScene";for(var r=0;r0&&C(t);for(var i=0;i0&&(r.trs=!0);var O,D={asset:{version:"2.0",generator:"GLTFExporter"}},F=0,R=[],I=[],U=new Map,k=[],B={},z={attributes:new Map,materials:new Map,textures:new Map,images:new Map};L(e),Promise.all(I).then(function(){var e=new Blob(R,{type:"application/octet-stream"}),i=Object.keys(B);if(i.length>0&&(D.extensionsUsed=i),D.buffers&&D.buffers.length>0){D.buffers[0].byteLength=e.size;var n=new Ds.FileReader;if(r.binary===!0){var o=12,s=1179937895,l=2,c=8,u=1313821514,d=5130562;n.readAsArrayBuffer(e),n.onloadend=function(){var e=h(n.result),r=new DataView(new ArrayBuffer(c));r.setUint32(0,e.byteLength,!0),r.setUint32(4,d,!0);var i=h(a(JSON.stringify(D)),32),p=new DataView(new ArrayBuffer(c));p.setUint32(0,i.byteLength,!0),p.setUint32(4,u,!0);var f=new ArrayBuffer(o),m=new DataView(f);m.setUint32(0,s,!0),m.setUint32(4,l,!0);var v=o+p.byteLength+i.byteLength+r.byteLength+e.byteLength;m.setUint32(8,v,!0);var g=new Blob([f,p,i,r,e],{type:"application/octet-stream"}),y=new Ds.FileReader;y.readAsArrayBuffer(g),y.onloadend=function(){t(y.result)}}}else n.readAsDataURL(e),n.onloadend=function(){var e=n.result;D.buffers[0].uri=e,t(D)}}else t(D)})}};var Tp=function(){function e(e){if(void 0===a){var t=new MMDParser.CharsetEncoder,r=t.s2uTable;a={};for(var i=Object.keys(r),n=0,o=i.length;n255?(c.push(l>>8&255),c.push(255&l)):c.push(255&l)}return new Uint8Array(c)}function t(e){var t=e.clone();return t.pose(),t.skeleton.bones}var a;this.parseVpd=function(a,o,s){function l(e){Math.abs(e)<1e-6&&(e=0);var t=e.toString();t.indexOf(".")===-1&&(t+="."),t+="000000";var r=t.indexOf("."),i=t.slice(0,r),n=t.slice(r+1,r+7);return i+"."+n}function c(e){for(var t=[],r=0,i=e.length;r256&&(m=2),d>65536&&(m=4);var v="ply\nformat "+(r.binary?"binary_big_endian":"ascii")+" 1.0\nelement vertex "+d+"\nproperty float x\nproperty float y\nproperty float z\n";c===!0&&(v+="property float nx\nproperty float ny\nproperty float nz\n"),h===!0&&(v+="property float s\nproperty float t\n"),u===!0&&(v+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),f===!0&&(v+="element face "+p+"\nproperty list uchar uint"+8*m+" vertex_index\n"),v+="end_header\n";var g=new i,y=new l,x=null;if(r.binary===!0){var b=(new TextEncoder).encode(v),w=d*(12+(c?12:0)+(u?3:0)+(h?8:0)),_=f?p*(3*m+1):0,S=new DataView(new ArrayBuffer(b.length+w+_));new Uint8Array(S.buffer).set(b,0);var A=b.length,M=b.length+w,T=0;n(function(e,t){var r=t.getAttribute("position"),i=t.getAttribute("normal"),n=t.getAttribute("uv"),a=t.getAttribute("color"),o=t.getIndex();y.getNormalMatrix(e.matrixWorld);for(var s=0,l=r.count;s=28){for(A=0;A<3;A++){for(M=0;M<4;M++)for(T=0;T<4;T++)j[4*T+M]=u[3*c[16*ge+4*M+T]+A],s&&ge>=20&&ge<28&&2!==A&&(j[4*T+M]*=1.077),l||2!==A||(j[4*T+M]*=h);ee.set(j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],j[8],j[9],j[10],j[11],j[12],j[13],j[14],j[15]),te.multiplyMatrices(ee,S),H[A].multiplyMatrices(le,te)}for(C=0;C<=t;C++)for(O=C/t,L=0;L<=t;L++){for(D=L/t,I=4,F=R=1;I--;)V[I]=F,G[I]=R,F*=O,R*=D,3===I?(W[I]=X[I]=0,Z=K=1):(W[I]=Z*(3-I),X[I]=K*(3-I),Z*=O,K*=D);for(re.fromArray(V),ie.fromArray(G),ne.fromArray(W),ae.fromArray(X),A=0;A<3;A++)E=re.clone(),E.applyMatrix4(H[A]),Y[A]=E.dot(ie),E=ne.clone(),E.applyMatrix4(H[A]),q[A]=E.dot(ie),E=re.clone(),E.applyMatrix4(H[A]),Q[A]=E.dot(ae);oe.fromArray(q),se.fromArray(Q),J.crossVectors(se,oe),J.normalize(),0===Y[0]&&0===Y[1]?$.set(0,Y[2]>p?1:-1,0):$.set(J.x,J.z,-J.y),b[pe++]=f*Y[0],b[pe++]=f*(Y[2]-p),b[pe++]=-f*Y[1],w[fe++]=$.x,w[fe++]=$.y,w[fe++]=$.z,_[me++]=1-D,_[me++]=1-O}for(C=0;Cr.far)return;a.push({distance:o,distanceToRay:Math.sqrt(n),point:f.clone(),index:i,face:null,object:s})}}var s=this,l=this.geometry,c=this.matrixWorld,u=r.params.Points.threshold;if(null===l.boundingSphere&&l.computeBoundingSphere(),n.copy(l.boundingSphere),n.applyMatrix4(c),n.radius+=u,r.ray.intersectsSphere(n)!==!1){e.getInverse(c),t.copy(r.ray).applyMatrix4(e);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),d=h*h,p=new i,f=new i;if(l.isBufferGeometry){var m=l.index,v=l.attributes,g=v.position.array;if(null!==m)for(var y=m.array,x=0,b=y.length;x 0. && v.y < .05 ) {","\t\tlifeLeft = 0.0;","\t}","\tif( v.x < - 1.45 ) {","\t\tlifeLeft = 0.0;","\t}","\tif( timeElapsed > 0.0 ) {","\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );","\t} else {","\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\t\tlifeLeft = 0.0;","\t\tgl_PointSize = 0.;","\t}","}"].join("\n"),fragmentShader:["float scaleLinear( float value, vec2 valueDomain ) {","\treturn ( value - valueDomain.x ) / ( valueDomain.y - valueDomain.x );","}","float scaleLinear( float value, vec2 valueDomain, vec2 valueRange ) {","\treturn mix( valueRange.x, valueRange.y, scaleLinear( value, valueDomain ) );","}","varying vec4 vColor;","varying float lifeLeft;","uniform sampler2D tSprite;","void main() {","\tfloat alpha = 0.;","\tif( lifeLeft > 0.995 ) {","\t\talpha = scaleLinear( lifeLeft, vec2( 1.0, 0.995 ), vec2( 0.0, 1.0 ) );","\t} else {","\t\talpha = lifeLeft * 0.75;","\t}","\tvec4 tex = texture2D( tSprite, gl_PointCoord );","\tgl_FragColor = vec4( vColor.rgb * tex.a, alpha * tex.a );","}"].join("\n")};for(r=1e5;r>0;r--)t.rand.push(Math.random()-.5);this.random=function(){return++r>=this.rand.length?this.rand[r=1]:this.rand[r]};var n=new Ue;this.particleNoiseTex=this.PARTICLE_NOISE_TEXTURE||n.load("textures/perlin-512.png"),this.particleNoiseTex.wrapS=this.particleNoiseTex.wrapT=Jl,this.particleSpriteTex=this.PARTICLE_SPRITE_TEXTURE||n.load("textures/particle2.png"),this.particleSpriteTex.wrapS=this.particleSpriteTex.wrapT=Jl,this.particleShaderMat=new pe({transparent:!0,depthWrite:!1,uniforms:{uTime:{value:0},uScale:{value:1},tNoise:{value:this.particleNoiseTex},tSprite:{value:this.particleSpriteTex}},blending:ol,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader}),this.particleShaderMat.defaultAttributeValues.particlePositionsStartTime=[0,0,0,0],this.particleShaderMat.defaultAttributeValues.particleVelColSizeLife=[0,0,0,0],this.init=function(){for(var e=this,t=0;t=this.PARTICLE_COUNT&&(this.PARTICLE_CURSOR=1);var t=this.particleContainers[Math.floor(this.PARTICLE_CURSOR/this.PARTICLES_PER_CONTAINER)];t.spawnParticle(e)},this.update=function(e){for(var t=this,r=0;r=this.PARTICLE_COUNT&&(this.PARTICLE_CURSOR=0),this.particleUpdate=!0},this.init=function(){this.particleSystem=new Et(this.particleShaderGeo,this.particleShaderMat),this.particleSystem.frustumCulled=!1,this.add(this.particleSystem)},this.update=function(e){this.time=e,this.particleShaderMat.uniforms.uTime.value=e,this.geometryUpdate()},this.geometryUpdate=function(){if(this.particleUpdate===!0){this.particleUpdate=!1;var e=this.particleShaderGeo.getAttribute("positionStart"),t=this.particleShaderGeo.getAttribute("startTime"),r=this.particleShaderGeo.getAttribute("velocity"),i=this.particleShaderGeo.getAttribute("turbulence"),n=this.particleShaderGeo.getAttribute("color"),a=this.particleShaderGeo.getAttribute("size"),o=this.particleShaderGeo.getAttribute("lifeTime"); +this.offset+this.count\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};var Up=function(e){pe.call(this,{type:"LineMaterial",uniforms:Mu.clone(vp.line.uniforms),vertexShader:vp.line.vertexShader,fragmentShader:vp.line.fragmentShader}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)};Up.prototype=Object.create(pe.prototype),Up.prototype.constructor=Up,Up.prototype.isLineMaterial=!0,Up.prototype.copy=function(e){return pe.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.resolution=e.resolution,this};var kp=function(e,t){k.call(this),this.type="LineSegments2",this.geometry=void 0!==e?e:new Ip,this.material=void 0!==t?t:new Up({color:16777215*Math.random()})};kp.prototype=Object.assign(Object.create(k.prototype),{constructor:kp,isLineSegments2:!0,computeLineDistances:function(){var e=new i,t=new i;return function(){for(var r=this.geometry,i=r.attributes.instanceStart,n=r.attributes.instanceEnd,a=new Float32Array(2*i.data.count),o=0,s=0,l=i.data.count;o=200)return void i("AssimpJSONLoader: Unsupported assimp2json file format version.")}t(n.parse(r,a))},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){function i(e,t){for(var r=this,i=new Array(e.length),n=0;n0&&n.addAttribute("normal",new M(s,3)),l.length>0&&n.addAttribute("uv",new M(l,2)),c.length>0&&n.addAttribute("color",new M(c,3)),n.computeBoundingSphere(),n}function a(e){var t=new Ee;for(var r in e.properties){var i=e.properties[r],n=i.key,a=i.value;switch(n){case"$tex.file":var o=i.semantic;if(1===o||2===o||5===o||6===o){var l;switch(o){case 1:l="map";break;case 2:l="specularMap";break;case 5:l="bumpMap";break;case 6:l="normalMap"}var c=s.load(a);c.wrapS=c.wrapT=Jl,t[l]=c}break;case"?mat.name":t.name=a;break;case"$clr.diffuse":t.color.fromArray(a);break;case"$clr.specular":t.specular.fromArray(a);break;case"$clr.emissive":t.emissive.fromArray(a);break;case"$mat.shininess":t.shininess=a;break;case"$mat.shadingm":t.flatShading=1===a;break;case"$mat.opacity":a<1&&(t.opacity=a,t.transparent=!0)}}return t}function o(e,t,i,n){var a,s,l=new c;for(l.name=t.name||"",l.matrix=(new r).fromArray(t.transformation).transpose(),l.matrix.decompose(l.position,l.quaternion,l.scale),a=0;t.meshes&&a4&&(r.length=4);for(var n=0,i=0;i<4;i++)n+=r[i].w*r[i].w;n=Math.sqrt(n);for(var i=0;i<4;i++)r[i].w=r[i].w/n,e[i]=r[i].i,t[i]=r[i].w}function d(e,t){if(0==e.name.indexOf("bone_"+t))return e;for(var r in e.children){var i=d(e.children[r],t);if(i)return i}}function p(){this.mPrimitiveTypes=0,this.mNumVertices=0,this.mNumFaces=0,this.mNumBones=0,this.mMaterialIndex=0,this.mVertices=[],this.mNormals=[],this.mTangents=[],this.mBitangents=[],this.mColors=[[]],this.mTextureCoords=[[]],this.mFaces=[],this.mBones=[],this.hookupSkeletons=function(e,t){var i=this;if(0!=this.mBones.length){for(var n=[],a=[],o=e.findNode(this.mBones[0].mName);o.mParent&&o.mParent.isBone;)o=o.mParent;var s=o.toTHREE(e),c=l(s,e);this.threeNode.add(c);for(var u=0;u0&&i.addAttribute("normal",new g(this.mNormalBuffer,3)),this.mColorBuffer&&this.mColorBuffer.length>0&&i.addAttribute("color",new g(this.mColorBuffer,4)),this.mTexCoordsBuffers[0]&&this.mTexCoordsBuffers[0].length>0&&i.addAttribute("uv",new g(new Float32Array(this.mTexCoordsBuffers[0]),2)),this.mTexCoordsBuffers[1]&&this.mTexCoordsBuffers[1].length>0&&i.addAttribute("uv1",new g(new Float32Array(this.mTexCoordsBuffers[1]),2)),this.mTangentBuffer&&this.mTangentBuffer.length>0&&i.addAttribute("tangents",new g(this.mTangentBuffer,3)),this.mBitangentBuffer&&this.mBitangentBuffer.length>0&&i.addAttribute("bitangents",new g(this.mBitangentBuffer,3)),this.mBones.length>0){for(var n=[],a=[],o=0;o0&&(d=new Rt(i,r)),this.threeNode=d,d}}function f(){this.mNumIndices=0,this.mIndices=[]}function m(){this.x=0,this.y=0,this.z=0,this.toTHREE=function(){return new i(this.x,this.y,this.z)}}function v(){this.r=0,this.g=0,this.b=0,this.a=0,this.toTHREE=function(){return new u(this.r,this.g,this.b,1)}}function y(){this.x=0,this.y=0,this.z=0,this.w=0,this.toTHREE=function(){return new n(this.x,this.y,this.z,this.w)}}function x(){this.mVertexId=0,this.mWeight=0}function b(){this.data=[],this.toString=function(){var e="";return this.data.forEach(function(t){e+=String.fromCharCode(t)}),e.replace(/[^\x20-\x7E]+/g,"")}}function w(){this.mTime=0,this.mValue=null}function _(){this.mTime=0,this.mValue=null}function S(){this.mName="",this.mTransformation=[],this.mNumChildren=0,this.mNumMeshes=0,this.mMeshes=[],this.mChildren=[],this.toTHREE=function(e){var t=this;if(this.threeNode)return this.threeNode;var r=new c;r.name=this.mName,r.matrix=this.mTransformation.toTHREE();for(var i=0;i0)var i=this.mAnimations[0].toTHREE(this);return{object:t,animation:i}}}function U(){this.elements=[[],[],[],[]],this.toTHREE=function(){for(var e=this,t=new r,i=0;i<4;++i)for(var n=0;n<4;++n)t.elements[4*i+n]=e.elements[n][i];return t}}function B(e){var t=e.getFloat32(e.readOffset,Ke);return e.readOffset+=4,t}function z(e){var t=e.getFloat64(e.readOffset,Ke);return e.readOffset+=8,t}function j(e){var t=e.getUint8(e.readOffset);return e.readOffset+=1,t}function V(e){var t=e.getUint16(e.readOffset,Ke);return e.readOffset+=2,t}function G(e){var t=e.getUint32(e.readOffset,Ke);return e.readOffset+=4,t}function W(e){var t=e.getUint32(e.readOffset,Ke);return e.readOffset+=4,t}function X(e){var t=new m;return t.x=B(e),t.y=B(e),t.z=B(e),t}function H(e){var t=new v;return t.r=B(e),t.g=B(e),t.b=B(e),t}function Y(e){var t=new y;return t.w=B(e),t.x=B(e),t.y=B(e),t.z=B(e),t}function q(e){var t=new b,r=G(e);return e.ReadBytes(t.data,1,r),t.toString()}function Q(e){var t=new x;return t.mVertexId=G(e),t.mWeight=B(e),t}function J(e){for(var t=new U,r=0;r<4;++r)for(var i=0;i<4;++i)t.elements[r][i]=B(e);return t}function Z(e){var t=new w;return t.mTime=z(e),t.mValue=X(e),t}function K(e){var t=new _;return t.mTime=z(e),t.mValue=Y(e),t}function $(e,t,r){for(var i=0;i0,we=V(r)>0,be)throw"Shortened binaries are not supported!";if(r.Seek(256,$e),r.Seek(128,$e),r.Seek(64,$e),!we)return me(r,t),t.toTHREE();var i=W(r),n=r.FileSize()-r.Tell(),a=[];r.Read(a,1,n);var o=[];uncompress(o,i,a,n);var s=new ArrayBuffer(o);me(s,t)}var ye=new Ue(this.manager);ye.setPath(t).setCrossOrigin(this.crossOrigin);var xe={};xe.KeyFrame=function(e,t){this.time=e,this.matrix=t.clone(),this.position=new i,this.quaternion=new n,this.scale=new i(1,1,1),this.matrix.decompose(this.position,this.quaternion,this.scale),this.clone=function(){var e=new xe.KeyFrame(this.time,this.matrix);return e},this.lerp=function(e,t){t-=this.time;var r=e.time-this.time,i=t/r,n=1-i,a=this.position,o=this.quaternion,s=e.position,l=e.quaternion;return xe.KeyFrame.tempAniPos.x=a.x*n+s.x*i,xe.KeyFrame.tempAniPos.y=a.y*n+s.y*i,xe.KeyFrame.tempAniPos.z=a.z*n+s.z*i,xe.KeyFrame.tempAniQuat.set(o.x,o.y,o.z,o.w),xe.KeyFrame.tempAniQuat.slerp(l,i),xe.KeyFrame.tempAniMatrix.compose(xe.KeyFrame.tempAniPos,xe.KeyFrame.tempAniQuat,xe.KeyFrame.tempAniScale)}},xe.KeyFrame.tempAniPos=new i,xe.KeyFrame.tempAniQuat=new n,xe.KeyFrame.tempAniScale=new i(1,1,1),xe.KeyFrame.tempAniMatrix=new r,xe.KeyFrameTrack=function(){this.keys=[],this.target=null,this.time=0,this.length=0,this._accelTable={},this.fps=20,this.addKey=function(e){this.keys.push(e)},this.init=function(){var e=this;if(this.sortKeys(),this.keys.length>0?this.length=this.keys[this.keys.length-1].time:this.length=0,this.fps)for(var t=0;t=t/e.fps){e._accelTable[t]=r;break}}},this.parseFromThree=function(e){var t=this,r=e.fps;this.target=e.node;for(var i=e.hierarchy[0].keys,n=0;ne){r=t.keys[n],i=t.keys[n+1];break}if(t.keys[n].time1)for(r=new c,m=0;m191&&n<224){var a=t._data.getUint8(t._ptr++,gf);r[i++]=String.fromCharCode((31&n)<<6|63&a)}else{var a=t._data.getUint8(t._ptr++,gf),o=t._data.getUint8(t._ptr++,gf);r[i++]=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o)}}return r.join("")}},kt.prototype=Object.assign(Object.create(c.prototype),{constructor:kt,isLight:!0,copy:function(e){return c.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=c.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Object.assign(Bt.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),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}}),zt.prototype=Object.assign(Object.create(kt.prototype),{constructor:zt,isPointLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),jt.prototype=Object.assign(Object.create(Bt.prototype),{constructor:jt}),Vt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Vt,isDirectionalLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Gt.prototype=Object.assign(Object.create(Bt.prototype),{constructor:Gt,isSpotLightShadow:!0,update:function(e){var t=this.camera,r=2*Fs.RAD2DEG*e.angle,i=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix())}}),Wt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Wt,isSpotLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),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}}),Xt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Xt,isHemisphereLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}});var xf=function(e){this.manager=void 0!==e?e:Du};xf.prototype={constructor:xf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},parse:function(e){function t(e){for(var t={},r=0,i=e.materials.length;r256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case m:case v:e.colormap_type&&console.error("TGALoader: Invalid type colormap data for colormap type.");break;case u:console.error("TGALoader: No data.");default:console.error('TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('TGALoader: Invalid pixel size "%s".',e.pixel_size)}function r(e,t,r,i,n){var a,o,s,l;if(o=r.pixel_size>>3,s=r.width*r.height*o,t&&(l=n.subarray(i,i+=r.colormap_length*(r.colormap_size>>3))),e){a=new Uint8Array(s);for(var c,u,h,d=0,p=new Uint8Array(o);d>7,e[4*(c+d*u)+1]=(992&l)>>2,e[4*(c+d*u)+2]=(31&l)>>3,e[4*(c+d*u)+3]=32768&l?0:255;return e}function a(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+1]=s[u+1],e[4*(l+h*c)+0]=s[u+2];return e}function o(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=4)e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+1]=s[u+1],e[4*(l+h*c)+0]=s[u+2],e[4*(l+h*c)+3]=s[u+3];return e}function s(e,t,r,i,n,a,o,s){var l,c,u,h=0,d=M.width;for(u=t;u!==i;u+=r)for(c=n;c!==o;c+=a,h++)l=s[h],e[4*(c+d*u)+0]=l,e[4*(c+d*u)+1]=l,e[4*(c+d*u)+2]=l,e[4*(c+d*u)+3]=255;return e}function l(e,t,r,i,n,a,o,s){var l,c,u=0,h=M.width;for(c=t;c!==i;c+=r)for(l=n;l!==o;l+=a,u+=2)e[4*(l+h*c)+0]=s[u+0],e[4*(l+h*c)+1]=s[u+0],e[4*(l+h*c)+2]=s[u+0],e[4*(l+h*c)+3]=s[u+1];return e}function c(e,t,r,c,u){var h,d,p,f,m,v;switch((M.flags&g)>>y){default:case w:h=0,p=1,m=t,d=0,f=1,v=r;break;case x:h=0,p=1,m=t,d=r-1,f=-1,v=-1;break;case _:h=t-1,p=-1,m=-1,d=0,f=1,v=r;break;case b:h=t-1,p=-1,m=-1,d=r-1,f=-1,v=-1}if(C)switch(M.pixel_size){case 8:s(e,d,f,v,h,p,m,c);break;case 16:l(e,d,f,v,h,p,m,c);break;default:console.error("TGALoader: Format not supported.")}else switch(M.pixel_size){case 8:i(e,d,f,v,h,p,m,c,u);break;case 16:n(e,d,f,v,h,p,m,c);break;case 24:a(e,d,f,v,h,p,m,c);break;case 32:o(e,d,f,v,h,p,m,c);break;default:console.error("TGALoader: Format not supported.")}return e}var u=0,h=1,d=2,p=3,f=9,m=10,v=11,g=48,y=4,x=0,b=1,w=2,_=3;e.length<19&&console.error("TGALoader: Not enough data to contain header.");var S=new Uint8Array(e),A=0,M={id_length:S[A++],colormap_type:S[A++],image_type:S[A++],colormap_index:S[A++]|S[A++]<<8,colormap_length:S[A++]|S[A++]<<8,colormap_size:S[A++],origin:[S[A++]|S[A++]<<8,S[A++]|S[A++]<<8],width:S[A++]|S[A++]<<8,height:S[A++]|S[A++]<<8,pixel_size:S[A++],flags:S[A++]};t(M),M.id_length+A>e.length&&console.error("TGALoader: No data."),A+=M.id_length;var T=!1,E=!1,C=!1;switch(M.image_type){case f:T=!0,E=!0;break;case h:E=!0;break;case m:T=!0;break;case d:break;case v:T=!0,C=!0;break;case p:C=!0}var L=document.createElement("canvas");L.width=M.width,L.height=M.height;var P=L.getContext("2d"),N=P.createImageData(M.width,M.height),O=r(T,E,M,A,S);c(N.data,M.width,M.height,O.pixel_data,O.palettes);return P.putImageData(N,0,0),L},setPath:function(e){return this.path=e,this}};var _f=function(e){this.manager=void 0!==e?e:Du};_f.prototype={constructor:_f,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=void 0===n.path?Ru.extractUrlBase(e):n.path,o=new we(n.manager);o.load(e,function(e){t(n.parse(e,a))},r,i)},setPath:function(e){return this.path=e,this},options:{set convertUpAxis(e){console.warn("ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.")}},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){function a(e,t){for(var r=[],i=e.childNodes,n=0,a=i.length;n0&&t.push(new te(i+".position",n,a)),o.length>0&&t.push(new $(i+".quaternion",n,o)),s.length>0&&t.push(new te(i+".scale",n,s)),t}function L(e,t,r){var i,n,a,o=!0;for(n=0,a=e.length;n=0;){var i=e[t];if(null!==i.value[r])return i;t--}return null}function D(e,t,r){for(;t>>0)+2);switch(r=r.toLowerCase()){case"tga":t=Xt;break;default:t=Gt}return t}function _e(e){function t(e){var t=i.profile.samplers[e.id],r=null;if(void 0!==t){var n=i.profile.surfaces[t.source];r=Z(n.init_from)}else console.warn("ColladaLoader: Undefined sampler. Access image directly (see #12530)."),r=Z(e.id);if(null!==r){var a=we(r);if(void 0!==a){var o=a.load(r),s=e.extra;if(void 0!==s&&void 0!==s.technique&&p(s.technique)===!1){var l=s.technique;o.wrapS=l.wrapU?Jl:Zl,o.wrapT=l.wrapV?Jl:Zl,o.offset.set(l.offsetU||0,l.offsetV||0),o.repeat.set(l.repeatU||1,l.repeatV||1)}else o.wrapS=Jl,o.wrapT=Jl;return o}return console.warn("ColladaLoader: Loader for texture %s not found.",r),null}return console.warn("ColladaLoader: Couldn't create texture with ID:",e.id),null}var r,i=xe(e.url),n=i.profile.technique,a=i.profile.extra;switch(n.type){case"phong":case"blinn":r=new Ee;break;case"lambert":r=new Me;break;default:r=new F}r.name=e.name;var o=n.parameters;for(var s in o){var l=o[s];switch(s){case"diffuse":l.color&&r.color.fromArray(l.color),l.texture&&(r.map=t(l.texture));break;case"specular":l.color&&r.specular&&r.specular.fromArray(l.color),l.texture&&(r.specularMap=t(l.texture));break;case"shininess":l["float"]&&r.shininess&&(r.shininess=l["float"]);break;case"emission":l.color&&r.emissive&&r.emissive.fromArray(l.color),l.texture&&(r.emissiveMap=t(l.texture))}}var c=o.transparent,u=o.transparency;if(void 0===u&&c&&(u={"float":1}),void 0===c&&u&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&u)if(c.data.texture)r.transparent=!0;else{var h=c.data.color;switch(c.opaque){case"A_ONE":r.opacity=h[3]*u["float"];break;case"RGB_ZERO":r.opacity=1-h[0]*u["float"];break;case"A_ZERO":r.opacity=1-h[3]*u["float"];break;case"RGB_ONE":r.opacity=h[0]*u["float"];break;default:console.warn('ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}r.opacity<1&&(r.transparent=!0)}return void 0!==a&&void 0!==a.technique&&1===a.technique.double_sided&&(r.side=Ks),r}function Se(e){return x(Zt.materials[e],_e)}function Ae(e){for(var t={name:e.getAttribute("name")},r=0,i=e.childNodes.length;r0&&t0&&u.addAttribute("position",new M(n.array,n.stride)),a.array.length>0&&u.addAttribute("normal",new M(a.array,a.stride)),s.array.length>0&&u.addAttribute("color",new M(s.array,s.stride)),o.array.length>0&&u.addAttribute("uv",new M(o.array,o.stride)),l.array.length>0&&u.addAttribute("skinIndex",new M(l.array,l.stride)),c.array.length>0&&u.addAttribute("skinWeight",new M(c.array,c.stride)),i.data=u,i.type=e[0].type,i.materialKeys=h,i}function He(e,t,r,i){function n(e){for(var t=a[e+r]*c,n=t+c;t4)for(var y=1,x=p-2;y<=x;y++){var f=u+0*o,m=u+o*y,v=u+o*(y+1);n(f),n(m),n(v)}u+=o*p}else for(var h=0,d=a.length;h=t.limits.max&&(t["static"]=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function et(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},r=0;ri.limits.max||t>8&255,e>>16&255,e>>24&255)}function n(e,t,r,i){for(var n=r*i*4,a=new Uint8Array(e,t,n),o=new Uint8Array(n),s=0,l=0,c=0;c>1,1),W=Math.max(W>>1,1)}return a},Jt.prototype=Object.assign(Object.create(B.prototype),{constructor:Jt,isLineLoop:!0});var Af=function(){function e(e){this.manager=void 0!==e?e:Du}function t(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}},update:function(t,r){for(var i in e){var n=e[i];n.update&&n.update(t,r)}}}}function n(e,t){var i={},n=e.material.uniforms;for(var a in n){var o=n[a];if(o.semantic){var s=o.node,l=e;s&&(l=t[s]),i[a]={semantic:o.semantic,sourceNode:l,targetNode:e,uniform:o}}}this.boundUniforms=i,this._m4=new r}function a(e){var t=this;this.name=x.KHR_MATERIALS_COMMON,this.lights={};var r=e.extensions&&e.extensions[x.KHR_MATERIALS_COMMON]||{},i=r.lights||{};for(var n in i){var a,o=i[n],s=o[o.type],l=(new u).fromArray(s.color);switch(o.type){case"directional":a=new Vt(l),a.position.set(0,0,1);break;case"point":a=new zt(l);break;case"spot":a=new Wt(l),a.position.set(0,0,1);break;case"ambient":a=new Ht(l)}a&&(t.lights[n]=a)}}function o(e){this.name=x.KHR_BINARY_GLTF;var t=new DataView(e,0,_),r={magic:Ru.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0),contentLength:t.getUint32(12,!0),contentFormat:t.getUint32(16,!0)};for(var i in w){var n=w[i];if(r[i]!==n)throw new Error('Unsupported glTF-Binary header: Expected "%s" to be "%s".',i,n)}var a=new Uint8Array(e,_,r.contentLength);this.header=r,this.content=Ru.decodeText(a),this.body=e.slice(_+r.contentLength,r.length)}function s(e,t,r){var i=this;if(!e)return Promise.resolve();var n,a=[];if("[object Array]"===Object.prototype.toString.call(e)){n=[];for(var o=e.length,s=0;s=0&&(n[x.KHR_MATERIALS_COMMON]=new a(l));var c=new y(l,n,{crossOrigin:this.crossOrigin,manager:this.manager,path:t||this.path});c.parse(function(e,t,i,n){var a={scene:e,scenes:t,cameras:i,animations:n};r(a)})}},e.Shaders={update:function(){console.warn("LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},n.prototype.update=function(e,t){var r=this,i=this.boundUniforms;for(var n in i){var a=i[n];switch(a.semantic){case"MODELVIEW":var o=a.uniform.value;o.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var s=a.uniform.value;r._m4.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld),s.getNormalMatrix(r._m4);break;case"PROJECTION":var o=a.uniform.value;o.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var l=a.uniform.value,c=0;c0&&console.log("Loaded a mesh.");else{if(s!=t.POINT_CLOUD){var l="DRACOLoader: Unknown geometry type.";throw console.error(l),new Error(l)}this.verbosity>0&&console.log("Loaded a point cloud.")}r(this.convertDracoGeometryTo3JS(t,o,s,a,i,n))},addAttributeToGeometry:function(e,t,r,i,n,a,o,s){if(0===a.ptr){var l="DRACOLoader: No attribute "+i;throw console.error(l),new Error(l)}var c,u,h=a.num_components(),d=r.num_points(),p=d*h;switch(n){case Float32Array:c=new e.DracoFloat32Array,t.GetAttributeFloatForAllPoints(r,a,c),s[i]=new Float32Array(p),u=M;break;case Int8Array:c=new e.DracoInt8Array,t.GetAttributeInt8ForAllPoints(r,a,c),s[i]=new Int8Array(p),u=y;break;case Int16Array:c=new e.DracoInt16Array,t.GetAttributeInt16ForAllPoints(r,a,c),s[i]=new Int16Array(p),u=w;break;case Int32Array:c=new e.DracoInt32Array,t.GetAttributeInt32ForAllPoints(r,a,c),s[i]=new Int32Array(p),u=S;break;case Uint8Array:c=new e.DracoUInt8Array,t.GetAttributeUInt8ForAllPoints(r,a,c),s[i]=new Uint8Array(p),u=x;break;case Uint16Array:c=new e.DracoUInt16Array,t.GetAttributeUInt16ForAllPoints(r,a,c),s[i]=new Uint16Array(p),u=_;break;case Uint32Array:c=new e.DracoUInt32Array,t.GetAttributeUInt32ForAllPoints(r,a,c),s[i]=new Uint32Array(p),u=A;break;default:var l="DRACOLoader: Unexpected attribute type.";throw console.error(l),new Error(l)}for(var f=0;f0&&console.log("Number of faces loaded: "+d.toString())):d=0;var p=s.num_points(),f=s.num_attributes();this.verbosity>0&&(console.log("Number of points loaded: "+p.toString()),console.log("Number of attributes loaded: "+f.toString()));var m=t.GetAttributeId(s,e.POSITION);if(m==-1){var u="DRACOLoader: No position attribute found.";throw console.error(u),e.destroy(t),e.destroy(s),new Error(u)}var v=t.GetAttribute(s,m),g={},y=new P;for(var x in o.nativeAttributeMap)if(void 0===n[x]){var b=t.GetAttributeId(s,e[o.nativeAttributeMap[x]]);if(b!==-1){o.verbosity>0&&console.log("Loaded "+x+" attribute.");var w=t.GetAttribute(s,b);o.addAttributeToGeometry(e,t,s,x,Float32Array,w,y,g)}}for(var x in n){var S=a[x]||Float32Array,M=n[x],w=t.GetAttributeByUniqueId(s,M);o.addAttributeToGeometry(e,t,s,x,S,w,y,g)}if(r==e.TRIANGULAR_MESH)if(this.drawMode===nu){var T=new e.DracoInt32Array;t.GetTriangleStripsFromMesh(s,T);g.indices=new Uint32Array(T.size());for(var E=0;E65535?A:_)(g.indices,1));var O=new e.AttributeQuantizationTransform;if(O.InitFromAttribute(v)){y.attributes.position.isQuantized=!0,y.attributes.position.maxRange=O.range(),y.attributes.position.numQuantizationBits=O.quantization_bits(),y.attributes.position.minValues=new Float32Array(3);for(var E=0;E<3;++E)y.attributes.position.minValues[E]=O.min_value(E)}return e.destroy(O),e.destroy(t),e.destroy(s),this.decode_time=h-c,this.import_time=performance.now()-h,this.verbosity>0&&(console.log("Decode time: "+this.decode_time),console.log("Import time: "+this.import_time)),y},isVersionSupported:function(e,t){Mf.getDecoderModule().then(function(r){t(r.decoder.isVersionSupported(e))})},getAttributeOptions:function(e){return"undefined"==typeof this.attributeOptions[e]&&(this.attributeOptions[e]={}),this.attributeOptions[e]}},Mf.decoderPath="./",Mf.decoderConfig={},Mf.decoderModulePromise=null,Mf.setDecoderPath=function(e){Mf.decoderPath=e},Mf.setDecoderConfig=function(e){var t=Mf.decoderConfig.wasmBinary;Mf.decoderConfig=e||{},Mf.releaseDecoderModule(),t&&(Mf.decoderConfig.wasmBinary=t)},Mf.releaseDecoderModule=function(){Mf.decoderModulePromise=null},Mf.getDecoderModule=function(){var e=this,t=Mf.decoderPath,r=Mf.decoderConfig,i=Mf.decoderModulePromise;return i?i:("undefined"!=typeof DracoDecoderModule?i=Promise.resolve():"object"!=typeof WebAssembly||"js"===r.type?i=Mf._loadScript(t+"draco_decoder.js"):(r.wasmBinaryFile=t+"draco_decoder.wasm",i=Mf._loadScript(t+"draco_wasm_wrapper.js").then(function(){return Mf._loadArrayBuffer(r.wasmBinaryFile)}).then(function(e){r.wasmBinary=e})),i=i.then(function(){return new Promise(function(t){r.onModuleLoaded=function(r){e.timeLoaded=performance.now(),t({decoder:r})},DracoDecoderModule(r)})}),Mf.decoderModulePromise=i,i)},Mf._loadScript=function(e){var t=document.getElementById("decoder_script");null!==t&&t.parentNode.removeChild(t);var r=document.getElementsByTagName("head")[0],i=document.createElement("script");return i.id="decoder_script",i.type="text/javascript",i.src=e,new Promise(function(e){i.onload=e,r.appendChild(i)})},Mf._loadArrayBuffer=function(e){var t=new we;return t.setResponseType("arraybuffer"),new Promise(function(r,i){t.load(e,r,void 0,i)})},Zt.prototype=Object.create(ge.prototype),Zt.prototype.constructor=Zt,Zt.prototype.isWebGLRenderTargetCube=!0;var Tf=function(e,t){this.sourceTexture=e,this.resolution=t.resolution||512,this.views=[{t:[1,0,0],u:[0,-1,0]},{t:[-1,0,0],u:[0,-1,0]},{t:[0,1,0],u:[0,0,1]},{t:[0,-1,0],u:[0,0,-1]},{t:[0,0,1],u:[0,-1,0]},{t:[0,0,-1],u:[0,-1,0]}],this.camera=new de(90,1,.1,10),this.boxMesh=new k(new le(1,1,1),this.getShader()),this.boxMesh.material.side=Zs,this.scene=new fe,this.scene.add(this.boxMesh);var r={format:t.format||this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:t.type||this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.renderTarget=new Zt(this.resolution,this.resolution,r)};Tf.prototype={constructor:Tf,update:function(e){for(var t=this,r=0;r<6;r++){t.renderTarget.activeCubeFace=r;var i=t.views[r];t.camera.position.set(0,0,0),t.camera.up.set(i.u[0],i.u[1],i.u[2]),t.camera.lookAt(i.t[0],i.t[1],i.t[2]),e.render(t.scene,t.camera,t.renderTarget,!0)}return this.renderTarget.texture},getShader:function(){var e=new pe({uniforms:{equirectangularMap:{value:this.sourceTexture}},vertexShader:"varying vec3 localPosition;\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tlocalPosition = position;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec3 localPosition;\n\t\t\t\tuniform sampler2D equirectangularMap;\n\t\t\t\t\n\t\t\t\tvec2 EquirectangularSampleUV(vec3 v) {\n\t\t\t vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n\t\t\t uv *= vec2(0.1591, 0.3183); // inverse atan\n\t\t\t uv += 0.5;\n\t\t\t return uv;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 uv = EquirectangularSampleUV(normalize(localPosition));\n \t\t\tvec3 color = texture2D(equirectangularMap, uv).rgb;\n \t\t\t\n\t\t\t\t\tgl_FragColor = vec4( color, 1.0 );\n\t\t\t\t}",blending:nl});return e.type="EquirectangularToCubeGenerator",e},dispose:function(){this.boxMesh.geometry.dispose(),this.boxMesh.material.dispose(),this.renderTarget.dispose()}},Object.assign(Kt.prototype,{load:function(e,t,r,i){var n=this,a=new Mt,o=new we(this.manager);return o.setResponseType("arraybuffer"),o.load(e,function(e){var r=n._parser(e);r&&(void 0!==r.image?a.image=r.image:void 0!==r.data&&(a.image.width=r.width,a.image.height=r.height,a.image.data=r.data),a.wrapS=void 0!==r.wrapS?r.wrapS:Zl,a.wrapT=void 0!==r.wrapT?r.wrapT:Zl,a.magFilter=void 0!==r.magFilter?r.magFilter:rc,a.minFilter=void 0!==r.minFilter?r.minFilter:nc,a.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,void 0!==r.format&&(a.format=r.format),void 0!==r.type&&(a.type=r.type),void 0!==r.mipmaps&&(a.mipmaps=r.mipmaps),1===r.mipmapCount&&(a.minFilter=rc),a.needsUpdate=!0,t&&t(a,r))},r,i),a}});var Ef=function(e){this.manager=void 0!==e?e:Du};Ef.prototype=Object.create(Kt.prototype),Ef.prototype._parser=function(e){function t(e,t){for(var r=0,i=0;i>3]&1<<(7&i))&&(t[r++]=i);for(var n=r-1;r>r&(1<0;--t){var i=r+$[t]>>1;$[t]=r,r=i}for(var t=0;t0&&(e[t]=n|$[n]++<<6)}}function a(e,t,r,a,o,s,l){for(var c=r,u=0,h=0;o<=s;o++){if(c.value-r.value>a)return!1;i(6,u,h,e,c);var d=K.l;if(u=K.c,h=K.lc,l[o]=d,d==W){if(c.value-r.value>a)throw"Something wrong with hufUnpackEncTable";i(8,u,h,e,c);var p=K.l+X;if(u=K.c,h=K.lc,o+p>s+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[o++]=0;o--}else if(d>=G){var p=d-G+2;if(o+p>s+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[o++]=0;o--}}n(l)}function o(e){return 63&e}function s(e){return e>>6}function l(e,t,r,i){for(;t<=r;t++){var n=s(e[t]),a=o(e[t]);if(n>>a)throw"Invalid table entry";if(a>B){var l=i[n>>a-B];if(l.len)throw"Invalid table entry";if(l.lit++,l.p){var c=l.p;l.p=new Array(l.lit);for(var u=0;u0;u--){var l=i[(n<>i,h=new Uint8Array([h])[0];if(l.value+h>u)return!1;for(var d=s[l.value-1];h-- >0;)s[l.value++]=d}else{if(!(l.value32767?t-65536:t}function p(e,t){var r=d(e),i=d(t),n=i,a=r+(1&n)+(n>>1),o=a,s=a-n;re.a=o,re.b=s}function f(e,t,r,i,n,a,o){for(var s,l=r>n?n:r,c=1;c<=l;)c<<=1;for(c>>=1,s=c,c>>=1;c>=1;){for(var u,h,d,f,m=0,v=m+a*(n-s),g=a*c,y=a*s,x=i*c,b=i*s;m<=v;m+=y){for(var w=m,_=m+i*(r-s);w<=_;w+=b){var S=w+x,A=w+g,M=A+x;p(t[w+e],t[A+e]),u=re.a,d=re.b,p(t[S+e],t[M+e]),h=re.a,f=re.b,p(u,h),t[w+e]=re.a,t[S+e]=re.b,p(d,f),t[A+e]=re.a,t[M+e]=re.b}if(r&c){var A=w+g;p(t[w+e],t[A+e]),u=re.a,t[A+e]=re.b,t[w+e]=u}}if(n&c)for(var w=m,_=m+i*(r-s);w<=_;w+=b){var S=w+x;p(t[w+e],t[S+e]),u=re.a,t[S+e]=re.b,t[w+e]=u}s=c,c>>=1}return m}function m(e,t,r,i,n,a,l,h,d,p){for(var f=0,m=0,v=h,g=Math.trunc(n.value+(a+7)/8);n.value=B;){var y=f>>m-B&V,x=t[y];if(x.len)m-=x.len,u(x.lit,l,f,m,r,i,n,d,p,v),f=te.c,m=te.lc;else{if(!x.p)throw"hufDecode issues";var b;for(b=0;b=w&&s(e[x.p[b]])==(f>>m-w&(1<>=_,m-=_;m>0;){var x=t[f<=z||d<0||d>=z)throw"Something wrong with HUF_ENCSIZE";var f=new Array(z),v=new Array(j);r(v);var g=n-(i.value-u);if(a(e,t,i,g,h,d,f),p>8*(n-(i.value-u)))throw"Something wrong with hufUncompress";l(f,h,d,v),m(f,v,e,t,i,p,d,c,o,s)}function g(e,t,r){for(var i=0;i=U)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(d<=p)for(var m=0;m>10,r=1023&e;return(e>>15?-1:1)*(t?31===t?r?NaN:1/0:Math.pow(2,t-15)*(1+r/1024):6103515625e-14*(r/1024))}function E(e,t){var r=e.getUint16(t.value,!0);return t.value+=J,r}function C(e,t){return T(E(e,t))}function L(e,t,r,i){for(var n=r.value,a=[];r.value>3,k=16,B=14,z=(1<=t.length&&t===E(e,0,t.length)}function y(e){function t(t){var r=e[t-1];return e=e.slice(i+t),i++,r}for(var r=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],i=0,n=0;n0,l="string"==typeof a.Content&&""!==a.Content;if(s||l){var c=e.parseImage(i[n]);r[a.RelativeFilename||a.Filename]=c}}}}for(var o in t){var u=t[o];void 0!==r[u]?t[o]=r[u]:t[o]=t[o].split("\\").pop()}return t},parseImage:function(e){var t,r=e.Content,i=e.RelativeFilename||e.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(n){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":if("function"!=typeof wf)return void console.warn("FBXLoader: TGALoader is required to load TGA textures");null===Loader.Handlers.get(".tga")&&Loader.Handlers.add(/\.tga$/i,new wf),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof r)return"data:"+t+";base64,"+r;var a=new Uint8Array(r);return Ds.URL.createObjectURL(new Blob([a],{type:t}))},parseTextures:function(e){var t=this,r=new Map;if("Texture"in O.Objects){var i=O.Objects.Texture;for(var n in i){var a=t.parseTexture(i[n],e);r.set(parseInt(n),a)}}return r},parseTexture:function(e,t){var r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;var i=e.WrapModeU,n=e.WrapModeV,a=void 0!==i?i.value:0,o=void 0!==n?n.value:0;if(r.wrapS=0===a?Jl:Zl,r.wrapT=0===o?Jl:Zl,"Scaling"in e){var s=e.Scaling.value;r.repeat.x=s[0],r.repeat.y=s[1]}return r},loadTexture:function(e,t){var r,i=this.textureLoader.path,n=D.get(e.id).children;void 0!==n&&n.length>0&&void 0!==t[n[0].ID]&&(r=t[n[0].ID],0!==r.indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));var a,o=e.FileName.slice(-3).toLowerCase();if("tga"===o){var s=Loader.Handlers.get(".tga");null===s?(console.warn("FBXLoader: TGALoader not found, creating empty placeholder texture for",r),a=new ve):a=s.load(r)}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating empty placeholder texture for",r),a=new ve):a=this.textureLoader.load(r);return this.textureLoader.setPath(i),a},parseMaterials:function(e){var t=this,r=new Map;if("Material"in O.Objects){var i=O.Objects.Material;for(var n in i){var a=t.parseMaterial(i[n],e);null!==a&&r.set(parseInt(n),a)}}return r},parseMaterial:function(e,t){var r=e.id,i=e.attrName,n=e.ShadingModel;if("object"==typeof n&&(n=n.value),!D.has(r))return null;var a,o=this.parseParameters(e,t,r);switch(n.toLowerCase()){case"phong":a=new Ee;break;case"lambert":a=new Me;break;default:console.warn('FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',n),a=new Ee({color:3342591})}return a.setValues(o),a.name=i,a},parseParameters:function(e,t,r){var i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new u).fromArray(e.Diffuse.value):e.DiffuseColor&&"Color"===e.DiffuseColor.type&&(i.color=(new u).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new u).fromArray(e.Emissive.value):e.EmissiveColor&&"Color"===e.EmissiveColor.type&&(i.emissive=(new u).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new u).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new u).fromArray(e.SpecularColor.value));var n=this;return D.get(r).children.forEach(function(e){var r=e.relationship;switch(r){case"Bump":i.bumpMap=n.getTexture(t,e.ID);break;case"DiffuseColor":i.map=n.getTexture(t,e.ID);break;case"DisplacementColor":i.displacementMap=n.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=n.getTexture(t,e.ID);break;case"NormalMap":i.normalMap=n.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=n.getTexture(t,e.ID),i.envMap.mapping=Xl;break;case"SpecularColor":i.specularMap=n.getTexture(t,e.ID);break;case"TransparentColor":i.alphaMap=n.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("FBXLoader: %s map is not supported in three.js, skipping texture.",r)}}),i},getTexture:function(e,t){return"LayeredTexture"in O.Objects&&t in O.Objects.LayeredTexture&&(console.warn("FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=D.get(t).children[0].ID),e.get(t)},parseDeformers:function(){var e=this,t={},r={};if("Deformer"in O.Objects){var i=O.Objects.Deformer;for(var n in i){var a=i[n],o=D.get(parseInt(n));if("Skin"===a.attrType){var s=e.parseSkeleton(o,i);s.ID=n,o.parents.length>1&&console.warn("FBXLoader: skeleton attached to more than one geometry is not supported."),s.geometryID=o.parents[0].ID,t[n]=s}else if("BlendShape"===a.attrType){var l={id:n};l.rawTargets=e.parseMorphTargets(o,i),l.id=n,o.parents.length>1&&console.warn("FBXLoader: morph target attached to more than one geometry is not supported."),r[n]=l}}}return{skeletons:t,morphTargets:r}},parseSkeleton:function(e,t){var i=[];return e.children.forEach(function(e){var n=t[e.ID];if("Cluster"===n.attrType){var a={ID:e.ID,indices:[],weights:[],transform:(new r).fromArray(n.Transform.a),transformLink:(new r).fromArray(n.TransformLink.a),linkMode:n.Mode};"Indexes"in n&&(a.indices=n.Indexes.a,a.weights=n.Weights.a),i.push(a)}}),{rawBones:i,bones:[]}},parseMorphTargets:function(e,t){for(var r=[],i=0;i1?a=o:o.length>0?a=o[0]:(a=new Ee({color:13421772}),o.push(a)),"color"in n.attributes&&o.forEach(function(e){e.vertexColors=il}),n.FBX_Deformer?(o.forEach(function(e){e.skinning=!0}),i=new Rt(n,a)):i=new k(n,a),i},createCurve:function(e,t){var r=e.children.reduce(function(e,r){return t.has(r.ID)&&(e=t.get(r.ID)),e},null),i=new R({color:3342591,linewidth:1});return new B(r,i)},setModelTransforms:function(e,t){var r={};"RotationOrder"in t&&(r.eulerOrder=parseInt(t.RotationOrder.value)),"Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value);var i=S(r);e.applyMatrix(i)},setLookAtProperties:function(e,t){if("LookAtProperty"in t){var r=D.get(e.ID).children;r.forEach(function(t){if("LookAtProperty"===t.relationship){var r=O.Objects.Model[t.ID];if("Lcl_Translation"in r){var n=r.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(n),F.add(e.target)):e.lookAt((new i).fromArray(n))}}})}},bindSkeleton:function(e,t,r){var i=this.parsePoseNodes();for(var n in e){var a=e[n],o=D.get(parseInt(a.ID)).parents;o.forEach(function(e){if(t.has(e.ID)){var n=e.ID,o=D.get(n);o.parents.forEach(function(e){if(r.has(e.ID)){var t=r.get(e.ID);t.bind(new Ft(a.bones),i[e.ID])}})}})}},parsePoseNodes:function(){var e={};if("Pose"in O.Objects){var t=O.Objects.Pose;for(var i in t)if("BindPose"===t[i].attrType){var n=t[i].PoseNode;Array.isArray(n)?n.forEach(function(t){e[t.Node]=(new r).fromArray(t.Matrix.a)}):e[n.Node]=(new r).fromArray(n.Matrix.a)}}return e},createAmbientLight:function(){if("GlobalSettings"in O&&"AmbientColor"in O.GlobalSettings){var e=O.GlobalSettings.AmbientColor.value,t=e[0],r=e[1],i=e[2];if(0!==t||0!==r||0!==i){var n=new u(t,r,i);F.add(new Ht(n,1))}}},setupMorphMaterials:function(){F.traverse(function(e){if(e.isMesh&&(e.geometry.morphAttributes.position||e.geometry.morphAttributes.normal)){var t=e.uuid,r=e.material.uuid,i=!1;F.traverse(function(e){e.isMesh&&e.material.uuid===r&&e.uuid!==t&&(i=!0)}),i===!0&&(e.material=e.material.clone()),e.material.morphTargets=!0}})}},a.prototype={constructor:a,parse:function(e){var t=this,r=new Map;if("Geometry"in O.Objects){var i=O.Objects.Geometry;for(var n in i){var a=D.get(parseInt(n)),o=t.parseGeometry(a,i[n],e);r.set(parseInt(n),o)}}return r},parseGeometry:function(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(e,t,r){var i=r.skeletons,n=r.morphTargets,a=e.parents.map(function(e){return O.Objects.Model[e.ID]});if(0!==a.length){var o=e.children.reduce(function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e},null),s=e.children.reduce(function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e},null),l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=l.RotationOrder.value),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);var u=S(c);return this.genGeometry(t,o,s,u)}},genGeometry:function(e,t,r,i){var n=new P;e.attrName&&(n.name=e.attrName);var a=this.parseGeoNode(e,t),o=this.genBuffers(a),s=new M(o.vertex,3);if(i.applyToBufferAttribute(s),n.addAttribute("position",s),o.colors.length>0&&n.addAttribute("color",new M(o.colors,3)),t&&(n.addAttribute("skinIndex",new _(o.weightsIndices,4)),n.addAttribute("skinWeight",new M(o.vertexWeights,4)),n.FBX_Deformer=t),o.normal.length>0){var c=new M(o.normal,3),u=(new l).getNormalMatrix(i);u.applyToBufferAttribute(c),n.addAttribute("normal",c)}if(o.uvs.forEach(function(e,t){var r="uv"+(t+1).toString();0===t&&(r="uv"),n.addAttribute(r,new M(o.uvs[t],2))}),a.material&&"AllSame"!==a.material.mappingType){var h=o.materialIndex[0],d=0;if(o.materialIndex.forEach(function(e,t){e!==h&&(n.addGroup(d,t-d,h),h=e,d=t)}),n.groups.length>0){var p=n.groups[n.groups.length-1],f=p.start+p.count;f!==o.materialIndex.length&&n.addGroup(f,o.materialIndex.length-f,h)}0===n.groups.length&&n.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(n,e,r,i),n},parseGeoNode:function(e,t){var r=this,i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];for(var n=0;e.LayerElementUV[n];)i.uv.push(r.parseUVs(e.LayerElementUV[n])),n++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,n){void 0===i.weightTable[r]&&(i.weightTable[r]=[]),i.weightTable[r].push({id:t,weight:e.weights[n]})})})),i},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},r=0,i=0,n=!1,a=[],o=[],s=[],l=[],c=[],u=[],h=this;return e.vertexIndices.forEach(function(d,p){var f=!1;d<0&&(d^=-1,f=!0);var m=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){var g=w(p,r,d,e.color);s.push(g[0],g[1],g[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach(function(e){v.push(e.weight),m.push(e.id)}),v.length>4){n||(console.warn("FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),n=!0);var y=[0,0,0,0],x=[0,0,0,0];v.forEach(function(e,t){var r=e,i=m[t];x.forEach(function(e,t,n){if(r>e){n[t]=r,r=e;var a=y[t];y[t]=i,i=a}})}),m=y,v=x}for(;v.length<4;)v.push(0),m.push(0);for(var b=0;b<4;++b)c.push(v[b]),u.push(m[b])}if(e.normal){var g=w(p,r,d,e.normal);o.push(g[0],g[1],g[2])}if(e.material&&"AllSame"!==e.material.mappingType)var _=w(p,r,d,e.material)[0];e.uv&&e.uv.forEach(function(e,t){var i=w(p,r,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])}),i++,f&&(h.genFace(t,e,a,_,o,s,l,c,u,i),r++,i=0,a=[],o=[],s=[],l=[],c=[],u=[])}),t},genFace:function(e,t,r,i,n,a,o,s,l,c){for(var u=2;u1&&console.warn("FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var a=e.get(n[0].ID);r[i]={name:t[i].attrName,layer:a}}return r},addClip:function(e){var t=[],r=this;return e.layer.forEach(function(e){t=t.concat(r.generateTracks(e))}),new re(e.name,(-1),t)},generateTracks:function(e){var t=[],r=new i,a=new n,s=new i;if(e.transform&&e.transform.decompose(r,a,s),r=r.toArray(),a=(new o).setFromQuaternion(a).toArray(),s=s.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var l=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");void 0!==l&&t.push(l)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var c=this.generateRotationTrack(e.modelName,e.R.curves,a,e.preRotations,e.postRotations);void 0!==c&&t.push(c)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var u=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");void 0!==u&&t.push(u)}if(void 0!==e.DeformPercent){var h=this.generateMorphTrack(e);void 0!==h&&t.push(h)}return t},generateVectorTrack:function(e,t,r,i){var n=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(n,t,r);return new te(e+"."+i,n,a)},generateRotationTrack:function(e,t,r,i,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Fs.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Fs.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Fs.degToRad));var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,r);void 0!==i&&(i=i.map(Fs.degToRad),i.push("ZYX"),i=(new o).fromArray(i),i=(new n).setFromEuler(i)),void 0!==a&&(a=a.map(Fs.degToRad),a.push("ZYX"),a=(new o).fromArray(a),a=(new n).setFromEuler(a).inverse());for(var c=new n,u=new o,h=[],d=0;d=180){for(var a=n/180,o=i/a,s=r+o,l=e.times[t-1],c=e.times[t]-l,u=c/a,h=l+u,d=[],p=[];h1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r,type:i}},parseNodeProperty:function(e,t,r){var i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),n=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===n&&(n=r.replace(/"/g,"").replace(/,$/,"").trim());var a=this.getCurrentNode(),o=a.name;if("Properties70"===o)return void this.parseNodeSpecialProperty(e,i,n);if("C"===i){var s=n.split(",").slice(1),l=parseInt(s[0]),c=parseInt(s[1]),u=n.split(",").slice(3);u=u.map(function(e){return e.trim().replace(/^"/,"")}),i="connections",n=[l,c],C(n,u),void 0===a[i]&&(a[i]=[])}"Node"===i&&(a.id=n),i in a&&Array.isArray(a[i])?a[i].push(n):"a"!==i?a[i]=n:a.a=n,this.setCurrentProp(a,i),"a"===i&&","!==n.slice(-1)&&(a.a=T(n))},parseNodePropertyContinued:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=T(t.a))},parseNodeSpecialProperty:function(e,t,r){var i=r.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),n=i[0],a=i[1],o=i[2],s=i[3],l=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=T(l)}this.getPrevNode()[n]={type:a,type2:o,flag:s,value:l},this.setCurrentProp(this.getPrevNode(),n)}},d.prototype={constructor:d,parse:function(e){var t=this,r=new p(e);r.skip(23);var i=r.getUint32();console.log("FBXLoader: FBX binary version: "+i);for(var n=new f;!this.endOfContent(r);){var a=t.parseNode(r,i);null!==a&&n.add(a.name,a)}return n},endOfContent:function(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var r=this,i={},n=t>=7500?e.getUint64():e.getUint32(),a=t>=7500?e.getUint64():e.getUint32(),o=(t>=7500?e.getUint64():e.getUint32(),e.getUint8()),s=e.getString(o);if(0===n)return null;for(var l=[],c=0;c0?l[0]:"",h=l.length>1?l[1]:"",d=l.length>2?l[2]:"";for(i.singleProperty=1===a&&e.getOffset()===n;n>e.getOffset();){var p=r.parseNode(e,t);null!==p&&r.parseSubNode(s,i,p)}return i.propertyList=l,"number"==typeof u&&(i.id=u),""!==h&&(i.attrName=h),""!==d&&(i.attrType=d),""!==s&&(i.name=s),i},parseSubNode:function(e,t,r){if(r.singleProperty===!0){var i=r.propertyList[0];Array.isArray(i)?(t[r.name]=r,r.a=i):t[r.name]=i}else if("Connections"===e&&"C"===r.name){var n=[];r.propertyList.forEach(function(e,t){0!==t&&n.push(e)}),void 0===t.connections&&(t.connections=[]),t.connections.push(n)}else if("Properties70"===r.name){var a=Object.keys(r);a.forEach(function(e){t[e]=r[e]})}else if("Properties70"===e&&"P"===r.name){var o,s=r.propertyList[0],l=r.propertyList[1],c=r.propertyList[2],u=r.propertyList[3];0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),0===l.indexOf("Lcl ")&&(l=l.replace("Lcl ","Lcl_")),o="Color"===l||"ColorRGB"===l||"Vector"===l||"Vector3D"===l||0===l.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[s]={type:l,type2:c,flag:u,value:o}}else void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)},parseProperty:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":var r=e.getUint32();return e.getArrayBuffer(r);case"S":var r=e.getUint32();return e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var i=e.getUint32(),n=e.getUint32(),a=e.getUint32();if(0===n)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}"undefined"==typeof Zlib&&console.error("FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js");var o=new Zlib.Inflate(new Uint8Array(e.getArrayBuffer(a))),s=new p(o.decompress().buffer);switch(t){case"b":case"c":return s.getBooleanArray(i);case"d":return s.getFloat64Array(i);case"f":return s.getFloat32Array(i);case"i":return s.getInt32Array(i);case"l":return s.getInt64Array(i)}default:throw new Error("FBXLoader: Unknown property type "+t)}}},p.prototype={constructor:p,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1===(1&this.getUint8())},getBooleanArray:function(e){for(var t=this,r=[],i=0;i=0&&(r=r.slice(0,n)),Ru.decodeText(new Uint8Array(r))}},f.prototype={constructor:f,add:function(e,t){this[e]=t}};var I=[],U=new r,z=new o,j=new i,V=new i,G=new r;return e}(),Lf=function(e){this.manager=void 0!==e?e:Du,this.splitLayer=!1};Lf.prototype.load=function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(e))},r,i)},Lf.prototype.parse=function(e){function t(e){c={vertex:[],pathVertex:[],z:e.z},l.push(c)}function r(e,r){void 0===c&&t(e),g.extruding?(c.vertex.push(e.x,e.y,e.z),c.vertex.push(r.x,r.y,r.z)):(c.pathVertex.push(e.x,e.y,e.z),c.pathVertex.push(r.x,r.y,r.z))}function i(e,t){return s.relative?t:t-e}function n(e,t){return s.relative?e+t:t}function a(e,t){var r=new P;r.addAttribute("position",new M(e,3));var i=new Yt(r,t?h:u);i.name="layer"+p,y.add(i)}var s={x:0,y:0,z:0,e:0,f:0,extruding:!1,relative:!1},l=[],c=void 0,u=new R({color:16711680});u.name="path";var h=new R({color:65280});h.name="extruded";for(var d=e.replace(/;.+/g,"").split("\n"),p=0;p0&&(g.extruding=i(s.e,g.e)>0,void 0!=c&&g.z==c.z||t(g)),r(s,g),s=g}else if("G2"===m||"G3"===m)console.warn("GCodeLoader: Arc command not supported");else if("G90"===m)s.relative=!1;else if("G91"===m)s.relative=!0;else if("G92"===m){var g=s;g.x=void 0!==v.x?v.x:g.x,g.y=void 0!==v.y?v.y:g.y,g.z=void 0!==v.z?v.z:g.z,g.e=void 0!==v.e?v.e:g.e,s=g}else console.warn("GCodeLoader: Command not supported:"+m)}var y=new Dt;if(y.name="gcode",this.splitLayer)for(var p=0;p",o).replace("#include ",s).replace("#include ",l).replace("#include ",c).replace("#include ",h);delete a.roughness,delete a.metalness,delete a.roughnessMap,delete a.metalnessMap,a.specular={value:(new u).setHex(1118481)},a.glossiness={value:.5},a.specularMap={value:null},a.glossinessMap={value:null},e.vertexShader=n.vertexShader,e.fragmentShader=d,e.uniforms=a,e.defines={STANDARD:""},e.color=new u(1,1,1),e.opacity=1;var p=[];if(Array.isArray(i.diffuseFactor)){var f=i.diffuseFactor;e.color.fromArray(f),e.opacity=f[3]}if(void 0!==i.diffuseTexture&&p.push(r.assignTexture(e,"map",i.diffuseTexture.index)),e.emissive=new u(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new u(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var m=i.specularGlossinessTexture.index;p.push(r.assignTexture(e,"glossinessMap",m)),p.push(r.assignTexture(e,"specularMap",m))}return Promise.all(p)},createMaterial:function(e){var t=new pe({defines:e.defines,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms,fog:!0,lights:!0,opacity:e.opacity,transparent:e.transparent});return t.isGLTFSpecularGlossinessMaterial=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t.extensions.derivatives=!0,t},cloneMaterial:function(e){var t=e.clone();t.isGLTFSpecularGlossinessMaterial=!0;for(var r=this.specularGlossinessParams,i=0,n=r.length;i=2&&(i[n+1]=e.getY(n)),r>=3&&(i[n+2]=e.getZ(n)),r>=4&&(i[n+3]=e.getW(n));return new g(i,r,e.normalized)}return e.clone()}function E(e){if(e.length<2)return!1;var t=e[0],r=t.targets||[];if(void 0===t.indices)return!1;for(var i=1,n=e.length;i=2.0 are supported. Use LegacyGLTFLoader instead.")));if(v.extensionsUsed)for(var g=0;g=0&&console.warn('GLTFLoader: Unknown extension "'+y+'".')}}var b=new C(v,d,{path:t||this.path||"",crossOrigin:this.crossOrigin,manager:this.manager});b.parse(function(e,t,i,n,a){var o={scene:e,scenes:t,cameras:i,animations:n,asset:a.asset,parser:b,userData:{}};m(d,o,a),r(o)},c)}};var N={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};a.prototype.getMaterialType=function(e){return F},a.prototype.extendParams=function(e,t,r){var i=[];e.color=new u(1,1,1),e.opacity=1;var n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){var a=n.baseColorFactor;e.color.fromArray(a),e.opacity=a[3]}void 0!==n.baseColorTexture&&i.push(r.assignTexture(e,"map",n.baseColorTexture.index))}return Promise.all(i)};var O="glTF",I=12,U={JSON:1313821514,BIN:5130562};s.prototype.decodePrimitive=function(e,t){var r=this.json,i=this.dracoLoader,n=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var c in a)c in Y&&(o[Y[c]]=a[c]);for(c in e.attributes)if(void 0!==Y[c]&&void 0!==a[c]){var u=r.accessors[e.attributes[c]],h=V[u.componentType];l[Y[c]]=h,s[Y[c]]=u.normalized===!0}return t.getDependency("bufferView",n).then(function(e){return new Promise(function(t){i.decodeDracoFile(e,function(e){for(var r in e.attributes){var i=e.attributes[r],n=s[r];void 0!==n&&(i.normalized=n)}t(e)},o,l)})})},h.prototype=Object.create(j.prototype),h.prototype.constructor=h,h.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i*3+i,a=0;a!==i;a++)t[a]=r[n+a];return t},h.prototype.beforeStart_=h.prototype.copySampleValue_,h.prototype.afterEnd_=h.prototype.copySampleValue_,h.prototype.interpolate_=function(e,t,r,i){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,c=i-t,u=(r-t)/c,h=u*u,d=h*u,p=e*l,f=p-l,m=2*d-3*h+1,v=d-2*h+u,g=-2*d+3*h,y=d-h,x=0;x!==o;x++){var b=a[f+x+o],w=a[f+x+s]*c,_=a[p+x+o],S=a[p+x]*c;n[x]=m*b+v*w+g*_+y*S}return n};var z={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},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},G={9728:$l,9729:rc,9984:ec,9985:ic,9986:tc,9987:nc},X={33071:Zl,33648:Kl,10497:Jl},H={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Y={POSITION:"position",NORMAL:"normal",TEXCOORD_0:"uv",TEXCOORD0:"uv",TEXCOORD:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",COLOR0:"color",COLOR:"color",WEIGHTS_0:"skinWeight",WEIGHT:"skinWeight",JOINTS_0:"skinIndex",JOINT:"skinIndex"},q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Q={CUBICSPLINE:$c,LINEAR:Kc,STEP:Zc},J={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},K={"image/png":xc,"image/jpeg":yc};return C.prototype.parse=function(e,t){var r=this.json;this.cache.removeAll(),this.markDefs(),this.getMultiDependencies(["scene","animation","camera"]).then(function(t){var i=t.scenes||[],n=i[r.scene||0],a=t.animations||[],o=t.cameras||[];e(n,i,o,a,r)})["catch"](t)},C.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],i={},n={},a=0,o=t.length;a=2&&a.setY(M,_[S*s+1]),s>=3&&a.setZ(M,_[S*s+2]),s>=4&&a.setW(M,_[S*s+3]),s>=5)throw new Error("GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a})},C.prototype.loadTexture=function(e){var t,r=this,i=this.json,n=this.options,a=this.textureLoader,o=Ds.URL||Ds.webkitURL,s=i.textures[e],l=s.extensions||{};t=l[N.MSFT_TEXTURE_DDS]?i.images[l[N.MSFT_TEXTURE_DDS].source]:i.images[s.source];var c=t.uri,u=!1;return void 0!==t.bufferView&&(c=r.getDependency("bufferView",t.bufferView).then(function(e){u=!0;var r=new Blob([e],{type:t.mimeType});return c=o.createObjectURL(r)})),Promise.resolve(c).then(function(e){var t=ke.Handlers.get(e);return t||(t=l[N.MSFT_TEXTURE_DDS]?r.extensions[N.MSFT_TEXTURE_DDS].ddsLoader:a),new Promise(function(r,i){t.load(d(e,n.path),r,void 0,i)})}).then(function(e){u===!0&&o.revokeObjectURL(c),e.flipY=!1,void 0!==s.name&&(e.name=s.name),t.mimeType in K&&(e.format=K[t.mimeType]);var r=i.samplers||{},n=r[s.sampler]||{};return e.magFilter=G[n.magFilter]||rc,e.minFilter=G[n.minFilter]||nc,e.wrapS=X[n.wrapS]||Jl,e.wrapT=X[n.wrapT]||Jl,e})},C.prototype.assignTexture=function(e,t,r){return this.getDependency("texture",r).then(function(r){e[t]=r})},C.prototype.loadMaterial=function(e){var t,r=this,i=this.json,n=this.extensions,a=i.materials[e],o={},s=a.extensions||{},l=[];if(s[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var c=n[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=c.getMaterialType(a),l.push(c.extendParams(o,a,r))}else if(s[N.KHR_MATERIALS_UNLIT]){var h=n[N.KHR_MATERIALS_UNLIT];t=h.getMaterialType(a),l.push(h.extendParams(o,a,r))}else{t=Ce;var d=a.pbrMetallicRoughness||{};if(o.color=new u(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){var p=d.baseColorFactor;o.color.fromArray(p),o.opacity=p[3]}if(void 0!==d.baseColorTexture&&l.push(r.assignTexture(o,"map",d.baseColorTexture.index)),o.metalness=void 0!==d.metallicFactor?d.metallicFactor:1,o.roughness=void 0!==d.roughnessFactor?d.roughnessFactor:1,void 0!==d.metallicRoughnessTexture){var g=d.metallicRoughnessTexture.index;l.push(r.assignTexture(o,"metalnessMap",g)),l.push(r.assignTexture(o,"roughnessMap",g))}}a.doubleSided===!0&&(o.side=Ks);var y=a.alphaMode||J.OPAQUE;return y===J.BLEND?o.transparent=!0:(o.transparent=!1,y===J.MASK&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==F&&(l.push(r.assignTexture(o,"normalMap",a.normalTexture.index)),o.normalScale=new f(1,1),void 0!==a.normalTexture.scale&&o.normalScale.set(a.normalTexture.scale,a.normalTexture.scale)),void 0!==a.occlusionTexture&&t!==F&&(l.push(r.assignTexture(o,"aoMap",a.occlusionTexture.index)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==F&&(o.emissive=(new u).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==F&&l.push(r.assignTexture(o,"emissiveMap",a.emissiveTexture.index)),Promise.all(l).then(function(){var e;return e=t===pe?n[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new t(o),void 0!==a.name&&(e.name=a.name),e.normalScale&&(e.normalScale.y=-e.normalScale.y),e.map&&(e.map.encoding=su),e.emissiveMap&&(e.emissiveMap.encoding=su),e.specularMap&&(e.specularMap.encoding=su),v(e,a),a.extensions&&m(n,e,a),e})},C.prototype.loadGeometries=function(e){var t,r=this,i=this.extensions,n=this.primitiveCache,a=E(e);return a&&(t=e,e=[e[0]]),this.getDependencies("accessor").then(function(o){for(var s=[],l=0,c=e.length;l1&&void 0!==Pf){for(var p=1,f=e.length;p0,l=[],c=0,u=r.length;c0&&x(h,n),h.name=n.name||"mesh_"+e,r.length>1&&(h.name+="_"+c),v(h,n),l.push(h);for(var m=s?h.material:[h.material],y=void 0!==d.attributes.color,b=void 0===d.attributes.normal,w=h.isSkinnedMesh===!0,_=Object.keys(d.morphAttributes).length>0,S=_&&void 0!==d.morphAttributes.normal,A=0,M=m.length;A1){var l=a[o.mesh]++;t=s.clone(),t.name+="_instance_"+l,t.onBeforeRender=s.onBeforeRender;for(var u=0,h=t.children.length;u(n=l.indexOf(u))&&a=e.byteLength||!(t=h(e)))return o(r,"no header found");if(!(i=t.match(a)))return o(n,"bad initial token");for(m.valid|=s,m.programtype=i[1],m.string+=t+"\n";;){if(t=h(e),!1===t)break;if(m.string+=t+"\n","#"!==t.charAt(0)){if((i=t.match(u))&&(m.gamma=parseFloat(i[1],10)),(i=t.match(d))&&(m.exposure=parseFloat(i[1],10)),(i=t.match(p))&&(m.valid|=l,m.format=i[1]),(i=t.match(f))&&(m.valid|=c,m.height=parseInt(i[1],10),m.width=parseInt(i[2],10)),m.valid&l&&m.valid&c)break}else m.comments+=t+"\n"}return m.valid&l?m.valid&c?m:o(n,"missing image size specifier"):o(n,"missing format specifier")},p=function(e,t,i){var s,l,c,u,h,d,p,f,m,v,g,y,x,b=t,w=i;if(b<8||b>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(b!==(e[2]<<8|e[3]))return o(n,"wrong scanline width");if(s=new Uint8Array(4*t*i),!s||!s.length)return o(a,"unable to allocate buffer space");for(l=0,c=0,f=4*b,x=new Uint8Array(4),d=new Uint8Array(f);w>0&&ce.byteLength)return o(r);if(x[0]=e[c++],x[1]=e[c++],x[2]=e[c++],x[3]=e[c++],2!=x[0]||2!=x[1]||(x[2]<<8|x[3])!=b)return o(n,"bad rgbe scanline format");for(p=0;p128,y&&(u-=128),0===u||p+u>f)return o(n,"bad scanline data");if(y)for(h=e[c++],m=0;m>16&32768,a=i>>12&2047,o=i>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&i):o<113?(a|=2048,n|=(a>>114-o)+(a>>113-o&1)):(n|=o-112<<10|a>>1,n+=1&a)}var t=new Float32Array(1),r=new Int32Array(t.buffer);return function(t,r,i,n){var a=t[r+3],o=Math.pow(2,a-128)/255;i[n+0]=e(t[r+0]*o),i[n+1]=e(t[r+1]*o),i[n+2]=e(t[r+2]*o)}}(),l=new $t;l.type=e,l.encoding=e===ac?cu:ou,l.format=e===ac?xc:yc,l.minFilter=l.encoding===cu?$l:rc,l.magFilter=l.encoding===cu?$l:rc,l.generateMipmaps=l.encoding!==cu,l.anisotropy=0;for(var c=this.hdrLoader,u=0,h=0;h>8&65280|e>>24&255},e.prototype.mipmaps=function(t){for(var r=this,i=[],n=e.HEADER_LEN+this.bytesOfKeyValueData,a=this.pixelWidth,o=this.pixelHeight,s=t?this.numberOfMipmapLevels:1,l=0;l0){var S=[];for(var w in v)f=v[w],S[w]=f.name;_="Adding mesh(es) ("+S.length+": "+S+") from input mesh: "+i,_+=" ("+(100*e.progress.numericalValue).toFixed(2)+"%)"}else _="Not adding mesh: "+i,_+=" ("+(100*e.progress.numericalValue).toFixed(2)+"%)";var A=this.callbacks.onProgress;if(r.isValid(A)){var M=new CustomEvent("MeshBuilderEvent",{detail:{type:"progress",modelName:e.params.meshName,text:_,numericalValue:e.progress.numericalValue}});A(M)}return v},e.prototype.updateMaterials=function(e){var t,i,n=this,a=e.materials.materialCloneInstructions;if(r.isValid(a)){var o=a.materialNameOrg,s=this.materials[o];if(r.isValid(o)){t=s.clone(),i=a.materialName,t.name=i;var l=a.materialProperties;for(var c in l)t.hasOwnProperty(c)&&l.hasOwnProperty(c)&&(t[c]=l[c]);this.materials[i]=t}else console.warn('Requested material "'+o+'" is not available!')}var u=e.materials.serializedMaterials;if(r.isValid(u)&&Object.keys(u).length>0){var h,d=new Re;for(i in u)h=u[i],r.isValid(h)&&(t=d.parse(h),n.logging.enabled&&console.info('De-serialized material with name "'+i+'" will be added.'),n.materials[i]=t)}if(u=e.materials.runtimeMaterials,r.isValid(u)&&Object.keys(u).length>0)for(i in u)t=u[i],n.logging.enabled&&console.info('Material with name "'+i+'" will be added.'),n.materials[i]=t},e.prototype.getMaterialsJSON=function(){var e,t=this,r={};for(var i in t.materials)e=t.materials[i],r[i]=e.toJSON();return r},e.prototype.getMaterials=function(){return this.materials},e}(),kf.WorkerRunnerRefImpl=function(){function e(){var e=this,t=function(t){e.processMessage(t.data)};self.addEventListener("message",t,!1)}return e.prototype.applyProperties=function(e,t){var r,i,n;for(r in t)i="set"+r.substring(0,1).toLocaleUpperCase()+r.substring(1),n=t[r],"function"==typeof e[i]?e[i](n):e.hasOwnProperty(r)&&(e[r]=n)},e.prototype.processMessage=function(e){if("run"===e.cmd){var t={callbackMeshBuilder:function(e){self.postMessage(e)},callbackProgress:function(t){e.logging.enabled&&e.logging.debug&&console.debug("WorkerRunner: progress: "+t)}},r=new Parser;"function"==typeof r.setLogging&&r.setLogging(e.logging.enabled,e.logging.debug),this.applyProperties(r,e.params),this.applyProperties(r,e.materials),this.applyProperties(r,t),r.workerScope=self,r.parse(e.data.input,e.data.options),e.logging.enabled&&console.log("WorkerRunner: Run complete!"),t.callbackMeshBuilder({cmd:"complete",msg:"WorkerRunner completed run."})}else console.error("WorkerRunner: Received unknown command: "+e.cmd)},e}(),kf.WorkerSupport=function(){function e(){if(console.info("Using LoaderSupport.WorkerSupport version: "+t),this.logging={enabled:!0,debug:!1},void 0===Ds.Worker)throw"This browser does not support web workers!";if(void 0===Ds.Blob)throw"This browser does not support Blob!";if("function"!=typeof Ds.URL.createObjectURL)throw"This browser does not support Object creation from URL!";this.loaderWorker=new i}var t="2.2.1",r=kf.Validator,i=function(){function e(){this._reset()}return e.prototype._reset=function(){this.logging={enabled:!0,debug:!1},this.worker=null,this.runnerImplName=null,this.callbacks={meshBuilder:null,onLoad:null},this.terminateRequested=!1,this.queuedMessage=null,this.started=!1,this.forceCopy=!1},e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.setForceCopy=function(e){this.forceCopy=e===!0},e.prototype.initWorker=function(e,t){this.runnerImplName=t;var r=new Blob([e],{type:"application/javascript"});this.worker=new Worker(Ds.URL.createObjectURL(r)),this.worker.onmessage=this._receiveWorkerMessage,this.worker.runtimeRef=this,this._postMessage()},e.prototype._receiveWorkerMessage=function(e){var t=e.data;switch(t.cmd){case"meshData":case"materialData":case"imageData":this.runtimeRef.callbacks.meshBuilder(t);break;case"complete":this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(t.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logging.enabled&&console.info("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run is complete. Terminating application on request!"),this.runtimeRef._terminate());break;case"error":console.error("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Reported error: "+t.msg),this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(t.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logging.enabled&&console.info("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run reported error. Terminating application on request!"),this.runtimeRef._terminate());break;default:console.error("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Received unknown command: "+t.cmd)}},e.prototype.setCallbacks=function(e,t){this.callbacks.meshBuilder=r.verifyInput(e,this.callbacks.meshBuilder),this.callbacks.onLoad=r.verifyInput(t,this.callbacks.onLoad)},e.prototype.run=function(e){if(r.isValid(this.queuedMessage))return void console.warn("Already processing message. Rejecting new run instruction");if(this.queuedMessage=e,this.started=!0,!r.isValid(this.callbacks.meshBuilder))throw'Unable to run as no "MeshBuilder" callback is set.';if(!r.isValid(this.callbacks.onLoad))throw'Unable to run as no "onLoad" callback is set.';"run"!==e.cmd&&(e.cmd="run"),r.isValid(e.logging)?(e.logging.enabled=e.logging.enabled===!0,e.logging.debug=e.logging.debug===!0):e.logging={enabled:!0,debug:!1},this._postMessage()},e.prototype._postMessage=function(){if(r.isValid(this.queuedMessage)&&r.isValid(this.worker))if(this.queuedMessage.data.input instanceof ArrayBuffer){var e;e=this.forceCopy?this.queuedMessage.data.input.slice(0):this.queuedMessage.data.input,this.worker.postMessage(this.queuedMessage,[e])}else this.worker.postMessage(this.queuedMessage)},e.prototype.setTerminateRequested=function(e){this.terminateRequested=e===!0,this.terminateRequested&&r.isValid(this.worker)&&!r.isValid(this.queuedMessage)&&this.started&&(this.logging.enabled&&console.info("Worker is terminated immediately as it is not running!"),this._terminate())},e.prototype._terminate=function(){this.worker.terminate(),this._reset()},e}();e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0,this.loaderWorker.setLogging(this.logging.enabled,this.logging.debug)},e.prototype.setForceWorkerDataCopy=function(e){this.loaderWorker.setForceCopy(e)},e.prototype.validate=function(e,t,i,o,s){if(!r.isValid(this.loaderWorker.worker)){this.logging.enabled&&(console.info("WorkerSupport: Building worker code..."),console.time("buildWebWorkerCode")),r.isValid(s)?this.logging.enabled&&console.info('WorkerSupport: Using "'+s.name+'" as Runner class for worker.'):(s=kf.WorkerRunnerRefImpl,this.logging.enabled&&console.info('WorkerSupport: Using DEFAULT "LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.'));var l=e(n,a);l+="var Parser = "+t+";\n\n",l+=a(s.name,s),l+="new "+s.name+"();\n\n";var c=this;if(r.isValid(i)&&i.length>0){var u="",h=function(e,t){if(0===t.length)c.loaderWorker.initWorker(u+l,s.name),c.logging.enabled&&console.timeEnd("buildWebWorkerCode");else{var r=function(r){u+=r,h(e,t)},i=new we;i.setPath(e),i.setResponseType("text"),i.load(t[0],r),t.shift()}};h(o,i)}else this.loaderWorker.initWorker(l,s.name),this.logging.enabled&&console.timeEnd("buildWebWorkerCode")}},e.prototype.setCallbacks=function(e,t){this.loaderWorker.setCallbacks(e,t)},e.prototype.run=function(e){this.loaderWorker.run(e)},e.prototype.setTerminateRequested=function(e){this.loaderWorker.setTerminateRequested(e)};var n=function(e,t){var r,i=e+" = {\n";for(var n in t)r=t[n],"string"==typeof r||r instanceof String?(r=r.replace("\n","\\n"),r=r.replace("\r","\\r"),i+="\t"+n+': "'+r+'",\n'):r instanceof Array?i+="\t"+n+": ["+r+"],\n":Number.isInteger(r)?i+="\t"+n+": "+r+",\n":"function"==typeof r&&(i+="\t"+n+": "+r+",\n");return i+="}\n\n"},a=function(e,t,i,n,a){var o,s,l,c="",u=r.isValid(i)?i:t.name;a=r.verifyInput(a,[]);for(var h in t.prototype)s=t.prototype[h],"constructor"===h?(o=s.toString(),o=o.replace("function",""),l="\tfunction "+u+o+";\n\n"):"function"==typeof s&&a.indexOf(h)<0&&(o=s.toString(),c+="\t"+u+".prototype."+h+" = "+o+";\n\n");c+="\treturn "+u+";\n",c+="})();\n\n";var d="";return r.isValid(n)&&(d+="\n",d+=u+".prototype = Object.create( "+n+".prototype );\n",d+=u+".constructor = "+u+";\n",d+="\n"),r.isValid(l)?c=e+" = (function () {\n\n"+d+l+c:(l=e+" = (function () {\n\n",l+=d+"\t"+t.prototype.constructor.toString()+"\n\n",c=l+c),c};return e}(),kf.WorkerDirector=function(){function e(e){if(console.info("Using LoaderSupport.WorkerDirector version: "+t),this.logging={enabled:!0,debug:!1},this.maxQueueSize=n,this.maxWebWorkers=i,this.crossOrigin=null,!r.isValid(e))throw"Provided invalid classDef: "+e;this.workerDescription={classDef:e,globalCallbacks:{},workerSupports:{},forceWorkerDataCopy:!0},this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0,this.callbackOnFinishedProcessing=null}var t="2.2.2",r=kf.Validator,i=16,n=8192;return e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.getMaxQueueSize=function(){return this.maxQueueSize},e.prototype.getMaxWebWorkers=function(){return this.maxWebWorkers},e.prototype.setCrossOrigin=function(e){this.crossOrigin=e},e.prototype.setForceWorkerDataCopy=function(e){this.workerDescription.forceWorkerDataCopy=e===!0},e.prototype.prepareWorkers=function(e,t,a){var o=this;r.isValid(e)&&(this.workerDescription.globalCallbacks=e),this.maxQueueSize=Math.min(t,n),this.maxWebWorkers=Math.min(a,i),this.maxWebWorkers=Math.min(this.maxWebWorkers,this.maxQueueSize),this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0;for(var s=0;s0&&this.instructionQueuePointer0},e.prototype.processQueue=function(){var e,t,r=this;for(var i in r.workerDescription.workerSupports)t=r.workerDescription.workerSupports[i],t.inUse||(r.instructionQueuePointer0){for(var E=[],x=0,V=p.length;x0){for(var C=[],x=0,V=p.length;x=w?b.skinIndices[w]:0);for(var w=0;w<4;w++)u.push(b.skinWeights.length-1>=w?b.skinWeights[w]:0)}for(var x=0;x=0&&(F.limitation=new i(1,0,0)),D.links.push(F)}p.push(D)}else for(var x=0;x0,h.morphTargets=t.morphTargets.length>0,h.lights=!0,h.fog=!0,h.blending=cl,h.blendSrc=xl,h.blendDst=bl,h.blendSrcAlpha=xl,h.blendDstAlpha=wl,"pmx"===e.metadata.format&&1===(1&c.flag)?h.side=Ks:h.side=1===h.opacity?Js:Ks,"pmd"===e.metadata.format){if(c.fileName){var d=c.fileName,p=d.split("*");if(h.map=a._loadTexture(p[0],s),p.length>1){var f=p[1].slice(-4).toLowerCase();h.envMap=a._loadTexture(p[1],s,{sphericalReflectionMapping:!0}),h.combine=".sph"===f?Fl:Il}}var m=c.toonIndex===-1?"toon00.bmp":e.toonTextures[c.toonIndex].fileName;h.gradientMap=a._loadTexture(m,s,{isToonTexture:!0,isDefaultToonTexture:a._isDefaultToonTexture(m)}),h.userData.outlineParameters={thickness:1===c.edgeFlag?.003:0,color:[0,0,0],alpha:1,visible:1===c.edgeFlag}}else{c.textureIndex!==-1&&(h.map=a._loadTexture(e.textures[c.textureIndex],s)),c.envTextureIndex===-1||1!==c.envFlag&&2!=c.envFlag||(h.envMap=a._loadTexture(e.textures[c.envTextureIndex],s,{sphericalReflectionMapping:!0}),h.combine=1===c.envFlag?Fl:Il);var m,v;c.toonIndex===-1||0!==c.toonFlag?(m="toon"+("0"+(c.toonIndex+1)).slice(-2)+".bmp",v=!0):(m=e.textures[c.toonIndex],v=!1),h.gradientMap=a._loadTexture(m,s,{isToonTexture:!0,isDefaultToonTexture:v}),h.userData.outlineParameters={thickness:c.edgeSize/300,color:c.edgeColor.slice(0,3),alpha:c.edgeColor[3],visible:0!==(16&c.flag)&&c.edgeSize>0}}void 0!==h.map&&(h.transparent||a._checkImageTransparency(h.map,t,l),h.emissive.multiplyScalar(.2)),o.push(new Pe(h))}if("pmx"===e.metadata.format)for(var l=0,g=e.morphs.length;l2){r=r.slice(),i=i.slice(),n=n.slice();for(var a=i.length/r.length,o=n.length/r.length,s=1,c=2,u=r.length;cs){r[s]=r[c];for(var h=0;h=0?o.substring(0,s):o;l=l.toLowerCase();var c=s>=0?o.substring(s+1):"";if(c=c.trim(),"newmtl"===l)r={name:c},n[c]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var u=c.split(i,3);r[l]=[parseFloat(u[0]),parseFloat(u[1]),parseFloat(u[2])]}else r[l]=c}}var h=new jf.MaterialCreator(this.texturePath||this.path,this.materialOptions);return h.setCrossOrigin(this.crossOrigin),h.setManager(this.manager),h.setMaterials(n),h}},jf.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:Js,this.wrap=this.options&&this.options.wrap?this.options.wrap:Jl},jf.MaterialCreator.prototype={constructor:jf.MaterialCreator,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){var t=this;if(!this.options)return e;var r={};for(var i in e){var n=e[i],a={};r[i]=a;for(var o in n){var s=!0,l=n[o],c=o.toLowerCase();switch(c){case"kd":case"ka":case"ks":t.options&&t.options.normalizeRGB&&(l=[l[0]/255,l[1]/255,l[2]/255]),t.options&&t.options.ignoreZeroRGBs&&0===l[0]&&0===l[1]&&0===l[2]&&(s=!1)}s&&(a[c]=l)}}return r},preload:function(){var e=this;for(var t in e.materialsInfo)e.create(t)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=this,t=0;for(var r in e.materialsInfo)e.materialsArray[t]=e.create(r),e.nameLookup[r]=t,t++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!o[e]){var i=n.getTextureParams(r,o),a=n.loadTexture(t(n.baseUrl,i.url));a.repeat.copy(i.scale),a.offset.copy(i.offset),a.wrapS=n.wrap,a.wrapT=n.wrap,o[e]=a}}var i=this,n=this,a=this.materialsInfo[e],o={name:e,side:this.side};for(var s in a){var l,c=a[s];if(""!==c)switch(s.toLowerCase()){case"kd":o.color=(new u).fromArray(c);break;case"ks":o.specular=(new u).fromArray(c);break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"ns":o.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(o.opacity=l,o.transparent=!0);break;case"tr":l=parseFloat(c),i.options&&i.options.invertTrProperty&&(l=1-l),l>0&&(o.opacity=1-l,o.transparent=!0)}}return this.materials[e]=new Ee(o),this.materials[e]},getTextureParams:function(e,t){var r,i={scale:new f(1,1),offset:new f(0,0)},n=e.split(/\s+/);return r=n.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(n[r+1]),n.splice(r,2)),r=n.indexOf("-s"),r>=0&&(i.scale.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),r=n.indexOf("-o"),r>=0&&(i.offset.set(parseFloat(n[r+1]),parseFloat(n[r+2])),n.splice(r,4)),i.url=n.join(" ").trim(),i},loadTexture:function(e,t,r,i,n){var a,o=ke.Handlers.get(e),s=void 0!==this.manager?this.manager:Du;return null===o&&(o=new Ue(s)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin),a=o.load(e,r,i,n),void 0!==t&&(a.mapping=t),a}},er.prototype={constructor:er,isNode:!0,parse:function(e,t){t=t||{},e.parsing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.parsing=!1},parseAndBuildCode:function(e,t,r){return r=r||{},this.parse(e,r),this.buildCode(e,t,r)},buildCode:function(e,t,r){r=r||{};var i={result:this.build(e.addFlow(r.slot,r.cache,r.context),t)};return i.code=e.clearNodeCode(),e.removeFlow(),i},build:function(e,t,r){t=t||this.getType(e,t);var i=e.getNodeData(r||this);return e.parsing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),void 0!==this.updateFrame&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)},appendDepsNode:function(e,t,r){t.deps=(t.deps||0)+1;var i=e.getTypeLength(r);(i>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=i,t.output=r)},setName:function(e){return this.name=e,this},getName:function(e){return this.name},getType:function(e,t){return"sampler2D"===t||"samplerCube"===t?t:this.type},getJSONNode:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.nodes[this.uuid])return e.nodes[this.uuid]},copy:function(e){void 0!==e.name&&(this.name=e.name),void 0!==e.userData&&(this.userData=JSON.parse(JSON.stringify(e.userData)))},createJSONNode:function(e){var t=void 0===e||"string"==typeof e,r={};if("string"!=typeof this.nodeType)throw new Error("Node does not allow serialization.");return r.uuid=this.uuid,r.nodeType=this.nodeType,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t||(e.nodes[this.uuid]=r),r},toJSON:function(e){return this.getJSONNode(e)||this.createJSONNode(e)}},tr.prototype=Object.create(er.prototype),tr.prototype.constructor=tr,tr.prototype.build=function(e,t,r,i){if(t=t||this.getType(e),this.isShared(e,t)){var n=this.isUnique(e,t);n&&void 0===this.constructor.uuid&&(this.constructor.uuid=Fs.generateUUID()),r=e.getUuid(r||this.getUuid(),!n);var a=e.getNodeData(r),o=a.output||this.getType(e);if(e.parsing)return(a.deps||0)>0?(this.appendDepsNode(e,a,t),this.generate(e,t,r)):er.prototype.build.call(this,e,t,r);if(n)return a.name=a.name||er.prototype.build.call(this,e,t,r),a.name;if(!this.isShared(e,o)||!e.optimize||1==a.deps)return er.prototype.build.call(this,e,t,r);r=this.getUuid(!1);var s=this.getTemp(e,r);if(s)return e.format(s,o,t);s=tr.prototype.generate.call(this,e,t,r,a.output,i);var l=this.generate(e,o,r);return e.addNodeCode(s+" = "+l+";"),e.format(s,o,t)}return er.prototype.build.call(this,e,t,r)},tr.prototype.isShared=function(e,t){return"sampler2D"!==t&&"samplerCube"!==t&&this.shared},tr.prototype.isUnique=function(e,t){return this.unique},tr.prototype.getUuid=function(e){var t=e||void 0==e?this.constructor.uuid||this.uuid:this.uuid;return"string"==typeof this.scope&&(t=this.scope+"-"+t),t},tr.prototype.getTemp=function(e,t){t=t||this.uuid;var r=e.getVars()[t];return r?r.name:void 0},tr.prototype.generate=function(e,t,r,i,n){return this.isShared(e,t)||console.error("TempNode is not shared!"),r=r||this.uuid,e.getTempVar(r,i||this.getType(e),n).name};var Vf=function(e,t,r,i){e=e||"",this.isMethod="string"!=typeof t,this.useKeywords=!0,tr.call(this,this.isMethod?null:t),this.isMethod?this.eval(e,t,r,i):this.eval(e,r,i)};Vf.rDeclaration=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\((.*?)\)/i,Vf.rProperties=/[a-z_0-9]+/gi,Vf.prototype=Object.create(tr.prototype),Vf.prototype.constructor=Vf,Vf.prototype.nodeType="Function",Vf.prototype.eval=function(e,t,r,i){var n=this;if(e=(e||"").trim(),this.includes=t||[],this.extensions=r||{},this.keywords=i||{},this.isMethod){var a=e.match(Vf.rDeclaration);if(this.inputs=[],a&&4==a.length){this.type=a[1],this.name=a[2];var o=a[3].match(Vf.rProperties);if(o)for(var s=0;s1?(i=a[1],r=a[2],n=a[3]):(r=this.src,i="f"),this.name=r,this.type=i,this.value=n},lr.prototype.build=function(e,t){return"source"!==t?(e.include(this),e.format(this.name,this.getType(e),t)):this.value?this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";":this.useDefine?this.src:void 0},lr.prototype.generate=function(e,t){return e.format(this.name,this.getType(e),t)},lr.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.eval(e.src,e.useDefine)},lr.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src,t.useDefine===!0&&(t.useDefine=!0)),t},Gf.addKeyword("uv",function(){return new rr}),Gf.addKeyword("uv2",function(){return new rr(1)}),Gf.addKeyword("position",function(){return new ir}),Gf.addKeyword("worldPosition",function(){return new ir(ir.WORLD)}),Gf.addKeyword("normal",function(){return new nr}),Gf.addKeyword("worldNormal",function(){return new nr(nr.WORLD)}),Gf.addKeyword("viewPosition",function(){return new ir(nr.VIEW)}),Gf.addKeyword("viewNormal",function(){return new nr(nr.VIEW)}),Gf.addKeyword("time",function(){return new sr}),Gf.add(new lr("vec3 LUMA vec3(0.2125, 0.7154, 0.0721)")),Gf.add(new Vf(["vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, vec2 scale ) {","\tvec3 q0 = dFdx( eye_pos );","\tvec3 q1 = dFdy( eye_pos );","\tvec2 st0 = dFdx( mUv.st );","\tvec2 st1 = dFdy( mUv.st );","\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );","\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );","\tvec3 N = normalize( surf_norm );","\tvec3 mapN = map * 2.0 - 1.0;","\tmapN.xy = scale * mapN.xy;","\tmat3 tsn = mat3( S, T, N );","\treturn normalize( tsn * mapN );","}"].join("\n"),null,{derivatives:!0})),Gf.add(new Vf(["float snoise(vec2 co) {","\treturn fract( sin( dot(co.xy, vec2(12.9898,78.233) ) ) * 43758.5453 );","}"].join("\n"))),Gf.add(new Vf(["vec3 hue_rgb(vec3 rgb, float adjustment) {","\tconst mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);","\tconst mat3 YIQtoRGB = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046);","\tvec3 yiq = RGBtoYIQ * rgb;","\tfloat hue = atan(yiq.z, yiq.y) + adjustment;","\tfloat chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);","\treturn YIQtoRGB * vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));","}"].join("\n"))),Gf.add(new Vf(["vec3 saturation_rgb(vec3 rgb, float adjustment) {","\tvec3 intensity = vec3(dot(rgb, LUMA));","\treturn mix(intensity, rgb, adjustment);","}"].join("\n"))),Gf.add(new Vf(["float luminance_rgb(vec3 rgb) {","\treturn dot(rgb, LUMA);","}"].join("\n"))),Gf.add(new Vf(["vec3 vibrance_rgb(vec3 rgb, float adjustment) {","\tfloat average = (rgb.r + rgb.g + rgb.b) / 3.0;","\tfloat mx = max(rgb.r, max(rgb.g, rgb.b));","\tfloat amt = (mx - average) * (-3.0 * adjustment);","\treturn mix(rgb.rgb, vec3(mx), amt);","}"].join("\n"))),Vf.prototype.isShared=function(e,t){return!this.isMethod},Vf.prototype.getType=function(e){return e.getTypeByFormat(this.type)},Vf.prototype.getInputByName=function(e){for(var t=this,r=this.inputs.length;r--;)if(t.inputs[r].name===e)return t.inputs[r]},Vf.prototype.getIncludeByName=function(e){for(var t=this,r=this.includes.length;r--;)if(t.includes[r].name===e)return t.includes[r]},Vf.prototype.generate=function(e,t){for(var r,i=this,n=0,a=this.value,o=0;o0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this,r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),e&&this.materials.length>1)for(var i=this.materials.length-1;i>=0;i--)t.materials[i].groupCount<=0&&t.materials.splice(i,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),r}},r&&r.name&&"function"==typeof r.clone){var i=r.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var i=this.vertices,n=this.object.geometry.vertices;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addVertexPoint:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,r){var i=this.normals,n=this.object.geometry.normals;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addColor:function(e,t,r){var i=this.colors,n=this.object.geometry.colors;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[r+0],i[r+1],i[r+2])},addUV:function(e,t,r){var i=this.uvs,n=this.object.geometry.uvs;n.push(i[e+0],i[e+1]),n.push(i[t+0],i[t+1]),n.push(i[r+0],i[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0],t[e+1])},addFace:function(e,t,r,i,n,a,o,s,l){var c=this.vertices.length,u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),d=this.parseVertexIndex(r,c);if(this.addVertex(u,h,d),void 0!==i&&""!==i){var p=this.uvs.length;u=this.parseUVIndex(i,p),h=this.parseUVIndex(n,p),d=this.parseUVIndex(a,p),this.addUV(u,h,d)}if(void 0!==o&&""!==o){var f=this.normals.length;u=this.parseNormalIndex(o,f),h=o===s?u:this.parseNormalIndex(s,f),d=o===l?u:this.parseNormalIndex(l,f),this.addNormal(u,h,d)}this.colors.length>0&&this.addColor(u,h,d)},addPointGeometry:function(e){var t=this;this.object.geometry.type="Points";for(var r=this.vertices.length,i=0,n=e.length;i0){var _=w.split("/");y.push(_)}}for(var S=y[0],x=1,b=y.length-1;x1){var U=h[1].trim().toLowerCase();o.object.smooth="0"!==U&&"off"!==U}else o.object.smooth=!0;var B=o.object.currentMaterial();B&&(B.smooth=o.object.smooth)}o.finalize();var z=new Dt;z.materialLibraries=[].concat(o.materialLibraries);for(var p=0,f=o.objects.length;p0?Y.addAttribute("normal",new M(V.normals,3)):Y.computeVertexNormals(),V.colors.length>0&&(H=!0,Y.addAttribute("color",new M(V.colors,3))),V.uvs.length>0&&Y.addAttribute("uv",new M(V.uvs,2));for(var q=[],Q=0,J=G.length;Q1){for(var Q=0,J=G.length;Qc)){c=u;var r='Download of "'+e.url+'": '+(100*u).toFixed(2)+"%";s.onProgress("progressLoad",r,u)}}}var h=new we(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.load(e.url,l,i,n)}},e.prototype.run=function(e,t){this._applyPrepData(e);var i=e.checkResourceDescriptorFiles(e.resources,[{ext:"obj",type:"ArrayBuffer",ignore:!1},{ext:"mtl",type:"String",ignore:!1},{ext:"zip",type:"String",ignore:!0}]);r.isValid(t)&&(this.terminateWorkerOnLoad=!1,this.workerSupport=t,this.logging.enabled=this.workerSupport.logging.enabled,this.logging.debug=this.workerSupport.logging.debug);var n=this,a=function(t){null!==t&&n.meshBuilder.setMaterials(t),n._loadObj(i.obj,n.callbacks.onLoad,null,null,n.callbacks.onMeshAlter,e.useAsync)};this._loadMtl(i.mtl,a,null,null,e.crossOrigin,e.materialOptions)},e.prototype._applyPrepData=function(e){r.isValid(e)&&(this.setLogging(e.logging.enabled,e.logging.debug),this.setModelName(e.modelName),this.setStreamMeshesTo(e.streamMeshesTo),this.meshBuilder.setMaterials(e.materials),this.setUseIndices(e.useIndices),this.setDisregardNormals(e.disregardNormals),this.setMaterialPerSmoothingGroup(e.materialPerSmoothingGroup),this.setUseOAsMesh(e.useOAsMesh),this._setCallbacks(e.getCallbacks()))},e.prototype.parse=function(e){if(!r.isValid(e))return console.warn("Provided content is not a valid ArrayBuffer or String."),this.loaderRootNode;this.logging.enabled&&console.time("OBJLoader2 parse: "+this.modelName),this.meshBuilder.init();var t=new i;t.setLogging(this.logging.enabled,this.logging.debug),t.setMaterialPerSmoothingGroup(this.materialPerSmoothingGroup),t.setUseOAsMesh(this.useOAsMesh),t.setUseIndices(this.useIndices),t.setDisregardNormals(this.disregardNormals),t.setMaterials(this.meshBuilder.getMaterials());var n=this,a=function(e){var t,r=n.meshBuilder.processPayload(e);for(var i in r)t=r[i],n.loaderRootNode.add(t)};t.setCallbackMeshBuilder(a);var o=function(e,t){n.onProgress("progressParse",e,t)};return t.setCallbackProgress(o),e instanceof ArrayBuffer||e instanceof Uint8Array?(this.logging.enabled&&console.info("Parsing arrayBuffer..."),t.parse(e)):"string"==typeof e||e instanceof String?(this.logging.enabled&&console.info("Parsing text..."),t.parseText(e)):this._throwError("Provided content was neither of type String nor Uint8Array! Aborting..."),this.logging.enabled&&console.timeEnd("OBJLoader2 parse: "+this.modelName),this.loaderRootNode},e.prototype.parseAsync=function(e,t){var n=this,a=!1,o=function(){t({detail:{loaderRootNode:n.loaderRootNode,modelName:n.modelName,instanceNo:n.instanceNo}}),a&&n.logging.enabled&&console.timeEnd("OBJLoader2 parseAsync: "+n.modelName)};r.isValid(e)?a=!0:(console.warn("Provided content is not a valid ArrayBuffer."),o()),a&&this.logging.enabled&&console.time("OBJLoader2 parseAsync: "+this.modelName),this.meshBuilder.init();var s=function(e){var t,r=n.meshBuilder.processPayload(e);for(var i in r)t=r[i],n.loaderRootNode.add(t)},l=function(e,t){var n="";return n+="\n\n",n+="THREE = { "+kf.constructor.name+": {} };\n\n",n+=e(""+kf.constructor.name+"."+kf.Validator.constructor.name,r),n+=t("Parser",i)};this.workerSupport.validate(l,"Parser"),this.workerSupport.setCallbacks(s,o),n.terminateWorkerOnLoad&&this.workerSupport.setTerminateRequested(!0);var c={},u=this.meshBuilder.getMaterials();for(var h in u)c[h]=h;this.workerSupport.run({params:{useAsync:!0,materialPerSmoothingGroup:this.materialPerSmoothingGroup,useOAsMesh:this.useOAsMesh,useIndices:this.useIndices,disregardNormals:this.disregardNormals},logging:{enabled:this.logging.enabled,debug:this.logging.debug},materials:{materials:c},data:{input:e,options:null}})};var i=function(){function e(){this.callbackProgress=null,this.callbackMeshBuilder=null,this.contentRef=null,this.legacyMode=!1,this.materials={},this.useAsync=!1,this.materialPerSmoothingGroup=!1,this.useOAsMesh=!1,this.useIndices=!1,this.disregardNormals=!1,this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.rawMesh={objectName:"",groupName:"",activeMtlName:"",mtllibName:"",faceType:-1,subGroups:[],subGroupInUse:null,smoothingGroup:{splitMaterials:!1,normalized:-1,real:-1},counts:{doubleIndicesCount:0,faceCount:0,mtlCount:0,smoothingGroupCount:0}},this.inputObjectCount=1,this.outputObjectCount=1,this.globalCounts={vertices:0,faces:0,doubleIndicesCount:0,lineByte:0,currentByte:0,totalBytes:0},this.logging={enabled:!0,debug:!1}}return e.prototype.resetRawMesh=function(){this.rawMesh.subGroups=[],this.rawMesh.subGroupInUse=null,this.rawMesh.smoothingGroup.normalized=-1,this.rawMesh.smoothingGroup.real=-1,this.pushSmoothingGroup(1),this.rawMesh.counts.doubleIndicesCount=0,this.rawMesh.counts.faceCount=0,this.rawMesh.counts.mtlCount=0,this.rawMesh.counts.smoothingGroupCount=0},e.prototype.setUseAsync=function(e){this.useAsync=e},e.prototype.setMaterialPerSmoothingGroup=function(e){this.materialPerSmoothingGroup=e},e.prototype.setUseOAsMesh=function(e){this.useOAsMesh=e},e.prototype.setUseIndices=function(e){this.useIndices=e},e.prototype.setDisregardNormals=function(e){this.disregardNormals=e},e.prototype.setMaterials=function(e){this.materials=kf.Validator.verifyInput(e,this.materials),this.materials=kf.Validator.verifyInput(this.materials,{})},e.prototype.setCallbackMeshBuilder=function(e){kf.Validator.isValid(e)||this._throwError('Unable to run as no "MeshBuilder" callback is set.'),this.callbackMeshBuilder=e},e.prototype.setCallbackProgress=function(e){this.callbackProgress=e},e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.configure=function(){if(this.pushSmoothingGroup(1),this.logging.enabled){var e=Object.keys(this.materials),t=e.length>0?"\n\tmaterialNames:\n\t\t- "+e.join("\n\t\t- "):"\n\tmaterialNames: None",r="OBJLoader2.Parser configuration:"+t+"\n\tuseAsync: "+this.useAsync+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseOAsMesh: "+this.useOAsMesh+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals+"\n\tcallbackMeshBuilderName: "+this.callbackMeshBuilder.name+"\n\tcallbackProgressName: "+this.callbackProgress.name;console.info(r)}},e.prototype.parse=function(e){var t=this;this.logging.enabled&&console.time("OBJLoader2.Parser.parse"),this.configure();var r=new Uint8Array(e);this.contentRef=r;var i=r.byteLength;this.globalCounts.totalBytes=i;for(var n,a=new Array(128),o="",s=0,l=0,c=0;c0&&(a[s++]=o),o="";break;case 47:o.length>0&&(a[s++]=o),l++,o="";break;case 10:o.length>0&&(a[s++]=o),o="",t.globalCounts.lineByte=t.globalCounts.currentByte,t.globalCounts.currentByte=c,t.processLine(a,s,l),s=0,l=0;break;case 13:break;default:o+=String.fromCharCode(n)}this.finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2.Parser.parse")},e.prototype.parseText=function(e){var t=this;this.logging.enabled&&console.time("OBJLoader2.Parser.parseText"),this.configure(),this.legacyMode=!0,this.contentRef=e;var r=e.length;this.globalCounts.totalBytes=r;for(var i,n=new Array(128),a="",o=0,s=0,l=0;l0&&(n[o++]=a),a="";break;case"/":a.length>0&&(n[o++]=a),s++,a="";break;case"\n":a.length>0&&(n[o++]=a),a="",t.globalCounts.lineByte=t.globalCounts.currentByte,t.globalCounts.currentByte=l,t.processLine(n,o,s),o=0,s=0;break;case"\r":break;default:a+=i}this.finalizeParsing(),this.logging.enabled&&console.timeEnd("OBJLoader2.Parser.parseText")},e.prototype.processLine=function(e,t,r){var i=this;if(!(t<1)){var n,a,o,s,l=function(e,t,r,i){var n="";if(i>r){var a;if(t)for(a=r;a4&&(this.colors.push(parseFloat(e[4])),this.colors.push(parseFloat(e[5])),this.colors.push(parseFloat(e[6])));break;case"vt":this.uvs.push(parseFloat(e[1])),this.uvs.push(parseFloat(e[2]));break;case"vn":this.normals.push(parseFloat(e[1])),this.normals.push(parseFloat(e[2])),this.normals.push(parseFloat(e[3]));break;case"f":if(n=t-1,0===r)for(this.checkFaceType(0),o=2,a=n;o0?n-1:n+i.vertices.length/3),o=i.rawMesh.subGroupInUse.vertices;o.push(i.vertices[a++]),o.push(i.vertices[a++]),o.push(i.vertices[a]);var s=i.colors.length>0?a+1:null;if(null!==s){var l=i.rawMesh.subGroupInUse.colors;l.push(i.colors[s++]),l.push(i.colors[s++]),l.push(i.colors[s])}if(t){var c=parseInt(t),u=2*(c>0?c-1:c+i.uvs.length/2),h=i.rawMesh.subGroupInUse.uvs;h.push(i.uvs[u++]),h.push(i.uvs[u])}if(r){var d=parseInt(r),p=3*(d>0?d-1:d+i.normals.length/3),f=i.rawMesh.subGroupInUse.normals;f.push(i.normals[p++]),f.push(i.normals[p++]),f.push(i.normals[p])}};if(this.useIndices){var a=e+(t?"_"+t:"_n")+(r?"_"+r:"_n"),o=this.rawMesh.subGroupInUse.indexMappings[a];kf.Validator.isValid(o)?this.rawMesh.counts.doubleIndicesCount++:(o=this.rawMesh.subGroupInUse.vertices.length/3,n(),this.rawMesh.subGroupInUse.indexMappings[a]=o,this.rawMesh.subGroupInUse.indexMappingsCount++),this.rawMesh.subGroupInUse.indices.push(o)}else n();this.rawMesh.counts.faceCount++},e.prototype.createRawMeshReport=function(e){return"Input Object number: "+e+"\n\tObject name: "+this.rawMesh.objectName+"\n\tGroup name: "+this.rawMesh.groupName+"\n\tMtllib name: "+this.rawMesh.mtllibName+"\n\tVertex count: "+this.vertices.length/3+"\n\tNormal count: "+this.normals.length/3+"\n\tUV count: "+this.uvs.length/2+"\n\tSmoothingGroup count: "+this.rawMesh.counts.smoothingGroupCount+"\n\tMaterial count: "+this.rawMesh.counts.mtlCount+"\n\tReal MeshOutputGroup count: "+this.rawMesh.subGroups.length},e.prototype.finalizeRawMesh=function(){var e,t,r=this,i=[],n=0,a=0,o=0,s=0,l=0,c=0;for(var u in r.rawMesh.subGroups)if(e=r.rawMesh.subGroups[u],e.vertices.length>0){if(t=e.indices,t.length>0&&a>0)for(var h in t)t[h]=t[h]+a;i.push(e),n+=e.vertices.length,a+=e.indexMappingsCount,o+=e.indices.length,s+=e.colors.length,c+=e.uvs.length,l+=e.normals.length}var d=null;return i.length>0&&(d={ +name:""!==this.rawMesh.groupName?this.rawMesh.groupName:this.rawMesh.objectName,subGroups:i,absoluteVertexCount:n,absoluteIndexCount:o,absoluteColorCount:s,absoluteNormalCount:l,absoluteUvCount:c,faceCount:this.rawMesh.counts.faceCount,doubleIndicesCount:this.rawMesh.counts.doubleIndicesCount}),d},e.prototype.processCompletedMesh=function(){var e=this.finalizeRawMesh();if(kf.Validator.isValid(e)){this.colors.length>0&&this.colors.length!==this.vertices.length&&this._throwError("Vertex Colors were detected, but vertex count and color count do not match!"),this.logging.enabled&&this.logging.debug&&console.debug(this.createRawMeshReport(this.inputObjectCount)),this.inputObjectCount++,this.buildMesh(e);var t=this.globalCounts.currentByte/this.globalCounts.totalBytes;return this.callbackProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*t).toFixed(2)+"%",t),this.resetRawMesh(),!0}return!1},e.prototype.buildMesh=function(e){var t=this,r=e.subGroups,i=new Float32Array(e.absoluteVertexCount);this.globalCounts.vertices+=e.absoluteVertexCount/3,this.globalCounts.faces+=e.faceCount,this.globalCounts.doubleIndicesCount+=e.doubleIndicesCount;var n,a,o,s,l,c,u,h=e.absoluteIndexCount>0?new Uint32Array(e.absoluteIndexCount):null,d=e.absoluteColorCount>0?new Float32Array(e.absoluteColorCount):null,p=e.absoluteNormalCount>0?new Float32Array(e.absoluteNormalCount):null,f=e.absoluteUvCount>0?new Float32Array(e.absoluteUvCount):null,m=kf.Validator.isValid(d),v=[],g=r.length>1,y=0,x=[],b=[],w=0,_=0,S=0,A=0,M=0,T=0,E=0;for(var C in r)if(r.hasOwnProperty(C)){if(n=r[C],u=n.materialName,c=t.rawMesh.faceType<4?u+(m?"_vertexColor":"")+(0===n.smoothingGroup?"_flat":""):6===t.rawMesh.faceType?"defaultPointMaterial":"defaultLineMaterial",s=t.materials[u],l=t.materials[c],!kf.Validator.isValid(s)&&!kf.Validator.isValid(l)){var L=m?"defaultVertexColorMaterial":"defaultMaterial";s=t.materials[L],t.logging.enabled&&console.warn('object_group "'+n.objectName+"_"+n.groupName+'" was defined with unresolvable material "'+u+'"! Assigning "'+L+'".'),u=L,u===c&&(l=s,c=L)}if(!kf.Validator.isValid(l)){var P={materialNameOrg:u,materialName:c,materialProperties:{vertexColors:m?2:0,flatShading:0===n.smoothingGroup}},N={cmd:"materialData",materials:{materialCloneInstructions:P}};t.callbackMeshBuilder(N),t.useAsync&&(t.materials[c]=P)}if(g?(a=x[c],a||(a=y,x[c]=y,v.push(c),y++),E=t.useIndices?n.indices.length:n.vertices.length/3,o={start:T,count:E,index:a},b.push(o),T+=E):v.push(c),i.set(n.vertices,w),w+=n.vertices.length,h&&(h.set(n.indices,_),_+=n.indices.length),d&&(d.set(n.colors,S),S+=n.colors.length),p&&(p.set(n.normals,A),A+=n.normals.length),f&&(f.set(n.uvs,M),M+=n.uvs.length),t.logging.enabled&&t.logging.debug){var O=kf.Validator.isValid(a)?"\n\t\tmaterialIndex: "+a:"",D="\tOutput Object no.: "+t.outputObjectCount+"\n\t\tgroupName: "+n.groupName+"\n\t\tIndex: "+n.index+"\n\t\tfaceType: "+t.rawMesh.faceType+"\n\t\tmaterialName: "+n.materialName+"\n\t\tsmoothingGroup: "+n.smoothingGroup+O+"\n\t\tobjectName: "+n.objectName+"\n\t\t#vertices: "+n.vertices.length/3+"\n\t\t#indices: "+n.indices.length+"\n\t\t#colors: "+n.colors.length/3+"\n\t\t#uvs: "+n.uvs.length/2+"\n\t\t#normals: "+n.normals.length/3;console.debug(D)}}this.outputObjectCount++,this.callbackMeshBuilder({cmd:"meshData",progress:{numericalValue:this.globalCounts.currentByte/this.globalCounts.totalBytes},params:{meshName:e.name},materials:{multiMaterial:g,materialNames:v,materialGroups:b},buffers:{vertices:i,indices:h,colors:d,normals:p,uvs:f},geometryType:this.rawMesh.faceType<4?0:6===this.rawMesh.faceType?2:1},[i.buffer],kf.Validator.isValid(h)?[h.buffer]:null,kf.Validator.isValid(d)?[d.buffer]:null,kf.Validator.isValid(p)?[p.buffer]:null,kf.Validator.isValid(f)?[f.buffer]:null)},e.prototype.finalizeParsing=function(){if(this.logging.enabled&&console.info("Global output object count: "+this.outputObjectCount),this.processCompletedMesh()&&this.logging.enabled){var e="Overall counts: \n\tVertices: "+this.globalCounts.vertices+"\n\tFaces: "+this.globalCounts.faces+"\n\tMultiple definitions: "+this.globalCounts.doubleIndicesCount;console.info(e)}},e}();return e.prototype.loadMtl=function(e,t,r,i,n,a,o){var s=new kf.ResourceDescriptor(e,"MTL");s.setContent(t),this._loadMtl(s,r,i,n,a,o)},e.prototype._loadMtl=function(e,t,i,n,a,o){void 0===jf&&console.error('"MTLLoader" is not available. "OBJLoader2" requires it for loading MTL files.'),r.isValid(e)&&this.logging.enabled&&console.time("Loading MTL: "+e.name);var s=[],l=this,c=function(i){var n=[];if(r.isValid(i)){i.preload(),n=i.materials;for(var a in n)n.hasOwnProperty(a)&&(s[a]=n[a])}r.isValid(e)&&l.logging.enabled&&console.timeEnd("Loading MTL: "+e.name),t(s,i)};if(r.isValid(e)&&(r.isValid(e.content)||r.isValid(e.url))){var u=new jf(this.manager);a=r.verifyInput(a,"anonymous"),u.setCrossOrigin(a),u.setPath(e.path),r.isValid(o)&&u.setMaterialOptions(o);var h=function(e){var t=e;"string"==typeof e||e instanceof String||(e.length>0||e.byteLength>0?t=Ru.decodeText(e):this._throwError("Unable to parse mtl as it it seems to be neither a String, an Array or an ArrayBuffer!")),c(u.parse(t))};if(r.isValid(e.content))h(e.content);else if(r.isValid(e.url)){var d=new we(this.manager);if(r.isValid(n)||(n=function(e){l._onError(e)}),!r.isValid(i)){var p=0,f=0;i=function(t){if(t.lengthComputable&&(f=t.loaded/t.total,f>p)){p=f;var r='Download of "'+e.url+'": '+(100*f).toFixed(2)+"%";l.onProgress("progressLoad",r,f)}}}d.load(e.url,h,i,n)}}else c()},e}(),Jf=function(e){this.manager=void 0!==e?e:Du,this.littleEndian=!0};Jf.prototype={constructor:Jf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),a.load(e,function(r){try{t(n.parse(r,e))}catch(a){if(!i)throw a;i(a)}},r,i)},parse:function(e,t){function r(e){var t={},r=e.search(/[\r\n]DATA\s(\S*)\s/i),i=/[\r\n]DATA\s(\S*)\s/i.exec(e.substr(r-1));if(t.data=i[1],t.headerLen=i[0].length+r,t.str=e.substr(0,t.headerLen),t.str=t.str.replace(/\#.*/gi,""),t.version=/VERSION (.*)/i.exec(t.str),t.fields=/FIELDS (.*)/i.exec(t.str),t.size=/SIZE (.*)/i.exec(t.str),t.type=/TYPE (.*)/i.exec(t.str),t.count=/COUNT (.*)/i.exec(t.str),t.width=/WIDTH (.*)/i.exec(t.str),t.height=/HEIGHT (.*)/i.exec(t.str),t.viewpoint=/VIEWPOINT (.*)/i.exec(t.str),t.points=/POINTS (.*)/i.exec(t.str),null!==t.version&&(t.version=parseFloat(t.version[1])),null!==t.fields&&(t.fields=t.fields[1].split(" ")),null!==t.type&&(t.type=t.type[1].split(" ")),null!==t.width&&(t.width=parseInt(t.width[1])),null!==t.height&&(t.height=parseInt(t.height[1])),null!==t.viewpoint&&(t.viewpoint=t.viewpoint[1]),null!==t.points&&(t.points=parseInt(t.points[1],10)),null===t.points&&(t.points=t.width*t.height),null!==t.size&&(t.size=t.size[1].split(" ").map(function(e){return parseInt(e,10)})),null!==t.count)t.count=t.count[1].split(" ").map(function(e){return parseInt(e,10)});else{t.count=[];for(var n=0,a=t.fields.length;n0&&y.addAttribute("position",new M(o,3)),s.length>0&&y.addAttribute("normal",new M(s,3)),l.length>0&&y.addAttribute("color",new M(l,3)),y.computeBoundingSphere();var x=new Ne({size:.005});l.length>0?x.vertexColors=!0:x.color.setHex(16777215*Math.random());var b=new Et(y,x),w=t.split("").reverse().join("");return w=/([^\/]*)/.exec(w),w=w[1].split("").reverse().join(""),b.name=w,b}};var Zf=function(e){this.manager=void 0!==e?e:Du};Zf.prototype={constructor:Zf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){function t(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function r(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}function i(e,t){return"s"+Math.min(e,t)+"e"+Math.max(e,t)}function n(e,t){var r=parseInt(m[v].substr(e,t));if(r){var n=i(y,r);void 0===f[n]&&(p.push([y-1,r-1,1]),f[n]=p.length-1)}}function a(){var e,t,r={geometryAtoms:new P,geometryBonds:new P,json:{atoms:d,bonds:p}},i=r.geometryAtoms,n=r.geometryBonds,a=[],o=[],s=[];for(e=0,t=d.length;e=t.elements[u].count&&(u++,h=0);var f=i(t.elements[u].properties,p);o(n,t.elements[u].name,f),h++}}return a(n)}function a(e){var t=new P;return e.indices.length>0&&t.setIndex(e.indices),t.addAttribute("position",new M(e.vertices,3)),e.normals.length>0&&t.addAttribute("normal",new M(e.normals,3)),e.uvs.length>0&&t.addAttribute("uv",new M(e.uvs,2)),e.colors.length>0&&t.addAttribute("color",new M(e.colors,3)),t.computeBoundingSphere(),t}function o(e,t,r){if("vertex"===t)e.vertices.push(r.x,r.y,r.z),"nx"in r&&"ny"in r&&"nz"in r&&e.normals.push(r.nx,r.ny,r.nz),"s"in r&&"t"in r&&e.uvs.push(r.s,r.t),"red"in r&&"green"in r&&"blue"in r&&e.colors.push(r.red/255,r.green/255,r.blue/255);else if("face"===t){var i=r.vertex_indices||r.vertex_index;3===i.length?e.indices.push(i[0],i[1],i[2]):4===i.length&&(e.indices.push(i[0],i[1],i[3]),e.indices.push(i[1],i[2],i[3]))}}function s(e,t,r,i){switch(r){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,i),2];case"uint16":case"ushort":return[e.getUint16(t,i),2];case"int32":case"int":return[e.getInt32(t,i),4];case"uint32":case"uint":return[e.getUint32(t,i),4];case"float32":case"float":return[e.getFloat32(t,i),4];case"float64":case"double":return[e.getFloat64(t,i),8]}}function l(e,t,r,i){for(var n,a={},o=0,l=0;l0;return f===p?(r=m?Nc:Lc,t=4):f===d?(r=m?Oc:Pc,t=2):console.error("PVRLoader: Unknown PVR format:",f),e.dataPtr=n,e.bpp=t,e.format=r,e.width=o,e.height=a,e.numSurfaces=u,e.numMipmaps=s+1,e.isCubemap=6===u,nm._extract(e)},nm._extract=function(e){var t={mipmaps:[],width:e.width,height:e.height,format:e.format,mipmapCount:e.numMipmaps,isCubemap:e.isCubemap},r=e.buffer,i=e.dataPtr,n=e.bpp,a=e.numSurfaces,o=0,s=0,l=0,c=0,u=0,h=0;2===n?(l=8,c=4):(l=4,c=4),s=l*c*n/8,t.mipmaps.length=e.numMipmaps*a;for(var d=0;d>d,f=e.height>>d;u=p/l,h=f/c,u<2&&(u=2),h<2&&(h=2),o=u*h*s;for(var m=0;m>5&31)/31,i=(A>>10&31)/31):(t=a,r=o,i=s)}for(var M=1;M<=3;M++){var T=b+12*M;v.push(c.getFloat32(T,!0)),v.push(c.getFloat32(T+4,!0)),v.push(c.getFloat32(T+8,!0)),y.push(w,_,S),h&&n.push(t,r,i)}}return m.addAttribute("position",new g(new Float32Array(v),3)),m.addAttribute("normal",new g(new Float32Array(y),3)),h&&(m.addAttribute("color",new g(new Float32Array(n),3)),m.hasColors=!0,m.alpha=l),m}function a(e){for(var t,r=new P,n=/facet([\s\S]*?)endfacet/g,a=0,o=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,s=new RegExp("vertex"+o+o+o,"g"),l=new RegExp("normal"+o+o+o,"g"),c=[],u=[],h=new i;null!==(t=n.exec(e));){for(var d=0,p=0,f=t[0];null!==(t=l.exec(f));)h.x=parseFloat(t[1]),h.y=parseFloat(t[2]),h.z=parseFloat(t[3]),p++;for(;null!==(t=s.exec(f));)c.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),u.push(h.x,h.y,h.z),d++;1!==p&&console.error("STLLoader: Something isn't right with the normal of face number "+a),3!==d&&console.error("STLLoader: Something isn't right with the vertices of face number "+a),a++}return r.addAttribute("position",new M(c,3)),r.addAttribute("normal",new M(u,3)),r}function o(e){return"string"!=typeof e?Ru.decodeText(new Uint8Array(e)):e}function s(e){if("string"==typeof e){for(var t=new Uint8Array(e.length),r=0;ri;)n-=i;n0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===l&&s===a-1&&(s=a-2,l=1);var c,u,h,d;if(this.closed||s>0?c=n[(s-1)%a]:(om.subVectors(n[0],n[1]).add(n[0]),c=om),u=n[s%a],h=n[(s+1)%a],this.closed||s+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return r.set(gr(o,s.x,l.x,c.x,u.x),gr(o,s.y,l.y,c.y,u.y)),r},Dr.prototype.copy=function(e){var t=this;at.prototype.copy.call(this,e),this.points=[];for(var r=0,i=e.points.length;r=r){var a=i[n]-r,o=t.curves[n],s=o.getLength(),l=0===s?0:1-a/s;return o.getPointAt(l)}n++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){var e=this;if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],r=0,i=0,n=this.curves.length;i1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},copy:function(e){var t=this;at.prototype.copy.call(this,e),this.curves=[];for(var r=0,i=e.curves.length;r0){var c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);var u=l.getPoint(1);this.currentPoint.copy(u)},copy:function(e){return Fr.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=Fr.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return Fr.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Ir.prototype=Object.assign(Object.create(Rr.prototype),{constructor:Ir,getPointsHoles:function(e){for(var t=this,r=[],i=0,n=this.holes.length;i80*r){s=c=e[0],l=u=e[1];for(var f=r;fc&&(c=h),d>u&&(u=d);p=Math.max(c-s,u-l),p=0!==p?1/p:0}return Br(a,o,r,s,l,p),o}},dm={area:function(e){for(var t=e.length,r=0,i=t-1,n=0;nNumber.EPSILON){if(c<0&&(o=t[a],l=-l,s=t[n],c=-c),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var u=c*(e.x-o.x)-l*(e.y-o.y);if(0===u)return!0;if(u<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=dm.isClockWise,a=this.subPaths;if(0===a.length)return[];if(t===!0)return r(a);var o,s,l,c=[];if(1===a.length)return s=a[0],l=new Ir,l.curves=s.curves,c.push(l),c;var u=!n(a[0].getPoints());u=e?!u:u;var h,d=[],p=[],f=[],m=0;p[m]=void 0,f[m]=[];for(var v=0,g=a.length;v1){for(var y=!1,x=[],b=0,w=p.length;b0&&(y||(f=d))}for(var E,v=0,C=p.length;v0&&(i.copy(o),r.currentPath.currentPoint.copy(i),s=!0);break;default:console.warn(p)}l&&(o.copy(i),l=!1)}return r}function n(e,t,r,i,n,o,s,l){i=i*Math.PI/180,t=Math.abs(t),r=Math.abs(r);var c=(s.x-l.x)/2,u=(s.y-l.y)/2,h=Math.cos(i)*c+Math.sin(i)*u,d=-Math.sin(i)*c+Math.cos(i)*u,p=t*t,f=r*r,m=h*h,v=d*d,g=m/p+v/f;if(g>1){var y=Math.sqrt(g);t=y*t,r=y*r,p=t*t,f=r*r}var x=p*v+f*m,b=(p*f-x)/x,w=Math.sqrt(Math.max(0,b));n===o&&(w=-w);var _=w*t*d/r,S=-w*r*h/t,A=Math.cos(i)*_-Math.sin(i)*S+(s.x+l.x)/2,M=Math.sin(i)*_+Math.cos(i)*S+(s.y+l.y)/2,T=a(1,0,(h-_)/t,(d-S)/r),E=a((h-_)/t,(d-S)/r,(-h-_)/t,(-d-S)/r)%(2*Math.PI);e.currentPath.absellipse(A,M,t,r,T,T+E,0===o,i)}function a(e,t,r,i){var n=e*r+t*i,a=Math.sqrt(e*e+t*t)*Math.sqrt(r*r+i*i),o=Math.acos(Math.max(-1,Math.min(1,n/a)));return e*i-t*r<0&&(o=-o),o}function o(e,t){var r=parseFloat(e.getAttribute("x")||0),i=parseFloat(e.getAttribute("y")||0),n=parseFloat(e.getAttribute("rx")||0),a=parseFloat(e.getAttribute("ry")||0),o=parseFloat(e.getAttribute("width")),s=parseFloat(e.getAttribute("height")),l=new pi;return l.color.setStyle(t.fill),l.moveTo(r+2*n,i),l.lineTo(r+o-2*n,i),0===n&&0===a||l.bezierCurveTo(r+o,i,r+o,i,r+o,i+2*a),l.lineTo(r+o,i+s-2*a),0===n&&0===a||l.bezierCurveTo(r+o,i+s,r+o,i+s,r+o-2*n,i+s),l.lineTo(r+2*n,i+s),0===n&&0===a||l.bezierCurveTo(r,i+s,r,i+s,r,i+s-2*a),l.lineTo(r,i+2*a),0===n&&0===a||l.bezierCurveTo(r,i,r,i,r+2*n,i),l}function s(e,t){function r(e,t,r){var i=parseFloat(t),o=parseFloat(r);0===a?n.moveTo(i,o):n.lineTo(i,o),a++}var i=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,n=new pi;n.color.setStyle(t.fill);var a=0;return e.getAttribute("points").replace(i,r),n.currentPath.autoClose=!0,n}function c(e,t){function r(e,t,r){var i=parseFloat(t),o=parseFloat(r);0===a?n.moveTo(i,o):n.lineTo(i,o),a++}var i=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,n=new pi;n.color.setStyle(t.fill);var a=0;return e.getAttribute("points").replace(i,r),n.currentPath.autoClose=!1,n}function u(e,t){var r=parseFloat(e.getAttribute("cx")),i=parseFloat(e.getAttribute("cy")),n=parseFloat(e.getAttribute("r")),a=new Rr;a.absarc(r,i,n,0,2*Math.PI);var o=new pi;return o.color.setStyle(t.fill),o.subPaths.push(a),o}function h(e,t){var r=parseFloat(e.getAttribute("cx")),i=parseFloat(e.getAttribute("cy")),n=parseFloat(e.getAttribute("rx")),a=parseFloat(e.getAttribute("ry")),o=new Rr;o.absellipse(r,i,n,a,0,2*Math.PI);var s=new pi;return s.color.setStyle(t.fill),s.subPaths.push(o),s}function d(e,t){var r=parseFloat(e.getAttribute("x1")),i=parseFloat(e.getAttribute("y1")),n=parseFloat(e.getAttribute("x2")),a=parseFloat(e.getAttribute("y2")),o=new pi;return o.moveTo(r,i),o.lineTo(n,a),o.currentPath.autoClose=!1,o}function p(e,t){return t=Object.assign({},t),e.hasAttribute("fill")&&(t.fill=e.getAttribute("fill")),""!==e.style.fill&&(t.fill=e.style.fill),t}function m(e){return"none"!==e.fill&&"transparent"!==e.fill}function v(e,t){return e-(t-e)}function g(e){for(var t=e.split(/[\s,]+|(?=\s?[+\-])/),r=0;r0&&t.premultiply(M[M.length-1]),L.copy(t),M.push(t)),t}function x(e){var t=e.getAttribute("transform"),r=null,i=t.indexOf("("),n=t.indexOf(")");if(i>0&&i=1){r=new l;var s=o[0],c=s;o.length>=2&&(c=o[1]),r.translate(s,c)}break;case"rotate":if(o.length>=1){var u=0,h=0,d=0;r=new l,u=-o[0]*Math.PI/180,o.length>=3&&(h=o[1],d=o[2]),T.identity().translate(-h,-d),E.identity().rotate(u),C.multiplyMatrices(E,T),T.identity().translate(h,d),r.multiplyMatrices(T,C)}break;case"scale":if(o.length>=1){r=new l;var p=o[0],f=p;o.length>=2&&(f=o[1]),r.scale(p,f)}break;case"skewX":1===o.length&&(r=new l,r.set(1,Math.tan(o[0]*Math.PI/180),0,0,1,0,0,0,1));break;case"skewY":1===o.length&&(r=new l,r.set(1,0,0,Math.tan(o[0]*Math.PI/180),1,0,0,0,1));break;case"matrix":6===o.length&&(r=new l,r.set(o[0],o[2],o[4],o[1],o[3],o[5],0,0,1))}}return r}function b(e,t){function r(e){o.set(e.x,e.y,1).applyMatrix3(t),e.set(o.x,o.y)}for(var n=w(t),a=new f,o=new i,s=e.subPaths,l=0,c=s.length;l=t.end)return 0;this.position=t.cur;try{var r=this.readChunk(e);return t.cur+=r.size,r.id}catch(i){return this.debugMessage("Unable to read chunk at "+this.position),0}},resetPosition:function(){this.position-=6},readByte:function(e){var t=e.getUint8(this.position,!0);return this.position+=1,t},readFloat:function(e){try{var t=e.getFloat32(this.position,!0);return this.position+=4,t}catch(r){this.debugMessage(r+" "+this.position+" "+e.byteLength)}},readInt:function(e){var t=e.getInt32(this.position,!0);return this.position+=4,t},readShort:function(e){var t=e.getInt16(this.position,!0);return this.position+=2,t},readDWord:function(e){var t=e.getUint32(this.position,!0);return this.position+=4,t},readWord:function(e){var t=e.getUint16(this.position,!0);return this.position+=2,t},readString:function(e,t){for(var r=this,i="",n=0;n0;r--){var n=e[r],t={type:n.type};void 0!==n.x2&&void 0!==n.y2?(t.x1=n.x2,t.y1=n.y2,t.x2=n.x1,t.y2=n.y1):void 0!==n.x1&&void 0!==n.y1&&(t.x1=n.x1,t.y1=n.y1),t.x=e[r-1].x,t.y=e[r-1].y,i.push(t)}}),i}return"undefined"==typeof opentype?(console.warn("TTFLoader: The loader requires opentype.js. Make sure it's included before using the loader."),null):t(opentype.parse(e),this.reversed)}};var $m=function(e){this.manager=void 0!==e?e:Du};$m.prototype={constructor:$m,isRecordingPoints:!1,isRecordingFaces:!1,points:[],indexes:[],isRecordingAngles:!1,isRecordingColors:!1,angles:[],colors:[],recordingFieldname:null,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=new we(this.manager);a.load(e,function(e){t(n.parse(e))},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e){function t(e,t){function o(e,t,r,n,a){for(var o=a===!0?1:-1,s=[],l={},c={},h=!1,d=0;dc.y:y.y>=l.y&&y.y0)for(var c=0;c0&&r.indexes.push(y),y=[]):y.push(parseInt(o[c])));/]/.exec(t)&&(y.length>0&&r.indexes.push(y),y=[],r.isRecordingFaces=!1,e[r.recordingFieldname]=r.indexes)}else if(r.isRecordingPoints){if("Coordinate"==e.nodeType)for(;null!==(o=v.exec(t));)a={x:parseFloat(o[1]),y:parseFloat(o[2]),z:parseFloat(o[3])},r.points.push(a);if("TextureCoordinate"==e.nodeType)for(;null!==(o=m.exec(t));)a={x:parseFloat(o[1]),y:parseFloat(o[2])},r.points.push(a);/]/.exec(t)&&(r.isRecordingPoints=!1,e.points=r.points)}else if(r.isRecordingAngles){if(o.length>0)for(var c=0;c-1&&"PointLight"===e.nodeType&&(e.nodeType="AmbientLight");var l=void 0===e.on||e.on,p=void 0!==e.intensity?e.intensity:1,m=new u;if(e.color&&m.copy(e.color),"AmbientLight"===e.nodeType)s=new Ht(m,p),s.visible=l,r.add(s);else if("PointLight"===e.nodeType){var v=0;void 0!==e.radius&&e.radius<1e3&&(v=e.radius),s=new zt(m,p,v),s.visible=l,r.add(s)}else if("SpotLight"===e.nodeType){var p=1,v=0,g=Math.PI/3,y=0,l=!0;void 0!==e.radius&&e.radius<1e3&&(v=e.radius),void 0!==e.cutOffAngle&&(g=e.cutOffAngle),s=new Wt(m,p,v,g,y),s.visible=l,r.add(s)}else if("Transform"===e.nodeType||"Group"===e.nodeType){if(s=new c,/DEF/.exec(e.string)&&(s.name=/DEF\s+([^\s]+)/.exec(e.string)[1],d[s.name]=s),void 0!==e.translation){var x=e.translation;s.position.set(x.x,x.y,x.z)}if(void 0!==e.rotation){var b=e.rotation;s.quaternion.setFromAxisAngle(new i(b.x,b.y,b.z),b.w)}if(void 0!==e.scale){var w=e.scale;s.scale.set(w.x,w.y,w.z)}r.add(s)}else if("Shape"===e.nodeType)s=new k,/DEF/.exec(e.string)&&(s.name=/DEF\s+([^\s]+)/.exec(e.string)[1],d[s.name]=s),r.add(s);else if("Background"===e.nodeType){var _=20,S=2e4,A=new O(S,_,_),T=new F({fog:!1,side:Zs});if(e.skyColor.length>1)o(A,S,e.skyAngle,e.skyColor,!0),T.vertexColors=il;else{var E=e.skyColor[0];T.color.setRGB(E.r,E.b,E.g)}if(t.add(new k(A,T)),void 0!==e.groundColor){S=12e3;var C=new O(S,_,_,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),L=new F({fog:!1,side:Zs,vertexColors:il});o(C,S,e.groundAngle,e.groundColor,!1),t.add(new k(C,L))}}else{if(/geometry/.exec(e.string)){if("Box"===e.nodeType){var w=e.size;r.geometry=new le(w.x,w.y,w.z)}else if("Cylinder"===e.nodeType)r.geometry=new ue(e.radius,e.radius,e.height);else if("Cone"===e.nodeType)r.geometry=new ue(e.topRadius,e.bottomRadius,e.height);else if("Sphere"===e.nodeType)r.geometry=new O(e.radius);else if("IndexedFaceSet"===e.nodeType){var N,D,R,I,U,B,z=new P,j=[],V=[];for(R=0,I=e.children.length;R-1){var W=/DEF\s+([^\s]+)/.exec(G.string)[1];d[W]=j.slice(0)}if(G.string.indexOf("USE")>-1){var X=/USE\s+([^\s]+)/.exec(G.string)[1];j=d[X]}}}var H=0;if(e.coordIndex){var Y=[],q=[];for(N=new i,D=new f,R=0,I=e.coordIndex.length;R=3&&H0&&z.addAttribute("uv",new M(V,2)),z.computeVertexNormals(),z.computeBoundingSphere(),/DEF/.exec(e.string)&&(z.name=/DEF ([^\s]+)/.exec(e.string)[1],d[z.name]=z),r.geometry=z}return}if(/appearance/.exec(e.string)){for(var R=0;R-1;l--){var h=s[l];if(/{.*[{\[]/.test(h)){var d=h.split("{").join("{\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}else if(/\].*}/.test(h)){var d=h.split("]").join("]\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}if(/}.*}/.test(h)){var d=h.split("}").join("}\n").split("\n");d.unshift(1),d.unshift(l),s.splice.apply(s,d)}/^\b[^\s]+\b$/.test(h.trim())?(s[l+1]=h+" "+s[l+1].trim(),s.splice(l,1)):h.indexOf("coord")>-1&&h.indexOf("[")<0&&h.indexOf("{")<0&&(s[l]+=" Coordinate {}")}var p=s.shift();return/V1.0/.exec(p)?console.warn("VRMLLoader: V1.0 not supported yet."):/V2.0/.exec(p)&&t(s,o),o}};var ev=function(){function e(e){if(void 0===Nf)throw new Error("VRMLoader: Import GLTFLoader.");this.manager=void 0!==e?e:Du,this.gltfLoader=new Nf(this.manager)}return e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this;this.gltfLoader.load(e,function(e){n.parse(e,t)},r,i)},setCrossOrigin:function(e){return this.glTFLoader.setCrossOrigin(e),this},setPath:function(e){return this.glTFLoader.setPath(e),this},setDRACOLoader:function(e){return this.glTFLoader.setDRACOLoader(e),this},parse:function(e,t){var r=(e.parser,e.userData.gltfExtensions||{});r.VRM||{};t(e)}},e}(),tv=function(e){this.manager=void 0!==e?e:Du};Object.assign(tv.prototype,a.prototype,{load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){function t(e){var t,r=[],i=[],n=[],a=[],o=/(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g,s=/^(\d+)\s+([\s\d]*)/,l=/^POINTS /,c=/^POLYGONS /,u=/^TRIANGLE_STRIPS /,h=/^POINT_DATA[ ]+(\d+)/,d=/^CELL_DATA[ ]+(\d+)/,p=/^COLOR_SCALARS[ ]+(\w+)[ ]+3/,f=/^NORMALS[ ]+(\w+)[ ]+(\w+)/,m=!1,v=!1,g=!1,y=!1,x=!1,b=!1,w=!1,_=e.split("\n");for(var S in _){var A=_[S];if(m)for(;null!==(t=o.exec(A));){var T=parseFloat(t[1]),E=parseFloat(t[2]),C=parseFloat(t[3]);i.push(T,E,C)}else if(v){if(null!==(t=s.exec(A))){var L=parseInt(t[1]),N=t[2].split(/\s+/);if(L>=3)for(var O,D,F=parseInt(N[0]),R=1,I=0;I=3)for(var F,O,D,I=0;I=c.byteLength)break}var _=new P;return _.setIndex(new g(p,1)),_.addAttribute("position",new g(h,3)),d.length===h.length&&_.addAttribute("normal",new g(d,3)),_}function i(e,t){var r=e.length,i=new Float32Array(r+t.length);return i.set(e),i.set(t,r),i}function n(e,t){var r=e.length,i=new Int32Array(r+t.length);return i.set(e),i.set(t,r),i}function a(e){function t(e){var r={};if(1===e.nodeType){if(e.attributes&&e.attributes.length>0){r.attributes={};for(var i=0;i0)throw new Error("Invalid string. Length must be a multiple of 4");u="="===e[o-2]?2:"="===e[o-1]?1:0,h=new r(3*o/4-u),l=u>0?o-4:o;var d=0;for(t=0,s=0;t>16,h[d++]=(65280&c)>>8,h[d++]=255&c;return 2===u?(c=n[e.charCodeAt(t)]<<2|n[e.charCodeAt(t+1)]>>4,h[d++]=255&c):1===u&&(c=n[e.charCodeAt(t)]<<10|n[e.charCodeAt(t+1)]<<4|n[e.charCodeAt(t+2)]>>2,h[d++]=c>>8&255,h[d++]=255&c),h}function a(e,t){var a=0;if("UInt64"===c.attributes.header_type?a=8:"UInt32"===c.attributes.header_type&&(a=4),"binary"===e.attributes.format&&t){var o,s,l,u,h,d,p,f,m;if("Float32"===e.attributes.type)var v=new Float32Array;else if("Int64"===e.attributes.type)var v=new Int32Array;o=e["#text"],l=r(o),u=l[0];for(var g=1;g0?3-d%3:0,d+=p,f=[],m=d,f.push(m),h=3*a;for(var g=0;g0&&(b[w].text=a(b[w],f)),w++;switch(m[v]){case"PointData":var S=parseInt(p.attributes.NumberOfPoints),A=x.attributes.Normals;if(S>0)for(var M=0,T=b.length;M0){var E=x.DataArray.attributes.NumberOfComponents;u=new Float32Array(S*E),u.set(x.DataArray.text,0)}break;case"Strips":var C=parseInt(p.attributes.NumberOfStrips);if(C>0){var L=new Int32Array(x.DataArray[0].text.length),N=new Int32Array(x.DataArray[1].text.length);L.set(x.DataArray[0].text,0),N.set(x.DataArray[1].text,0);var O=C+L.length;d=new Uint32Array(3*O-9*C);for(var D=0,M=0,T=C;M0&&(U=N[M-1]);for(var k=0,I=N[M],U=0;k0&&(U=N[M-1])}}break;case"Polys":var B=parseInt(p.attributes.NumberOfPolys);if(B>0){var L=new Int32Array(x.DataArray[0].text.length),N=new Int32Array(x.DataArray[1].text.length);L.set(x.DataArray[0].text,0),N.set(x.DataArray[1].text,0);var O=B+L.length;d=new Uint32Array(3*O-9*B);for(var D=0,z=0,M=0,T=B,U=0;M=d.maxCount-3&&(d.hasPositions=!0,d.hasNormals=!0,d.enableUvs&&(d.hasUvs=!0),d.enableColors&&(d.hasColors=!0),a(d))}function h(e,t,r){var i=new Float32Array(e.length+r);return i.set(e,0),i.set(t.slice(0,r),e.length),i}fi.call(this,t);var d=this,p=new Float32Array(36),f=new Float32Array(36);this.enableUvs=void 0!==r&&r,this.enableColors=void 0!==i&&i,this.init=function(e){this.resolution=e,this.isolation=80,this.size=e,this.size2=this.size*this.size,this.size3=this.size2*this.size,this.halfsize=this.size/2,this.delta=2/this.size,this.yd=this.size,this.zd=this.size2,this.field=new Float32Array(this.size3),this.normal_cache=new Float32Array(3*this.size3),this.maxCount=4096,this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=new Float32Array(3*this.maxCount),this.normalArray=new Float32Array(3*this.maxCount),this.enableUvs&&(this.uvArray=new Float32Array(2*this.maxCount)),this.enableColors&&(this.colorArray=new Float32Array(3*this.maxCount))},this.begin=function(){this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasUvs=!1,this.hasColors=!1},this.end=function(e){var t=this;if(0!==this.count){for(var r=3*this.count;rthis.size-1&&(d=this.size-1);var p=Math.floor(c-s);p<1&&(p=1);var f=Math.floor(c+s);f>this.size-1&&(f=this.size-1);var m=Math.floor(u-s);m<1&&(m=1);var v=Math.floor(u+s);v>this.size-1&&(v=this.size-1);var g,y,x,b,w,_,S,A,M,T,E;for(x=h;x0&&(a.field[b+g]+=E*o)},this.addPlaneX=function(e,t){var r,i,n,a,o,s,l,c=this.size,u=this.yd,h=this.zd,d=this.field,p=c*Math.sqrt(e/t);for(p>c&&(p=c),r=0;r0)for(i=0;iu&&(f=u),i=0;i0)for(l=i*h,r=0;ru&&(f=u),n=0;n0)for(l=d*n,i=0;ir.far||i.push({distance:x,point:t.clone(),uv:U.getUV(t,c,u,h,d,p,m,new f),face:null, +object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return c.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var sv=function(e,t){var r=this;this.lut=[],this.map=lv[e],this.n=t,this.mapname=e;for(var i=1/this.n,n=0;n<=1;n+=i)for(var a=0;a=r.map[a][0]&&n=this.maxV&&(e=this.maxV),e=(e-this.minV)/(this.maxV-this.minV);var t=Math.round(e*this.n);return t==this.n?t-=1:t,this.lut[t]},addColorMap:function(e,t){lv[e]=t},setLegendOn:function(e){var t=this;void 0===e&&(e={}),this.legend={},this.legend.layout=e.hasOwnProperty("layout")?e.layout:"vertical",this.legend.position=e.hasOwnProperty("position")?e.position:{x:4,y:0,z:0},this.legend.dimensions=e.hasOwnProperty("dimensions")?e.dimensions:{width:.5,height:3},this.legend.canvas=document.createElement("canvas"),this.legend.canvas.setAttribute("id","legend"),this.legend.canvas.setAttribute("hidden",!0),document.body.appendChild(this.legend.canvas),this.legend.ctx=this.legend.canvas.getContext("2d"),this.legend.canvas.setAttribute("width",1),this.legend.canvas.setAttribute("height",this.n),this.legend.texture=new ve(this.legend.canvas);var r=this.legend.ctx.getImageData(0,0,1,this.n),i=r.data;this.map=lv[this.mapname];for(var n=0,a=1/this.n,o=1;o>=0;o-=a)for(var s=this.map.length-1;s>=0;s--)if(o=t.map[s-1][0]){var l=t.map[s-1][0],c=t.map[s][0],h=new u(16777215).setHex(t.map[s-1][1]),d=new u(16777215).setHex(t.map[s][1]),p=h.lerp(d,(o-l)/(c-l));i[4*n]=Math.round(255*p.r),i[4*n+1]=Math.round(255*p.g),i[4*n+2]=Math.round(255*p.b),i[4*n+3]=255,n+=1}return this.legend.ctx.putImageData(r,0,0),this.legend.texture.needsUpdate=!0,this.legend.legendGeometry=new xe(this.legend.dimensions.width,this.legend.dimensions.height),this.legend.legendMaterial=new F({map:this.legend.texture,side:Ks}),this.legend.mesh=new k(this.legend.legendGeometry,this.legend.legendMaterial),"horizontal"==this.legend.layout&&(this.legend.mesh.rotation.z=-90*(Math.PI/180)),this.legend.mesh.position.copy(this.legend.position),this.legend.mesh},setLegendOff:function(){return this.legend=null,this.legend},setLegendLayout:function(e){return!!this.legend&&(this.legend.layout!=e&&(("horizontal"==e||"vertical"==e)&&(this.layout=e,"horizontal"==e&&(this.legend.mesh.rotation.z=90*(Math.PI/180)),"vertical"==e&&(this.legend.mesh.rotation.z=-90*(Math.PI/180)),this.legend.mesh)))},setLegendPosition:function(e){return this.legend.position=new i(e.x,e.y,e.z),this.legend},setLegendLabels:function(e,t){var r=this;if(!this.legend)return!1;"function"==typeof e&&(t=e),void 0===e&&(e={}),this.legend.labels={},this.legend.labels.fontsize=e.hasOwnProperty("fontsize")?e.fontsize:24,this.legend.labels.fontface=e.hasOwnProperty("fontface")?e.fontface:"Arial",this.legend.labels.title=e.hasOwnProperty("title")?e.title:"",this.legend.labels.um=e.hasOwnProperty("um")?" [ "+e.um+" ]":"",this.legend.labels.ticks=e.hasOwnProperty("ticks")?e.ticks:0,this.legend.labels.decimal=e.hasOwnProperty("decimal")?e.decimal:2,this.legend.labels.notation=e.hasOwnProperty("notation")?e.notation:"standard";var n={r:255,g:100,b:100,a:.8},a={r:255,g:0,b:0,a:1},o=4,s=document.createElement("canvas"),l=s.getContext("2d");l.font="Normal "+1.2*this.legend.labels.fontsize+"px "+this.legend.labels.fontface,l.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",l.strokeStyle="rgba("+a.r+","+a.g+","+a.b+","+a.a+")",l.lineWidth=o,l.fillStyle="rgba( 0, 0, 0, 1.0 )",l.fillText(this.legend.labels.title.toString()+this.legend.labels.um.toString(),o,this.legend.labels.fontsize+o);var c=new mi(s);c.minFilter=rc;var u=new Fe({map:c}),h=new vi(u);if(h.scale.set(2,1,1),"vertical"==this.legend.layout&&h.position.set(this.legend.position.x+this.legend.dimensions.width,this.legend.position.y+.45*this.legend.dimensions.height,this.legend.position.z),"horizontal"==this.legend.layout&&h.position.set(1.015*this.legend.position.x,this.legend.position.y+.03*this.legend.dimensions.height,this.legend.position.z),this.legend.labels.ticks>0){var d={},p={};if("vertical"==this.legend.layout)var f=this.legend.position.y+.36*this.legend.dimensions.height,m=this.legend.position.y-.61*this.legend.dimensions.height;if("horizontal"==this.legend.layout)var v=this.legend.position.x+.75*this.legend.dimensions.height,g=this.legend.position.x-1.2*this.legend.dimensions.width;for(var y=0;y5)if(y%2===0)var T=1.7;else var T=2.1;else var T=1.7;A.position.set(M,r.legend.position.y-r.legend.dimensions.width*T,r.legend.position.z)}var E=new R({color:0,linewidth:2}),C=[];if("vertical"==r.legend.layout){var L=r.legend.position.y-.5*r.legend.dimensions.height+.01+r.legend.dimensions.height*((x-r.minV)/(r.maxV-r.minV)*.99);C.push(new i(r.legend.position.x+.55*r.legend.dimensions.width,L,r.legend.position.z)),C.push(new i(r.legend.position.x+.7*r.legend.dimensions.width,L,r.legend.position.z))}if("horizontal"==r.legend.layout){var L=r.legend.position.x-.5*r.legend.dimensions.height+.01+r.legend.dimensions.height*((x-r.minV)/(r.maxV-r.minV)*.99);C.push(new i(L,r.legend.position.y-.55*r.legend.dimensions.width,r.legend.position.z)),C.push(new i(L,r.legend.position.y-.7*r.legend.dimensions.width,r.legend.position.z))}var N=(new P).setFromPoints(C),O=new B(N,E);p[y]=O,d[y]=A}}return{title:h,ticks:d,lines:p}}};var lv={rainbow:[[0,"0x0000FF"],[.2,"0x00FFFF"],[.5,"0x00FF00"],[.8,"0xFFFF00"],[1,"0xFF0000"]],cooltowarm:[[0,"0x3C4EC2"],[.2,"0x9BBCFF"],[.5,"0xDCDCDC"],[.8,"0xF6A385"],[1,"0xB40426"]],blackbody:[[0,"0x000000"],[.2,"0x780000"],[.5,"0xE63200"],[.8,"0xFFFF00"],[1,"0xFFFFFF"]],grayscale:[[0,"0x000000"],[.2,"0x404040"],[.5,"0x7F7F80"],[.8,"0xBFBFBF"],[1,"0xFFFFFF"]]},cv=function(){function e(e,t){for(var i=new Ue,n=[],a=0;a1){var l=s[1];n[l]||(n[l]={start:1/0,end:-(1/0)});var c=n[l];ac.end&&(c.end=a),t||(t=l)}a++}for(var l in n){var c=n[l];r.createAnimation(l,c.start,c.end,e)}this.firstAnimation=t},setAnimationDirectionForward:function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},setAnimationDirectionBackward:function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},setAnimationFPS:function(e,t){var r=this.animationsMap[e];r&&(r.fps=t,r.duration=(r.end-r.start)/r.fps)},setAnimationDuration:function(e,t){var r=this.animationsMap[e];r&&(r.duration=t,r.fps=(r.end-r.start)/r.duration)},setAnimationWeight:function(e,t){var r=this.animationsMap[e];r&&(r.weight=t)},setAnimationTime:function(e,t){var r=this.animationsMap[e];r&&(r.time=t)},getAnimationTime:function(e){var t=0,r=this.animationsMap[e];return r&&(t=r.time),t},getAnimationDuration:function(e){var t=-1,r=this.animationsMap[e];return r&&(t=r.duration),t},playAnimation:function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},stopAnimation:function(e){var t=this.animationsMap[e];t&&(t.active=!1)},update:function(e){for(var t=this,r=0,i=this.animationsList.length;rn.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var o=n.start+Fs.clamp(Math.floor(n.time/a),0,n.length-1),s=n.weight;o!==n.currentFrame&&(t.morphTargetInfluences[n.lastFrame]=0,t.morphTargetInfluences[n.currentFrame]=1*s,t.morphTargetInfluences[o]=0,n.lastFrame=n.currentFrame,n.currentFrame=o);var l=n.time%a/a;n.directionBackwards&&(l=1-l),n.currentFrame!==n.lastFrame?(t.morphTargetInfluences[n.currentFrame]=l*s,t.morphTargetInfluences[n.lastFrame]=(1-l)*s):t.morphTargetInfluences[n.currentFrame]=s}}}});var hv=function(){function e(e,t){for(var i=new Ue,n=[],a=0;a0&&(t=(this.transitionFrames-this.blendCounter)/this.transitionFrames,this.blendCounter-=1),this.meshBody&&(this.meshBody.update(e),this.meshBody.setAnimationWeight(this.activeAnimation,t),this.meshBody.setAnimationWeight(this.oldAnimation,1-t)),this.meshWeapon&&(this.meshWeapon.update(e),this.meshWeapon.setAnimationWeight(this.activeAnimation,t),this.meshWeapon.setAnimationWeight(this.oldAnimation,1-t))},this.updateBehaviors=function(e){var t,r,i=this.controls,n=this.animations;i.crouch?(t=n.crouchMove,r=n.crouchIdle):(t=n.move,r=n.idle),i.jump&&(t=n.jump,r=n.jump),i.attack&&(i.crouch?(t=n.crouchAttack,r=n.crouchAttack):(t=n.attack,r=n.attack)),(i.moveForward||i.moveBackward||i.moveLeft||i.moveRight)&&this.activeAnimation!==t&&this.setAnimation(t),Math.abs(this.speed)<.2*this.maxSpeed&&!(i.moveLeft||i.moveRight||i.moveForward||i.moveBackward)&&this.activeAnimation!==r&&this.setAnimation(r),i.moveForward&&(this.meshBody&&(this.meshBody.setAnimationDirectionForward(this.activeAnimation),this.meshBody.setAnimationDirectionForward(this.oldAnimation)),this.meshWeapon&&(this.meshWeapon.setAnimationDirectionForward(this.activeAnimation),this.meshWeapon.setAnimationDirectionForward(this.oldAnimation))),i.moveBackward&&(this.meshBody&&(this.meshBody.setAnimationDirectionBackward(this.activeAnimation),this.meshBody.setAnimationDirectionBackward(this.oldAnimation)),this.meshWeapon&&(this.meshWeapon.setAnimationDirectionBackward(this.activeAnimation),this.meshWeapon.setAnimationDirectionBackward(this.oldAnimation)))},this.updateMovementModel=function(e){var t=this.controls;t.crouch?this.maxSpeed=this.crouchSpeed:this.maxSpeed=this.walkSpeed,this.maxReverseSpeed=-this.maxSpeed,t.moveForward&&(this.speed=Fs.clamp(this.speed+e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),t.moveBackward&&(this.speed=Fs.clamp(this.speed-e*this.backAcceleration,this.maxReverseSpeed,this.maxSpeed));var r=1;if(t.moveLeft&&(this.bodyOrientation+=e*this.angularSpeed,this.speed=Fs.clamp(this.speed+r*e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),t.moveRight&&(this.bodyOrientation-=e*this.angularSpeed,this.speed=Fs.clamp(this.speed+r*e*this.frontAcceleration,this.maxReverseSpeed,this.maxSpeed)),!t.moveForward&&!t.moveBackward)if(this.speed>0){var n=i(this.speed/this.maxSpeed);this.speed=Fs.clamp(this.speed-n*e*this.frontDecceleration,0,this.maxSpeed)}else{var n=i(this.speed/this.maxReverseSpeed);this.speed=Fs.clamp(this.speed+n*e*this.backAcceleration,this.maxReverseSpeed,0)}var a=this.speed*e;this.root.position.x+=Math.sin(this.bodyOrientation)*a,this.root.position.z+=Math.cos(this.bodyOrientation)*a,this.root.rotation.y=this.bodyOrientation}},dv=function(){};dv.prototype.modify=function(e){for(var t=[],r=0,i=e.faces.length;r-1&&e.splice(r,1)}function r(e,t){var r,i,n,a=t.position.distanceTo(e.position),o=0,s=[],l=e.faces.length;for(r=0;r=0;s--)r.faces[s].hasVertex(i)&&o(r.faces[s],t);for(s=r.faces.length-1;s>=0;s--)r.faces[s].replaceVertex(r,i);for(a(r,e),s=0;s0;)t.smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e},function(){function e(e,t,r){var i=Math.min(e,t),n=Math.max(e,t),a=i+"_"+n;return r[a]}function t(e,t,r,i,n,a){var o,s=Math.min(e,t),l=Math.max(e,t),c=s+"_"+l;if(c in i)o=i[c];else{var u=r[s],h=r[l];o={a:u,b:h,newEdge:null,faces:[]},i[c]=o}o.faces.push(n),a[e].edges.push(o),a[t].edges.push(o)}function r(e,r,i,n){var a,o,s;for(a=0,o=e.length;a0;x=new Array(l.length),b={},r(l,c,x,b),w=[];var T,E,C,L,P,N,O;for(m in b){for(E=b[m],C=new i,P=3/8,N=1/8,O=E.faces.length,2!=O&&(P=.5,N=0),C.addVectors(E.a,E.b).multiplyScalar(P),S.set(0,0,0),g=0;g3&&(D=3/(8*p)),F=1-p*D,R=D,p<=2&&2==p&&(F=.75,R=1/8),B=k.clone().multiplyScalar(F),S.set(0,0,0),g=0;gn||v>n||g>n){var y=e.vertices.length,x=s.clone(),b=s.clone();if(m>=v&&m>=g){var w=d.clone();if(w.lerp(p,.5),x.a=l,x.b=y,x.c=u,b.a=y,b.b=c,b.c=u,3===s.vertexNormals.length){var _=s.vertexNormals[0].clone();_.lerp(s.vertexNormals[1],.5),x.vertexNormals[1].copy(_),b.vertexNormals[0].copy(_)}if(3===s.vertexColors.length){var S=s.vertexColors[0].clone();S.lerp(s.vertexColors[1],.5),x.vertexColors[1].copy(S),b.vertexColors[0].copy(S)}t=0}else if(v>=m&&v>=g){var w=p.clone();if(w.lerp(f,.5),x.a=l,x.b=c,x.c=y,b.a=y,b.b=u,b.c=l,3===s.vertexNormals.length){var _=s.vertexNormals[1].clone();_.lerp(s.vertexNormals[2],.5),x.vertexNormals[2].copy(_),b.vertexNormals[0].copy(_),b.vertexNormals[1].copy(s.vertexNormals[2]),b.vertexNormals[2].copy(s.vertexNormals[0])}if(3===s.vertexColors.length){var S=s.vertexColors[1].clone();S.lerp(s.vertexColors[2],.5),x.vertexColors[2].copy(S),b.vertexColors[0].copy(S),b.vertexColors[1].copy(s.vertexColors[2]),b.vertexColors[2].copy(s.vertexColors[0])}t=1}else{var w=d.clone();if(w.lerp(f,.5),x.a=l,x.b=c,x.c=y,b.a=y,b.b=c,b.c=u,3===s.vertexNormals.length){var _=s.vertexNormals[0].clone();_.lerp(s.vertexNormals[2],.5),x.vertexNormals[2].copy(_),b.vertexNormals[0].copy(_)}if(3===s.vertexColors.length){var S=s.vertexColors[0].clone();S.lerp(s.vertexColors[2],.5),x.vertexColors[2].copy(S),b.vertexColors[0].copy(S)}t=2}r.push(x,b),e.vertices.push(w);for(var A=0,M=e.faceVertexUvs.length;A absDirection.z ) {","\t\tif(absDirection.x > absDirection.y )","\t\t\tface = direction.x > 0.0 ? 0 : 3;","\t\telse","\t\t\tface = direction.y > 0.0 ? 1 : 4;","\t}","\telse {","\t\tif(absDirection.z > absDirection.y )","\t\t\tface = direction.z > 0.0 ? 2 : 5;","\t\telse","\t\t\tface = direction.y > 0.0 ? 1 : 4;","\t}","\treturn face;","}"].join("\n")),r=new lr("#define cubeUV_maxLods1 ( log2( cubeUV_textureSize * 0.25 ) - 1.0 )"),i=new lr("#define cubeUV_rangeClamp ( exp2( ( 6.0 - 1.0 ) * 2.0 ) )"),n=new Vf(["vec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness, in float cubeUV_textureSize ) {","\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);","\tfloat dxRoughness = dFdx(roughness);","\tfloat dyRoughness = dFdy(roughness);","\tvec3 dx = dFdx( vec * scale * dxRoughness );","\tvec3 dy = dFdy( vec * scale * dyRoughness );","\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );","\td = clamp(d, 1.0, cubeUV_rangeClamp);","\tfloat mipLevel = 0.5 * log2(d);","\treturn vec2(floor(mipLevel), fract(mipLevel));","}"].join("\n"),[r,i],{derivatives:!0}),a=new lr("#define cubeUV_maxLods2 ( log2( cubeUV_textureSize * 0.25 ) - 2.0 )"),o=new lr("#define cubeUV_rcpTextureSize ( 1.0 / cubeUV_textureSize )"),s=new Vf(["vec2 getCubeUV( vec3 direction, float roughnessLevel, float mipLevel, in float cubeUV_textureSize ) {","\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;","\tfloat a = 16.0 * cubeUV_rcpTextureSize;","","\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );","\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;","\tfloat powScale = exp2_packed.x * exp2_packed.y;","\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;","\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;","","\tbool bRes = mipLevel == 0.0;","\tscale = bRes && (scale < a) ? a : scale;","","\tvec3 r;","\tvec2 offset;","\tint face = getFaceFromDirection(direction);","","\tfloat rcpPowScale = 1.0 / powScale;","","\tif( face == 0) {","\t\tr = vec3(direction.x, -direction.z, direction.y);","\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 1) {","\t\tr = vec3(direction.y, direction.x, direction.z);","\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 2) {","\t\tr = vec3(direction.z, direction.x, direction.y);","\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;","\t}","\telse if( face == 3) {","\t\tr = vec3(direction.x, direction.z, direction.y);","\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\telse if( face == 4) {","\t\tr = vec3(direction.y, direction.x, -direction.z);","\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\telse {","\t\tr = vec3(direction.z, -direction.x, direction.y);","\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);","\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;","\t}","\tr = normalize(r);","\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;","\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;","\tvec2 base = offset + vec2( texelOffset );","\treturn base + s * ( scale - 2.0 * texelOffset );","}"].join("\n"),[a,o,t]),l=new lr("#define cubeUV_maxLods3 ( log2( cubeUV_textureSize * 0.25 ) - 3.0 )"),c=new Vf(["TextureCubeUVData textureCubeUV( vec3 reflectedDirection, float roughness, in float cubeUV_textureSize ) {","\tfloat roughnessVal = roughness * cubeUV_maxLods3;","\tfloat r1 = floor(roughnessVal);","\tfloat r2 = r1 + 1.0;","\tfloat t = fract(roughnessVal);","\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness, cubeUV_textureSize);","\tfloat s = mipInfo.y;","\tfloat level0 = mipInfo.x;","\tfloat level1 = level0 + 1.0;","\tlevel1 = level1 > 5.0 ? 5.0 : level1;","","\tlevel0 += min( floor( s + 0.5 ), 5.0 );","","\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0, cubeUV_textureSize);","\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0, cubeUV_textureSize);","","\treturn TextureCubeUVData(uv_10, uv_20, t);","}"].join("\n"),[e,l,n,s]);return{TextureCubeUVData:e,textureCubeUV:c}}(),Li.prototype=Object.create(tr.prototype),Li.prototype.constructor=Li,Li.prototype.nodeType="TextureCubeUV",Li.prototype.generate=function(e,t){if(e.isShader("fragment")){var r=e.include(Li.Nodes.textureCubeUV);return e.format(r+"( "+this.uv.build(e,"v3")+", "+this.blinnExponentToRoughness.build(e,"f")+", "+this.textureSize.build(e,"f")+" )",this.getType(e),t)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)},Li.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.blinnExponentToRoughness=this.blinnExponentToRoughness.toJSON(e).uuid),t},Pi.prototype=Object.create(tr.prototype),Pi.prototype.constructor=Pi,Pi.prototype.nodeType="TextureCube",Pi.prototype.generate=function(e,t){if(e.isShader("fragment")){var r=this.uv.build(e)+".uv_10",i=this.uv.build(e)+".uv_20",n=this.uv.build(e)+".t",a=e.getTexelDecodingFunctionFromTexture("texture2D( "+this.value.build(e,"sampler2D")+", "+r+" )",this.value.value),o=e.getTexelDecodingFunctionFromTexture("texture2D( "+this.value.build(e,"sampler2D")+", "+i+" )",this.value.value);return e.format("vec4( mix( "+a+", "+o+", "+n+" ).rgb, 1.0 )",this.getType(e),t)}return console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)},Pi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.blinnExponentToRoughness=this.blinnExponentToRoughness.toJSON(e).uuid,this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid)),t};var _v=xv.elements,Sv=["float","vec2","vec3","vec4"],Av={"float":"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4","int":"i"},Mv={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4"};Ni.prototype={constructor:Ni,build:function(e,t){return this.buildShader("vertex",e),this.buildShader("fragment",t),this.requires.uv[0]&&(this.addVaryCode("varying vec2 vUv;"),this.addVertexFinalCode("vUv = uv;")),this.requires.uv[1]&&(this.addVaryCode("varying vec2 vUv2;"),this.addVertexParsCode("attribute vec2 uv2;"),this.addVertexFinalCode("vUv2 = uv2;")),this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;")),this},buildShader:function(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")},setMaterial:function(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this},addFlow:function(e,t,r){return this.addSlot(e).addCache(t).addContext(r)},removeFlow:function(){return this.removeSlot().removeCache().removeContext()},addCache:function(e){return this.cache=e||"",this.caches.push(this.cache),this},removeCache:function(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this},addContext:function(e){return this.context=Object.assign({},this.context,e),this.contexts.push(this.context),this},removeContext:function(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this},addSlot:function(e){return this.slot=e||"",this.slots.push(this.slot),this},removeSlot:function(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this},addVertexCode:function(e){this.addCode(e,"vertex")},addFragmentCode:function(e){this.addCode(e,"fragment")},addCode:function(e,t){this.code[t||this.shader]+=e+"\n"},addVertexNodeCode:function(e){this.addNodeCode(e,"vertex")},addFragmentNodeCode:function(e){this.addNodeCode(e,"fragment")},addNodeCode:function(e,t){this.nodeCode[t||this.shader]+=e+"\n"},clearNodeCode:function(e){e=e||this.shader;var t=this.nodeCode[e];return this.nodeCode[e]="",t},clearVertexNodeCode:function(){return this.clearNodeCode("vertex")},clearFragmentNodeCode:function(){return this.clearNodeCode("fragment")},addVertexFinalCode:function(e){this.addFinalCode(e,"vertex")},addFragmentFinalCode:function(e){this.addFinalCode(e,"fragment")},addFinalCode:function(e,t){this.finalCode[t||this.shader]+=e+"\n"},addVertexParsCode:function(e){this.addParsCode(e,"vertex")},addFragmentParsCode:function(e){this.addParsCode(e,"fragment")},addParsCode:function(e,t){this.parsCode[t||this.shader]+=e+"\n"},addVaryCode:function(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)},isCache:function(e){return this.caches.indexOf(e)!==-1},isSlot:function(e){return this.slots.indexOf(e)!==-1},define:function(e,t){this.defines[e]=void 0===t?1:t},isDefined:function(e){return void 0!==this.defines[e]},getVar:function(e,t,r,i){i=i||"varying";var n=this.getVars(i),a=n[e];if(!a){var o=n.length,s=r?r:"nVv"+o;a={name:s,type:t},n.push(a),n[e]=a}return a},getTempVar:function(e,t,r){return this.getVar(e,t,r,this.shader)},getAttribute:function(e,t){if(!this.attributes[e]){var r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]},getCode:function(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")},getVarListCode:function(e,t){var r=this;t=t||"";for(var i="",n=0,a=e.length;nal,this.needsUpdate=!1,this},Fi.prototype.copy=function(e){var t=this,r=this.uuid;for(var i in e)t[i]=e[i];this.uuid=r,void 0!==e.userData&&(this.userData=JSON.parse(JSON.stringify(e.userData)))},Fi.prototype.toJSON=function(e){var t=void 0===e||"string"==typeof e;if(t&&(e={nodes:{}}),e&&!e.materials&&(e.materials={}),!e.materials[this.uuid]){var r={};r.uuid=this.uuid,r.type=this.type,e.materials[r.uuid]=r,""!==this.name&&(r.name=this.name),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==al&&(r.blending=this.blending),this.flatShading===!0&&(r.flatShading=this.flatShading),this.side!==Js&&(r.side=this.side),this.vertexColors!==tl&&(r.vertexColors=this.vertexColors),this.depthFunc!==Ll&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.morphTargets===!0&&(r.morphTargets=!0),this.skinning===!0&&(r.skinning=!0),this.visible===!1&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.fog=this.fog,r.lights=this.lights,r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid}return e.material=this.uuid,e},Ri.prototype=Object.create(ar.prototype),Ri.prototype.constructor=Ri,Ri.prototype.nodeType="Vector2",xv.addShortcuts(Ri.prototype,"value",["x","y"]),Ri.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("vec2( "+this.x+", "+this.y+" )",i,t)},Ri.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.copy(e)},Ri.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.x,t.y=this.y,this.readonly===!0&&(t.readonly=!0)),t},Ii.prototype=Object.create(Ri.prototype),Ii.prototype.constructor=Ii,Ii.prototype.nodeType="Resolution",Ii.prototype.updateFrame=function(e){if(e.renderer){var t=e.renderer.getSize(),r=e.renderer.getPixelRatio();this.x=t.width*r,this.y=t.height*r}else console.warn("ResolutionNode need a renderer in NodeFrame")},Ii.prototype.copy=function(e){Ri.prototype.copy.call(this,e),this.renderer=e.renderer},Ii.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.renderer=this.renderer.uuid),t},Ui.prototype=Object.create(tr.prototype),Ui.prototype.constructor=Ui,Ui.prototype.nodeType="ScreenUV",Ui.prototype.generate=function(e,t){var r;return e.isShader("fragment")?r="( gl_FragCoord.xy / "+this.resolution.build(e,"v2")+")":(console.warn("ScreenUVNode is not compatible with "+e.shader+" shader."),r="vec2( 0.0 )"),e.format(r,this.getType(e),t)},Ui.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.resolution=e.resolution},Ui.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.resolution=this.resolution.toJSON(e).uuid),t},ki.prototype=Object.create(or.prototype),ki.prototype.constructor=ki,ki.prototype.nodeType="MaxMIPLevel",Object.defineProperties(ki.prototype,{value:{get:function(){if(0===this.maxMIPLevel){var e=this.texture.value.image?this.texture.value.image[0]:void 0;this.maxMIPLevel=void 0!==e?Math.log(Math.max(e.width,e.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}}),ki.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.uuid),t},Bi.Nodes=function(){var e=new Vf(["float getSpecularMIPLevel( const in float blinnShininessExponent, const in float maxMIPLevelScalar ) {","\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );","\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join("\n"));return{getSpecularMIPLevel:e}}(),Bi.prototype=Object.create(tr.prototype),Bi.prototype.constructor=Bi,Bi.prototype.nodeType="RoughnessToBlinnExponent",Bi.prototype.generate=function(e,t){if(e.isShader("fragment")){ this.maxMIPLevel.texture=this.texture;var r=e.include(Bi.Nodes.getSpecularMIPLevel);return e.format(r+"( "+this.blinnShininessExponent.build(e,"f")+", "+this.maxMIPLevel.build(e,"f")+" )",this.type,t)}return console.warn("RoughnessToBlinnExponentNode is not compatible with "+e.shader+" shader."),e.format("0.0",this.type,t)},Bi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.texture=e.texture},Bi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture),t},zi.prototype=Object.create(er.prototype),zi.prototype.constructor=zi,zi.prototype.nodeType="Attribute",zi.prototype.getAttributeType=function(e){return"number"==typeof this.type?e.getConstructorFromLength(this.type):this.type},zi.prototype.getType=function(e){var t=this.getAttributeType(e);return e.getTypeByFormat(t)},zi.prototype.generate=function(e,t){var r=this.getAttributeType(e),i=e.getAttribute(this.name,r),n=e.isShader("vertex")?this.name:i.varying.name;return console.log(i),e.format(n,this.getType(e),t)},zi.prototype.copy=function(e){er.prototype.copy.call(this,e),this.type=e.type},zi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.type=this.type),t},ji.prototype=Object.create(Vf.prototype),ji.prototype.constructor=ji,ji.prototype.nodeType="Expression",Vi.prototype=Object.create(tr.prototype),Vi.prototype.constructor=Vi,Vi.prototype.nodeType="FunctionCall",Vi.prototype.setFunction=function(e,t){this.value=e,this.inputs=t||[]},Vi.prototype.getFunction=function(){return this.value},Vi.prototype.getType=function(e){return this.value.getType(e)},Vi.prototype.generate=function(e,t){for(var r=this,i=this.getType(e),n=this.value,a=n.build(e,t)+"( ",o=[],s=0;se.getTypeLength(t)?r:t},Ki.prototype.generate=function(e,t){var r=(e.getNodeData(this),this.getType(e)),i=this.a.build(e,r),n=this.b.build(e,r);return e.format("( "+i+" "+this.op+" "+n+" )",r,t)},Ki.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.a=e.a,this.b=e.b,this.op=e.op},Ki.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op),t},$i.prototype=Object.create(tr.prototype),$i.prototype.constructor=$i,$i.prototype.nodeType="Reflector",$i.prototype.setMirror=function(e){this.mirror=e,this.textureMatrix=new Ji(this.mirror.material.uniforms.textureMatrix.value),this.localPosition=new ir(ir.LOCAL),this.uv=new Ki(this.textureMatrix,this.localPosition,Ki.MUL),this.uvResult=new Ki(null,this.uv,Ki.ADD),this.texture=new Mi(this.mirror.material.uniforms.tDiffuse.value,this.uv,null,(!0))},$i.prototype.generate=function(e,t){return e.isShader("fragment")?(this.uvResult.a=this.offset,this.texture.uv=this.offset?this.uvResult:this.uv,"sampler2D"===t?this.texture.build(e,t):e.format(this.texture.build(e,this.type),this.type,t)):(console.warn("ReflectorNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.type,t))},$i.prototype.copy=function(e){InputNode.prototype.copy.call(this,e),this.scope.mirror=e.mirror},$i.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.mirror=this.mirror.uuid,this.offset&&(t.offset=this.offset.toJSON(e).uuid)),t},en.prototype=Object.create(Mi.prototype),en.prototype.constructor=en,en.prototype.nodeType="RTT",en.prototype.build=function(e,t,r){var i=new Ni;return i.nodes=e.nodes,i.updaters=e.updaters,this.material.fragment.value=this.input,this.material.build({builder:i}),Mi.prototype.build.call(this,e,t,r)},en.prototype.updateFramesaveTo=function(e){if(this.saveTo.render=!1,this.saveTo!==this.saveToCurrent){this.saveToMaterial&&this.saveToMaterial.dispose();var t=new Fi;t.fragment.value=this,t.build();var r=new fe,i=new k(new xe(2,2),t);i.frustumCulled=!1,r.add(i),this.saveToScene=r,this.saveToMaterial=t}this.saveToCurrent=this.saveTo,e.renderer.render(this.saveToScene,this.camera,this.saveTo.renderTarget,this.saveTo.clear)},en.prototype.updateFrame=function(e){e.renderer?(this.saveTo&&this.saveTo.render===!1&&this.updateFramesaveTo(e),this.render&&(this.material.uniforms.renderTexture&&(this.material.uniforms.renderTexture.value=e.renderTexture),e.renderer.render(this.scene,this.camera,this.renderTarget,this.clear)),this.saveTo&&this.saveTo.render===!0&&this.updateFramesaveTo(e)):console.warn("RTTNode need a renderer in NodeFrame")},en.prototype.copy=function(e){Mi.prototype.copy.call(this,e),this.saveTo=e.saveTo},en.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=Mi.prototype.toJSON.call(this,e),this.saveTo&&(t.saveTo=this.saveTo.toJSON(e).uuid)),t},tn.prototype=Object.create(Mi.prototype),tn.prototype.constructor=tn,tn.prototype.nodeType="Screen",tn.prototype.isUnique=function(){return!0},tn.prototype.getTexture=function(e,t){return ar.prototype.generate.call(this,e,t,this.getUuid(),"t","renderTexture")},rn.prototype=Object.create(er.prototype),rn.prototype.constructor=rn,rn.prototype.nodeType="Standard",rn.prototype.build=function(e){var t;if(e.define(this.clearCoat||this.clearCoatRoughness?"PHYSICAL":"STANDARD"),e.requires.lights=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){var r=this.position?this.position.parseAndBuildCode(e,"v3",{cache:"position"}):void 0;e.mergeUniform(Mu.merge([mp.fog,mp.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include ","#include ","#include ","#include ","#include ","#include "].join("\n"));var i=["#include ","#include ","#include ","#include ","#include ","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","#include "];r&&i.push(r.code,r.result?"transformed = "+r.result+";":""),i.push("#include ","#include ","#include ","#include ","#include ","#include ","\tvViewPosition = - mvPosition.xyz;","#include ","#include "),t=i.join("\n")}else{var n={bias:Bi,gamma:!0},a={gamma:!0},o=!e.isDefined("STANDARD");this.color.parse(e,{slot:"color",context:a}),this.roughness.parse(e),this.metalness.parse(e),this.alpha&&this.alpha.parse(e),this.normal&&this.normal.parse(e),this.clearCoat&&this.clearCoat.parse(e),this.clearCoatRoughness&&this.clearCoatRoughness.parse(e),this.reflectivity&&this.reflectivity.parse(e),this.light&&this.light.parse(e,{cache:"light"}),this.ao&&this.ao.parse(e),this.ambient&&this.ambient.parse(e),this.shadow&&this.shadow.parse(e),this.emissive&&this.emissive.parse(e,{slot:"emissive"}),this.environment&&this.environment.parse(e,{cache:"env",context:n,slot:"environment"});var s=this.color.buildCode(e,"c",{slot:"color",context:a}),l=this.roughness.buildCode(e,"f"),c=this.metalness.buildCode(e,"f"),u=this.alpha?this.alpha.buildCode(e,"f"):void 0,h=this.normal?this.normal.buildCode(e,"v3"):void 0,d=this.clearCoat?this.clearCoat.buildCode(e,"f"):void 0,p=this.clearCoatRoughness?this.clearCoatRoughness.buildCode(e,"f"):void 0,f=this.reflectivity?this.reflectivity.buildCode(e,"f"):void 0,m=this.light?this.light.buildCode(e,"v3",{cache:"light"}):void 0,v=this.ao?this.ao.buildCode(e,"f"):void 0,g=this.ambient?this.ambient.buildCode(e,"c"):void 0,y=this.shadow?this.shadow.buildCode(e,"c"):void 0,x=this.emissive?this.emissive.buildCode(e,"c",{slot:"emissive"}):void 0,b=this.environment?this.environment.buildCode(e,"c",{cache:"env",context:n,slot:"environment"}):void 0,w=o&&b?this.environment.buildCode(e,"c",{cache:"clearCoat",context:n,slot:"environment"}):void 0;e.requires.transparent=void 0!==u,e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join("\n"));var i=["#include ","\t#include ","\tPhysicalMaterial material;","\tmaterial.diffuseColor = vec3( 1.0 );",s.code,"\tvec3 diffuseColor = "+s.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include ",l.code,"\tfloat roughnessFactor = "+l.result+";",c.code,"\tfloat metalnessFactor = "+c.result+";"];u&&i.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),h&&i.push(h.code,"normal = "+h.result+";"),i.push("material.diffuseColor = "+(m?"vec3( 1.0 )":"diffuseColor * (1.0 - metalnessFactor)")+";","material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );"),d?i.push(d.code,"material.clearCoat = saturate( "+d.result+" );"):o&&i.push("material.clearCoat = 0.0;"),p?i.push(p.code,"material.clearCoatRoughness = clamp( "+p.result+", 0.04, 1.0 );"):o&&i.push("material.clearCoatRoughness = 0.0;"),f?i.push(f.code,"material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( "+f.result+" ) ), diffuseColor, metalnessFactor );"):i.push("material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor, metalnessFactor );"),i.push("#include "),m&&(i.push(m.code,"reflectedLight.directDiffuse = "+m.result+";"),i.push("diffuseColor *= 1.0 - metalnessFactor;","reflectedLight.directDiffuse *= diffuseColor;","reflectedLight.indirectDiffuse *= diffuseColor;")),v&&i.push(v.code,"reflectedLight.indirectDiffuse *= "+v.result+";","float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );","reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, "+v.result+", material.specularRoughness );"),g&&i.push(g.code,"reflectedLight.indirectDiffuse += "+g.result+";"),y&&i.push(y.code,"reflectedLight.directDiffuse *= "+y.result+";","reflectedLight.directSpecular *= "+y.result+";"),x&&i.push(x.code,"reflectedLight.directDiffuse += "+x.result+";"),b&&(i.push(b.code),w&&i.push(w.code,"clearCoatRadiance += "+w.result+";"),i.push("radiance += "+b.result+";")),i.push("#include "),i.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),u?i.push("gl_FragColor = vec4( outgoingLight, "+u.result+" );"):i.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),i.push("#include ","#include ","#include ","#include ","#include "),t=i.join("\n")}return t},rn.prototype.copy=function(e){er.prototype.copy.call(this,e),e.position&&(this.position=e.position),this.color=e.color,this.roughness=e.roughness,this.metalness=e.metalness,e.alpha&&(this.alpha=e.alpha),e.normal&&(this.normal=e.normal),e.clearCoat&&(this.clearCoat=e.clearCoat),e.clearCoatRoughness&&(this.clearCoatRoughness=e.clearCoatRoughness),e.reflectivity&&(this.reflectivity=e.reflectivity),e.light&&(this.light=e.light),e.shadow&&(this.shadow=e.shadow),e.ao&&(this.ao=e.ao),e.emissive&&(this.emissive=e.emissive),e.ambient&&(this.ambient=e.ambient),e.environment&&(this.environment=e.environment)},rn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),t.color=this.color.toJSON(e).uuid,t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.clearCoat&&(t.clearCoat=this.clearCoat.toJSON(e).uuid),this.clearCoatRoughness&&(t.clearCoatRoughness=this.clearCoatRoughness.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid)),t},nn.prototype=Object.create(er.prototype),nn.prototype.constructor=nn,nn.prototype.nodeType="Switch",nn.prototype.getType=function(e){return e.getTypeFromLength(this.components.length)},nn.prototype.generate=function(e,t){var r=this.node.getType(e),i=this.node.build(e,r),n=e.getTypeLength(r)-1;if(n>0){var a,o=0,s=e.colorToVectorProperties(this.components),l=s.length;for(a=0;an&&(o=n),i+=".",a=0;ao&&(c=o),i+=e.getElementByIndex(c)}return e.format(i,this.getType(e),t)}return e.format(i,r,t)},nn.prototype.copy=function(e){er.prototype.copy.call(this,e),this.node=e.node,this.components=e.components},nn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.node=this.node.toJSON(e).uuid,t.components=this.components),t},an.Nodes=function(){var e=new Vf(["vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, vec2 normalScale ) {","\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );","\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );","\tvec2 st0 = dFdx( mUv.st );","\tvec2 st1 = dFdy( mUv.st );","\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );","\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );","\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );","\tvec3 N = normalize( surf_norm );","\tmat3 tsn = mat3( S, T, N );","\tvec3 mapN = map * 2.0 - 1.0;","\tmapN.xy *= normalScale;","\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );","\treturn normalize( tsn * mapN );","}"].join("\n"),null,{derivatives:!0});return{perturbNormal2Arb:e}}(),an.prototype=Object.create(tr.prototype),an.prototype.constructor=an,an.prototype.nodeType="NormalMap",an.prototype.generate=function(e,t){if(e.isShader("fragment")){var r=e.include(an.Nodes.perturbNormal2Arb);return this.normal=this.normal||new nr,this.position=this.position||new ir(ir.VIEW),this.uv=this.uv||new rr,e.format(r+"( -"+this.position.build(e,"v3")+", "+this.normal.build(e,"v3")+", "+this.value.build(e,"v3")+", "+this.uv.build(e,"v2")+", "+this.scale.build(e,"v2")+" )",this.getType(e),t)}return console.warn("NormalMapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)},an.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.value=e.value,this.scale=e.scale},an.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid),t},on.prototype=Object.create(rn.prototype),on.prototype.constructor=on,on.prototype.nodeType="MeshStandard",on.prototype.build=function(e){var t=this.properties,r=this.inputs;if(e.isShader("fragment")){var i=e.findNode(t.color,r.color),n=e.resolve(t.map);this.color=n?new Ki(i,n,Ki.MUL):i;var a=e.findNode(t.roughness,r.roughness),o=e.resolve(t.roughnessMap);this.roughness=o?new Ki(a,new nn(o,"g"),Ki.MUL):a;var s=e.findNode(t.metalness,r.metalness),l=e.resolve(t.metalnessMap);this.metalness=l?new Ki(s,new nn(l,"b"),Ki.MUL):s,t.normalMap?(this.normal=new an(e.resolve(t.normalMap)),this.normal.scale=e.findNode(t.normalScale,r.normalScale)):this.normal=void 0,this.environment=e.resolve(t.envMap)}return rn.prototype.build.call(this,e)},on.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),console.warn(".toJSON not implemented in",this)),t},sn.prototype=Object.create(Fi.prototype),sn.prototype.constructor=sn,xv.addShortcuts(sn.prototype,"properties",["color","roughness","metalness","map","normalMap","normalScale","metalnessMap","roughnessMap","envMap"]),ln.prototype=Object.create(er.prototype),ln.prototype.constructor=ln,ln.prototype.nodeType="Phong",ln.prototype.build=function(e){var t;if(e.define("PHONG"),e.requires.lights=!0,e.isShader("vertex")){var r=this.position?this.position.parseAndBuildCode(e,"v3",{cache:"position"}):void 0;e.mergeUniform(Mu.merge([mp.fog,mp.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include ","#include ","#include ","#include ","#include ","#include "].join("\n"));var i=["#include ","#include ","#include ","#include ","#include ","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","#include "];r&&i.push(r.code,r.result?"transformed = "+r.result+";":""),i.push("\t#include ","\t#include ","\t#include ","\t#include ","\t#include ","\t#include ","\tvViewPosition = - mvPosition.xyz;","\t#include ","\t#include ","\t#include "),t=i.join("\n")}else{this.color.parse(e,{slot:"color"}),this.specular.parse(e),this.shininess.parse(e),this.alpha&&this.alpha.parse(e),this.normal&&this.normal.parse(e),this.light&&this.light.parse(e,{cache:"light"}),this.ao&&this.ao.parse(e),this.ambient&&this.ambient.parse(e),this.shadow&&this.shadow.parse(e),this.emissive&&this.emissive.parse(e,{slot:"emissive"}),this.environment&&this.environment.parse(e,{slot:"environment"}),this.environmentAlpha&&this.environment&&this.environmentAlpha.parse(e);var n=this.color.buildCode(e,"c",{slot:"color"}),a=this.specular.buildCode(e,"c"),o=this.shininess.buildCode(e,"f"),s=this.alpha?this.alpha.buildCode(e,"f"):void 0,l=this.normal?this.normal.buildCode(e,"v3"):void 0,c=this.light?this.light.buildCode(e,"v3",{cache:"light"}):void 0,u=this.ao?this.ao.buildCode(e,"f"):void 0,h=this.ambient?this.ambient.buildCode(e,"c"):void 0,d=this.shadow?this.shadow.buildCode(e,"c"):void 0,p=this.emissive?this.emissive.buildCode(e,"c",{slot:"emissive"}):void 0,f=this.environment?this.environment.buildCode(e,"c",{slot:"environment"}):void 0,m=this.environmentAlpha&&this.environment?this.environmentAlpha.buildCode(e,"f"):void 0;e.requires.transparent=void 0!=s,e.addParsCode(["#include ","#include ","#include ","#include ","#include ","#include "].join("\n"));var i=["#include ","\tBlinnPhongMaterial material;",n.code,"\tvec3 diffuseColor = "+n.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include ",a.code,"\tvec3 specular = "+a.result+";",o.code,"\tfloat shininess = max( 0.0001, "+o.result+" );","\tfloat specularStrength = 1.0;"];s&&i.push(s.code,"#ifdef ALPHATEST","if ( "+s.result+" <= ALPHATEST ) discard;","#endif"),l&&i.push(l.code,"normal = "+l.result+";"),i.push("material.diffuseColor = "+(c?"vec3( 1.0 )":"diffuseColor")+";"),i.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),c&&(i.push(c.code,"reflectedLight.directDiffuse = "+c.result+";"),i.push("reflectedLight.directDiffuse *= diffuseColor;","reflectedLight.indirectDiffuse *= diffuseColor;")),u&&i.push(u.code,"reflectedLight.indirectDiffuse *= "+u.result+";"),h&&i.push(h.code,"reflectedLight.indirectDiffuse += "+h.result+";"),d&&i.push(d.code,"reflectedLight.directDiffuse *= "+d.result+";","reflectedLight.directSpecular *= "+d.result+";"),p&&i.push(p.code,"reflectedLight.directDiffuse += "+p.result+";"),i.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),f&&(i.push(f.code),m?i.push(m.code,"outgoingLight = mix( outgoingLight, "+f.result+", "+m.result+" );"):i.push("outgoingLight = "+f.result+";")),s?i.push("gl_FragColor = vec4( outgoingLight, "+s.result+" );"):i.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),i.push("#include ","#include ","#include ","#include "),t=i.join("\n")}return t},ln.prototype.copy=function(e){er.prototype.copy.call(this,e),e.position&&(this.position=e.position),this.color=e.color,this.specular=e.specular,this.shininess=e.shininess,e.alpha&&(this.alpha=e.alpha),e.normal&&(this.normal=e.normal),e.light&&(this.light=e.light),e.shadow&&(this.shadow=e.shadow),e.ao&&(this.ao=e.ao),e.emissive&&(this.emissive=e.emissive),e.ambient&&(this.ambient=e.ambient),e.environment&&(this.environment=e.environment),e.environmentAlpha&&(this.environmentAlpha=e.environmentAlpha)},ln.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),t.color=this.color.toJSON(e).uuid,t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid),this.environmentAlpha&&(t.environmentAlpha=this.environmentAlpha.toJSON(e).uuid)),t},cn.prototype=Object.create(er.prototype),cn.prototype.constructor=cn,cn.prototype.nodeType="Sprite",cn.prototype.build=function(e){var t;if(e.define("SPRITE"),e.requires.lights=!1,e.requires.transparent=void 0!==this.alpha,e.isShader("vertex")){var r=this.position?this.position.parseAndBuildCode(e,"v3",{cache:"position"}):void 0;e.mergeUniform(Mu.merge([mp.fog])),e.addParsCode(["#include ","#include ","#include "].join("\n")),t=["#include ","#include "], r&&t.push(r.code,r.result?"transformed = "+r.result+";":""),t.push("#include ","#include ","mat4 modelViewMtx = modelViewMatrix;","mat4 modelMtx = modelMatrix;","modelMtx[3][0] = 0.0;","modelMtx[3][1] = 0.0;","modelMtx[3][2] = 0.0;"),this.spherical||t.push("modelMtx[1][1] = 1.0;"),t.push("modelViewMtx[0][0] = 1.0;","modelViewMtx[0][1] = 0.0;","modelViewMtx[0][2] = 0.0;"),this.spherical&&t.push("modelViewMtx[1][0] = 0.0;","modelViewMtx[1][1] = 1.0;","modelViewMtx[1][2] = 0.0;"),t.push("modelViewMtx[2][0] = 0.0;","modelViewMtx[2][1] = 0.0;","modelViewMtx[2][2] = 1.0;","gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( transformed, 1.0 );","#include ","#include ","#include ")}else{e.addParsCode(["#include ","#include ","#include "].join("\n")),e.addCode(["#include ","#include "].join("\n")),this.alpha&&this.alpha.parse(e),this.color.parse(e,{slot:"color"});var i=this.alpha?this.alpha.buildCode(e,"f"):void 0,n=this.color.buildCode(e,"c",{slot:"color"});t=i?[i.code,"#ifdef ALPHATEST","if ( "+i.result+" <= ALPHATEST ) discard;","#endif",n.code,"gl_FragColor = vec4( "+n.result+", "+i.result+" );"]:[n.code,"gl_FragColor = vec4( "+n.result+", 1.0 );"],t.push("#include ","#include ","#include ")}return t.join("\n")},cn.prototype.copy=function(e){er.prototype.copy.call(this,e),e.position&&(this.position=e.position),this.color=e.color,void 0!==e.spherical&&(this.spherical=e.spherical),e.alpha&&(this.alpha=e.alpha)},cn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),t.color=this.color.toJSON(e).uuid,this.spherical===!1&&(t.spherical=!1),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid)),t},un.prototype=Object.create(Fi.prototype),un.prototype.constructor=un,xv.addShortcuts(un.prototype,"fragment",["color","alpha","specular","shininess","normal","emissive","ambient","light","shadow","ao","environment","environmentAlpha","position"]),hn.prototype=Object.create(Fi.prototype),hn.prototype.constructor=hn,xv.addShortcuts(hn.prototype,"fragment",["color","alpha","position","spherical"]),dn.prototype=Object.create(Fi.prototype),dn.prototype.constructor=dn,xv.addShortcuts(dn.prototype,"fragment",["color","alpha","roughness","metalness","reflectivity","clearCoat","clearCoatRoughness","normal","emissive","ambient","light","shadow","ao","environment","position"]),pn.EQUAL="==",pn.NOT_EQUAL="!=",pn.GREATER=">",pn.GREATER_EQUAL=">=",pn.LESS="<",pn.LESS_EQUAL="<=",pn.prototype=Object.create(tr.prototype),pn.prototype.constructor=pn,pn.prototype.nodeType="Cond",pn.prototype.getType=function(e){return e.getTypeLength(this.elseNode.getType(e))>e.getTypeLength(this.ifNode.getType(e))?this.elseNode.getType(e):this.ifNode.getType(e)},pn.prototype.getCondType=function(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)},pn.prototype.generate=function(e,t){var r=this.getType(e),i=this.getCondType(e),n=this.a.build(e,i),a=this.b.build(e,i),o=this.ifNode.build(e,r),s=this.elseNode.build(e,r),l="( "+[n,this.op,a,"?",o,":",s].join(" ")+" )";return e.format(l,this.getType(e),t)},pn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.a=e.a,this.b=e.b,this.ifNode=e.ifNode,this.elseNode=e.elseNode,this.op=e.op},pn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.ifNode=this.ifNode.toJSON(e).uuid,t.elseNode=this.elseNode.toJSON(e).uuid,t.op=this.op),t},fn.RAD="radians",fn.DEG="degrees",fn.EXP="exp",fn.EXP2="exp2",fn.LOG="log",fn.LOG2="log2",fn.SQRT="sqrt",fn.INV_SQRT="inversesqrt",fn.FLOOR="floor",fn.CEIL="ceil",fn.NORMALIZE="normalize",fn.FRACT="fract",fn.SAT="saturate",fn.SIN="sin",fn.COS="cos",fn.TAN="tan",fn.ASIN="asin",fn.ACOS="acos",fn.ARCTAN="atan",fn.ABS="abs",fn.SIGN="sign",fn.LENGTH="length",fn.NEGATE="negate",fn.INVERT="invert",fn.prototype=Object.create(tr.prototype),fn.prototype.constructor=fn,fn.prototype.nodeType="Math1",fn.prototype.getType=function(e){switch(this.method){case fn.LENGTH:return"f"}return this.a.getType(e)},fn.prototype.generate=function(e,t){var r=this.getType(e),i=this.a.build(e,r);switch(this.method){case fn.NEGATE:i="( -"+i+" )";break;case fn.INVERT:i="( 1.0 - "+i+" )";break;default:i=this.method+"( "+i+" )"}return e.format(i,r,t)},fn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.a=e.a,this.method=e.method},fn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.method=this.method),t},mn.MIN="min",mn.MAX="max",mn.MOD="mod",mn.STEP="step",mn.REFLECT="reflect",mn.DISTANCE="distance",mn.DOT="dot",mn.CROSS="cross",mn.POW="pow",mn.prototype=Object.create(tr.prototype),mn.prototype.constructor=mn,mn.prototype.nodeType="Math2",mn.prototype.getInputType=function(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)},mn.prototype.getType=function(e){switch(this.method){case mn.DISTANCE:case mn.DOT:return"f";case mn.CROSS:return"v3"}return this.getInputType(e)},mn.prototype.generate=function(e,t){var r,i,n=this.getInputType(e),a=e.getTypeLength(this.a.getType(e)),o=e.getTypeLength(this.b.getType(e));switch(this.method){case mn.CROSS:r=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case mn.STEP:r=this.a.build(e,1===a?"f":n),i=this.b.build(e,n);break;case mn.MIN:case mn.MAX:case mn.MOD:r=this.a.build(e,n),i=this.b.build(e,1===o?"f":n);break;default:r=this.a.build(e,n),i=this.b.build(e,n)}return e.format(this.method+"( "+r+", "+i+" )",this.getType(e),t)},mn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.a=e.a,this.b=e.b,this.method=e.method},mn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.method=this.method),t},vn.MIX="mix",vn.REFRACT="refract",vn.SMOOTHSTEP="smoothstep",vn.FACEFORWARD="faceforward",vn.prototype=Object.create(tr.prototype),vn.prototype.constructor=vn,vn.prototype.nodeType="Math3",vn.prototype.getType=function(e){var t=e.getTypeLength(this.a.getType(e)),r=e.getTypeLength(this.b.getType(e)),i=e.getTypeLength(this.c.getType(e));return t>r&&t>i?this.a.getType(e):r>i?this.b.getType(e):this.c.getType(e)},vn.prototype.generate=function(e,t){var r,i,n,a=(e.getTypeLength(this.a.getType(e)),e.getTypeLength(this.b.getType(e)),e.getTypeLength(this.c.getType(e))),o=this.getType(e);switch(this.method){case vn.REFRACT:r=this.a.build(e,o),i=this.b.build(e,o),n=this.c.build(e,"f");break;case vn.MIX:r=this.a.build(e,o),i=this.b.build(e,o),n=this.c.build(e,1===a?"f":o);break;default:r=this.a.build(e,o),i=this.b.build(e,o),n=this.c.build(e,o)}return e.format(this.method+"( "+r+", "+i+", "+n+" )",o,t)},vn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.a=e.a,this.b=e.b,this.c=e.c,this.method=e.method},vn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.c=this.c.toJSON(e).uuid,t.method=this.method),t},gn.Nodes=function(){var e=new Vf(["vec2 dHdxy_fwd( sampler2D bumpMap, vec2 vUv, float bumpScale ) {","\tvec2 dSTdx = dFdx( vUv );","\tvec2 dSTdy = dFdy( vUv );","\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;","\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;","\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;","\treturn vec2( dBx, dBy );","}"].join("\n"),null,{derivatives:!0}),t=new Vf(["vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {","\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );","\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );","\tvec3 vN = surf_norm;","\tvec3 R1 = cross( vSigmaY, vN );","\tvec3 R2 = cross( vN, vSigmaX );","\tfloat fDet = dot( vSigmaX, R1 );","\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );","\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );","\treturn normalize( abs( fDet ) * surf_norm - vGrad );","}"].join("\n"),[e],{derivatives:!0}),r=new Vf(["vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, float scale ) {","\tvec2 dSTdx = dFdx( uv );","\tvec2 dSTdy = dFdy( uv );","\tfloat Hll = texture2D( bumpMap, uv ).x;","\tfloat dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;","\tfloat dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;","\treturn vec3( .5 - ( dBx * scale ), .5 - ( dBy * scale ), 1.0 );","}"].join("\n"),null,{derivatives:!0});return{dHdxy_fwd:e,perturbNormalArb:t,bumpToNormal:r}}(),gn.prototype=Object.create(tr.prototype),gn.prototype.constructor=gn,gn.prototype.nodeType="BumpMap",gn.prototype.generate=function(e,t){if(e.isShader("fragment")){if(this.toNormalMap){var r=e.include(gn.Nodes.bumpToNormal);return e.format(r+"( "+this.value.build(e,"sampler2D")+", "+this.value.uv.build(e,"v2")+", "+this.scale.build(e,"f")+" )",this.getType(e),t)}var i=e.include(gn.Nodes.dHdxy_fwd),n=e.include(gn.Nodes.perturbNormalArb);this.normal=this.normal||new nr,this.position=this.position||new ir(ir.VIEW);var a=i+"( "+this.value.build(e,"sampler2D")+", "+this.value.uv.build(e,"v2")+", "+this.scale.build(e,"f")+" )";return e.format(n+"( -"+this.position.build(e,"v3")+", "+this.normal.build(e,"v3")+", "+a+" )",this.getType(e),t)}return console.warn("BumpMapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)},gn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.value=e.value,this.scale=e.scale},gn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid),t};var Tv=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1};Object.assign(Tv.prototype,{setSize:function(e,t){},render:function(e,t,r,i,n){console.error("Pass: .render() must be implemented in derived pass.")}});var Ev=function(e,t){Tv.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof pe?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Mu.clone(e.uniforms),this.material=new pe({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};Ev.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Ev,render:function(e,t,r,i,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)}}),yn.prototype=Object.create(Ev.prototype),yn.prototype.constructor=yn,yn.prototype.render=function(){this.needsUpdate&&(this.material.dispose(),this.material.fragment.value=this.input,this.needsUpdate=!1),this.uniforms=this.material.uniforms,Ev.prototype.render.apply(this,arguments)},yn.prototype.copy=function(e){this.input=e.input},yn.prototype.toJSON=function(e){var t=void 0===e||"string"==typeof e;if(t&&(e={nodes:{}}),e&&!e.passes&&(e.passes={}),!e.passes[this.uuid]){var r={};r.uuid=this.uuid,r.type="NodePass",e.passes[this.uuid]=r,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.input=this.input.toJSON(e).uuid}return e.pass=this.uuid,e},xn.prototype={constructor:xn,render:function(e,t,r){this.needsUpdate&&(this.material.dispose(),this.material.fragment.value=this.output,this.material.build(),this.material.uniforms.renderTexture&&(this.material.uniforms.renderTexture.value=this.renderTarget.texture),this.needsUpdate=!1),r.setRenderer(this.renderer).setRenderTexture(this.renderTarget.texture),this.renderer.render(e,t,this.renderTarget),r.updateNode(this.material),this.renderer.render(this.scene,this.camera)},setSize:function(e,t){this.renderTarget.setSize(e,t),this.renderer.setSize(e,t)},copy:function(e){this.output=e.output},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(t&&(e={nodes:{}}),e&&!e.post&&(e.post={}),!e.post[this.uuid]){var r={};r.uuid=this.uuid,r.type="NodePostProcessing",e.post[this.uuid]=r,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.output=this.output.toJSON(e).uuid}return e.post=this.uuid,e}},bn.prototype=Object.create(tr.prototype),bn.prototype.constructor=bn,bn.prototype.nodeType="Noise",bn.Nodes=function(){var e=new Vf(["float checker( vec2 uv ) {","\tfloat cx = floor( uv.x );","\tfloat cy = floor( uv.y ); ","\tfloat result = mod( cx + cy, 2.0 );","\treturn sign( result );","}"].join("\n"));return{checker:e}}(),bn.prototype.generate=function(e,t){var r=e.include(bn.Nodes.checker);return e.format(r+"( "+this.uv.build(e,"v2")+" )",this.getType(e),t)},bn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.uv=e.uv},bn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid),t},wn.prototype=Object.create(tr.prototype),wn.prototype.constructor=wn,wn.prototype.nodeType="Noise",wn.Nodes=function(){var e=new Vf(["float snoise(vec2 co) {","\treturn fract( sin( dot( co.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );","}"].join("\n"));return{snoise:e}}(),wn.prototype.generate=function(e,t){var r=e.include(wn.Nodes.snoise);return e.format(r+"( "+this.uv.build(e,"v2")+" )",this.getType(e),t)},wn.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.uv=e.uv},wn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid),t},_n.prototype=Object.create(er.prototype),_n.prototype.constructor=_n,_n.prototype.nodeType="Bypass",_n.prototype.getType=function(e){return this.value?this.value.getType(e):e.isShader("fragment")?"f":"void"},_n.prototype.generate=function(e,t){var r=this.code.build(e,t)+";";return e.addNodeCode(r),e.isShader("vertex")?this.value?this.value.build(e,t):void 0:this.value?this.value.build(e,t):e.format("0.0","f",t)},_n.prototype.copy=function(e){er.prototype.copy.call(this,e),this.code=e.code,this.value=e.value},_n.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.code=this.code.toJSON(e).uuid,this.value&&(t.value=this.value.toJSON(e).uuid)),t};var Cv=xv.elements;Sn.prototype=Object.create(tr.prototype),Sn.prototype.constructor=Sn,Sn.prototype.nodeType="Join",Sn.prototype.getNumElements=function(){for(var e=this,t=Cv.length;t--;)if(void 0!==e[Cv[t]]){++t;break}return Math.max(t,2)},Sn.prototype.getType=function(e){return e.getTypeFromLength(this.getNumElements())},Sn.prototype.generate=function(e,t){for(var r=this,i=this.getType(e),n=this.getNumElements(),a=[],o=0;o1?e.getConstructorFromLength(n):"")+"( "+a.join(", ")+" )";return e.format(l,i,t)},Sn.prototype.copy=function(e){var t=this;tr.prototype.copy.call(this,e);for(var r in e.inputs)t[r]=e.inputs[r]},Sn.prototype.toJSON=function(e){var t=this,r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.inputs={};for(var i=this.getNumElements(),n=0;nthis.max.x||e.ythis.max.y)},containsBox: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},getParameter:function(e,t){return void 0===t&&(console.warn("Box2: .getParameter() target is now required"),t=new f),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("Box2: .clampPoint() target is now required"),t=new f),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new f;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var Lv=function(){k.call(this,Lv.Geometry,new F({opacity:0,transparent:!0})),this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;var e=new i,t=new Mt(new Uint8Array(768),16,16,yc);t.minFilter=$l,t.magFilter=$l,t.wrapS=Zl,t.wrapT=Zl,t.needsUpdate=!0;var r=new Mt(new Uint8Array(768),16,16,yc);r.minFilter=$l,r.magFilter=$l,r.wrapS=Zl,r.wrapT=Zl,r.needsUpdate=!0;var n=Lv.Geometry,a=new Oe({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:["precision highp float;","uniform vec3 screenPosition;","uniform vec2 scale;","attribute vec3 position;","void main() {","\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","void main() {","\tgl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 );","}"].join("\n"),depthTest:!0,depthWrite:!1,transparent:!1}),o=new Oe({uniforms:{map:{value:t},scale:{value:null},screenPosition:{value:null}},vertexShader:["precision highp float;","uniform vec3 screenPosition;","uniform vec2 scale;","attribute vec3 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","\tvUV = uv;","\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","uniform sampler2D map;","varying vec2 vUV;","void main() {","\tgl_FragColor = texture2D( map, vUV );","}"].join("\n"),depthTest:!1,depthWrite:!1,transparent:!1}),s=new k(n,a),l=[],c=Pv.Shader,h=new Oe({uniforms:{map:{value:null},occlusionMap:{value:r},color:{value:new u(16777215)},scale:{value:new f},screenPosition:{value:new i}},vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:ol,transparent:!0,depthWrite:!1}),d=new k(n,h);this.addElement=function(e){l.push(e)};var p=new f,m=new f,g=new Tn,y=new v;this.onBeforeRender=function(i,c,u){y.copy(i.getCurrentViewport());var f=y.w/y.z,v=y.z/2,x=y.w/2,b=16/y.w;if(p.set(b*f,b),g.min.set(y.x,y.y),g.max.set(y.x+(y.z-16),y.y+(y.w-16)),e.setFromMatrixPosition(this.matrixWorld),e.applyMatrix4(u.matrixWorldInverse),e.applyMatrix4(u.projectionMatrix),m.x=y.x+e.x*v+v-8,m.y=y.y+e.y*x+x-8,g.containsPoint(m)){i.copyFramebufferToTexture(m,t);var w=a.uniforms;w.scale.value=p,w.screenPosition.value=e,i.renderBufferDirect(u,null,n,a,s,null),i.copyFramebufferToTexture(m,r);var w=o.uniforms;w.scale.value=p,w.screenPosition.value=e,i.renderBufferDirect(u,null,n,o,s,null);for(var _=2*-e.x,S=2*-e.y,A=0,M=l.length;A0)){w.reflect(p).negate(),w.add(f),g.extractRotation(r.matrixWorld),y.set(0,0,-1),y.applyMatrix4(g),y.add(m),_.subVectors(f,y),_.reflect(p).negate(),_.add(f),M.position.copy(w),M.up.set(0,1,0),M.up.applyMatrix4(g),M.up.reflect(p),M.lookAt(_),M.far=r.far,M.updateMatrixWorld(),M.projectionMatrix.copy(r.projectionMatrix),M.userData.recursion=0,A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(M.projectionMatrix),A.multiply(M.matrixWorldInverse),A.multiply(n.matrixWorld),d.setFromNormalAndCoplanarPoint(p,f),d.applyMatrix4(M.matrixWorldInverse),x.set(d.normal.x,d.normal.y,d.normal.z,d.constant);var i=M.projectionMatrix;S.x=(Math.sign(x.x)+i.elements[8])/i.elements[0],S.y=(Math.sign(x.y)+i.elements[9])/i.elements[5],S.z=-1,S.w=(1+i.elements[10])/i.elements[14],x.multiplyScalar(2/x.dot(S)),i.elements[2]=x.x,i.elements[6]=x.y,i.elements[10]=x.z+1-l,i.elements[14]=x.w,n.visible=!1;var a=e.getRenderTarget(),o=e.vr.enabled,s=e.shadowMap.autoUpdate;e.vr.enabled=!1,e.shadowMap.autoUpdate=!1,e.render(t,M,E,!0),e.vr.enabled=o,e.shadowMap.autoUpdate=s,e.setRenderTarget(a);var c=r.bounds;if(void 0!==c){var u=e.getSize(),v=e.getPixelRatio();b.x=c.x*u.width*v,b.y=c.y*u.height*v,b.z=c.z*u.width*v,b.w=c.w*u.height*v,e.state.viewport(b)}n.visible=!0}},this.getRenderTarget=function(){return E}};Nv.prototype=Object.create(k.prototype),Nv.prototype.constructor=Nv,Nv.ReflectorShader={uniforms:{color:{type:"c",value:null},tDiffuse:{type:"t",value:null},textureMatrix:{type:"m4",value:null}},vertexShader:["uniform mat4 textureMatrix;","varying vec4 vUv;","void main() {","\tvUv = textureMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec4 vUv;","float blendOverlay( float base, float blend ) {","\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );","}","vec3 blendOverlay( vec3 base, vec3 blend ) {","\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );","}","void main() {","\tvec4 base = texture2DProj( tDiffuse, vUv );","\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );","}"].join("\n")};var Ov=function(e,t){Nv.call(this,e,t),this.geometry.setDrawRange(0,0)};Ov.prototype=Object.create(Nv.prototype);var Dv=function(e,t){function a(e){m.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),m.multiply(e.projectionMatrix),m.multiply(e.matrixWorldInverse),m.multiply(o.matrixWorld)}k.call(this,e),this.type="Refractor";var o=this;t=t||{};var s=new u(void 0!==t.color?t.color:8355711),l=t.textureWidth||512,c=t.textureHeight||512,h=t.clipBias||0,d=t.shader||Dv.RefractorShader,p=new de;p.matrixAutoUpdate=!1,p.userData.refractor=!0;var f=new ze,m=new r,g={minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1},y=new ge(l,c,g);Fs.isPowerOfTwo(l)&&Fs.isPowerOfTwo(c)||(y.texture.generateMipmaps=!1),this.material=new pe({uniforms:Mu.clone(d.uniforms),vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,transparent:!0}),this.material.uniforms.color.value=s,this.material.uniforms.tDiffuse.value=y.texture,this.material.uniforms.textureMatrix.value=m;var x=function(){var e=new i,t=new i,n=new r,a=new i,s=new i;return function(r){return e.setFromMatrixPosition(o.matrixWorld),t.setFromMatrixPosition(r.matrixWorld),a.subVectors(e,t),n.extractRotation(o.matrixWorld),s.set(0,0,1),s.applyMatrix4(n),a.dot(s)<0}}(),b=function(){var e=new i,t=new i,r=new n,a=new i;return function(){o.matrixWorld.decompose(t,r,a),e.set(0,0,1).applyQuaternion(r).normalize(),e.negate(),f.setFromNormalAndCoplanarPoint(e,t)}}(),w=function(){var e=new ze,t=new v,r=new v;return function(i){p.matrixWorld.copy(i.matrixWorld),p.matrixWorldInverse.getInverse(p.matrixWorld),p.projectionMatrix.copy(i.projectionMatrix),p.far=i.far,e.copy(f),e.applyMatrix4(p.matrixWorldInverse),t.set(e.normal.x,e.normal.y,e.normal.z,e.constant);var n=p.projectionMatrix;r.x=(Math.sign(t.x)+n.elements[8])/n.elements[0],r.y=(Math.sign(t.y)+n.elements[9])/n.elements[5],r.z=-1,r.w=(1+n.elements[10])/n.elements[14],t.multiplyScalar(2/t.dot(r)),n.elements[2]=t.x,n.elements[6]=t.y,n.elements[10]=t.z+1-h,n.elements[14]=t.w}}(),_=function(){var e=new v;return function(t,r,i){o.visible=!1;var n=t.getRenderTarget(),a=t.vr.enabled,s=t.shadowMap.autoUpdate;t.vr.enabled=!1,t.shadowMap.autoUpdate=!1,t.render(r,p,y,!0),t.vr.enabled=a,t.shadowMap.autoUpdate=s,t.setRenderTarget(n);var l=i.bounds;if(void 0!==l){var c=t.getSize(),u=t.getPixelRatio();e.x=l.x*c.width*u,e.y=l.y*c.height*u,e.z=l.z*c.width*u,e.w=l.w*c.height*u,t.state.viewport(e)}o.visible=!0}}();this.onBeforeRender=function(e,t,r){r.userData.refractor!==!0&&!x(r)!=!0&&(b(),a(r),w(r),_(e,t,r))},this.getRenderTarget=function(){return y}};Dv.prototype=Object.create(k.prototype),Dv.prototype.constructor=Dv,Dv.RefractorShader={uniforms:{color:{type:"c",value:null},tDiffuse:{type:"t",value:null},textureMatrix:{type:"m4",value:null}},vertexShader:["uniform mat4 textureMatrix;","varying vec4 vUv;","void main() {","\tvUv = textureMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec4 vUv;","float blendOverlay( float base, float blend ) {","\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );","}","vec3 blendOverlay( vec3 base, vec3 blend ) {","\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );","}","void main() {","\tvec4 base = texture2DProj( tDiffuse, vUv );","\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );","}"].join("\n") -};var Fv=function(e){var t=new F({color:0,transparent:!0,opacity:.6,depthWrite:!1});k.call(this,e.geometry,t),this.meshMatrix=e.matrixWorld,this.frustumCulled=!1,this.matrixAutoUpdate=!1};Fv.prototype=Object.create(k.prototype),Fv.prototype.constructor=Fv,Fv.prototype.update=function(){var e=new r;return function(t,r){var i=t.normal.x*r.x+t.normal.y*r.y+t.normal.z*r.z+-t.constant*r.w,n=e.elements;n[0]=i-r.x*t.normal.x,n[4]=-r.x*t.normal.y,n[8]=-r.x*t.normal.z,n[12]=-r.x*-t.constant,n[1]=-r.y*t.normal.x,n[5]=i-r.y*t.normal.y,n[9]=-r.y*t.normal.z,n[13]=-r.y*-t.constant,n[2]=-r.z*t.normal.x,n[6]=-r.z*t.normal.y,n[10]=i-r.z*t.normal.z,n[14]=-r.z*-t.constant,n[3]=-r.w*t.normal.x,n[7]=-r.w*t.normal.y,n[11]=-r.w*t.normal.z,n[15]=i-r.w*-t.constant,this.matrix.multiplyMatrices(e,this.meshMatrix)}}();var Iv=function(){var e=Iv.SkyShader,t=new pe({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:Mu.clone(e.uniforms),side:Zs});k.call(this,new le(1,1,1),t)};Iv.prototype=Object.create(k.prototype),Iv.SkyShader={uniforms:{luminance:{value:1},turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new i}},vertexShader:["uniform vec3 sunPosition;","uniform float rayleigh;","uniform float turbidity;","uniform float mieCoefficient;","varying vec3 vWorldPosition;","varying vec3 vSunDirection;","varying float vSunfade;","varying vec3 vBetaR;","varying vec3 vBetaM;","varying float vSunE;","const vec3 up = vec3( 0.0, 1.0, 0.0 );","const float e = 2.71828182845904523536028747135266249775724709369995957;","const float pi = 3.141592653589793238462643383279502884197169;","const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );","const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );","const float v = 4.0;","const vec3 K = vec3( 0.686, 0.678, 0.666 );","const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );","const float cutoffAngle = 1.6110731556870734;","const float steepness = 1.5;","const float EE = 1000.0;","float sunIntensity( float zenithAngleCos ) {","\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );","\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );","}","vec3 totalMie( float T ) {","\tfloat c = ( 0.2 * T ) * 10E-18;","\treturn 0.434 * c * MieConst;","}","void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvWorldPosition = worldPosition.xyz;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tgl_Position.z = gl_Position.w;","\tvSunDirection = normalize( sunPosition );","\tvSunE = sunIntensity( dot( vSunDirection, up ) );","\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );","\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );","\tvBetaR = totalRayleigh * rayleighCoefficient;","\tvBetaM = totalMie( turbidity ) * mieCoefficient;","}"].join("\n"),fragmentShader:["varying vec3 vWorldPosition;","varying vec3 vSunDirection;","varying float vSunfade;","varying vec3 vBetaR;","varying vec3 vBetaM;","varying float vSunE;","uniform float luminance;","uniform float mieDirectionalG;","const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );","const float pi = 3.141592653589793238462643383279502884197169;","const float n = 1.0003;","const float N = 2.545E25;","const float rayleighZenithLength = 8.4E3;","const float mieZenithLength = 1.25E3;","const vec3 up = vec3( 0.0, 1.0, 0.0 );","const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;","const float THREE_OVER_SIXTEENPI = 0.05968310365946075;","const float ONE_OVER_FOURPI = 0.07957747154594767;","float rayleighPhase( float cosTheta ) {","\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );","}","float hgPhase( float cosTheta, float g ) {","\tfloat g2 = pow( g, 2.0 );","\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );","\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );","}","const float A = 0.15;","const float B = 0.50;","const float C = 0.10;","const float D = 0.20;","const float E = 0.02;","const float F = 0.30;","const float whiteScale = 1.0748724675633854;","vec3 Uncharted2Tonemap( vec3 x ) {","\treturn ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;","}","void main() {","\tfloat zenithAngle = acos( max( 0.0, dot( up, normalize( vWorldPosition - cameraPos ) ) ) );","\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );","\tfloat sR = rayleighZenithLength * inverse;","\tfloat sM = mieZenithLength * inverse;","\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );","\tfloat cosTheta = dot( normalize( vWorldPosition - cameraPos ), vSunDirection );","\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );","\tvec3 betaRTheta = vBetaR * rPhase;","\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );","\tvec3 betaMTheta = vBetaM * mPhase;","\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );","\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );","\tvec3 direction = normalize( vWorldPosition - cameraPos );","\tfloat theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]","\tfloat phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]","\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );","\tvec3 L0 = vec3( 0.1 ) * Fex;","\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );","\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;","\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );","\tvec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );","\tvec3 color = curr * whiteScale;","\tvec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );","\tgl_FragColor = vec4( retColor, 1.0 );","}"].join("\n")};var Rv=function(e,t){k.call(this,e);var n=this;t=t||{};var a=void 0!==t.textureWidth?t.textureWidth:512,o=void 0!==t.textureHeight?t.textureHeight:512,s=void 0!==t.clipBias?t.clipBias:0,l=void 0!==t.alpha?t.alpha:1,c=void 0!==t.time?t.time:0,h=void 0!==t.waterNormals?t.waterNormals:null,d=void 0!==t.sunDirection?t.sunDirection:new i(.70707,.70707,0),p=new u(void 0!==t.sunColor?t.sunColor:16777215),f=new u(void 0!==t.waterColor?t.waterColor:8355711),m=void 0!==t.eye?t.eye:new i(0,0,0),g=void 0!==t.distortionScale?t.distortionScale:20,y=void 0!==t.side?t.side:Js,x=void 0!==t.fog&&t.fog,b=new ze,w=new i,_=new i,S=new i,A=new r,M=new i(0,0,(-1)),T=new v,E=new i,C=new i,L=new v,P=new r,N=new de,O={minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1},D=new ge(a,o,O);Fs.isPowerOfTwo(a)&&Fs.isPowerOfTwo(o)||(D.texture.generateMipmaps=!1);var F={uniforms:Mu.merge([mp.fog,mp.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new r},sunColor:{value:new u(8355711)},sunDirection:{value:new i(.70707,.70707,0)},eye:{value:new i},waterColor:{value:new u(5592405)}}]),vertexShader:["uniform mat4 textureMatrix;","uniform float time;","varying vec4 mirrorCoord;","varying vec4 worldPosition;",fp.fog_pars_vertex,fp.shadowmap_pars_vertex,"void main() {","\tmirrorCoord = modelMatrix * vec4( position, 1.0 );","\tworldPosition = mirrorCoord.xyzw;","\tmirrorCoord = textureMatrix * mirrorCoord;","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * mvPosition;",fp.fog_vertex,fp.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D mirrorSampler;","uniform float alpha;","uniform float time;","uniform float size;","uniform float distortionScale;","uniform sampler2D normalSampler;","uniform vec3 sunColor;","uniform vec3 sunDirection;","uniform vec3 eye;","uniform vec3 waterColor;","varying vec4 mirrorCoord;","varying vec4 worldPosition;","vec4 getNoise( vec2 uv ) {","\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);","\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );","\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );","\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );","\tvec4 noise = texture2D( normalSampler, uv0 ) +","\t\ttexture2D( normalSampler, uv1 ) +","\t\ttexture2D( normalSampler, uv2 ) +","\t\ttexture2D( normalSampler, uv3 );","\treturn noise * 0.5 - 1.0;","}","void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {","\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );","\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );","\tspecularColor += pow( direction, shiny ) * sunColor * spec;","\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;","}",fp.common,fp.packing,fp.bsdfs,fp.fog_pars_fragment,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.shadowmask_pars_fragment,"void main() {","\tvec4 noise = getNoise( worldPosition.xz * size );","\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );","\tvec3 diffuseLight = vec3(0.0);","\tvec3 specularLight = vec3(0.0);","\tvec3 worldToEye = eye-worldPosition.xyz;","\tvec3 eyeDirection = normalize( worldToEye );","\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );","\tfloat distance = length(worldToEye);","\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;","\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.z + distortion ) );","\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );","\tfloat rf0 = 0.3;","\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );","\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;","\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);","\tvec3 outgoingLight = albedo;","\tgl_FragColor = vec4( outgoingLight, alpha );",fp.tonemapping_fragment,fp.fog_fragment,"}"].join("\n")},I=new pe({fragmentShader:F.fragmentShader,vertexShader:F.vertexShader,uniforms:Mu.clone(F.uniforms),transparent:!0,lights:!0,side:y,fog:x});I.uniforms.mirrorSampler.value=D.texture,I.uniforms.textureMatrix.value=P,I.uniforms.alpha.value=l,I.uniforms.time.value=c,I.uniforms.normalSampler.value=h,I.uniforms.sunColor.value=p,I.uniforms.waterColor.value=f,I.uniforms.sunDirection.value=d,I.uniforms.distortionScale.value=g,I.uniforms.eye.value=m,n.material=I,n.onBeforeRender=function(e,t,r){if(_.setFromMatrixPosition(n.matrixWorld),S.setFromMatrixPosition(r.matrixWorld),A.extractRotation(n.matrixWorld),w.set(0,0,1),w.applyMatrix4(A),E.subVectors(_,S),!(E.dot(w)>0)){E.reflect(w).negate(),E.add(_),A.extractRotation(r.matrixWorld),M.set(0,0,-1),M.applyMatrix4(A),M.add(S),C.subVectors(_,M),C.reflect(w).negate(),C.add(_),N.position.copy(E),N.up.set(0,1,0),N.up.applyMatrix4(A),N.up.reflect(w),N.lookAt(C),N.far=r.far,N.updateMatrixWorld(),N.projectionMatrix.copy(r.projectionMatrix),P.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),P.multiply(N.projectionMatrix),P.multiply(N.matrixWorldInverse),b.setFromNormalAndCoplanarPoint(w,_),b.applyMatrix4(N.matrixWorldInverse),T.set(b.normal.x,b.normal.y,b.normal.z,b.constant);var i=N.projectionMatrix;L.x=(Math.sign(T.x)+i.elements[8])/i.elements[0],L.y=(Math.sign(T.y)+i.elements[9])/i.elements[5],L.z=-1,L.w=(1+i.elements[10])/i.elements[14],T.multiplyScalar(2/T.dot(L)),i.elements[2]=T.x,i.elements[6]=T.y,i.elements[10]=T.z+1-s,i.elements[14]=T.w,m.setFromMatrixPosition(r.matrixWorld);var a=e.getRenderTarget(),o=e.vr.enabled,l=e.shadowMap.autoUpdate;n.visible=!1,e.vr.enabled=!1,e.shadowMap.autoUpdate=!1,e.render(t,N,D,!0),n.visible=!0,e.vr.enabled=o,e.shadowMap.autoUpdate=l,e.setRenderTarget(a)}}};Rv.prototype=Object.create(k.prototype),Rv.prototype.constructor=Rv,Object.assign(En.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=("undefined"==typeof performance?Date:performance).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}),Cn.prototype=Object.create(k.prototype),Cn.prototype.constructor=Cn,Cn.Water2Shader={uniforms:{color:{type:"c",value:null},reflectivity:{type:"f",value:0},tReflectionMap:{type:"t",value:null},tRefractionMap:{type:"t",value:null},tNormalMap0:{type:"t",value:null},tNormalMap1:{type:"t",value:null},textureMatrix:{type:"m4",value:null},config:{type:"v4",value:new v}},vertexShader:["#include ","uniform mat4 textureMatrix;","varying vec4 vCoord;","varying vec2 vUv;","varying vec3 vToEye;","void main() {","\tvUv = uv;","\tvCoord = textureMatrix * vec4( position, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvToEye = cameraPosition - worldPosition.xyz;","\tvec4 mvPosition = viewMatrix * worldPosition;","\tgl_Position = projectionMatrix * mvPosition;","\t#include ","}"].join("\n"),fragmentShader:["#include ","#include ","uniform sampler2D tReflectionMap;","uniform sampler2D tRefractionMap;","uniform sampler2D tNormalMap0;","uniform sampler2D tNormalMap1;","#ifdef USE_FLOWMAP","\tuniform sampler2D tFlowMap;","#else","\tuniform vec2 flowDirection;","#endif","uniform vec3 color;","uniform float reflectivity;","uniform vec4 config;","varying vec4 vCoord;","varying vec2 vUv;","varying vec3 vToEye;","void main() {","\tfloat flowMapOffset0 = config.x;","\tfloat flowMapOffset1 = config.y;","\tfloat halfCycle = config.z;","\tfloat scale = config.w;","\tvec3 toEye = normalize( vToEye );","\tvec2 flow;","\t#ifdef USE_FLOWMAP","\t\tflow = texture2D( tFlowMap, vUv ).rg * 2.0 - 1.0;","\t#else","\t\tflow = flowDirection;","\t#endif","\tflow.x *= - 1.0;","\tvec4 normalColor0 = texture2D( tNormalMap0, ( vUv * scale ) + flow * flowMapOffset0 );","\tvec4 normalColor1 = texture2D( tNormalMap1, ( vUv * scale ) + flow * flowMapOffset1 );","\tfloat flowLerp = abs( halfCycle - flowMapOffset0 ) / halfCycle;","\tvec4 normalColor = mix( normalColor0, normalColor1, flowLerp );","\tvec3 normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );","\tfloat theta = max( dot( toEye, normal ), 0.0 );","\tfloat reflectance = reflectivity + ( 1.0 - reflectivity ) * pow( ( 1.0 - theta ), 5.0 );","\tvec3 coord = vCoord.xyz / vCoord.w;","\tvec2 uv = coord.xy + coord.z * normal.xz * 0.05;","\tvec4 reflectColor = texture2D( tReflectionMap, vec2( 1.0 - uv.x, uv.y ) );","\tvec4 refractColor = texture2D( tRefractionMap, uv );","\tgl_FragColor = vec4( color, 1.0 ) * mix( refractColor, reflectColor, reflectance );","\t#include ","\t#include ","\t#include ","}"].join("\n")};var Uv=function(e,t,r,n){function a(e,t){return void 0!==e?e:t}this.changed=!0,this.initial=!0,this.oceanCamera=new me,this.oceanCamera.position.z=1,this.renderer=e,this.renderer.clearColor(16777215),this.scene=new fe,n=n||{},this.clearColor=a(n.CLEAR_COLOR,[1,1,1,0]),this.geometryOrigin=a(n.GEOMETRY_ORIGIN,[-1e3,-1e3]),this.sunDirectionX=a(n.SUN_DIRECTION[0],-1),this.sunDirectionY=a(n.SUN_DIRECTION[1],1),this.sunDirectionZ=a(n.SUN_DIRECTION[2],1),this.oceanColor=a(n.OCEAN_COLOR,new i(.004,.016,.047)),this.skyColor=a(n.SKY_COLOR,new i(3.2,9.6,12.8)),this.exposure=a(n.EXPOSURE,.35),this.geometryResolution=a(n.GEOMETRY_RESOLUTION,32),this.geometrySize=a(n.GEOMETRY_SIZE,2e3),this.resolution=a(n.RESOLUTION,64),this.floatSize=a(n.SIZE_OF_FLOAT,4),this.windX=a(n.INITIAL_WIND[0],10),this.windY=a(n.INITIAL_WIND[1],10),this.size=a(n.INITIAL_SIZE,250),this.choppiness=a(n.INITIAL_CHOPPINESS,1.5),this.matrixNeedsUpdate=!1;var o=a(n.USE_HALF_FLOAT,!1)?dc:hc,s={minFilter:rc,magFilter:rc,wrapS:Zl,wrapT:Zl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o},l={minFilter:$l,magFilter:$l,wrapS:Zl,wrapT:Zl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o},c={minFilter:$l,magFilter:$l,wrapS:Jl,wrapT:Jl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o};this.initialSpectrumFramebuffer=new ge(this.resolution,this.resolution,c),this.spectrumFramebuffer=new ge(this.resolution,this.resolution,l),this.pingPhaseFramebuffer=new ge(this.resolution,this.resolution,l),this.pongPhaseFramebuffer=new ge(this.resolution,this.resolution,l),this.pingTransformFramebuffer=new ge(this.resolution,this.resolution,l),this.pongTransformFramebuffer=new ge(this.resolution,this.resolution,l),this.displacementMapFramebuffer=new ge(this.resolution,this.resolution,s),this.normalMapFramebuffer=new ge(this.resolution,this.resolution,s);var u=vp.ocean_sim_vertex,h=vp.ocean_subtransform,d=Mu.clone(h.uniforms);this.materialOceanHorizontal=new pe({uniforms:d,vertexShader:u.vertexShader,fragmentShader:"#define HORIZONTAL \n"+h.fragmentShader}),this.materialOceanHorizontal.uniforms.u_transformSize={value:this.resolution},this.materialOceanHorizontal.uniforms.u_subtransformSize={value:null},this.materialOceanHorizontal.uniforms.u_input={value:null},this.materialOceanHorizontal.depthTest=!1;var p=vp.ocean_subtransform,m=Mu.clone(p.uniforms);this.materialOceanVertical=new pe({uniforms:m,vertexShader:u.vertexShader,fragmentShader:p.fragmentShader}),this.materialOceanVertical.uniforms.u_transformSize={value:this.resolution},this.materialOceanVertical.uniforms.u_subtransformSize={value:null},this.materialOceanVertical.uniforms.u_input={value:null},this.materialOceanVertical.depthTest=!1;var v=vp.ocean_initial_spectrum,g=Mu.clone(v.uniforms);this.materialInitialSpectrum=new pe({uniforms:g,vertexShader:u.vertexShader,fragmentShader:v.fragmentShader}),this.materialInitialSpectrum.uniforms.u_wind={value:new f},this.materialInitialSpectrum.uniforms.u_resolution={value:this.resolution},this.materialInitialSpectrum.depthTest=!1;var y=vp.ocean_phase,x=Mu.clone(y.uniforms);this.materialPhase=new pe({uniforms:x,vertexShader:u.vertexShader,fragmentShader:y.fragmentShader}),this.materialPhase.uniforms.u_resolution={value:this.resolution},this.materialPhase.depthTest=!1;var b=vp.ocean_spectrum,w=Mu.clone(b.uniforms);this.materialSpectrum=new pe({uniforms:w,vertexShader:u.vertexShader,fragmentShader:b.fragmentShader}),this.materialSpectrum.uniforms.u_initialSpectrum={value:null},this.materialSpectrum.uniforms.u_resolution={value:this.resolution},this.materialSpectrum.depthTest=!1;var _=vp.ocean_normals,S=Mu.clone(_.uniforms);this.materialNormal=new pe({uniforms:S,vertexShader:u.vertexShader,fragmentShader:_.fragmentShader}),this.materialNormal.uniforms.u_displacementMap={value:null},this.materialNormal.uniforms.u_resolution={value:this.resolution},this.materialNormal.depthTest=!1;var A=vp.ocean_main,M=Mu.clone(A.uniforms);this.materialOcean=new pe({uniforms:M,vertexShader:A.vertexShader,fragmentShader:A.fragmentShader}),this.materialOcean.uniforms.u_geometrySize={value:this.resolution},this.materialOcean.uniforms.u_displacementMap={value:this.displacementMapFramebuffer.texture},this.materialOcean.uniforms.u_normalMap={value:this.normalMapFramebuffer.texture},this.materialOcean.uniforms.u_oceanColor={value:this.oceanColor},this.materialOcean.uniforms.u_skyColor={value:this.skyColor},this.materialOcean.uniforms.u_sunDirection={value:new i(this.sunDirectionX,this.sunDirectionY,this.sunDirectionZ)},this.materialOcean.uniforms.u_exposure={value:this.exposure},this.materialOceanHorizontal.blending=0,this.materialOceanVertical.blending=0,this.materialInitialSpectrum.blending=0,this.materialPhase.blending=0,this.materialSpectrum.blending=0,this.materialNormal.blending=0,this.materialOcean.blending=0,this.screenQuad=new k(new xe(2,2)),this.scene.add(this.screenQuad),this.generateSeedPhaseTexture(),this.generateMesh()};Uv.prototype.generateMesh=function(){var e=new xe(this.geometrySize,this.geometrySize,this.geometryResolution,this.geometryResolution);e.rotateX(-Math.PI/2),this.oceanMesh=new k(e,this.materialOcean)},Uv.prototype.render=function(){this.scene.overrideMaterial=null,this.changed&&this.renderInitialSpectrum(),this.renderWavePhase(),this.renderSpectrum(),this.renderSpectrumFFT(),this.renderNormalMap(),this.scene.overrideMaterial=null},Uv.prototype.generateSeedPhaseTexture=function(){var e=this;this.pingPhase=!0;for(var t=new Ds.Float32Array(this.resolution*this.resolution*4),r=0;r0){for(var t=0,r=this.objectsDeferred.length;t0&&(i=Fn(this.objectsDeferred,"object",e),i!==-1&&this.objectsDeferred.splice(i,1))},extend:function(e){var t,r,i,n,a=this;if(e instanceof kv)for(i=e.objectsData,t=0,r=i.length;t0||(t=Number.MAX_VALUE),n instanceof i&&(n=this.utilVec31Search.copy(n).normalize(),m=this.utilVec32Search.set(1,1,1).divide(n)),a=0,o=this.root.nodesIndices.length;a y-axis, [-pi/2, pi/2]","\tfloat phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]","\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );","\tvec3 L0 = vec3( 0.1 ) * Fex;","\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );","\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;","\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );","\tvec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );","\tvec3 color = curr * whiteScale;","\tvec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );","\tgl_FragColor = vec4( retColor, 1.0 );","}"].join("\n")};var Iv=function(e,t){k.call(this,e);var n=this;t=t||{};var a=void 0!==t.textureWidth?t.textureWidth:512,o=void 0!==t.textureHeight?t.textureHeight:512,s=void 0!==t.clipBias?t.clipBias:0,l=void 0!==t.alpha?t.alpha:1,c=void 0!==t.time?t.time:0,h=void 0!==t.waterNormals?t.waterNormals:null,d=void 0!==t.sunDirection?t.sunDirection:new i(.70707,.70707,0),p=new u(void 0!==t.sunColor?t.sunColor:16777215),f=new u(void 0!==t.waterColor?t.waterColor:8355711),m=void 0!==t.eye?t.eye:new i(0,0,0),g=void 0!==t.distortionScale?t.distortionScale:20,y=void 0!==t.side?t.side:Js,x=void 0!==t.fog&&t.fog,b=new ze,w=new i,_=new i,S=new i,A=new r,M=new i(0,0,(-1)),T=new v,E=new i,C=new i,L=new v,P=new r,N=new de,O={minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1},D=new ge(a,o,O);Fs.isPowerOfTwo(a)&&Fs.isPowerOfTwo(o)||(D.texture.generateMipmaps=!1);var F={uniforms:Mu.merge([mp.fog,mp.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new r},sunColor:{value:new u(8355711)},sunDirection:{value:new i(.70707,.70707,0)},eye:{value:new i},waterColor:{value:new u(5592405)}}]),vertexShader:["uniform mat4 textureMatrix;","uniform float time;","varying vec4 mirrorCoord;","varying vec4 worldPosition;",fp.fog_pars_vertex,fp.shadowmap_pars_vertex,"void main() {","\tmirrorCoord = modelMatrix * vec4( position, 1.0 );","\tworldPosition = mirrorCoord.xyzw;","\tmirrorCoord = textureMatrix * mirrorCoord;","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * mvPosition;",fp.fog_vertex,fp.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D mirrorSampler;","uniform float alpha;","uniform float time;","uniform float size;","uniform float distortionScale;","uniform sampler2D normalSampler;","uniform vec3 sunColor;","uniform vec3 sunDirection;","uniform vec3 eye;","uniform vec3 waterColor;","varying vec4 mirrorCoord;","varying vec4 worldPosition;","vec4 getNoise( vec2 uv ) {","\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);","\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );","\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );","\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );","\tvec4 noise = texture2D( normalSampler, uv0 ) +","\t\ttexture2D( normalSampler, uv1 ) +","\t\ttexture2D( normalSampler, uv2 ) +","\t\ttexture2D( normalSampler, uv3 );","\treturn noise * 0.5 - 1.0;","}","void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {","\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );","\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );","\tspecularColor += pow( direction, shiny ) * sunColor * spec;","\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;","}",fp.common,fp.packing,fp.bsdfs,fp.fog_pars_fragment,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.shadowmask_pars_fragment,"void main() {","\tvec4 noise = getNoise( worldPosition.xz * size );","\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );","\tvec3 diffuseLight = vec3(0.0);","\tvec3 specularLight = vec3(0.0);","\tvec3 worldToEye = eye-worldPosition.xyz;","\tvec3 eyeDirection = normalize( worldToEye );","\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );","\tfloat distance = length(worldToEye);","\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;","\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.z + distortion ) );","\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );","\tfloat rf0 = 0.3;","\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );","\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;","\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);","\tvec3 outgoingLight = albedo;","\tgl_FragColor = vec4( outgoingLight, alpha );",fp.tonemapping_fragment,fp.fog_fragment,"}"].join("\n")},R=new pe({fragmentShader:F.fragmentShader,vertexShader:F.vertexShader,uniforms:Mu.clone(F.uniforms),transparent:!0,lights:!0,side:y,fog:x});R.uniforms.mirrorSampler.value=D.texture,R.uniforms.textureMatrix.value=P,R.uniforms.alpha.value=l,R.uniforms.time.value=c,R.uniforms.normalSampler.value=h,R.uniforms.sunColor.value=p,R.uniforms.waterColor.value=f,R.uniforms.sunDirection.value=d,R.uniforms.distortionScale.value=g,R.uniforms.eye.value=m,n.material=R,n.onBeforeRender=function(e,t,r){if(_.setFromMatrixPosition(n.matrixWorld),S.setFromMatrixPosition(r.matrixWorld),A.extractRotation(n.matrixWorld),w.set(0,0,1),w.applyMatrix4(A),E.subVectors(_,S),!(E.dot(w)>0)){E.reflect(w).negate(),E.add(_),A.extractRotation(r.matrixWorld),M.set(0,0,-1),M.applyMatrix4(A),M.add(S),C.subVectors(_,M),C.reflect(w).negate(),C.add(_),N.position.copy(E),N.up.set(0,1,0),N.up.applyMatrix4(A),N.up.reflect(w),N.lookAt(C),N.far=r.far,N.updateMatrixWorld(),N.projectionMatrix.copy(r.projectionMatrix),P.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),P.multiply(N.projectionMatrix),P.multiply(N.matrixWorldInverse),b.setFromNormalAndCoplanarPoint(w,_),b.applyMatrix4(N.matrixWorldInverse),T.set(b.normal.x,b.normal.y,b.normal.z,b.constant);var i=N.projectionMatrix;L.x=(Math.sign(T.x)+i.elements[8])/i.elements[0],L.y=(Math.sign(T.y)+i.elements[9])/i.elements[5],L.z=-1,L.w=(1+i.elements[10])/i.elements[14],T.multiplyScalar(2/T.dot(L)),i.elements[2]=T.x,i.elements[6]=T.y,i.elements[10]=T.z+1-s,i.elements[14]=T.w,m.setFromMatrixPosition(r.matrixWorld);var a=e.getRenderTarget(),o=e.vr.enabled,l=e.shadowMap.autoUpdate;n.visible=!1,e.vr.enabled=!1,e.shadowMap.autoUpdate=!1,e.render(t,N,D,!0),n.visible=!0,e.vr.enabled=o,e.shadowMap.autoUpdate=l,e.setRenderTarget(a)}}};Iv.prototype=Object.create(k.prototype),Iv.prototype.constructor=Iv,Object.assign(En.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=("undefined"==typeof performance?Date:performance).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}),Cn.prototype=Object.create(k.prototype),Cn.prototype.constructor=Cn,Cn.Water2Shader={uniforms:{color:{type:"c",value:null},reflectivity:{type:"f",value:0},tReflectionMap:{type:"t",value:null},tRefractionMap:{type:"t",value:null},tNormalMap0:{type:"t",value:null},tNormalMap1:{type:"t",value:null},textureMatrix:{type:"m4",value:null},config:{type:"v4",value:new v}},vertexShader:["#include ","uniform mat4 textureMatrix;","varying vec4 vCoord;","varying vec2 vUv;","varying vec3 vToEye;","void main() {","\tvUv = uv;","\tvCoord = textureMatrix * vec4( position, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvToEye = cameraPosition - worldPosition.xyz;","\tvec4 mvPosition = viewMatrix * worldPosition;","\tgl_Position = projectionMatrix * mvPosition;","\t#include ","}"].join("\n"),fragmentShader:["#include ","#include ","uniform sampler2D tReflectionMap;","uniform sampler2D tRefractionMap;","uniform sampler2D tNormalMap0;","uniform sampler2D tNormalMap1;","#ifdef USE_FLOWMAP","\tuniform sampler2D tFlowMap;","#else","\tuniform vec2 flowDirection;","#endif","uniform vec3 color;","uniform float reflectivity;","uniform vec4 config;","varying vec4 vCoord;","varying vec2 vUv;","varying vec3 vToEye;","void main() {","\tfloat flowMapOffset0 = config.x;","\tfloat flowMapOffset1 = config.y;","\tfloat halfCycle = config.z;","\tfloat scale = config.w;","\tvec3 toEye = normalize( vToEye );","\tvec2 flow;","\t#ifdef USE_FLOWMAP","\t\tflow = texture2D( tFlowMap, vUv ).rg * 2.0 - 1.0;","\t#else","\t\tflow = flowDirection;","\t#endif","\tflow.x *= - 1.0;","\tvec4 normalColor0 = texture2D( tNormalMap0, ( vUv * scale ) + flow * flowMapOffset0 );","\tvec4 normalColor1 = texture2D( tNormalMap1, ( vUv * scale ) + flow * flowMapOffset1 );","\tfloat flowLerp = abs( halfCycle - flowMapOffset0 ) / halfCycle;","\tvec4 normalColor = mix( normalColor0, normalColor1, flowLerp );","\tvec3 normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );","\tfloat theta = max( dot( toEye, normal ), 0.0 );","\tfloat reflectance = reflectivity + ( 1.0 - reflectivity ) * pow( ( 1.0 - theta ), 5.0 );","\tvec3 coord = vCoord.xyz / vCoord.w;","\tvec2 uv = coord.xy + coord.z * normal.xz * 0.05;","\tvec4 reflectColor = texture2D( tReflectionMap, vec2( 1.0 - uv.x, uv.y ) );","\tvec4 refractColor = texture2D( tRefractionMap, uv );","\tgl_FragColor = vec4( color, 1.0 ) * mix( refractColor, reflectColor, reflectance );","\t#include ","\t#include ","\t#include ","}"].join("\n")};var Uv=function(e,t,r,n){function a(e,t){return void 0!==e?e:t}this.changed=!0,this.initial=!0,this.oceanCamera=new me,this.oceanCamera.position.z=1,this.renderer=e,this.renderer.clearColor(16777215),this.scene=new fe,n=n||{},this.clearColor=a(n.CLEAR_COLOR,[1,1,1,0]),this.geometryOrigin=a(n.GEOMETRY_ORIGIN,[-1e3,-1e3]),this.sunDirectionX=a(n.SUN_DIRECTION[0],-1),this.sunDirectionY=a(n.SUN_DIRECTION[1],1),this.sunDirectionZ=a(n.SUN_DIRECTION[2],1),this.oceanColor=a(n.OCEAN_COLOR,new i(.004,.016,.047)),this.skyColor=a(n.SKY_COLOR,new i(3.2,9.6,12.8)),this.exposure=a(n.EXPOSURE,.35),this.geometryResolution=a(n.GEOMETRY_RESOLUTION,32),this.geometrySize=a(n.GEOMETRY_SIZE,2e3),this.resolution=a(n.RESOLUTION,64),this.floatSize=a(n.SIZE_OF_FLOAT,4),this.windX=a(n.INITIAL_WIND[0],10),this.windY=a(n.INITIAL_WIND[1],10),this.size=a(n.INITIAL_SIZE,250),this.choppiness=a(n.INITIAL_CHOPPINESS,1.5),this.matrixNeedsUpdate=!1;var o=a(n.USE_HALF_FLOAT,!1)?dc:hc,s={minFilter:rc,magFilter:rc,wrapS:Zl,wrapT:Zl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o},l={minFilter:$l,magFilter:$l,wrapS:Zl,wrapT:Zl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o},c={minFilter:$l,magFilter:$l,wrapS:Jl,wrapT:Jl,format:xc,stencilBuffer:!1,depthBuffer:!1,premultiplyAlpha:!1,type:o};this.initialSpectrumFramebuffer=new ge(this.resolution,this.resolution,c),this.spectrumFramebuffer=new ge(this.resolution,this.resolution,l),this.pingPhaseFramebuffer=new ge(this.resolution,this.resolution,l),this.pongPhaseFramebuffer=new ge(this.resolution,this.resolution,l),this.pingTransformFramebuffer=new ge(this.resolution,this.resolution,l),this.pongTransformFramebuffer=new ge(this.resolution,this.resolution,l),this.displacementMapFramebuffer=new ge(this.resolution,this.resolution,s),this.normalMapFramebuffer=new ge(this.resolution,this.resolution,s);var u=vp.ocean_sim_vertex,h=vp.ocean_subtransform,d=Mu.clone(h.uniforms);this.materialOceanHorizontal=new pe({uniforms:d,vertexShader:u.vertexShader,fragmentShader:"#define HORIZONTAL \n"+h.fragmentShader}),this.materialOceanHorizontal.uniforms.u_transformSize={value:this.resolution},this.materialOceanHorizontal.uniforms.u_subtransformSize={value:null},this.materialOceanHorizontal.uniforms.u_input={value:null},this.materialOceanHorizontal.depthTest=!1;var p=vp.ocean_subtransform,m=Mu.clone(p.uniforms);this.materialOceanVertical=new pe({uniforms:m,vertexShader:u.vertexShader,fragmentShader:p.fragmentShader}),this.materialOceanVertical.uniforms.u_transformSize={value:this.resolution},this.materialOceanVertical.uniforms.u_subtransformSize={value:null},this.materialOceanVertical.uniforms.u_input={value:null},this.materialOceanVertical.depthTest=!1;var v=vp.ocean_initial_spectrum,g=Mu.clone(v.uniforms);this.materialInitialSpectrum=new pe({uniforms:g,vertexShader:u.vertexShader,fragmentShader:v.fragmentShader}),this.materialInitialSpectrum.uniforms.u_wind={value:new f},this.materialInitialSpectrum.uniforms.u_resolution={value:this.resolution},this.materialInitialSpectrum.depthTest=!1;var y=vp.ocean_phase,x=Mu.clone(y.uniforms);this.materialPhase=new pe({uniforms:x,vertexShader:u.vertexShader,fragmentShader:y.fragmentShader}),this.materialPhase.uniforms.u_resolution={value:this.resolution},this.materialPhase.depthTest=!1;var b=vp.ocean_spectrum,w=Mu.clone(b.uniforms);this.materialSpectrum=new pe({uniforms:w,vertexShader:u.vertexShader,fragmentShader:b.fragmentShader}),this.materialSpectrum.uniforms.u_initialSpectrum={value:null},this.materialSpectrum.uniforms.u_resolution={value:this.resolution},this.materialSpectrum.depthTest=!1;var _=vp.ocean_normals,S=Mu.clone(_.uniforms);this.materialNormal=new pe({uniforms:S,vertexShader:u.vertexShader,fragmentShader:_.fragmentShader}),this.materialNormal.uniforms.u_displacementMap={value:null},this.materialNormal.uniforms.u_resolution={value:this.resolution},this.materialNormal.depthTest=!1;var A=vp.ocean_main,M=Mu.clone(A.uniforms);this.materialOcean=new pe({uniforms:M,vertexShader:A.vertexShader,fragmentShader:A.fragmentShader}),this.materialOcean.uniforms.u_geometrySize={value:this.resolution},this.materialOcean.uniforms.u_displacementMap={value:this.displacementMapFramebuffer.texture},this.materialOcean.uniforms.u_normalMap={value:this.normalMapFramebuffer.texture},this.materialOcean.uniforms.u_oceanColor={value:this.oceanColor},this.materialOcean.uniforms.u_skyColor={value:this.skyColor},this.materialOcean.uniforms.u_sunDirection={value:new i(this.sunDirectionX,this.sunDirectionY,this.sunDirectionZ)},this.materialOcean.uniforms.u_exposure={value:this.exposure},this.materialOceanHorizontal.blending=0,this.materialOceanVertical.blending=0,this.materialInitialSpectrum.blending=0,this.materialPhase.blending=0,this.materialSpectrum.blending=0,this.materialNormal.blending=0,this.materialOcean.blending=0,this.screenQuad=new k(new xe(2,2)),this.scene.add(this.screenQuad),this.generateSeedPhaseTexture(),this.generateMesh()};Uv.prototype.generateMesh=function(){var e=new xe(this.geometrySize,this.geometrySize,this.geometryResolution,this.geometryResolution);e.rotateX(-Math.PI/2),this.oceanMesh=new k(e,this.materialOcean)},Uv.prototype.render=function(){this.scene.overrideMaterial=null,this.changed&&this.renderInitialSpectrum(),this.renderWavePhase(),this.renderSpectrum(),this.renderSpectrumFFT(),this.renderNormalMap(),this.scene.overrideMaterial=null},Uv.prototype.generateSeedPhaseTexture=function(){var e=this;this.pingPhase=!0;for(var t=new Ds.Float32Array(this.resolution*this.resolution*4),r=0;r0){for(var t=0,r=this.objectsDeferred.length;t0&&(i=Fn(this.objectsDeferred,"object",e),i!==-1&&this.objectsDeferred.splice(i,1))},extend:function(e){var t,r,i,n,a=this;if(e instanceof kv)for(i=e.objectsData,t=0,r=i.length;t0||(t=Number.MAX_VALUE),n instanceof i&&(n=this.utilVec31Search.copy(n).normalize(),m=this.utilVec32Search.set(1,1,1).divide(n)),a=0,o=this.root.nodesIndices.length;a0?e.radius:1,this.indexOctant=e.indexOctant,this.depth=0,this.reset(),this.setParent(e.parent),this.overlap=this.radius*this.tree.overlapPct,this.radiusOverlap=this.radius+this.overlap,this.left=this.position.x-this.radiusOverlap,this.right=this.position.x+this.radiusOverlap,this.bottom=this.position.y-this.radiusOverlap,this.top=this.position.y+this.radiusOverlap,this.back=this.position.z-this.radiusOverlap,this.front=this.position.z+this.radiusOverlap,this.tree.scene&&(this.visual=new Yt(this.tree.visualGeometry,this.tree.visualMaterial),this.visual.scale.set(2*this.radiusOverlap,2*this.radiusOverlap,2*this.radiusOverlap),this.visual.position.copy(this.position),this.tree.scene.add(this.visual))};zv.prototype={setParent:function(e){e!==this&&this.parent!==e&&(this.parent=e,this.updateProperties())},updateProperties:function(){var e,t,r=this;for(this.parent instanceof zv?(this.tree=this.parent.tree,this.depth=this.parent.depth+1):this.depth=0,e=0,t=this.nodesIndices.length;e-1&&this.nodesIndices.length>0?(i=this.branch(r),i.addObject(e)):r<-1&&this.parent instanceof zv?this.parent.addObject(e):(t=Dn(this.objects,e),t===-1&&this.objects.push(e),e.node=this,this.checkGrow())},addObjectWithoutCheck:function(e){var t,r,i,n=this;for(t=0,r=e.length;t0)for(t=0,r=i.length;t=0;r--)if(n=s.objects[r],n.object===e&&(s.objects.splice(r,1),n.node=void 0,t.objectsDataRemoved.push(n),o=!0,!n.faces&&!n.vertices)){t.searchComplete=!0;break}if(o===!0&&t.nodesRemovedFrom.push(this),t.searchComplete!==!0)for(r=0,i=this.nodesIndices.length;rthis.tree.objectsThreshold&&this.tree.objectsThreshold>0&&this.grow()},grow:function(){var e,t,r,i,n=this,a=[],o=[],s=[],l=[],c=[];for(r=0,i=this.objects.length;r-1?(s.push(t),l.push(e)):e<-1?(a.push(t),o.push(e)):c.push(t);s.length>0&&(c=c.concat(this.split(s,l))),a.length>0&&(c=c.concat(this.expand(a,o))),this.objects=c,this.checkMerge()},split:function(e,t){var r,i,n,a,o,s,l=this;if(this.depth-1?(o=l.branch(n),o.addObject(a)):s.push(a);e===this.objects&&(this.objects=s)}else s=this.objects;return s},branch:function(e){var t,r,n,a,o,s;return this.nodesByIndex[e]instanceof zv?t=this.nodesByIndex[e]:(n=.5*this.radiusOverlap,r=n*this.tree.overlapPct,a=n-r,o=this.utilVec31Branch.set(1&e?a:-a,2&e?a:-a,4&e?a:-a),s=(new i).addVectors(this.position,o),t=new zv({tree:this.tree,parent:this,position:s,radius:n,indexOctant:e}),this.addNode(t,e)),t},expand:function(e,t){var r,n,a,o,s,l,c,u,h,d,p,f,m,v,g,y,x,b,w,_,S,A,M,T,E,C,L,P,N,O=this,D=this.tree.INDEX_OUTSIDE_MAP,F=this.utilVec31Expand;if(this.tree.root.getDepthEnd()0)for(h=D.slice(0),h.sort(function(e,t){return t.count-e.count}),d=h[0],m=1|d.index,g=h[1],y=h[2],p=(1|g.index)!==m?g:y,v=1|p.index,g=h[2],y=h[3],x=h[4],b=1|g.index,w=1|y.index,f=b!==m&&b!==v?g:w!==m&&w!==v?y:x,_=d.x+p.x+f.x,S=d.y+p.y+f.y,A=d.z+p.z+f.z,l=this.getOctantIndexFromPosition(_,S,A),u=this.getOctantIndexFromPosition(-_,-S,-A),M=this.overlap,T=this.radius,C=this.tree.overlapPct>0?M/(.5*this.tree.overlapPct*(1+this.tree.overlapPct)):2*T,L=C*this.tree.overlapPct,E=C+L-(T+M),F.set(1&l?E:-E,2&l?E:-E,4&l?E:-E),P=(new i).addVectors(this.position,F),N=new zv({tree:this.tree,position:P,radius:C}),N.addNode(this,u),this.tree.setRoot(N),r=0,n=s.length;r0){for(a=0,o=this.objects.length,e=0,t=this.nodesIndices.length;ea)&&(n=r,a=i);o-=a,oh)return o+r>h&&(p^=i>0?this.tree.FLAG_POS_X:this.tree.FLAG_NEG_X),s+r>h&&(p^=n>0?this.tree.FLAG_POS_Y:this.tree.FLAG_NEG_Y),l+r>h&&(p^=a>0?this.tree.FLAG_POS_Z:this.tree.FLAG_NEG_Z),e.indexOctant=-p-this.tree.INDEX_OUTSIDE_OFFSET,e.indexOctant;if(i-r>-d)p=1|p;else if(!(i+r-d)p=2|p;else if(!(n+r-d)p=4|p;else if(!(a+r0&&(i=1|i),t>0&&(i=2|i),r>0&&(i=4|i),i},search:function(e,t,r,i,n){var a,o,s,l,c=this;if(l=i?this.intersectRay(e,i,t,n):this.intersectSphere(e,t),l===!0)for(r=r.concat(this.objects),a=0,o=this.nodesIndices.length;athis.right&&(r-=Math.pow(i-this.right,2)),nthis.top&&(r-=Math.pow(n-this.top,2)),athis.front&&(r-=Math.pow(a-this.front,2)),r>=0},intersectRay:function(e,t,r,i){"undefined"==typeof i&&(i=this.utilVec31Ray.set(1,1,1).divide(t));var n,a=(this.left-e.x)*i.x,o=(this.right-e.x)*i.x,s=(this.bottom-e.y)*i.y,l=(this.top-e.y)*i.y,c=(this.back-e.z)*i.z,u=(this.front-e.z)*i.z,h=Math.min(Math.min(Math.max(a,o),Math.max(s,l)),Math.max(c,u));return!(h<0)&&(n=Math.max(Math.max(Math.min(a,o),Math.min(s,l)),Math.min(c,u)),!(n>h||n>r))},getDepthEnd:function(e){var t,r,i,n=this;if(this.nodesIndices.length>0)for(t=0,r=this.nodesIndices.length;te?this.depth:e;return e},getNodeCountEnd:function(){return this.tree.root.getNodeCountRecursive()+1},getNodeCountRecursive:function(){var e,t,r=this,i=this.nodesIndices.length;for(e=0,t=this.nodesIndices.length;e ":" octree ROOT > ",this," // id: ",this.id," // indexOctant: ",this.indexOctant," // position: ",this.position.x,this.position.y,this.position.z," // radius: ",this.radius," // depth: ",this.depth),console.log(this.parent?e+" ":" ","+ objects ( ",this.objects.length," ) ",this.objects),console.log(this.parent?e+" ":" ","+ children ( ",this.nodesIndices.length," )",this.nodesIndices,this.nodesByIndex),t=0,r=this.nodesIndices.length;t0&&(e.geometry.faces=a),r=this.intersectObject(e,t),a.length>0&&(e.geometry.faces=n)):r=this.intersectObject(e,t),r},je.prototype.intersectOctreeObjects=function(e,t){var r,i,n=this,a=[];for(r=0,i=e.length;r16&&(c*=2);for(var d=r>16?6:1,p=0,m=0,v=r,g=0;g16&&(r/=2)}};jv.prototype={constructor:jv,update:function(e){var t=e.gammaInput,r=e.gammaOutput,i=e.toneMapping,n=e.toneMappingExposure,a=e.getRenderTarget();e.gammaInput=!1,e.gammaOutput=!1,e.toneMapping=kl,e.toneMappingExposure=1,e.render(this.scene,this.camera,this.CubeUVRenderTarget,!1),e.setRenderTarget(a),e.toneMapping=i,e.toneMappingExposure=n,e.gammaInput=t,e.gammaOutput=r},getShader:function(){var e=new pe({uniforms:{faceIndex:{value:0},mapSize:{value:0},envMap:{value:null},testColor:{value:new i(1,1,1)}},vertexShader:"precision highp float;\t\t\t\tvarying vec2 vUv;\t\t\t\tvoid main() {\t\t\t\t\tvUv = uv;\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\t\t\t\t}",fragmentShader:"precision highp float;\t\t\t\tvarying vec2 vUv;\t\t\t\tuniform samplerCube envMap;\t\t\t\tuniform float mapSize;\t\t\t\tuniform vec3 testColor;\t\t\t\tuniform int faceIndex;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec3 sampleDirection;\t\t\t\t\tvec2 uv = vUv;\t\t\t\t\tuv = uv * 2.0 - 1.0;\t\t\t\t\tuv.y *= -1.0;\t\t\t\t\tif(faceIndex == 0) {\t\t\t\t\t\tsampleDirection = normalize(vec3(1.0, uv.y, -uv.x));\t\t\t\t\t} else if(faceIndex == 1) {\t\t\t\t\t\tsampleDirection = normalize(vec3(uv.x, 1.0, uv.y));\t\t\t\t\t} else if(faceIndex == 2) {\t\t\t\t\t\tsampleDirection = normalize(vec3(uv.x, uv.y, 1.0));\t\t\t\t\t} else if(faceIndex == 3) {\t\t\t\t\t\tsampleDirection = normalize(vec3(-1.0, uv.y, uv.x));\t\t\t\t\t} else if(faceIndex == 4) {\t\t\t\t\t\tsampleDirection = normalize(vec3(uv.x, -1.0, -uv.y));\t\t\t\t\t} else {\t\t\t\t\t\tsampleDirection = normalize(vec3(-uv.x, uv.y, -1.0));\t\t\t\t\t}\t\t\t\t\tvec4 color = envMapTexelToLinear( textureCube( envMap, sampleDirection ) );\t\t\t\t\tgl_FragColor = linearToOutputTexel( color );\t\t\t\t}",blending:nl});return e.type="PMREMCubeUVPacker",e},dispose:function(){for(var e=this,t=0,r=this.objects.length;t\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform int faceIndex;\n\t\t\t\tuniform float roughness;\n\t\t\t\tuniform samplerCube envMap;\n\t\t\t\tuniform float mapSize;\n\t\t\t\tuniform vec3 testColor;\n\t\t\t\tuniform vec3 queryScale;\n\t\t\t\t\n\t\t\t\tfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\t\t\t\t\tfloat a = ggxRoughness + 0.0001;\n\t\t\t\t\ta *= a;\n\t\t\t\t\treturn ( 2.0 / a - 2.0 );\n\t\t\t\t}\n\t\t\t\tvec3 ImportanceSamplePhong(vec2 uv, mat3 vecSpace, float specPow) {\n\t\t\t\t\tfloat phi = uv.y * 2.0 * PI;\n\t\t\t\t\tfloat cosTheta = pow(1.0 - uv.x, 1.0 / (specPow + 1.0));\n\t\t\t\t\tfloat sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n\t\t\t\t\tvec3 sampleDir = vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);\n\t\t\t\t\treturn vecSpace * sampleDir;\n\t\t\t\t}\n\t\t\t\tvec3 ImportanceSampleGGX( vec2 uv, mat3 vecSpace, float Roughness )\n\t\t\t\t{\n\t\t\t\t\tfloat a = Roughness * Roughness;\n\t\t\t\t\tfloat Phi = 2.0 * PI * uv.x;\n\t\t\t\t\tfloat CosTheta = sqrt( (1.0 - uv.y) / ( 1.0 + (a*a - 1.0) * uv.y ) );\n\t\t\t\t\tfloat SinTheta = sqrt( 1.0 - CosTheta * CosTheta );\n\t\t\t\t\treturn vecSpace * vec3(SinTheta * cos( Phi ), SinTheta * sin( Phi ), CosTheta);\n\t\t\t\t}\n\t\t\t\tmat3 matrixFromVector(vec3 n) {\n\t\t\t\t\tfloat a = 1.0 / (1.0 + n.z);\n\t\t\t\t\tfloat b = -n.x * n.y * a;\n\t\t\t\t\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\t\t\t\t\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\t\t\t\t\treturn mat3(b1, b2, n);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvec4 testColorMap(float Roughness) {\n\t\t\t\t\tvec4 color;\n\t\t\t\t\tif(faceIndex == 0)\n\t\t\t\t\t\tcolor = vec4(1.0,0.0,0.0,1.0);\n\t\t\t\t\telse if(faceIndex == 1)\n\t\t\t\t\t\tcolor = vec4(0.0,1.0,0.0,1.0);\n\t\t\t\t\telse if(faceIndex == 2)\n\t\t\t\t\t\tcolor = vec4(0.0,0.0,1.0,1.0);\n\t\t\t\t\telse if(faceIndex == 3)\n\t\t\t\t\t\tcolor = vec4(1.0,1.0,0.0,1.0);\n\t\t\t\t\telse if(faceIndex == 4)\n\t\t\t\t\t\tcolor = vec4(0.0,1.0,1.0,1.0);\n\t\t\t\t\telse\n\t\t\t\t\t\tcolor = vec4(1.0,0.0,1.0,1.0);\n\t\t\t\t\tcolor *= ( 1.0 - Roughness );\n\t\t\t\t\treturn color;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec3 sampleDirection;\n\t\t\t\t\tvec2 uv = vUv*2.0 - 1.0;\n\t\t\t\t\tfloat offset = -1.0/mapSize;\n\t\t\t\t\tconst float a = -1.0;\n\t\t\t\t\tconst float b = 1.0;\n\t\t\t\t\tfloat c = -1.0 + offset;\n\t\t\t\t\tfloat d = 1.0 - offset;\n\t\t\t\t\tfloat bminusa = b - a;\n\t\t\t\t\tuv.x = (uv.x - a)/bminusa * d - (uv.x - b)/bminusa * c;\n\t\t\t\t\tuv.y = (uv.y - a)/bminusa * d - (uv.y - b)/bminusa * c;\n\t\t\t\t\tif (faceIndex==0) {\n\t\t\t\t\t\tsampleDirection = vec3(1.0, -uv.y, -uv.x);\n\t\t\t\t\t} else if (faceIndex==1) {\n\t\t\t\t\t\tsampleDirection = vec3(-1.0, -uv.y, uv.x);\n\t\t\t\t\t} else if (faceIndex==2) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, 1.0, uv.y);\n\t\t\t\t\t} else if (faceIndex==3) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, -1.0, -uv.y);\n\t\t\t\t\t} else if (faceIndex==4) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, -uv.y, 1.0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsampleDirection = vec3(-uv.x, -uv.y, -1.0);\n\t\t\t\t\t}\n\t\t\t\t\tmat3 vecSpace = matrixFromVector(normalize(sampleDirection * queryScale));\n\t\t\t\t\tvec3 rgbColor = vec3(0.0);\n\t\t\t\t\tconst int NumSamples = SAMPLES_PER_LEVEL;\n\t\t\t\t\tvec3 vect;\n\t\t\t\t\tfloat weight = 0.0;\n\t\t\t\t\tfor( int i = 0; i < NumSamples; i ++ ) {\n\t\t\t\t\t\tfloat sini = sin(float(i));\n\t\t\t\t\t\tfloat cosi = cos(float(i));\n\t\t\t\t\t\tfloat r = rand(vec2(sini, cosi));\n\t\t\t\t\t\tvect = ImportanceSampleGGX(vec2(float(i) / float(NumSamples), r), vecSpace, roughness);\n\t\t\t\t\t\tfloat dotProd = dot(vect, normalize(sampleDirection));\n\t\t\t\t\t\tweight += dotProd;\n\t\t\t\t\t\tvec3 color = envMapTexelToLinear(textureCube(envMap,vect)).rgb;\n\t\t\t\t\t\trgbColor.rgb += color;\n\t\t\t\t\t}\n\t\t\t\t\trgbColor /= float(NumSamples);\n\t\t\t\t\t//rgbColor = testColorMap( roughness ).rgb;\n\t\t\t\t\tgl_FragColor = linearToOutputTexel( vec4( rgbColor, 1.0 ) );\n\t\t\t\t}",blending:nl});return e.type="PMREMGenerator",e},dispose:function(){for(var e=this,t=0,r=this.cubeLods.length;t","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","float l = linearToRelativeLuminance( texel.rgb );","gl_FragColor = vec4( l, l, l, texel.w );","}"].join("\n")},Xv={uniforms:{tDiffuse:{value:null},averageLuminance:{value:1},luminanceMap:{value:null},maxLuminance:{value:16},minLuminance:{value:.01},middleGrey:{value:.6}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform float middleGrey;","uniform float minLuminance;","uniform float maxLuminance;","#ifdef ADAPTED_LUMINANCE","uniform sampler2D luminanceMap;","#else","uniform float averageLuminance;","#endif","vec3 ToneMap( vec3 vColor ) {","#ifdef ADAPTED_LUMINANCE","float fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;","#else","float fLumAvg = averageLuminance;","#endif","float fLumPixel = linearToRelativeLuminance( vColor );","float fLumScaled = (fLumPixel * middleGrey) / max( minLuminance, fLumAvg );","float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);","return fLumCompressed * vColor;","}","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );","}"].join("\n")},Hv=function(e,t){Tv.call(this),this.resolution=void 0!==t?t:256,this.needsInit=!0,this.adaptive=void 0===e||!!e,this.luminanceRT=null,this.previousLuminanceRT=null,this.currentLuminanceRT=null,void 0===Gv&&console.error("AdaptiveToneMappingPass relies on CopyShader");var r=Gv;this.copyUniforms=Mu.clone(r.uniforms),this.materialCopy=new pe({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,blending:nl,depthTest:!1}),void 0===Wv&&console.error("AdaptiveToneMappingPass relies on LuminosityShader"),this.materialLuminance=new pe({uniforms:Mu.clone(Wv.uniforms),vertexShader:Wv.vertexShader,fragmentShader:Wv.fragmentShader,blending:nl}),this.adaptLuminanceShader={defines:{MIP_LEVEL_1X1:(Math.log(this.resolution)/Math.log(2)).toFixed(1)},uniforms:{lastLum:{value:null},currentLum:{value:null},minLuminance:{value:.01},delta:{value:.016},tau:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D lastLum;","uniform sampler2D currentLum;","uniform float minLuminance;","uniform float delta;","uniform float tau;","void main() {","vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );","vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );","float fLastLum = max( minLuminance, lastLum.r );","float fCurrentLum = max( minLuminance, currentLum.r );","fCurrentLum *= fCurrentLum;","float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));","gl_FragColor.r = fAdaptedLum;","}"].join("\n")},this.materialAdaptiveLum=new pe({uniforms:Mu.clone(this.adaptLuminanceShader.uniforms),vertexShader:this.adaptLuminanceShader.vertexShader,fragmentShader:this.adaptLuminanceShader.fragmentShader,defines:Object.assign({},this.adaptLuminanceShader.defines),blending:nl}),void 0===Xv&&console.error("AdaptiveToneMappingPass relies on ToneMapShader"),this.materialToneMap=new pe({uniforms:Mu.clone(Xv.uniforms),vertexShader:Xv.vertexShader,fragmentShader:Xv.fragmentShader,blending:nl}),this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};Hv.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Hv,render:function(e,t,r,i,n){this.needsInit&&(this.reset(e),this.luminanceRT.texture.type=r.texture.type,this.previousLuminanceRT.texture.type=r.texture.type,this.currentLuminanceRT.texture.type=r.texture.type,this.needsInit=!1),this.adaptive&&(this.quad.material=this.materialLuminance,this.materialLuminance.uniforms.tDiffuse.value=r.texture,e.render(this.scene,this.camera,this.currentLuminanceRT),this.quad.material=this.materialAdaptiveLum,this.materialAdaptiveLum.uniforms.delta.value=i,this.materialAdaptiveLum.uniforms.lastLum.value=this.previousLuminanceRT.texture,this.materialAdaptiveLum.uniforms.currentLum.value=this.currentLuminanceRT.texture,e.render(this.scene,this.camera,this.luminanceRT),this.quad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.luminanceRT.texture,e.render(this.scene,this.camera,this.previousLuminanceRT)),this.quad.material=this.materialToneMap,this.materialToneMap.uniforms.tDiffuse.value=r.texture,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)},reset:function(e){this.luminanceRT&&this.luminanceRT.dispose(),this.currentLuminanceRT&&this.currentLuminanceRT.dispose(),this.previousLuminanceRT&&this.previousLuminanceRT.dispose();var t={minFilter:rc,magFilter:rc,format:xc};this.luminanceRT=new ge(this.resolution,this.resolution,t),this.luminanceRT.texture.name="AdaptiveToneMappingPass.l",this.luminanceRT.texture.generateMipmaps=!1,this.previousLuminanceRT=new ge(this.resolution,this.resolution,t),this.previousLuminanceRT.texture.name="AdaptiveToneMappingPass.pl",this.previousLuminanceRT.texture.generateMipmaps=!1,t.minFilter=nc,this.currentLuminanceRT=new ge(this.resolution,this.resolution,t),this.currentLuminanceRT.texture.name="AdaptiveToneMappingPass.cl",this.adaptive&&(this.materialToneMap.defines.ADAPTED_LUMINANCE="",this.materialToneMap.uniforms.luminanceMap.value=this.luminanceRT.texture),this.quad.material=new F({color:7829367}),this.materialLuminance.needsUpdate=!0,this.materialAdaptiveLum.needsUpdate=!0,this.materialToneMap.needsUpdate=!0},setAdaptive:function(e){e?(this.adaptive=!0,this.materialToneMap.defines.ADAPTED_LUMINANCE="",this.materialToneMap.uniforms.luminanceMap.value=this.luminanceRT.texture):(this.adaptive=!1,delete this.materialToneMap.defines.ADAPTED_LUMINANCE,this.materialToneMap.uniforms.luminanceMap.value=null),this.materialToneMap.needsUpdate=!0},setAdaptionRate:function(e){e&&(this.materialAdaptiveLum.uniforms.tau.value=Math.abs(e))},setMinLuminance:function(e){e&&(this.materialToneMap.uniforms.minLuminance.value=e,this.materialAdaptiveLum.uniforms.minLuminance.value=e)},setMaxLuminance:function(e){e&&(this.materialToneMap.uniforms.maxLuminance.value=e)},setAverageLuminance:function(e){e&&(this.materialToneMap.uniforms.averageLuminance.value=e)},setMiddleGrey:function(e){e&&(this.materialToneMap.uniforms.middleGrey.value=e)},dispose:function(){this.luminanceRT&&this.luminanceRT.dispose(),this.previousLuminanceRT&&this.previousLuminanceRT.dispose(),this.currentLuminanceRT&&this.currentLuminanceRT.dispose(),this.materialLuminance&&this.materialLuminance.dispose(),this.materialAdaptiveLum&&this.materialAdaptiveLum.dispose(),this.materialCopy&&this.materialCopy.dispose(),this.materialToneMap&&this.materialToneMap.dispose()}});var Yv={uniforms:{damp:{value:.96},tOld:{value:null},tNew:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float damp;","uniform sampler2D tOld;","uniform sampler2D tNew;","varying vec2 vUv;","vec4 when_gt( vec4 x, float y ) {","return max( sign( x - y ), 0.0 );","}","void main() {","vec4 texelOld = texture2D( tOld, vUv );","vec4 texelNew = texture2D( tNew, vUv );","texelOld *= damp * when_gt( texelOld, 0.1 );","gl_FragColor = max(texelNew, texelOld);","}"].join("\n")},qv=function(e){Tv.call(this),void 0===Yv&&console.error("AfterimagePass relies on AfterimageShader"),this.shader=Yv,this.uniforms=Mu.clone(this.shader.uniforms),this.uniforms.damp.value=void 0!==e?e:.96,this.textureComp=new ge(Ds.innerWidth,Ds.innerHeight,{minFilter:rc,magFilter:$l,format:xc}),this.textureOld=new ge(Ds.innerWidth,Ds.innerHeight,{minFilter:rc,magFilter:$l,format:xc}),this.shaderMaterial=new pe({uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.sceneComp=new fe,this.scene=new fe,this.camera=new me((-1),1,1,(-1),0,1),this.camera.position.z=1;var t=new xe(2,2);this.quadComp=new k(t,this.shaderMaterial),this.sceneComp.add(this.quadComp);var r=new F({map:this.textureComp.texture}),i=new k(t,r);this.scene.add(i)};qv.prototype=Object.assign(Object.create(Tv.prototype),{constructor:qv,render:function(e,t,r){this.uniforms.tOld.value=this.textureOld.texture,this.uniforms.tNew.value=r.texture,this.quadComp.material=this.shaderMaterial,e.render(this.sceneComp,this.camera,this.textureComp),e.render(this.scene,this.camera,this.textureOld),this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)}});var Qv={defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{value:null},uImageIncrement:{value:new f(.001953125,0)},cKernel:{value:[]}},vertexShader:["uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float cKernel[ KERNEL_SIZE_INT ];","uniform sampler2D tDiffuse;","uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","vec2 imageCoord = vUv;","vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );","for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {","sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];","imageCoord += uImageIncrement;","}","gl_FragColor = sum;","}"].join("\n"),buildKernel:function(e){function t(e,t){return Math.exp(-(e*e)/(2*t*t))}var r,i,n,a,o=25,s=2*Math.ceil(3*e)+1;for(s>o&&(s=o),a=.5*(s-1),i=new Array(s),n=0,r=0;r","uniform float time;","uniform bool grayscale;","uniform float nIntensity;","uniform float sIntensity;","uniform float sCount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 cTextureScreen = texture2D( tDiffuse, vUv );","float dx = rand( vUv + time );","vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );","vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );","cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;","cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );","if( grayscale ) {","cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );","}","gl_FragColor = vec4( cResult, cTextureScreen.a );","}"].join("\n")},og=function(e,t,r,i){Tv.call(this),void 0===ag&&console.error("FilmPass relies on FilmShader");var n=ag;this.uniforms=Mu.clone(n.uniforms),this.material=new pe({uniforms:this.uniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader}),void 0!==i&&(this.uniforms.grayscale.value=i),void 0!==e&&(this.uniforms.nIntensity.value=e),void 0!==t&&(this.uniforms.sIntensity.value=t),void 0!==r&&(this.uniforms.sCount.value=r),this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};og.prototype=Object.assign(Object.create(Tv.prototype),{constructor:og,render:function(e,t,r,i,n){this.uniforms.tDiffuse.value=r.texture,this.uniforms.time.value+=i,this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)}});var sg={uniforms:{tDiffuse:{value:null},tDisp:{value:null},byp:{value:0},amount:{value:.08},angle:{value:.02},seed:{value:.02},seed_x:{value:.02},seed_y:{value:.02},distortion_x:{value:.5},distortion_y:{value:.6},col_s:{value:.05}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform int byp;","uniform sampler2D tDiffuse;","uniform sampler2D tDisp;","uniform float amount;","uniform float angle;","uniform float seed;","uniform float seed_x;","uniform float seed_y;","uniform float distortion_x;","uniform float distortion_y;","uniform float col_s;","varying vec2 vUv;","float rand(vec2 co){","return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);","}","void main() {","if(byp<1) {","vec2 p = vUv;","float xs = floor(gl_FragCoord.x / 0.5);","float ys = floor(gl_FragCoord.y / 0.5);","vec4 normal = texture2D (tDisp, p*seed*seed);","if(p.ydistortion_x-col_s*seed) {","if(seed_x>0.){","p.y = 1. - (p.y + distortion_y);","}","else {","p.y = distortion_y;","}","}","if(p.xdistortion_y-col_s*seed) {","if(seed_y>0.){","p.x=distortion_x;","}","else {","p.x = 1. - (p.x + distortion_x);","}","}","p.x+=normal.x*seed_x*(seed/5.);","p.y+=normal.y*seed_y*(seed/5.);","vec2 offset = amount * vec2( cos(angle), sin(angle));","vec4 cr = texture2D(tDiffuse, p + offset);","vec4 cga = texture2D(tDiffuse, p);","vec4 cb = texture2D(tDiffuse, p - offset);","gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);","vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);","gl_FragColor = gl_FragColor+ snow;","}","else {","gl_FragColor=texture2D (tDiffuse, vUv);","}","}"].join("\n")},lg=function(e){Tv.call(this),void 0===sg&&console.error("GlitchPass relies on DigitalGlitch");var t=sg;this.uniforms=Mu.clone(t.uniforms),void 0==e&&(e=64),this.uniforms.tDisp.value=this.generateHeightmap(e),this.material=new pe({uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.goWild=!1,this.curF=0,this.generateTrigger()};lg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:lg,render:function(e,t,r,i,n){this.uniforms.tDiffuse.value=r.texture,this.uniforms.seed.value=Math.random(),this.uniforms.byp.value=0,this.curF%this.randX==0||1==this.goWild?(this.uniforms.amount.value=Math.random()/30,this.uniforms.angle.value=Fs.randFloat(-Math.PI,Math.PI),this.uniforms.seed_x.value=Fs.randFloat(-1,1),this.uniforms.seed_y.value=Fs.randFloat(-1,1),this.uniforms.distortion_x.value=Fs.randFloat(0,1),this.uniforms.distortion_y.value=Fs.randFloat(0,1),this.curF=0,this.generateTrigger()):this.curF%this.randX cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );","}","return rad - dist;","}","struct Cell {","vec2 normal;","vec2 p1;","vec2 p2;","vec2 p3;","vec2 p4;","float samp2;","float samp1;","float samp3;","float samp4;","};","vec4 getSample( vec2 point ) {","vec4 tex = texture2D( tDiffuse, vec2( point.x / width, point.y / height ) );","float base = rand( vec2( floor( point.x ), floor( point.y ) ) ) * PI2;","float step = PI2 / float( samples );","float dist = radius * 0.66;","for ( int i = 0; i < samples; ++i ) {","float r = base + step * float( i );","vec2 coord = point + vec2( cos( r ) * dist, sin( r ) * dist );","tex += texture2D( tDiffuse, vec2( coord.x / width, coord.y / height ) );","}","tex /= float( samples ) + 1.0;","return tex;","}","float getDotColour( Cell c, vec2 p, int channel, float angle, float aa ) {","float dist_c_1, dist_c_2, dist_c_3, dist_c_4, res;","if ( channel == 0 ) {","c.samp1 = getSample( c.p1 ).r;","c.samp2 = getSample( c.p2 ).r;","c.samp3 = getSample( c.p3 ).r;","c.samp4 = getSample( c.p4 ).r;","} else if (channel == 1) {","c.samp1 = getSample( c.p1 ).g;","c.samp2 = getSample( c.p2 ).g;","c.samp3 = getSample( c.p3 ).g;","c.samp4 = getSample( c.p4 ).g;","} else {","c.samp1 = getSample( c.p1 ).b;","c.samp3 = getSample( c.p3 ).b;","c.samp2 = getSample( c.p2 ).b;","c.samp4 = getSample( c.p4 ).b;","}","dist_c_1 = distanceToDotRadius( c.samp1, c.p1, c.normal, p, angle, radius );","dist_c_2 = distanceToDotRadius( c.samp2, c.p2, c.normal, p, angle, radius );","dist_c_3 = distanceToDotRadius( c.samp3, c.p3, c.normal, p, angle, radius );","dist_c_4 = distanceToDotRadius( c.samp4, c.p4, c.normal, p, angle, radius );","res = ( dist_c_1 > 0.0 ) ? clamp( dist_c_1 / aa, 0.0, 1.0 ) : 0.0;","res += ( dist_c_2 > 0.0 ) ? clamp( dist_c_2 / aa, 0.0, 1.0 ) : 0.0;","res += ( dist_c_3 > 0.0 ) ? clamp( dist_c_3 / aa, 0.0, 1.0 ) : 0.0;","res += ( dist_c_4 > 0.0 ) ? clamp( dist_c_4 / aa, 0.0, 1.0 ) : 0.0;","res = clamp( res, 0.0, 1.0 );","return res;","}","Cell getReferenceCell( vec2 p, vec2 origin, float grid_angle, float step ) {","Cell c;","vec2 n = vec2( cos( grid_angle ), sin( grid_angle ) );","float threshold = step * 0.5;","float dot_normal = n.x * ( p.x - origin.x ) + n.y * ( p.y - origin.y );","float dot_line = -n.y * ( p.x - origin.x ) + n.x * ( p.y - origin.y );","vec2 offset = vec2( n.x * dot_normal, n.y * dot_normal );","float offset_normal = mod( hypot( offset.x, offset.y ), step );","float normal_dir = ( dot_normal < 0.0 ) ? 1.0 : -1.0;","float normal_scale = ( ( offset_normal < threshold ) ? -offset_normal : step - offset_normal ) * normal_dir;","float offset_line = mod( hypot( ( p.x - offset.x ) - origin.x, ( p.y - offset.y ) - origin.y ), step );","float line_dir = ( dot_line < 0.0 ) ? 1.0 : -1.0;","float line_scale = ( ( offset_line < threshold ) ? -offset_line : step - offset_line ) * line_dir;","c.normal = n;","c.p1.x = p.x - n.x * normal_scale + n.y * line_scale;","c.p1.y = p.y - n.y * normal_scale - n.x * line_scale;","if ( scatter != 0.0 ) {","float off_mag = scatter * threshold * 0.5;","float off_angle = rand( vec2( floor( c.p1.x ), floor( c.p1.y ) ) ) * PI2;","c.p1.x += cos( off_angle ) * off_mag;","c.p1.y += sin( off_angle ) * off_mag;","}","float normal_step = normal_dir * ( ( offset_normal < threshold ) ? step : -step );","float line_step = line_dir * ( ( offset_line < threshold ) ? step : -step );","c.p2.x = c.p1.x - n.x * normal_step;","c.p2.y = c.p1.y - n.y * normal_step;","c.p3.x = c.p1.x + n.y * line_step;","c.p3.y = c.p1.y - n.x * line_step;","c.p4.x = c.p1.x - n.x * normal_step + n.y * line_step;","c.p4.y = c.p1.y - n.y * normal_step - n.x * line_step;","return c;","}","float blendColour( float a, float b, float t ) {","if ( blendingMode == BLENDING_LINEAR ) {","return blend( a, b, 1.0 - t );","} else if ( blendingMode == BLENDING_ADD ) {","return blend( a, min( 1.0, a + b ), t );","} else if ( blendingMode == BLENDING_MULTIPLY ) {","return blend( a, max( 0.0, a * b ), t );","} else if ( blendingMode == BLENDING_LIGHTER ) {","return blend( a, max( a, b ), t );","} else if ( blendingMode == BLENDING_DARKER ) {","return blend( a, min( a, b ), t );","} else {","return blend( a, b, 1.0 - t );","}","}","void main() {","if ( ! disable ) {","vec2 p = vec2( vUV.x * width, vUV.y * height );","vec2 origin = vec2( 0, 0 );","float aa = ( radius < 2.5 ) ? radius * 0.5 : 1.25;","Cell cell_r = getReferenceCell( p, origin, rotateR, radius );","Cell cell_g = getReferenceCell( p, origin, rotateG, radius );","Cell cell_b = getReferenceCell( p, origin, rotateB, radius );","float r = getDotColour( cell_r, p, 0, rotateR, aa );","float g = getDotColour( cell_g, p, 1, rotateG, aa );","float b = getDotColour( cell_b, p, 2, rotateB, aa );","vec4 colour = texture2D( tDiffuse, vUV );","r = blendColour( r, colour.r, blending );","g = blendColour( g, colour.g, blending );","b = blendColour( b, colour.b, blending );","if ( greyscale ) {","r = g = b = (r + b + g) / 3.0;","}","gl_FragColor = vec4( r, g, b, 1.0 );","} else {","gl_FragColor = texture2D( tDiffuse, vUV );","}","}"].join("\n")},ug=function(e,t,r){var i=this;Tv.call(this),void 0===cg&&console.error("HalftonePass requires HalftoneShader"),this.uniforms=Mu.clone(cg.uniforms),this.material=new pe({uniforms:this.uniforms,fragmentShader:cg.fragmentShader,vertexShader:cg.vertexShader}),this.uniforms.width.value=e,this.uniforms.height.value=t;for(var n in r)r.hasOwnProperty(n)&&i.uniforms.hasOwnProperty(n)&&(i.uniforms[n].value=r[n]);this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};ug.prototype=Object.assign(Object.create(Tv.prototype),{constructor:ug,render:function(e,t,r,i,n){this.material.uniforms.tDiffuse.value=r.texture,this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)},setSize:function(e,t){this.uniforms.width.value=e,this.uniforms.height.value=t}});var hg=function(e,t,i,n){function a(e,t){var r=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,r+"DepthToViewZ")}this.renderScene=t,this.renderCamera=i,this.selectedObjects=void 0!==n?n:[],this.visibleEdgeColor=new u(1,1,1),this.hiddenEdgeColor=new u(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,Tv.call(this),this.resolution=void 0!==e?new f(e.x,e.y):new f(256,256);var o={minFilter:rc,magFilter:rc,format:xc},s=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new F({color:16777215}),this.maskBufferMaterial.side=Ks,this.renderTargetMaskBuffer=new ge(this.resolution.x,this.resolution.y,o),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Se,this.depthMaterial.side=Ks,this.depthMaterial.depthPacking=mu,this.depthMaterial.blending=nl,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=Ks,this.prepareMaskMaterial.fragmentShader=a(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new ge(this.resolution.x,this.resolution.y,o),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new ge(s,l,o),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new ge(s,l,o),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new ge(Math.round(s/2),Math.round(l/2),o),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new ge(s,l,o),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new ge(Math.round(s/2),Math.round(l/2),o),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;var c=4,h=4;this.separableBlurMaterial1=this.getSeperableBlurMaterial(c),this.separableBlurMaterial1.uniforms.texSize.value=new f(s,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(h),this.separableBlurMaterial2.uniforms.texSize.value=new f(Math.round(s/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=h,this.overlayMaterial=this.getOverlayMaterial(),void 0===Gv&&console.error("OutlinePass relies on CopyShader");var d=Gv;this.copyUniforms=Mu.clone(d.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new pe({uniforms:this.copyUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:nl,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new u,this.oldClearAlpha=1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad),this.tempPulseColor1=new u,this.tempPulseColor2=new u,this.textureMatrix=new r};hg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:hg,dispose:function(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()},setSize:function(e,t){this.renderTargetMaskBuffer.setSize(e,t);var r=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(r,i),this.renderTargetBlurBuffer1.setSize(r,i),this.renderTargetEdgeBuffer1.setSize(r,i),this.separableBlurMaterial1.uniforms.texSize.value=new f(r,i),r=Math.round(r/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(r,i),this.renderTargetEdgeBuffer2.setSize(r,i),this.separableBlurMaterial2.uniforms.texSize.value=new f(r,i)},changeVisibilityOfSelectedObjects:function(e){function t(t){t.isMesh&&(e?(t.visible=t.userData.oldVisible,delete t.userData.oldVisible):(t.userData.oldVisible=t.visible,t.visible=e))}for(var r=this,i=0;i0){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,n&&e.context.disable(e.context.STENCIL_TEST),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);var o=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.render(this.renderScene,this.renderCamera,this.renderTargetDepthBuffer,!0),this.changeVisibilityOfSelectedObjects(!0),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value=new f(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.render(this.renderScene,this.renderCamera,this.renderTargetMaskBuffer,!0),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this.renderScene.background=o,this.quad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.render(this.scene,this.camera,this.renderTargetMaskDownSampleBuffer,!0),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){var s=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(s),this.tempPulseColor2.multiplyScalar(s)}this.quad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new f(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.render(this.scene,this.camera,this.renderTargetEdgeBuffer1,!0),this.quad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=hg.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.render(this.scene,this.camera,this.renderTargetBlurBuffer1,!0),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=hg.BlurDirectionY,e.render(this.scene,this.camera,this.renderTargetEdgeBuffer1,!0),this.quad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=hg.BlurDirectionX,e.render(this.scene,this.camera,this.renderTargetBlurBuffer2,!0),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=hg.BlurDirectionY,e.render(this.scene,this.camera,this.renderTargetEdgeBuffer2,!0),this.quad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,n&&e.context.enable(e.context.STENCIL_TEST),e.render(this.scene,this.camera,r,!1),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this.quad.material=this.materialCopy, -this.copyUniforms.tDiffuse.value=r.texture,e.render(this.scene,this.camera))},getPrepareMaskMaterial:function(){return new pe({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new f(.5,.5)},textureMatrix:{value:new r}},vertexShader:["varying vec4 projTexCoord;","varying vec4 vPosition;","uniform mat4 textureMatrix;","void main() {","\tvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tprojTexCoord = textureMatrix * worldPosition;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec4 vPosition;","varying vec4 projTexCoord;","uniform sampler2D depthTexture;","uniform vec2 cameraNearFar;","void main() {","\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));","\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );","\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;","\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);","}"].join("\n")})},getEdgeDetectionMaterial:function(){return new pe({uniforms:{maskTexture:{value:null},texSize:{value:new f(.5,.5)},visibleEdgeColor:{value:new i(1,1,1)},hiddenEdgeColor:{value:new i(1,1,1)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec3 visibleEdgeColor;\t\t\t\tuniform vec3 hiddenEdgeColor;\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\t\t\t\t}"})},getSeperableBlurMaterial:function(e){return new pe({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new f(.5,.5)},direction:{value:new f(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tuniform sampler2D colorTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tuniform float kernelRadius;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\t\t\t\t\tvec2 uvOffset = delta;\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\t\t\t\t\t\tweightSum += (2.0 * w);\t\t\t\t\t\tuvOffset += delta;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\t\t\t\t}"})},getOverlayMaterial:function(){return new pe({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform sampler2D edgeTexture1;\t\t\t\tuniform sampler2D edgeTexture2;\t\t\t\tuniform sampler2D patternTexture;\t\t\t\tuniform float edgeStrength;\t\t\t\tuniform float edgeGlow;\t\t\t\tuniform bool usePatternTexture;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\t\t\t\t\tif(usePatternTexture)\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\t\t\t\t\tgl_FragColor = finalColor;\t\t\t\t}",blending:ol,depthTest:!1,depthWrite:!1,transparent:!0})}}),hg.BlurDirectionX=new f(1,0),hg.BlurDirectionY=new f(0,1);var dg=function(e,t,r,i,n){Tv.call(this),this.scene=e,this.camera=t,this.overrideMaterial=r,this.clearColor=i,this.clearAlpha=void 0!==n?n:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1};dg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:dg,render:function(e,t,r,i,n){var a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial;var o,s;this.clearColor&&(o=e.getClearColor().getHex(),s=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.render(this.scene,this.camera,this.renderToScreen?null:r,this.clear),this.clearColor&&e.setClearColor(o,s),this.scene.overrideMaterial=null,e.autoClear=a}}),In.prototype=Object.create(ve.prototype),In.prototype.constructor=In,In.prototype.isDepthTexture=!0;var pg={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{type:"t",value:null},tDiffuse:{type:"t",value:null},tNormal:{type:"t",value:null},size:{type:"v2",value:new f(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new r},cameraInverseProjectionMatrix:{type:"m4",value:new r},scale:{type:"f",value:1},intensity:{type:"f",value:.1},bias:{type:"f",value:.5},minResolution:{type:"f",value:0},kernelRadius:{type:"f",value:100},randomSeed:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","#if DIFFUSE_TEXTURE == 1","uniform sampler2D tDiffuse;","#endif","uniform sampler2D tDepth;","#if NORMAL_TEXTURE == 1","uniform sampler2D tNormal;","#endif","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float scale;","uniform float intensity;","uniform float bias;","uniform float kernelRadius;","uniform float minResolution;","uniform vec2 size;","uniform float randomSeed;","// RGBA depth","#include ","vec4 getDefaultColor( const in vec2 screenPosition ) {","\t#if DIFFUSE_TEXTURE == 1","\treturn texture2D( tDiffuse, vUv );","\t#else","\treturn vec4( 1.0 );","\t#endif","}","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","\tclipPosition *= clipW; // unprojection.","\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {","\t#if NORMAL_TEXTURE == 1","\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","\t#else","\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );","\t#endif","}","float scaleDividedByCameraFar;","float minResolutionMultipliedByCameraFar;","float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {","\tvec3 viewDelta = sampleViewPosition - centerViewPosition;","\tfloat viewDistance = length( viewDelta );","\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;","\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );","}","// moving costly divides into consts","const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );","const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );","float getAmbientOcclusion( const in vec3 centerViewPosition ) {","\t// precompute some variables require in getOcclusion.","\tscaleDividedByCameraFar = scale / cameraFar;","\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;","\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );","\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/","\tfloat angle = rand( vUv + randomSeed ) * PI2;","\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;","\tvec2 radiusStep = radius;","\tfloat occlusionSum = 0.0;","\tfloat weightSum = 0.0;","\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {","\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;","\t\tradius += radiusStep;","\t\tangle += ANGLE_STEP;","\t\tfloat sampleDepth = getDepth( sampleUv );","\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {","\t\t\tcontinue;","\t\t}","\t\tfloat sampleViewZ = getViewZ( sampleDepth );","\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );","\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );","\t\tweightSum += 1.0;","\t}","\tif( weightSum == 0.0 ) discard;","\treturn occlusionSum * ( intensity / weightSum );","}","void main() {","\tfloat centerDepth = getDepth( vUv );","\tif( centerDepth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = getViewZ( centerDepth );","\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );","\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );","\tgl_FragColor = getDefaultColor( vUv );","\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;","}"].join("\n")},fg={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{type:"t",value:null},size:{type:"v2",value:new f(512,512)},sampleUvOffsets:{type:"v2v",value:[new f(0,0)]},sampleWeights:{type:"1fv",value:[1]},tDepth:{type:"t",value:null},cameraNear:{type:"f",value:10},cameraFar:{type:"f",value:1e3},depthCutoff:{type:"f",value:10}},vertexShader:["#include ","uniform vec2 size;","varying vec2 vUv;","varying vec2 vInvSize;","void main() {","\tvUv = uv;","\tvInvSize = 1.0 / size;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#include ","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","uniform float cameraNear;","uniform float cameraFar;","uniform float depthCutoff;","uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];","uniform float sampleWeights[ KERNEL_RADIUS + 1 ];","varying vec2 vUv;","varying vec2 vInvSize;","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","void main() {","\tfloat depth = getDepth( vUv );","\tif( depth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = -getViewZ( depth );","\tbool rBreak = false, lBreak = false;","\tfloat weightSum = sampleWeights[0];","\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;","\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {","\t\tfloat sampleWeight = sampleWeights[i];","\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;","\t\tvec2 sampleUv = vUv + sampleUvOffset;","\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;","\t\tif( ! rBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t\tsampleUv = vUv - sampleUvOffset;","\t\tviewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;","\t\tif( ! lBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t}","\tgl_FragColor = diffuseSum / weightSum;","}"].join("\n")},mg={createSampleWeights:function(e,t){for(var r=function(e,t){return Math.exp(-(e*e)/(2*(t*t)))/(Math.sqrt(2*Math.PI)*t)},i=[],n=0;n<=e;n++)i.push(r(n,t));return i},createSampleOffsets:function(e,t){for(var r=[],i=0;i<=e;i++)r.push(t.clone().multiplyScalar(i));return r},configure:function(e,t,r,i){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=mg.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=mg.createSampleWeights(t,r),e.needsUpdate=!0}},vg={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","#include ","void main() {","float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );","gl_FragColor = vec4( vec3( depth ), opacity );","}"].join("\n")},gg=function(e,t,r,i,n){if(Tv.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=void 0!==r&&r,this.supportsNormalTexture=void 0!==i&&i,this.oldClearColor=new u,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=void 0!==n?new f(n.x,n.y):new f(256,256),this.saoRenderTarget=new ge(this.resolution.x,this.resolution.y,{minFilter:rc,magFilter:rc,format:xc}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new ge(this.resolution.x,this.resolution.y,{minFilter:$l,magFilter:$l,format:xc}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension){var r=new In;r.type=lc,r.minFilter=$l,r.maxFilter=$l,this.beautyRenderTarget.depthTexture=r,this.beautyRenderTarget.depthBuffer=!0}this.depthMaterial=new Se,this.depthMaterial.depthPacking=mu,this.depthMaterial.blending=nl,this.normalMaterial=new Te,this.normalMaterial.blending=nl,void 0===pg&&console.error("SAOPass relies on SAOShader"),this.saoMaterial=new pe({defines:Object.assign({},pg.defines),fragmentShader:pg.fragmentShader,vertexShader:pg.vertexShader,uniforms:Mu.clone(pg.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=nl,void 0===fg&&console.error("SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new pe({uniforms:Mu.clone(fg.uniforms),defines:Object.assign({},fg.defines),vertexShader:fg.vertexShader,fragmentShader:fg.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=nl,this.hBlurMaterial=new pe({uniforms:Mu.clone(fg.uniforms),defines:Object.assign({},fg.defines),vertexShader:fg.vertexShader,fragmentShader:fg.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=nl,void 0===Gv&&console.error("SAOPass relies on CopyShader"),this.materialCopy=new pe({uniforms:Mu.clone(Gv.uniforms),vertexShader:Gv.vertexShader,fragmentShader:Gv.fragmentShader,blending:nl}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=cl,this.materialCopy.blendSrc=Sl,this.materialCopy.blendDst=ml,this.materialCopy.blendEquation=ul,this.materialCopy.blendSrcAlpha=wl,this.materialCopy.blendDstAlpha=ml,this.materialCopy.blendEquationAlpha=ul,void 0===Gv&&console.error("SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new pe({uniforms:Mu.clone(vg.uniforms),vertexShader:vg.vertexShader,fragmentShader:vg.fragmentShader,blending:nl}),this.quadCamera=new me((-1),1,1,(-1),0,1),this.quadScene=new fe,this.quad=new k(new xe(2,2),null),this.quadScene.add(this.quad)};gg.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4},gg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:gg,render:function(e,t,r,i,n){if(this.renderToScreen&&(this.materialCopy.blending=nl,this.materialCopy.uniforms.tDiffuse.value=r.texture,this.materialCopy.needsUpdate=!0,this.renderPass(e,this.materialCopy,null)),1!==this.params.output){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,e.clearTarget(this.depthRenderTarget),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;var o=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=o,this.hBlurMaterial.uniforms.depthCutoff.value=o,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(mg.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new f(0,1)),mg.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new f(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),e.setClearColor(0),e.render(this.scene,this.camera,this.beautyRenderTarget,!0),this.supportsDepthTextureExtension||this.renderOverride(e,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(e,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(e,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(e,this.hBlurMaterial,this.saoRenderTarget,16777215,1));var s=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,s=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?s.blending=cl:s.blending=nl,this.renderPass(e,s,this.renderToScreen?null:r),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a}},renderPass:function(e,t,r,i,n){var a=e.getClearColor(),o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1;var l=void 0!==i&&null!==i;l&&(e.setClearColor(i),e.setClearAlpha(n||0)),this.quad.material=t,e.render(this.quadScene,this.quadCamera,r,l),e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},renderOverride:function(e,t,r,i,n){var a=e.getClearColor(),o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1,i=t.clearColor||i,n=t.clearAlpha||n;var l=void 0!==i&&null!==i;l&&(e.setClearColor(i),e.setClearAlpha(n||0)),this.scene.overrideMaterial=t,e.render(this.scene,this.camera,r,l),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},setSize:function(e,t){this.beautyRenderTarget.setSize(e,t),this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.depthRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(e,t),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(e,t),this.hBlurMaterial.needsUpdate=!0}});var yg=function(e){Tv.call(this),void 0===Gv&&console.error("SavePass relies on CopyShader");var t=Gv;this.textureID="tDiffuse",this.uniforms=Mu.clone(t.uniforms),this.material=new pe({uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.renderTarget=e,void 0===this.renderTarget&&(this.renderTarget=new ge(Ds.innerWidth,Ds.innerHeight,{minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1}),this.renderTarget.texture.name="SavePass.rt"),this.needsSwap=!1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};yg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:yg,render:function(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.quad.material=this.material,e.render(this.scene,this.camera,this.renderTarget,this.clear)}});var xg=[{defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","void SMAAEdgeDetectionVS( vec2 texcoord ) {","vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );","vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );","vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 );","}","void main() {","vUv = uv;","SMAAEdgeDetectionVS( vUv );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {","vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );","vec4 delta;","vec3 C = texture2D( colorTex, texcoord ).rgb;","vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;","vec3 t = abs( C - Cleft );","delta.x = max( max( t.r, t.g ), t.b );","vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;","t = abs( C - Ctop );","delta.y = max( max( t.r, t.g ), t.b );","vec2 edges = step( threshold, delta.xy );","if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )","discard;","vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;","t = abs( C - Cright );","delta.z = max( max( t.r, t.g ), t.b );","vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;","t = abs( C - Cbottom );","delta.w = max( max( t.r, t.g ), t.b );","float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );","vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;","t = abs( C - Cleftleft );","delta.z = max( max( t.r, t.g ), t.b );","vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;","t = abs( C - Ctoptop );","delta.w = max( max( t.r, t.g ), t.b );","maxDelta = max( max( maxDelta, delta.z ), delta.w );","edges.xy *= step( 0.5 * maxDelta, delta.xy );","return vec4( edges, 0.0, 0.0 );","}","void main() {","gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );","}"].join("\n")},{defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","varying vec2 vPixcoord;","void SMAABlendingWeightCalculationVS( vec2 texcoord ) {","vPixcoord = texcoord / resolution;","vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 );","vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 );","vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );","}","void main() {","vUv = uv;","SMAABlendingWeightCalculationVS( vUv );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )","uniform sampler2D tDiffuse;","uniform sampler2D tArea;","uniform sampler2D tSearch;","uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[3];","varying vec2 vPixcoord;","vec2 round( vec2 x ) {","return sign( x ) * floor( abs( x ) + 0.5 );","}","float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {","e.r = bias + e.r * scale;","return 255.0 * texture2D( searchTex, e, 0.0 ).r;","}","float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 0.0, 1.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord -= vec2( 2.0, 0.0 ) * resolution;","if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;","}","texcoord.x += 0.25 * resolution.x;","texcoord.x += resolution.x;","texcoord.x += 2.0 * resolution.x;","texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);","return texcoord.x;","}","float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 0.0, 1.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord += vec2( 2.0, 0.0 ) * resolution;","if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;","}","texcoord.x -= 0.25 * resolution.x;","texcoord.x -= resolution.x;","texcoord.x -= 2.0 * resolution.x;","texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );","return texcoord.x;","}","float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 1.0, 0.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord += vec2( 0.0, 2.0 ) * resolution;","if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;","}","texcoord.y -= 0.25 * resolution.y;","texcoord.y -= resolution.y;","texcoord.y -= 2.0 * resolution.y;","texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 );","return texcoord.y;","}","float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 1.0, 0.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord -= vec2( 0.0, 2.0 ) * resolution;","if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;","}","texcoord.y += 0.25 * resolution.y;","texcoord.y += resolution.y;","texcoord.y += 2.0 * resolution.y;","texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 );","return texcoord.y;","}","vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {","vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;","texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );","texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;","return texture2D( areaTex, texcoord, 0.0 ).rg;","}","vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {","vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );","vec2 e = texture2D( edgesTex, texcoord ).rg;","if ( e.g > 0.0 ) {","vec2 d;","vec2 coords;","coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );","coords.y = offset[ 1 ].y;","d.x = coords.x;","float e1 = texture2D( edgesTex, coords, 0.0 ).r;","coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );","d.y = coords.x;","d = d / resolution.x - pixcoord.x;","vec2 sqrt_d = sqrt( abs( d ) );","coords.y -= 1.0 * resolution.y;","float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;","weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );","}","if ( e.r > 0.0 ) {","vec2 d;","vec2 coords;","coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );","coords.x = offset[ 0 ].x;","d.x = coords.y;","float e1 = texture2D( edgesTex, coords, 0.0 ).g;","coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );","d.y = coords.y;","d = d / resolution.y - pixcoord.y;","vec2 sqrt_d = sqrt( abs( d ) );","coords.y -= 1.0 * resolution.y;","float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;","weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );","}","return weights;","}","void main() {","gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );","}"].join("\n")},{ +this.copyUniforms.tDiffuse.value=r.texture,e.render(this.scene,this.camera))},getPrepareMaskMaterial:function(){return new pe({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new f(.5,.5)},textureMatrix:{value:new r}},vertexShader:["varying vec4 projTexCoord;","varying vec4 vPosition;","uniform mat4 textureMatrix;","void main() {","\tvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tprojTexCoord = textureMatrix * worldPosition;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec4 vPosition;","varying vec4 projTexCoord;","uniform sampler2D depthTexture;","uniform vec2 cameraNearFar;","void main() {","\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));","\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );","\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;","\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);","}"].join("\n")})},getEdgeDetectionMaterial:function(){return new pe({uniforms:{maskTexture:{value:null},texSize:{value:new f(.5,.5)},visibleEdgeColor:{value:new i(1,1,1)},hiddenEdgeColor:{value:new i(1,1,1)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec3 visibleEdgeColor;\t\t\t\tuniform vec3 hiddenEdgeColor;\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\t\t\t\t}"})},getSeperableBlurMaterial:function(e){return new pe({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new f(.5,.5)},direction:{value:new f(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tuniform sampler2D colorTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tuniform float kernelRadius;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\t\t\t\t\tvec2 uvOffset = delta;\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\t\t\t\t\t\tweightSum += (2.0 * w);\t\t\t\t\t\tuvOffset += delta;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\t\t\t\t}"})},getOverlayMaterial:function(){return new pe({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform sampler2D edgeTexture1;\t\t\t\tuniform sampler2D edgeTexture2;\t\t\t\tuniform sampler2D patternTexture;\t\t\t\tuniform float edgeStrength;\t\t\t\tuniform float edgeGlow;\t\t\t\tuniform bool usePatternTexture;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\t\t\t\t\tif(usePatternTexture)\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\t\t\t\t\tgl_FragColor = finalColor;\t\t\t\t}",blending:ol,depthTest:!1,depthWrite:!1,transparent:!0})}}),hg.BlurDirectionX=new f(1,0),hg.BlurDirectionY=new f(0,1);var dg=function(e,t,r,i,n){Tv.call(this),this.scene=e,this.camera=t,this.overrideMaterial=r,this.clearColor=i,this.clearAlpha=void 0!==n?n:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1};dg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:dg,render:function(e,t,r,i,n){var a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial;var o,s;this.clearColor&&(o=e.getClearColor().getHex(),s=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.render(this.scene,this.camera,this.renderToScreen?null:r,this.clear),this.clearColor&&e.setClearColor(o,s),this.scene.overrideMaterial=null,e.autoClear=a}}),Rn.prototype=Object.create(ve.prototype),Rn.prototype.constructor=Rn,Rn.prototype.isDepthTexture=!0;var pg={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{type:"t",value:null},tDiffuse:{type:"t",value:null},tNormal:{type:"t",value:null},size:{type:"v2",value:new f(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new r},cameraInverseProjectionMatrix:{type:"m4",value:new r},scale:{type:"f",value:1},intensity:{type:"f",value:.1},bias:{type:"f",value:.5},minResolution:{type:"f",value:0},kernelRadius:{type:"f",value:100},randomSeed:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","#if DIFFUSE_TEXTURE == 1","uniform sampler2D tDiffuse;","#endif","uniform sampler2D tDepth;","#if NORMAL_TEXTURE == 1","uniform sampler2D tNormal;","#endif","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float scale;","uniform float intensity;","uniform float bias;","uniform float kernelRadius;","uniform float minResolution;","uniform vec2 size;","uniform float randomSeed;","// RGBA depth","#include ","vec4 getDefaultColor( const in vec2 screenPosition ) {","\t#if DIFFUSE_TEXTURE == 1","\treturn texture2D( tDiffuse, vUv );","\t#else","\treturn vec4( 1.0 );","\t#endif","}","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","\tclipPosition *= clipW; // unprojection.","\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {","\t#if NORMAL_TEXTURE == 1","\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","\t#else","\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );","\t#endif","}","float scaleDividedByCameraFar;","float minResolutionMultipliedByCameraFar;","float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {","\tvec3 viewDelta = sampleViewPosition - centerViewPosition;","\tfloat viewDistance = length( viewDelta );","\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;","\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );","}","// moving costly divides into consts","const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );","const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );","float getAmbientOcclusion( const in vec3 centerViewPosition ) {","\t// precompute some variables require in getOcclusion.","\tscaleDividedByCameraFar = scale / cameraFar;","\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;","\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );","\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/","\tfloat angle = rand( vUv + randomSeed ) * PI2;","\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;","\tvec2 radiusStep = radius;","\tfloat occlusionSum = 0.0;","\tfloat weightSum = 0.0;","\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {","\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;","\t\tradius += radiusStep;","\t\tangle += ANGLE_STEP;","\t\tfloat sampleDepth = getDepth( sampleUv );","\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {","\t\t\tcontinue;","\t\t}","\t\tfloat sampleViewZ = getViewZ( sampleDepth );","\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );","\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );","\t\tweightSum += 1.0;","\t}","\tif( weightSum == 0.0 ) discard;","\treturn occlusionSum * ( intensity / weightSum );","}","void main() {","\tfloat centerDepth = getDepth( vUv );","\tif( centerDepth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = getViewZ( centerDepth );","\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );","\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );","\tgl_FragColor = getDefaultColor( vUv );","\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;","}"].join("\n")},fg={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{type:"t",value:null},size:{type:"v2",value:new f(512,512)},sampleUvOffsets:{type:"v2v",value:[new f(0,0)]},sampleWeights:{type:"1fv",value:[1]},tDepth:{type:"t",value:null},cameraNear:{type:"f",value:10},cameraFar:{type:"f",value:1e3},depthCutoff:{type:"f",value:10}},vertexShader:["#include ","uniform vec2 size;","varying vec2 vUv;","varying vec2 vInvSize;","void main() {","\tvUv = uv;","\tvInvSize = 1.0 / size;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#include ","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","uniform float cameraNear;","uniform float cameraFar;","uniform float depthCutoff;","uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];","uniform float sampleWeights[ KERNEL_RADIUS + 1 ];","varying vec2 vUv;","varying vec2 vInvSize;","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","void main() {","\tfloat depth = getDepth( vUv );","\tif( depth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = -getViewZ( depth );","\tbool rBreak = false, lBreak = false;","\tfloat weightSum = sampleWeights[0];","\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;","\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {","\t\tfloat sampleWeight = sampleWeights[i];","\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;","\t\tvec2 sampleUv = vUv + sampleUvOffset;","\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;","\t\tif( ! rBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t\tsampleUv = vUv - sampleUvOffset;","\t\tviewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;","\t\tif( ! lBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t}","\tgl_FragColor = diffuseSum / weightSum;","}"].join("\n")},mg={createSampleWeights:function(e,t){for(var r=function(e,t){return Math.exp(-(e*e)/(2*(t*t)))/(Math.sqrt(2*Math.PI)*t)},i=[],n=0;n<=e;n++)i.push(r(n,t));return i},createSampleOffsets:function(e,t){for(var r=[],i=0;i<=e;i++)r.push(t.clone().multiplyScalar(i));return r},configure:function(e,t,r,i){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=mg.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=mg.createSampleWeights(t,r),e.needsUpdate=!0}},vg={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","#include ","void main() {","float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );","gl_FragColor = vec4( vec3( depth ), opacity );","}"].join("\n")},gg=function(e,t,r,i,n){if(Tv.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=void 0!==r&&r,this.supportsNormalTexture=void 0!==i&&i,this.oldClearColor=new u,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=void 0!==n?new f(n.x,n.y):new f(256,256),this.saoRenderTarget=new ge(this.resolution.x,this.resolution.y,{minFilter:rc,magFilter:rc,format:xc}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new ge(this.resolution.x,this.resolution.y,{minFilter:$l,magFilter:$l,format:xc}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension){var r=new Rn;r.type=lc,r.minFilter=$l,r.maxFilter=$l,this.beautyRenderTarget.depthTexture=r,this.beautyRenderTarget.depthBuffer=!0}this.depthMaterial=new Se,this.depthMaterial.depthPacking=mu,this.depthMaterial.blending=nl,this.normalMaterial=new Te,this.normalMaterial.blending=nl,void 0===pg&&console.error("SAOPass relies on SAOShader"),this.saoMaterial=new pe({defines:Object.assign({},pg.defines),fragmentShader:pg.fragmentShader,vertexShader:pg.vertexShader,uniforms:Mu.clone(pg.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=nl,void 0===fg&&console.error("SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new pe({uniforms:Mu.clone(fg.uniforms),defines:Object.assign({},fg.defines),vertexShader:fg.vertexShader,fragmentShader:fg.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=nl,this.hBlurMaterial=new pe({uniforms:Mu.clone(fg.uniforms),defines:Object.assign({},fg.defines),vertexShader:fg.vertexShader,fragmentShader:fg.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?r:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=nl,void 0===Gv&&console.error("SAOPass relies on CopyShader"),this.materialCopy=new pe({uniforms:Mu.clone(Gv.uniforms),vertexShader:Gv.vertexShader,fragmentShader:Gv.fragmentShader,blending:nl}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=cl,this.materialCopy.blendSrc=Sl,this.materialCopy.blendDst=ml,this.materialCopy.blendEquation=ul,this.materialCopy.blendSrcAlpha=wl,this.materialCopy.blendDstAlpha=ml,this.materialCopy.blendEquationAlpha=ul,void 0===Gv&&console.error("SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new pe({uniforms:Mu.clone(vg.uniforms),vertexShader:vg.vertexShader,fragmentShader:vg.fragmentShader,blending:nl}),this.quadCamera=new me((-1),1,1,(-1),0,1),this.quadScene=new fe,this.quad=new k(new xe(2,2),null),this.quadScene.add(this.quad)};gg.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4},gg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:gg,render:function(e,t,r,i,n){if(this.renderToScreen&&(this.materialCopy.blending=nl,this.materialCopy.uniforms.tDiffuse.value=r.texture,this.materialCopy.needsUpdate=!0,this.renderPass(e,this.materialCopy,null)),1!==this.params.output){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,e.clearTarget(this.depthRenderTarget),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;var o=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=o,this.hBlurMaterial.uniforms.depthCutoff.value=o,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(mg.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new f(0,1)),mg.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new f(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),e.setClearColor(0),e.render(this.scene,this.camera,this.beautyRenderTarget,!0),this.supportsDepthTextureExtension||this.renderOverride(e,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(e,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(e,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(e,this.hBlurMaterial,this.saoRenderTarget,16777215,1));var s=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,s=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?s.blending=cl:s.blending=nl,this.renderPass(e,s,this.renderToScreen?null:r),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a}},renderPass:function(e,t,r,i,n){var a=e.getClearColor(),o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1;var l=void 0!==i&&null!==i;l&&(e.setClearColor(i),e.setClearAlpha(n||0)),this.quad.material=t,e.render(this.quadScene,this.quadCamera,r,l),e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},renderOverride:function(e,t,r,i,n){var a=e.getClearColor(),o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1,i=t.clearColor||i,n=t.clearAlpha||n;var l=void 0!==i&&null!==i;l&&(e.setClearColor(i),e.setClearAlpha(n||0)),this.scene.overrideMaterial=t,e.render(this.scene,this.camera,r,l),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},setSize:function(e,t){this.beautyRenderTarget.setSize(e,t),this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.depthRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(e,t),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(e,t),this.hBlurMaterial.needsUpdate=!0}});var yg=function(e){Tv.call(this),void 0===Gv&&console.error("SavePass relies on CopyShader");var t=Gv;this.textureID="tDiffuse",this.uniforms=Mu.clone(t.uniforms),this.material=new pe({uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.renderTarget=e,void 0===this.renderTarget&&(this.renderTarget=new ge(Ds.innerWidth,Ds.innerHeight,{minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1}),this.renderTarget.texture.name="SavePass.rt"),this.needsSwap=!1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};yg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:yg,render:function(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.quad.material=this.material,e.render(this.scene,this.camera,this.renderTarget,this.clear)}});var xg=[{defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","void SMAAEdgeDetectionVS( vec2 texcoord ) {","vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );","vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );","vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 );","}","void main() {","vUv = uv;","SMAAEdgeDetectionVS( vUv );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {","vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );","vec4 delta;","vec3 C = texture2D( colorTex, texcoord ).rgb;","vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;","vec3 t = abs( C - Cleft );","delta.x = max( max( t.r, t.g ), t.b );","vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;","t = abs( C - Ctop );","delta.y = max( max( t.r, t.g ), t.b );","vec2 edges = step( threshold, delta.xy );","if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )","discard;","vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;","t = abs( C - Cright );","delta.z = max( max( t.r, t.g ), t.b );","vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;","t = abs( C - Cbottom );","delta.w = max( max( t.r, t.g ), t.b );","float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );","vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;","t = abs( C - Cleftleft );","delta.z = max( max( t.r, t.g ), t.b );","vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;","t = abs( C - Ctoptop );","delta.w = max( max( t.r, t.g ), t.b );","maxDelta = max( max( maxDelta, delta.z ), delta.w );","edges.xy *= step( 0.5 * maxDelta, delta.xy );","return vec4( edges, 0.0, 0.0 );","}","void main() {","gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );","}"].join("\n")},{defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","varying vec2 vPixcoord;","void SMAABlendingWeightCalculationVS( vec2 texcoord ) {","vPixcoord = texcoord / resolution;","vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 );","vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 );","vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );","}","void main() {","vUv = uv;","SMAABlendingWeightCalculationVS( vUv );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )","uniform sampler2D tDiffuse;","uniform sampler2D tArea;","uniform sampler2D tSearch;","uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[3];","varying vec2 vPixcoord;","vec2 round( vec2 x ) {","return sign( x ) * floor( abs( x ) + 0.5 );","}","float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {","e.r = bias + e.r * scale;","return 255.0 * texture2D( searchTex, e, 0.0 ).r;","}","float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 0.0, 1.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord -= vec2( 2.0, 0.0 ) * resolution;","if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;","}","texcoord.x += 0.25 * resolution.x;","texcoord.x += resolution.x;","texcoord.x += 2.0 * resolution.x;","texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);","return texcoord.x;","}","float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 0.0, 1.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord += vec2( 2.0, 0.0 ) * resolution;","if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;","}","texcoord.x -= 0.25 * resolution.x;","texcoord.x -= resolution.x;","texcoord.x -= 2.0 * resolution.x;","texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );","return texcoord.x;","}","float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 1.0, 0.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord += vec2( 0.0, 2.0 ) * resolution;","if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;","}","texcoord.y -= 0.25 * resolution.y;","texcoord.y -= resolution.y;","texcoord.y -= 2.0 * resolution.y;","texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 );","return texcoord.y;","}","float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","vec2 e = vec2( 1.0, 0.0 );","for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","e = texture2D( edgesTex, texcoord, 0.0 ).rg;","texcoord -= vec2( 0.0, 2.0 ) * resolution;","if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;","}","texcoord.y += 0.25 * resolution.y;","texcoord.y += resolution.y;","texcoord.y += 2.0 * resolution.y;","texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 );","return texcoord.y;","}","vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {","vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;","texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );","texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;","return texture2D( areaTex, texcoord, 0.0 ).rg;","}","vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {","vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );","vec2 e = texture2D( edgesTex, texcoord ).rg;","if ( e.g > 0.0 ) {","vec2 d;","vec2 coords;","coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );","coords.y = offset[ 1 ].y;","d.x = coords.x;","float e1 = texture2D( edgesTex, coords, 0.0 ).r;","coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );","d.y = coords.x;","d = d / resolution.x - pixcoord.x;","vec2 sqrt_d = sqrt( abs( d ) );","coords.y -= 1.0 * resolution.y;","float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;","weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );","}","if ( e.r > 0.0 ) {","vec2 d;","vec2 coords;","coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );","coords.x = offset[ 0 ].x;","d.x = coords.y;","float e1 = texture2D( edgesTex, coords, 0.0 ).g;","coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );","d.y = coords.y;","d = d / resolution.y - pixcoord.y;","vec2 sqrt_d = sqrt( abs( d ) );","coords.y -= 1.0 * resolution.y;","float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;","weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );","}","return weights;","}","void main() {","gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );","}"].join("\n")},{ uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 2 ];","void SMAANeighborhoodBlendingVS( vec2 texcoord ) {","vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );","vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );","}","void main() {","vUv = uv;","SMAANeighborhoodBlendingVS( vUv );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform sampler2D tColor;","uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 2 ];","vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {","vec4 a;","a.xz = texture2D( blendTex, texcoord ).xz;","a.y = texture2D( blendTex, offset[ 1 ].zw ).g;","a.w = texture2D( blendTex, offset[ 1 ].xy ).a;","if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {","return texture2D( colorTex, texcoord, 0.0 );","} else {","vec2 offset;","offset.x = a.a > a.b ? a.a : -a.b;","offset.y = a.g > a.r ? -a.g : a.r;","if ( abs( offset.x ) > abs( offset.y )) {","offset.y = 0.0;","} else {","offset.x = 0.0;","}","vec4 C = texture2D( colorTex, texcoord, 0.0 );","texcoord += sign( offset ) * resolution;","vec4 Cop = texture2D( colorTex, texcoord, 0.0 );","float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );","C.xyz = pow(C.xyz, vec3(2.2));","Cop.xyz = pow(Cop.xyz, vec3(2.2));","vec4 mixed = mix(C, Cop, s);","mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));","return mixed;","}","}","void main() {","gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );","}"].join("\n")}],bg=function(e,t){Tv.call(this),this.edgesRT=new ge(e,t,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:rc,format:yc}),this.edgesRT.texture.name="SMAAPass.edges",this.weightsRT=new ge(e,t,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:rc,format:xc}),this.weightsRT.texture.name="SMAAPass.weights";var r=new Image;r.src=this.getAreaTexture(),this.areaTexture=new ve,this.areaTexture.name="SMAAPass.area",this.areaTexture.image=r,this.areaTexture.format=yc,this.areaTexture.minFilter=rc,this.areaTexture.generateMipmaps=!1,this.areaTexture.needsUpdate=!0,this.areaTexture.flipY=!1;var i=new Image;i.src=this.getSearchTexture(),this.searchTexture=new ve,this.searchTexture.name="SMAAPass.search",this.searchTexture.image=i,this.searchTexture.magFilter=$l,this.searchTexture.minFilter=$l,this.searchTexture.generateMipmaps=!1,this.searchTexture.needsUpdate=!0,this.searchTexture.flipY=!1,void 0===xg&&console.error("SMAAPass relies on SMAAShader"),this.uniformsEdges=Mu.clone(xg[0].uniforms),this.uniformsEdges.resolution.value.set(1/e,1/t),this.materialEdges=new pe({defines:Object.assign({},xg[0].defines),uniforms:this.uniformsEdges,vertexShader:xg[0].vertexShader,fragmentShader:xg[0].fragmentShader}),this.uniformsWeights=Mu.clone(xg[1].uniforms),this.uniformsWeights.resolution.value.set(1/e,1/t),this.uniformsWeights.tDiffuse.value=this.edgesRT.texture,this.uniformsWeights.tArea.value=this.areaTexture,this.uniformsWeights.tSearch.value=this.searchTexture,this.materialWeights=new pe({defines:Object.assign({},xg[1].defines),uniforms:this.uniformsWeights,vertexShader:xg[1].vertexShader,fragmentShader:xg[1].fragmentShader}),this.uniformsBlend=Mu.clone(xg[2].uniforms),this.uniformsBlend.resolution.value.set(1/e,1/t),this.uniformsBlend.tDiffuse.value=this.weightsRT.texture,this.materialBlend=new pe({uniforms:this.uniformsBlend,vertexShader:xg[2].vertexShader,fragmentShader:xg[2].fragmentShader}),this.needsSwap=!1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};bg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:bg,render:function(e,t,r,i,n){this.uniformsEdges.tDiffuse.value=r.texture,this.quad.material=this.materialEdges,e.render(this.scene,this.camera,this.edgesRT,this.clear),this.quad.material=this.materialWeights,e.render(this.scene,this.camera,this.weightsRT,this.clear),this.uniformsBlend.tColor.value=r.texture,this.quad.material=this.materialBlend,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)},setSize:function(e,t){this.edgesRT.setSize(e,t),this.weightsRT.setSize(e,t),this.materialEdges.uniforms.resolution.value.set(1/e,1/t),this.materialWeights.uniforms.resolution.value.set(1/e,1/t),this.materialBlend.uniforms.resolution.value.set(1/e,1/t)},getAreaTexture:function(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="; -},getSearchTexture:function(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}});var wg=function(e,t,r,i){Tv.call(this),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==r?r:0,this.clearAlpha=void 0!==i?i:0,void 0===Gv&&console.error("SSAARenderPass relies on CopyShader");var n=Gv;this.copyUniforms=Mu.clone(n.uniforms),this.copyMaterial=new pe({uniforms:this.copyUniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:ol,depthTest:!1,depthWrite:!1}),this.camera2=new me((-1),1,1,(-1),0,1),this.scene2=new fe,this.quad2=new k(new xe(2,2),this.copyMaterial),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2)};wg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:wg,dispose:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)},setSize:function(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)},render:function(e,t,r){var i=this;this.sampleRenderTarget||(this.sampleRenderTarget=new ge(r.width,r.height,{minFilter:rc,magFilter:rc,format:xc}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var n=wg.JitterVectors[Math.max(0,Math.min(this.sampleLevel,5))],a=e.autoClear;e.autoClear=!1;var o=e.getClearColor().getHex(),s=e.getClearAlpha(),l=1/n.length,c=1/32;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;for(var u=r.width,h=r.height,d=0;d","vec2 rand( const vec2 coord ) {","vec2 noise;","if ( useNoise ) {","float nx = dot ( coord, vec2( 12.9898, 78.233 ) );","float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );","noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );","} else {","float ff = fract( 1.0 - coord.s * ( size.x / 2.0 ) );","float gg = fract( coord.t * ( size.y / 2.0 ) );","noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;","}","return ( noise * 2.0 - 1.0 ) * noiseAmount;","}","float readDepth( const in vec2 coord ) {","float cameraFarPlusNear = cameraFar + cameraNear;","float cameraFarMinusNear = cameraFar - cameraNear;","float cameraCoef = 2.0 * cameraNear;","#ifdef USE_LOGDEPTHBUF","float logz = unpackRGBAToDepth( texture2D( tDepth, coord ) );","float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;","float z = (logz / w) + 1.0;","#else","float z = unpackRGBAToDepth( texture2D( tDepth, coord ) );","#endif","return cameraCoef / ( cameraFarPlusNear - z * cameraFarMinusNear );","}","float compareDepths( const in float depth1, const in float depth2, inout int far ) {","float garea = 8.0;","float diff = ( depth1 - depth2 ) * 100.0;","if ( diff < gDisplace ) {","garea = diffArea;","} else {","far = 1;","}","float dd = diff - gDisplace;","float gauss = pow( EULER, -2.0 * ( dd * dd ) / ( garea * garea ) );","return gauss;","}","float calcAO( float depth, float dw, float dh ) {","vec2 vv = vec2( dw, dh );","vec2 coord1 = vUv + radius * vv;","vec2 coord2 = vUv - radius * vv;","float temp1 = 0.0;","float temp2 = 0.0;","int far = 0;","temp1 = compareDepths( depth, readDepth( coord1 ), far );","if ( far > 0 ) {","temp2 = compareDepths( readDepth( coord2 ), depth, far );","temp1 += ( 1.0 - temp1 ) * temp2;","}","return temp1;","}","void main() {","vec2 noise = rand( vUv );","float depth = readDepth( vUv );","float tt = clamp( depth, aoClamp, 1.0 );","float w = ( 1.0 / size.x ) / tt + ( noise.x * ( 1.0 - noise.x ) );","float h = ( 1.0 / size.y ) / tt + ( noise.y * ( 1.0 - noise.y ) );","float ao = 0.0;","float dz = 1.0 / float( samples );","float l = 0.0;","float z = 1.0 - dz / 2.0;","for ( int i = 0; i <= samples; i ++ ) {","float r = sqrt( 1.0 - z );","float pw = cos( l ) * r;","float ph = sin( l ) * r;","ao += calcAO( depth, pw * w, ph * h );","z = z - dz;","l = l + DL;","}","ao /= float( samples );","ao = 1.0 - ao;","vec3 color = texture2D( tDiffuse, vUv ).rgb;","vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );","float lum = dot( color.rgb, lumcoeff );","vec3 luminance = vec3( lum );","vec3 final = vec3( color * mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","if ( onlyAO ) {","final = vec3( mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","}","gl_FragColor = vec4( final, 1.0 );","}"].join("\n")},Sg=function(e,t,r,i){return void 0===_g?(console.warn("SSAOPass depends on SSAOShader"),new Ev):(Ev.call(this,_g),this.width=void 0!==r?r:512,this.height=void 0!==i?i:256,this.renderToScreen=!1,this.camera2=t,this.scene2=e,this.depthMaterial=new Se,this.depthMaterial.depthPacking=mu,this.depthMaterial.blending=nl,this.depthRenderTarget=new ge(this.width,this.height,{minFilter:rc,magFilter:rc}),this.uniforms.tDepth.value=this.depthRenderTarget.texture,this.uniforms.size.value.set(this.width,this.height),this.uniforms.cameraNear.value=this.camera2.near,this.uniforms.cameraFar.value=this.camera2.far,this.uniforms.radius.value=4,this.uniforms.onlyAO.value=!1,this.uniforms.aoClamp.value=.25,this.uniforms.lumInfluence.value=.7,void Object.defineProperties(this,{radius:{get:function(){return this.uniforms.radius.value},set:function(e){this.uniforms.radius.value=e}},onlyAO:{get:function(){return this.uniforms.onlyAO.value},set:function(e){this.uniforms.onlyAO.value=e}},aoClamp:{get:function(){return this.uniforms.aoClamp.value},set:function(e){this.uniforms.aoClamp.value=e}},lumInfluence:{get:function(){return this.uniforms.lumInfluence.value},set:function(e){this.uniforms.lumInfluence.value=e}}}))};Sg.prototype=Object.create(Ev.prototype),Sg.prototype.render=function(e,t,r,i,n){this.scene2.overrideMaterial=this.depthMaterial,e.render(this.scene2,this.camera2,this.depthRenderTarget,!0),this.scene2.overrideMaterial=null,Ev.prototype.render.call(this,e,t,r,i,n)},Sg.prototype.setScene=function(e){this.scene2=e},Sg.prototype.setCamera=function(e){this.camera2=e,this.uniforms.cameraNear.value=this.camera2.near,this.uniforms.cameraFar.value=this.camera2.far},Sg.prototype.setSize=function(e,t){this.width=e,this.height=t,this.uniforms.size.value.set(this.width,this.height),this.depthRenderTarget.setSize(this.width,this.height)};var Ag=function(e,t,r){void 0===wg&&console.error("TAARenderPass relies on SSAARenderPass"),wg.call(this,e,t,r),this.sampleLevel=0,this.accumulate=!1};Ag.JitterVectors=wg.JitterVectors,Ag.prototype=Object.assign(Object.create(wg.prototype),{constructor:Ag,render:function(e,t,r,i){var n=this;if(!this.accumulate)return wg.prototype.render.call(this,e,t,r,i),void(this.accumulateIndex=-1);var a=Ag.JitterVectors[5];this.sampleRenderTarget||(this.sampleRenderTarget=new ge(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),this.holdRenderTarget||(this.holdRenderTarget=new ge(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),this.accumulate&&this.accumulateIndex===-1&&(wg.prototype.render.call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0);var o=e.autoClear;e.autoClear=!1;var s=1/a.length;if(this.accumulateIndex>=0&&this.accumulateIndex=a.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}var d=this.accumulateIndex*s;d>0&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.render(this.scene2,this.camera2,t,!0)),d<1&&(this.copyUniforms.opacity.value=1-d,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.render(this.scene2,this.camera2,t,0===d)),e.autoClear=o}});var Mg=function(e,t){Tv.call(this),void 0===Gv&&console.error("TexturePass relies on CopyShader");var r=Gv;this.map=e,this.opacity=void 0!==t?t:1,this.uniforms=Mu.clone(r.uniforms),this.material=new pe({uniforms:this.uniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,depthTest:!1,depthWrite:!1}),this.needsSwap=!1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};Mg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Mg,render:function(e,t,r,i,n){var a=e.autoClear;e.autoClear=!1,this.quad.material=this.material,this.uniforms.opacity.value=this.opacity,this.uniforms.tDiffuse.value=this.map,this.material.transparent=this.opacity<1,e.render(this.scene,this.camera,this.renderToScreen?null:r,this.clear),e.autoClear=a}});var Tg={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new u(0)},defaultOpacity:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 defaultColor;","uniform float defaultOpacity;","uniform float luminosityThreshold;","uniform float smoothWidth;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );","float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );","gl_FragColor = mix( outputColor, texel, alpha );","}"].join("\n")},Eg=function(e,t,r,n){var a=this;Tv.call(this),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=n,this.resolution=void 0!==e?new f(e.x,e.y):new f(256,256),this.clearColor=new u(0,0,0);var o={minFilter:rc,magFilter:rc,format:xc};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var s=Math.round(this.resolution.x/2),l=Math.round(this.resolution.y/2);this.renderTargetBright=new ge(s,l,o),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var c=0;c\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat fSigma = float(SIGMA);\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\t\t\t\t\t\tfloat x = float(i);\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\t\t\t\t\t\tweightSum += 2.0 * w;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})},getCompositeMaterial:function(e){return new pe({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D blurTexture1;\t\t\t\tuniform sampler2D blurTexture2;\t\t\t\tuniform sampler2D blurTexture3;\t\t\t\tuniform sampler2D blurTexture4;\t\t\t\tuniform sampler2D blurTexture5;\t\t\t\tuniform sampler2D dirtTexture;\t\t\t\tuniform float bloomStrength;\t\t\t\tuniform float bloomRadius;\t\t\t\tuniform float bloomFactors[NUM_MIPS];\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\t\t\t\t\t\t\t\tfloat lerpBloomFactor(const in float factor) { \t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\t\t\t\t}"})}}),Eg.BlurDirectionX=new f(1,0),Eg.BlurDirectionY=new f(0,1);var Cg=function(){this.seed=1,this.next=function(){return this.gen()/2147483647},this.nextRange=function(e,t){return e+(t-e)*this.next()},this.gen=function(){return this.seed=16807*this.seed%2147483647}};Object.assign(Rn.prototype,{set:function(e,t,r,i,n,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(n),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],l=r[5],c=r[6],u=r[7],h=r[8],d=r[9],p=r[10],f=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return t[0].setComponents(o-i,u-s,f-h,y-m).normalize(),t[1].setComponents(o+i,u+s,f+h,y+m).normalize(),t[2].setComponents(o+n,u+l,f+d,y+v).normalize(),t[3].setComponents(o-n,u-l,f-d,y-v).normalize(),t[4].setComponents(o-a,u-c,f-p,y-g).normalize(),t[5].setComponents(o+a,u+c,f+p,y+g).normalize(),this},intersectsObject:function(){var e=new p;return function(t){var r=t.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),e.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new p;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,r=e.center,i=-e.radius,n=0;n<6;n++){var a=t[n].distanceToPoint(r);if(a0?t.max.x:t.min.x,e.y=n.normal.y>0?t.max.y:t.min.y,e.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(e)<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}});var Lg=function(){this.id=0,this.object=null,this.z=0,this.renderOrder=0},Pg=function(){this.id=0,this.v1=new Ng,this.v2=new Ng,this.v3=new Ng,this.normalModel=new i,this.vertexNormalsModel=[new i,new i,new i],this.vertexNormalsLength=0,this.color=new u,this.material=null,this.uvs=[new f,new f,new f],this.z=0,this.renderOrder=0},Ng=function(){this.position=new i,this.positionWorld=new i,this.positionScreen=new v,this.visible=!0};Ng.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)};var Og=function(){this.id=0,this.v1=new Ng,this.v2=new Ng,this.vertexColors=[new u,new u],this.material=null,this.z=0,this.renderOrder=0},Dg=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new f,this.material=null,this.renderOrder=0},Fg=function(){function e(r){if(r.visible!==!1){if(r instanceof kt)z.lights.push(r);else if(r instanceof k||r instanceof B||r instanceof Et){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&J.intersectsObject(r)===!1)return;t(r)}else if(r instanceof vi){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&J.intersectsSprite(r)===!1)return;t(r)}for(var i=r.children,n=0,a=i.length;n=-1&&e.z<=1&&(A=u(),A.id=t.id,A.x=e.x*i,A.y=e.y*i,A.z=e.z,A.renderOrder=t.renderOrder,A.object=t,A.rotation=t.rotation,A.scale.x=t.scale.x*Math.abs(A.x-(e.x+r.projectionMatrix.elements[0])/(e.w+r.projectionMatrix.elements[12])),A.scale.y=t.scale.y*Math.abs(A.y-(e.y+r.projectionMatrix.elements[5])/(e.w+r.projectionMatrix.elements[13])),A.material=t.material,z.elements.push(A))}function a(){if(g===C){var e=new Lg;return E.push(e),C++,g++,e}return E[g++]}function o(){if(x===N){var e=new Ng;return L.push(e),N++,x++,e}return L[x++]}function s(){if(w===D){var e=new Pg;return O.push(e),D++,w++,e}return O[w++]}function c(){if(S===I){var e=new Og;return F.push(e),I++,S++,e}return F[S++]}function u(){if(M===U){var e=new Dg;return R.push(e),U++,M++,e}return R[M++]}function h(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function p(e,t){var r=0,i=1,n=e.z+e.w,a=t.z+t.w,o=-e.z+e.w,s=-t.z+t.w;return n>=0&&a>=0&&o>=0&&s>=0||!(n<0&&a<0||o<0&&s<0)&&(n<0?r=Math.max(r,n/(n-a)):a<0&&(i=Math.min(i,n/(n-a))),o<0?r=Math.max(r,o/(o-s)):s<0&&(i=Math.min(i,o/(o-s))),!(i=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function r(e,r,i){y=o(),y.position.set(e,r,i),t(y)}function i(e,t,r){m.push(e,t,r)}function n(e,t,r){v.push(e,t,r)}function a(e,t){g.push(e,t)}function u(e,t,r){return e.visible===!0||t.visible===!0||r.visible===!0||(X[0]=e.positionScreen,X[1]=t.positionScreen,X[2]=r.positionScreen,G.intersectsBox(W.setFromPoints(X)))}function h(e,t,r){return(r.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(r.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}function d(e,t){var r=L[e],i=L[t];r.positionScreen.copy(r.position).applyMatrix4(q),i.positionScreen.copy(i.position).applyMatrix4(q),p(r.positionScreen,i.positionScreen)===!0&&(r.positionScreen.multiplyScalar(1/r.positionScreen.w),i.positionScreen.multiplyScalar(1/i.positionScreen.w),_=c(),_.id=x.id,_.v1.copy(r),_.v2.copy(i),_.z=Math.max(r.positionScreen.z,i.positionScreen.z),_.renderOrder=x.renderOrder,_.material=x.material,x.material.vertexColors===il&&(_.vertexColors[0].fromArray(v,3*e),_.vertexColors[1].fromArray(v,3*t)),z.elements.push(_))}function f(e,t,r,i){var n=arguments,a=L[e],o=L[t],l=L[r];if(u(a,o,l)!==!1&&(i.side===Ks||h(a,o,l)===!0)){b=s(),b.id=x.id,b.v1.copy(a),b.v2.copy(o),b.v3.copy(l),b.z=(a.positionScreen.z+o.positionScreen.z+l.positionScreen.z)/3,b.renderOrder=x.renderOrder,j.subVectors(l.position,o.position),V.subVectors(a.position,o.position),j.cross(V),b.normalModel.copy(j),b.normalModel.applyMatrix3(S).normalize();for(var c=0;c<3;c++){var d=b.vertexNormalsModel[c];d.fromArray(m,3*n[c]),d.applyMatrix3(S).normalize();var p=b.uvs[c];p.fromArray(g,2*n[c])}b.vertexNormalsLength=3,b.material=i,i.vertexColors===rl&&b.color.fromArray(v,3*e),z.elements.push(b)}}var m=[],v=[],g=[],x=null,w=null,S=new l;return{setObject:e,projectVertex:t,checkTriangleVisibility:u,checkBackfaceCulling:h,pushVertex:r,pushNormal:i,pushColor:n,pushUv:a,pushLine:d,pushTriangle:f}},ee=new $;this.projectScene=function(t,r,i,a){w=0,S=0,M=0,z.elements.length=0,t.autoUpdate===!0&&t.updateMatrixWorld(),null===r.parent&&r.updateMatrixWorld(),H.copy(r.matrixWorldInverse),Y.multiplyMatrices(r.projectionMatrix,H),J.setFromMatrix(Y),g=0,z.objects.length=0,z.lights.length=0,e(t),i===!0&&z.objects.sort(h);for(var l=z.objects,u=0,d=l.length;u0)for(var oe=0;oe0)for(var oe=0;oe0||(be=L[x-2],Z.copy(xe.positionScreen),K.copy(be.positionScreen),p(Z,K)===!0&&(Z.multiplyScalar(1/Z.w),K.multiplyScalar(1/K.w),_=c(),_.id=f.id,_.v1.positionScreen.copy(Z),_.v2.positionScreen.copy(K),_.z=Math.max(Z.z,K.z),_.renderOrder=f.renderOrder,_.material=f.material,f.material.vertexColors===il&&(_.vertexColors[0].copy(f.geometry.colors[he]),_.vertexColors[1].copy(f.geometry.colors[he-1])),z.elements.push(_)))}}else if(f instanceof Et){if(q.multiplyMatrices(Y,T),v instanceof m)for(var le=f.geometry.vertices,he=0,de=le.length;he0&&(m(1),v(al),w("rgba("+Math.floor(255*te.r)+","+Math.floor(255*te.g)+","+Math.floor(255*te.b)+","+re+")"),ee.fillRect(0|ge.min.x,0|ge.max.y,ge.max.x-ge.min.x|0,ge.min.y-ge.max.y|0)),ge.makeEmpty())},this.clearColor=function(){},this.clearDepth=function(){},this.clearStencil=function(){},this.render=function(e,r){if(void 0===r.isCamera)return void console.error("CanvasRenderer.render: camera is not an instance of Camera.");var i=e.background;i&&i.isColor?(m(1),v(al),w(i.getStyle()),ee.fillRect(0,0,X,H)):this.autoClear===!0&&this.clear(),V.info.render.vertices=0,V.info.render.faces=0,ee.setTransform(Z/X,0,0,-K/H,Q,H-J),ee.translate(Y,q),S=G.projectScene(e,r,this.sortObjects,this.sortElements),A=S.elements,M=S.lights,Me.getNormalMatrix(r.matrixWorldInverse),t();for(var s=0,l=A.length;s1)continue;if(E.positionScreen.z<-1||E.positionScreen.z>1)continue;if(C.positionScreen.z<-1||C.positionScreen.z>1)continue;T.positionScreen.x*=Y,T.positionScreen.y*=q,E.positionScreen.x*=Y,E.positionScreen.y*=q,C.positionScreen.x*=Y,C.positionScreen.y*=q,u.overdraw>0&&(f(T.positionScreen,E.positionScreen,u.overdraw),f(E.positionScreen,C.positionScreen,u.overdraw),f(C.positionScreen,T.positionScreen,u.overdraw)),ye.setFromPoints([T.positionScreen,E.positionScreen,C.positionScreen]),ve.intersectsBox(ye)===!0&&o(T,E,C,0,1,2,c,u)}ge.union(ye)}}ee.setTransform(1,0,0,1,0,0)}},Ug=function(e){c.call(this),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",function(e){null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)})};Ug.prototype=Object.create(c.prototype),Ug.prototype.constructor=Ug;var kg=function(){console.log("CSS2DRenderer",Bs);var e,t,n,a,o=new i,s=new r,l=new r,c={objects:new WeakMap},u=document.createElement("div");u.style.overflow="hidden",this.domElement=u,this.getSize=function(){return{width:e,height:t}},this.setSize=function(r,i){e=r,t=i,n=e/2,a=t/2,u.style.width=r+"px",u.style.height=i+"px"};var h=function(e,t){if(e instanceof Ug){o.setFromMatrixPosition(e.matrixWorld),o.applyMatrix4(l);var r=e.element,i="translate(-50%,-50%) translate("+(o.x*n+n)+"px,"+(-o.y*a+a)+"px)";r.style.WebkitTransform=i,r.style.MozTransform=i,r.style.oTransform=i,r.style.transform=i;var s={distanceToCameraSquared:d(t,e)};c.objects.set(e,s),r.parentNode!==u&&u.appendChild(r)}for(var p=0,f=e.children.length;pp)return s.splice(s.indexOf(this),1),this.terminate();r(this)}},n.color=(new u).setHSL(Math.random(),.8,.8).getHexString(),s.push(n),t(n),l&&(n.postMessage({scene:w,camera:_,annex:A,sceneId:g}),r(n))}if(!l)for(;s.length>p;)s.pop().terminate()},this.setWorkers(p),this.setClearColor=function(e){d.set(e)},this.setPixelRatio=function(){},this.setSize=function(e,r){c.width=e,c.height=r,n=c.width,a=c.height,h.fillStyle="white",s.forEach(t)},this.setSize(c.width,c.height),this.clear=function(){};var y,x,b,w,_,S,A={},M={mirror:1,reflectivity:1,refractionRatio:1,glass:1};this.render=function(e,t){l=!0,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),w=e.toJSON(),_=t.toJSON(),++g,e.traverse(i),s.forEach(function(e){e.postMessage({scene:w,camera:_,annex:A,sceneId:g})}),h.clearRect(0,0,n,a),S=Date.now(),x=Math.ceil(n/f),b=Math.ceil(a/f),y=x*b,m=[];for(var c=0;c0?~~o:0),f=h-1,m=u.data,v=4*((a*h&f)*h+(n*h&f));if(d){var g=l.palette[p]*m[v],y=l.palette[p+1]*m[v+1],x=l.palette[p+2]*m[v+2],b=m[v+3]*l.opacity/256,w=e[c],_=e[c+1],S=e[c+2];e[c]=g*b+w*(1-b),e[c+1]=y*b+_*(1-b),e[c+2]=x*b+S*(1-b),e[c+3]=(l.opacity<<8)-1,255==e[c+3]&&(t[r]=i)}else e[c]=l.palette[p]*m[v]>>8,e[c+1]=l.palette[p+1]*m[v+1]>>8,e[c+2]=l.palette[p+2]*m[v+2]>>8,e[c+3]=(l.opacity<<8)-1,t[r]=i}}function s(e){var t=e.id,r=D[t];if(r&&e.map&&!R[e.map.id]&&delete D[t],void 0===D[t]||e.needsUpdate===!0){if(e instanceof F||e instanceof Me||e instanceof Ee||e instanceof Fe){e instanceof Me?e.palette||(e.palette=n(e,!1)):e instanceof Ee&&(e.palette||(e.palette=n(e,!0)));var i;if(e.map){var s=new Gg.Texture;if(s.fromImage(e.map.image),!s.data)return;R[e.map.id]=s,r=e instanceof F||e instanceof Fe?a:o}else i=e.vertexColors===rl?["var colorOffset = offset * 4;","buffer[ colorOffset ] = face.color.r * 255;","buffer[ colorOffset + 1 ] = face.color.g * 255;","buffer[ colorOffset + 2 ] = face.color.b * 255;","buffer[ colorOffset + 3 ] = material.opacity * 255;","depthBuf[ offset ] = depth;"].join("\n"):["var colorOffset = offset * 4;","buffer[ colorOffset ] = material.color.r * 255;","buffer[ colorOffset + 1 ] = material.color.g * 255;","buffer[ colorOffset + 2 ] = material.color.b * 255;","buffer[ colorOffset + 3 ] = material.opacity * 255;","depthBuf[ offset ] = depth;"].join("\n"),r=new Function("buffer, depthBuf, offset, depth, u, v, n, face, material",i)}else if(e instanceof I){var i=["var colorOffset = offset * 4;","buffer[ colorOffset ] = material.color.r * (color1.r+color2.r) * 0.5 * 255;","buffer[ colorOffset + 1 ] = material.color.g * (color1.g+color2.g) * 0.5 * 255;","buffer[ colorOffset + 2 ] = material.color.b * (color1.b+color2.b) * 0.5 * 255;","buffer[ colorOffset + 3 ] = 255;","depthBuf[ offset ] = depth;"].join("\n");r=new Function("buffer, depthBuf, offset, depth, color1, color2, material",i)}else{var i=["var colorOffset = offset * 4;","buffer[ colorOffset ] = u * 255;","buffer[ colorOffset + 1 ] = v * 255;","buffer[ colorOffset + 2 ] = 0;","buffer[ colorOffset + 3 ] = 255;","depthBuf[ offset ] = depth;"].join("\n");r=new Function("buffer, depthBuf, offset, depth, u, v, n, face, material",i)}D[t]=r,e.needsUpdate=!1}return r}function l(e,t,r,n,a,o,s,c,u){if(!(e.z<-1||e.z>1||t.z<-1||t.z>1||r.z<-1||r.z>1)){var d=1<100*d){var U,k,X,H={vertexNormalsModel:[],color:c.color};if(I){me===fe.length?(U=new f,fe.push(U),++me,k=new f,fe.push(k),++me,X=new f,fe.push(X),++me):(U=fe[me],++me,k=fe[me],++me,X=fe[me],++me);var Y;Y=(1+t.z)*(t.w/e.w)/(1+e.z),U.copy(n).multiplyScalar(Y).add(a).multiplyScalar(1/(Y+1)),Y=(1+r.z)*(r.w/t.w)/(1+t.z),k.copy(a).multiplyScalar(Y).add(o).multiplyScalar(1/(Y+1)),Y=(1+e.z)*(e.w/r.w)/(1+r.z),X.copy(o).multiplyScalar(Y).add(n).multiplyScalar(1/(Y+1))}var q,$,ee;he===ue.length?(q=new v,ue.push(q),++he,$=new v,ue.push($),++he,ee=new v,ue.push(ee),++he):(q=ue[he],++he,$=ue[he],++he,ee=ue[he],++he),q.copy(e).add(t).multiplyScalar(.5),$.copy(t).add(r).multiplyScalar(.5),ee.copy(r).add(e).multiplyScalar(.5);var te,re,ie;return F&&(pe===de.length?(te=new i,de.push(te),++pe,re=new i,de.push(re),++pe,ie=new i,de.push(ie),++pe):(te=de[pe],++pe,re=de[pe],++pe,ie=de[pe],++pe),te.copy(c.vertexNormalsModel[0]).add(c.vertexNormalsModel[1]).normalize(),re.copy(c.vertexNormalsModel[1]).add(c.vertexNormalsModel[2]).normalize(),ie.copy(c.vertexNormalsModel[2]).add(c.vertexNormalsModel[0]).normalize()),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[0],H.vertexNormalsModel[1]=te,H.vertexNormalsModel[2]=ie),l(e,q,ee,n,U,X,s,H,u),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[1],H.vertexNormalsModel[1]=re,H.vertexNormalsModel[2]=te),l(t,$,q,a,k,U,s,H,u),F&&(H.vertexNormalsModel[0]=te,H.vertexNormalsModel[1]=re,H.vertexNormalsModel[2]=ie),l(q,$,ee,U,k,X,s,H,u),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[2],H.vertexNormalsModel[1]=ie,H.vertexNormalsModel[2]=re),void l(r,ee,$,o,X,k,s,H,u)}var ne,ae,oe,se,le,ce,ve=e.z*w+A|0,ge=t.z*w+A|0,ye=r.z*w+A|0,I=!1;n&&a&&o&&(I=!0,ne=n.x,ae=1-n.y,oe=a.x,se=1-a.y,le=o.x,ce=1-o.y);var xe,be,we,_e,Se,Ae;F&&(xe=c.vertexNormalsModel[0],be=c.vertexNormalsModel[1],we=c.vertexNormalsModel[2],_e=255*xe.z,Se=255*be.z,Ae=255*we.z);var Me=y-M,Te=O-N,Ee=M-C,Ce=D-O,Le=C-y,Pe=N-D,Ne=Math.max(Math.min(y,M,C)+V>>j,0),Oe=Math.min(Math.max(y,M,C)+V>>j,p),De=Math.max(Math.min(N,O,D)+V>>j,0),Fe=Math.min(Math.max(N,O,D)+V>>j,m);Q=Math.min(Ne,Q),Z=Math.max(Oe,Z),J=Math.min(De,J),K=Math.max(Fe,K);var Ie=W;Ne&=~(Ie-1),De&=~(Ie-1);var Re=Ne<0||0==Te&&Me>0)&&ke++,(Ce>0||0==Ce&&Ee>0)&&Be++,(Pe>0||0==Pe&&Le>0)&&ze++,ke=ke-1>>j,Be=Be-1>>j,ze=ze-1>>j;var je=ve-ge,Ve=ye-ve,Ge=1/(Me*Pe-Le*Te),We=Ge*(je*Pe-Ve*Te),Xe=Ge*(je*Le-Me*Ve),He=ve+(Re-y)*We+(Ue-N)*Xe|0;We=We*d|0,Xe=Xe*d|0;var Ye,qe,Qe,Je;if(I){var Ze=ne-oe,Ke=le-ne,$e=Ge*(Ze*Pe-Ke*Te),et=Ge*(Ze*Le-Me*Ke),tt=ae-se,rt=ce-ae;Ye=Ge*(tt*Pe-rt*Te),qe=Ge*(tt*Le-Me*rt),Qe=ne+(Re-y)*$e+(Ue-N)*et,Je=ae+(Re-y)*Ye+(Ue-N)*qe,$e*=d,et*=d,Ye*=d,qe*=d}var it,nt;if(F){var at=_e-Se,ot=Ae-_e,st=Ge*(at*Pe-ot*Te),it=Ge*(at*Le-Me*ot);nt=_e+(Re-y)*st+(Ue-N)*it,st*=d,it*=d}var lt=Ie-1,ct=0,ut=0,ht=0,dt=0,pt=0,ft=0,mt=0,vt=0;Me>=0?ut-=lt*Me:ct-=lt*Me,Te>=0?ut-=lt*Te:ct-=lt*Te,Ee>=0?dt-=lt*Ee:ht-=lt*Ee,Ce>=0?dt-=lt*Ce:ht-=lt*Ce,Le>=0?ft-=lt*Le:pt-=lt*Le,Pe>=0?ft-=lt*Pe:pt-=lt*Pe,We>=0?vt+=lt*We:mt+=lt*We,Xe>=0?vt+=lt*Xe:mt+=lt*Xe;var gt,yt,xt=p-Ie,bt=ke,wt=Be,_t=ze,St=He,At=-Ie,Mt=At*Te,Tt=At*Ce,Et=At*Pe,Ct=At*We;I&&(gt=At*$e,yt=At*Ye);var Lt;F&&(Lt=At*st);for(var Pt=Ne,Nt=De;Nt=Ne&&Pt=ut&&wt>=dt&&_t>=ft;)Pt+=At,bt+=Mt,wt+=Tt,_t+=Et,St+=Ct,I&&(Qe+=gt,Je+=yt),F&&(nt+=Lt);for(At=-At,Mt=-Mt,Tt=-Tt,Et=-Et,Ct=-Ct,I&&(gt=-gt,yt=-yt),F&&(Lt=-Lt);;){if(Pt+=At,bt+=Mt,wt+=Tt,_t+=Et,St+=Ct,I&&(Qe+=gt,Je+=yt),F&&(nt+=Lt),Pt=Oe)break;if(bt>G,Dt=Nt>>G,Ft=Ot+Dt*g,It=St+mt;if(!(L[Ft]=ct&&wt>=ht&&_t>=pt){var kt=St+vt;L[Ft]=Math.min(L[Ft],kt);var Bt,zt,jt=bt,Vt=wt,Gt=St;I&&(Bt=Qe,zt=Je);var Wt;F&&(Wt=nt);for(var Xt=0;Xt=0){var $t=Jt;$t1||t.z<-1||t.z>1)){var o=Math.floor(.5*(a.linewidth-1)),s=e.x*x+_|0,l=t.x*x+_|0,c=e.y*b+S|0,u=t.y*b+S|0,d=e.z*w+A|0,f=t.z*w+A|0,v=s-l,y=c-u,M=d-f,C=Math.max(Math.min(s,l)+V>>j,0),O=Math.min(Math.max(s,l)+V>>j,p),D=Math.max(Math.min(c,u)+V>>j,0),F=Math.min(Math.max(c,u)+V>>j,m),I=Math.max(Math.min(d,f)+V>>j,0),R=Math.max(d,f)+V>>j;Q=Math.min(C,Q),Z=Math.max(O,Z),J=Math.min(D,J),K=Math.max(F,K);var U,k,X,$,ee,te,re=Math.sqrt(y*y+v*v),ie=v/re,ne=y/re,ae=M/re;for(q.set(ie,ne,ae),q.cross(Y),q.normalize();re>0;){U=l+re*ie,k=u+re*ne,X=f+re*ae,U=U+V>>j,k=k+V>>j,te=X+V>>j;for(var oe=-o;oe<=o;++oe)if($=Math.floor(U+q.x*oe),ee=Math.floor(k+q.y*oe),!(Q>=$||Z<=$||J>=ee||K<=ee)){var se=$>>G,le=ee>>G,ce=se+le*g;if(!(L[ce]t.height?t.width:t.height;r=Fs.ceilPowerOfTwo(r),e.width==r&&e.height==r||(e.width=r,e.height=r);var i=e.getContext("2d");i.clearRect(0,0,r,r),i.drawImage(t,0,0,r,r);var n=i.getImageData(0,0,r,r);this.data=n.data,this.width=r,this.height=r,this.srcUrl=t.src}}};var Wg=function(e){c.call(this),this.node=e};Wg.prototype=Object.create(c.prototype),Wg.prototype.constructor=Wg;var Xg=function(){function e(){for(Y=0;P.childNodes.length>0;)P.removeChild(P.childNodes[0])}function t(e,t){var r=Math.floor(255*e.r)+","+Math.floor(255*e.g)+","+Math.floor(255*e.b);return void 0===t||1===t?"rgb("+r+")":"rgb("+r+"); fill-opacity: "+t}function n(e){return null!==Q?e.toFixed(Q):e}function a(e){I.setRGB(0,0,0),R.setRGB(0,0,0),U.setRGB(0,0,0);for(var t=0,r=e.length;t1)continue;if(S.positionScreen.z<-1||S.positionScreen.z>1)continue;if(A.positionScreen.z<-1||A.positionScreen.z>1)continue;_.positionScreen.x*=b,_.positionScreen.y*=-w,S.positionScreen.x*=b,S.positionScreen.y*=-w,A.positionScreen.x*=b,A.positionScreen.y*=-w,O.setFromPoints([_.positionScreen,S.positionScreen,A.positionScreen]),N.intersectsBox(O)===!0&&h(_,S,A,u,d)}}p(),r.traverseVisible(function(e){if(e instanceof Wg){z.setFromMatrixPosition(e.matrixWorld),z.applyMatrix4(X);var t=z.x*b,r=-z.y*w,i=e.node;i.setAttribute("transform","translate("+t+","+r+")"),P.appendChild(i)}})}},Hg=new ve,Yg=new $t,qg=[],Qg=[],Jg=new Float32Array(16),Zg=new Float32Array(9),Kg=new Float32Array(4);Ea.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),$n(t,e)},Ca.prototype.setValue=function(e,t,r){for(var i=this.seq,n=0,a=i.length;n!==a;++n){var o=i[n];o.setValue(e,t[o.id],r)}};var $g=/([\w\d_]+)(\])?(\[|\.)?/g;Na.prototype.setValue=function(e,t,r){var i=this.map[t];void 0!==i&&i.setValue(e,r,this.renderer)},Na.prototype.setOptional=function(e,t,r){var i=t[r];void 0!==i&&this.setValue(e,r,i)},Na.upload=function(e,t,r,i){for(var n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o.id];s.needsUpdate!==!1&&o.setValue(e,s.value,i)}},Na.seqWithValue=function(e,t){for(var r=[],i=0,n=e.length;i!==n;++i){var a=e[i];a.id in t&&r.push(a)}return r};var ey=0,ty=0;so.prototype=Object.assign(Object.create(de.prototype),{constructor:so,isArrayCamera:!0}),ho.prototype.clone=function(){return new ho(void 0===this.value.clone?this.value:this.value.clone())};var ry={uniforms:{tDiffuse:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","","uniform sampler2D tDiffuse;","","uniform vec2 resolution;","","varying vec2 vUv;","","// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)","","//----------------------------------------------------------------------------------","// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag","// SDK Version: v3.00","// Email: gameworks@nvidia.com","// Site: http://developer.nvidia.com/","//","// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.","//","// Redistribution and use in source and binary forms, with or without","// modification, are permitted provided that the following conditions","// are met:","// * Redistributions of source code must retain the above copyright","// notice, this list of conditions and the following disclaimer.","// * Redistributions in binary form must reproduce the above copyright","// notice, this list of conditions and the following disclaimer in the","// documentation and/or other materials provided with the distribution.","// * Neither the name of NVIDIA CORPORATION nor the names of its","// contributors may be used to endorse or promote products derived","// from this software without specific prior written permission.","//","// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY","// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE","// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR","// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR","// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,","// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,","// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR","// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY","// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT","// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE","// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.","//","//----------------------------------------------------------------------------------","","#define FXAA_PC 1","#define FXAA_GLSL_100 1","#define FXAA_QUALITY_PRESET 12","","#define FXAA_GREEN_AS_LUMA 1","","","#ifndef FXAA_PC_CONSOLE"," //"," // The console algorithm for PC is included"," // for developers targeting really low spec machines."," // Likely better to just run FXAA_PC, and use a really low preset."," //"," #define FXAA_PC_CONSOLE 0","#endif","","#ifndef FXAA_GLSL_120"," #define FXAA_GLSL_120 0","#endif","","#ifndef FXAA_GLSL_130"," #define FXAA_GLSL_130 0","#endif","","#ifndef FXAA_HLSL_3"," #define FXAA_HLSL_3 0","#endif","","#ifndef FXAA_HLSL_4"," #define FXAA_HLSL_4 0","#endif","","#ifndef FXAA_HLSL_5"," #define FXAA_HLSL_5 0","#endif","","#ifndef FXAA_GREEN_AS_LUMA"," //"," // For those using non-linear color,"," // and either not able to get luma in alpha, or not wanting to,"," // this enables FXAA to run using green as a proxy for luma."," // So with this enabled, no need to pack luma in alpha."," //"," // This will turn off AA on anything which lacks some amount of green."," // Pure red and blue or combination of only R and B, will get no AA."," //"," // Might want to lower the settings for both,"," // fxaaConsoleEdgeThresholdMin"," // fxaaQualityEdgeThresholdMin"," // In order to insure AA does not get turned off on colors"," // which contain a minor amount of green."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_GREEN_AS_LUMA 0","#endif","","#ifndef FXAA_EARLY_EXIT"," //"," // Controls algorithm's early exit path."," // On PS3 turning this ON adds 2 cycles to the shader."," // On 360 turning this OFF adds 10ths of a millisecond to the shader."," // Turning this off on console will result in a more blurry image."," // So this defaults to on."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_EARLY_EXIT 1","#endif","","#ifndef FXAA_DISCARD"," //"," // Only valid for PC OpenGL currently."," // Probably will not work when FXAA_GREEN_AS_LUMA = 1."," //"," // 1 = Use discard on pixels which don't need AA."," // For APIs which enable concurrent TEX+ROP from same surface."," // 0 = Return unchanged color on pixels which don't need AA."," //"," #define FXAA_DISCARD 0","#endif","","#ifndef FXAA_FAST_PIXEL_OFFSET"," //"," // Used for GLSL 120 only."," //"," // 1 = GL API supports fast pixel offsets"," // 0 = do not use fast pixel offsets"," //"," #ifdef GL_EXT_gpu_shader4"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifndef FXAA_FAST_PIXEL_OFFSET"," #define FXAA_FAST_PIXEL_OFFSET 0"," #endif","#endif","","#ifndef FXAA_GATHER4_ALPHA"," //"," // 1 = API supports gather4 on alpha channel."," // 0 = API does not support gather4 on alpha channel."," //"," #if (FXAA_HLSL_5 == 1)"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifndef FXAA_GATHER4_ALPHA"," #define FXAA_GATHER4_ALPHA 0"," #endif","#endif","","","","#ifndef FXAA_QUALITY_PRESET"," //"," // Choose the quality preset."," // This needs to be compiled into the shader as it effects code."," // Best option to include multiple presets is to"," // in each shader define the preset, then include this file."," //"," // OPTIONS"," // -----------------------------------------------------------------------"," // 10 to 15 - default medium dither (10=fastest, 15=highest quality)"," // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)"," // 39 - no dither, very expensive"," //"," // NOTES"," // -----------------------------------------------------------------------"," // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)"," // 13 = about same speed as FXAA 3.9 and better than 12"," // 23 = closest to FXAA 3.9 visually and performance wise"," // _ = the lowest digit is directly related to performance"," // _ = the highest digit is directly related to style"," //"," #define FXAA_QUALITY_PRESET 12","#endif","","","","","","#if (FXAA_QUALITY_PRESET == 10)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 3.0"," #define FXAA_QUALITY_P2 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 11)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 3.0"," #define FXAA_QUALITY_P3 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 12)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 4.0"," #define FXAA_QUALITY_P4 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 13)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 4.0"," #define FXAA_QUALITY_P5 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 14)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 4.0"," #define FXAA_QUALITY_P6 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 15)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 12.0","#endif","","","#if (FXAA_QUALITY_PRESET == 20)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 2.0"," #define FXAA_QUALITY_P2 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 21)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 22)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 23)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 24)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 3.0"," #define FXAA_QUALITY_P6 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 25)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 26)"," #define FXAA_QUALITY_PS 9"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 4.0"," #define FXAA_QUALITY_P8 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 27)"," #define FXAA_QUALITY_PS 10"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 4.0"," #define FXAA_QUALITY_P9 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 28)"," #define FXAA_QUALITY_PS 11"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 4.0"," #define FXAA_QUALITY_P10 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 29)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","","#if (FXAA_QUALITY_PRESET == 39)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.0"," #define FXAA_QUALITY_P2 1.0"," #define FXAA_QUALITY_P3 1.0"," #define FXAA_QUALITY_P4 1.0"," #define FXAA_QUALITY_P5 1.5"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","","","","#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)"," #define FxaaBool bool"," #define FxaaDiscard discard"," #define FxaaFloat float"," #define FxaaFloat2 vec2"," #define FxaaFloat3 vec3"," #define FxaaFloat4 vec4"," #define FxaaHalf float"," #define FxaaHalf2 vec2"," #define FxaaHalf3 vec3"," #define FxaaHalf4 vec4"," #define FxaaInt2 ivec2"," #define FxaaSat(x) clamp(x, 0.0, 1.0)"," #define FxaaTex sampler2D","#else"," #define FxaaBool bool"," #define FxaaDiscard clip(-1)"," #define FxaaFloat float"," #define FxaaFloat2 float2"," #define FxaaFloat3 float3"," #define FxaaFloat4 float4"," #define FxaaHalf half"," #define FxaaHalf2 half2"," #define FxaaHalf3 half3"," #define FxaaHalf4 half4"," #define FxaaSat(x) saturate(x)","#endif","","#if (FXAA_GLSL_100 == 1)"," #define FxaaTexTop(t, p) texture2D(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)","#endif","","#if (FXAA_GLSL_120 == 1)"," // Requires,"," // #version 120"," // And at least,"," // #extension GL_EXT_gpu_shader4 : enable"," // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)"," #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)"," #if (FXAA_FAST_PIXEL_OFFSET == 1)"," #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)"," #else"," #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)"," #endif"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","","#if (FXAA_GLSL_130 == 1)",' // Requires "#version 130" or better'," #define FxaaTexTop(t, p) textureLod(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","","#if (FXAA_HLSL_3 == 1)"," #define FxaaInt2 float2"," #define FxaaTex sampler2D"," #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))"," #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))","#endif","","#if (FXAA_HLSL_4 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)","#endif","","#if (FXAA_HLSL_5 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)"," #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)"," #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)"," #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)"," #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)","#endif","","","","#if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }","#else"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }","#endif","","","","","","#if (FXAA_PC == 1)","","FxaaFloat4 FxaaPixelShader("," //"," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy} = center of pixel"," FxaaFloat2 pos,"," //"," // Used only for FXAA Console, and not used on the 360 version."," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy_} = upper left of pixel"," // {_zw} = lower right of pixel"," FxaaFloat4 fxaaConsolePosPos,"," //"," // Input color texture."," // {rgb_} = color in linear or perceptual color space"," // if (FXAA_GREEN_AS_LUMA == 0)"," // {__a} = luma in perceptual color space (not linear)"," FxaaTex tex,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 2nd sampler."," // This sampler needs to have an exponent bias of -1."," FxaaTex fxaaConsole360TexExpBiasNegOne,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 3nd sampler."," // This sampler needs to have an exponent bias of -2."," FxaaTex fxaaConsole360TexExpBiasNegTwo,"," //"," // Only used on FXAA Quality."," // This must be from a constant/uniform."," // {x_} = 1.0/screenWidthInPixels"," // {_y} = 1.0/screenHeightInPixels"," FxaaFloat2 fxaaQualityRcpFrame,"," //"," // Only used on FXAA Console."," // This must be from a constant/uniform."," // This effects sub-pixel AA quality and inversely sharpness."," // Where N ranges between,"," // N = 0.50 (default)"," // N = 0.33 (sharper)"," // {x__} = -N/screenWidthInPixels"," // {_y_} = -N/screenHeightInPixels"," // {_z_} = N/screenWidthInPixels"," // {__w} = N/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt,"," //"," // Only used on FXAA Console."," // Not used on 360, but used on PS3 and PC."," // This must be from a constant/uniform."," // {x__} = -2.0/screenWidthInPixels"," // {_y_} = -2.0/screenHeightInPixels"," // {_z_} = 2.0/screenWidthInPixels"," // {__w} = 2.0/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt2,"," //"," // Only used on FXAA Console."," // Only used on 360 in place of fxaaConsoleRcpFrameOpt2."," // This must be from a constant/uniform."," // {x__} = 8.0/screenWidthInPixels"," // {_y_} = 8.0/screenHeightInPixels"," // {_z_} = -4.0/screenWidthInPixels"," // {__w} = -4.0/screenHeightInPixels"," FxaaFloat4 fxaaConsole360RcpFrameOpt2,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_SUBPIX define."," // It is here now to allow easier tuning."," // Choose the amount of sub-pixel aliasing removal."," // This can effect sharpness."," // 1.00 - upper limit (softer)"," // 0.75 - default amount of filtering"," // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)"," // 0.25 - almost off"," // 0.00 - completely off"," FxaaFloat fxaaQualitySubpix,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // The minimum amount of local contrast required to apply algorithm."," // 0.333 - too little (faster)"," // 0.250 - low quality"," // 0.166 - default"," // 0.125 - high quality"," // 0.063 - overkill (slower)"," FxaaFloat fxaaQualityEdgeThreshold,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // 0.0833 - upper limit (default, the start of visible unfiltered edges)"," // 0.0625 - high quality (faster)"," // 0.0312 - visible limit (slower)"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaQualityEdgeThresholdMin,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3."," // Due to the PS3 being ALU bound,"," // there are only three safe values here: 2 and 4 and 8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // For all other platforms can be a non-power of two."," // 8.0 is sharper (default!!!)"," // 4.0 is softer"," // 2.0 is really soft (good only for vector graphics inputs)"," FxaaFloat fxaaConsoleEdgeSharpness,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3."," // Due to the PS3 being ALU bound,"," // there are only two safe values here: 1/4 and 1/8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // The console setting has a different mapping than the quality setting."," // Other platforms can use other values."," // 0.125 leaves less aliasing, but is softer (default!!!)"," // 0.25 leaves more aliasing, and is sharper"," FxaaFloat fxaaConsoleEdgeThreshold,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // The console setting has a different mapping than the quality setting."," // This only applies when FXAA_EARLY_EXIT is 1."," // This does not apply to PS3,"," // PS3 was simplified to avoid more shader instructions."," // 0.06 - faster but more aliasing in darks"," // 0.05 - default"," // 0.04 - slower and less aliasing in darks"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaConsoleEdgeThresholdMin,"," //"," // Extra constants for 360 FXAA Console only."," // Use zeros or anything else for other platforms."," // These must be in physical constant registers and NOT immediates."," // Immediates will result in compiler un-optimizing."," // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)"," FxaaFloat4 fxaaConsole360ConstDir",") {",""," FxaaFloat2 posM;"," posM.x = pos.x;"," posM.y = pos.y;"," #if (FXAA_GATHER4_ALPHA == 1)"," #if (FXAA_DISCARD == 0)"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #endif"," #if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));"," #else"," FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));"," #endif"," #if (FXAA_DISCARD == 1)"," #define lumaM luma4A.w"," #endif"," #define lumaE luma4A.z"," #define lumaS luma4A.x"," #define lumaSE luma4A.y"," #define lumaNW luma4B.w"," #define lumaN luma4B.z"," #define lumaW luma4B.x"," #else"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));"," #endif"," #endif",""," FxaaFloat maxSM = max(lumaS, lumaM);"," FxaaFloat minSM = min(lumaS, lumaM);"," FxaaFloat maxESM = max(lumaE, maxSM);"," FxaaFloat minESM = min(lumaE, minSM);"," FxaaFloat maxWN = max(lumaN, lumaW);"," FxaaFloat minWN = min(lumaN, lumaW);"," FxaaFloat rangeMax = max(maxWN, maxESM);"," FxaaFloat rangeMin = min(minWN, minESM);"," FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;"," FxaaFloat range = rangeMax - rangeMin;"," FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);"," FxaaBool earlyExit = range < rangeMaxClamped;",""," if(earlyExit)"," #if (FXAA_DISCARD == 1)"," FxaaDiscard;"," #else"," return rgbyM;"," #endif",""," #if (FXAA_GATHER4_ALPHA == 0)"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif"," #else"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif",""," FxaaFloat lumaNS = lumaN + lumaS;"," FxaaFloat lumaWE = lumaW + lumaE;"," FxaaFloat subpixRcpRange = 1.0/range;"," FxaaFloat subpixNSWE = lumaNS + lumaWE;"," FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;"," FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;",""," FxaaFloat lumaNESE = lumaNE + lumaSE;"," FxaaFloat lumaNWNE = lumaNW + lumaNE;"," FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;"," FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;",""," FxaaFloat lumaNWSW = lumaNW + lumaSW;"," FxaaFloat lumaSWSE = lumaSW + lumaSE;"," FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);"," FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);"," FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;"," FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;"," FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;"," FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;",""," FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;"," FxaaFloat lengthSign = fxaaQualityRcpFrame.x;"," FxaaBool horzSpan = edgeHorz >= edgeVert;"," FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;",""," if(!horzSpan) lumaN = lumaW;"," if(!horzSpan) lumaS = lumaE;"," if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;"," FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;",""," FxaaFloat gradientN = lumaN - lumaM;"," FxaaFloat gradientS = lumaS - lumaM;"," FxaaFloat lumaNN = lumaN + lumaM;"," FxaaFloat lumaSS = lumaS + lumaM;"," FxaaBool pairN = abs(gradientN) >= abs(gradientS);"," FxaaFloat gradient = max(abs(gradientN), abs(gradientS));"," if(pairN) lengthSign = -lengthSign;"," FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);",""," FxaaFloat2 posB;"," posB.x = posM.x;"," posB.y = posM.y;"," FxaaFloat2 offNP;"," offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;"," offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;"," if(!horzSpan) posB.x += lengthSign * 0.5;"," if( horzSpan) posB.y += lengthSign * 0.5;",""," FxaaFloat2 posN;"," posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;"," posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;"," FxaaFloat2 posP;"," posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;"," posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;"," FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;"," FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));"," FxaaFloat subpixE = subpixC * subpixC;"," FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));",""," if(!pairN) lumaNN = lumaSS;"," FxaaFloat gradientScaled = gradient * 1.0/4.0;"," FxaaFloat lumaMM = lumaM - lumaNN * 0.5;"," FxaaFloat subpixF = subpixD * subpixE;"," FxaaBool lumaMLTZero = lumaMM < 0.0;",""," lumaEndN -= lumaNN * 0.5;"," lumaEndP -= lumaNN * 0.5;"," FxaaBool doneN = abs(lumaEndN) >= gradientScaled;"," FxaaBool doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;"," FxaaBool doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;",""," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;",""," #if (FXAA_QUALITY_PS > 3)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;",""," #if (FXAA_QUALITY_PS > 4)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;",""," #if (FXAA_QUALITY_PS > 5)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;",""," #if (FXAA_QUALITY_PS > 6)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;",""," #if (FXAA_QUALITY_PS > 7)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;",""," #if (FXAA_QUALITY_PS > 8)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;",""," #if (FXAA_QUALITY_PS > 9)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;",""," #if (FXAA_QUALITY_PS > 10)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;",""," #if (FXAA_QUALITY_PS > 11)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;",""," #if (FXAA_QUALITY_PS > 12)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }",""," FxaaFloat dstN = posM.x - posN.x;"," FxaaFloat dstP = posP.x - posM.x;"," if(!horzSpan) dstN = posM.y - posN.y;"," if(!horzSpan) dstP = posP.y - posM.y;",""," FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;"," FxaaFloat spanLength = (dstP + dstN);"," FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;"," FxaaFloat spanLengthRcp = 1.0/spanLength;",""," FxaaBool directionN = dstN < dstP;"," FxaaFloat dst = min(dstN, dstP);"," FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;"," FxaaFloat subpixG = subpixF * subpixF;"," FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;"," FxaaFloat subpixH = subpixG * fxaaQualitySubpix;",""," FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;"," FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);"," if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;"," if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;"," #if (FXAA_DISCARD == 1)"," return FxaaTexTop(tex, posM);"," #else"," return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);"," #endif","}","","#endif","","void main() {"," gl_FragColor = FxaaPixelShader("," vUv,"," vec4(0.0),"," tDiffuse,"," tDiffuse,"," tDiffuse,"," resolution,"," vec4(0.0),"," vec4(0.0),"," vec4(0.0),"," 0.75,"," 0.166,"," 0.0833,"," 0.0,"," 0.0,"," 0.0,"," vec4(0.0)"," );",""," // TODO avoid querying texture twice for same texel"," gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join("\n") -},iy=function(e){function t(e){ke.renderer=void 0!==e.renderer?e.renderer:new uo,ke.domElement=ke.renderer.domElement,de=ke.renderer.context,ve=void 0!==e.width?e.width:ke.renderer.getSize().width,ye=void 0!==e.height?e.height:ke.renderer.getSize().height;var t=void 0!==e.antialias&&e.antialias;void 0!==e.cacheKeepAlive&&(Ve=e.cacheKeepAlive),r(),n(),a(),o(),s(),l(),ke.setSize(ve,ye),ke.setAntialias(t),ke.enableLightPrePass(!1)}function r(){Fe=new In(ve,ye,vc,(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),Ac)}function n(){Le=new dg,Le.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,stencilBuffer:!0,depthTexture:Fe});e.texture.generateMipamps=!1,Te=new ng(ke.renderer,e),Te.addPass(Le)}function a(){we=new dg,we.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,be=new ng(ke.renderer,e),be.addPass(we)}function o(){Ne=new dg,Ne.clear=!0,Ne.camera=new me((-1),1,1,(-1),0,1),Pe=new dg,Pe.clear=!1;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,Ee=new ng(ke.renderer,e),Ee.addPass(Ne),Ee.addPass(Pe)}function s(){Me=new dg,Me.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,Ae=new ng(ke.renderer,e),Ae.addPass(Me)}function l(){Oe=new Ev(oy["final"]),Oe.clear=!0,Oe.uniforms.samplerResult.value=Ee.renderTarget2.texture,Oe.material.blending=nl,Oe.material.depthWrite=!1,Oe.material.depthTest=!1,_e=new dg,_e.clear=!1,Se=new Ev(Gv),De=new Ev(ry);var e=new ge(ve,ye,{minFilter:$l,magFilter:rc,format:yc,type:ac,depthTexture:Fe});e.texture.generateMipamps=!1,Ce=new ng(ke.renderer,e),Ce.addPass(Oe),Ce.addPass(_e),Ce.addPass(Se),Ce.addPass(De)}function c(e){var t=Xe[e.uuid],r=He[e.uuid];if(void 0===t){var i=new fe;i.userData.lights={},t=re(),t.scene=i,Xe[e.uuid]=t}if(void 0===r){var i=new fe;i.userData.lights={};var n=P();i.userData.emissiveLight=n,i.add(n),r=re(),r.scene=i,He[e.uuid]=r}t.used=!0,r.used=!0;var a=t.scene,o=r.scene;o.userData.emissiveLight.visible=!je,Re=a,Ue=o}function u(e,t,r,i){var n=t[e.uuid];return void 0===n&&(n=re(),n.material=r(e),t[e.uuid]=n),n.used=!0,i(n.material,e),tt[n.material.uuid]=e,n.material}function h(e,t,r){if(void 0!==e.material){if(Array.isArray(e.material))for(var i=0,n=e.material.length;i0&&(e.scale.set(1,1,1).multiplyScalar(r),e.position.setFromMatrixPosition(t.matrixWorld))}function G(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=s.distance,c=n.uniforms;c.lightColor.value.copy(s.color),l>0?(c.lightRadius.value=l,c.lightIntensity.value=s.intensity,c.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(Ie.matrixWorldInverse)):c.lightRadius.value=1/0,B(c)}function W(e){var t=R(e,new xe(2,2));return t.onBeforeRender=H,t}function X(){var e=je?oy.spotLightPre:oy.spotLight,t=U(e);return t.depthTest=!1,t}function H(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightAngle.value=s.angle,l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity,l.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(Ie.matrixWorldInverse);var c=l.lightDirectionVS.value,u=We;c.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),c.sub(u).normalize().transformDirection(Ie.matrixWorldInverse),B(l)}function Y(e){var t=R(e,new xe(2,2));return t.onBeforeRender=Q,t}function q(){var e=je?oy.directionalLightPre:oy.directionalLight,t=U(e);return t.depthTest=!1,t}function Q(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity;var c=l.lightDirectionVS.value,u=We;c.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),c.sub(u).normalize().transformDirection(Ie.matrixWorldInverse),B(l)}function J(e){if(void 0!==e.material&&(rt[e.uuid]=e.onBeforeRender,!ze&&!je&&e.visible))if(Array.isArray(e.material)){for(var t=0,r=e.material.length;tet&&delete e[n]):(e[n].used=!1,e[n].count=0)}}function ne(e){for(var t=Object.keys(e),r=0,i=t.length;r","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","\tvNormal = normalize( transformedNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",ny.packNormalDepth,"\tgl_FragColor = packedNormalDepth;","}"].join("\n")},color:{uniforms:{map:new ho(null),offsetRepeat:new ho(new v(0,0,1,1)),diffuse:new ho(new u(0)),emissive:new ho(new u(0)),specular:new ho(new u(0)),shininess:new ho(30)},vertexShader:["#include ","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","#include ","#include ",ny.packVector3,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;","#include ",ny.packColor,"\tgl_FragColor = packedColor;","}"].join("\n")},emissiveLight:{uniforms:Object.assign({samplerColor:new ho(null)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackColor,"\tgl_FragColor = vec4( emissiveColor, 1.0 );","}"].join("\n")},pointLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightPositionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1),lightRadius:new ho(1)},ay.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",ny.unpackColor,ny.computeSpecular,"\t//float cutoff = 0.3;","\t//float denom = distance / lightRadius + 1.0;","\t//float attenuation = 1.0 / ( denom * denom );","\t//attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );","\t//attenuation = max( attenuation, 0.0 );","\t//attenuation *= attenuation;","\t//diffuseColor *= saturate( -distance / lightRadius + 1.0 );","\t//float attenuation = 1.0;","\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",ny.combine,"}"].join("\n")},spotLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightPositionVS:new ho(new i(0,1,0)),lightAngle:new ho(1),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,ny.unpackColor,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}","\tdiffuseColor *= spot;",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.combine,"}"].join("\n")},directionalLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,ny.unpackColor,"\tvec3 lightVector = normalize( lightDirectionVS );",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.combine,"}"].join("\n")},normalDepthShininess:{uniforms:{shininess:new ho(30)},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","\tvNormal = normalize( transformedNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","uniform float shininess;",ny.packNormal,"void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",ny.packNormalDepthShininess,"\tgl_FragColor = packedNormalDepthShininess;","}"].join("\n")},pointLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightPositionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1),lightRadius:new ho(1)},ay.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",ny.computeSpecular,"\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",ny.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},spotLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightPositionVS:new ho(new i(0,1,0)),lightAngle:new ho(1),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.packLight,"\tgl_FragColor = spot * packedLight;","}"].join("\n")},directionalLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightDirectionVS );",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},reconstruction:{uniforms:Object.assign({samplerLight:new ho(null),map:new ho(null),offsetRepeat:new ho(new v(0,0,1,1)),diffuse:new ho(new u(0)),emissive:new ho(new u(0)),specular:new ho(new u(0)),shininess:new ho(30)},ay.commonUniforms),vertexShader:["#include ","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","}"].join("\n"),fragmentShader:["uniform sampler2D samplerLight;","uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","uniform float viewHeight;","uniform float viewWidth;","#include ","#include ",ny.unpackFloat,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",ny.computeTextureCoord,"\tvec4 light = texture2D( samplerLight, texCoord );","#include ","\tvec3 diffuseFinal = diffuseColor.rgb * light.rgb;","\tvec3 emissiveFinal = emissiveColor;","\tvec3 specularFinal = specularColor * light.rgb * light.a;","\tgl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );","}"].join("\n")},"final":{uniforms:{samplerResult:new ho(null)},vertexShader:["varying vec2 texCoord;","void main() {","\tvec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );","\ttexCoord = pos.xy * vec2( 0.5 ) + 0.5;","\tgl_Position = pos;","}"].join("\n"),fragmentShader:["varying vec2 texCoord;","uniform sampler2D samplerResult;","void main() {","\tgl_FragColor = texture2D( samplerResult, texCoord );","}"].join("\n")}};po.prototype=Object.create(P.prototype),fo.prototype=Object.create(P.prototype),mo.prototype=Object.create(P.prototype),vo.prototype=Object.create(P.prototype),go.prototype=Object.create(P.prototype);var sy={godrays_depthMask:{uniforms:{tInput:{value:null}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D tInput;","void main() {","\tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );","}"].join("\n")},godrays_generate:{uniforms:{tInput:{value:null},fStepSize:{value:1},vSunPositionScreenSpace:{value:new f(.5,.5)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define TAPS_PER_PASS 6.0","varying vec2 vUv;","uniform sampler2D tInput;","uniform vec2 vSunPositionScreenSpace;","uniform float fStepSize;","void main() {","vec2 delta = vSunPositionScreenSpace - vUv;","float dist = length( delta );","vec2 stepv = fStepSize * delta / dist;","float iters = dist/fStepSize;","vec2 uv = vUv.xy;","float col = 0.0;","if ( 0.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 1.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 2.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 3.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 4.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 5.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","gl_FragColor = vec4( col/TAPS_PER_PASS );","gl_FragColor.a = 1.0;","}"].join("\n")},godrays_combine:{uniforms:{tColors:{value:null},tGodRays:{value:null},fGodRayIntensity:{value:.69},vSunPositionScreenSpace:{value:new f(.5,.5)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D tColors;","uniform sampler2D tGodRays;","uniform vec2 vSunPositionScreenSpace;","uniform float fGodRayIntensity;","void main() {","gl_FragColor = texture2D( tColors, vUv ) + fGodRayIntensity * vec4( 1.0 - texture2D( tGodRays, vUv ).r );","gl_FragColor.a = 1.0;","}"].join("\n")},godrays_fake_sun:{uniforms:{vSunPositionScreenSpace:{value:new f(.5,.5)},fAspect:{value:1},sunColor:{value:new u(16772608)},bgColor:{value:new u(0)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform vec2 vSunPositionScreenSpace;","uniform float fAspect;","uniform vec3 sunColor;","uniform vec3 bgColor;","void main() {","vec2 diff = vUv - vSunPositionScreenSpace;","diff.x *= fAspect;","float prop = clamp( length( diff ) / 0.5, 0.0, 1.0 );","prop = 0.35 * pow( 1.0 - prop, 3.0 );","gl_FragColor.xyz = mix( sunColor, bgColor, 1.0 - prop );","gl_FragColor.w = 1.0;","}"].join("\n")}},ly={uniforms:{},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["void main() {","gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );","}"].join("\n")},cy={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 base = texture2D( tDiffuse, vUv );","vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );","float lum = dot( lumCoeff, base.rgb );","vec3 blend = vec3( lum );","float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );","vec3 result1 = 2.0 * base.rgb * blend;","vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );","vec3 newColor = mix( result1, result2, L );","float A2 = opacity * base.a;","vec3 mixRGB = A2 * newColor.rgb;","mixRGB += ( ( 1.0 - A2 ) * base.rgb );","gl_FragColor = vec4( mixRGB, base.a );","}"].join("\n") -},uy={uniforms:{tDiffuse1:{value:null},tDiffuse2:{value:null},mixRatio:{value:.5},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform float mixRatio;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","varying vec2 vUv;","void main() {","vec4 texel1 = texture2D( tDiffuse1, vUv );","vec4 texel2 = texture2D( tDiffuse2, vUv );","gl_FragColor = opacity * mix( texel1, texel2, mixRatio );","}"].join("\n")},hy={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float brightness;","uniform float contrast;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","gl_FragColor.rgb += brightness;","if (contrast > 0.0) {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;","} else {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;","}","}"].join("\n")},dy={uniforms:{tDiffuse:{value:null},powRGB:{value:new i(2,2,2)},mulRGB:{value:new i(1,1,1)},addRGB:{value:new i(0,0,0)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 powRGB;","uniform vec3 mulRGB;","uniform vec3 addRGB;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );","}"].join("\n")},py={uniforms:{tDiffuse:{value:null},color:{value:new u(16777215)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","gl_FragColor = vec4( v * color, texel.w );","}"].join("\n")},fy={uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},maxblur:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float focus;","uniform float maxblur;","uniform sampler2D tColor;","uniform sampler2D tDepth;","varying vec2 vUv;","void main() {","vec4 depth = texture2D( tDepth, vUv );","float factor = depth.x - focus;","vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );","gl_FragColor = col;","gl_FragColor.a = 1.0;","}"].join("\n")},my={uniforms:{tDiffuse:{value:null},screenWidth:{value:1024},screenHeight:{value:1024},sampleDistance:{value:.94},waveFactor:{value:.00125}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float screenWidth;","uniform float screenHeight;","uniform float sampleDistance;","uniform float waveFactor;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 color, org, tmp, add;","float sample_dist, f;","vec2 vin;","vec2 uv = vUv;","add = color = org = texture2D( tDiffuse, uv );","vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );","sample_dist = dot( vin, vin ) * 2.0;","f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;","vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );","add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );","color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );","gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );","}"].join("\n")},vy={uniforms:{tDiffuse:{value:null},aspect:{value:new f(512,512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform vec2 aspect;","vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);","mat3 G[9];","const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );","const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );","const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );","const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );","const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );","const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );","const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );","const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );","const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );","void main(void)","{","G[0] = g0,","G[1] = g1,","G[2] = g2,","G[3] = g3,","G[4] = g4,","G[5] = g5,","G[6] = g6,","G[7] = g7,","G[8] = g8;","mat3 I;","float cnv[9];","vec3 sample;","for (float i=0.0; i<3.0; i++) {","for (float j=0.0; j<3.0; j++) {","sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;","I[int(i)][int(j)] = length(sample);","}","}","for (int i=0; i<9; i++) {","float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);","cnv[i] = dp3 * dp3;","}","float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);","float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);","gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);","}"].join("\n")},gy={uniforms:{mRefractionRatio:{value:1.02},mFresnelBias:{value:.1},mFresnelPower:{value:2},mFresnelScale:{value:1},tCube:{value:null}},vertexShader:["uniform float mRefractionRatio;","uniform float mFresnelBias;","uniform float mFresnelScale;","uniform float mFresnelPower;","varying vec3 vReflect;","varying vec3 vRefract[3];","varying float vReflectionFactor;","void main() {","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","vec3 I = worldPosition.xyz - cameraPosition;","vReflect = reflect( I, worldNormal );","vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );","vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );","vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );","vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","varying vec3 vReflect;","varying vec3 vRefract[3];","varying float vReflectionFactor;","void main() {","vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );","vec4 refractedColor = vec4( 1.0 );","refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;","refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;","refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;","gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );","}"].join("\n")},yy={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );","}"].join("\n")},xy={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float h;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},by={uniforms:{tDiffuse:{value:null},h:{value:1/512},r:{value:.35}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float h;","uniform float r;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","float hh = h * abs( r - vUv.y );","sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},wy={uniforms:{tDiffuse:{value:null},hue:{value:0},saturation:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float hue;","uniform float saturation;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","float angle = hue * 3.14159265;","float s = sin(angle), c = cos(angle);","vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;","float len = length(gl_FragColor.rgb);","gl_FragColor.rgb = vec3(","dot(gl_FragColor.rgb, weights.xyz),","dot(gl_FragColor.rgb, weights.zxy),","dot(gl_FragColor.rgb, weights.yzx)",");","float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;","if (saturation > 0.0) {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));","} else {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);","}","}"].join("\n")},_y={uniforms:{tDiffuse:{value:null},sides:{value:6},angle:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float sides;","uniform float angle;","varying vec2 vUv;","void main() {","vec2 p = vUv - 0.5;","float r = length(p);","float a = atan(p.y, p.x) + angle;","float tau = 2. * 3.1416 ;","a = mod(a, tau/sides);","a = abs(a - tau/sides/2.) ;","p = r * vec2(cos(a), sin(a));","vec4 color = texture2D(tDiffuse, p + 0.5);","gl_FragColor = color;","}"].join("\n")},Sy={uniforms:{tDiffuse:{value:null},side:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform int side;","varying vec2 vUv;","void main() {","vec2 p = vUv;","if (side == 0){","if (p.x > 0.5) p.x = 1.0 - p.x;","}else if (side == 1){","if (p.x < 0.5) p.x = 1.0 - p.x;","}else if (side == 2){","if (p.y < 0.5) p.y = 1.0 - p.y;","}else if (side == 3){","if (p.y > 0.5) p.y = 1.0 - p.y;","} ","vec4 color = texture2D(tDiffuse, p);","gl_FragColor = color;","}"].join("\n")},Ay={uniforms:{heightMap:{value:null},resolution:{value:new f(512,512)},scale:{value:new f(1,1)},height:{value:.05}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float height;","uniform vec2 resolution;","uniform sampler2D heightMap;","varying vec2 vUv;","void main() {","float val = texture2D( heightMap, vUv ).x;","float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;","float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;","gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );","}"].join("\n")},My={modes:{none:"NO_PARALLAX",basic:"USE_BASIC_PARALLAX",steep:"USE_STEEP_PARALLAX",occlusion:"USE_OCLUSION_PARALLAX",relief:"USE_RELIEF_PARALLAX"},uniforms:{bumpMap:{value:null},map:{value:null},parallaxScale:{value:null},parallaxMinLayers:{value:null},parallaxMaxLayers:{value:null}},vertexShader:["varying vec2 vUv;","varying vec3 vViewPosition;","varying vec3 vNormal;","void main() {","vUv = uv;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform sampler2D bumpMap;","uniform sampler2D map;","uniform float parallaxScale;","uniform float parallaxMinLayers;","uniform float parallaxMaxLayers;","varying vec2 vUv;","varying vec3 vViewPosition;","varying vec3 vNormal;","#ifdef USE_BASIC_PARALLAX","vec2 parallaxMap( in vec3 V ) {","float initialHeight = texture2D( bumpMap, vUv ).r;","vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;","return vUv - texCoordOffset;","}","#else","vec2 parallaxMap( in vec3 V ) {","float numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );","float layerHeight = 1.0 / numLayers;","float currentLayerHeight = 0.0;","vec2 dtex = parallaxScale * V.xy / V.z / numLayers;","vec2 currentTextureCoords = vUv;","float heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","for ( int i = 0; i < 30; i += 1 ) {","if ( heightFromTexture <= currentLayerHeight ) {","break;","}","currentLayerHeight += layerHeight;","currentTextureCoords -= dtex;","heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","}","#ifdef USE_STEEP_PARALLAX","return currentTextureCoords;","#elif defined( USE_RELIEF_PARALLAX )","vec2 deltaTexCoord = dtex / 2.0;","float deltaHeight = layerHeight / 2.0;","currentTextureCoords += deltaTexCoord;","currentLayerHeight -= deltaHeight;","const int numSearches = 5;","for ( int i = 0; i < numSearches; i += 1 ) {","deltaTexCoord /= 2.0;","deltaHeight /= 2.0;","heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","if( heightFromTexture > currentLayerHeight ) {","currentTextureCoords -= deltaTexCoord;","currentLayerHeight += deltaHeight;","} else {","currentTextureCoords += deltaTexCoord;","currentLayerHeight -= deltaHeight;","}","}","return currentTextureCoords;","#elif defined( USE_OCLUSION_PARALLAX )","vec2 prevTCoords = currentTextureCoords + dtex;","float nextH = heightFromTexture - currentLayerHeight;","float prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;","float weight = nextH / ( nextH - prevH );","return prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );","#else","return vUv;","#endif","}","#endif","vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {","vec2 texDx = dFdx( vUv );","vec2 texDy = dFdy( vUv );","vec3 vSigmaX = dFdx( surfPosition );","vec3 vSigmaY = dFdy( surfPosition );","vec3 vR1 = cross( vSigmaY, surfNormal );","vec3 vR2 = cross( surfNormal, vSigmaX );","float fDet = dot( vSigmaX, vR1 );","vec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );","vec3 vProjVtex;","vProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;","vProjVtex.z = dot( surfNormal, viewPosition );","return parallaxMap( vProjVtex );","}","void main() {","vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );","gl_FragColor = texture2D( map, mapUv );","}"].join("\n")},Ty={uniforms:{tDiffuse:{value:null},resolution:{value:null},pixelSize:{value:1}},vertexShader:["varying highp vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float pixelSize;","uniform vec2 resolution;","varying highp vec2 vUv;","void main(){","vec2 dxy = pixelSize / resolution;","vec2 coord = dxy * floor( vUv / dxy );","gl_FragColor = texture2D(tDiffuse, coord);","}"].join("\n")},Ey={uniforms:{tDiffuse:{value:null},amount:{value:.005},angle:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float amount;","uniform float angle;","varying vec2 vUv;","void main() {","vec2 offset = amount * vec2( cos(angle), sin(angle));","vec4 cr = texture2D(tDiffuse, vUv + offset);","vec4 cga = texture2D(tDiffuse, vUv);","vec4 cb = texture2D(tDiffuse, vUv - offset);","gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);","}"].join("\n")},Cy={uniforms:{tDiffuse:{value:null},amount:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float amount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 color = texture2D( tDiffuse, vUv );","vec3 c = color.rgb;","color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );","color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );","color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );","gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );","}"].join("\n")},Ly={uniforms:{tDiffuse:{value:null},resolution:{value:new f}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","void main() {","vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );","const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );","const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );","float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;","float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;","float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;","float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;","float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;","float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;","float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;","float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;","float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;","float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ","Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ","Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ","float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ","Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ","Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ","float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );","gl_FragColor = vec4( vec3( G ), 1 );","}"].join("\n")},Py={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);","gl_FragColor = newTex;","}"].join("\n")},Ny={uniforms:{texture:{value:null},delta:{value:new f(1,1)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#define ITERATIONS 10.0","uniform sampler2D texture;","uniform vec2 delta;","varying vec2 vUv;","void main() {","vec4 color = vec4( 0.0 );","float total = 0.0;","float offset = rand( vUv );","for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {","float percent = ( t + offset - 0.5 ) / ITERATIONS;","float weight = 1.0 - abs( percent );","color += texture2D( texture, vUv + delta * percent ) * weight;","total += weight;","}","gl_FragColor = color / total;","}"].join("\n")},Oy={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float v;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},Dy={uniforms:{tDiffuse:{value:null},v:{value:1/512},r:{value:.35}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float v;","uniform float r;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","float vv = v * abs( r - vUv.y );","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},Fy={uniforms:{tDiffuse:{value:null},offset:{value:1},darkness:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float offset;","uniform float darkness;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );","gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );","}"].join("\n")},Iy={uniforms:{color:{type:"c",value:null},time:{type:"f",value:0},tDiffuse:{type:"t",value:null},tDudv:{type:"t",value:null},textureMatrix:{type:"m4",value:null}},vertexShader:["uniform mat4 textureMatrix;","varying vec2 vUv;","varying vec4 vUvRefraction;","void main() {","\tvUv = uv;","\tvUvRefraction = textureMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform float time;","uniform sampler2D tDiffuse;","uniform sampler2D tDudv;","varying vec2 vUv;","varying vec4 vUvRefraction;","float blendOverlay( float base, float blend ) {","\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );","}","vec3 blendOverlay( vec3 base, vec3 blend ) {","\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ),blendOverlay( base.b, blend.b ) );","}","void main() {"," float waveStrength = 0.1;"," float waveSpeed = 0.03;","\tvec2 distortedUv = texture2D( tDudv, vec2( vUv.x + time * waveSpeed, vUv.y ) ).rg * waveStrength;","\tdistortedUv = vUv.xy + vec2( distortedUv.x, distortedUv.y + time * waveSpeed );","\tvec2 distortion = ( texture2D( tDudv, distortedUv ).rg * 2.0 - 1.0 ) * waveStrength;"," vec4 uv = vec4( vUvRefraction );"," uv.xy += distortion;","\tvec4 base = texture2DProj( tDiffuse, uv );","\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );","}"].join("\n")},Ry={skinSimple:{uniforms:Mu.merge([mp.fog,mp.lights,{enableBump:{value:0},enableSpecular:{value:0},tDiffuse:{value:null},tBeckmann:{value:null},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},opacity:{value:1},uRoughness:{value:.15},uSpecularBrightness:{value:.75},bumpMap:{value:null},bumpScale:{value:1},specularMap:{value:null},offsetRepeat:{value:new v(0,0,1,1)},uWrapRGB:{value:new i(.75,.375,.1875)}}]),fragmentShader:["#define USE_BUMPMAP","uniform bool enableBump;","uniform bool enableSpecular;","uniform vec3 diffuse;","uniform vec3 specular;","uniform float opacity;","uniform float uRoughness;","uniform float uSpecularBrightness;","uniform vec3 uWrapRGB;","uniform sampler2D tDiffuse;","uniform sampler2D tBeckmann;","uniform sampler2D specularMap;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.bsdfs,fp.packing,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.fog_pars_fragment,fp.bumpmap_pars_fragment,"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {","float base = 1.0 - dot( V, H );","float exponential = pow( base, 5.0 );","return exponential + F0 * ( 1.0 - exponential );","}","float KS_Skin_Specular( vec3 N,","vec3 L,","vec3 V,","float m,","float rho_s",") {","float result = 0.0;","float ndotl = dot( N, L );","if( ndotl > 0.0 ) {","vec3 h = L + V;","vec3 H = normalize( h );","float ndoth = dot( N, H );","float PH = pow( 2.0 * texture2D( tBeckmann, vec2( ndoth, m ) ).x, 10.0 );","float F = fresnelReflectance( H, V, 0.028 );","float frSpec = max( PH * F / dot( h, h ), 0.0 );","result = ndotl * rho_s * frSpec;","}","return result;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec4 colDiffuse = texture2D( tDiffuse, vUv );","colDiffuse.rgb *= colDiffuse.rgb;","diffuseColor = diffuseColor * colDiffuse;","vec3 normal = normalize( vNormal );","vec3 viewerDirection = normalize( vViewPosition );","float specularStrength;","if ( enableSpecular ) {","vec4 texelSpecular = texture2D( specularMap, vUv );","specularStrength = texelSpecular.r;","} else {","specularStrength = 1.0;","}","#ifdef USE_BUMPMAP","if ( enableBump ) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );","#endif","vec3 totalSpecularLight = vec3( 0.0 );","vec3 totalDiffuseLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 lVector = pointLights[ i ].position + vViewPosition.xyz;","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","lVector = normalize( lVector );","float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), uWrapRGB );","float pointSpecularWeight = KS_Skin_Specular( normal, lVector, viewerDirection, uRoughness, uSpecularBrightness );","totalDiffuseLight += pointLight[ i ].color * ( pointDiffuseWeight * attenuation );","totalSpecularLight += pointLight[ i ].color * specular * ( pointSpecularWeight * specularStrength * attenuation );","}","#endif","#if NUM_DIR_LIGHTS > 0","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );","float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3 ( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), uWrapRGB );","float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","totalSpecularLight += directionalLights[ i ].color * ( dirSpecularWeight * specularStrength );","}","#endif","#if NUM_HEMI_LIGHTS > 0","for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","vec3 lVector = hemisphereLightDirection[ i ];","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","totalDiffuseLight += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","float hemiSpecularWeight = 0.0;","hemiSpecularWeight += KS_Skin_Specular( normal, lVector, viewerDirection, uRoughness, uSpecularBrightness );","vec3 lVectorGround = -lVector;","hemiSpecularWeight += KS_Skin_Specular( normal, lVectorGround, viewerDirection, uRoughness, uSpecularBrightness );","vec3 hemiSpecularColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","totalSpecularLight += hemiSpecularColor * specular * ( hemiSpecularWeight * specularStrength );","}","#endif","outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor * diffuse ) + totalSpecularLight;","gl_FragColor = linearToOutputTexel( vec4( outgoingLight, diffuseColor.a ) );",fp.fog_fragment,"}"].join("\n"),vertexShader:["uniform vec4 offsetRepeat;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.lights_pars_begin,fp.shadowmap_pars_vertex,fp.fog_pars_vertex,"void main() {","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv * offsetRepeat.zw + offsetRepeat.xy;","gl_Position = projectionMatrix * mvPosition;",fp.shadowmap_vertex,fp.fog_vertex,"}"].join("\n") -},skin:{uniforms:Mu.merge([mp.fog,mp.lights,{passID:{value:0},tDiffuse:{value:null},tNormal:{value:null},tBlur1:{value:null},tBlur2:{value:null},tBlur3:{value:null},tBlur4:{value:null},tBeckmann:{value:null},uNormalScale:{value:1},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},opacity:{value:1},uRoughness:{value:.15},uSpecularBrightness:{value:.75}}]),fragmentShader:["uniform vec3 diffuse;","uniform vec3 specular;","uniform float opacity;","uniform float uRoughness;","uniform float uSpecularBrightness;","uniform int passID;","uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tBlur1;","uniform sampler2D tBlur2;","uniform sampler2D tBlur3;","uniform sampler2D tBlur4;","uniform sampler2D tBeckmann;","uniform float uNormalScale;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.lights_pars_begin,fp.fog_pars_fragment,"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {","float base = 1.0 - dot( V, H );","float exponential = pow( base, 5.0 );","return exponential + F0 * ( 1.0 - exponential );","}","float KS_Skin_Specular( vec3 N,","vec3 L,","vec3 V,","float m,","float rho_s",") {","float result = 0.0;","float ndotl = dot( N, L );","if( ndotl > 0.0 ) {","vec3 h = L + V;","vec3 H = normalize( h );","float ndoth = dot( N, H );","float PH = pow( 2.0 * texture2D( tBeckmann, vec2( ndoth, m ) ).x, 10.0 );","float F = fresnelReflectance( H, V, 0.028 );","float frSpec = max( PH * F / dot( h, h ), 0.0 );","result = ndotl * rho_s * frSpec;","}","return result;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec4 mSpecular = vec4( specular, opacity );","vec4 colDiffuse = texture2D( tDiffuse, vUv );","colDiffuse *= colDiffuse;","diffuseColor *= colDiffuse;","vec4 posAndU = vec4( -vViewPosition, vUv.x );","vec4 posAndU_dx = dFdx( posAndU ), posAndU_dy = dFdy( posAndU );","vec3 tangent = posAndU_dx.w * posAndU_dx.xyz + posAndU_dy.w * posAndU_dy.xyz;","vec3 normal = normalize( vNormal );","vec3 binormal = normalize( cross( tangent, normal ) );","tangent = cross( normal, binormal );","mat3 tsb = mat3( tangent, binormal, normal );","vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","vec3 finalNormal = tsb * normalTex;","normal = normalize( finalNormal );","vec3 viewerDirection = normalize( vViewPosition );","vec3 totalDiffuseLight = vec3( 0.0 );","vec3 totalSpecularLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 pointVector = normalize( pointLights[ i ].direction );","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );","totalDiffuseLight += pointLightColor[ i ] * ( pointDiffuseWeight * attenuation );","if ( passID == 1 ) {","float pointSpecularWeight = KS_Skin_Specular( normal, pointVector, viewerDirection, uRoughness, uSpecularBrightness );","totalSpecularLight += pointLightColor[ i ] * mSpecular.xyz * ( pointSpecularWeight * attenuation );","}","}","#endif","#if NUM_DIR_LIGHTS > 0","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","if ( passID == 1 ) {","float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );","totalSpecularLight += directionalLights[ i ].color * mSpecular.xyz * dirSpecularWeight;","}","}","#endif","outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalSpecularLight );","if ( passID == 0 ) {","outgoingLight = sqrt( outgoingLight );","} else if ( passID == 1 ) {","#ifdef VERSION1","vec3 nonblurColor = sqrt(outgoingLight );","#else","vec3 nonblurColor = outgoingLight;","#endif","vec3 blur1Color = texture2D( tBlur1, vUv ).xyz;","vec3 blur2Color = texture2D( tBlur2, vUv ).xyz;","vec3 blur3Color = texture2D( tBlur3, vUv ).xyz;","vec3 blur4Color = texture2D( tBlur4, vUv ).xyz;","outgoingLight = vec3( vec3( 0.22, 0.437, 0.635 ) * nonblurColor + ","vec3( 0.101, 0.355, 0.365 ) * blur1Color + ","vec3( 0.119, 0.208, 0.0 ) * blur2Color + ","vec3( 0.114, 0.0, 0.0 ) * blur3Color + ","vec3( 0.444, 0.0, 0.0 ) * blur4Color );","outgoingLight *= sqrt( colDiffuse.xyz );","outgoingLight += ambientLightColor * diffuse * colDiffuse.xyz + totalSpecularLight;","#ifndef VERSION1","outgoingLight = sqrt( outgoingLight );","#endif","}","gl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.fog_fragment,"}"].join("\n"),vertexShader:["#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.fog_pars_vertex,"void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv;","#ifdef VERTEX_TEXTURES","vec3 dv = texture2D( tDisplacement, uv ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;","gl_Position = projectionMatrix * displacedPosition;","#else","gl_Position = projectionMatrix * mvPosition;","#endif",fp.fog_vertex,"}"].join("\n"),vertexShaderUV:["varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,"void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv;","gl_Position = vec4( uv.x * 2.0 - 1.0, uv.y * 2.0 - 1.0, 0.0, 1.0 );","}"].join("\n")},beckmann:{uniforms:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","float PHBeckmann( float ndoth, float m ) {","float alpha = acos( ndoth );","float ta = tan( alpha );","float val = 1.0 / ( m * m * pow( ndoth, 4.0 ) ) * exp( -( ta * ta ) / ( m * m ) );","return val;","}","float KSTextureCompute( vec2 tex ) {","return 0.5 * pow( PHBeckmann( tex.x, tex.y ), 0.1 );","}","void main() {","float x = KSTextureCompute( vUv );","gl_FragColor = vec4( x, x, x, 1.0 );","}"].join("\n")}},Uy={terrain:{uniforms:Mu.merge([mp.fog,mp.lights,{enableDiffuse1:{value:0},enableDiffuse2:{value:0},enableSpecular:{value:0},enableReflection:{value:0},tDiffuse1:{value:null},tDiffuse2:{value:null},tDetail:{value:null},tNormal:{value:null},tSpecular:{value:null},tDisplacement:{value:null},uNormalScale:{value:1},uDisplacementBias:{value:0},uDisplacementScale:{value:1},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},shininess:{value:30},opacity:{value:1},uRepeatBase:{value:new f(1,1)},uRepeatOverlay:{value:new f(1,1)},uOffset:{value:new f(0,0)}}]),fragmentShader:["uniform vec3 diffuse;","uniform vec3 specular;","uniform float shininess;","uniform float opacity;","uniform bool enableDiffuse1;","uniform bool enableDiffuse2;","uniform bool enableSpecular;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","uniform sampler2D tDetail;","uniform sampler2D tNormal;","uniform sampler2D tSpecular;","uniform sampler2D tDisplacement;","uniform float uNormalScale;","uniform vec2 uRepeatOverlay;","uniform vec2 uRepeatBase;","uniform vec2 uOffset;","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.bsdfs,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.fog_pars_fragment,"float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {","if ( decayExponent > 0.0 ) {","return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );","}","return 1.0;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec3 specularTex = vec3( 1.0 );","vec2 uvOverlay = uRepeatOverlay * vUv + uOffset;","vec2 uvBase = uRepeatBase * vUv;","vec3 normalTex = texture2D( tDetail, uvOverlay ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","if( enableDiffuse1 && enableDiffuse2 ) {","vec4 colDiffuse1 = texture2D( tDiffuse1, uvOverlay );","vec4 colDiffuse2 = texture2D( tDiffuse2, uvOverlay );","colDiffuse1 = GammaToLinear( colDiffuse1, float( GAMMA_FACTOR ) );","colDiffuse2 = GammaToLinear( colDiffuse2, float( GAMMA_FACTOR ) );","diffuseColor *= mix ( colDiffuse1, colDiffuse2, 1.0 - texture2D( tDisplacement, uvBase ) );"," } else if( enableDiffuse1 ) {","diffuseColor *= texture2D( tDiffuse1, uvOverlay );","} else if( enableDiffuse2 ) {","diffuseColor *= texture2D( tDiffuse2, uvOverlay );","}","if( enableSpecular )","specularTex = texture2D( tSpecular, uvOverlay ).xyz;","mat3 tsb = mat3( vTangent, vBinormal, vNormal );","vec3 finalNormal = tsb * normalTex;","vec3 normal = normalize( finalNormal );","vec3 viewPosition = normalize( vViewPosition );","vec3 totalDiffuseLight = vec3( 0.0 );","vec3 totalSpecularLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 lVector = pointLights[ i ].position + vViewPosition.xyz;","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","lVector = normalize( lVector );","vec3 pointHalfVector = normalize( lVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );","float pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );","totalDiffuseLight += attenuation * pointLights[ i ].color * pointDiffuseWeight;","totalSpecularLight += attenuation * pointLights[ i ].color * specular * pointSpecularWeight * pointDiffuseWeight;","}","#endif","#if NUM_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","float dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","totalSpecularLight += directionalLights[ i ].color * specular * dirSpecularWeight * dirDiffuseWeight;","}","#endif","#if NUM_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","vec3 lVector = hemisphereLightDirection[ i ];","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","totalDiffuseLight += mix( hemisphereLights[ i ].groundColor, hemisphereLights[ i ].skyColor, hemiDiffuseWeight );","float hemiSpecularWeight = 0.0;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","hemiSpecularWeight += specularTex.r * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","hemiSpecularWeight += specularTex.r * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );","totalSpecularLight += specular * mix( hemisphereLights[ i ].groundColor, hemisphereLights[ i ].skyColor, hemiDiffuseWeight ) * hemiSpecularWeight * hemiDiffuseWeight;","}","#endif","outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor + totalSpecularLight );","gl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;","uniform vec2 uRepeatBase;","uniform sampler2D tNormal;","#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.shadowmap_pars_vertex,fp.fog_pars_vertex,"void main() {","vNormal = normalize( normalMatrix * normal );","vTangent = normalize( normalMatrix * tangent.xyz );","vBinormal = cross( vNormal, vTangent ) * tangent.w;","vBinormal = normalize( vBinormal );","vUv = uv;","vec2 uvBase = uv * uRepeatBase;","#ifdef VERTEX_TEXTURES","vec3 dv = texture2D( tDisplacement, uvBase ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","vec3 displacedPosition = normal * df + position;","vec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );","#else","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","#endif","gl_Position = projectionMatrix * mvPosition;","vViewPosition = -mvPosition.xyz;","vec3 normalTex = texture2D( tNormal, uvBase ).xyz * 2.0 - 1.0;","vNormal = normalMatrix * normalTex;",fp.shadowmap_vertex,fp.fog_vertex,"}"].join("\n")}},ky={toon1:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)}},vertexShader:["varying vec3 vNormal;","varying vec3 vRefract;","void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","vNormal = normalize( normalMatrix * normal );","vec3 I = worldPosition.xyz - cameraPosition;","vRefract = refract( normalize( I ), worldNormal, 1.02 );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","varying vec3 vRefract;","void main() {","float directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","float intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );","intensity += length(lightWeighting) * 0.2;","float cameraWeighting = dot( normalize( vNormal ), vRefract );","intensity += pow( 1.0 - length( cameraWeighting ), 6.0 );","intensity = intensity * 0.2 + 0.3;","if ( intensity < 0.50 ) {","gl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );","} else {","gl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );","}","}"].join("\n")},toon2:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(15658734)},uLineColor1:{value:new u(8421504)},uLineColor2:{value:new u(0)},uLineColor3:{value:new u(0)},uLineColor4:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);","float light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {","gl_FragColor *= vec4( uLineColor1, 1.0 );","}","if ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {","gl_FragColor *= vec4( uLineColor2, 1.0 );","}","}"].join("\n")},hatching:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)},uLineColor1:{value:new u(0)},uLineColor2:{value:new u(0)},uLineColor3:{value:new u(0)},uLineColor4:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","if ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","if ( length(lightWeighting) < 0.75 ) {","if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor2, 1.0 );","}","}","if ( length(lightWeighting) < 0.50 ) {","if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor3, 1.0 );","}","}","if ( length(lightWeighting) < 0.3465 ) {","if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor4, 1.0 );","}","}","}"].join("\n")},dotted:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)},uLineColor1:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","if ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","if ( length(lightWeighting) < 0.50 ) {","if ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","}"].join("\n")}},By=function(){this.uniforms=Mu.merge([mp.common,mp.lights,{color:{value:new u(16777215)},diffuse:{value:new u(16777215)},specular:{value:new u(16777215)},emissive:{value:new u(0)},opacity:{value:1},shininess:{value:1},thicknessMap:{value:null},thicknessColor:{value:new u(16777215)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),this.fragmentShader=["#define USE_MAP","#define PHONG","#define TRANSLUCENT","#include ","#include ","#include ","#include ","#include ","varying vec3 vColor;","uniform vec3 diffuse;","uniform vec3 specular;","uniform vec3 emissive;","uniform float opacity;","uniform float shininess;","uniform sampler2D thicknessMap;","uniform float thicknessPower;","uniform float thicknessScale;","uniform float thicknessDistortion;","uniform float thicknessAmbient;","uniform float thicknessAttenuation;","uniform vec3 thicknessColor;",fp.lights_pars_begin,"void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {","\tvec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;","\tvec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));","\tfloat scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;","\tvec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;","\treflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;","}","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 viewerDirection = normalize( vViewPosition );","\tvec4 diffuseColor = vec4( diffuse, opacity );","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",fp.map_fragment,fp.color_fragment,fp.specularmap_fragment,"\tvec3 totalEmissiveRadiance = emissive;",fp.lights_phong_fragment,"\tGeometricContext geometry;","\tgeometry.position = - vViewPosition;","\tgeometry.normal = normal;","\tgeometry.viewDir = normalize( vViewPosition );","\tIncidentLight directLight;","\t#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )","\t\tPointLight pointLight;","\t\t#pragma unroll_loop","\t\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","\t\t \tpointLight = pointLights[ i ];","\t\t \tgetPointDirectLightIrradiance( pointLight, geometry, directLight );","\t\t\t#ifdef USE_SHADOWMAP","\t\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;","\t\t\t#endif","\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );","\t\t\t#if defined( TRANSLUCENT ) && defined( USE_MAP )","\t\t\tRE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","\t\t\t#endif","\t\t}","\t\t#endif","\t#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )","\t\tDirectionalLight directionalLight;","\t\t#pragma unroll_loop","\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {","\t\t\tdirectionalLight = directionalLights[ i ];","\t\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );","\t\t\t#ifdef USE_SHADOWMAP","\t\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;","\t\t\t#endif","\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );","\t\t\t#if defined( TRANSLUCENT ) && defined( USE_MAP )","\t\t\tRE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","\t\t\t#endif","\t\t}","\t#endif","\t#if defined( RE_IndirectDiffuse )","\t\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );","\t\t#if ( NUM_HEMI_LIGHTS > 0 )","\t\t\t#pragma unroll_loop","\t\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","\t\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );","\t\t\t}","\t\t#endif","\t#endif","\t#if defined( RE_IndirectSpecular )","\t\tvec3 radiance = vec3( 0.0 );","\t\tvec3 clearCoatRadiance = vec3( 0.0 );","\t#endif",fp.lights_fragment_end,"\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;","\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.encodings_fragment,"}"].join("\n"),this.vertexShader=["varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,"void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvViewPosition = -mvPosition.xyz;","\tvNormal = normalize( normalMatrix * normal );","\tvUv = uv;","\tgl_Position = projectionMatrix * mvPosition;","}"].join("\n")},zy=function(e){var t=this;void 0==e&&(e=Math),this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(var r=0;r<256;r++)t.p[r]=Math.floor(256*e.random());this.perm=[];for(var r=0;r<512;r++)t.perm[r]=t.p[255&r];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]};zy.prototype.dot=function(e,t,r){return e[0]*t+e[1]*r},zy.prototype.dot3=function(e,t,r,i){return e[0]*t+e[1]*r+e[2]*i},zy.prototype.dot4=function(e,t,r,i,n){return e[0]*t+e[1]*r+e[2]*i+e[3]*n},zy.prototype.noise=function(e,t){var r,i,n,a,o,s=.5*(Math.sqrt(3)-1),l=(e+t)*s,c=Math.floor(e+l),u=Math.floor(t+l),h=(3-Math.sqrt(3))/6,d=(c+u)*h,p=c-d,f=u-d,m=e-p,v=t-f;m>v?(a=1,o=0):(a=0,o=1);var g=m-a+h,y=v-o+h,x=m-1+2*h,b=v-1+2*h,w=255&c,_=255&u,S=this.perm[w+this.perm[_]]%12,A=this.perm[w+a+this.perm[_+o]]%12,M=this.perm[w+1+this.perm[_+1]]%12,T=.5-m*m-v*v;T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[S],m,v));var E=.5-g*g-y*y;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[A],g,y));var C=.5-x*x-b*b;return C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[M],x,b)),70*(r+i+n)},zy.prototype.noise3d=function(e,t,r){var i,n,a,o,s,l,c,u,h,d,p=1/3,f=(e+t+r)*p,m=Math.floor(e+f),v=Math.floor(t+f),g=Math.floor(r+f),y=1/6,x=(m+v+g)*y,b=m-x,w=v-x,_=g-x,S=e-b,A=t-w,M=r-_;S>=A?A>=M?(s=1,l=0,c=0,u=1,h=1,d=0):S>=M?(s=1,l=0,c=0,u=1,h=0,d=1):(s=0,l=0,c=1,u=1,h=0,d=1):AU?32:0,j=R>k?16:0,V=U>k?8:0,G=R>B?4:0,W=U>B?2:0,X=k>B?1:0,H=z+j+V+G+W+X;c=_[H][0]>=3?1:0,u=_[H][1]>=3?1:0,h=_[H][2]>=3?1:0,d=_[H][3]>=3?1:0,p=_[H][0]>=2?1:0,f=_[H][1]>=2?1:0,m=_[H][2]>=2?1:0,v=_[H][3]>=2?1:0,g=_[H][0]>=1?1:0,y=_[H][1]>=1?1:0,x=_[H][2]>=1?1:0,b=_[H][3]>=1?1:0;var Y=R-c+M,q=U-u+M,Q=k-h+M,J=B-d+M,Z=R-p+2*M,K=U-f+2*M,$=k-m+2*M,ee=B-v+2*M,te=R-g+3*M,re=U-y+3*M,ie=k-x+3*M,ne=B-b+3*M,ae=R-1+4*M,oe=U-1+4*M,se=k-1+4*M,le=B-1+4*M,ce=255&E,ue=255&C,he=255&L,de=255&P,pe=S[ce+S[ue+S[he+S[de]]]]%32,fe=S[ce+c+S[ue+u+S[he+h+S[de+d]]]]%32,me=S[ce+p+S[ue+f+S[he+m+S[de+v]]]]%32,ve=S[ce+g+S[ue+y+S[he+x+S[de+b]]]]%32,ge=S[ce+1+S[ue+1+S[he+1+S[de+1]]]]%32,ye=.6-R*R-U*U-k*k-B*B;ye<0?n=0:(ye*=ye,n=ye*ye*this.dot4(w[pe],R,U,k,B));var xe=.6-Y*Y-q*q-Q*Q-J*J;xe<0?a=0:(xe*=xe,a=xe*xe*this.dot4(w[fe],Y,q,Q,J));var be=.6-Z*Z-K*K-$*$-ee*ee;be<0?o=0:(be*=be,o=be*be*this.dot4(w[me],Z,K,$,ee));var we=.6-te*te-re*re-ie*ie-ne*ne;we<0?s=0:(we*=we,s=we*we*this.dot4(w[ve],te,re,ie,ne));var _e=.6-ae*ae-oe*oe-se*se-le*le;return _e<0?l=0:(_e*=_e,l=_e*_e*this.dot4(w[ge],ae,oe,se,le)),27*(n+a+o+s+l)};var jy=function(e,t,r){this._scene=e,this._trackInfo=t,this._onUpdate=r,this._mixer=new ae(e),this._clip=null,this._action=null,this._tracks={},this._propRefs={},this._channelNames=[]};jy.prototype={constructor:jy,init:function(e){for(var t=this,r=[],i=this._trackInfo,n=0,a=i.length;n!==a;++n){var o=i[n];r.push(t._addTrack(o.type,o.propertyPath,o.initialValue,o.interpolation))}this._clip=new re("editclip",0,r),this._action=this._mixer.clipAction(this._clip).play()},setDisplayTime:function(e){this._action.time=e,this._mixer.update(0),this._onUpdate()},setDuration:function(e){this._clip.duration=e},getChannelNames:function(){return this._channelNames},getChannelKeyTimes:function(e){return this._tracks[e].times},setKeyframe:function(e,t){var r=this._tracks[e],i=r.times,n=Timeliner.binarySearch(i,t),a=r.values,o=r.getValueSize(),s=n*o;if(n<0){n=~n,s=n*o;for(var l=i.length+1,c=a.length+o,u=l-1;u!==n;--u)i[u]=i[u-1];for(var u=c-1,h=s+o-1;u!==h;--u)a[u]=a[u-o]}i[n]=t,this._propRefs[e].getValue(a,s)},delKeyframe:function(e,t){var r=this._tracks[e],i=r.times,n=Timeliner.binarySearch(i,t);if(i.length>1&&n>=0){for(var a=i.length-1,o=r.values,s=r.getValueSize(),l=o.length-s,c=n;c!==a;++c)i[c]=i[c+1];i.pop();for(var u=n*s;u!==l;++u)o[u]=o[u+s];o.length=l}},moveKeyframe:function(e,t,r,i){var n=this._tracks[e],a=n.times,o=Timeliner.binarySearch(a,t);if(o>=0){for(var s=i?a.length:o+1,l=a[o-1]<=t||!i&&t>=a[o+1];o!==s;)a[o++]+=r;l&&this._sort(n)}},serialize:function(){for(var e={duration:this._clip.duration,channels:{}},t=this._channelNames,r=this._tracks,i=e.channels,n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o];i[o]={times:s.times,values:s.values}}return e},deserialize:function(e){var t=this,r=this._channelNames,i=this._tracks,n=e.channels;this.setDuration(e.duration);for(var a=0,o=r.length;a!==o;++a){var s=r[a],l=i[s],c=n[s];t._setArray(l.times,c.times),t._setArray(l.values,c.values)}this.setDisplayTime(this._mixer.time)},_sort:function(e){var t=e.times,r=wu.getKeyframeOrder(t);this._setArray(t,wu.sortedArray(t,1,r));var i=e.values,n=e.getValueSize();this._setArray(i,wu.sortedArray(i,n,r))},_setArray:function(e,t){e.length=0,e.push.apply(e,t)},_addTrack:function(e,t,r,i){var n=new e(t,[0],r,i);return n.times=Array.prototype.slice.call(n.times),n.values=Array.prototype.slice.call(n.values),this._channelNames.push(t),this._tracks[t]=n,this._propRefs[t]=new W(this._scene,t),n}};var Vy={};Vy.quicksortIP=function(e,t,r){for(var i,n,a=[],o=-1,s=0,l=e.length/t-1,c=0,u=0,h=0,d=function(r,i){for(r*=t,i*=t,h=0;h=s&&e[i*t+r]>p[r];){for(u=0;u>1;for(i=s+1,n=l,d(m,i),e[s*t+r]>e[l*t+r]&&d(s,l),e[i*t+r]>e[l*t+r]&&d(i,l),e[s*t+r]>e[i*t+r]&&d(s,i),u=0;uf[r]);if(n=n-s?(a[++o]=i,a[++o]=l,l=n-1):(a[++o]=s,a[++o]=n-1,s=i)}return e}, -Vy.Kdtree=function(e,t,r){function i(e,t,s,l){var c,u,h=t%r,d=e.length/r;return t>a&&(a=t),0===d?null:1===d?new n.Node(o(e,0),t,s,l):(Vy.quicksortIP(e,r,h),c=Math.floor(d/2),u=new n.Node(o(e,c),t,s,c+l),u.left=i(e.subarray(0,c*r),t+1,u,l),u.right=i(e.subarray((c+1)*r,e.length),t+1,u,l+c+1),u)}var n=this,a=0,o=function(e,t){return e.subarray(t*r,t*r+r)};this.root=i(e,0,null,0),this.getMaxDepth=function(){return a},this.nearest=function(e,i,a){function o(n){function a(e,t){c.push([e,t]),c.size()>i&&c.pop()}var s,l,u,h=n.depth%r,d=t(e,n.obj),p=0,f=[];for(u=0;u0&&(this.content[0]=t,this.sinkDown(0)),e},peek:function(){return this.content[0]},remove:function(e){for(var t=this,r=this.content.length,i=0;i0;){var i=Math.floor((e+1)/2)-1,n=t.content[i];if(!(t.scoreFunction(r)1&&(o=1-o,s=1-s);var l=1-o-s;return a.copy(t),a.multiplyScalar(o),e.copy(r),e.multiplyScalar(s),a.add(e),e.copy(n),e.multiplyScalar(l),a.add(e),a}}(),randomPointInFace:function(e,t){var r,i,n;return r=t.vertices[e.a],i=t.vertices[e.b],n=t.vertices[e.c],Wy.randomPointInTriangle(r,i,n)},randomPointsInGeometry:function(e,t){function r(e){function t(r,i){if(ie?t(r,n-1):d[n]e?t(r,n-1):u[n].95&&h.fillText(r,n.x%1*c,(1-n.y)*u),h.font="8pt Arial bold",h.fillStyle="rgba( 0, 0, 0, 1.0 )",o=0,s=t.length;o.95&&h.fillText(i[o]+d,a.x%1*c,(1-a.y)*u)}}var i="abc",n=new f,a=new f,o=[new f,new f,new f],s=[],l=document.createElement("canvas"),c=t||1024,u=t||1024;l.width=c,l.height=u;var h=l.getContext("2d");if(h.lineWidth=2,h.strokeStyle="rgba( 0, 0, 0, 1.0 )",h.textAlign="center",h.fillStyle="rgba( 255, 255, 255, 1.0 )",h.fillRect(0,0,c,u),e.isGeometry)for(var d=e.faces,p=e.faceVertexUvs[0],m=0,v=p.length;m=e.colorMap.length?g%e.colorMap.length+1:g;var y=e.colorMap[g];l[4*f]=y>>24&255,l[4*f+1]=y>>16&255,l[4*f+2]=y>>8&255,l[4*f+3]=255&y,f++}else for(var m=0;m=x&&h<=x?b:0,x=Math.floor(255*(x-d)/(p-d)),x=x>255?255:x<0?0:0|x,l[4*f]=x,l[4*f+1]=x,l[4*f+2]=x,l[4*f+3]=b,f++}o.putImageData(s,0,0),this.ctx.drawImage(a,0,0,t,r,0,0,this.canvas.width,this.canvas.height),this.mesh.material.map.needsUpdate=!0},updateGeometry:function(){var e=this.volume.extractPerpendicularPlane(this.axis,this.index);this.sliceAccess=e.sliceAccess,this.jLength=e.jLength,this.iLength=e.iLength,this.matrix=e.matrix,this.canvas.width=e.planeWidth,this.canvas.height=e.planeHeight,this.canvasBuffer.width=this.iLength,this.canvasBuffer.height=this.jLength,this.ctx=this.canvas.getContext("2d"),this.ctxBuffer=this.canvasBuffer.getContext("2d"),this.geometry=new xe(e.planeWidth,e.planeHeight),this.mesh&&(this.mesh.geometry=this.geometry,this.mesh.matrix=(new r).identity(),this.mesh.applyMatrix(this.matrix)),this.geometryNeedsUpdate=!1}};var Zy=function(){function e(){for(var e=navigator.getGamepads&&navigator.getGamepads(),t=0;t<4;t++){var r=e[t];if(r&&"Daydream Controller"===r.id)return r}}c.call(this);var t,r=this,n=[0,0],a=!1,o=new i;this.matrixAutoUpdate=!1,this.getGamepad=function(){return t},this.getTouchpadState=function(){return a},this.update=function(){if(t=e(),void 0!==t&&void 0!==t.pose){var i=t.pose;if(null===i)return;null!==i.orientation&&r.quaternion.fromArray(i.orientation),r.updateMatrix(),r.visible=!0,null===i.angularVelocity||o.equals(i.angularVelocity)||(o.fromArray(i.angularVelocity),r.dispatchEvent({type:"angularvelocitychanged",angularVelocity:o})),n[0]===t.axes[0]&&n[1]===t.axes[1]||(n[0]=t.axes[0],n[1]=t.axes[1],r.dispatchEvent({type:"axischanged",axes:n})),a!==t.buttons[0].pressed&&(a=t.buttons[0].pressed,r.dispatchEvent({type:a?"touchpaddown":"touchpadup"}))}else r.visible=!1},this.getTouchPadState=function(){return console.warn("DaydreamController: getTouchPadState() is now getTouchpadState()"),a}};Zy.prototype=Object.create(c.prototype),Zy.prototype.constructor=Zy;var Ky=function(){function e(){for(var e=navigator.getGamepads&&navigator.getGamepads(),t=0;t<4;t++){var r=e[t];if(r&&("Gear VR Controller"===r.id||"Oculus Go Controller"===r.id))return r}}c.call(this);var t,r=this,n=[0,0],a=!1,o=!1,s=new i;this.matrixAutoUpdate=!0,this.getGamepad=function(){return t},this.getTouchpadState=function(){return a},this.update=function(){if(t=e(),void 0!==t&&void 0!==t.pose){var i=t.pose;if(null===i)return;null!==i.orientation&&r.quaternion.fromArray(i.orientation),r.updateMatrix(),r.visible=!0,null===i.angularVelocity||s.equals(i.angularVelocity)||(s.fromArray(i.angularVelocity),r.dispatchEvent({type:"angularvelocitychanged",angularVelocity:s})),n[0]===t.axes[0]&&n[1]===t.axes[1]||(n[0]=t.axes[0],n[1]=t.axes[1],r.dispatchEvent({type:"axischanged",axes:n})),a!==t.buttons[0].pressed&&(a=t.buttons[0].pressed,r.dispatchEvent({type:a?"touchpaddown":"touchpadup",axes:n})),o!==t.buttons[1].pressed&&(o=t.buttons[1].pressed,r.dispatchEvent({type:o?"triggerdown":"triggerup"}))}else r.visible=!1},this.getTouchPadState=function(){return console.warn("GearVRController: getTouchPadState() is now getTouchpadState()"),a},this.setHand=function(){console.warn("GearVRController: setHand() has been removed.")}};Ky.prototype=Object.create(c.prototype),Ky.prototype.constructor=Ky;var $y=function(e){function t(e){for(var t=navigator.getGamepads&&navigator.getGamepads(),r=0,i=0;r0?r(e[0]):n()})["catch"](n),o}var s=document.createElement("a");return s.href="https://webvr.info",s.innerHTML="WEBVR NOT SUPPORTED",s.style.left="calc(50% - 90px)",s.style.width="180px",s.style.textDecoration="none",a(s),s},checkAvailability:function(){return console.warn("WEBVR.checkAvailability has been deprecated."),new Promise(function(){})},getMessageContainer:function(){return console.warn("WEBVR.getMessageContainer has been deprecated."),document.createElement("div")},getButton:function(){return console.warn("WEBVR.getButton has been deprecated."),document.createElement("div")},getVRDisplay:function(){console.warn("WEBVR.getVRDisplay has been deprecated.")}};Object.assign(Eo.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=arguments,t=this._objects,r=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,a=this._paths,o=this._parsedPaths,s=this._bindings,l=s.length,c=void 0,u=0,h=arguments.length;u!==h;++u){var d=e[u],p=d.uuid,f=n[p];if(void 0===f){f=r++,n[p]=f,t.push(d);for(var m=0,v=l;m!==v;++m)s[m].push(new W(d,a[m],o[m]))}else if(f=r){var h=r++,d=t[h];i[d.uuid]=u,t[u]=d,i[c]=h,t[h]=l;for(var p=0,f=a;p!==f;++p){var m=n[p],v=m[h],g=m[u];m[u]=v,m[h]=g}}}this.nCachedObjects_=r},uncache:function(){for(var e=arguments,t=this._objects,r=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,a=this._bindings,o=a.length,s=0,l=arguments.length;s!==l;++s){var c=e[s],u=c.uuid,h=n[u];if(void 0!==h)if(delete n[u],h0){this.source.connect(this.filters[0]);for(var t=1,r=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,r=this.filters.length;t.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(r.z,0,-r.x).normalize(),e=Math.acos(r.y),this.quaternion.setFromAxisAngle(t,e))}}(),as.prototype.setLength=function(e,t,r){void 0===t&&(t=.2*e),void 0===r&&(r=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()},as.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},os.prototype=Object.create(Yt.prototype),os.prototype.constructor=os,ss.prototype=Object.create(Yt.prototype),ss.prototype.constructor=ss,ss.prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),c.prototype.updateMatrixWorld.call(this,e))},ls.prototype=Object.create(Yt.prototype),ls.prototype.constructor=ls,ls.prototype.update=function(){function e(e,i,o,s){n.set(i,o,s).unproject(a);var l=r[e];if(void 0!==l)for(var c=t.getAttribute("position"),u=0,h=l.length;u1){e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;a0){var a=new be(t),o=new Re(a);o.setCrossOrigin(this.crossOrigin);for(var s=0,l=e.length;s0?new It(s,l):new k(s,l);break;case"LOD":a=new Ts;break;case"Line":a=new B(i(e.geometry),n(e.material),e.mode);break;case"LineLoop":a=new Jt(i(e.geometry),n(e.material));break;case"LineSegments":a=new Yt(i(e.geometry),n(e.material));break;case"PointCloud":case"Points":a=new Et(i(e.geometry),n(e.material));break;case"Sprite":a=new vi(n(e.material));break;case"Group":a=new Dt;break;default:a=new c}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.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),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 h=e.children,d=0;d=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),e.CCDIKSolver=xu,e.MMDAnimationHelper=Su,e.MMDPhysics=_u,e.AnimationClipCreator=Au,e.CinematicCamera=Nu,e.Car=Uu,e.DeviceOrientationControls=ku,e.DragControls=Bu,e.EditorControls=zu,e.FirstPersonControls=ju,e.FlyControls=Vu,e.MapControls=Gu,e.OrbitControls=Wu,e.OrthographicTrackballControls=Xu,e.PointerLockControls=Hu,e.TrackballControls=Yu,e.TransformControls=qu,e.TransformControlsGizmo=Qu,e.TransformControlsPlane=Ju,e.ConvexObjectBreaker=$u,e.GrannyKnot=ot,e.HeartCurve=st,e.VivianiCurve=lt,e.KnotCurve=ct,e.HelixCurve=ut,e.TrefoilKnot=ht,e.TorusKnot=dt,e.CinquefoilKnot=pt,e.TrefoilPolynomialKnot=ft,e.FigureEightPolynomialKnot=mt,e.DecoratedTorusKnot4a=vt,e.DecoratedTorusKnot4b=gt,e.DecoratedTorusKnot5a=yt,e.DecoratedTorusKnot5c=xt,e.NURBSCurve=rh,e.NURBSSurface=ih,e.NURBSUtils=th,e.Detector=nh,e.AnaglyphEffect=ah,e.AsciiEffect=oh,e.OutlineEffect=gp,e.ParallaxBarrierEffect=yp,e.PeppersGhostEffect=xp,e.StereoEffect=bp,e.ColladaExporter=wp,e.GLTFExporter=Mp,e.MMDExporter=Tp,e.OBJExporter=Ep,e.PLYExporter=Cp,e.STLExporter=Lp,e.TypedGeometryExporter=Pp,e.ConvexGeometry=it,e.ConvexBufferGeometry=nt,e.DecalGeometry=wt,e.hilbert2D=St,e.hilbert3D=At,e.TeapotBufferGeometry=Np,e.GPUComputationRenderer=Tt,e.GPUParticleSystem=Op,e.GPUParticleContainer=Dp,e.Gyroscope=Fp,e.ImprovedNoise=Ip,e.Line2=zp,e.LineGeometry=Bp,e.LineMaterial=Up,e.LineSegments2=kp,e.LineSegmentsGeometry=Rp,e.Wireframe=jp,e.WireframeGeometry2=Vp,e.ThreeMFLoader=Gp,e.AMFLoader=Wp,e.AssimpJSONLoader=Xp,e.AssimpLoader=Hp,e.AWDLoader=yf,e.BabylonLoader=xf,e.BinaryLoader=Ru,e.BVHLoader=bf,e.ColladaLoader=_f,e.DDSLoader=Sf,e.LegacyGLTFLoader=Af,e.DRACOLoader=Mf,e.EquirectangularToCubeGenerator=Tf,e.EXRLoader=Ef,e.FBXLoader=Cf,e.GCodeLoader=Lf,e.GLTFLoader=Nf,e.HDRCubeTextureLoader=Ff,e.KMZLoader=If,e.KTXLoader=Rf,e.LoaderSupport=kf,e.MD2Loader=Bf,e.MMDLoader=zf,e.MTLLoader=jf,e.NodeMaterialLoader=Yf,e.OBJLoader=qf,e.OBJLoader2=Qf,e.PCDLoader=Jf,e.PDBLoader=Zf,e.PlayCanvasLoader=Kf,e.PLYLoader=$f,e.PRWMLoader=im,e.PVRLoader=nm,e.HDRLoader=Df,e.RGBELoader=Of,e.STLLoader=am,e.SVGLoader=pm,e.TDSLoader=fm,e.TGALoader=wf,e.TTFLoader=Km,e.VRMLLoader=$m,e.VRMLoader=ev,e.VTKLoader=tv,e.MarchingCubes=rv,e.ColorConverter=av,e.Lut=sv,e.MD2Character=cv,e.MD2CharacterComplex=hv,e.ExplodeModifier=dv,e.SimplifyModifier=pv,e.SubdivisionModifier=fv,e.TessellateModifier=mv,e.MorphAnimMesh=vv,e.MorphBlendMesh=uv,e.CameraNode=cr,e.ColorsNode=gi,e.LightNode=yi,e.NormalNode=nr,e.PositionNode=ir,e.ReflectNode=xi,e.ResolutionNode=Ri,e.ScreenUVNode=Ui,e.UVNode=rr,e.BlinnExponentToRoughnessNode=Ci,e.BlinnShininessExponentNode=Ei,e.RoughnessToBlinnExponentNode=Bi,e.AttributeNode=zi,e.ConstNode=lr,e.ExpressionNode=ji,e.FunctionCallNode=Vi,e.FunctionNode=Vf,e.InputNode=ar,e.Node=er,e.NodeBuilder=Ni,e.NodeFrame=Gi,e.NodeLib=Gf,e.NodeUniform=bi,e.NodeUtils=xv,e.StructNode=wi,e.TempNode=tr,e.VarNode=Wi,e.BlurNode=Xi,e.ColorAdjustmentNode=Yi,e.LuminanceNode=Hi,e.ColorNode=Oi,e.CubeTextureNode=Ti,e.FloatNode=or,e.IntNode=qi,e.Matrix3Node=Qi,e.Matrix4Node=Ji,e.PropertyNode=Zi,e.ReflectorNode=$i,e.RTTNode=en,e.ScreenNode=tn,e.TextureNode=Mi,e.Vector2Node=Ii,e.Vector3Node=_i,e.Vector4Node=Si,e.MeshStandardNodeMaterial=sn,e.NodeMaterial=Fi,e.MeshStandardNode=on,e.PhongNode=ln,e.RawNode=Di,e.SpriteNode=cn,e.StandardNode=rn,e.PhongNodeMaterial=un,e.SpriteNodeMaterial=hn,e.StandardNodeMaterial=dn,e.CondNode=pn,e.Math1Node=fn,e.Math2Node=mn,e.Math3Node=vn,e.OperatorNode=Ki,e.BumpMapNode=gn,e.NormalMapNode=an,e.TextureCubeNode=Pi,e.TextureCubeUVNode=Li,e.NodePass=yn,e.NodePostProcessing=xn, -e.CheckerNode=bn,e.NoiseNode=wn,e.BypassNode=_n,e.ColorSpaceNode=Ai,e.JoinNode=Sn,e.MaxMIPLevelNode=ki,e.SwitchNode=nn,e.TimerNode=sr,e.UVTransformNode=An,e.VelocityNode=Mn,e.Lensflare=Lv,e.LensflareElement=Pv,e.Reflector=Nv,e.ReflectorRTT=Ov,e.Refractor=Dv,e.ShadowMesh=Fv,e.Sky=Iv,e.Water=Rv,e.Water2=Cn,e.Ocean=Uv,e.Octree=kv,e.OctreeObjectData=Bv,e.OctreeNode=zv,e.PMREMCubeUVPacker=jv,e.PMREMGenerator=Vv,e.AdaptiveToneMappingPass=Hv,e.AfterimagePass=qv,e.BloomPass=Jv,e.BokehPass=Zv,e.ClearPass=Kv,e.CubeTexturePass=$v,e.DotScreenPass=tg,e.EffectComposer=ng,e.FilmPass=og,e.GlitchPass=lg,e.HalftonePass=ug,e.MaskPass=rg,e.ClearMaskPass=ig,e.OutlinePass=hg,e.Pass=Tv,e.RenderPass=dg,e.SAOPass=gg,e.SavePass=yg,e.ShaderPass=Ev,e.SMAAPass=bg,e.SSAARenderPass=wg,e.SSAOPass=Sg,e.TAARenderPass=Ag,e.TexturePass=Mg,e.UnrealBloomPass=Eg,e.PRNG=Cg,e.QuickHull=Ke,e.SpriteCanvasMaterial=Ig,e.CanvasRenderer=Rg,e.CSS2DObject=Ug,e.CSS2DRenderer=kg,e.CSS3DObject=Bg,e.CSS3DSprite=zg,e.CSS3DRenderer=jg,e.RenderableObject=Lg,e.RenderableFace=Pg,e.RenderableVertex=Ng,e.RenderableLine=Og,e.RenderableSprite=Dg,e.Projector=Fg,e.RaytracingRenderer=Vg,e.SoftwareRenderer=Gg,e.SVGObject=Wg,e.SVGRenderer=Xg,e.WebGLDeferredRenderer=iy,e.RollerCoasterGeometry=po,e.RollerCoasterLiftersGeometry=fo,e.RollerCoasterShadowGeometry=mo,e.SkyGeometry=vo,e.TreesGeometry=go,e.ShaderGodRays=sy,e.AfterimageShader=Yv,e.BasicShader=ly,e.BleachBypassShader=cy,e.BlendShader=uy,e.BokehShader=Cu,e.BokehShader2=Lu,e.BokehDepthShader=Pu,e.BrightnessContrastShader=hy,e.ColorCorrectionShader=dy,e.ColorifyShader=py,e.ConvolutionShader=Qv,e.CopyShader=Gv,e.DepthLimitedBlurShader=fg,e.BlurShaderUtils=mg,e.DigitalGlitch=sg,e.DOFMipMapShader=fy,e.DotScreenShader=eg,e.FilmShader=ag,e.FocusShader=my,e.FreiChenShader=vy,e.FresnelShader=gy,e.FXAAShader=ry,e.GammaCorrectionShader=yy,e.HalftoneShader=cg,e.HorizontalBlurShader=xy,e.HorizontalTiltShiftShader=by,e.HueSaturationShader=wy,e.KaleidoShader=_y,e.LuminosityHighPassShader=Tg,e.LuminosityShader=Wv,e.MirrorShader=Sy,e.NormalMapShader=Ay,e.ParallaxShader=My,e.PixelShader=Ty,e.RGBShiftShader=Ey,e.SAOShader=pg,e.SepiaShader=Cy,e.SMAAShader=xg,e.SobelOperatorShader=Ly,e.SSAOShader=_g,e.TechnicolorShader=Py,e.ToneMapShader=Xv,e.TriangleBlurShader=Ny,e.UnpackDepthRGBAShader=vg,e.VerticalBlurShader=Oy,e.VerticalTiltShiftShader=Dy,e.VignetteShader=Fy,e.WaterRefractionShader=Iy,e.ShaderSkin=Ry,e.ShaderTerrain=Uy,e.ShaderToon=ky,e.TranslucentShader=By,e.SimplexNoise=zy,e.TimelinerController=jy,e.TypedArrayUtils=Vy,e.UCSCharacter=Gy,e.BufferGeometryUtils=Pf,e.GeometryUtils=Wy,e.MathUtils=Xy,e.SceneUtils=Hy,e.ShadowMapViewer=Yy,e.SkeletonUtils=qy,e.UVsDebug=Qy,e.VolumeSlice=Jy,e.DaydreamController=Zy,e.GearVRController=Ky,e.PaintViveController=ex,e.ViveController=$y,e.WebVR=tx,e.AnimationAction=z,e.AnimationClip=re,e.AnimationMixer=ae,e.AnimationObjectGroup=Eo,e.AnimationUtils=wu,e.KeyframeTrack=q,e.PropertyBinding=W,e.PropertyMixer=X,e.BooleanKeyframeTrack=Q,e.ColorKeyframeTrack=J,e.NumberKeyframeTrack=Z,e.QuaternionKeyframeTrack=$,e.StringKeyframeTrack=ee,e.VectorKeyframeTrack=te,e.Audio=Co,e.AudioAnalyser=Lo,e.AudioContext=ix,e.AudioListener=Po,e.PositionalAudio=No,e.ArrayCamera=so,e.Camera=he,e.CubeCamera=Oo,e.OrthographicCamera=me,e.PerspectiveCamera=de,e.StereoCamera=bt,e.REVISION=Bs,e.MOUSE=zs,e.CullFaceNone=js,e.CullFaceBack=Vs,e.CullFaceFront=Gs,e.CullFaceFrontBack=Ws,e.FrontFaceDirectionCW=Xs,e.FrontFaceDirectionCCW=Hs,e.BasicShadowMap=Ys,e.PCFShadowMap=qs,e.PCFSoftShadowMap=Qs,e.FrontSide=Js,e.BackSide=Zs,e.DoubleSide=Ks,e.FlatShading=$s,e.SmoothShading=el,e.NoColors=tl,e.FaceColors=rl,e.VertexColors=il,e.NoBlending=nl,e.NormalBlending=al,e.AdditiveBlending=ol,e.SubtractiveBlending=sl,e.MultiplyBlending=ll,e.CustomBlending=cl,e.AddEquation=ul,e.SubtractEquation=hl,e.ReverseSubtractEquation=dl,e.MinEquation=pl,e.MaxEquation=fl,e.ZeroFactor=ml,e.OneFactor=vl,e.SrcColorFactor=gl,e.OneMinusSrcColorFactor=yl,e.SrcAlphaFactor=xl,e.OneMinusSrcAlphaFactor=bl,e.DstAlphaFactor=wl,e.OneMinusDstAlphaFactor=_l,e.DstColorFactor=Sl,e.OneMinusDstColorFactor=Al,e.SrcAlphaSaturateFactor=Ml,e.NeverDepth=Tl,e.AlwaysDepth=El,e.LessDepth=Cl,e.LessEqualDepth=Ll,e.EqualDepth=Pl,e.GreaterEqualDepth=Nl,e.GreaterDepth=Ol,e.NotEqualDepth=Dl,e.MultiplyOperation=Fl,e.MixOperation=Il,e.AddOperation=Rl,e.NoToneMapping=Ul,e.LinearToneMapping=kl,e.ReinhardToneMapping=Bl,e.Uncharted2ToneMapping=zl,e.CineonToneMapping=jl,e.UVMapping=Vl,e.CubeReflectionMapping=Gl,e.CubeRefractionMapping=Wl,e.EquirectangularReflectionMapping=Xl,e.EquirectangularRefractionMapping=Hl,e.SphericalReflectionMapping=Yl,e.CubeUVReflectionMapping=ql,e.CubeUVRefractionMapping=Ql,e.RepeatWrapping=Jl,e.ClampToEdgeWrapping=Zl,e.MirroredRepeatWrapping=Kl,e.NearestFilter=$l,e.NearestMipMapNearestFilter=ec,e.NearestMipMapLinearFilter=tc,e.LinearFilter=rc,e.LinearMipMapNearestFilter=ic,e.LinearMipMapLinearFilter=nc,e.UnsignedByteType=ac,e.ByteType=oc,e.ShortType=sc,e.UnsignedShortType=lc,e.IntType=cc,e.UnsignedIntType=uc,e.FloatType=hc,e.HalfFloatType=dc,e.UnsignedShort4444Type=pc,e.UnsignedShort5551Type=fc,e.UnsignedShort565Type=mc,e.UnsignedInt248Type=vc,e.AlphaFormat=gc,e.RGBFormat=yc,e.RGBAFormat=xc,e.LuminanceFormat=bc,e.LuminanceAlphaFormat=wc,e.RGBEFormat=_c,e.DepthFormat=Sc,e.DepthStencilFormat=Ac,e.RGB_S3TC_DXT1_Format=Mc,e.RGBA_S3TC_DXT1_Format=Tc,e.RGBA_S3TC_DXT3_Format=Ec,e.RGBA_S3TC_DXT5_Format=Cc,e.RGB_PVRTC_4BPPV1_Format=Lc,e.RGB_PVRTC_2BPPV1_Format=Pc,e.RGBA_PVRTC_4BPPV1_Format=Nc,e.RGBA_PVRTC_2BPPV1_Format=Oc,e.RGB_ETC1_Format=Dc,e.RGBA_ASTC_4x4_Format=Fc,e.RGBA_ASTC_5x4_Format=Ic,e.RGBA_ASTC_5x5_Format=Rc,e.RGBA_ASTC_6x5_Format=Uc,e.RGBA_ASTC_6x6_Format=kc,e.RGBA_ASTC_8x5_Format=Bc,e.RGBA_ASTC_8x6_Format=zc,e.RGBA_ASTC_8x8_Format=jc,e.RGBA_ASTC_10x5_Format=Vc,e.RGBA_ASTC_10x6_Format=Gc,e.RGBA_ASTC_10x8_Format=Wc,e.RGBA_ASTC_10x10_Format=Xc,e.RGBA_ASTC_12x10_Format=Hc,e.RGBA_ASTC_12x12_Format=Yc,e.LoopOnce=qc,e.LoopRepeat=Qc,e.LoopPingPong=Jc,e.InterpolateDiscrete=Zc,e.InterpolateLinear=Kc,e.InterpolateSmooth=$c,e.ZeroCurvatureEnding=eu,e.ZeroSlopeEnding=tu,e.WrapAroundEnding=ru,e.TrianglesDrawMode=iu,e.TriangleStripDrawMode=nu,e.TriangleFanDrawMode=au,e.LinearEncoding=ou,e.sRGBEncoding=su,e.GammaEncoding=lu,e.RGBEEncoding=cu,e.LogLuvEncoding=uu,e.RGBM7Encoding=hu,e.RGBM16Encoding=du,e.RGBDEncoding=pu,e.BasicDepthPacking=fu,e.RGBADepthPacking=mu,e.TangentSpaceNormalMap=vu,e.ObjectSpaceNormalMap=gu,e.Float64BufferAttribute=T,e.Float32BufferAttribute=M,e.Uint32BufferAttribute=A,e.Int32BufferAttribute=S,e.Uint16BufferAttribute=_,e.Int16BufferAttribute=w,e.Uint8ClampedBufferAttribute=b,e.Uint8BufferAttribute=x,e.Int8BufferAttribute=y,e.BufferAttribute=g,e.BufferGeometry=P,e.Clock=En,e.DirectGeometry=E,e.EventDispatcher=a,e.Face3=h,e.Geometry=m,e.InstancedBufferAttribute=Do,e.InstancedBufferGeometry=Ct,e.InstancedInterleavedBuffer=Pt,e.InterleavedBuffer=Lt,e.InterleavedBufferAttribute=Nt,e.Layers=s,e.Object3D=c,e.Raycaster=je,e.Uniform=ho,e.Curve=at,e.CurvePath=Fr,e.Font=Fo,e.CatmullRom=gr,e.QuadraticBezier=wr,e.CubicBezier=Tr,e.Path=Ir,e.Shape=Rr,e.ShapePath=pi,e.ArcCurve=fr,e.CatmullRomCurve3=vr,e.CubicBezierCurve=Er,e.CubicBezierCurve3=Cr,e.EllipseCurve=pr,e.LineCurve=Lr,e.LineCurve3=Pr,e.QuadraticBezierCurve=Nr,e.QuadraticBezierCurve3=Or,e.SplineCurve=Dr,e.Earcut=hm,e.ImageUtils=Tu,e.ImmediateRenderObject=fi,e.ShapeUtils=dm,e.BoxGeometry=se,e.BoxBufferGeometry=le,e.CircleGeometry=bo,e.CircleBufferGeometry=wo,e.ConeGeometry=Uo,e.ConeBufferGeometry=ko,e.CylinderGeometry=ce,e.CylinderBufferGeometry=ue,e.DodecahedronGeometry=Bo,e.DodecahedronBufferGeometry=zo,e.EdgesGeometry=jo,e.ExtrudeGeometry=Vo,e.ExtrudeBufferGeometry=Go,e.IcosahedronGeometry=_o,e.IcosahedronBufferGeometry=So,e.LatheGeometry=Xo,e.LatheBufferGeometry=Ho,e.OctahedronGeometry=Ye,e.OctahedronBufferGeometry=qe,e.ParametricGeometry=Yo,e.ParametricBufferGeometry=qo,e.PlaneGeometry=ye,e.PlaneBufferGeometry=xe,e.PolyhedronGeometry=Xe,e.PolyhedronBufferGeometry=He,e.RingGeometry=Qo,e.RingBufferGeometry=Jo,e.ShapeGeometry=Ao,e.ShapeBufferGeometry=Mo,e.SphereGeometry=N,e.SphereBufferGeometry=O,e.TetrahedronGeometry=Zo,e.TetrahedronBufferGeometry=Ko,e.TextGeometry=$o,e.TextBufferGeometry=es,e.TorusGeometry=Qe,e.TorusBufferGeometry=Je,e.TorusKnotGeometry=ts,e.TorusKnotBufferGeometry=rs,e.TubeGeometry=is,e.TubeBufferGeometry=ns,e.WireframeGeometry=Ot,e.ArrowHelper=as,e.AxesHelper=os,e.Box3Helper=ss,e.BoxHelper=Ln,e.CameraHelper=ls,e.DirectionalLightHelper=cs,e.FaceNormalsHelper=us,e.GridHelper=hs,e.HemisphereLightHelper=ds,e.PlaneHelper=ps,e.PointLightHelper=fs,e.PolarGridHelper=ms,e.RectAreaLightHelper=vs,e.SkeletonHelper=xo,e.SpotLightHelper=gs,e.VertexNormalsHelper=ys,e.AmbientLight=Ht,e.DirectionalLight=Vt,e.DirectionalLightShadow=jt,e.HemisphereLight=Xt,e.Light=kt,e.LightShadow=Bt,e.PointLight=zt,e.RectAreaLight=xs,e.SpotLight=Wt,e.SpotLightShadow=Gt,e.AnimationLoader=bs,e.AudioLoader=ws,e.BufferGeometryLoader=_s,e.Cache=Ou,e.CompressedTextureLoader=Qt,e.CubeTextureLoader=Ss,e.DataTextureLoader=Kt,e.FileLoader=we,e.FontLoader=As,e.ImageBitmapLoader=Ms,e.ImageLoader=Re,e.JSONLoader=Be,e.Loader=ke,e.LoaderUtils=Iu,e.DefaultLoadingManager=Du,e.LoadingManager=be,e.MaterialLoader=Ie,e.ObjectLoader=Ls,e.TextureLoader=Ue,e.LineBasicMaterial=I,e.LineDashedMaterial=_e,e.Material=D,e.MeshBasicMaterial=F,e.MeshDepthMaterial=Se,e.MeshDistanceMaterial=Ae,e.MeshLambertMaterial=Me,e.MeshNormalMaterial=Te,e.MeshPhongMaterial=Ee,e.MeshPhysicalMaterial=Le,e.MeshStandardMaterial=Ce,e.MeshToonMaterial=Pe,e.PointsMaterial=Ne,e.RawShaderMaterial=Oe,e.ShaderMaterial=pe,e.ShadowMaterial=De,e.SpriteMaterial=Fe,e.Box2=Tn,e.Box3=d,e.Color=u,e.Cylindrical=Ps,e.Euler=o,e.Frustum=Rn,e.Interpolant=j,e.CubicInterpolant=H,e.DiscreteInterpolant=Y,e.LinearInterpolant=V,e.QuaternionLinearInterpolant=K,e.Line3=Ze,e._Math=Fs,e.Matrix3=l,e.Matrix4=r,e.Plane=ze,e.Quaternion=n,e.Ray=R,e.Sphere=p,e.Spherical=We,e.Triangle=U,e.Vector2=f,e.Vector3=i,e.Vector4=v,e.Bone=oe,e.Group=Dt,e.Line=B,e.LineLoop=Jt,e.LineSegments=Yt,e.LOD=Ts,e.Mesh=k,e.Points=Et,e.Skeleton=Ft,e.SkinnedMesh=It,e.Sprite=vi,e.ShaderChunk=fp,e.ShaderLib=vp,e.UniformsLib=mp,e.UniformsUtils=Mu,e.WebGLAnimation=Un,e.WebGLAttributes=kn,e.WebGLBackground=Bn,e.WebGLBufferRenderer=zn,e.WebGLCapabilities=jn,e.WebGLClipping=Vn,e.WebGLExtensions=Gn,e.WebGLGeometries=Wn,e.WebGLIndexedBufferRenderer=Xn,e.WebGLInfo=Hn,e.WebGLLights=eo,e.WebGLMorphtargets=qn,e.WebGLObjects=Qn,e.WebGLProgram=Ha,e.WebGLPrograms=Ya,e.WebGLProperties=qa,e.WebGLRenderLists=Ka,e.WebGLRenderStates=ro,e.WebGLShader=Da,e.WebGLShadowMap=io,e.WebGLState=no,e.WebGLTextures=ao,e.WebGLUniforms=Na,e.WebGLUtils=oo,e.WebGL2Renderer=Ns,e.WebGLRenderer=uo,e.WebGLRenderTarget=ge,e.WebGLRenderTargetCube=Zt,e.WebVRManager=lo,e.WebXRManager=co,e.Fog=Es,e.FogExp2=Cs,e.Scene=fe,e.CanvasTexture=mi,e.CompressedTexture=qt,e.CubeTexture=$t,e.DataTexture=Mt,e.DepthTexture=In,e.Texture=ve,e.VideoTexture=Os,e.arrayMin=C,e.arrayMax=L}()}),require.register("js/components/Example.js",function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r=0;)e=this._listeners[t],e&&e.apply(this,null);this._idRAF=requestAnimationFrame(this._binds.update)}},{key:"start",value:function(){this._update()}},{key:"stop",value:function(){cancelAnimationFrame(this._idRAF)}},{key:"add",value:function(e){var t=this._listeners.indexOf(e);t>=0||(this._listeners.push(e),this._count++)}},{key:"remove",value:function(e){var t=this._listeners.indexOf(e);t<0||(this._listeners.splice(t,1),this._count--)}}]),e}();r.exports=new a}),require.register("js/core/Webgl.js",function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r","vec2 rand( const vec2 coord ) {","vec2 noise;","if ( useNoise ) {","float nx = dot ( coord, vec2( 12.9898, 78.233 ) );","float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );","noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );","} else {","float ff = fract( 1.0 - coord.s * ( size.x / 2.0 ) );","float gg = fract( coord.t * ( size.y / 2.0 ) );","noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;","}","return ( noise * 2.0 - 1.0 ) * noiseAmount;","}","float readDepth( const in vec2 coord ) {","float cameraFarPlusNear = cameraFar + cameraNear;","float cameraFarMinusNear = cameraFar - cameraNear;","float cameraCoef = 2.0 * cameraNear;","#ifdef USE_LOGDEPTHBUF","float logz = unpackRGBAToDepth( texture2D( tDepth, coord ) );","float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;","float z = (logz / w) + 1.0;","#else","float z = unpackRGBAToDepth( texture2D( tDepth, coord ) );","#endif","return cameraCoef / ( cameraFarPlusNear - z * cameraFarMinusNear );","}","float compareDepths( const in float depth1, const in float depth2, inout int far ) {","float garea = 8.0;","float diff = ( depth1 - depth2 ) * 100.0;","if ( diff < gDisplace ) {","garea = diffArea;","} else {","far = 1;","}","float dd = diff - gDisplace;","float gauss = pow( EULER, -2.0 * ( dd * dd ) / ( garea * garea ) );","return gauss;","}","float calcAO( float depth, float dw, float dh ) {","vec2 vv = vec2( dw, dh );","vec2 coord1 = vUv + radius * vv;","vec2 coord2 = vUv - radius * vv;","float temp1 = 0.0;","float temp2 = 0.0;","int far = 0;","temp1 = compareDepths( depth, readDepth( coord1 ), far );","if ( far > 0 ) {","temp2 = compareDepths( readDepth( coord2 ), depth, far );","temp1 += ( 1.0 - temp1 ) * temp2;","}","return temp1;","}","void main() {","vec2 noise = rand( vUv );","float depth = readDepth( vUv );","float tt = clamp( depth, aoClamp, 1.0 );","float w = ( 1.0 / size.x ) / tt + ( noise.x * ( 1.0 - noise.x ) );","float h = ( 1.0 / size.y ) / tt + ( noise.y * ( 1.0 - noise.y ) );","float ao = 0.0;","float dz = 1.0 / float( samples );","float l = 0.0;","float z = 1.0 - dz / 2.0;","for ( int i = 0; i <= samples; i ++ ) {","float r = sqrt( 1.0 - z );","float pw = cos( l ) * r;","float ph = sin( l ) * r;","ao += calcAO( depth, pw * w, ph * h );","z = z - dz;","l = l + DL;","}","ao /= float( samples );","ao = 1.0 - ao;","vec3 color = texture2D( tDiffuse, vUv ).rgb;","vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );","float lum = dot( color.rgb, lumcoeff );","vec3 luminance = vec3( lum );","vec3 final = vec3( color * mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","if ( onlyAO ) {","final = vec3( mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","}","gl_FragColor = vec4( final, 1.0 );","}"].join("\n")},Sg=function(e,t,r,i){return void 0===_g?(console.warn("SSAOPass depends on SSAOShader"),new Ev):(Ev.call(this,_g),this.width=void 0!==r?r:512,this.height=void 0!==i?i:256,this.renderToScreen=!1,this.camera2=t,this.scene2=e,this.depthMaterial=new Se,this.depthMaterial.depthPacking=mu,this.depthMaterial.blending=nl,this.depthRenderTarget=new ge(this.width,this.height,{minFilter:rc,magFilter:rc}),this.uniforms.tDepth.value=this.depthRenderTarget.texture,this.uniforms.size.value.set(this.width,this.height),this.uniforms.cameraNear.value=this.camera2.near,this.uniforms.cameraFar.value=this.camera2.far,this.uniforms.radius.value=4,this.uniforms.onlyAO.value=!1,this.uniforms.aoClamp.value=.25,this.uniforms.lumInfluence.value=.7,void Object.defineProperties(this,{radius:{get:function(){return this.uniforms.radius.value},set:function(e){this.uniforms.radius.value=e}},onlyAO:{get:function(){return this.uniforms.onlyAO.value},set:function(e){this.uniforms.onlyAO.value=e}},aoClamp:{get:function(){return this.uniforms.aoClamp.value},set:function(e){this.uniforms.aoClamp.value=e}},lumInfluence:{get:function(){return this.uniforms.lumInfluence.value},set:function(e){this.uniforms.lumInfluence.value=e}}}))};Sg.prototype=Object.create(Ev.prototype),Sg.prototype.render=function(e,t,r,i,n){this.scene2.overrideMaterial=this.depthMaterial,e.render(this.scene2,this.camera2,this.depthRenderTarget,!0),this.scene2.overrideMaterial=null,Ev.prototype.render.call(this,e,t,r,i,n)},Sg.prototype.setScene=function(e){this.scene2=e},Sg.prototype.setCamera=function(e){this.camera2=e,this.uniforms.cameraNear.value=this.camera2.near,this.uniforms.cameraFar.value=this.camera2.far},Sg.prototype.setSize=function(e,t){this.width=e,this.height=t,this.uniforms.size.value.set(this.width,this.height),this.depthRenderTarget.setSize(this.width,this.height)};var Ag=function(e,t,r){void 0===wg&&console.error("TAARenderPass relies on SSAARenderPass"),wg.call(this,e,t,r),this.sampleLevel=0,this.accumulate=!1};Ag.JitterVectors=wg.JitterVectors,Ag.prototype=Object.assign(Object.create(wg.prototype),{constructor:Ag,render:function(e,t,r,i){var n=this;if(!this.accumulate)return wg.prototype.render.call(this,e,t,r,i),void(this.accumulateIndex=-1);var a=Ag.JitterVectors[5];this.sampleRenderTarget||(this.sampleRenderTarget=new ge(r.width,r.height,this.params),this.sampleRenderTarget.texture.name="TAARenderPass.sample"),this.holdRenderTarget||(this.holdRenderTarget=new ge(r.width,r.height,this.params),this.holdRenderTarget.texture.name="TAARenderPass.hold"),this.accumulate&&this.accumulateIndex===-1&&(wg.prototype.render.call(this,e,this.holdRenderTarget,r,i),this.accumulateIndex=0);var o=e.autoClear;e.autoClear=!1;var s=1/a.length;if(this.accumulateIndex>=0&&this.accumulateIndex=a.length)break}this.camera.clearViewOffset&&this.camera.clearViewOffset()}var d=this.accumulateIndex*s;d>0&&(this.copyUniforms.opacity.value=1,this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,e.render(this.scene2,this.camera2,t,!0)),d<1&&(this.copyUniforms.opacity.value=1-d,this.copyUniforms.tDiffuse.value=this.holdRenderTarget.texture,e.render(this.scene2,this.camera2,t,0===d)),e.autoClear=o}});var Mg=function(e,t){Tv.call(this),void 0===Gv&&console.error("TexturePass relies on CopyShader");var r=Gv;this.map=e,this.opacity=void 0!==t?t:1,this.uniforms=Mu.clone(r.uniforms),this.material=new pe({uniforms:this.uniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,depthTest:!1,depthWrite:!1}),this.needsSwap=!1,this.camera=new me((-1),1,1,(-1),0,1),this.scene=new fe,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};Mg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Mg,render:function(e,t,r,i,n){var a=e.autoClear;e.autoClear=!1,this.quad.material=this.material,this.uniforms.opacity.value=this.opacity,this.uniforms.tDiffuse.value=this.map,this.material.transparent=this.opacity<1,e.render(this.scene,this.camera,this.renderToScreen?null:r,this.clear),e.autoClear=a}});var Tg={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new u(0)},defaultOpacity:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 defaultColor;","uniform float defaultOpacity;","uniform float luminosityThreshold;","uniform float smoothWidth;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );","float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );","gl_FragColor = mix( outputColor, texel, alpha );","}"].join("\n")},Eg=function(e,t,r,n){var a=this;Tv.call(this),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=n,this.resolution=void 0!==e?new f(e.x,e.y):new f(256,256),this.clearColor=new u(0,0,0);var o={minFilter:rc,magFilter:rc,format:xc};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var s=Math.round(this.resolution.x/2),l=Math.round(this.resolution.y/2);this.renderTargetBright=new ge(s,l,o),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var c=0;c\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat fSigma = float(SIGMA);\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\t\t\t\t\t\tfloat x = float(i);\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\t\t\t\t\t\tweightSum += 2.0 * w;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})},getCompositeMaterial:function(e){return new pe({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D blurTexture1;\t\t\t\tuniform sampler2D blurTexture2;\t\t\t\tuniform sampler2D blurTexture3;\t\t\t\tuniform sampler2D blurTexture4;\t\t\t\tuniform sampler2D blurTexture5;\t\t\t\tuniform sampler2D dirtTexture;\t\t\t\tuniform float bloomStrength;\t\t\t\tuniform float bloomRadius;\t\t\t\tuniform float bloomFactors[NUM_MIPS];\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\t\t\t\t\t\t\t\tfloat lerpBloomFactor(const in float factor) { \t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\t\t\t\t}"})}}),Eg.BlurDirectionX=new f(1,0),Eg.BlurDirectionY=new f(0,1);var Cg=function(){this.seed=1,this.next=function(){return this.gen()/2147483647},this.nextRange=function(e,t){return e+(t-e)*this.next()},this.gen=function(){return this.seed=16807*this.seed%2147483647}};Object.assign(In.prototype,{set:function(e,t,r,i,n,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(n),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],l=r[5],c=r[6],u=r[7],h=r[8],d=r[9],p=r[10],f=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return t[0].setComponents(o-i,u-s,f-h,y-m).normalize(),t[1].setComponents(o+i,u+s,f+h,y+m).normalize(),t[2].setComponents(o+n,u+l,f+d,y+v).normalize(),t[3].setComponents(o-n,u-l,f-d,y-v).normalize(),t[4].setComponents(o-a,u-c,f-p,y-g).normalize(),t[5].setComponents(o+a,u+c,f+p,y+g).normalize(),this},intersectsObject:function(){var e=new p;return function(t){var r=t.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),e.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new p;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,r=e.center,i=-e.radius,n=0;n<6;n++){var a=t[n].distanceToPoint(r);if(a0?t.max.x:t.min.x,e.y=n.normal.y>0?t.max.y:t.min.y,e.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(e)<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}});var Lg=function(){this.id=0,this.object=null,this.z=0,this.renderOrder=0},Pg=function(){this.id=0,this.v1=new Ng,this.v2=new Ng,this.v3=new Ng,this.normalModel=new i,this.vertexNormalsModel=[new i,new i,new i],this.vertexNormalsLength=0,this.color=new u,this.material=null,this.uvs=[new f,new f,new f],this.z=0,this.renderOrder=0},Ng=function(){this.position=new i,this.positionWorld=new i,this.positionScreen=new v,this.visible=!0};Ng.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)};var Og=function(){this.id=0,this.v1=new Ng,this.v2=new Ng,this.vertexColors=[new u,new u],this.material=null,this.z=0,this.renderOrder=0},Dg=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new f,this.material=null,this.renderOrder=0},Fg=function(){function e(r){if(r.visible!==!1){if(r instanceof kt)z.lights.push(r);else if(r instanceof k||r instanceof B||r instanceof Et){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&J.intersectsObject(r)===!1)return;t(r)}else if(r instanceof vi){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&J.intersectsSprite(r)===!1)return;t(r)}for(var i=r.children,n=0,a=i.length;n=-1&&e.z<=1&&(A=u(),A.id=t.id,A.x=e.x*i,A.y=e.y*i,A.z=e.z,A.renderOrder=t.renderOrder,A.object=t,A.rotation=t.rotation,A.scale.x=t.scale.x*Math.abs(A.x-(e.x+r.projectionMatrix.elements[0])/(e.w+r.projectionMatrix.elements[12])),A.scale.y=t.scale.y*Math.abs(A.y-(e.y+r.projectionMatrix.elements[5])/(e.w+r.projectionMatrix.elements[13])),A.material=t.material,z.elements.push(A))}function a(){if(g===C){var e=new Lg;return E.push(e),C++,g++,e}return E[g++]}function o(){if(x===N){var e=new Ng;return L.push(e),N++,x++,e}return L[x++]}function s(){if(w===D){var e=new Pg;return O.push(e),D++,w++,e}return O[w++]}function c(){if(S===R){var e=new Og;return F.push(e),R++,S++,e}return F[S++]}function u(){if(M===U){var e=new Dg;return I.push(e),U++,M++,e}return I[M++]}function h(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function p(e,t){var r=0,i=1,n=e.z+e.w,a=t.z+t.w,o=-e.z+e.w,s=-t.z+t.w;return n>=0&&a>=0&&o>=0&&s>=0||!(n<0&&a<0||o<0&&s<0)&&(n<0?r=Math.max(r,n/(n-a)):a<0&&(i=Math.min(i,n/(n-a))),o<0?r=Math.max(r,o/(o-s)):s<0&&(i=Math.min(i,o/(o-s))),!(i=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function r(e,r,i){y=o(),y.position.set(e,r,i),t(y)}function i(e,t,r){m.push(e,t,r)}function n(e,t,r){v.push(e,t,r)}function a(e,t){g.push(e,t)}function u(e,t,r){return e.visible===!0||t.visible===!0||r.visible===!0||(X[0]=e.positionScreen,X[1]=t.positionScreen,X[2]=r.positionScreen,G.intersectsBox(W.setFromPoints(X)))}function h(e,t,r){return(r.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(r.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}function d(e,t){var r=L[e],i=L[t];r.positionScreen.copy(r.position).applyMatrix4(q),i.positionScreen.copy(i.position).applyMatrix4(q),p(r.positionScreen,i.positionScreen)===!0&&(r.positionScreen.multiplyScalar(1/r.positionScreen.w),i.positionScreen.multiplyScalar(1/i.positionScreen.w),_=c(),_.id=x.id,_.v1.copy(r),_.v2.copy(i),_.z=Math.max(r.positionScreen.z,i.positionScreen.z),_.renderOrder=x.renderOrder,_.material=x.material,x.material.vertexColors===il&&(_.vertexColors[0].fromArray(v,3*e),_.vertexColors[1].fromArray(v,3*t)),z.elements.push(_))}function f(e,t,r,i){var n=arguments,a=L[e],o=L[t],l=L[r];if(u(a,o,l)!==!1&&(i.side===Ks||h(a,o,l)===!0)){b=s(),b.id=x.id,b.v1.copy(a),b.v2.copy(o),b.v3.copy(l),b.z=(a.positionScreen.z+o.positionScreen.z+l.positionScreen.z)/3,b.renderOrder=x.renderOrder,j.subVectors(l.position,o.position),V.subVectors(a.position,o.position),j.cross(V),b.normalModel.copy(j),b.normalModel.applyMatrix3(S).normalize();for(var c=0;c<3;c++){var d=b.vertexNormalsModel[c];d.fromArray(m,3*n[c]),d.applyMatrix3(S).normalize();var p=b.uvs[c];p.fromArray(g,2*n[c])}b.vertexNormalsLength=3,b.material=i,i.vertexColors===rl&&b.color.fromArray(v,3*e),z.elements.push(b)}}var m=[],v=[],g=[],x=null,w=null,S=new l;return{setObject:e,projectVertex:t,checkTriangleVisibility:u,checkBackfaceCulling:h,pushVertex:r,pushNormal:i,pushColor:n,pushUv:a,pushLine:d,pushTriangle:f}},ee=new $;this.projectScene=function(t,r,i,a){w=0,S=0,M=0,z.elements.length=0,t.autoUpdate===!0&&t.updateMatrixWorld(),null===r.parent&&r.updateMatrixWorld(),H.copy(r.matrixWorldInverse),Y.multiplyMatrices(r.projectionMatrix,H),J.setFromMatrix(Y),g=0,z.objects.length=0,z.lights.length=0,e(t),i===!0&&z.objects.sort(h);for(var l=z.objects,u=0,d=l.length;u0)for(var oe=0;oe0)for(var oe=0;oe0||(be=L[x-2],Z.copy(xe.positionScreen),K.copy(be.positionScreen),p(Z,K)===!0&&(Z.multiplyScalar(1/Z.w),K.multiplyScalar(1/K.w),_=c(),_.id=f.id,_.v1.positionScreen.copy(Z),_.v2.positionScreen.copy(K),_.z=Math.max(Z.z,K.z),_.renderOrder=f.renderOrder,_.material=f.material,f.material.vertexColors===il&&(_.vertexColors[0].copy(f.geometry.colors[he]),_.vertexColors[1].copy(f.geometry.colors[he-1])),z.elements.push(_)))}}else if(f instanceof Et){if(q.multiplyMatrices(Y,T),v instanceof m)for(var le=f.geometry.vertices,he=0,de=le.length;he0&&(m(1),v(al),w("rgba("+Math.floor(255*te.r)+","+Math.floor(255*te.g)+","+Math.floor(255*te.b)+","+re+")"),ee.fillRect(0|ge.min.x,0|ge.max.y,ge.max.x-ge.min.x|0,ge.min.y-ge.max.y|0)),ge.makeEmpty())},this.clearColor=function(){},this.clearDepth=function(){},this.clearStencil=function(){},this.render=function(e,r){if(void 0===r.isCamera)return void console.error("CanvasRenderer.render: camera is not an instance of Camera.");var i=e.background;i&&i.isColor?(m(1),v(al),w(i.getStyle()),ee.fillRect(0,0,X,H)):this.autoClear===!0&&this.clear(),V.info.render.vertices=0,V.info.render.faces=0,ee.setTransform(Z/X,0,0,-K/H,Q,H-J),ee.translate(Y,q),S=G.projectScene(e,r,this.sortObjects,this.sortElements),A=S.elements,M=S.lights,Me.getNormalMatrix(r.matrixWorldInverse),t();for(var s=0,l=A.length;s1)continue;if(E.positionScreen.z<-1||E.positionScreen.z>1)continue;if(C.positionScreen.z<-1||C.positionScreen.z>1)continue;T.positionScreen.x*=Y,T.positionScreen.y*=q,E.positionScreen.x*=Y,E.positionScreen.y*=q,C.positionScreen.x*=Y,C.positionScreen.y*=q,u.overdraw>0&&(f(T.positionScreen,E.positionScreen,u.overdraw),f(E.positionScreen,C.positionScreen,u.overdraw),f(C.positionScreen,T.positionScreen,u.overdraw)),ye.setFromPoints([T.positionScreen,E.positionScreen,C.positionScreen]),ve.intersectsBox(ye)===!0&&o(T,E,C,0,1,2,c,u)}ge.union(ye)}}ee.setTransform(1,0,0,1,0,0)}},Ug=function(e){c.call(this),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",function(e){null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)})};Ug.prototype=Object.create(c.prototype),Ug.prototype.constructor=Ug;var kg=function(){console.log("CSS2DRenderer",Bs);var e,t,n,a,o=new i,s=new r,l=new r,c={objects:new WeakMap},u=document.createElement("div");u.style.overflow="hidden",this.domElement=u,this.getSize=function(){return{width:e,height:t}},this.setSize=function(r,i){e=r,t=i,n=e/2,a=t/2,u.style.width=r+"px",u.style.height=i+"px"};var h=function(e,t){if(e instanceof Ug){o.setFromMatrixPosition(e.matrixWorld),o.applyMatrix4(l);var r=e.element,i="translate(-50%,-50%) translate("+(o.x*n+n)+"px,"+(-o.y*a+a)+"px)";r.style.WebkitTransform=i,r.style.MozTransform=i,r.style.oTransform=i,r.style.transform=i;var s={distanceToCameraSquared:d(t,e)};c.objects.set(e,s),r.parentNode!==u&&u.appendChild(r)}for(var p=0,f=e.children.length;pp)return s.splice(s.indexOf(this),1),this.terminate();r(this)}},n.color=(new u).setHSL(Math.random(),.8,.8).getHexString(),s.push(n),t(n),l&&(n.postMessage({scene:w,camera:_,annex:A,sceneId:g}),r(n))}if(!l)for(;s.length>p;)s.pop().terminate()},this.setWorkers(p),this.setClearColor=function(e){d.set(e)},this.setPixelRatio=function(){},this.setSize=function(e,r){c.width=e,c.height=r,n=c.width,a=c.height,h.fillStyle="white",s.forEach(t)},this.setSize(c.width,c.height),this.clear=function(){};var y,x,b,w,_,S,A={},M={mirror:1,reflectivity:1,refractionRatio:1,glass:1};this.render=function(e,t){l=!0,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),w=e.toJSON(),_=t.toJSON(),++g,e.traverse(i),s.forEach(function(e){e.postMessage({scene:w,camera:_,annex:A,sceneId:g})}),h.clearRect(0,0,n,a),S=Date.now(),x=Math.ceil(n/f),b=Math.ceil(a/f),y=x*b,m=[];for(var c=0;c0?~~o:0),f=h-1,m=u.data,v=4*((a*h&f)*h+(n*h&f));if(d){var g=l.palette[p]*m[v],y=l.palette[p+1]*m[v+1],x=l.palette[p+2]*m[v+2],b=m[v+3]*l.opacity/256,w=e[c],_=e[c+1],S=e[c+2];e[c]=g*b+w*(1-b),e[c+1]=y*b+_*(1-b),e[c+2]=x*b+S*(1-b),e[c+3]=(l.opacity<<8)-1,255==e[c+3]&&(t[r]=i)}else e[c]=l.palette[p]*m[v]>>8,e[c+1]=l.palette[p+1]*m[v+1]>>8,e[c+2]=l.palette[p+2]*m[v+2]>>8,e[c+3]=(l.opacity<<8)-1,t[r]=i}}function s(e){var t=e.id,r=D[t];if(r&&e.map&&!I[e.map.id]&&delete D[t],void 0===D[t]||e.needsUpdate===!0){if(e instanceof F||e instanceof Me||e instanceof Ee||e instanceof Fe){e instanceof Me?e.palette||(e.palette=n(e,!1)):e instanceof Ee&&(e.palette||(e.palette=n(e,!0)));var i;if(e.map){var s=new Gg.Texture;if(s.fromImage(e.map.image),!s.data)return;I[e.map.id]=s,r=e instanceof F||e instanceof Fe?a:o}else i=e.vertexColors===rl?["var colorOffset = offset * 4;","buffer[ colorOffset ] = face.color.r * 255;","buffer[ colorOffset + 1 ] = face.color.g * 255;","buffer[ colorOffset + 2 ] = face.color.b * 255;","buffer[ colorOffset + 3 ] = material.opacity * 255;","depthBuf[ offset ] = depth;"].join("\n"):["var colorOffset = offset * 4;","buffer[ colorOffset ] = material.color.r * 255;","buffer[ colorOffset + 1 ] = material.color.g * 255;","buffer[ colorOffset + 2 ] = material.color.b * 255;","buffer[ colorOffset + 3 ] = material.opacity * 255;","depthBuf[ offset ] = depth;"].join("\n"),r=new Function("buffer, depthBuf, offset, depth, u, v, n, face, material",i)}else if(e instanceof R){var i=["var colorOffset = offset * 4;","buffer[ colorOffset ] = material.color.r * (color1.r+color2.r) * 0.5 * 255;","buffer[ colorOffset + 1 ] = material.color.g * (color1.g+color2.g) * 0.5 * 255;","buffer[ colorOffset + 2 ] = material.color.b * (color1.b+color2.b) * 0.5 * 255;","buffer[ colorOffset + 3 ] = 255;","depthBuf[ offset ] = depth;"].join("\n");r=new Function("buffer, depthBuf, offset, depth, color1, color2, material",i)}else{var i=["var colorOffset = offset * 4;","buffer[ colorOffset ] = u * 255;","buffer[ colorOffset + 1 ] = v * 255;","buffer[ colorOffset + 2 ] = 0;","buffer[ colorOffset + 3 ] = 255;","depthBuf[ offset ] = depth;"].join("\n");r=new Function("buffer, depthBuf, offset, depth, u, v, n, face, material",i)}D[t]=r,e.needsUpdate=!1}return r}function l(e,t,r,n,a,o,s,c,u){if(!(e.z<-1||e.z>1||t.z<-1||t.z>1||r.z<-1||r.z>1)){var d=1<100*d){var U,k,X,H={vertexNormalsModel:[],color:c.color};if(R){me===fe.length?(U=new f,fe.push(U),++me,k=new f,fe.push(k),++me,X=new f,fe.push(X),++me):(U=fe[me],++me,k=fe[me],++me,X=fe[me],++me);var Y;Y=(1+t.z)*(t.w/e.w)/(1+e.z),U.copy(n).multiplyScalar(Y).add(a).multiplyScalar(1/(Y+1)),Y=(1+r.z)*(r.w/t.w)/(1+t.z),k.copy(a).multiplyScalar(Y).add(o).multiplyScalar(1/(Y+1)),Y=(1+e.z)*(e.w/r.w)/(1+r.z),X.copy(o).multiplyScalar(Y).add(n).multiplyScalar(1/(Y+1))}var q,$,ee;he===ue.length?(q=new v,ue.push(q),++he,$=new v,ue.push($),++he,ee=new v,ue.push(ee),++he):(q=ue[he],++he,$=ue[he],++he,ee=ue[he],++he),q.copy(e).add(t).multiplyScalar(.5),$.copy(t).add(r).multiplyScalar(.5),ee.copy(r).add(e).multiplyScalar(.5);var te,re,ie;return F&&(pe===de.length?(te=new i,de.push(te),++pe,re=new i,de.push(re),++pe,ie=new i,de.push(ie),++pe):(te=de[pe],++pe,re=de[pe],++pe,ie=de[pe],++pe),te.copy(c.vertexNormalsModel[0]).add(c.vertexNormalsModel[1]).normalize(),re.copy(c.vertexNormalsModel[1]).add(c.vertexNormalsModel[2]).normalize(),ie.copy(c.vertexNormalsModel[2]).add(c.vertexNormalsModel[0]).normalize()),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[0],H.vertexNormalsModel[1]=te,H.vertexNormalsModel[2]=ie),l(e,q,ee,n,U,X,s,H,u),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[1],H.vertexNormalsModel[1]=re,H.vertexNormalsModel[2]=te),l(t,$,q,a,k,U,s,H,u),F&&(H.vertexNormalsModel[0]=te,H.vertexNormalsModel[1]=re,H.vertexNormalsModel[2]=ie),l(q,$,ee,U,k,X,s,H,u),F&&(H.vertexNormalsModel[0]=c.vertexNormalsModel[2],H.vertexNormalsModel[1]=ie,H.vertexNormalsModel[2]=re),void l(r,ee,$,o,X,k,s,H,u)}var ne,ae,oe,se,le,ce,ve=e.z*w+A|0,ge=t.z*w+A|0,ye=r.z*w+A|0,R=!1;n&&a&&o&&(R=!0,ne=n.x,ae=1-n.y,oe=a.x,se=1-a.y,le=o.x,ce=1-o.y);var xe,be,we,_e,Se,Ae;F&&(xe=c.vertexNormalsModel[0],be=c.vertexNormalsModel[1],we=c.vertexNormalsModel[2],_e=255*xe.z,Se=255*be.z,Ae=255*we.z);var Me=y-M,Te=O-N,Ee=M-C,Ce=D-O,Le=C-y,Pe=N-D,Ne=Math.max(Math.min(y,M,C)+V>>j,0),Oe=Math.min(Math.max(y,M,C)+V>>j,p),De=Math.max(Math.min(N,O,D)+V>>j,0),Fe=Math.min(Math.max(N,O,D)+V>>j,m);Q=Math.min(Ne,Q),Z=Math.max(Oe,Z),J=Math.min(De,J),K=Math.max(Fe,K);var Re=W;Ne&=~(Re-1),De&=~(Re-1);var Ie=Ne<0||0==Te&&Me>0)&&ke++,(Ce>0||0==Ce&&Ee>0)&&Be++,(Pe>0||0==Pe&&Le>0)&&ze++,ke=ke-1>>j,Be=Be-1>>j,ze=ze-1>>j;var je=ve-ge,Ve=ye-ve,Ge=1/(Me*Pe-Le*Te),We=Ge*(je*Pe-Ve*Te),Xe=Ge*(je*Le-Me*Ve),He=ve+(Ie-y)*We+(Ue-N)*Xe|0;We=We*d|0,Xe=Xe*d|0;var Ye,qe,Qe,Je;if(R){var Ze=ne-oe,Ke=le-ne,$e=Ge*(Ze*Pe-Ke*Te),et=Ge*(Ze*Le-Me*Ke),tt=ae-se,rt=ce-ae;Ye=Ge*(tt*Pe-rt*Te),qe=Ge*(tt*Le-Me*rt),Qe=ne+(Ie-y)*$e+(Ue-N)*et,Je=ae+(Ie-y)*Ye+(Ue-N)*qe,$e*=d,et*=d,Ye*=d,qe*=d}var it,nt;if(F){var at=_e-Se,ot=Ae-_e,st=Ge*(at*Pe-ot*Te),it=Ge*(at*Le-Me*ot);nt=_e+(Ie-y)*st+(Ue-N)*it,st*=d,it*=d}var lt=Re-1,ct=0,ut=0,ht=0,dt=0,pt=0,ft=0,mt=0,vt=0;Me>=0?ut-=lt*Me:ct-=lt*Me,Te>=0?ut-=lt*Te:ct-=lt*Te,Ee>=0?dt-=lt*Ee:ht-=lt*Ee,Ce>=0?dt-=lt*Ce:ht-=lt*Ce,Le>=0?ft-=lt*Le:pt-=lt*Le,Pe>=0?ft-=lt*Pe:pt-=lt*Pe,We>=0?vt+=lt*We:mt+=lt*We,Xe>=0?vt+=lt*Xe:mt+=lt*Xe;var gt,yt,xt=p-Re,bt=ke,wt=Be,_t=ze,St=He,At=-Re,Mt=At*Te,Tt=At*Ce,Et=At*Pe,Ct=At*We;R&&(gt=At*$e,yt=At*Ye);var Lt;F&&(Lt=At*st);for(var Pt=Ne,Nt=De;Nt=Ne&&Pt=ut&&wt>=dt&&_t>=ft;)Pt+=At,bt+=Mt,wt+=Tt,_t+=Et,St+=Ct,R&&(Qe+=gt,Je+=yt),F&&(nt+=Lt);for(At=-At,Mt=-Mt,Tt=-Tt,Et=-Et,Ct=-Ct,R&&(gt=-gt,yt=-yt),F&&(Lt=-Lt);;){if(Pt+=At,bt+=Mt,wt+=Tt,_t+=Et,St+=Ct,R&&(Qe+=gt,Je+=yt),F&&(nt+=Lt),Pt=Oe)break;if(bt>G,Dt=Nt>>G,Ft=Ot+Dt*g,Rt=St+mt;if(!(L[Ft]=ct&&wt>=ht&&_t>=pt){var kt=St+vt;L[Ft]=Math.min(L[Ft],kt);var Bt,zt,jt=bt,Vt=wt,Gt=St;R&&(Bt=Qe,zt=Je);var Wt;F&&(Wt=nt);for(var Xt=0;Xt=0){var $t=Jt;$t1||t.z<-1||t.z>1)){var o=Math.floor(.5*(a.linewidth-1)),s=e.x*x+_|0,l=t.x*x+_|0,c=e.y*b+S|0,u=t.y*b+S|0,d=e.z*w+A|0,f=t.z*w+A|0,v=s-l,y=c-u,M=d-f,C=Math.max(Math.min(s,l)+V>>j,0),O=Math.min(Math.max(s,l)+V>>j,p),D=Math.max(Math.min(c,u)+V>>j,0),F=Math.min(Math.max(c,u)+V>>j,m),R=Math.max(Math.min(d,f)+V>>j,0),I=Math.max(d,f)+V>>j;Q=Math.min(C,Q),Z=Math.max(O,Z),J=Math.min(D,J),K=Math.max(F,K);var U,k,X,$,ee,te,re=Math.sqrt(y*y+v*v),ie=v/re,ne=y/re,ae=M/re;for(q.set(ie,ne,ae),q.cross(Y),q.normalize();re>0;){U=l+re*ie,k=u+re*ne,X=f+re*ae,U=U+V>>j,k=k+V>>j,te=X+V>>j;for(var oe=-o;oe<=o;++oe)if($=Math.floor(U+q.x*oe),ee=Math.floor(k+q.y*oe),!(Q>=$||Z<=$||J>=ee||K<=ee)){var se=$>>G,le=ee>>G,ce=se+le*g;if(!(L[ce]t.height?t.width:t.height;r=Fs.ceilPowerOfTwo(r),e.width==r&&e.height==r||(e.width=r,e.height=r);var i=e.getContext("2d");i.clearRect(0,0,r,r),i.drawImage(t,0,0,r,r);var n=i.getImageData(0,0,r,r);this.data=n.data,this.width=r,this.height=r,this.srcUrl=t.src}}};var Wg=function(e){c.call(this),this.node=e};Wg.prototype=Object.create(c.prototype),Wg.prototype.constructor=Wg;var Xg=function(){function e(){for(Y=0;P.childNodes.length>0;)P.removeChild(P.childNodes[0])}function t(e,t){var r=Math.floor(255*e.r)+","+Math.floor(255*e.g)+","+Math.floor(255*e.b);return void 0===t||1===t?"rgb("+r+")":"rgb("+r+"); fill-opacity: "+t}function n(e){return null!==Q?e.toFixed(Q):e}function a(e){R.setRGB(0,0,0),I.setRGB(0,0,0),U.setRGB(0,0,0);for(var t=0,r=e.length;t1)continue;if(S.positionScreen.z<-1||S.positionScreen.z>1)continue;if(A.positionScreen.z<-1||A.positionScreen.z>1)continue;_.positionScreen.x*=b,_.positionScreen.y*=-w,S.positionScreen.x*=b,S.positionScreen.y*=-w,A.positionScreen.x*=b,A.positionScreen.y*=-w,O.setFromPoints([_.positionScreen,S.positionScreen,A.positionScreen]),N.intersectsBox(O)===!0&&h(_,S,A,u,d)}}p(),r.traverseVisible(function(e){if(e instanceof Wg){z.setFromMatrixPosition(e.matrixWorld),z.applyMatrix4(X);var t=z.x*b,r=-z.y*w,i=e.node;i.setAttribute("transform","translate("+t+","+r+")"),P.appendChild(i)}})}},Hg=new ve,Yg=new $t,qg=[],Qg=[],Jg=new Float32Array(16),Zg=new Float32Array(9),Kg=new Float32Array(4);Ea.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),$n(t,e)},Ca.prototype.setValue=function(e,t,r){for(var i=this.seq,n=0,a=i.length;n!==a;++n){var o=i[n];o.setValue(e,t[o.id],r)}};var $g=/([\w\d_]+)(\])?(\[|\.)?/g;Na.prototype.setValue=function(e,t,r){var i=this.map[t];void 0!==i&&i.setValue(e,r,this.renderer)},Na.prototype.setOptional=function(e,t,r){var i=t[r];void 0!==i&&this.setValue(e,r,i)},Na.upload=function(e,t,r,i){for(var n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o.id];s.needsUpdate!==!1&&o.setValue(e,s.value,i)}},Na.seqWithValue=function(e,t){for(var r=[],i=0,n=e.length;i!==n;++i){var a=e[i];a.id in t&&r.push(a)}return r};var ey=0,ty=0;so.prototype=Object.assign(Object.create(de.prototype),{constructor:so,isArrayCamera:!0}),ho.prototype.clone=function(){return new ho(void 0===this.value.clone?this.value:this.value.clone())};var ry={uniforms:{tDiffuse:{value:null},resolution:{value:new f(1/1024,1/512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","","uniform sampler2D tDiffuse;","","uniform vec2 resolution;","","varying vec2 vUv;","","// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)","","//----------------------------------------------------------------------------------","// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag","// SDK Version: v3.00","// Email: gameworks@nvidia.com","// Site: http://developer.nvidia.com/","//","// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.","//","// Redistribution and use in source and binary forms, with or without","// modification, are permitted provided that the following conditions","// are met:","// * Redistributions of source code must retain the above copyright","// notice, this list of conditions and the following disclaimer.","// * Redistributions in binary form must reproduce the above copyright","// notice, this list of conditions and the following disclaimer in the","// documentation and/or other materials provided with the distribution.","// * Neither the name of NVIDIA CORPORATION nor the names of its","// contributors may be used to endorse or promote products derived","// from this software without specific prior written permission.","//","// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY","// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE","// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR","// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR","// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,","// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,","// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR","// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY","// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT","// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE","// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.","//","//----------------------------------------------------------------------------------","","#define FXAA_PC 1","#define FXAA_GLSL_100 1","#define FXAA_QUALITY_PRESET 12","","#define FXAA_GREEN_AS_LUMA 1","","","#ifndef FXAA_PC_CONSOLE"," //"," // The console algorithm for PC is included"," // for developers targeting really low spec machines."," // Likely better to just run FXAA_PC, and use a really low preset."," //"," #define FXAA_PC_CONSOLE 0","#endif","","#ifndef FXAA_GLSL_120"," #define FXAA_GLSL_120 0","#endif","","#ifndef FXAA_GLSL_130"," #define FXAA_GLSL_130 0","#endif","","#ifndef FXAA_HLSL_3"," #define FXAA_HLSL_3 0","#endif","","#ifndef FXAA_HLSL_4"," #define FXAA_HLSL_4 0","#endif","","#ifndef FXAA_HLSL_5"," #define FXAA_HLSL_5 0","#endif","","#ifndef FXAA_GREEN_AS_LUMA"," //"," // For those using non-linear color,"," // and either not able to get luma in alpha, or not wanting to,"," // this enables FXAA to run using green as a proxy for luma."," // So with this enabled, no need to pack luma in alpha."," //"," // This will turn off AA on anything which lacks some amount of green."," // Pure red and blue or combination of only R and B, will get no AA."," //"," // Might want to lower the settings for both,"," // fxaaConsoleEdgeThresholdMin"," // fxaaQualityEdgeThresholdMin"," // In order to insure AA does not get turned off on colors"," // which contain a minor amount of green."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_GREEN_AS_LUMA 0","#endif","","#ifndef FXAA_EARLY_EXIT"," //"," // Controls algorithm's early exit path."," // On PS3 turning this ON adds 2 cycles to the shader."," // On 360 turning this OFF adds 10ths of a millisecond to the shader."," // Turning this off on console will result in a more blurry image."," // So this defaults to on."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_EARLY_EXIT 1","#endif","","#ifndef FXAA_DISCARD"," //"," // Only valid for PC OpenGL currently."," // Probably will not work when FXAA_GREEN_AS_LUMA = 1."," //"," // 1 = Use discard on pixels which don't need AA."," // For APIs which enable concurrent TEX+ROP from same surface."," // 0 = Return unchanged color on pixels which don't need AA."," //"," #define FXAA_DISCARD 0","#endif","","#ifndef FXAA_FAST_PIXEL_OFFSET"," //"," // Used for GLSL 120 only."," //"," // 1 = GL API supports fast pixel offsets"," // 0 = do not use fast pixel offsets"," //"," #ifdef GL_EXT_gpu_shader4"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifndef FXAA_FAST_PIXEL_OFFSET"," #define FXAA_FAST_PIXEL_OFFSET 0"," #endif","#endif","","#ifndef FXAA_GATHER4_ALPHA"," //"," // 1 = API supports gather4 on alpha channel."," // 0 = API does not support gather4 on alpha channel."," //"," #if (FXAA_HLSL_5 == 1)"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifndef FXAA_GATHER4_ALPHA"," #define FXAA_GATHER4_ALPHA 0"," #endif","#endif","","","","#ifndef FXAA_QUALITY_PRESET"," //"," // Choose the quality preset."," // This needs to be compiled into the shader as it effects code."," // Best option to include multiple presets is to"," // in each shader define the preset, then include this file."," //"," // OPTIONS"," // -----------------------------------------------------------------------"," // 10 to 15 - default medium dither (10=fastest, 15=highest quality)"," // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)"," // 39 - no dither, very expensive"," //"," // NOTES"," // -----------------------------------------------------------------------"," // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)"," // 13 = about same speed as FXAA 3.9 and better than 12"," // 23 = closest to FXAA 3.9 visually and performance wise"," // _ = the lowest digit is directly related to performance"," // _ = the highest digit is directly related to style"," //"," #define FXAA_QUALITY_PRESET 12","#endif","","","","","","#if (FXAA_QUALITY_PRESET == 10)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 3.0"," #define FXAA_QUALITY_P2 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 11)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 3.0"," #define FXAA_QUALITY_P3 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 12)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 4.0"," #define FXAA_QUALITY_P4 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 13)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 4.0"," #define FXAA_QUALITY_P5 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 14)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 4.0"," #define FXAA_QUALITY_P6 12.0","#endif","","#if (FXAA_QUALITY_PRESET == 15)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 12.0","#endif","","","#if (FXAA_QUALITY_PRESET == 20)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 2.0"," #define FXAA_QUALITY_P2 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 21)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 22)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 23)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 24)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 3.0"," #define FXAA_QUALITY_P6 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 25)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 26)"," #define FXAA_QUALITY_PS 9"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 4.0"," #define FXAA_QUALITY_P8 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 27)"," #define FXAA_QUALITY_PS 10"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 4.0"," #define FXAA_QUALITY_P9 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 28)"," #define FXAA_QUALITY_PS 11"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 4.0"," #define FXAA_QUALITY_P10 8.0","#endif","","#if (FXAA_QUALITY_PRESET == 29)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","","#if (FXAA_QUALITY_PRESET == 39)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.0"," #define FXAA_QUALITY_P2 1.0"," #define FXAA_QUALITY_P3 1.0"," #define FXAA_QUALITY_P4 1.0"," #define FXAA_QUALITY_P5 1.5"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","","","","#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)"," #define FxaaBool bool"," #define FxaaDiscard discard"," #define FxaaFloat float"," #define FxaaFloat2 vec2"," #define FxaaFloat3 vec3"," #define FxaaFloat4 vec4"," #define FxaaHalf float"," #define FxaaHalf2 vec2"," #define FxaaHalf3 vec3"," #define FxaaHalf4 vec4"," #define FxaaInt2 ivec2"," #define FxaaSat(x) clamp(x, 0.0, 1.0)"," #define FxaaTex sampler2D","#else"," #define FxaaBool bool"," #define FxaaDiscard clip(-1)"," #define FxaaFloat float"," #define FxaaFloat2 float2"," #define FxaaFloat3 float3"," #define FxaaFloat4 float4"," #define FxaaHalf half"," #define FxaaHalf2 half2"," #define FxaaHalf3 half3"," #define FxaaHalf4 half4"," #define FxaaSat(x) saturate(x)","#endif","","#if (FXAA_GLSL_100 == 1)"," #define FxaaTexTop(t, p) texture2D(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)","#endif","","#if (FXAA_GLSL_120 == 1)"," // Requires,"," // #version 120"," // And at least,"," // #extension GL_EXT_gpu_shader4 : enable"," // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)"," #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)"," #if (FXAA_FAST_PIXEL_OFFSET == 1)"," #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)"," #else"," #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)"," #endif"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","","#if (FXAA_GLSL_130 == 1)",' // Requires "#version 130" or better'," #define FxaaTexTop(t, p) textureLod(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","","#if (FXAA_HLSL_3 == 1)"," #define FxaaInt2 float2"," #define FxaaTex sampler2D"," #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))"," #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))","#endif","","#if (FXAA_HLSL_4 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)","#endif","","#if (FXAA_HLSL_5 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)"," #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)"," #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)"," #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)"," #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)","#endif","","","","#if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }","#else"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }","#endif","","","","","","#if (FXAA_PC == 1)","","FxaaFloat4 FxaaPixelShader("," //"," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy} = center of pixel"," FxaaFloat2 pos,"," //"," // Used only for FXAA Console, and not used on the 360 version."," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy_} = upper left of pixel"," // {_zw} = lower right of pixel"," FxaaFloat4 fxaaConsolePosPos,"," //"," // Input color texture."," // {rgb_} = color in linear or perceptual color space"," // if (FXAA_GREEN_AS_LUMA == 0)"," // {__a} = luma in perceptual color space (not linear)"," FxaaTex tex,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 2nd sampler."," // This sampler needs to have an exponent bias of -1."," FxaaTex fxaaConsole360TexExpBiasNegOne,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 3nd sampler."," // This sampler needs to have an exponent bias of -2."," FxaaTex fxaaConsole360TexExpBiasNegTwo,"," //"," // Only used on FXAA Quality."," // This must be from a constant/uniform."," // {x_} = 1.0/screenWidthInPixels"," // {_y} = 1.0/screenHeightInPixels"," FxaaFloat2 fxaaQualityRcpFrame,"," //"," // Only used on FXAA Console."," // This must be from a constant/uniform."," // This effects sub-pixel AA quality and inversely sharpness."," // Where N ranges between,"," // N = 0.50 (default)"," // N = 0.33 (sharper)"," // {x__} = -N/screenWidthInPixels"," // {_y_} = -N/screenHeightInPixels"," // {_z_} = N/screenWidthInPixels"," // {__w} = N/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt,"," //"," // Only used on FXAA Console."," // Not used on 360, but used on PS3 and PC."," // This must be from a constant/uniform."," // {x__} = -2.0/screenWidthInPixels"," // {_y_} = -2.0/screenHeightInPixels"," // {_z_} = 2.0/screenWidthInPixels"," // {__w} = 2.0/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt2,"," //"," // Only used on FXAA Console."," // Only used on 360 in place of fxaaConsoleRcpFrameOpt2."," // This must be from a constant/uniform."," // {x__} = 8.0/screenWidthInPixels"," // {_y_} = 8.0/screenHeightInPixels"," // {_z_} = -4.0/screenWidthInPixels"," // {__w} = -4.0/screenHeightInPixels"," FxaaFloat4 fxaaConsole360RcpFrameOpt2,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_SUBPIX define."," // It is here now to allow easier tuning."," // Choose the amount of sub-pixel aliasing removal."," // This can effect sharpness."," // 1.00 - upper limit (softer)"," // 0.75 - default amount of filtering"," // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)"," // 0.25 - almost off"," // 0.00 - completely off"," FxaaFloat fxaaQualitySubpix,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // The minimum amount of local contrast required to apply algorithm."," // 0.333 - too little (faster)"," // 0.250 - low quality"," // 0.166 - default"," // 0.125 - high quality"," // 0.063 - overkill (slower)"," FxaaFloat fxaaQualityEdgeThreshold,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // 0.0833 - upper limit (default, the start of visible unfiltered edges)"," // 0.0625 - high quality (faster)"," // 0.0312 - visible limit (slower)"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaQualityEdgeThresholdMin,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3."," // Due to the PS3 being ALU bound,"," // there are only three safe values here: 2 and 4 and 8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // For all other platforms can be a non-power of two."," // 8.0 is sharper (default!!!)"," // 4.0 is softer"," // 2.0 is really soft (good only for vector graphics inputs)"," FxaaFloat fxaaConsoleEdgeSharpness,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3."," // Due to the PS3 being ALU bound,"," // there are only two safe values here: 1/4 and 1/8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // The console setting has a different mapping than the quality setting."," // Other platforms can use other values."," // 0.125 leaves less aliasing, but is softer (default!!!)"," // 0.25 leaves more aliasing, and is sharper"," FxaaFloat fxaaConsoleEdgeThreshold,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // The console setting has a different mapping than the quality setting."," // This only applies when FXAA_EARLY_EXIT is 1."," // This does not apply to PS3,"," // PS3 was simplified to avoid more shader instructions."," // 0.06 - faster but more aliasing in darks"," // 0.05 - default"," // 0.04 - slower and less aliasing in darks"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaConsoleEdgeThresholdMin,"," //"," // Extra constants for 360 FXAA Console only."," // Use zeros or anything else for other platforms."," // These must be in physical constant registers and NOT immediates."," // Immediates will result in compiler un-optimizing."," // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)"," FxaaFloat4 fxaaConsole360ConstDir",") {",""," FxaaFloat2 posM;"," posM.x = pos.x;"," posM.y = pos.y;"," #if (FXAA_GATHER4_ALPHA == 1)"," #if (FXAA_DISCARD == 0)"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #endif"," #if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));"," #else"," FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));"," #endif"," #if (FXAA_DISCARD == 1)"," #define lumaM luma4A.w"," #endif"," #define lumaE luma4A.z"," #define lumaS luma4A.x"," #define lumaSE luma4A.y"," #define lumaNW luma4B.w"," #define lumaN luma4B.z"," #define lumaW luma4B.x"," #else"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));"," #endif"," #endif",""," FxaaFloat maxSM = max(lumaS, lumaM);"," FxaaFloat minSM = min(lumaS, lumaM);"," FxaaFloat maxESM = max(lumaE, maxSM);"," FxaaFloat minESM = min(lumaE, minSM);"," FxaaFloat maxWN = max(lumaN, lumaW);"," FxaaFloat minWN = min(lumaN, lumaW);"," FxaaFloat rangeMax = max(maxWN, maxESM);"," FxaaFloat rangeMin = min(minWN, minESM);"," FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;"," FxaaFloat range = rangeMax - rangeMin;"," FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);"," FxaaBool earlyExit = range < rangeMaxClamped;",""," if(earlyExit)"," #if (FXAA_DISCARD == 1)"," FxaaDiscard;"," #else"," return rgbyM;"," #endif",""," #if (FXAA_GATHER4_ALPHA == 0)"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif"," #else"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif",""," FxaaFloat lumaNS = lumaN + lumaS;"," FxaaFloat lumaWE = lumaW + lumaE;"," FxaaFloat subpixRcpRange = 1.0/range;"," FxaaFloat subpixNSWE = lumaNS + lumaWE;"," FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;"," FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;",""," FxaaFloat lumaNESE = lumaNE + lumaSE;"," FxaaFloat lumaNWNE = lumaNW + lumaNE;"," FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;"," FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;",""," FxaaFloat lumaNWSW = lumaNW + lumaSW;"," FxaaFloat lumaSWSE = lumaSW + lumaSE;"," FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);"," FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);"," FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;"," FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;"," FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;"," FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;",""," FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;"," FxaaFloat lengthSign = fxaaQualityRcpFrame.x;"," FxaaBool horzSpan = edgeHorz >= edgeVert;"," FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;",""," if(!horzSpan) lumaN = lumaW;"," if(!horzSpan) lumaS = lumaE;"," if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;"," FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;",""," FxaaFloat gradientN = lumaN - lumaM;"," FxaaFloat gradientS = lumaS - lumaM;"," FxaaFloat lumaNN = lumaN + lumaM;"," FxaaFloat lumaSS = lumaS + lumaM;"," FxaaBool pairN = abs(gradientN) >= abs(gradientS);"," FxaaFloat gradient = max(abs(gradientN), abs(gradientS));"," if(pairN) lengthSign = -lengthSign;"," FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);",""," FxaaFloat2 posB;"," posB.x = posM.x;"," posB.y = posM.y;"," FxaaFloat2 offNP;"," offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;"," offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;"," if(!horzSpan) posB.x += lengthSign * 0.5;"," if( horzSpan) posB.y += lengthSign * 0.5;",""," FxaaFloat2 posN;"," posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;"," posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;"," FxaaFloat2 posP;"," posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;"," posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;"," FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;"," FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));"," FxaaFloat subpixE = subpixC * subpixC;"," FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));",""," if(!pairN) lumaNN = lumaSS;"," FxaaFloat gradientScaled = gradient * 1.0/4.0;"," FxaaFloat lumaMM = lumaM - lumaNN * 0.5;"," FxaaFloat subpixF = subpixD * subpixE;"," FxaaBool lumaMLTZero = lumaMM < 0.0;",""," lumaEndN -= lumaNN * 0.5;"," lumaEndP -= lumaNN * 0.5;"," FxaaBool doneN = abs(lumaEndN) >= gradientScaled;"," FxaaBool doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;"," FxaaBool doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;",""," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;",""," #if (FXAA_QUALITY_PS > 3)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;",""," #if (FXAA_QUALITY_PS > 4)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;",""," #if (FXAA_QUALITY_PS > 5)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;",""," #if (FXAA_QUALITY_PS > 6)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;",""," #if (FXAA_QUALITY_PS > 7)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;",""," #if (FXAA_QUALITY_PS > 8)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;",""," #if (FXAA_QUALITY_PS > 9)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;",""," #if (FXAA_QUALITY_PS > 10)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;",""," #if (FXAA_QUALITY_PS > 11)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;",""," #if (FXAA_QUALITY_PS > 12)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }"," #endif",""," }",""," FxaaFloat dstN = posM.x - posN.x;"," FxaaFloat dstP = posP.x - posM.x;"," if(!horzSpan) dstN = posM.y - posN.y;"," if(!horzSpan) dstP = posP.y - posM.y;",""," FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;"," FxaaFloat spanLength = (dstP + dstN);"," FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;"," FxaaFloat spanLengthRcp = 1.0/spanLength;",""," FxaaBool directionN = dstN < dstP;"," FxaaFloat dst = min(dstN, dstP);"," FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;"," FxaaFloat subpixG = subpixF * subpixF;"," FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;"," FxaaFloat subpixH = subpixG * fxaaQualitySubpix;",""," FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;"," FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);"," if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;"," if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;"," #if (FXAA_DISCARD == 1)"," return FxaaTexTop(tex, posM);"," #else"," return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);"," #endif","}","","#endif","","void main() {"," gl_FragColor = FxaaPixelShader("," vUv,"," vec4(0.0),"," tDiffuse,"," tDiffuse,"," tDiffuse,"," resolution,"," vec4(0.0),"," vec4(0.0),"," vec4(0.0),"," 0.75,"," 0.166,"," 0.0833,"," 0.0,"," 0.0,"," 0.0,"," vec4(0.0)"," );",""," // TODO avoid querying texture twice for same texel"," gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join("\n") +},iy=function(e){function t(e){ke.renderer=void 0!==e.renderer?e.renderer:new uo,ke.domElement=ke.renderer.domElement,de=ke.renderer.context,ve=void 0!==e.width?e.width:ke.renderer.getSize().width,ye=void 0!==e.height?e.height:ke.renderer.getSize().height;var t=void 0!==e.antialias&&e.antialias;void 0!==e.cacheKeepAlive&&(Ve=e.cacheKeepAlive),r(),n(),a(),o(),s(),l(),ke.setSize(ve,ye),ke.setAntialias(t),ke.enableLightPrePass(!1)}function r(){Fe=new Rn(ve,ye,vc,(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),Ac)}function n(){Le=new dg,Le.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,stencilBuffer:!0,depthTexture:Fe});e.texture.generateMipamps=!1,Te=new ng(ke.renderer,e),Te.addPass(Le)}function a(){we=new dg,we.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,be=new ng(ke.renderer,e),be.addPass(we)}function o(){Ne=new dg,Ne.clear=!0,Ne.camera=new me((-1),1,1,(-1),0,1),Pe=new dg,Pe.clear=!1;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,Ee=new ng(ke.renderer,e),Ee.addPass(Ne),Ee.addPass(Pe)}function s(){Me=new dg,Me.clear=!0;var e=new ge(ve,ye,{minFilter:$l,magFilter:$l,format:xc,type:hc,depthTexture:Fe});e.texture.generateMipamps=!1,Ae=new ng(ke.renderer,e),Ae.addPass(Me)}function l(){Oe=new Ev(oy["final"]),Oe.clear=!0,Oe.uniforms.samplerResult.value=Ee.renderTarget2.texture,Oe.material.blending=nl,Oe.material.depthWrite=!1,Oe.material.depthTest=!1,_e=new dg,_e.clear=!1,Se=new Ev(Gv),De=new Ev(ry);var e=new ge(ve,ye,{minFilter:$l,magFilter:rc,format:yc,type:ac,depthTexture:Fe});e.texture.generateMipamps=!1,Ce=new ng(ke.renderer,e),Ce.addPass(Oe),Ce.addPass(_e),Ce.addPass(Se),Ce.addPass(De)}function c(e){var t=Xe[e.uuid],r=He[e.uuid];if(void 0===t){var i=new fe;i.userData.lights={},t=re(),t.scene=i,Xe[e.uuid]=t}if(void 0===r){var i=new fe;i.userData.lights={};var n=P();i.userData.emissiveLight=n,i.add(n),r=re(),r.scene=i,He[e.uuid]=r}t.used=!0,r.used=!0;var a=t.scene,o=r.scene;o.userData.emissiveLight.visible=!je,Ie=a,Ue=o}function u(e,t,r,i){var n=t[e.uuid];return void 0===n&&(n=re(),n.material=r(e),t[e.uuid]=n),n.used=!0,i(n.material,e),tt[n.material.uuid]=e,n.material}function h(e,t,r){if(void 0!==e.material){if(Array.isArray(e.material))for(var i=0,n=e.material.length;i0&&(e.scale.set(1,1,1).multiplyScalar(r),e.position.setFromMatrixPosition(t.matrixWorld))}function G(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=s.distance,c=n.uniforms;c.lightColor.value.copy(s.color),l>0?(c.lightRadius.value=l,c.lightIntensity.value=s.intensity,c.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(Re.matrixWorldInverse)):c.lightRadius.value=1/0,B(c)}function W(e){var t=I(e,new xe(2,2));return t.onBeforeRender=H,t}function X(){var e=je?oy.spotLightPre:oy.spotLight,t=U(e);return t.depthTest=!1,t}function H(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightAngle.value=s.angle,l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity,l.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(Re.matrixWorldInverse);var c=l.lightDirectionVS.value,u=We;c.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),c.sub(u).normalize().transformDirection(Re.matrixWorldInverse),B(l)}function Y(e){var t=I(e,new xe(2,2));return t.onBeforeRender=Q,t}function q(){var e=je?oy.directionalLightPre:oy.directionalLight,t=U(e);return t.depthTest=!1,t}function Q(e,t,r,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity;var c=l.lightDirectionVS.value,u=We;c.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),c.sub(u).normalize().transformDirection(Re.matrixWorldInverse),B(l)}function J(e){if(void 0!==e.material&&(rt[e.uuid]=e.onBeforeRender,!ze&&!je&&e.visible))if(Array.isArray(e.material)){for(var t=0,r=e.material.length;tet&&delete e[n]):(e[n].used=!1,e[n].count=0)}}function ne(e){for(var t=Object.keys(e),r=0,i=t.length;r","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","\tvNormal = normalize( transformedNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",ny.packNormalDepth,"\tgl_FragColor = packedNormalDepth;","}"].join("\n")},color:{uniforms:{map:new ho(null),offsetRepeat:new ho(new v(0,0,1,1)),diffuse:new ho(new u(0)),emissive:new ho(new u(0)),specular:new ho(new u(0)),shininess:new ho(30)},vertexShader:["#include ","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","#include ","#include ",ny.packVector3,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;","#include ",ny.packColor,"\tgl_FragColor = packedColor;","}"].join("\n")},emissiveLight:{uniforms:Object.assign({samplerColor:new ho(null)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackColor,"\tgl_FragColor = vec4( emissiveColor, 1.0 );","}"].join("\n")},pointLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightPositionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1),lightRadius:new ho(1)},ay.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",ny.unpackColor,ny.computeSpecular,"\t//float cutoff = 0.3;","\t//float denom = distance / lightRadius + 1.0;","\t//float attenuation = 1.0 / ( denom * denom );","\t//attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );","\t//attenuation = max( attenuation, 0.0 );","\t//attenuation *= attenuation;","\t//diffuseColor *= saturate( -distance / lightRadius + 1.0 );","\t//float attenuation = 1.0;","\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",ny.combine,"}"].join("\n")},spotLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightPositionVS:new ho(new i(0,1,0)),lightAngle:new ho(1),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,ny.unpackColor,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}","\tdiffuseColor *= spot;",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.combine,"}"].join("\n")},directionalLight:{uniforms:Object.assign({samplerNormalDepth:new ho(null),samplerColor:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepth,ny.computeVertexPositionVS,ny.unpackColor,"\tvec3 lightVector = normalize( lightDirectionVS );",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.combine,"}"].join("\n")},normalDepthShininess:{uniforms:{shininess:new ho(30)},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","\tvNormal = normalize( transformedNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","uniform float shininess;",ny.packNormal,"void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",ny.packNormalDepthShininess,"\tgl_FragColor = packedNormalDepthShininess;","}"].join("\n")},pointLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightPositionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1),lightRadius:new ho(1)},ay.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",ny.computeSpecular,"\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",ny.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},spotLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightPositionVS:new ho(new i(0,1,0)),lightAngle:new ho(1),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.packLight,"\tgl_FragColor = spot * packedLight;","}"].join("\n")},directionalLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new ho(null),lightColor:new ho(new u(0)),lightDirectionVS:new ho(new i(0,1,0)),lightIntensity:new ho(1)},ay.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",ny.unpackFloat,ny.unpackVector2,"void main() {",ny.computeTextureCoord,ny.unpackNormalDepthShininess,ny.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightDirectionVS );",ny.computeSpecular,"\tconst float attenuation = 1.0;",ny.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},reconstruction:{uniforms:Object.assign({samplerLight:new ho(null),map:new ho(null),offsetRepeat:new ho(new v(0,0,1,1)),diffuse:new ho(new u(0)),emissive:new ho(new u(0)),specular:new ho(new u(0)),shininess:new ho(30)},ay.commonUniforms),vertexShader:["#include ","#include ","#include ","void main() {","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","}"].join("\n"),fragmentShader:["uniform sampler2D samplerLight;","uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","uniform float viewHeight;","uniform float viewWidth;","#include ","#include ",ny.unpackFloat,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",ny.computeTextureCoord,"\tvec4 light = texture2D( samplerLight, texCoord );","#include ","\tvec3 diffuseFinal = diffuseColor.rgb * light.rgb;","\tvec3 emissiveFinal = emissiveColor;","\tvec3 specularFinal = specularColor * light.rgb * light.a;","\tgl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );","}"].join("\n")},"final":{uniforms:{samplerResult:new ho(null)},vertexShader:["varying vec2 texCoord;","void main() {","\tvec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );","\ttexCoord = pos.xy * vec2( 0.5 ) + 0.5;","\tgl_Position = pos;","}"].join("\n"),fragmentShader:["varying vec2 texCoord;","uniform sampler2D samplerResult;","void main() {","\tgl_FragColor = texture2D( samplerResult, texCoord );","}"].join("\n")}};po.prototype=Object.create(P.prototype),fo.prototype=Object.create(P.prototype),mo.prototype=Object.create(P.prototype),vo.prototype=Object.create(P.prototype),go.prototype=Object.create(P.prototype);var sy={godrays_depthMask:{uniforms:{tInput:{value:null}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D tInput;","void main() {","\tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );","}"].join("\n")},godrays_generate:{uniforms:{tInput:{value:null},fStepSize:{value:1},vSunPositionScreenSpace:{value:new f(.5,.5)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define TAPS_PER_PASS 6.0","varying vec2 vUv;","uniform sampler2D tInput;","uniform vec2 vSunPositionScreenSpace;","uniform float fStepSize;","void main() {","vec2 delta = vSunPositionScreenSpace - vUv;","float dist = length( delta );","vec2 stepv = fStepSize * delta / dist;","float iters = dist/fStepSize;","vec2 uv = vUv.xy;","float col = 0.0;","if ( 0.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 1.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 2.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 3.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 4.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","if ( 5.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;","uv += stepv;","gl_FragColor = vec4( col/TAPS_PER_PASS );","gl_FragColor.a = 1.0;","}"].join("\n")},godrays_combine:{uniforms:{tColors:{value:null},tGodRays:{value:null},fGodRayIntensity:{value:.69},vSunPositionScreenSpace:{value:new f(.5,.5)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D tColors;","uniform sampler2D tGodRays;","uniform vec2 vSunPositionScreenSpace;","uniform float fGodRayIntensity;","void main() {","gl_FragColor = texture2D( tColors, vUv ) + fGodRayIntensity * vec4( 1.0 - texture2D( tGodRays, vUv ).r );","gl_FragColor.a = 1.0;","}"].join("\n")},godrays_fake_sun:{uniforms:{vSunPositionScreenSpace:{value:new f(.5,.5)},fAspect:{value:1},sunColor:{value:new u(16772608)},bgColor:{value:new u(0)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform vec2 vSunPositionScreenSpace;","uniform float fAspect;","uniform vec3 sunColor;","uniform vec3 bgColor;","void main() {","vec2 diff = vUv - vSunPositionScreenSpace;","diff.x *= fAspect;","float prop = clamp( length( diff ) / 0.5, 0.0, 1.0 );","prop = 0.35 * pow( 1.0 - prop, 3.0 );","gl_FragColor.xyz = mix( sunColor, bgColor, 1.0 - prop );","gl_FragColor.w = 1.0;","}"].join("\n")}},ly={uniforms:{},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["void main() {","gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );","}"].join("\n")},cy={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 base = texture2D( tDiffuse, vUv );","vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );","float lum = dot( lumCoeff, base.rgb );","vec3 blend = vec3( lum );","float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );","vec3 result1 = 2.0 * base.rgb * blend;","vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );","vec3 newColor = mix( result1, result2, L );","float A2 = opacity * base.a;","vec3 mixRGB = A2 * newColor.rgb;","mixRGB += ( ( 1.0 - A2 ) * base.rgb );","gl_FragColor = vec4( mixRGB, base.a );","}"].join("\n") +},uy={uniforms:{tDiffuse1:{value:null},tDiffuse2:{value:null},mixRatio:{value:.5},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform float mixRatio;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","varying vec2 vUv;","void main() {","vec4 texel1 = texture2D( tDiffuse1, vUv );","vec4 texel2 = texture2D( tDiffuse2, vUv );","gl_FragColor = opacity * mix( texel1, texel2, mixRatio );","}"].join("\n")},hy={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float brightness;","uniform float contrast;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","gl_FragColor.rgb += brightness;","if (contrast > 0.0) {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;","} else {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;","}","}"].join("\n")},dy={uniforms:{tDiffuse:{value:null},powRGB:{value:new i(2,2,2)},mulRGB:{value:new i(1,1,1)},addRGB:{value:new i(0,0,0)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 powRGB;","uniform vec3 mulRGB;","uniform vec3 addRGB;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );","}"].join("\n")},py={uniforms:{tDiffuse:{value:null},color:{value:new u(16777215)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","gl_FragColor = vec4( v * color, texel.w );","}"].join("\n")},fy={uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},maxblur:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float focus;","uniform float maxblur;","uniform sampler2D tColor;","uniform sampler2D tDepth;","varying vec2 vUv;","void main() {","vec4 depth = texture2D( tDepth, vUv );","float factor = depth.x - focus;","vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );","gl_FragColor = col;","gl_FragColor.a = 1.0;","}"].join("\n")},my={uniforms:{tDiffuse:{value:null},screenWidth:{value:1024},screenHeight:{value:1024},sampleDistance:{value:.94},waveFactor:{value:.00125}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float screenWidth;","uniform float screenHeight;","uniform float sampleDistance;","uniform float waveFactor;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 color, org, tmp, add;","float sample_dist, f;","vec2 vin;","vec2 uv = vUv;","add = color = org = texture2D( tDiffuse, uv );","vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );","sample_dist = dot( vin, vin ) * 2.0;","f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;","vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );","add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );","if( tmp.b < color.b ) color = tmp;","color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );","color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );","gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );","}"].join("\n")},vy={uniforms:{tDiffuse:{value:null},aspect:{value:new f(512,512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform vec2 aspect;","vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);","mat3 G[9];","const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );","const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );","const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );","const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );","const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );","const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );","const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );","const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );","const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );","void main(void)","{","G[0] = g0,","G[1] = g1,","G[2] = g2,","G[3] = g3,","G[4] = g4,","G[5] = g5,","G[6] = g6,","G[7] = g7,","G[8] = g8;","mat3 I;","float cnv[9];","vec3 sample;","for (float i=0.0; i<3.0; i++) {","for (float j=0.0; j<3.0; j++) {","sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;","I[int(i)][int(j)] = length(sample);","}","}","for (int i=0; i<9; i++) {","float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);","cnv[i] = dp3 * dp3;","}","float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);","float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);","gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);","}"].join("\n")},gy={uniforms:{mRefractionRatio:{value:1.02},mFresnelBias:{value:.1},mFresnelPower:{value:2},mFresnelScale:{value:1},tCube:{value:null}},vertexShader:["uniform float mRefractionRatio;","uniform float mFresnelBias;","uniform float mFresnelScale;","uniform float mFresnelPower;","varying vec3 vReflect;","varying vec3 vRefract[3];","varying float vReflectionFactor;","void main() {","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","vec3 I = worldPosition.xyz - cameraPosition;","vReflect = reflect( I, worldNormal );","vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );","vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );","vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );","vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","varying vec3 vReflect;","varying vec3 vRefract[3];","varying float vReflectionFactor;","void main() {","vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );","vec4 refractedColor = vec4( 1.0 );","refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;","refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;","refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;","gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );","}"].join("\n")},yy={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );","}"].join("\n")},xy={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float h;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},by={uniforms:{tDiffuse:{value:null},h:{value:1/512},r:{value:.35}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float h;","uniform float r;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","float hh = h * abs( r - vUv.y );","sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},wy={uniforms:{tDiffuse:{value:null},hue:{value:0},saturation:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float hue;","uniform float saturation;","varying vec2 vUv;","void main() {","gl_FragColor = texture2D( tDiffuse, vUv );","float angle = hue * 3.14159265;","float s = sin(angle), c = cos(angle);","vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;","float len = length(gl_FragColor.rgb);","gl_FragColor.rgb = vec3(","dot(gl_FragColor.rgb, weights.xyz),","dot(gl_FragColor.rgb, weights.zxy),","dot(gl_FragColor.rgb, weights.yzx)",");","float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;","if (saturation > 0.0) {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));","} else {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);","}","}"].join("\n")},_y={uniforms:{tDiffuse:{value:null},sides:{value:6},angle:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float sides;","uniform float angle;","varying vec2 vUv;","void main() {","vec2 p = vUv - 0.5;","float r = length(p);","float a = atan(p.y, p.x) + angle;","float tau = 2. * 3.1416 ;","a = mod(a, tau/sides);","a = abs(a - tau/sides/2.) ;","p = r * vec2(cos(a), sin(a));","vec4 color = texture2D(tDiffuse, p + 0.5);","gl_FragColor = color;","}"].join("\n")},Sy={uniforms:{tDiffuse:{value:null},side:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform int side;","varying vec2 vUv;","void main() {","vec2 p = vUv;","if (side == 0){","if (p.x > 0.5) p.x = 1.0 - p.x;","}else if (side == 1){","if (p.x < 0.5) p.x = 1.0 - p.x;","}else if (side == 2){","if (p.y < 0.5) p.y = 1.0 - p.y;","}else if (side == 3){","if (p.y > 0.5) p.y = 1.0 - p.y;","} ","vec4 color = texture2D(tDiffuse, p);","gl_FragColor = color;","}"].join("\n")},Ay={uniforms:{heightMap:{value:null},resolution:{value:new f(512,512)},scale:{value:new f(1,1)},height:{value:.05}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float height;","uniform vec2 resolution;","uniform sampler2D heightMap;","varying vec2 vUv;","void main() {","float val = texture2D( heightMap, vUv ).x;","float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;","float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;","gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );","}"].join("\n")},My={modes:{none:"NO_PARALLAX",basic:"USE_BASIC_PARALLAX",steep:"USE_STEEP_PARALLAX",occlusion:"USE_OCLUSION_PARALLAX",relief:"USE_RELIEF_PARALLAX"},uniforms:{bumpMap:{value:null},map:{value:null},parallaxScale:{value:null},parallaxMinLayers:{value:null},parallaxMaxLayers:{value:null}},vertexShader:["varying vec2 vUv;","varying vec3 vViewPosition;","varying vec3 vNormal;","void main() {","vUv = uv;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform sampler2D bumpMap;","uniform sampler2D map;","uniform float parallaxScale;","uniform float parallaxMinLayers;","uniform float parallaxMaxLayers;","varying vec2 vUv;","varying vec3 vViewPosition;","varying vec3 vNormal;","#ifdef USE_BASIC_PARALLAX","vec2 parallaxMap( in vec3 V ) {","float initialHeight = texture2D( bumpMap, vUv ).r;","vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;","return vUv - texCoordOffset;","}","#else","vec2 parallaxMap( in vec3 V ) {","float numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );","float layerHeight = 1.0 / numLayers;","float currentLayerHeight = 0.0;","vec2 dtex = parallaxScale * V.xy / V.z / numLayers;","vec2 currentTextureCoords = vUv;","float heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","for ( int i = 0; i < 30; i += 1 ) {","if ( heightFromTexture <= currentLayerHeight ) {","break;","}","currentLayerHeight += layerHeight;","currentTextureCoords -= dtex;","heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","}","#ifdef USE_STEEP_PARALLAX","return currentTextureCoords;","#elif defined( USE_RELIEF_PARALLAX )","vec2 deltaTexCoord = dtex / 2.0;","float deltaHeight = layerHeight / 2.0;","currentTextureCoords += deltaTexCoord;","currentLayerHeight -= deltaHeight;","const int numSearches = 5;","for ( int i = 0; i < numSearches; i += 1 ) {","deltaTexCoord /= 2.0;","deltaHeight /= 2.0;","heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;","if( heightFromTexture > currentLayerHeight ) {","currentTextureCoords -= deltaTexCoord;","currentLayerHeight += deltaHeight;","} else {","currentTextureCoords += deltaTexCoord;","currentLayerHeight -= deltaHeight;","}","}","return currentTextureCoords;","#elif defined( USE_OCLUSION_PARALLAX )","vec2 prevTCoords = currentTextureCoords + dtex;","float nextH = heightFromTexture - currentLayerHeight;","float prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;","float weight = nextH / ( nextH - prevH );","return prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );","#else","return vUv;","#endif","}","#endif","vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {","vec2 texDx = dFdx( vUv );","vec2 texDy = dFdy( vUv );","vec3 vSigmaX = dFdx( surfPosition );","vec3 vSigmaY = dFdy( surfPosition );","vec3 vR1 = cross( vSigmaY, surfNormal );","vec3 vR2 = cross( surfNormal, vSigmaX );","float fDet = dot( vSigmaX, vR1 );","vec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );","vec3 vProjVtex;","vProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;","vProjVtex.z = dot( surfNormal, viewPosition );","return parallaxMap( vProjVtex );","}","void main() {","vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );","gl_FragColor = texture2D( map, mapUv );","}"].join("\n")},Ty={uniforms:{tDiffuse:{value:null},resolution:{value:null},pixelSize:{value:1}},vertexShader:["varying highp vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float pixelSize;","uniform vec2 resolution;","varying highp vec2 vUv;","void main(){","vec2 dxy = pixelSize / resolution;","vec2 coord = dxy * floor( vUv / dxy );","gl_FragColor = texture2D(tDiffuse, coord);","}"].join("\n")},Ey={uniforms:{tDiffuse:{value:null},amount:{value:.005},angle:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float amount;","uniform float angle;","varying vec2 vUv;","void main() {","vec2 offset = amount * vec2( cos(angle), sin(angle));","vec4 cr = texture2D(tDiffuse, vUv + offset);","vec4 cga = texture2D(tDiffuse, vUv);","vec4 cb = texture2D(tDiffuse, vUv - offset);","gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);","}"].join("\n")},Cy={uniforms:{tDiffuse:{value:null},amount:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float amount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 color = texture2D( tDiffuse, vUv );","vec3 c = color.rgb;","color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );","color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );","color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );","gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );","}"].join("\n")},Ly={uniforms:{tDiffuse:{value:null},resolution:{value:new f}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","void main() {","vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );","const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );","const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );","float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;","float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;","float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;","float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;","float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;","float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;","float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;","float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;","float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;","float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ","Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ","Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ","float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ","Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ","Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ","float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );","gl_FragColor = vec4( vec3( G ), 1 );","}"].join("\n")},Py={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);","gl_FragColor = newTex;","}"].join("\n")},Ny={uniforms:{texture:{value:null},delta:{value:new f(1,1)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#define ITERATIONS 10.0","uniform sampler2D texture;","uniform vec2 delta;","varying vec2 vUv;","void main() {","vec4 color = vec4( 0.0 );","float total = 0.0;","float offset = rand( vUv );","for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {","float percent = ( t + offset - 0.5 ) / ITERATIONS;","float weight = 1.0 - abs( percent );","color += texture2D( texture, vUv + delta * percent ) * weight;","total += weight;","}","gl_FragColor = color / total;","}"].join("\n")},Oy={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float v;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},Dy={uniforms:{tDiffuse:{value:null},v:{value:1/512},r:{value:.35}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float v;","uniform float r;","varying vec2 vUv;","void main() {","vec4 sum = vec4( 0.0 );","float vv = v * abs( r - vUv.y );","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;","sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;","gl_FragColor = sum;","}"].join("\n")},Fy={uniforms:{tDiffuse:{value:null},offset:{value:1},darkness:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float offset;","uniform float darkness;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );","gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );","}"].join("\n")},Ry={uniforms:{color:{type:"c",value:null},time:{type:"f",value:0},tDiffuse:{type:"t",value:null},tDudv:{type:"t",value:null},textureMatrix:{type:"m4",value:null}},vertexShader:["uniform mat4 textureMatrix;","varying vec2 vUv;","varying vec4 vUvRefraction;","void main() {","\tvUv = uv;","\tvUvRefraction = textureMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform float time;","uniform sampler2D tDiffuse;","uniform sampler2D tDudv;","varying vec2 vUv;","varying vec4 vUvRefraction;","float blendOverlay( float base, float blend ) {","\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );","}","vec3 blendOverlay( vec3 base, vec3 blend ) {","\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ),blendOverlay( base.b, blend.b ) );","}","void main() {"," float waveStrength = 0.1;"," float waveSpeed = 0.03;","\tvec2 distortedUv = texture2D( tDudv, vec2( vUv.x + time * waveSpeed, vUv.y ) ).rg * waveStrength;","\tdistortedUv = vUv.xy + vec2( distortedUv.x, distortedUv.y + time * waveSpeed );","\tvec2 distortion = ( texture2D( tDudv, distortedUv ).rg * 2.0 - 1.0 ) * waveStrength;"," vec4 uv = vec4( vUvRefraction );"," uv.xy += distortion;","\tvec4 base = texture2DProj( tDiffuse, uv );","\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );","}"].join("\n")},Iy={skinSimple:{uniforms:Mu.merge([mp.fog,mp.lights,{enableBump:{value:0},enableSpecular:{value:0},tDiffuse:{value:null},tBeckmann:{value:null},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},opacity:{value:1},uRoughness:{value:.15},uSpecularBrightness:{value:.75},bumpMap:{value:null},bumpScale:{value:1},specularMap:{value:null},offsetRepeat:{value:new v(0,0,1,1)},uWrapRGB:{value:new i(.75,.375,.1875)}}]),fragmentShader:["#define USE_BUMPMAP","uniform bool enableBump;","uniform bool enableSpecular;","uniform vec3 diffuse;","uniform vec3 specular;","uniform float opacity;","uniform float uRoughness;","uniform float uSpecularBrightness;","uniform vec3 uWrapRGB;","uniform sampler2D tDiffuse;","uniform sampler2D tBeckmann;","uniform sampler2D specularMap;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.bsdfs,fp.packing,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.fog_pars_fragment,fp.bumpmap_pars_fragment,"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {","float base = 1.0 - dot( V, H );","float exponential = pow( base, 5.0 );","return exponential + F0 * ( 1.0 - exponential );","}","float KS_Skin_Specular( vec3 N,","vec3 L,","vec3 V,","float m,","float rho_s",") {","float result = 0.0;","float ndotl = dot( N, L );","if( ndotl > 0.0 ) {","vec3 h = L + V;","vec3 H = normalize( h );","float ndoth = dot( N, H );","float PH = pow( 2.0 * texture2D( tBeckmann, vec2( ndoth, m ) ).x, 10.0 );","float F = fresnelReflectance( H, V, 0.028 );","float frSpec = max( PH * F / dot( h, h ), 0.0 );","result = ndotl * rho_s * frSpec;","}","return result;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec4 colDiffuse = texture2D( tDiffuse, vUv );","colDiffuse.rgb *= colDiffuse.rgb;","diffuseColor = diffuseColor * colDiffuse;","vec3 normal = normalize( vNormal );","vec3 viewerDirection = normalize( vViewPosition );","float specularStrength;","if ( enableSpecular ) {","vec4 texelSpecular = texture2D( specularMap, vUv );","specularStrength = texelSpecular.r;","} else {","specularStrength = 1.0;","}","#ifdef USE_BUMPMAP","if ( enableBump ) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );","#endif","vec3 totalSpecularLight = vec3( 0.0 );","vec3 totalDiffuseLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 lVector = pointLights[ i ].position + vViewPosition.xyz;","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","lVector = normalize( lVector );","float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), uWrapRGB );","float pointSpecularWeight = KS_Skin_Specular( normal, lVector, viewerDirection, uRoughness, uSpecularBrightness );","totalDiffuseLight += pointLight[ i ].color * ( pointDiffuseWeight * attenuation );","totalSpecularLight += pointLight[ i ].color * specular * ( pointSpecularWeight * specularStrength * attenuation );","}","#endif","#if NUM_DIR_LIGHTS > 0","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );","float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3 ( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), uWrapRGB );","float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","totalSpecularLight += directionalLights[ i ].color * ( dirSpecularWeight * specularStrength );","}","#endif","#if NUM_HEMI_LIGHTS > 0","for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","vec3 lVector = hemisphereLightDirection[ i ];","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","totalDiffuseLight += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","float hemiSpecularWeight = 0.0;","hemiSpecularWeight += KS_Skin_Specular( normal, lVector, viewerDirection, uRoughness, uSpecularBrightness );","vec3 lVectorGround = -lVector;","hemiSpecularWeight += KS_Skin_Specular( normal, lVectorGround, viewerDirection, uRoughness, uSpecularBrightness );","vec3 hemiSpecularColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","totalSpecularLight += hemiSpecularColor * specular * ( hemiSpecularWeight * specularStrength );","}","#endif","outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor * diffuse ) + totalSpecularLight;","gl_FragColor = linearToOutputTexel( vec4( outgoingLight, diffuseColor.a ) );",fp.fog_fragment,"}"].join("\n"),vertexShader:["uniform vec4 offsetRepeat;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.lights_pars_begin,fp.shadowmap_pars_vertex,fp.fog_pars_vertex,"void main() {","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv * offsetRepeat.zw + offsetRepeat.xy;","gl_Position = projectionMatrix * mvPosition;",fp.shadowmap_vertex,fp.fog_vertex,"}"].join("\n") +},skin:{uniforms:Mu.merge([mp.fog,mp.lights,{passID:{value:0},tDiffuse:{value:null},tNormal:{value:null},tBlur1:{value:null},tBlur2:{value:null},tBlur3:{value:null},tBlur4:{value:null},tBeckmann:{value:null},uNormalScale:{value:1},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},opacity:{value:1},uRoughness:{value:.15},uSpecularBrightness:{value:.75}}]),fragmentShader:["uniform vec3 diffuse;","uniform vec3 specular;","uniform float opacity;","uniform float uRoughness;","uniform float uSpecularBrightness;","uniform int passID;","uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tBlur1;","uniform sampler2D tBlur2;","uniform sampler2D tBlur3;","uniform sampler2D tBlur4;","uniform sampler2D tBeckmann;","uniform float uNormalScale;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.lights_pars_begin,fp.fog_pars_fragment,"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {","float base = 1.0 - dot( V, H );","float exponential = pow( base, 5.0 );","return exponential + F0 * ( 1.0 - exponential );","}","float KS_Skin_Specular( vec3 N,","vec3 L,","vec3 V,","float m,","float rho_s",") {","float result = 0.0;","float ndotl = dot( N, L );","if( ndotl > 0.0 ) {","vec3 h = L + V;","vec3 H = normalize( h );","float ndoth = dot( N, H );","float PH = pow( 2.0 * texture2D( tBeckmann, vec2( ndoth, m ) ).x, 10.0 );","float F = fresnelReflectance( H, V, 0.028 );","float frSpec = max( PH * F / dot( h, h ), 0.0 );","result = ndotl * rho_s * frSpec;","}","return result;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec4 mSpecular = vec4( specular, opacity );","vec4 colDiffuse = texture2D( tDiffuse, vUv );","colDiffuse *= colDiffuse;","diffuseColor *= colDiffuse;","vec4 posAndU = vec4( -vViewPosition, vUv.x );","vec4 posAndU_dx = dFdx( posAndU ), posAndU_dy = dFdy( posAndU );","vec3 tangent = posAndU_dx.w * posAndU_dx.xyz + posAndU_dy.w * posAndU_dy.xyz;","vec3 normal = normalize( vNormal );","vec3 binormal = normalize( cross( tangent, normal ) );","tangent = cross( normal, binormal );","mat3 tsb = mat3( tangent, binormal, normal );","vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","vec3 finalNormal = tsb * normalTex;","normal = normalize( finalNormal );","vec3 viewerDirection = normalize( vViewPosition );","vec3 totalDiffuseLight = vec3( 0.0 );","vec3 totalSpecularLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 pointVector = normalize( pointLights[ i ].direction );","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );","totalDiffuseLight += pointLightColor[ i ] * ( pointDiffuseWeight * attenuation );","if ( passID == 1 ) {","float pointSpecularWeight = KS_Skin_Specular( normal, pointVector, viewerDirection, uRoughness, uSpecularBrightness );","totalSpecularLight += pointLightColor[ i ] * mSpecular.xyz * ( pointSpecularWeight * attenuation );","}","}","#endif","#if NUM_DIR_LIGHTS > 0","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","if ( passID == 1 ) {","float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewerDirection, uRoughness, uSpecularBrightness );","totalSpecularLight += directionalLights[ i ].color * mSpecular.xyz * dirSpecularWeight;","}","}","#endif","outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalSpecularLight );","if ( passID == 0 ) {","outgoingLight = sqrt( outgoingLight );","} else if ( passID == 1 ) {","#ifdef VERSION1","vec3 nonblurColor = sqrt(outgoingLight );","#else","vec3 nonblurColor = outgoingLight;","#endif","vec3 blur1Color = texture2D( tBlur1, vUv ).xyz;","vec3 blur2Color = texture2D( tBlur2, vUv ).xyz;","vec3 blur3Color = texture2D( tBlur3, vUv ).xyz;","vec3 blur4Color = texture2D( tBlur4, vUv ).xyz;","outgoingLight = vec3( vec3( 0.22, 0.437, 0.635 ) * nonblurColor + ","vec3( 0.101, 0.355, 0.365 ) * blur1Color + ","vec3( 0.119, 0.208, 0.0 ) * blur2Color + ","vec3( 0.114, 0.0, 0.0 ) * blur3Color + ","vec3( 0.444, 0.0, 0.0 ) * blur4Color );","outgoingLight *= sqrt( colDiffuse.xyz );","outgoingLight += ambientLightColor * diffuse * colDiffuse.xyz + totalSpecularLight;","#ifndef VERSION1","outgoingLight = sqrt( outgoingLight );","#endif","}","gl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.fog_fragment,"}"].join("\n"),vertexShader:["#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.fog_pars_vertex,"void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv;","#ifdef VERTEX_TEXTURES","vec3 dv = texture2D( tDisplacement, uv ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;","gl_Position = projectionMatrix * displacedPosition;","#else","gl_Position = projectionMatrix * mvPosition;","#endif",fp.fog_vertex,"}"].join("\n"),vertexShaderUV:["varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,"void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vViewPosition = -mvPosition.xyz;","vNormal = normalize( normalMatrix * normal );","vUv = uv;","gl_Position = vec4( uv.x * 2.0 - 1.0, uv.y * 2.0 - 1.0, 0.0, 1.0 );","}"].join("\n")},beckmann:{uniforms:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","float PHBeckmann( float ndoth, float m ) {","float alpha = acos( ndoth );","float ta = tan( alpha );","float val = 1.0 / ( m * m * pow( ndoth, 4.0 ) ) * exp( -( ta * ta ) / ( m * m ) );","return val;","}","float KSTextureCompute( vec2 tex ) {","return 0.5 * pow( PHBeckmann( tex.x, tex.y ), 0.1 );","}","void main() {","float x = KSTextureCompute( vUv );","gl_FragColor = vec4( x, x, x, 1.0 );","}"].join("\n")}},Uy={terrain:{uniforms:Mu.merge([mp.fog,mp.lights,{enableDiffuse1:{value:0},enableDiffuse2:{value:0},enableSpecular:{value:0},enableReflection:{value:0},tDiffuse1:{value:null},tDiffuse2:{value:null},tDetail:{value:null},tNormal:{value:null},tSpecular:{value:null},tDisplacement:{value:null},uNormalScale:{value:1},uDisplacementBias:{value:0},uDisplacementScale:{value:1},diffuse:{value:new u(15658734)},specular:{value:new u(1118481)},shininess:{value:30},opacity:{value:1},uRepeatBase:{value:new f(1,1)},uRepeatOverlay:{value:new f(1,1)},uOffset:{value:new f(0,0)}}]),fragmentShader:["uniform vec3 diffuse;","uniform vec3 specular;","uniform float shininess;","uniform float opacity;","uniform bool enableDiffuse1;","uniform bool enableDiffuse2;","uniform bool enableSpecular;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","uniform sampler2D tDetail;","uniform sampler2D tNormal;","uniform sampler2D tSpecular;","uniform sampler2D tDisplacement;","uniform float uNormalScale;","uniform vec2 uRepeatOverlay;","uniform vec2 uRepeatBase;","uniform vec2 uOffset;","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,fp.bsdfs,fp.lights_pars_begin,fp.shadowmap_pars_fragment,fp.fog_pars_fragment,"float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {","if ( decayExponent > 0.0 ) {","return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );","}","return 1.0;","}","void main() {","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","vec3 specularTex = vec3( 1.0 );","vec2 uvOverlay = uRepeatOverlay * vUv + uOffset;","vec2 uvBase = uRepeatBase * vUv;","vec3 normalTex = texture2D( tDetail, uvOverlay ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","if( enableDiffuse1 && enableDiffuse2 ) {","vec4 colDiffuse1 = texture2D( tDiffuse1, uvOverlay );","vec4 colDiffuse2 = texture2D( tDiffuse2, uvOverlay );","colDiffuse1 = GammaToLinear( colDiffuse1, float( GAMMA_FACTOR ) );","colDiffuse2 = GammaToLinear( colDiffuse2, float( GAMMA_FACTOR ) );","diffuseColor *= mix ( colDiffuse1, colDiffuse2, 1.0 - texture2D( tDisplacement, uvBase ) );"," } else if( enableDiffuse1 ) {","diffuseColor *= texture2D( tDiffuse1, uvOverlay );","} else if( enableDiffuse2 ) {","diffuseColor *= texture2D( tDiffuse2, uvOverlay );","}","if( enableSpecular )","specularTex = texture2D( tSpecular, uvOverlay ).xyz;","mat3 tsb = mat3( vTangent, vBinormal, vNormal );","vec3 finalNormal = tsb * normalTex;","vec3 normal = normalize( finalNormal );","vec3 viewPosition = normalize( vViewPosition );","vec3 totalDiffuseLight = vec3( 0.0 );","vec3 totalSpecularLight = vec3( 0.0 );","#if NUM_POINT_LIGHTS > 0","for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","vec3 lVector = pointLights[ i ].position + vViewPosition.xyz;","float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );","lVector = normalize( lVector );","vec3 pointHalfVector = normalize( lVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );","float pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );","totalDiffuseLight += attenuation * pointLights[ i ].color * pointDiffuseWeight;","totalSpecularLight += attenuation * pointLights[ i ].color * specular * pointSpecularWeight * pointDiffuseWeight;","}","#endif","#if NUM_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < NUM_DIR_LIGHTS; i++ ) {","vec3 dirVector = directionalLights[ i ].direction;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","float dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );","totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeight;","totalSpecularLight += directionalLights[ i ].color * specular * dirSpecularWeight * dirDiffuseWeight;","}","#endif","#if NUM_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","vec3 lVector = hemisphereLightDirection[ i ];","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","totalDiffuseLight += mix( hemisphereLights[ i ].groundColor, hemisphereLights[ i ].skyColor, hemiDiffuseWeight );","float hemiSpecularWeight = 0.0;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","hemiSpecularWeight += specularTex.r * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","hemiSpecularWeight += specularTex.r * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );","totalSpecularLight += specular * mix( hemisphereLights[ i ].groundColor, hemisphereLights[ i ].skyColor, hemiDiffuseWeight ) * hemiSpecularWeight * hemiDiffuseWeight;","}","#endif","outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor + totalSpecularLight );","gl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;","uniform vec2 uRepeatBase;","uniform sampler2D tNormal;","#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.shadowmap_pars_vertex,fp.fog_pars_vertex,"void main() {","vNormal = normalize( normalMatrix * normal );","vTangent = normalize( normalMatrix * tangent.xyz );","vBinormal = cross( vNormal, vTangent ) * tangent.w;","vBinormal = normalize( vBinormal );","vUv = uv;","vec2 uvBase = uv * uRepeatBase;","#ifdef VERTEX_TEXTURES","vec3 dv = texture2D( tDisplacement, uvBase ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","vec3 displacedPosition = normal * df + position;","vec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );","#else","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","#endif","gl_Position = projectionMatrix * mvPosition;","vViewPosition = -mvPosition.xyz;","vec3 normalTex = texture2D( tNormal, uvBase ).xyz * 2.0 - 1.0;","vNormal = normalMatrix * normalTex;",fp.shadowmap_vertex,fp.fog_vertex,"}"].join("\n")}},ky={toon1:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)}},vertexShader:["varying vec3 vNormal;","varying vec3 vRefract;","void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","vNormal = normalize( normalMatrix * normal );","vec3 I = worldPosition.xyz - cameraPosition;","vRefract = refract( normalize( I ), worldNormal, 1.02 );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","varying vec3 vRefract;","void main() {","float directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","float intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );","intensity += length(lightWeighting) * 0.2;","float cameraWeighting = dot( normalize( vNormal ), vRefract );","intensity += pow( 1.0 - length( cameraWeighting ), 6.0 );","intensity = intensity * 0.2 + 0.3;","if ( intensity < 0.50 ) {","gl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );","} else {","gl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );","}","}"].join("\n")},toon2:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(15658734)},uLineColor1:{value:new u(8421504)},uLineColor2:{value:new u(0)},uLineColor3:{value:new u(0)},uLineColor4:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);","float light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {","gl_FragColor *= vec4( uLineColor1, 1.0 );","}","if ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {","gl_FragColor *= vec4( uLineColor2, 1.0 );","}","}"].join("\n")},hatching:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)},uLineColor1:{value:new u(0)},uLineColor2:{value:new u(0)},uLineColor3:{value:new u(0)},uLineColor4:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","if ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","if ( length(lightWeighting) < 0.75 ) {","if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor2, 1.0 );","}","}","if ( length(lightWeighting) < 0.50 ) {","if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor3, 1.0 );","}","}","if ( length(lightWeighting) < 0.3465 ) {","if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {","gl_FragColor = vec4( uLineColor4, 1.0 );","}","}","}"].join("\n")},dotted:{uniforms:{uDirLightPos:{value:new i},uDirLightColor:{value:new u(15658734)},uAmbientLightColor:{value:new u(328965)},uBaseColor:{value:new u(16777215)},uLineColor1:{value:new u(0)}},vertexShader:["varying vec3 vNormal;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","if ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","if ( length(lightWeighting) < 0.50 ) {","if ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {","gl_FragColor = vec4( uLineColor1, 1.0 );","}","}","}"].join("\n")}},By=function(){this.uniforms=Mu.merge([mp.common,mp.lights,{color:{value:new u(16777215)},diffuse:{value:new u(16777215)},specular:{value:new u(16777215)},emissive:{value:new u(0)},opacity:{value:1},shininess:{value:1},thicknessMap:{value:null},thicknessColor:{value:new u(16777215)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),this.fragmentShader=["#define USE_MAP","#define PHONG","#define TRANSLUCENT","#include ","#include ","#include ","#include ","#include ","varying vec3 vColor;","uniform vec3 diffuse;","uniform vec3 specular;","uniform vec3 emissive;","uniform float opacity;","uniform float shininess;","uniform sampler2D thicknessMap;","uniform float thicknessPower;","uniform float thicknessScale;","uniform float thicknessDistortion;","uniform float thicknessAmbient;","uniform float thicknessAttenuation;","uniform vec3 thicknessColor;",fp.lights_pars_begin,"void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {","\tvec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;","\tvec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));","\tfloat scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;","\tvec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;","\treflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;","}","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 viewerDirection = normalize( vViewPosition );","\tvec4 diffuseColor = vec4( diffuse, opacity );","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",fp.map_fragment,fp.color_fragment,fp.specularmap_fragment,"\tvec3 totalEmissiveRadiance = emissive;",fp.lights_phong_fragment,"\tGeometricContext geometry;","\tgeometry.position = - vViewPosition;","\tgeometry.normal = normal;","\tgeometry.viewDir = normalize( vViewPosition );","\tIncidentLight directLight;","\t#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )","\t\tPointLight pointLight;","\t\t#pragma unroll_loop","\t\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {","\t\t \tpointLight = pointLights[ i ];","\t\t \tgetPointDirectLightIrradiance( pointLight, geometry, directLight );","\t\t\t#ifdef USE_SHADOWMAP","\t\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;","\t\t\t#endif","\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );","\t\t\t#if defined( TRANSLUCENT ) && defined( USE_MAP )","\t\t\tRE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","\t\t\t#endif","\t\t}","\t\t#endif","\t#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )","\t\tDirectionalLight directionalLight;","\t\t#pragma unroll_loop","\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {","\t\t\tdirectionalLight = directionalLights[ i ];","\t\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );","\t\t\t#ifdef USE_SHADOWMAP","\t\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;","\t\t\t#endif","\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );","\t\t\t#if defined( TRANSLUCENT ) && defined( USE_MAP )","\t\t\tRE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","\t\t\t#endif","\t\t}","\t#endif","\t#if defined( RE_IndirectDiffuse )","\t\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );","\t\t#if ( NUM_HEMI_LIGHTS > 0 )","\t\t\t#pragma unroll_loop","\t\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {","\t\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );","\t\t\t}","\t\t#endif","\t#endif","\t#if defined( RE_IndirectSpecular )","\t\tvec3 radiance = vec3( 0.0 );","\t\tvec3 clearCoatRadiance = vec3( 0.0 );","\t#endif",fp.lights_fragment_end,"\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;","\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );",fp.encodings_fragment,"}"].join("\n"),this.vertexShader=["varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vViewPosition;",fp.common,"void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvViewPosition = -mvPosition.xyz;","\tvNormal = normalize( normalMatrix * normal );","\tvUv = uv;","\tgl_Position = projectionMatrix * mvPosition;","}"].join("\n")},zy=function(e){var t=this;void 0==e&&(e=Math),this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(var r=0;r<256;r++)t.p[r]=Math.floor(256*e.random());this.perm=[];for(var r=0;r<512;r++)t.perm[r]=t.p[255&r];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]};zy.prototype.dot=function(e,t,r){return e[0]*t+e[1]*r},zy.prototype.dot3=function(e,t,r,i){return e[0]*t+e[1]*r+e[2]*i},zy.prototype.dot4=function(e,t,r,i,n){return e[0]*t+e[1]*r+e[2]*i+e[3]*n},zy.prototype.noise=function(e,t){var r,i,n,a,o,s=.5*(Math.sqrt(3)-1),l=(e+t)*s,c=Math.floor(e+l),u=Math.floor(t+l),h=(3-Math.sqrt(3))/6,d=(c+u)*h,p=c-d,f=u-d,m=e-p,v=t-f;m>v?(a=1,o=0):(a=0,o=1);var g=m-a+h,y=v-o+h,x=m-1+2*h,b=v-1+2*h,w=255&c,_=255&u,S=this.perm[w+this.perm[_]]%12,A=this.perm[w+a+this.perm[_+o]]%12,M=this.perm[w+1+this.perm[_+1]]%12,T=.5-m*m-v*v;T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[S],m,v));var E=.5-g*g-y*y;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[A],g,y));var C=.5-x*x-b*b;return C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[M],x,b)),70*(r+i+n)},zy.prototype.noise3d=function(e,t,r){var i,n,a,o,s,l,c,u,h,d,p=1/3,f=(e+t+r)*p,m=Math.floor(e+f),v=Math.floor(t+f),g=Math.floor(r+f),y=1/6,x=(m+v+g)*y,b=m-x,w=v-x,_=g-x,S=e-b,A=t-w,M=r-_;S>=A?A>=M?(s=1,l=0,c=0,u=1,h=1,d=0):S>=M?(s=1,l=0,c=0,u=1,h=0,d=1):(s=0,l=0,c=1,u=1,h=0,d=1):AU?32:0,j=I>k?16:0,V=U>k?8:0,G=I>B?4:0,W=U>B?2:0,X=k>B?1:0,H=z+j+V+G+W+X;c=_[H][0]>=3?1:0,u=_[H][1]>=3?1:0,h=_[H][2]>=3?1:0,d=_[H][3]>=3?1:0,p=_[H][0]>=2?1:0,f=_[H][1]>=2?1:0,m=_[H][2]>=2?1:0,v=_[H][3]>=2?1:0,g=_[H][0]>=1?1:0,y=_[H][1]>=1?1:0,x=_[H][2]>=1?1:0,b=_[H][3]>=1?1:0;var Y=I-c+M,q=U-u+M,Q=k-h+M,J=B-d+M,Z=I-p+2*M,K=U-f+2*M,$=k-m+2*M,ee=B-v+2*M,te=I-g+3*M,re=U-y+3*M,ie=k-x+3*M,ne=B-b+3*M,ae=I-1+4*M,oe=U-1+4*M,se=k-1+4*M,le=B-1+4*M,ce=255&E,ue=255&C,he=255&L,de=255&P,pe=S[ce+S[ue+S[he+S[de]]]]%32,fe=S[ce+c+S[ue+u+S[he+h+S[de+d]]]]%32,me=S[ce+p+S[ue+f+S[he+m+S[de+v]]]]%32,ve=S[ce+g+S[ue+y+S[he+x+S[de+b]]]]%32,ge=S[ce+1+S[ue+1+S[he+1+S[de+1]]]]%32,ye=.6-I*I-U*U-k*k-B*B;ye<0?n=0:(ye*=ye,n=ye*ye*this.dot4(w[pe],I,U,k,B));var xe=.6-Y*Y-q*q-Q*Q-J*J;xe<0?a=0:(xe*=xe,a=xe*xe*this.dot4(w[fe],Y,q,Q,J));var be=.6-Z*Z-K*K-$*$-ee*ee;be<0?o=0:(be*=be,o=be*be*this.dot4(w[me],Z,K,$,ee));var we=.6-te*te-re*re-ie*ie-ne*ne;we<0?s=0:(we*=we,s=we*we*this.dot4(w[ve],te,re,ie,ne));var _e=.6-ae*ae-oe*oe-se*se-le*le;return _e<0?l=0:(_e*=_e,l=_e*_e*this.dot4(w[ge],ae,oe,se,le)),27*(n+a+o+s+l)};var jy=function(e,t,r){this._scene=e,this._trackInfo=t,this._onUpdate=r,this._mixer=new ae(e),this._clip=null,this._action=null,this._tracks={},this._propRefs={},this._channelNames=[]};jy.prototype={constructor:jy,init:function(e){for(var t=this,r=[],i=this._trackInfo,n=0,a=i.length;n!==a;++n){var o=i[n];r.push(t._addTrack(o.type,o.propertyPath,o.initialValue,o.interpolation))}this._clip=new re("editclip",0,r),this._action=this._mixer.clipAction(this._clip).play()},setDisplayTime:function(e){this._action.time=e,this._mixer.update(0),this._onUpdate()},setDuration:function(e){this._clip.duration=e},getChannelNames:function(){return this._channelNames},getChannelKeyTimes:function(e){return this._tracks[e].times},setKeyframe:function(e,t){var r=this._tracks[e],i=r.times,n=Timeliner.binarySearch(i,t),a=r.values,o=r.getValueSize(),s=n*o;if(n<0){n=~n,s=n*o;for(var l=i.length+1,c=a.length+o,u=l-1;u!==n;--u)i[u]=i[u-1];for(var u=c-1,h=s+o-1;u!==h;--u)a[u]=a[u-o]}i[n]=t,this._propRefs[e].getValue(a,s)},delKeyframe:function(e,t){var r=this._tracks[e],i=r.times,n=Timeliner.binarySearch(i,t);if(i.length>1&&n>=0){for(var a=i.length-1,o=r.values,s=r.getValueSize(),l=o.length-s,c=n;c!==a;++c)i[c]=i[c+1];i.pop();for(var u=n*s;u!==l;++u)o[u]=o[u+s];o.length=l}},moveKeyframe:function(e,t,r,i){var n=this._tracks[e],a=n.times,o=Timeliner.binarySearch(a,t);if(o>=0){for(var s=i?a.length:o+1,l=a[o-1]<=t||!i&&t>=a[o+1];o!==s;)a[o++]+=r;l&&this._sort(n)}},serialize:function(){for(var e={duration:this._clip.duration,channels:{}},t=this._channelNames,r=this._tracks,i=e.channels,n=0,a=t.length;n!==a;++n){var o=t[n],s=r[o];i[o]={times:s.times,values:s.values}}return e},deserialize:function(e){var t=this,r=this._channelNames,i=this._tracks,n=e.channels;this.setDuration(e.duration);for(var a=0,o=r.length;a!==o;++a){var s=r[a],l=i[s],c=n[s];t._setArray(l.times,c.times),t._setArray(l.values,c.values)}this.setDisplayTime(this._mixer.time)},_sort:function(e){var t=e.times,r=wu.getKeyframeOrder(t);this._setArray(t,wu.sortedArray(t,1,r));var i=e.values,n=e.getValueSize();this._setArray(i,wu.sortedArray(i,n,r))},_setArray:function(e,t){e.length=0,e.push.apply(e,t)},_addTrack:function(e,t,r,i){var n=new e(t,[0],r,i);return n.times=Array.prototype.slice.call(n.times),n.values=Array.prototype.slice.call(n.values),this._channelNames.push(t),this._tracks[t]=n,this._propRefs[t]=new W(this._scene,t),n}};var Vy={};Vy.quicksortIP=function(e,t,r){for(var i,n,a=[],o=-1,s=0,l=e.length/t-1,c=0,u=0,h=0,d=function(r,i){for(r*=t,i*=t,h=0;h=s&&e[i*t+r]>p[r];){for(u=0;u>1;for(i=s+1,n=l,d(m,i),e[s*t+r]>e[l*t+r]&&d(s,l),e[i*t+r]>e[l*t+r]&&d(i,l),e[s*t+r]>e[i*t+r]&&d(s,i),u=0;uf[r]);if(n=n-s?(a[++o]=i,a[++o]=l,l=n-1):(a[++o]=s,a[++o]=n-1,s=i)}return e}, +Vy.Kdtree=function(e,t,r){function i(e,t,s,l){var c,u,h=t%r,d=e.length/r;return t>a&&(a=t),0===d?null:1===d?new n.Node(o(e,0),t,s,l):(Vy.quicksortIP(e,r,h),c=Math.floor(d/2),u=new n.Node(o(e,c),t,s,c+l),u.left=i(e.subarray(0,c*r),t+1,u,l),u.right=i(e.subarray((c+1)*r,e.length),t+1,u,l+c+1),u)}var n=this,a=0,o=function(e,t){return e.subarray(t*r,t*r+r)};this.root=i(e,0,null,0),this.getMaxDepth=function(){return a},this.nearest=function(e,i,a){function o(n){function a(e,t){c.push([e,t]),c.size()>i&&c.pop()}var s,l,u,h=n.depth%r,d=t(e,n.obj),p=0,f=[];for(u=0;u0&&(this.content[0]=t,this.sinkDown(0)),e},peek:function(){return this.content[0]},remove:function(e){for(var t=this,r=this.content.length,i=0;i0;){var i=Math.floor((e+1)/2)-1,n=t.content[i];if(!(t.scoreFunction(r)1&&(o=1-o,s=1-s);var l=1-o-s;return a.copy(t),a.multiplyScalar(o),e.copy(r),e.multiplyScalar(s),a.add(e),e.copy(n),e.multiplyScalar(l),a.add(e),a}}(),randomPointInFace:function(e,t){var r,i,n;return r=t.vertices[e.a],i=t.vertices[e.b],n=t.vertices[e.c],Wy.randomPointInTriangle(r,i,n)},randomPointsInGeometry:function(e,t){function r(e){function t(r,i){if(ie?t(r,n-1):d[n]e?t(r,n-1):u[n].95&&h.fillText(r,n.x%1*c,(1-n.y)*u),h.font="8pt Arial bold",h.fillStyle="rgba( 0, 0, 0, 1.0 )",o=0,s=t.length;o.95&&h.fillText(i[o]+d,a.x%1*c,(1-a.y)*u)}}var i="abc",n=new f,a=new f,o=[new f,new f,new f],s=[],l=document.createElement("canvas"),c=t||1024,u=t||1024;l.width=c,l.height=u;var h=l.getContext("2d");if(h.lineWidth=2,h.strokeStyle="rgba( 0, 0, 0, 1.0 )",h.textAlign="center",h.fillStyle="rgba( 255, 255, 255, 1.0 )",h.fillRect(0,0,c,u),e.isGeometry)for(var d=e.faces,p=e.faceVertexUvs[0],m=0,v=p.length;m=e.colorMap.length?g%e.colorMap.length+1:g;var y=e.colorMap[g];l[4*f]=y>>24&255,l[4*f+1]=y>>16&255,l[4*f+2]=y>>8&255,l[4*f+3]=255&y,f++}else for(var m=0;m=x&&h<=x?b:0,x=Math.floor(255*(x-d)/(p-d)),x=x>255?255:x<0?0:0|x,l[4*f]=x,l[4*f+1]=x,l[4*f+2]=x,l[4*f+3]=b,f++}o.putImageData(s,0,0),this.ctx.drawImage(a,0,0,t,r,0,0,this.canvas.width,this.canvas.height),this.mesh.material.map.needsUpdate=!0},updateGeometry:function(){var e=this.volume.extractPerpendicularPlane(this.axis,this.index);this.sliceAccess=e.sliceAccess,this.jLength=e.jLength,this.iLength=e.iLength,this.matrix=e.matrix,this.canvas.width=e.planeWidth,this.canvas.height=e.planeHeight,this.canvasBuffer.width=this.iLength,this.canvasBuffer.height=this.jLength,this.ctx=this.canvas.getContext("2d"),this.ctxBuffer=this.canvasBuffer.getContext("2d"),this.geometry=new xe(e.planeWidth,e.planeHeight),this.mesh&&(this.mesh.geometry=this.geometry,this.mesh.matrix=(new r).identity(),this.mesh.applyMatrix(this.matrix)),this.geometryNeedsUpdate=!1}};var Zy=function(){function e(){for(var e=navigator.getGamepads&&navigator.getGamepads(),t=0;t<4;t++){var r=e[t];if(r&&"Daydream Controller"===r.id)return r}}c.call(this);var t,r=this,n=[0,0],a=!1,o=new i;this.matrixAutoUpdate=!1,this.getGamepad=function(){return t},this.getTouchpadState=function(){return a},this.update=function(){if(t=e(),void 0!==t&&void 0!==t.pose){var i=t.pose;if(null===i)return;null!==i.orientation&&r.quaternion.fromArray(i.orientation),r.updateMatrix(),r.visible=!0,null===i.angularVelocity||o.equals(i.angularVelocity)||(o.fromArray(i.angularVelocity),r.dispatchEvent({type:"angularvelocitychanged",angularVelocity:o})),n[0]===t.axes[0]&&n[1]===t.axes[1]||(n[0]=t.axes[0],n[1]=t.axes[1],r.dispatchEvent({type:"axischanged",axes:n})),a!==t.buttons[0].pressed&&(a=t.buttons[0].pressed,r.dispatchEvent({type:a?"touchpaddown":"touchpadup"}))}else r.visible=!1},this.getTouchPadState=function(){return console.warn("DaydreamController: getTouchPadState() is now getTouchpadState()"),a}};Zy.prototype=Object.create(c.prototype),Zy.prototype.constructor=Zy;var Ky=function(){function e(){for(var e=navigator.getGamepads&&navigator.getGamepads(),t=0;t<4;t++){var r=e[t];if(r&&("Gear VR Controller"===r.id||"Oculus Go Controller"===r.id))return r}}c.call(this);var t,r=this,n=[0,0],a=!1,o=!1,s=new i;this.matrixAutoUpdate=!0,this.getGamepad=function(){return t},this.getTouchpadState=function(){return a},this.update=function(){if(t=e(),void 0!==t&&void 0!==t.pose){var i=t.pose;if(null===i)return;null!==i.orientation&&r.quaternion.fromArray(i.orientation),r.updateMatrix(),r.visible=!0,null===i.angularVelocity||s.equals(i.angularVelocity)||(s.fromArray(i.angularVelocity),r.dispatchEvent({type:"angularvelocitychanged",angularVelocity:s})),n[0]===t.axes[0]&&n[1]===t.axes[1]||(n[0]=t.axes[0],n[1]=t.axes[1],r.dispatchEvent({type:"axischanged",axes:n})),a!==t.buttons[0].pressed&&(a=t.buttons[0].pressed,r.dispatchEvent({type:a?"touchpaddown":"touchpadup",axes:n})),o!==t.buttons[1].pressed&&(o=t.buttons[1].pressed,r.dispatchEvent({type:o?"triggerdown":"triggerup"}))}else r.visible=!1},this.getTouchPadState=function(){return console.warn("GearVRController: getTouchPadState() is now getTouchpadState()"),a},this.setHand=function(){console.warn("GearVRController: setHand() has been removed.")}};Ky.prototype=Object.create(c.prototype),Ky.prototype.constructor=Ky;var $y=function(e){function t(e){for(var t=navigator.getGamepads&&navigator.getGamepads(),r=0,i=0;r0?r(e[0]):n()})["catch"](n),o}var s=document.createElement("a");return s.href="https://webvr.info",s.innerHTML="WEBVR NOT SUPPORTED",s.style.left="calc(50% - 90px)",s.style.width="180px",s.style.textDecoration="none",a(s),s},checkAvailability:function(){return console.warn("WEBVR.checkAvailability has been deprecated."),new Promise(function(){})},getMessageContainer:function(){return console.warn("WEBVR.getMessageContainer has been deprecated."),document.createElement("div")},getButton:function(){return console.warn("WEBVR.getButton has been deprecated."),document.createElement("div")},getVRDisplay:function(){console.warn("WEBVR.getVRDisplay has been deprecated.")}};Object.assign(Eo.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=arguments,t=this._objects,r=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,a=this._paths,o=this._parsedPaths,s=this._bindings,l=s.length,c=void 0,u=0,h=arguments.length;u!==h;++u){var d=e[u],p=d.uuid,f=n[p];if(void 0===f){f=r++,n[p]=f,t.push(d);for(var m=0,v=l;m!==v;++m)s[m].push(new W(d,a[m],o[m]))}else if(f=r){var h=r++,d=t[h];i[d.uuid]=u,t[u]=d,i[c]=h,t[h]=l;for(var p=0,f=a;p!==f;++p){var m=n[p],v=m[h],g=m[u];m[u]=v,m[h]=g}}}this.nCachedObjects_=r},uncache:function(){for(var e=arguments,t=this._objects,r=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,a=this._bindings,o=a.length,s=0,l=arguments.length;s!==l;++s){var c=e[s],u=c.uuid,h=n[u];if(void 0!==h)if(delete n[u],h0){this.source.connect(this.filters[0]);for(var t=1,r=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,r=this.filters.length;t.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(r.z,0,-r.x).normalize(),e=Math.acos(r.y),this.quaternion.setFromAxisAngle(t,e))}}(),as.prototype.setLength=function(e,t,r){void 0===t&&(t=.2*e),void 0===r&&(r=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()},as.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},os.prototype=Object.create(Yt.prototype),os.prototype.constructor=os,ss.prototype=Object.create(Yt.prototype),ss.prototype.constructor=ss,ss.prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),c.prototype.updateMatrixWorld.call(this,e))},ls.prototype=Object.create(Yt.prototype),ls.prototype.constructor=ls,ls.prototype.update=function(){function e(e,i,o,s){n.set(i,o,s).unproject(a);var l=r[e];if(void 0!==l)for(var c=t.getAttribute("position"),u=0,h=l.length;u1){e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;a0){var a=new be(t),o=new Ie(a);o.setCrossOrigin(this.crossOrigin);for(var s=0,l=e.length;s0?new Rt(s,l):new k(s,l);break;case"LOD":a=new Ts;break;case"Line":a=new B(i(e.geometry),n(e.material),e.mode);break;case"LineLoop":a=new Jt(i(e.geometry),n(e.material));break;case"LineSegments":a=new Yt(i(e.geometry),n(e.material));break;case"PointCloud":case"Points":a=new Et(i(e.geometry),n(e.material));break;case"Sprite":a=new vi(n(e.material));break;case"Group":a=new Dt;break;default:a=new c}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.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),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 h=e.children,d=0;d=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),e.CCDIKSolver=xu,e.MMDAnimationHelper=Su,e.MMDPhysics=_u,e.AnimationClipCreator=Au,e.CinematicCamera=Nu,e.Car=Uu,e.DeviceOrientationControls=ku,e.DragControls=Bu,e.EditorControls=zu,e.FirstPersonControls=ju,e.FlyControls=Vu,e.MapControls=Gu,e.OrbitControls=Wu,e.OrthographicTrackballControls=Xu,e.PointerLockControls=Hu,e.TrackballControls=Yu,e.TransformControls=qu,e.TransformControlsGizmo=Qu,e.TransformControlsPlane=Ju,e.ConvexObjectBreaker=$u,e.GrannyKnot=ot,e.HeartCurve=st,e.VivianiCurve=lt,e.KnotCurve=ct,e.HelixCurve=ut,e.TrefoilKnot=ht,e.TorusKnot=dt,e.CinquefoilKnot=pt,e.TrefoilPolynomialKnot=ft,e.FigureEightPolynomialKnot=mt,e.DecoratedTorusKnot4a=vt,e.DecoratedTorusKnot4b=gt,e.DecoratedTorusKnot5a=yt,e.DecoratedTorusKnot5c=xt,e.NURBSCurve=rh,e.NURBSSurface=ih,e.NURBSUtils=th,e.Detector=nh,e.AnaglyphEffect=ah,e.AsciiEffect=oh,e.OutlineEffect=gp,e.ParallaxBarrierEffect=yp,e.PeppersGhostEffect=xp,e.StereoEffect=bp,e.ColladaExporter=wp,e.GLTFExporter=Mp,e.MMDExporter=Tp,e.OBJExporter=Ep,e.PLYExporter=Cp,e.STLExporter=Lp,e.TypedGeometryExporter=Pp,e.ConvexGeometry=it,e.ConvexBufferGeometry=nt,e.DecalGeometry=wt,e.hilbert2D=St,e.hilbert3D=At,e.TeapotBufferGeometry=Np,e.GPUComputationRenderer=Tt,e.GPUParticleSystem=Op,e.GPUParticleContainer=Dp,e.Gyroscope=Fp,e.ImprovedNoise=Rp,e.Line2=zp,e.LineGeometry=Bp,e.LineMaterial=Up,e.LineSegments2=kp,e.LineSegmentsGeometry=Ip,e.Wireframe=jp,e.WireframeGeometry2=Vp,e.ThreeMFLoader=Gp,e.AMFLoader=Wp,e.AssimpJSONLoader=Xp,e.AssimpLoader=Hp,e.AWDLoader=yf,e.BabylonLoader=xf,e.BinaryLoader=Iu,e.BVHLoader=bf,e.ColladaLoader=_f,e.DDSLoader=Sf,e.LegacyGLTFLoader=Af,e.DRACOLoader=Mf,e.EquirectangularToCubeGenerator=Tf,e.EXRLoader=Ef,e.FBXLoader=Cf,e.GCodeLoader=Lf,e.GLTFLoader=Nf,e.HDRCubeTextureLoader=Ff,e.KMZLoader=Rf,e.KTXLoader=If,e.LoaderSupport=kf,e.MD2Loader=Bf,e.MMDLoader=zf,e.MTLLoader=jf,e.NodeMaterialLoader=Yf,e.OBJLoader=qf,e.OBJLoader2=Qf,e.PCDLoader=Jf,e.PDBLoader=Zf,e.PlayCanvasLoader=Kf,e.PLYLoader=$f,e.PRWMLoader=im,e.PVRLoader=nm,e.HDRLoader=Df,e.RGBELoader=Of,e.STLLoader=am,e.SVGLoader=pm,e.TDSLoader=fm,e.TGALoader=wf,e.TTFLoader=Km,e.VRMLLoader=$m,e.VRMLoader=ev,e.VTKLoader=tv,e.MarchingCubes=rv,e.ColorConverter=av,e.Lut=sv,e.MD2Character=cv,e.MD2CharacterComplex=hv,e.ExplodeModifier=dv,e.SimplifyModifier=pv,e.SubdivisionModifier=fv,e.TessellateModifier=mv,e.MorphAnimMesh=vv,e.MorphBlendMesh=uv,e.CameraNode=cr,e.ColorsNode=gi,e.LightNode=yi,e.NormalNode=nr,e.PositionNode=ir,e.ReflectNode=xi,e.ResolutionNode=Ii,e.ScreenUVNode=Ui,e.UVNode=rr,e.BlinnExponentToRoughnessNode=Ci,e.BlinnShininessExponentNode=Ei,e.RoughnessToBlinnExponentNode=Bi,e.AttributeNode=zi,e.ConstNode=lr,e.ExpressionNode=ji,e.FunctionCallNode=Vi,e.FunctionNode=Vf,e.InputNode=ar,e.Node=er,e.NodeBuilder=Ni,e.NodeFrame=Gi,e.NodeLib=Gf,e.NodeUniform=bi,e.NodeUtils=xv,e.StructNode=wi,e.TempNode=tr,e.VarNode=Wi,e.BlurNode=Xi,e.ColorAdjustmentNode=Yi,e.LuminanceNode=Hi,e.ColorNode=Oi,e.CubeTextureNode=Ti,e.FloatNode=or,e.IntNode=qi,e.Matrix3Node=Qi,e.Matrix4Node=Ji,e.PropertyNode=Zi,e.ReflectorNode=$i,e.RTTNode=en,e.ScreenNode=tn,e.TextureNode=Mi,e.Vector2Node=Ri,e.Vector3Node=_i,e.Vector4Node=Si,e.MeshStandardNodeMaterial=sn,e.NodeMaterial=Fi,e.MeshStandardNode=on,e.PhongNode=ln,e.RawNode=Di,e.SpriteNode=cn,e.StandardNode=rn,e.PhongNodeMaterial=un,e.SpriteNodeMaterial=hn,e.StandardNodeMaterial=dn,e.CondNode=pn,e.Math1Node=fn,e.Math2Node=mn,e.Math3Node=vn,e.OperatorNode=Ki,e.BumpMapNode=gn,e.NormalMapNode=an,e.TextureCubeNode=Pi,e.TextureCubeUVNode=Li,e.NodePass=yn,e.NodePostProcessing=xn, +e.CheckerNode=bn,e.NoiseNode=wn,e.BypassNode=_n,e.ColorSpaceNode=Ai,e.JoinNode=Sn,e.MaxMIPLevelNode=ki,e.SwitchNode=nn,e.TimerNode=sr,e.UVTransformNode=An,e.VelocityNode=Mn,e.Lensflare=Lv,e.LensflareElement=Pv,e.Reflector=Nv,e.ReflectorRTT=Ov,e.Refractor=Dv,e.ShadowMesh=Fv,e.Sky=Rv,e.Water=Iv,e.Water2=Cn,e.Ocean=Uv,e.Octree=kv,e.OctreeObjectData=Bv,e.OctreeNode=zv,e.PMREMCubeUVPacker=jv,e.PMREMGenerator=Vv,e.AdaptiveToneMappingPass=Hv,e.AfterimagePass=qv,e.BloomPass=Jv,e.BokehPass=Zv,e.ClearPass=Kv,e.CubeTexturePass=$v,e.DotScreenPass=tg,e.EffectComposer=ng,e.FilmPass=og,e.GlitchPass=lg,e.HalftonePass=ug,e.MaskPass=rg,e.ClearMaskPass=ig,e.OutlinePass=hg,e.Pass=Tv,e.RenderPass=dg,e.SAOPass=gg,e.SavePass=yg,e.ShaderPass=Ev,e.SMAAPass=bg,e.SSAARenderPass=wg,e.SSAOPass=Sg,e.TAARenderPass=Ag,e.TexturePass=Mg,e.UnrealBloomPass=Eg,e.PRNG=Cg,e.QuickHull=Ke,e.SpriteCanvasMaterial=Rg,e.CanvasRenderer=Ig,e.CSS2DObject=Ug,e.CSS2DRenderer=kg,e.CSS3DObject=Bg,e.CSS3DSprite=zg,e.CSS3DRenderer=jg,e.RenderableObject=Lg,e.RenderableFace=Pg,e.RenderableVertex=Ng,e.RenderableLine=Og,e.RenderableSprite=Dg,e.Projector=Fg,e.RaytracingRenderer=Vg,e.SoftwareRenderer=Gg,e.SVGObject=Wg,e.SVGRenderer=Xg,e.WebGLDeferredRenderer=iy,e.RollerCoasterGeometry=po,e.RollerCoasterLiftersGeometry=fo,e.RollerCoasterShadowGeometry=mo,e.SkyGeometry=vo,e.TreesGeometry=go,e.ShaderGodRays=sy,e.AfterimageShader=Yv,e.BasicShader=ly,e.BleachBypassShader=cy,e.BlendShader=uy,e.BokehShader=Cu,e.BokehShader2=Lu,e.BokehDepthShader=Pu,e.BrightnessContrastShader=hy,e.ColorCorrectionShader=dy,e.ColorifyShader=py,e.ConvolutionShader=Qv,e.CopyShader=Gv,e.DepthLimitedBlurShader=fg,e.BlurShaderUtils=mg,e.DigitalGlitch=sg,e.DOFMipMapShader=fy,e.DotScreenShader=eg,e.FilmShader=ag,e.FocusShader=my,e.FreiChenShader=vy,e.FresnelShader=gy,e.FXAAShader=ry,e.GammaCorrectionShader=yy,e.HalftoneShader=cg,e.HorizontalBlurShader=xy,e.HorizontalTiltShiftShader=by,e.HueSaturationShader=wy,e.KaleidoShader=_y,e.LuminosityHighPassShader=Tg,e.LuminosityShader=Wv,e.MirrorShader=Sy,e.NormalMapShader=Ay,e.ParallaxShader=My,e.PixelShader=Ty,e.RGBShiftShader=Ey,e.SAOShader=pg,e.SepiaShader=Cy,e.SMAAShader=xg,e.SobelOperatorShader=Ly,e.SSAOShader=_g,e.TechnicolorShader=Py,e.ToneMapShader=Xv,e.TriangleBlurShader=Ny,e.UnpackDepthRGBAShader=vg,e.VerticalBlurShader=Oy,e.VerticalTiltShiftShader=Dy,e.VignetteShader=Fy,e.WaterRefractionShader=Ry,e.ShaderSkin=Iy,e.ShaderTerrain=Uy,e.ShaderToon=ky,e.TranslucentShader=By,e.SimplexNoise=zy,e.TimelinerController=jy,e.TypedArrayUtils=Vy,e.UCSCharacter=Gy,e.BufferGeometryUtils=Pf,e.GeometryUtils=Wy,e.MathUtils=Xy,e.SceneUtils=Hy,e.ShadowMapViewer=Yy,e.SkeletonUtils=qy,e.UVsDebug=Qy,e.VolumeSlice=Jy,e.DaydreamController=Zy,e.GearVRController=Ky,e.PaintViveController=ex,e.ViveController=$y,e.WebVR=tx,e.AnimationAction=z,e.AnimationClip=re,e.AnimationMixer=ae,e.AnimationObjectGroup=Eo,e.AnimationUtils=wu,e.KeyframeTrack=q,e.PropertyBinding=W,e.PropertyMixer=X,e.BooleanKeyframeTrack=Q,e.ColorKeyframeTrack=J,e.NumberKeyframeTrack=Z,e.QuaternionKeyframeTrack=$,e.StringKeyframeTrack=ee,e.VectorKeyframeTrack=te,e.Audio=Co,e.AudioAnalyser=Lo,e.AudioContext=ix,e.AudioListener=Po,e.PositionalAudio=No,e.ArrayCamera=so,e.Camera=he,e.CubeCamera=Oo,e.OrthographicCamera=me,e.PerspectiveCamera=de,e.StereoCamera=bt,e.REVISION=Bs,e.MOUSE=zs,e.CullFaceNone=js,e.CullFaceBack=Vs,e.CullFaceFront=Gs,e.CullFaceFrontBack=Ws,e.FrontFaceDirectionCW=Xs,e.FrontFaceDirectionCCW=Hs,e.BasicShadowMap=Ys,e.PCFShadowMap=qs,e.PCFSoftShadowMap=Qs,e.FrontSide=Js,e.BackSide=Zs,e.DoubleSide=Ks,e.FlatShading=$s,e.SmoothShading=el,e.NoColors=tl,e.FaceColors=rl,e.VertexColors=il,e.NoBlending=nl,e.NormalBlending=al,e.AdditiveBlending=ol,e.SubtractiveBlending=sl,e.MultiplyBlending=ll,e.CustomBlending=cl,e.AddEquation=ul,e.SubtractEquation=hl,e.ReverseSubtractEquation=dl,e.MinEquation=pl,e.MaxEquation=fl,e.ZeroFactor=ml,e.OneFactor=vl,e.SrcColorFactor=gl,e.OneMinusSrcColorFactor=yl,e.SrcAlphaFactor=xl,e.OneMinusSrcAlphaFactor=bl,e.DstAlphaFactor=wl,e.OneMinusDstAlphaFactor=_l,e.DstColorFactor=Sl,e.OneMinusDstColorFactor=Al,e.SrcAlphaSaturateFactor=Ml,e.NeverDepth=Tl,e.AlwaysDepth=El,e.LessDepth=Cl,e.LessEqualDepth=Ll,e.EqualDepth=Pl,e.GreaterEqualDepth=Nl,e.GreaterDepth=Ol,e.NotEqualDepth=Dl,e.MultiplyOperation=Fl,e.MixOperation=Rl,e.AddOperation=Il,e.NoToneMapping=Ul,e.LinearToneMapping=kl,e.ReinhardToneMapping=Bl,e.Uncharted2ToneMapping=zl,e.CineonToneMapping=jl,e.UVMapping=Vl,e.CubeReflectionMapping=Gl,e.CubeRefractionMapping=Wl,e.EquirectangularReflectionMapping=Xl,e.EquirectangularRefractionMapping=Hl,e.SphericalReflectionMapping=Yl,e.CubeUVReflectionMapping=ql,e.CubeUVRefractionMapping=Ql,e.RepeatWrapping=Jl,e.ClampToEdgeWrapping=Zl,e.MirroredRepeatWrapping=Kl,e.NearestFilter=$l,e.NearestMipMapNearestFilter=ec,e.NearestMipMapLinearFilter=tc,e.LinearFilter=rc,e.LinearMipMapNearestFilter=ic,e.LinearMipMapLinearFilter=nc,e.UnsignedByteType=ac,e.ByteType=oc,e.ShortType=sc,e.UnsignedShortType=lc,e.IntType=cc,e.UnsignedIntType=uc,e.FloatType=hc,e.HalfFloatType=dc,e.UnsignedShort4444Type=pc,e.UnsignedShort5551Type=fc,e.UnsignedShort565Type=mc,e.UnsignedInt248Type=vc,e.AlphaFormat=gc,e.RGBFormat=yc,e.RGBAFormat=xc,e.LuminanceFormat=bc,e.LuminanceAlphaFormat=wc,e.RGBEFormat=_c,e.DepthFormat=Sc,e.DepthStencilFormat=Ac,e.RGB_S3TC_DXT1_Format=Mc,e.RGBA_S3TC_DXT1_Format=Tc,e.RGBA_S3TC_DXT3_Format=Ec,e.RGBA_S3TC_DXT5_Format=Cc,e.RGB_PVRTC_4BPPV1_Format=Lc,e.RGB_PVRTC_2BPPV1_Format=Pc,e.RGBA_PVRTC_4BPPV1_Format=Nc,e.RGBA_PVRTC_2BPPV1_Format=Oc,e.RGB_ETC1_Format=Dc,e.RGBA_ASTC_4x4_Format=Fc,e.RGBA_ASTC_5x4_Format=Rc,e.RGBA_ASTC_5x5_Format=Ic,e.RGBA_ASTC_6x5_Format=Uc,e.RGBA_ASTC_6x6_Format=kc,e.RGBA_ASTC_8x5_Format=Bc,e.RGBA_ASTC_8x6_Format=zc,e.RGBA_ASTC_8x8_Format=jc,e.RGBA_ASTC_10x5_Format=Vc,e.RGBA_ASTC_10x6_Format=Gc,e.RGBA_ASTC_10x8_Format=Wc,e.RGBA_ASTC_10x10_Format=Xc,e.RGBA_ASTC_12x10_Format=Hc,e.RGBA_ASTC_12x12_Format=Yc,e.LoopOnce=qc,e.LoopRepeat=Qc,e.LoopPingPong=Jc,e.InterpolateDiscrete=Zc,e.InterpolateLinear=Kc,e.InterpolateSmooth=$c,e.ZeroCurvatureEnding=eu,e.ZeroSlopeEnding=tu,e.WrapAroundEnding=ru,e.TrianglesDrawMode=iu,e.TriangleStripDrawMode=nu,e.TriangleFanDrawMode=au,e.LinearEncoding=ou,e.sRGBEncoding=su,e.GammaEncoding=lu,e.RGBEEncoding=cu,e.LogLuvEncoding=uu,e.RGBM7Encoding=hu,e.RGBM16Encoding=du,e.RGBDEncoding=pu,e.BasicDepthPacking=fu,e.RGBADepthPacking=mu,e.TangentSpaceNormalMap=vu,e.ObjectSpaceNormalMap=gu,e.Float64BufferAttribute=T,e.Float32BufferAttribute=M,e.Uint32BufferAttribute=A,e.Int32BufferAttribute=S,e.Uint16BufferAttribute=_,e.Int16BufferAttribute=w,e.Uint8ClampedBufferAttribute=b,e.Uint8BufferAttribute=x,e.Int8BufferAttribute=y,e.BufferAttribute=g,e.BufferGeometry=P,e.Clock=En,e.DirectGeometry=E,e.EventDispatcher=a,e.Face3=h,e.Geometry=m,e.InstancedBufferAttribute=Do,e.InstancedBufferGeometry=Ct,e.InstancedInterleavedBuffer=Pt,e.InterleavedBuffer=Lt,e.InterleavedBufferAttribute=Nt,e.Layers=s,e.Object3D=c,e.Raycaster=je,e.Uniform=ho,e.Curve=at,e.CurvePath=Fr,e.Font=Fo,e.CatmullRom=gr,e.QuadraticBezier=wr,e.CubicBezier=Tr,e.Path=Rr,e.Shape=Ir,e.ShapePath=pi,e.ArcCurve=fr,e.CatmullRomCurve3=vr,e.CubicBezierCurve=Er,e.CubicBezierCurve3=Cr,e.EllipseCurve=pr,e.LineCurve=Lr,e.LineCurve3=Pr,e.QuadraticBezierCurve=Nr,e.QuadraticBezierCurve3=Or,e.SplineCurve=Dr,e.Earcut=hm,e.ImageUtils=Tu,e.ImmediateRenderObject=fi,e.ShapeUtils=dm,e.BoxGeometry=se,e.BoxBufferGeometry=le,e.CircleGeometry=bo,e.CircleBufferGeometry=wo,e.ConeGeometry=Uo,e.ConeBufferGeometry=ko,e.CylinderGeometry=ce,e.CylinderBufferGeometry=ue,e.DodecahedronGeometry=Bo,e.DodecahedronBufferGeometry=zo,e.EdgesGeometry=jo,e.ExtrudeGeometry=Vo,e.ExtrudeBufferGeometry=Go,e.IcosahedronGeometry=_o,e.IcosahedronBufferGeometry=So,e.LatheGeometry=Xo,e.LatheBufferGeometry=Ho,e.OctahedronGeometry=Ye,e.OctahedronBufferGeometry=qe,e.ParametricGeometry=Yo,e.ParametricBufferGeometry=qo,e.PlaneGeometry=ye,e.PlaneBufferGeometry=xe,e.PolyhedronGeometry=Xe,e.PolyhedronBufferGeometry=He,e.RingGeometry=Qo,e.RingBufferGeometry=Jo,e.ShapeGeometry=Ao,e.ShapeBufferGeometry=Mo,e.SphereGeometry=N,e.SphereBufferGeometry=O,e.TetrahedronGeometry=Zo,e.TetrahedronBufferGeometry=Ko,e.TextGeometry=$o,e.TextBufferGeometry=es,e.TorusGeometry=Qe,e.TorusBufferGeometry=Je,e.TorusKnotGeometry=ts,e.TorusKnotBufferGeometry=rs,e.TubeGeometry=is,e.TubeBufferGeometry=ns,e.WireframeGeometry=Ot,e.ArrowHelper=as,e.AxesHelper=os,e.Box3Helper=ss,e.BoxHelper=Ln,e.CameraHelper=ls,e.DirectionalLightHelper=cs,e.FaceNormalsHelper=us,e.GridHelper=hs,e.HemisphereLightHelper=ds,e.PlaneHelper=ps,e.PointLightHelper=fs,e.PolarGridHelper=ms,e.RectAreaLightHelper=vs,e.SkeletonHelper=xo,e.SpotLightHelper=gs,e.VertexNormalsHelper=ys,e.AmbientLight=Ht,e.DirectionalLight=Vt,e.DirectionalLightShadow=jt,e.HemisphereLight=Xt,e.Light=kt,e.LightShadow=Bt,e.PointLight=zt,e.RectAreaLight=xs,e.SpotLight=Wt,e.SpotLightShadow=Gt,e.AnimationLoader=bs,e.AudioLoader=ws,e.BufferGeometryLoader=_s,e.Cache=Ou,e.CompressedTextureLoader=Qt,e.CubeTextureLoader=Ss,e.DataTextureLoader=Kt,e.FileLoader=we,e.FontLoader=As,e.ImageBitmapLoader=Ms,e.ImageLoader=Ie,e.JSONLoader=Be,e.Loader=ke,e.LoaderUtils=Ru,e.DefaultLoadingManager=Du,e.LoadingManager=be,e.MaterialLoader=Re,e.ObjectLoader=Ls,e.TextureLoader=Ue,e.LineBasicMaterial=R,e.LineDashedMaterial=_e,e.Material=D,e.MeshBasicMaterial=F,e.MeshDepthMaterial=Se,e.MeshDistanceMaterial=Ae,e.MeshLambertMaterial=Me,e.MeshNormalMaterial=Te,e.MeshPhongMaterial=Ee,e.MeshPhysicalMaterial=Le,e.MeshStandardMaterial=Ce,e.MeshToonMaterial=Pe,e.PointsMaterial=Ne,e.RawShaderMaterial=Oe,e.ShaderMaterial=pe,e.ShadowMaterial=De,e.SpriteMaterial=Fe,e.Box2=Tn,e.Box3=d,e.Color=u,e.Cylindrical=Ps,e.Euler=o,e.Frustum=In,e.Interpolant=j,e.CubicInterpolant=H,e.DiscreteInterpolant=Y,e.LinearInterpolant=V,e.QuaternionLinearInterpolant=K,e.Line3=Ze,e._Math=Fs,e.Matrix3=l,e.Matrix4=r,e.Plane=ze,e.Quaternion=n,e.Ray=I,e.Sphere=p,e.Spherical=We,e.Triangle=U,e.Vector2=f,e.Vector3=i,e.Vector4=v,e.Bone=oe,e.Group=Dt,e.Line=B,e.LineLoop=Jt,e.LineSegments=Yt,e.LOD=Ts,e.Mesh=k,e.Points=Et,e.Skeleton=Ft,e.SkinnedMesh=Rt,e.Sprite=vi,e.ShaderChunk=fp,e.ShaderLib=vp,e.UniformsLib=mp,e.UniformsUtils=Mu,e.WebGLAnimation=Un,e.WebGLAttributes=kn,e.WebGLBackground=Bn,e.WebGLBufferRenderer=zn,e.WebGLCapabilities=jn,e.WebGLClipping=Vn,e.WebGLExtensions=Gn,e.WebGLGeometries=Wn,e.WebGLIndexedBufferRenderer=Xn,e.WebGLInfo=Hn,e.WebGLLights=eo,e.WebGLMorphtargets=qn,e.WebGLObjects=Qn,e.WebGLProgram=Ha,e.WebGLPrograms=Ya,e.WebGLProperties=qa,e.WebGLRenderLists=Ka,e.WebGLRenderStates=ro,e.WebGLShader=Da,e.WebGLShadowMap=io,e.WebGLState=no,e.WebGLTextures=ao,e.WebGLUniforms=Na,e.WebGLUtils=oo,e.WebGL2Renderer=Ns,e.WebGLRenderer=uo,e.WebGLRenderTarget=ge,e.WebGLRenderTargetCube=Zt,e.WebVRManager=lo,e.WebXRManager=co,e.Fog=Es,e.FogExp2=Cs,e.Scene=fe,e.CanvasTexture=mi,e.CompressedTexture=qt,e.CubeTexture=$t,e.DataTexture=Mt,e.DepthTexture=Rn,e.Texture=ve,e.VideoTexture=Os,e.arrayMin=C,e.arrayMax=L}()}),require.register("js/components/Bean.js",function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r=0;)e=this._listeners[t],e&&e.apply(this,null);this._idRAF=requestAnimationFrame(this._binds.update)}},{key:"start",value:function(){this._update()}},{key:"stop",value:function(){cancelAnimationFrame(this._idRAF)}},{key:"add",value:function(e){var t=this._listeners.indexOf(e);t>=0||(this._listeners.push(e),this._count++)}},{key:"remove",value:function(e){var t=this._listeners.indexOf(e);t<0||(this._listeners.splice(t,1),this._count--)}}]),e}();r.exports=new a}),require.register("js/core/Webgl.js",function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r Brunch - Three.js - es6 +